Location context

VERSION 0.2.1455
PUBLIC PREVIEW

The Navigation SDK for iOS is only available upon request. Contact us to get started.

The detailed information about a current location on the road is called the location context. Every location update that comes from MapMatchingEngine to Navigation is map matched. Map matched locations are then used as an input for LocationContextDetectionEngine, which retrieves detailed information about the current location. Both MapMatchingEngine and LocationContextDetectionEngine can be customized during NavigationConfigurationBuilder creation.

1let configuration = NavigationConfigurationBuilder(
2 navigationKey: "<NAVIGATION-KEY>",
3 routingService: routingService
4)
5.with(mapMatchingEngine: customMapMatchingEngine)
6.with(locationContextDetectionEngine: customLocationContextDetectionEngine)
7.build()
8navigation = Navigation(configuration: configuration)

The details are returned as a LocationContext object.

LocationContext consists of:

  • speed - The current speed.
  • speedLimit - The speed limit, or null if it is unknown.
  • address - The address of the current location which consists of:
    • streetName - The street name.
    • city - The city.
    • countryCode - The 3-character ISO 3166-1 alpha-3 country code.
  • road - The road type of the current location which consists of:
    • isTunnel - Indicates if the location is in a tunnel.
    • isUnderpass - Indicates if the location is in an underpass.
    • functionalRoadClass - Indicates the relative importance of the road in the routing network. Regular values are in range [0, 7], where lower numbers indicate more important, faster roads.

To get current LocationContext updates, set up a TomTomNavigationDelegate::tomTomNavigation(_: Navigation, didDetectLocationContext context: LocationContext) callback.

1func tomTomNavigation(_: Navigation, didDetectLocationContext context: LocationContext) {
2 let speed: Measurement<UnitSpeed> = context.speed
3 let speedLimit: SpeedLimit? = context.speedLimit
4
5 let countryCode: String = context.address.countryCode
6 let city: String = context.address.city
7 let streetName: String = context.address.steetName
8
9 let functionalRoadClass: Int? = context.road?.functionalRoadClass
10 let isRoadTunnel: Bool? = context.road?.isTunnel
11 let isRoadUnderpass: Bool? = context.road?.isUnderpass
12}