2

I am relatively very new to building GIS based applications and have a very limited understanding in this area. So I need some help in building a java based desktop application which would generate map tiles on the fly for a given tile coordinates (zoom level, x and y coordinate of the tile). I could build a reasonable solution using the below procedure using postgresql/postgis and geotools APIs. But now my client wants me to use the embedded database instead of postgresql/postgis since that eliminates the database administration.

Here is what I have done so far:

  1. Downloaded osm data and used osm2pgsql tool to populated the required osm tables in posgresql/postgis data.
  2. I have used mapnik's SLD files to style the map objects (openstreetmap.org serves the tiles generated by mapnik). I have used mapnik to generate the SQL script that populates the map objects tables in posgresql/postgis database using osm tables in step 1 and the SLD files that can be used by geotools API to syle the objects. By map objects, I mean objects like roads, buildings, addresses etc which are map features that get loaded into each layer of the map.
  3. geotools has APIs (StreamingRenderer) to generate the raster image of the bounding box that corresponds to a given tile coordinate. The generated raster image gets served as the tile.

I have started exploring spatialite (spatial extension to sqlite) since I found that geotools has a plugin for spatialite which will load the map objects into the map. I am able to load the OSM data into spatialite tables using the spatialite-tool "spatialite_osm_map". Looking at the tables generated in spatialite, it seems like all map objects got populated. But I am not sure how to render these map objects of spatialite. I am not able to use the SLD files that were meant for postgis map objects. I would want to leverage the styling done for postgis, but that does not seem to be possible. I have googled quite a bit and did not find anyone using SLD files to style the spatialite map objects. Typically one uses desktop application such as QGIS to show the map objects of spatialite. The spatialite 4.1.0 has started supporting SLD styling, but that version is not compatible with geotools plugin for spatialite which relies on version 2.4.0.

So with all these constraints, I guess I need to adopt entirely different approach of using embedded database. May be some other embedded databases. I looked at this discussion in this site, but among all of them I found spatialite to be more popular and being actively used and hence started exploring it. Has anyone used any other embedded database to solve this kind of problem? Can someone please guide me through this? That would be really helpful and highly appreciated. Any alternate approaches, thoughts are most welcome.

I guess one way could be storing the already generated tiles in sqlite (conforming to MBtiles spec)? But that may not be acceptable by my client since he wants tiles to be generated on the fly.

@BradHards - Ok, I will try to be more specific. I would like use a embedded database (for e.g. spatialite) in my java desktop application to store the map data (osm data) instead of postgis/postgresql and be able to generate the tile on the fly for a given tile coordinate using the stored map data. The generated tile should look similar to what one sees in openstreetmap.org. Any suggestions to achieve this workflow?

It seems QGIS does not out of the box support for java based on this discussion.

I did look at spatiliate link that you mentioned - The SLD styling is supported in spatialite 4.1.0 and the geotools-spatialite plugin which I am presently using is compatible with spatialite 2.4.0. However I can go ahead and use spatialite 4.1.0, but I did not find any java framework that can possibly help me in achieving the workflow of reading the map data and generate tiles similar to openstreetmap.

@blah238 - Thanks for the pointer. I will take dig at uDig and see if Neo4j spatial can be used in my case.

Regarding on-the-fly generation of tiles - My client does not want to store all the tiles for various zoom levels (required zoom level is around 20) in the database or file system since that would be a huge data to be stored and is impracticable for him.

closed as too broad by neogeomat, Vince, BERA, nmtoken, whyzar Apr 18 '18 at 11:36

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    Welcome to gis.SE. Your question is too vague / general to provide a useful answer (and invites too much subjective opinion). However you might like to just use a customised version of QGIS. Have you tried that? Have you looked at gaia-gis.it/fossil/libspatialite/wiki?name=SLD/SE+Styling – BradHards Nov 1 '13 at 6:42
  • You might also consider customizing uDig and using Neo4j Spatial as an embedded DB. – blah238 Nov 1 '13 at 7:44
  • Can you explain why your client wants to have tiles generated on the fly in a desktop app? Why not just render to the display directly from the database? – blah238 Nov 1 '13 at 7:50
  • Why generate tiles at all though? (in response to your most recent edit) – blah238 Nov 1 '13 at 16:50