Location context

VERSION 0.2.2822
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 apiKey: "<NAVIGATION-KEY>",
3 routePlanner: routePlanner
4)
5.with(mapMatchingEngine: customMapMatchingEngine)
6.with(locationContextDetectionEngine: customLocationContextDetectionEngine)
7.build()
8self.navigation = Navigation(configuration: configuration)

The details are returned as a LocationContext object.

LocationContext consists of:

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

To get current LocationContext updates, set up a NavigationLocationContextObserver::func didDetectLocationContext(locationContext: LocationContext) callback.

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

Next steps

Since you have learned about location context, here are recommendations for the next steps: