package geospatial
A collection of geospatial components and interfaces that implement different flavors of proximity search.
Note: com.here.platform.location packages use a set of terms to describe different geospatial aspects:
Coordinates: Cartesian coordinates (x, y[, z]) Geo coordinates: WGS 84 coordinates (latitude, longitude[, elevation]) Point: Geometry element holding coordinates + system specific information (ID, precision, etc.) Geo point: Geospatial element holding geocoordinates + system specific information Node: Topological element of the road network representing a location where multiple manoeuvres are possible, such as before an intersection or where a lane starts/finishes forming/merging. Segment: Topological element of the road network that connects exactly two nodes Any change in attributes along the segment define a new link (sub-segment) Link: Nonbreakable element of a topological segment with a particular set of attributes Attribute: Property of a link, such as its speed limit Vertex: Node in the routing graph, referring to a topological segment Edge: Arc in the routing graph that connects exactly two vertices Incidence graph: Routing graph providing vertices connected to a given edge:
- its source vertex, which is the tail of the arrow when directed
- its target vertex, which is the head of the arrow when directed Directed graph: Incidence graph providing edges going out of a given vertex
Note: WGS84-related functionality works with a reasonable accuracy when latitude is between -85 and +85 degrees.
- Alphabetic
- By Inheritance
- geospatial
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Type Members
-
trait
AncestorTileResolver extends AnyRef
Looks up the ancestor TileIds containing the given tile.
-
trait
DiskTileResolver extends AnyRef
Looks up TileIds that cover a given circle.
-
class
GeometryTile extends AnyRef
Contains the road geometry data for a single tile.
Contains the road geometry data for a single tile.
In HERE Map Content, a road segment is the unbroken stretch of road between two intersections. The intersections are called nodes.
The geometry of a road segment is a line-string, a sequence of points, starting from the segment's start node and ending with its end node.
A segment geometry consists of a sequence of one or more adjacent segment geometry chunks. Each chunk is a pair of subsequent points of a segment geometry. That means, that the n-th chunk of a segment's geometry consists of points n and n+1 in that geometry.
Road Segment Geometries
Every GeometryTile
t1
contains geometries for two kinds of segments.- Segments that belong to tile
t1
(internal segments). - Segments that belong to some other tile
t2
but whose geometry is partially inside tilet1
(external segments).
These geometries are stored in segmentGeometryCoordinates in the following order:
- First, for the internal segments, stored in the same order as the Vertices corresponding to these segments in the GraphTile with the same ID.
- Then, for the external segments, ordered by the (tileId, localIndex) for each external segment.
To determine which points inside
segmentGeometryCoordinates
constitute the geometry for a segment we need to consultsegmentGeometryFirstCoordinateIndices
. For example, the geometry of the segment with index n starts at the point with indexsegmentGeometryFirstCoordinateIndices(n)
and ends at the point with indexsegmentGeometryFirstCoordinateIndices(n+1)
(exclusive). This implies that the first entry ofsegmentGeometryFirstCoordinateIndices
will always be 0 and the last entry will always besegmentGeometryCoordinates.length
.Point Encoding
GeometryTiles contain points to represent segment geometries (in
segmentGeometryCoordinates
) and to represent bounding boxes (inboundingBoxCoordinates
). All these points are stored as 64 bit integers. This representation consumes a lot less memory than, for example a pair of doubles. More importantly, because integers are primitive types, they usually don't need an object to be created for them and, as a consequence, are a lot faster to work with.A point is usually represented by a GeoCoordinate object containing a longitude and a latitude.
In order to pack these coordinates into an integer, multiply each coordinate by 1000000 and convert it to an integer. The two integer coordinates then become the high (latitude) and low (longitude) bits of a long:
packed_representation = (latitude*1E6).toLong << 32) | (longitude*1E6).toLong & 0xFFFFFFFFL)
This packing means that the precision of each coordinate is one millionth of a degree, which is around 10 cm.
To reconstruct the original point, apply the inverse transformation:
latitude = (packed_representation >> 32) / 1E6 longitude = (packed_representation & 0xFFFFFFFFL).toInt / 1E6
External Segments
Every GeometryTile may contain some geometries for segments external to that tile (see above). In order to find out which tile an external segment belongs to and what its index in that tile is, you need to consult
externalSegmentPartitions
andexternalSegmentLocalIndices
. These are parallel arrays that contain the tile ID and segment index, respectively, for each external segment.External segments are always the last segments in a tile. That means, you can decide whether a segment is external, just by looking at its index. The segment with index n is external, if
n >= internalSegmentCount
.The ID of the tile that this external segment belongs to is
externalSegmentPartitions(n - number_of_internal_segments)
and its index thereexternalSegmentLocalIndices(n - number_of_internal_segments)
.The Spatial Index
In order to quickly find segments in a particular area, GeometryTiles contain a spatial index. The spatial index is a tree data structure where every internal node is associated with a bounding box around all its children. Using the bounding boxes while traversing the tree, you can quickly decide whether a sub-tree might contain segment geometries relevant to your search and avoid descending into it, if it does not.
A leaf node in the tree (a node without child nodes) points to a single chunk inside a segment geometry in this tile.
The structure of the tree is stored in
indexTree
. The tree containsindexTree.length - 1
nodes. For a tree node with index m, the range fromindexTree(m)
toindexTree(m+1)
(exclusive) contains the indices of its child nodes. In particular, ifindexTree(m) == indexTree(m+1)
, the node is a leaf node. The node with index 0 is the tree's root nodeindexTree
. The first entry inindexTree
is always 1 and the last entry alwaysindexTree.length
.Each node in
indexTree
is associated with two values inindexValues
. For an internal (non-leaf) tree node with index n,indexValues(2*n)
contains the index of a bounding box inboundingBoxCoordinates
. Because two points are required for storing each bounding box, the index of a bounding box will always be even. For a leaf node with index n,indexValues(2*n)
contains a segment index in this tile andindexValues(2*n+1)
a chunk index inside the geometry for that segment.Cumulative Chunk Lengths
For every chunk in every segment geometry,
cumulativeChunkLengths
contains the sum of the length of that chunk and the lengths of all previous chunks in the segment (inclusive prefix sum). The cumulative chunk lengths can be used to calculate the distance fraction for a point on a segment's geometry. The distance fraction (or simply fraction) for a point on a segment is the ratio between the distance you need to travel along a segment from the beginning of the segment to reach that point and the length of the segment.A segment whose geometry consists of
p
points, always hasp-1
chunks. To retrieve the cumulative chunk length for the chunk with indexc
in the segment with indexn
, you therefore need to use the following index intocumulativeChunkLengths
:length_index = segmentGeometryFirstCoordinateIndices(n) - n + c cumulative_chunk_length = cumulativeChunkLengths(length_index)
The cumulative chunk length of a segment's last chunk is also the total length of the segment.
segment_length = cumulativeChunkLengths(segmentGeometryFirstCoordinateIndices(n + 1) - n - 2)
- Note
Although this object contains Arrays, you should treat it as immutable.
- Segments that belong to tile
-
final
class
PackedGeoCoordinate extends AnyVal
Represents geocoordinates packed into a Long.
Represents geocoordinates packed into a Long.
This format is used, for example, in the
geometry
layer of an Optimized Map for Location Library. -
trait
PackedLineString extends Serializable
A line string containing PackedGeoCoordinates.
A line string containing PackedGeoCoordinates.
This interface is optimized to avoid allocations when accessing vertex geometries.
-
final
case class
TileId(value: Long) extends AnyVal with Product with Serializable
Represents the ID of a tile for the HEREtile schema.
Represents the ID of a tile for the HEREtile schema.
For more information on HEREtiles and IDs, see the documentation for
com.here.olp.util.quad.HereQuad
.- value
The tile ID
-
trait
TileResolver extends DiskTileResolver with AncestorTileResolver with Serializable
Looks up TileIds using various point- or area-based queries.
Looks up TileIds using various point- or area-based queries.
- Note
The output tile level is implementation specific.
-
class
TiledProximitySearch extends ProximitySearch[(TileId, SegmentIndex)]
An implementation of com.here.platform.location.core.geospatial.ProximitySearch for the indexed segment geometry of the Optimized Map for Location Library, which uses an R-tree to find segments.
An implementation of com.here.platform.location.core.geospatial.ProximitySearch for the indexed segment geometry of the Optimized Map for Location Library, which uses an R-tree to find segments.
It will return one result for each segment chunk that is in range. Thus, the search might return multiple results for a segment.
See also GeometryTile for details on the data format used by this class.
Value Members
- object GeometryTile
- object PackedGeoCoordinate
- object PackedLineString extends Serializable
-
object
VertexProximitySearch
Contains factory methods for creating ProximitySearches returning Vertices.