How can I get the data from PostgreSQL db and display on map using GetMapRequest?

  • I have done connecting the PostgreSQL db which contains the geometry data.
  • Now I want to redirect that data to map using GetMapRequest from my Java code.
  • As GetMapRequest returns a raster image in response. So, how it would be done using the GetMapRequest in Java?
  • 1
    have a look at GeoTools – Ian Turton Jul 30 '18 at 8:57
  • @IanTurton Can i use the geotools GetMapRequest service to get the vector data and display it on map? Is it possible? – user3120327 Jul 30 '18 at 10:13
  • 1
    If it must be vector data then you need a WFS (which GeoTools can do) as getMapRequest is a WMS call and will return an image. GeoTools will talk directly to your postgis db too. Please edit your question to narrow it down – Ian Turton Jul 30 '18 at 10:36
  • @IanTurton I actually want to return the image by sending a getMapRequest to my postgisdb which contains the vector data. Any possible way for doing that? – user3120327 Jul 30 '18 at 11:12
  • please edit your question to make it clearer – Ian Turton Jul 30 '18 at 11:16

You seem confused about how GeoTools works, you can make a getMap request using the gt-wms module to fetch an image of a map from a WMS server (like GeoServer, MapServer or QgisServer). If you are more interested in actual vectors then you could use the gt-wfs-ng module to make a getFeatures request to a WFS server (all the previous mentioned servers support WFS too).

However if you want to fetch vector data from a datastore (e.g. PostGIS, Oracle, Shapefiles, GeoJSON files etc) you will need to create a datastore of the relevant type. This will allow your program to read the data and allow you to carry out analysis or renderer it to a map. The GeoTools quickstart tutorial covers this.

However, from your other questions, I suspect you are trying to write a new WMS server from scratch in which case you will need to fetch the data from PostGIS (using a PostGIS datastore), reproject (CRS modules) it if necessary and then render it to an image (see the rendering module) having taken any styling into account (see the styling module). You will also need to write some code to parse and understand the WMS getMap requests that you receive (for some pointers you can look at GeoServer's GetMapKvpRequestReader).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.