Marble/OSMVectorTileCreation: Difference between revisions

From KDE TechBase
No edit summary
(Adds several small paragraphs to help users resolve common errors that occur when running the tile creator)
Line 68: Line 68:
</source>
</source>
The four numbers of the bounding box passed with the -b=... parameter can be obtained from the [https://www.openstreetmap.org/export#map=15/49.0139/8.4072 OSM export tool] in the order left, bottom, right, top.
The four numbers of the bounding box passed with the -b=... parameter can be obtained from the [https://www.openstreetmap.org/export#map=15/49.0139/8.4072 OSM export tool] in the order left, bottom, right, top.
=== Resolving errors ===
If you get a segmentation fault after the tile creation downloaded the cache files, the most probably cause it that you are missing one or several dependencies.
To find the missing dependencies, examine the first few lines of cmake when generating the Makefile. They should contain a list of dependencies needed, with a note if it was found or not. You probably got a critical warning that stated that shapelib (libshp) was missing. Installing all those dependencies should fix the segmentation fault.
Here, the packages libgps and libwlocate are missing, and should be installed in addition to libshp.
<source lang="bash">
$ cmake -DBUILD_MARBLE_TOOLS=TRUE ../marble
-- Could NOT find libgps (missing:  LIBGPS_INCLUDE_DIR LIBGPS_LIBRARIES)
-- Could NOT find libwlocate (missing:  LIBWLOCATE_INCLUDE_DIR LIBWLOCATE_LIBRARIES)
--
-- The following features have been enabled:
* Unit tests , Build unit tests. Toggle with BUILD_MARBLE_TESTS=YES/NO. 'make test' will run all.
* Qt Designer plugins , Marble widget support in Qt Designer. Toggle with WITH_DESIGNER_PLUGIN=YES/NO
* Marble Desktop/Mobile applications , Build Marble Desktop/Mobile applications. Toggle with BUILD_MARBLE_APPS=YES/NO.
* Marble tools , Build various Marble tools for e.g. file format conversion. Toggle with BUILD_MARBLE_TOOLS=YES/NO.
[...]
</source>

Revision as of 19:07, 8 January 2017

OSM Vector Tiles

Creating tiles from a pbf file

As an example we'd like to render tiles for tile level 13, 15 and 17 of San Francisco. First you need the osm.pbf file for that region. In our case we get it from:

http://download.geofabrik.de/north-america/us/california.html

where we locate the link to the pbf file as http://download.geofabrik.de/north-america/us/california-latest.osm.pbf

Creating the tools - osmconvert and marble-vectorosm-tilecreator

Now we need the tools for conversion and filtering the pbf file into tiles. In order to compile the tools you should have zlib installed on your system (e.g. via sudo apt-get install zlib1g-dev). Then run:

cd /tmp
wget http://m.m.i24.cc/osmconvert.c
gcc -O3 -o osmconvert osmconvert.c -lz
sudo mv osmconvert /usr/local/bin

if that works, running

osmconvert -h

should output usage instructions.

Please compile Marble from source code as well as described in https://marble.kde.org/sources.php and make sure to compile the development version (master branch). Pass the option -DBUILD_MARBLE_TOOLS=TRUE to cmake in order to compile all Marble tools.

Running the VectorTileCreator

Now our tool is needed. In a shell, go to the marble build directory and then

cd tools/vectorosm-tilecreator

now running

./marble-vectorosm-tilecreator -h

should give usage instructions.

The tile cutter tool works as follows: You call it with a link to an osm .pbf file as parameter.

The tool will generate tiles for zoom levels 11, 13, 15 and 17 by default. You can overwrite that using the -z switch, e.g. -z 13 15.

Full Example

If you follow the steps above, the final tile creation run after installing the required tools will look like this:

cd ~/marble/build/
cd tools/vectorosm-tilecreator
./marble-vectorosm-tilecreator http://download.geofabrik.de/north-america/us/california-latest.osm.pbf
 [========================================>]  100%  734.4/734.4 MB  Downloading california-latest.osm.pbf
 [========================================>]  100%  0.0/0.0 MB  Downloading california.poly
 [========================================>]  100%  osm cache tiles complete.
 [========================================>]  100%  landmass cache tiles complete.                    
 [========================================>]  100%  Vector OSM tiles complete.

Smaller Regions

For large countries the tile creation can take several hours or even days. If you're just interested in a certain region (say, a city), you can preprocess the pbf and extract the region you're interested in. Use osmconvert for that like this:

osmconvert --complex-ways --complete-ways -b=8.3735,49.0016,8.4409,49.0261 -o=smallregion.pbf largeregion.pbf
./marble-vectorosm-tilecreator smallregion.pbf

The four numbers of the bounding box passed with the -b=... parameter can be obtained from the OSM export tool in the order left, bottom, right, top.

Resolving errors

If you get a segmentation fault after the tile creation downloaded the cache files, the most probably cause it that you are missing one or several dependencies.

To find the missing dependencies, examine the first few lines of cmake when generating the Makefile. They should contain a list of dependencies needed, with a note if it was found or not. You probably got a critical warning that stated that shapelib (libshp) was missing. Installing all those dependencies should fix the segmentation fault.

Here, the packages libgps and libwlocate are missing, and should be installed in addition to libshp.

$ cmake -DBUILD_MARBLE_TOOLS=TRUE ../marble
-- Could NOT find libgps (missing:  LIBGPS_INCLUDE_DIR LIBGPS_LIBRARIES) 
-- Could NOT find libwlocate (missing:  LIBWLOCATE_INCLUDE_DIR LIBWLOCATE_LIBRARIES) 
-- 
-- The following features have been enabled:

 * Unit tests , Build unit tests. Toggle with BUILD_MARBLE_TESTS=YES/NO. 'make test' will run all.
 * Qt Designer plugins , Marble widget support in Qt Designer. Toggle with WITH_DESIGNER_PLUGIN=YES/NO
 * Marble Desktop/Mobile applications , Build Marble Desktop/Mobile applications. Toggle with BUILD_MARBLE_APPS=YES/NO.
 * Marble tools , Build various Marble tools for e.g. file format conversion. Toggle with BUILD_MARBLE_TOOLS=YES/NO.
[...]