GeoPolyline (API Reference)
Class GeoPolyline
A list of geographic coordinates representing the vertices of a polyline.
An instance of this class, initialized with appropriate vertices.
Represents a GeoPolyline as a series of geographic coordinates.
-
Field Summary
FieldsModifier and TypeFieldDescriptionfinal List<GeoCoordinates>The list of vertices representing the polyline. -
Constructor Summary
ConstructorsConstructorDescriptionGeoPolyline(GeoBox geoBox) Constructs an instance of this class fromGeoBox.GeoPolyline(List<GeoCoordinates> vertices) Constructs a GeoPolyline from the provided vertices. -
Method Summary
Modifier and TypeMethodDescriptioncoordinatesAtOffsetInMeters(double offsetInMeters, GeoPolylineDirection direction) Returns the coordinates at the given distance along the polyline.booleanlonggetNearestIndexTo(GeoCoordinates point) Returns the index of the nearest vertex to the given point.inthashCode()
-
Field Details
-
vertices
The list of vertices representing the polyline.
-
-
Constructor Details
-
GeoPolyline
Constructs a GeoPolyline from the provided vertices. Throws an InstantiationError if the number of vertices is less than two.
- Parameters:
vertices-List of vertices representing the polyline.
- Throws:
InstantiationErrorException-Instantiation error.
-
GeoPolyline
Constructs an instance of this class from
GeoBox.- Parameters:
geoBox-A rectangle defined by the
GeoBoxto be converted intoGeoPolyline. The corner coordinates of theGeoBoxwill define the points of the resultingGeoPolyline.
-
-
Method Details
-
equals
-
hashCode
public int hashCode() -
getNearestIndexTo
Returns the index of the nearest vertex to the given point.
- Parameters:
point-Coordinates of the point.
- Returns:
Index of the closest vertex of the polyline.
-
coordinatesAtOffsetInMeters
@NonNull public GeoCoordinates coordinatesAtOffsetInMeters(double offsetInMeters, @NonNull GeoPolylineDirection direction) Returns the coordinates at the given distance along the polyline. When the polyline is traversed from the beginning, the distance is calculated from the start of the polyline; while a direction from the end indicates a distance from the last vertex.
The offset is expected to be non-negative and smaller than the length of the polyline. When the offset is negative, the function returns the starting end point of the polyline, i.e. the first vertex in positive direction and the last vertex in the negative direction. Similarly, when the offset is larger than the length of the polyline, then the function returns the opposite end point of the polyline.
The distance between two consecutive vertices is calculated using the
GeoCoordinates.distanceTo(com.here.sdk.core.GeoCoordinates)function. Therefore, it computes the distance (in meters) along the great circle between the two vertices. Similarly, the full length of the polyline is the sum of the distances between its vertices. The interpolation coordinates between two vertices is calculated using theGeoCoordinates.interpolate(com.here.sdk.core.GeoCoordinates, double)function.Note: the result may different from the analogue result from other matching components since they may adapt the result to the length of the underlying object described by the polyline.
- Parameters:
offsetInMeters-The distance along the polyline in meters
direction-The direction in which the polyline is traversed.
- Returns:
The coordinates of the point at the given distance
-