It's pretty simple: you define a source and a destination - and a callback which gets called with a deserialized tile object as soon as the async grinder parsed another tile. The library transparently takes care of compression, protobuf and geometry de-/encoding and rebundling of the altered data into a new MBTiles.
Take a look at
tileshrink to see what you can build with it!
tilegrinderuses the native protobuf wrapper library
node-protobuffor its magic
To let it build during
npm install, take care of following things:
libprotobufmust be present (
apt-get install build-essential pkg-config libprotobuf-dev)
brew install pkg-config protobuf
node-protobufincludes a pre-compiled version for 64bit systems
How to install it?
Just install it into your project folder with
npm install --save tilegrinder
How to code it?
Following example will
create a new MBTiles file
simple.mbtilescontaining the tiles of the first 4 zoom levels of
roadlayers are kept
while all points get moved by an offset of 256
const TileGrinder =grinder = maxZoom: 4grinder
Which will generate following output:
bash$ node example.js[>] starting to grind[>] 38% less data in zoom 1, x: 0 y: 1[>] 39% less data in zoom 1, x: 1 y: 1[>] 20% less data in zoom 1, x: 0 y: 0.......[>] 16% less data in zoom 2, x: 2 y: 1[>] 33% less data in zoom 4, x: 8 y: 5[+] waiting![>] saved 35% of storagebash$
The MIT License (MIT)
Copyright (c) 2019 Michael Straßburger
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.