Class GeoPolyline
Class GeoPolyline
- java.lang.Object
-
- com.here.sdk.core.GeoPolyline
-
public final class GeoPolyline extends java.lang.ObjectA list of geographic coordinates representing the vertices of a polyline. An instance of this class, initialized with appropriate vertices. Represents a
GeoPolylineas a series of geographic coordinates.
-
-
Field Summary
Fields Modifier and Type Field Description java.util.List<GeoCoordinates>verticesThe list of vertices representing the polyline.
-
Constructor Summary
Constructors Constructor Description GeoPolyline(GeoBox geoBox)Constructs an instance of this class fromGeoBox.GeoPolyline(java.util.List<GeoCoordinates> vertices)Constructs a GeoPolyline from the provided vertices.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description GeoCoordinatescoordinatesAtOffsetInMeters(double offsetInMeters, GeoPolylineDirection direction)Returns the coordinates at the given distance along the polyline.booleanequals(java.lang.Object obj)longgetNearestIndexTo(GeoCoordinates point)Returns the index of the nearest vertex to the given point.inthashCode()
-
-
-
Field Detail
-
vertices
@NonNull public final java.util.List<GeoCoordinates> vertices
The list of vertices representing the polyline.
-
-
Constructor Detail
-
GeoPolyline
public GeoPolyline(@NonNull java.util.List<GeoCoordinates> vertices) throws InstantiationErrorExceptionConstructs 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
public GeoPolyline(@NonNull GeoBox geoBox)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 Detail
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
getNearestIndexTo
public long getNearestIndexTo(@NonNull GeoCoordinates point)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
-
-