Difference between revisions of "Marble/OSMVectorTileCreation"

Jump to: navigation, search
(Adds several small paragraphs to help users resolve common errors that occur when running the tile creator)
(Resolving errors)
 
Line 70: Line 70:
  
 
=== Resolving errors ===
 
=== 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.
+
If you get an error message after the tile creation downloaded the cache files, a likely cause is that you are missing the shapelib (libshp) dependency. It's an optional dependency of Marble, but a required dependency for vector tile creation.
  
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.
+
To check whether shapelib (libshp) was found, examine the first few lines of cmake. They should contain a list of dependencies needed, with a note if it was found or not. You might get a warning that shapelib (libshp) is missing. Installing it and recompiling Marble will then fix the error.
  
Here, the packages libgps and libwlocate are missing, and should be installed in addition to libshp.
+
In the example cmake output below, the optional packages libgps and libwlocate are missing, but shapelib (libshp) is found after installing it using the package manager of the Linux distribution:
 
<source lang="bash">
 
<source lang="bash">
 
$ cmake -DBUILD_MARBLE_TOOLS=TRUE ../marble
 
$ cmake -DBUILD_MARBLE_TOOLS=TRUE ../marble
Line 80: Line 80:
 
-- Could NOT find libwlocate (missing:  LIBWLOCATE_INCLUDE_DIR LIBWLOCATE_LIBRARIES)  
 
-- Could NOT find libwlocate (missing:  LIBWLOCATE_INCLUDE_DIR LIBWLOCATE_LIBRARIES)  
 
--  
 
--  
-- The following features have been enabled:
+
-- The following OPTIONAL packages have been found:
 
+
[...]
* Unit tests , Build unit tests. Toggle with BUILD_MARBLE_TESTS=YES/NO. 'make test' will run all.
+
  * libshp , reading and writing of ESRI Shapefiles (.shp) , <http://shapelib.maptools.org/>
  * Qt Designer plugins , Marble widget support in Qt Designer. Toggle with WITH_DESIGNER_PLUGIN=YES/NO
+
  reading and displaying .shp files
* 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>
 
</source>

Latest revision as of 19:38, 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 an error message after the tile creation downloaded the cache files, a likely cause is that you are missing the shapelib (libshp) dependency. It's an optional dependency of Marble, but a required dependency for vector tile creation.

To check whether shapelib (libshp) was found, examine the first few lines of cmake. They should contain a list of dependencies needed, with a note if it was found or not. You might get a warning that shapelib (libshp) is missing. Installing it and recompiling Marble will then fix the error.

In the example cmake output below, the optional packages libgps and libwlocate are missing, but shapelib (libshp) is found after installing it using the package manager of the Linux distribution:

$ 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 OPTIONAL packages have been found:
[...]
 * libshp , reading and writing of ESRI Shapefiles (.shp) , <http://shapelib.maptools.org/>
   reading and displaying .shp files
[...]

This page was last modified on 8 January 2017, at 19:38. Content is available under Creative Commons License SA 4.0 unless otherwise noted.