Class GeoPolyline

java.lang.Object
com.here.sdk.core.GeoPolyline

public final class GeoPolyline extends Object

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 Details

    • vertices

      @NonNull public final List<GeoCoordinates> vertices

      The list of vertices representing the polyline.

  • Constructor Details

    • GeoPolyline

      public GeoPolyline(@NonNull List<GeoCoordinates> vertices) throws InstantiationErrorException

      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

      public GeoPolyline(@NonNull GeoBox geoBox)

      Constructs an instance of this class from GeoBox.

      Parameters:
      geoBox -

      A rectangle defined by the GeoBox to be converted into GeoPolyline. The corner coordinates of the GeoBox will define the points of the resulting GeoPolyline.

  • Method Details

    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class 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 the GeoCoordinates.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