HERE Android SDK Developer's Guide

Route

The class Route is a member of com.here.android.mpa.routing .

Class Summary

public class Route

extends java.lang.Object

Represents a distinct path connecting two or more waypoints GeoCoordinate .

[For complete information, see the section Class Details]

See also:

RouteResult

Nested Class Summary

Table 1. Nested Classes in Route
Nested Classes

public static abstract interface Route.DeserializationCallback

Callback interface for when deserialization is done, passed to deserializeAsync.

public static class Route.DeserializationResult

Represents the result of a Route de-serialization

public static final enumeration Route.EtaValidity

Enumeration used for calculating the estimated time of arrival(ETA).

public static abstract interface Route.SerializationCallback

Callback interface for when serialization is done, passed to serializeAsync.

public static class Route.SerializationResult

Represents the result of a Route serialization

public static final enumeration Route.SerializerError

Represents values describing possible route serialization errors.

public static final enumeration Route.TrafficPenaltyMode

Defines the possible traffic penalty modes used for route calculation and traffic event handling.

Field Summary

Table 2. Fields in Route
Fields

public static final int WHOLE_ROUTE

See Route.getTta(TrafficPenaltyMode, int).

Method Summary

Table 3. Methods in Route
Methods

public static DeserializationResult deserialize (byte[] buffer)

Deprecated: Deprecated as of release 3.4.

Deserialize a route given a byte buffer

public static void deserializeAsync (byte[] buffer, DeserializationCallback callback)

Asynchronously serialize a Route data structure to a data buffer

public boolean equals (Object obj)

Compare with other Route using hash code

public java.util.List <RouteIntersection> getAllIntersectionsAfter (RoadElement roadElement, int minDistance, int maxDistance)

This function returns all intersections found after the road element.

public GeoBoundingBox getBoundingBox ()

Gets the smallest GeoBoundingBox that contains the entire route.

public RouteConsumption getConsumption (ConsumptionParameters consumptionParameters, DynamicPenalty dynamicPenalty)

Return the anticipated energy consumption for driving this route

public GeoCoordinate getDestination ()

Gets the destination coordinate for the route.

public RouteIntersection getFirstIntersectionAfter (RoadElement roadElement, int minDistance, int maxDistance)

This function returns the first intersection found after the road element.

public Maneuver getFirstManeuver ()

Returns the first Maneuver.

public GeoCoordinate getLastReachablePosition (RouteConsumption routeConsumption, int energyCapacity)

The last reachable waypoint given a specific consumption model The RouteConsumption passed to this method shoud have been previously obtained from the getConsumption method.

public int getLength ()

Gets the length of the route, in meters.

public java.util.List <Maneuver> getManeuvers ()

Gets the list of all maneuvers that travelers will encounter along the route.

public List getPermanentDirectedLinkIds ()

Returns list of permanent link ids of the RouteElement objects contained in this route with their travel directions.

public List getPermanentLinkIds ()

Returns list of permanent link ids of the RouteElement objects contained in this route.

public RouteElements getRouteElements ()

Returns all RouteElements in this route.

public RouteElements getRouteElements (Maneuver maneuver)

Gets the RouteElements belonging to this Maneuver.

public RouteElements getRouteElementsFromDuration (long duration)

Gets the RouteElements for a given duration (in seconds) from the start of the route.

public RouteElements getRouteElementsFromDuration (long start, long duration)

Gets the RouteElements for a given duration (in seconds) within the route.

public RouteElements getRouteElementsFromLength (int length)

Gets the RouteElements for a given distance (in meters) within the route.

public RouteElements getRouteElementsFromLength (int start, int length)

Gets the RouteElements for a given distance (in meters) within the route.

public java.util.List <GeoCoordinate> getRouteGeometry ()

Gets the list of all GeoCoordinate values representing, in order, the polyline of the route.

public java.util.List <GeoCoordinate> getRouteGeometryWithElevationData ()

Gets the list of all GeoCoordinate values representing, in order, the polyline of the route with elevation data (if available).

public RoutePlan getRoutePlan ()

Returns the route plan for defining a route with one or more route legs.

public java.util.List <RouteWaypoint> getRouteWaypoints ()

Gets the list of all waypoints for the route.

public GeoCoordinate getStart ()

Gets the starting coordinate for the route.

public int getSublegCount ()

Returns the number of sub-legs the route has.

public TransitRouteSourceAttribution getTransitRouteSourceAttribution ()

In certain cases, data provided by Transit Agencies cannot be used without displaying copyright notices to the end user.

public RouteTta getTta (TrafficPenaltyMode mode, int subleg)

Gets the estimated time to arrival with current traffic conditions.

public java.util.List <GeoCoordinate> getWaypoints ()

Gets the list of all waypoints for the route.

public int hashCode ()

For documentation, see java.lang.Object

public static SerializationResult serialize (Route route)

Deprecated: Deprecated as of release 3.4.

Serialize a Route data structure to a data buffer

