HERE iOS SDK Developer's Guide

NMADynamicPenalty

Class Summary

class NMADynamicPenalty

Derived from: NSObject

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

Include: NMAKit.framework/headers/NMADynamicPenalty.h

Inheritance Diagrams

Figure 1. Public inheritance diagram for NMADynamicPenalty

[For complete information, see the section Class Details]

Public Property Summary

Table 1. Public Properties
Public Properties

[readable, writable, assign] NMATrafficPenaltyMode   trafficPenaltyMode

To decide route calculation should take traffic into account

Instance Method Summary

Table 2. Instance Methods
Instance Method Summary

-(BOOL) addBannedArea:(nonnull NMAMapPolygon *) area

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

-(BOOL) addPenaltyForRoadElement:(nonnull NMARoadElement *) element withDrivingDirection:( NMADrivingDirection ) direction speed:(NSUInteger) newSpeed

Sets a penalty for a road segment.

-(nonnull instancetype) init

Constructs a default NMADynamicPenalty.

-(void) removeAllAreaPenalties

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

-(void) removeAllRoadElementPenalties

Removes all previously-added road penalties.

-(BOOL) removeBannedArea:(nonnull NMAMapPolygon *) area

Removes a banned area, if added previously.

-(BOOL) removePenaltyForRoadElement:(nonnull NMARoadElement *) element

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

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.

Public Property Details

[readable, writable, assign] NMATrafficPenaltyMode  trafficPenaltyMode

To decide route calculation should take traffic into account.

This property defaults to NMATrafficPenaltyModeDisabled.

Instance Method Details

-(BOOL) addBannedArea:(nonnull NMAMapPolygon *) area

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

An area is defined in terms of NMAMapPolygon.

Parameters:

  • area

    area to with penalty is being added.

Returns:

YES if banned area is added successfully. NO if area is nil.

-(BOOL) addPenaltyForRoadElement:(nonnull NMARoadElement *) element withDrivingDirection:( NMADrivingDirection ) direction speed:(NSUInteger) newSpeed

Sets a penalty for a road segment.

Note:

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

    to identify the road segment.

  • direction

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

  • newSpeed

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

Returns:

YES if road penalty is added successfully. NO if element is nil OR newSpeed is less than 0 or greater than 254 OR otherwise.

-(nonnull instancetype) init

Constructs a default NMADynamicPenalty.

-(void) removeAllAreaPenalties

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

-(void) removeAllRoadElementPenalties

Removes all previously-added road penalties.

-(BOOL) removeBannedArea:(nonnull NMAMapPolygon *) area

Removes a banned area, if added previously.

Note:

Area is defined in terms of NMAGeoPolygon.

Parameters:

  • area

    area to be removed from penalty policy

-(BOOL) removePenaltyForRoadElement:(nonnull NMARoadElement *) element

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

Parameters:

  • element

    to identify the road segment.

Returns:

YES if road penalty is removed successfully. NO otherwise.