Invented by Mapbox, VectorTiles are a combination of the ideas of finite-sized tiles and vector geometries. Mapbox maintains the official implementation spec for VectorTile codecs. The specification is free and open source.
VectorTiles are advantageous over raster tiles in that:
- They are typically smaller to store
- They can be easily transformed (rotated, etc.) in real time
- They allow for continuous (as opposed to step-wise) zoom in Slippy Maps
Raw VectorTile data is stored in the protobuf format. Any codec implementing
the spec must
decode and encode data according to this .proto
schema.
For more detailed information on VectorTiles, our data types, and usage instructions for this library, see the Scaladocs.
This codec uses ScalaPB to auto-generate
its .pbf -> Scala
bridge code. The tool itself offers an SBT plugin to do
this, but I've found it easier to run their spbc
tool directly.
Once you have that, generate the code as follows. From the vectortile/
directory:
spbc vector_tile.proto --scala_out=.
This will produce some scala sources that will need to override what's present
in /vectortile/src/main/scala/geotrellis/vectortile/internal/vector_tile
.
This should be two files, Tile.scala
and VectorTileProto.scala
.
To get everything to compile, you will also have to manually change the package names in each of the files to:
package geotrellis.vectortile.internal.vector_tile
Please also add the Apache 2 license headers to each file.
You will have to complete this entire process whenever you choose to update the scalapb
dependency line in vectortile/build.sbt
.