public static void serializeAsync (Route route, SerializationCallback callback)

Asynchronously serialize a Route data structure to a data buffer

Class Details

Represents a distinct path connecting two or more waypoints GeoCoordinate . A Route consists of a list of maneuvers and route links.

See also:

RouteResult

Field Details

public static final int WHOLE_ROUTE

See Route.getTta(TrafficPenaltyMode, int).

Method Details

public static DeserializationResult deserialize (byte[] buffer)

Deprecated: Deprecated as of release 3.4.

Use deserializeAsync(byte[], Route.DeserializationCallback) instead.

Deserialize a route given a byte buffer

When deserializing a route with many waypoints, use an android.os.android.os.AsyncTask to avoid blockage on the main thread

IMPORTANT: Route serialization is a Beta feature. The related classes are subject to change without notice.

Parameters:

  • buffer

    Data buffer containing the route.

Returns:

Route.DeserializationResult object.

public static void deserializeAsync (byte[] buffer, DeserializationCallback callback)

Asynchronously serialize a Route data structure to a data buffer

IMPORTANT: Route serialization is a Beta feature. The related classes are subject to change without notice.

Parameters:

  • buffer

    Data buffer containing the route.

  • callback

    DeserializationCallback callback which runs on the GUI thread when route deserialization is done.

public boolean equals (Object obj)

Compare with other Route using hash code

Parameters:

  • obj

public java.util.List <RouteIntersection> getAllIntersectionsAfter (RoadElement roadElement, int minDistance, int maxDistance)

This function returns all intersections found after the road element. This API is not supported for reset route, e.g. truck routing, online timetable routing.

Parameters:

  • roadElement

    road element on the route from which search should be started

  • minDistance

    The minimum distance from the given roadElement to the intersection

  • maxDistance

    The maximum distance from the given roadElement to the intersection

Returns:

a List of RouteIntersections.

public GeoBoundingBox getBoundingBox ()

Gets the smallest GeoBoundingBox that contains the entire route.

Returns:

The GeoBoundingBox

public RouteConsumption getConsumption (ConsumptionParameters consumptionParameters, DynamicPenalty dynamicPenalty)

Return the anticipated energy consumption for driving this route

IMPORTANT: Consumption calculation is a Beta feature. The related classes and methods are subject to change without notice.

Parameters:

  • consumptionParameters

    Consumption parameters specific to the vehicle that is to drive the route

  • dynamicPenalty

    Restriction factors for a given area that will influence consumption

Returns:

a RouteConsumption instance containing data about the route consumption, or null if the route type doesn't support consumption information (e.g. a transit route)

public GeoCoordinate getDestination ()

Gets the destination coordinate for the route.

Returns:

The destination GeoCoordinate

public RouteIntersection getFirstIntersectionAfter (RoadElement roadElement, int minDistance, int maxDistance)

This function returns the first intersection found after the road element. If the road element provided ends on the intersection this intersection will be returned. This API is not supported for reset route, e.g. truck routing, online timetable routing.

Parameters:

  • roadElement

    road element on the route from which search should be started

  • minDistance

    The minimum distance from the given roadElement to the intersection

  • maxDistance

    The maximum distance from the given roadElement to the intersection

Returns:

a RouteIntersection if found, otherwise null if no intersection is found

public Maneuver getFirstManeuver ()

Returns the first Maneuver.

Returns:

the first Maneuver, null if there are no maneuvers

public GeoCoordinate getLastReachablePosition (RouteConsumption routeConsumption, int energyCapacity)

The last reachable waypoint given a specific consumption model The RouteConsumption passed to this method shoud have been previously obtained from the getConsumption method. In the case that getConsumption was called with the default values provided by ConsumptionParameters , an appropriate value for energyCapacity would be 300000. This would represent a vehicle with maximum capacity. A lower value would correspond to a vehicle with lower remaining capacity which would not be able to travel as far.

IMPORTANT: Consumption calculation is a Beta feature. The related classes and methods are subject to change without notice.

Parameters:

  • routeConsumption

    Specifies the parameters of consumption for a given vehicle.

  • energyCapacity

    Available capacity at the beginning of the route

Returns:

the coordinates of the last reachable position.

public int getLength ()

Gets the length of the route, in meters.

Returns:

The route length in meters

public java.util.List <Maneuver> getManeuvers ()

Gets the list of all maneuvers that travelers will encounter along the route. If the RouteOptions.TransportMode of the route is PUBLIC_TRANSPORT, cast the Maneuver objects to TransitManeuver objects to get additional data about the transit route.

Returns:

The list of Maneuver objects

public List getPermanentDirectedLinkIds ()

Returns list of permanent link ids of the RouteElement objects contained in this route with their travel directions. Will return empty list for offline calculated route or for public transport route.

Returns:

all permanent link ids

See also:

getPermanentLinkId()

getPermanentDirectedLinkId()

getPermanentLinkIds()

public List getPermanentLinkIds ()

