1

We have a Java Application deployed on Tomcat. There is a PostgreSQL database with PostGIS extension enabled. We have both geometries and geo-points in the database.

We have a backend thread that generates PDF reports asynchronously (when requested). We now want to add maps to the PDFs (based on the geometries) with geo-points plotted.

How can we get access to the necessary map tiles for the PDF from Java? There is always Internet access from Tomcat, but, obviously, no browser or JavaScript interpreter available.

Added We have found something that suggests installing our own OSM Map Tile Server and using that. Are there any other options that do not require us to install our own Map Tile Server?

2

The simplest solution is to use any WMS server to read the database and render a map as an image that you can include in your PDF generator. I would recommend GeoServer since it is easy to set up and will run in your existing tomcat service.

Alternatively, you could create a custom Java program using GeoTools which is the library that GeoServer is built with. It gives you easy access to the PostGIS database and a renderer which can draw to a Graphics2D object if that is available in your PDF package.

Update

GeoTools has a TileClient module that can read and render OSM & Bing tiles from remote servers. I think this will solve your problem.

  • When you say "read the database" are you assuming that we have installed a local Map Tile Server (e.g. GeoServer with OSM data)? I am curious if there are other options without us having to install our own Map Tile Server? I will clarify this in the question. – Ask613 Nov 30 '17 at 14:04
  • No, in both cases I'm assuming that you only want to draw your own data from PostGIS. You could add any data you liked to GeoServer – Ian Turton Nov 30 '17 at 14:15
  • Sorry - I am confused. In our database all we have are some geometries. What we need is the maps associated with those geometries so that we can show the geometry on a actual map in the PDF. From your answer I am not sure from which server we get the map tiles. – Ask613 Nov 30 '17 at 14:26
  • In the first case, you would need to add base mapping to GeoServer. In the second you could import tiles from any public service using the TiledClient – Ian Turton Nov 30 '17 at 14:32
  • Sorry - let me clarify again. The desire is that we use an external Map Tile Server like Google, Mapbox, Bing Maps, OSM, etc. Is there a Java library that would enable that? – Ask613 Nov 30 '17 at 19:24

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.