Packages

  • package root
    Definition Classes
    root
  • package geotrellis
    Definition Classes
    root
  • package vectortile

    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:

    • 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.

    What is this package?

    geotrellis-vectortile is a high-performance implementation of Version 2.1 of the VectorTile spec. It features:

    • Decoding of Version 2 VectorTiles from Protobuf byte data into useful GeoTrellis types.
    • Lazy decoding of Geometries. Only parse what you need!

    Using this Package

    Modules

    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.

    Types

    The central type is the geotrellis.vectortile.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.

    Implementation Assumptions

    This particular implementation of the VectorTile spec makes the following assumptions:

    • Geometries are implicitly encoded in some Coordinate Reference system. That is, there is no such thing as a "projectionless" VectorTile. When decoding a VectorTile, we must provide a GeoTrellis geotrellis.vector.Extent that represents the Tile's area on a map. With this, the grid coordinates stored in the VectorTile's Geometry are shifted from their original [0,4096] range to actual world coordinates in the Extent's CRS.
    • The id field in VectorTile Features doesn't matter.
    • UNKNOWN geometries are safe to ignore.
    • If a VectorTile 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.
    Definition Classes
    geotrellis
    Version

    2.1

  • package internal

    Users need not concern themselves with this subpackage; it handles the details internal to the VectorTile encoding/decoding process.

    Users need not concern themselves with this subpackage; it handles the details internal to the VectorTile encoding/decoding process.

    Definition Classes
    vectortile
  • Layer
  • LazyLayer
  • MVTFeature
  • StrictLayer
  • VBool
  • VDouble
  • VFloat
  • VInt64
  • VSint64
  • VString
  • VWord64
  • Value
  • VectorTile

case class VectorTile(layers: Map[String, Layer], tileExtent: Extent, forcePolygonWinding: Boolean = true) extends Product with Serializable

A concrete representation of a VectorTile, as one decoded from Protobuf bytes. At its simplest, a Tile is just a collection of Layers. We opt to expose each Layer name at the Tile level, as the keys of a Map. This way, if the layer names are known by the user ahead of time, they can search through the Tile quickly.

import geotrellis.vectortile._

val bytes: Array[Byte] = ...  // from some `.mvt` file
val key: SpatialKey = ...  // preknown
val layout: LayoutDefinition = ...  // preknown
val tileExtent: Extent = layout.mapTransform(key)

val tile: VectorTile = VectorTile.fromBytes(bytes, tileExtent)
Annotations
@experimental()
Linear Supertypes
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. VectorTile
  2. Serializable
  3. Serializable
  4. Product
  5. Equals
  6. AnyRef
  7. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Instance Constructors

  1. new VectorTile(layers: Map[String, Layer], tileExtent: Extent, forcePolygonWinding: Boolean = true)

    This is not meant to be called directly - see this class's companion object for the available helper methods.

Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  4. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  5. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... ) @native()
  6. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  7. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  8. val forcePolygonWinding: Boolean
  9. final def getClass(): Class[_]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  10. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  11. val layers: Map[String, Layer]
  12. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  13. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  14. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  15. def pretty: String

    Pretty-print this VectorTile.

  16. final def synchronized[T0](arg0: ⇒ T0): T0
    Definition Classes
    AnyRef
  17. val tileExtent: Extent
  18. def toBytes: Array[Byte]

    Encode this VectorTile back into its original form of Protobuf bytes.

  19. def toGeoJson: String

    Yield GeoJson for this VectorTile.

    Yield GeoJson for this VectorTile. Geometries are reprojected from WebMercator to LatLng, and metadata is dropped.

  20. def toIterable: Iterable[MVTFeature[Geometry]]

    Return a VectorTile to a Spark-friendly structure.

  21. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  22. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  23. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... ) @native()

Inherited from Serializable

Inherited from Serializable

Inherited from Product

Inherited from Equals

Inherited from AnyRef

Inherited from Any

Ungrouped