我正在使用 Here Map iOS SDK 版本 3.16.3 我正在使用 Here 地图绘制具有多个航点的路线。在计算路线中的 ETA 时,我收到错误NMARoutingErrorViolatesOptions。当我在NMARouteResult类中进一步检查时,该类中的 Property deniedOptions在数组中返回4096 。请在下面找到有关providedOptions属性的注释。
/**
* NSArray of NSNumber objects, one per route calculated,
* representing which options (if any) were violated for the
* corresponding route. The NSNumber objects should be converted to
* NSUInteger before checking. The value will be an OR combination of
* NMARoutingOption and `NMARoutingViolatedOption` values, or
* NMARoutingViolatedOptionNone if no options were violated. If route calculation
* failed, the array will contain a single object containing all the routing
* options (if any).
*/
@property (nonatomic, readonly, nullable) NSArray <NSNumber *> *violatedOptions;
我已将NMACoreRouter对象中的路由选项设置为NMARoutingOptionAvoidBoatFerry。
NMARoutingOptionAvoidBoatFerry = 1 << 0,
以下是违反选项的枚举,我正在尝试查找路线中发生的确切错误。
/**
* Implicit routing options that may be violated by routing calculation operations.
*
* @note Violations which depend on traffic data (e.g. BlockedRoad) will only be returned if
* the traffic feature is available.
*/
// The violatedOptions value returned from NMARouter will be an OR
// combination of NMARoutingOption and NMARoutingViolatedOption values. Thus the
// NMARoutingViolatedOption values offset from a larger value to leave room
// for NMARoutingOption values to grow in the future.
typedef NS_OPTIONS(NSInteger, NMARoutingViolatedOption) {
/** The returned route does not violate any options */
NMARoutingViolatedOptionNone NS_SWIFT_NAME(none) = 0,
/** The route passes through a blocked road (e.g. due to construction or a traffic accident) */
NMARoutingViolatedOptionBlockedRoad NS_SWIFT_NAME(blockedRoad) = 1 << 12,
/** The route passes through a road with a time-based turn restriction */
NMARoutingViolatedOptionTurnRestriction NS_SWIFT_NAME(turnRestriction) = 1 << 13,
/** The route's start direction is not as requested */
NMARoutingViolatedOptionStartDirection NS_SWIFT_NAME(startDirection) = 1 << 14,
/** The route uses roads or turns which are permanently forbidden for given truck */
NMARoutingViolatedPermanentTruckRestriction = 1 << 15,
/** The route uses roads that belong to restricted areas. */
NMARoutingViolatedOptionZoneRestriction NS_SWIFT_NAME(zoneRestriction) = 1 << 16
};
由于 4096 的二进制代码是 1000000000000 = 1 << 12。在代码文档中
从 NMARouter 返回的冲突选项值将是 NMARoutingOption 和 NMARoutingViolatedOption 值的 OR 组合。因此,NMARoutingViolatedOption 值从较大的值偏移,以便为 NMARoutingOption 值在未来增长留出空间。
1 << 0 (NMARoutingOption) 或 (NMARoutingViolatedOption 中的某个值) = 1 << 12 (4096)
这是获取 NMARoutingViolatedOption 值的正确逻辑吗?没有一个NMARoutingViolatedOption值不适合上述逻辑。谁能帮助我更好地理解这一点?