Returns list of permanent link ids of the RouteElement objects contained in this route. Will return empty list for offline calculated route or for public transport route.

Returns:

all permanent link ids

See also:

getPermanentLinkId()

getPermanentDirectedLinkId()

getPermanentDirectedLinkIds()

createLinkIdsRequest(Set<String>, Set<Long>)

public RouteElements getRouteElements ()

Returns all RouteElements in this route.

Returns:

all RouteElements

public RouteElements getRouteElements (Maneuver maneuver)

Gets the RouteElements belonging to this Maneuver.

Parameters:

  • maneuver

    The Maneuver to get the RouteElements for.

Returns:

The RouteElements belonging to this Maneuver.

public RouteElements getRouteElementsFromDuration (long duration)

Gets the RouteElements for a given duration (in seconds) from the start of the route.

Parameters:

  • duration

    The number of seconds from the beginning of the route.

Returns:

The RouteElements within the given duration.

public RouteElements getRouteElementsFromDuration (long start, long duration)

Gets the RouteElements for a given duration (in seconds) within the route.

Parameters:

  • start

    The number of seconds into the route to start getting RouteElements.

  • duration

    The number of seconds from the given start of the route.

Returns:

The RouteElements within the given duration.

public RouteElements getRouteElementsFromLength (int length)

Gets the RouteElements for a given distance (in meters) within the route.

Parameters:

  • length

    The number of meters from the beginning of the route.

Returns:

The RouteElements within the given distance.

public RouteElements getRouteElementsFromLength (int start, int length)

Gets the RouteElements for a given distance (in meters) within the route.

Parameters:

  • start

    The number of meters into the route to start getting RouteElements.

  • length

    The number of meters from the start parameter within this route.

Returns:

The RouteElements within the given distance.

public java.util.List <GeoCoordinate> getRouteGeometry ()

Gets the list of all GeoCoordinate values representing, in order, the polyline of the route. No elevation profile of the route is returned. The getAltitude() always returns UNKNOWN_ALTITUDE.

Returns:

A list of GeoCoordinate values without elevation data

See also:

MapPolyline

public java.util.List <GeoCoordinate> getRouteGeometryWithElevationData ()

Gets the list of all GeoCoordinate values representing, in order, the polyline of the route with elevation data (if available). An elevation profile of the route can be determined if the getAltitude() does not return UNKNOWN_ALTITUDE.

Returns:

A list of GeoCoordinate values

See also:

MapPolyline

public RoutePlan getRoutePlan ()

Returns the route plan for defining a route with one or more route legs. Route legs are formed by a list of stop overs in the route plan. Each route leg has it's own route options.

Returns:

The RoutePlan

public java.util.List <RouteWaypoint> getRouteWaypoints ()

Gets the list of all waypoints for the route.

Returns:

The list of RouteWaypoint objects.

public GeoCoordinate getStart ()

Gets the starting coordinate for the route.

Returns:

The starting GeoCoordinate

public int getSublegCount ()

Returns the number of sub-legs the route has. A sub leg is the part of a route between two stop waypoints

Returns:

number of sublegs

public TransitRouteSourceAttribution getTransitRouteSourceAttribution ()

In certain cases, data provided by Transit Agencies cannot be used without displaying copyright notices to the end user. The copyright information is provided in the source attribution objects and must be displayed together with a route. This requirement forms part of the terms and conditions of the API. This field will be null for non transit routes.

Returns:

SourceAttribution Copyright info that must be displayed along with the route.

public RouteTta getTta (TrafficPenaltyMode mode, int subleg)

Gets the estimated time to arrival with current traffic conditions. If traffic is to be used, the caller is recommended to obtain a traffic update for the route first (and wait for it to complete) to populate the traffic database.

Parameters:

Returns:

The RouteTta of the subleg.

Throws:

  • IllegalArgumentException

    if mode is AVOID_CONGESTION.

  • IllegalArgumentException

    if subleg is less than 0 or greater than or equal to getSublegCount().

  • AccessControlException

    Access to this operation is denied. Contact your HERE representative for more information.

public java.util.List <GeoCoordinate> getWaypoints ()

Gets the list of all waypoints for the route.

Returns:

The list of GeoCoordinate objects

public int hashCode ()

For documentation, see java.lang.Object

public static SerializationResult serialize (Route route)

Deprecated: Deprecated as of release 3.4.

Use serializeAsync(Route, Route.SerializationCallback) instead.

Serialize a Route data structure to a data buffer

IMPORTANT: Route serialization is a Beta feature. The related classes are subject to change without notice.

Parameters:

  • route

    Route object to serialize.

Returns:

Route.SerializationResult object.

public static void serializeAsync (Route route, SerializationCallback callback)

Asynchronously serialize a Route data structure to a data buffer

IMPORTANT: Route serialization is a Beta feature. The related classes are subject to change without notice.

Parameters:

  • route

    Route object to serialize.

  • callback

    SerializationCallback callback which runs on the GUI thread when route serialization is done.