VectorTile geometries are stored as packed lists of "Command Integers".
VectorTile geometries are stored as packed lists of "Command Integers". There are currently three legal Commands: MoveTo, LineTo, and ClosePath. Each adhere to the following format:
[ ... 00000 | 000 ] ------------------- | | | --- The "Command ID". MoveTo: 001 (1) | LineTo: 010 (2) | ClosePath: 111 (7) | --- The remaining 29 bits are the "Parameter Count". This indicates the number of _pairs_ of ints that follow that should be interpreted as Z-encoded deltas from the current "cursor".
The "cursor" is the location of the current vertex being considered, and it starts at (0,0) for each Feature. As MoveTo and LineTo commands are read, the cursor moves according the list of parsed delta pairs. ClosePath does not move the cursor, but may in future versions of the spec.
Caveats:
If some invalid combination of command id and parameter count are given.
If an sequence of Commands is given that does not conform to what the Point, LineString, and Polygon decoders expect.
LineTo
indicates that a LineString should be continued from the current
cursor.
MoveTo
signals a series of moves from the current cursor (default of (0,0)
).
MoveTo
signals a series of moves from the current cursor (default of (0,0)
).
The parameter pairs that follow don't represent a point to move to,
but instead are deltas from the current cursor.
An isomorphism for any Geotrellis geometry type that can convert between a collection of Command Integers.
An isomorphism for any Geotrellis geometry type that can convert between a collection of Command Integers. As of version 2.1 of the VectorTile spec, there is no explicit difference between single and multi geometries. When there eventually is, this trait will have to be split to provide separate instances for both the single and multi forms.
Since we assume that all VectorTiles implicitely exist in some CRS, we ask for the top-left corner of the current Tile's extent, as well as its resolution in order to perform the transformation into CRS space.
Instances of this trait can be found in the package object.
Usage:
val topLeft: Point = ... val resolution: Double = ... implicitly[ProtobufGeom[Point, MultiPoint]].fromCommands(Command.commands(Seq(9,2,2)), topLeft, resolution)
Signals the end of a Polygon.
Signals the end of a Polygon. Never has parameters, and doesn't move the cursor.
Contains convenience functions for handling Commands.
Translate Point coordinates within a CRS to those of a fixed VectorTile grid.
Translate Point coordinates within a CRS to those of a fixed VectorTile grid. The reverse of toProjection.
The Point in CRS space.
The CRS coordinates of the top-left corner of this Tile.
How much of the CRS's units are covered by a single VT grid coordinate.
Grid coordinates in VectorTile space.
Instance definition of the ProtobufGeom typeclass for Lines.
Instance definition of the ProtobufGeom typeclass for Points.
Instance definition of the ProtobufGeom typeclass for Polygons.
Automatically convert mid-level Protobuf Values into a high-level Value.
Translate coordinates in VectorTile grid space into real CRS coordinates.
Translate coordinates in VectorTile grid space into real CRS coordinates.
A point in a VectorTile geometry, in grid coordinates.
The location in the current CRS of the top-left corner of this Tile.
How much of the CRS's units are covered by a single VT grid coordinate.
The Point projected into the CRS.
Extents always exist in some CRS. Below is information for determining values related to translating fixed VectorTile grid coordinates into map coordinates within the implied CRS. You can find resolution this way. Let:
G := Height of grid (# number of cell rows)
T := Height of a Tile (default 4096)
E := Height of the Extent
Then the resolution
R = E / (G * T)
This actually allows same-Tile Layers with different integer extent
values
to make sense!
Finding the top-left corner
X = xmin + (R * T * SpatialKeyX) Y = ymax - (R * T * SpatialKeyY)
Resolution and the top-left corner only need to be calculated once per Layer. Shifting the VT grid points
vtX = X + (R * tileX) vtY = Y - (R * tileY)