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

3

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

    
asked by anonymous 16.06.2016 / 03:11

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 transform GML into SVG (using XSLT + java.xml.transform) and send it to the client (embedded or not in HTML) or send GeoJSON to the client to build the SVG (in this case in JavaScript, using D3.js or some similar library).

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

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

At the client, you will need to draw the map. D3.js offers features for extracting GeoJSON properties (such as county name), geographic projections, and various functions that convert GeoJSON polygons to SVG paths, which are drawn on the screen and you can paint and set using CSS.

This tutorial explains everything from how to convert SHP to GeoJSON to creating a map with D3.js. It also shows you how to optimize (since GeoJSON files are often very large) using the Topojson.js library)

    
11.07.2016 / 04:02