HERE Android SDK Developer's Guide

DynamicPenalty

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

Class Summary

public final class DynamicPenalty

extends java.lang.Object

This class represents a policy containing road, area, and traffic restriction factors that are taken into account while calculating routes.

[For complete information, see the section Class Details]

See also:

Route.TrafficPenaltyMode

Constructor Summary

Table 1. Constructors in DynamicPenalty
Constructors

DynamicPenalty ()

Default constructor.

Method Summary

Table 2. Methods in DynamicPenalty
Methods

public void addBannedArea (GeoPolygon area)

Sets a banned area which is excluded from the routing calculation.

public void addRoadPenalty (RoadElement element, DrivingDirection direction, int newSpeed)

Sets a penalty for a road segment.

public void clearAllAreaPenalties ()

Removes all previously-added areas and their penalty from this policy.

public void clearAllRoadPenalties ()

Removes all previously-added road penalties.

public TrafficPenaltyMode getTrafficPenaltyMode ()

Retrieves the traffic penalty mode for route calculations.

public void removeBannedArea (GeoPolygon area)

Removes a banned area, if added previously.

public void removeRoadPenalty (RoadElement element)

Remove a road segment from the penalty policy.

public void setTrafficPenaltyMode (TrafficPenaltyMode mode)

Sets whether route calculation should take traffic into account.

Class Details

This class represents a policy containing road, area, and traffic restriction factors that are taken into account while calculating routes. These restriction factors are also known as penalties. For example, you can use this class to set an area penalty to indicate that the travel speed in an area is 50% slower than the legal speed limit.

DynamicPenalty must be set with setDynamicPenalty(DynamicPenalty) for its restrictions to be in effect.

See also:

Route.TrafficPenaltyMode

Constructor Details

DynamicPenalty ()

Default constructor.

Method Details

public void addBannedArea (GeoPolygon area)

Sets a banned area which is excluded from the routing calculation.

A banned area is defined in terms of GeoPolygon.

Parameters:

  • area

    area to with penalty is being added.

Throws:

  • NullPointerException

    if area is null

public void addRoadPenalty (RoadElement element, DrivingDirection direction, int newSpeed)

Sets a penalty for a road segment. Road penalties are defined as a speed that overrides the original speed of the road segment.

Road penalties are in kilometers per hour and must be between 0 and 254. A penalty of 0 blocks the road segment from route calculations altogether.

Segments can be blocked in the forward, backward, or both directions. If a road segment is excluded in the backward direction, it can still be accessed in the forward direction. If you want to completely exclude the segment, block both directions.

Parameters:

  • element

    RoadElement to identify the road segment.

  • direction

    The road's direction represented by DrivingDirection to be used to apply penalty.

  • newSpeed

    New Speed for the segment in kilometers per hour. Must be in between 0 to 254.

Throws:

  • IllegalArgumentException

    if newSpeed is less than 0 or greater than 254

  • NullPointerException

    if the RoadElement is null

public void clearAllAreaPenalties ()

Removes all previously-added areas and their penalty from this policy.

public void clearAllRoadPenalties ()

Removes all previously-added road penalties.

public TrafficPenaltyMode getTrafficPenaltyMode ()

Retrieves the traffic penalty mode for route calculations.

Returns:

The Route.TrafficPenaltyMode used for calculations

public void removeBannedArea (GeoPolygon area)

Removes a banned area, if added previously.

Area is defined in terms of GeoPolygon.

Parameters:

  • area

    area to be removed from penalty policy

public void removeRoadPenalty (RoadElement element)

Remove a road segment from the penalty policy. This will remove penalties for every DrivingDirection

Parameters:

  • element

    RoadElement to identify the road segment.

public void setTrafficPenaltyMode (TrafficPenaltyMode mode)

Sets whether route calculation should take traffic into account. By default, traffic penalty mode is DISABLED.

Parameters:

  • mode

    A TrafficPenaltyMode indicating whether to take traffic into account.

You cannot use this account to purchase a commercial plan on Developer Portal, as it is already associated to plans with different payment methods.

To purchase a commercial plan on Developer Portal, please register for or sign in with a different HERE Account.

Something took longer than expected.

The project should be available soon under your projects page.

Sorry, our services are not available in this region.

Something seems to have gone wrong. Please try again later.

We've detected that your account is set to Australian Dollars (AUD).
Unfortunately, we do not offer checkouts in AUD anymore.
You can continue using your current plan as normal, but to subscribe to one of our new plans,
please register for a new HERE account or contact us for billing questions on selfservesupport@here.com.