Implicit conversion for geotrellis.vector.Geometry instances.
This package is experimental. Expect API flux.
This package is experimental. Expect API flux.
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:
Raw VectorTile data is stored in the protobuf format. Any codec implementing the spec must decode and encode data according to this .proto schema.
geotrellis-vectortile is a high-performance implementation of Version 2.1 of the VectorTile spec. It features:
Users of this library need only pay attention to geotrellis.vectortile. Any classes in the internal.* submodules are unique to the machinery of VectorTile {de,en}coding, and can be safely ignored.
The central type is the VectorTile class. Its companion object can be used to construct VectorTiles from raw byte data:
import geotrellis.spark.SpatialKey import geotrellis.spark.tiling.LayoutDefinition import geotrellis.vector.Extent import geotrellis.vectortile.VectorTile val bytes: Array[Byte] = ... // from some `.mvt` file val key: SpatialKey = ... // preknown val layout: LayoutDefinition = ... // preknown val tileExtent: Extent = layout.mapTransform(key) /* Decode Protobuf bytes. */ val tile: VectorTile = VectorTile.fromBytes(bytes, tileExtent) /* Encode a VectorTile back into bytes. */ val encodedBytes: Array[Byte] = tile.toBytes
The V* types form a small sum type and are used to represent usually untyped Feature-level metadata. This metadata is equivalent to a JSON Object, where String keys index values of any type. A Scala Map requires more rigidity (for the better), and so we use geotrellis.vectortile.Value to guarantee type safety.
This particular implementation of the VectorTile spec makes the following assumptions:
id
field in VectorTile Features doesn't matter.UNKNOWN
geometries are safe to ignore.geometry
list marked as POINT
has only one pair
of coordinates, it will be decoded as a GeoTrellis Point
. If it has
more than one pair, it will be decoded as a MultiPoint
. Likewise for
the LINESTRING
and POLYGON
types. A complaint has been made about
the spec regarding this, and future versions may include a difference
between single and multi geometries.
2.1
Implicit conversion for geotrellis.vector.Geometry instances.