seandepagnier / mbtiles-nautical-tools

tools for manipulating and converting mbtiles for nautical purposes
9 stars 1 forks source link

This collection of scripts and programs is intended to be used to facilitate mbtiles for nautical charting purposes

==== Requirements ==== convert from imagemagick libpng-dev libfreeimage-dev mapproxy

pypng mbutil landez

==== Building ==== $ git clone https://github.com/seandepagnier/imgkap.git $ sudo make -C imgkap install

$ git clone https://github.com/mapbox/mbutil.git $ cd mbutil $ sudo python setup.py install $ cd ..

$ git clone https://github.com/seandepagnier/landez.git $ sudo easy_install landez

$ sudo easy_install pypng

$ pip install cffi

$ make $ sudo make install

==== Example ====

First browse to a tms server in firefox, with ctrl+shift+c enter debugger and select networking tab. Now browse the areas in the map to store. Right click the debugger and save all as HAR.

Now run the script har2mbtiles to create an mbtiles in xyz format

If you have mbtiles in xyz format.

1) Filter Tiles (Optional)

You can use the scripts to filter, recolor etc This example makes compression much less for nautical charts:

$ wget -c https://s32.postimg.org/ea7daiwp1/subneg.png $ mbtilessub.sh nautical-17.mbtiles nautical-17-sub.mbtiles subneg.png

2) Convert to kap mbtiles2kaps.py nautical-17-sub.mbtiles nautical mbtiles-nautical-boxes/boxes/nautical-17

==== Tools ====

mbtiles2kaps.py: generates kaps from a given mbtiles database

kap2mbtiles.py: convert a single kap file to mbtiles database

If the output mbtiles already exists, the kap will be inserted
possibly overwritting existing overlapping chart tiles.
For this reason, when converting a set of kaps to a single
mbtiles database, they should be inserted in order from the
smallest to largest scale

mbtilesrecolor.sh: Apply a color matrix to every tile in mbtiles This can apply "color schemes" such as day/dusk/night to charts

mbtilessub.sh: can remove identical features (if present) in every tile of an mbtiles This is useful to reduce the size of the resulting mbtiles as it will compress better without this feature, relies on subpng.c and needs a mask tile (typically inverted white tile containing the feature)

mbtilesreduce.sh: tiles to 8bit png reducing the size of mbtiles to a given number of colors this can greatly reduce the size of the mbtiles database, but should not be done before converting to kap as the kap conversion will calculate a palette per chart (rather than per tile which is what is here) and if the tiles already have a low-color palette, the resulting kaps will be of lower quality and larger in size

har2mbtiles.py: Convert http archive into mbtiles database

mbtilesflip.sh: Simply flips y values in mbtiles, so converts from tms to wmts This is useful if the mbfiles is obtained in wmts

mbtiles2kap.sh: (obsolete not recommended) script that converts from mbtiles to single kap it makes various assumptions and will fail on mbtiles that do not form a complete rectangle at a specific zoom level

Note: the shell scripts create a working directory "output" which may be left behind in the event of a failure you may not run two tools in the same working directory