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
  • object PBTile extends GeneratedMessageCompanion[PBTile] with Serializable
    Definition Classes
    internal
  • PBFeature
  • PBGeomType
  • PBLayer
  • PBTileLens
  • PBValue

final case class PBLayer(version: Int, name: String, features: Seq[PBFeature] = _root_.scala.Seq.empty, keys: Seq[String] = _root_.scala.Seq.empty, values: Seq[PBValue] = _root_.scala.Seq.empty, extent: Option[Int] = _root_.scala.None, unknownFields: UnknownFieldSet = _root_.scalapb.UnknownFieldSet()) extends GeneratedMessage with Message[PBLayer] with Updatable[PBLayer] with ExtendableMessage[PBLayer] with Product with Serializable

Layers are described in section 4.1 of the specification

version

Any compliant implementation must first read the version number encoded in this message and choose the correct implementation for this version number before proceeding to decode other parts of this message.

features

The actual features in this tile.

keys

Dictionary encoding for keys

values

Dictionary encoding for values

extent

Although this is an "optional" field it is required by the specification. See https://github.com/mapbox/vector-tile-spec/issues/47

Annotations
@SerialVersionUID()
Linear Supertypes
Product, Equals, ExtendableMessage[PBLayer], Updatable[PBLayer], Message[PBLayer], GeneratedMessage, Serializable, Serializable, AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. PBLayer
  2. Product
  3. Equals
  4. ExtendableMessage
  5. Updatable
  6. Message
  7. GeneratedMessage
  8. Serializable
  9. Serializable
  10. AnyRef
  11. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Instance Constructors

  1. new PBLayer(version: Int, name: String, features: Seq[PBFeature] = _root_.scala.Seq.empty, keys: Seq[String] = _root_.scala.Seq.empty, values: Seq[PBValue] = _root_.scala.Seq.empty, extent: Option[Int] = _root_.scala.None, unknownFields: UnknownFieldSet = _root_.scalapb.UnknownFieldSet())

    version

    Any compliant implementation must first read the version number encoded in this message and choose the correct implementation for this version number before proceeding to decode other parts of this message.

    features

    The actual features in this tile.

    keys

    Dictionary encoding for keys

    values

    Dictionary encoding for values

    extent

    Although this is an "optional" field it is required by the specification. See https://github.com/mapbox/vector-tile-spec/issues/47

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. def addAllFeatures(__vs: Iterable[PBFeature]): PBLayer
  5. def addAllKeys(__vs: Iterable[String]): PBLayer
  6. def addAllValues(__vs: Iterable[PBValue]): PBLayer
  7. def addFeatures(__vs: PBFeature*): PBLayer
  8. def addKeys(__vs: String*): PBLayer
  9. def addValues(__vs: PBValue*): PBLayer
  10. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  11. def clearExtent: PBLayer
  12. def clearFeatures: PBLayer
  13. def clearKeys: PBLayer
  14. def clearValues: PBLayer
  15. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... ) @native()
  16. def companion: PBLayer.type
    Definition Classes
    PBLayer → GeneratedMessage
  17. def discardUnknownFields: PBLayer
  18. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  19. def extension[T](generatedExtension: GeneratedExtension[PBLayer, T]): T
    Definition Classes
    ExtendableMessage
  20. val extent: Option[Int]
  21. val features: Seq[PBFeature]
  22. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  23. final def getClass(): Class[_]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  24. def getExtent: Int
  25. def getField(__field: FieldDescriptor): PValue
    Definition Classes
    PBLayer → GeneratedMessage
  26. def getFieldByNumber(__fieldNumber: Int): Any
    Definition Classes
    PBLayer → GeneratedMessage
  27. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  28. val keys: Seq[String]
  29. def mergeFrom(_input__: CodedInputStream): PBLayer
    Definition Classes
    PBLayer → Message
  30. val name: String
  31. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  32. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  33. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  34. final def serializedSize: Int
    Definition Classes
    PBLayer → GeneratedMessage
  35. final def synchronized[T0](arg0: ⇒ T0): T0
    Definition Classes
    AnyRef
  36. def toByteArray: Array[Byte]
    Definition Classes
    GeneratedMessage
  37. def toByteString: ByteString
    Definition Classes
    GeneratedMessage
  38. def toPMessage: PMessage
    Definition Classes
    GeneratedMessage
  39. def toProtoString: String
    Definition Classes
    PBLayer → GeneratedMessage
  40. val unknownFields: UnknownFieldSet
    Definition Classes
    PBLayer → ExtendableMessage
  41. def update(ms: (Lens[PBLayer, PBLayer]) ⇒ Mutation[PBLayer]*): PBLayer
    Definition Classes
    Updatable
  42. val values: Seq[PBValue]
  43. val version: Int
  44. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  45. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  46. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... ) @native()
  47. def withExtension[T](generatedExtension: GeneratedExtension[PBLayer, T])(value: T): PBLayer
    Definition Classes
    ExtendableMessage
  48. def withExtent(__v: Int): PBLayer
  49. def withFeatures(__v: Seq[PBFeature]): PBLayer
  50. def withKeys(__v: Seq[String]): PBLayer
  51. def withName(__v: String): PBLayer
  52. def withUnknownFields(__v: UnknownFieldSet): PBLayer
    Definition Classes
    PBLayer → ExtendableMessage
  53. def withValues(__v: Seq[PBValue]): PBLayer
  54. def withVersion(__v: Int): PBLayer
  55. def writeDelimitedTo(output: OutputStream): Unit
    Definition Classes
    GeneratedMessage
  56. def writeTo(_output__: CodedOutputStream): Unit
    Definition Classes
    PBLayer → GeneratedMessage
  57. def writeTo(output: OutputStream): Unit
    Definition Classes
    GeneratedMessage

Deprecated Value Members

  1. def getAllFields: Map[FieldDescriptor, Any]
    Definition Classes
    GeneratedMessage
    Annotations
    @deprecated
    Deprecated

    (Since version 0.6.0) Use toPMessage

  2. def getField(field: FieldDescriptor): Any
    Definition Classes
    GeneratedMessage
    Annotations
    @deprecated
    Deprecated

    (Since version 0.6.0) Use getField that accepts a ScalaPB descriptor and returns PValue

Inherited from Product

Inherited from Equals

Inherited from ExtendableMessage[PBLayer]

Inherited from Updatable[PBLayer]

Inherited from Message[PBLayer]

Inherited from GeneratedMessage

Inherited from Serializable

Inherited from Serializable

Inherited from AnyRef

Inherited from Any

Ungrouped