I've been working for a couple of days to get offline map tiles working for use in JXMapviewer2 but I am having trouble when using generate_tiles_multiprocess.py to process the tiles.
My intention is to allow JXMapviewer2 to process it's background tiles offline for a java project I'm working on. Online tiles work but not on the specific network that it is going to be implemented on.
My progress so far;
- Download and install PostgreSQL with PostGIS database.
- Update pg_hba.conf to trust
- Download osm2pgsql and load pbf file into database using openstreetmap-carto. My tables are; planet_osm* line, nodes, point, polygon, rels, roads, ways and then pointcloud_formats, spatial_ref_sys.
osm2pgsql -k -c -S openstreetmap-carto.style -d gis -U postgres new-zealand-latest.osm.pbf
- Edit carto project.mml to contain PostGIS connection info
- Download and place shapefiles in correct carto directory
- Generate XML file and remove font references
carto project.mml > osm.xml
- Update generate_tiles_multiprocess.py to point to my osm.xml file and tile_dir. Include bbox and zoom levels.
if __name__ == "__main__":
#home = os.environ['$HOME']
try:
mapfile = os.environ['MAPNIK_MAP_FILE']
except KeyError:
mapfile = 'C:/Mapnik Tiles/osm_tiles/openstreetmap-carto-master/osm.xml'
try:
tile_dir = os.environ['MAPNIK_TILE_DIR']
except KeyError:
tile_dir = 'C:/Mapnik Tiles/osm_tiles/openstreetmap-carto-master/tiles/'
if not tile_dir.endswith('/'):
tile_dir = tile_dir + '/'
#-------------------------------------------------------------------------
# Change the following for different bounding boxes and zoom levels
#
# Start with an overview
# NZ
bbox = (166.245, -47.339, 178.660, -33.943)
render_tiles(bbox, mapfile, tile_dir, 0, 18, "World")
Run generate_tiles_multiprocess.py
This is where I have the issues. The folder structure gets created, eg. 0, 1, 2 etc but no tiles are created. The console output displays multiple lines of "* attribute 'repeat-distance' with value '50' at line 39259" and sits. (more than 999 lines of this with varying line references) I then have to Keyboard interrupt to get back to command line.
If I use generate_image.py it creates a map of New Zealand and shows the same attribute lines as above.
Is it a case of leaving it to create the tiles?
I've left it for 10 minutes with no images being output.
JXMapviewer2 java example code;
// Create a zip-file based TileFactoryInfo for OpenStreetMap
// See https://docs.oracle.com/javase/8/docs/api/java/net/JarURLConnection.html for URL syntax details
// You can create such a ZIP file by zipping the content of ${HOME}/.jxmapviewer2/tile.openstreetmap.org
// The ZIP file should contain a list of folders (0, 1, 2, 3 ...) that represent the OSM path structure
TileFactoryInfo info = new OSMTileFactoryInfo("ZIP archive", "C:/Mapnik Tiles/osm_tiles/openstreetmap-carto-master/tiles/tiles.zip!");