How to bring the content of a postgis query to a JSP page?

Asked

Viewed 183 times

3

I have postgis with a database that I downloaded from ibge and I need to make a javaweb application that reads the name of a municipality and brings back the data in svg format and displays the region passed as a parameter on the screen.How could I do that? Could someone give me a tutorial?

1 answer

2


You should export your map as an open format that can be read in Java, such as Geojson or GML. You can generate the SVG on the server. For this you can turn GML into SVG (using XSLT + java.xml.Transform) and send it to the client (embedded or not in an HTML) or send Geojson to the client to build the SVG (in this case, in Javascript, using the D3.js or some similar library).

Although they are XML formats, the conversion of GML into SVG is not so trivial (XSLT is not a very simple language to use, and the conversion of coordinates into instructions path SVG is not simple and there may be quality loss.)

Nowadays the most popular solution is to convert to Geojson and process in client. In this case, you need to export your map (probably files in the format *.SHP) in Geojson. If your version of Postgis does not do this, you can download the latest QGIS, or use the GDAL/OGR tools who do this on the command line or in Java.

In the client, you will need to draw the map. D3.js provides resources to extract Geojson properties (for example, municipality name), geographical projections, and various functions that convert Geojson polygons into SVG paths, which are drawn on the screen and you can paint and configure using CSS.

This tutorial explains how to convert SHP to Geojson until creating a map with D3.js. It also shows how to optimize (since Geojson files are usually very large) using the library Topojson.js)

  • Thank you very much for your attention, I will check all the llinks, and in the future, if I can’t solve , I put my code here, then you can make an analysis.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.