Route sections

VERSION 0.44.1
PUBLIC PREVIEW

Route sections are parts of the planned route that have specific characteristics, such as ones on a ferry or motorway, or sections with traffic incidents in them. You can show users where these things lie on a planned route using sections. Moreover, sections can be used to see if specific avoids were observed or a route contains an avoided segment type.

Sections are requested by default. The lane, speed limit, and road shield sections can be retrieved with an API key for the extended Routing API. To do so, specify ExtendedSections.all with GuidanceOptions.extendedSections. Read more about route planning in the Planning a route guide.

The array of supported section types can be found further in this guide.

1let amsterdamCoordinate = CLLocationCoordinate2DMake(52.3764527, 4.9062047)
2let berlinCoordinate = CLLocationCoordinate2DMake(52.5069751, 13.3631919)
3let itinerary = Itinerary(
4 origin: ItineraryPoint(coordinate: amsterdamCoordinate),
5 destination: ItineraryPoint(coordinate: berlinCoordinate)
6)
7
8let options: RoutePlanningOptions
9var routePlanner: OnlineRoutePlanner!
10do {
11 options = try RoutePlanningOptions(
12 itinerary: itinerary,
13 guidanceOptions: GuidanceOptions(extendedSections: .all)
14 )
15} catch {
16 print("Invalid planning options: \(error.localizedDescription)")
17 return
18}

Specific sections can be found within the Route object by the corresponding properties like Sections.motorwaySections, Sections.laneSections, etc.

1func handleResponse(response: RoutePlanningResponse) {
2 guard let route = response.routes?.first else { return }
3 let laneSections = route.sections.laneSections
4 let motorwaySections = route.sections.motorwaySections
5 let trafficSections = route.sections.trafficSections
6}

Each section in the response has three basic properties:

However, some specific section types return additional information about the section.

The possible section types are:

  • LaneSection - Represents a route section with a lane section available. It additionally provides:
    • Information about the Lane and Direction the driver should follow.
    • Information about the lane separators.
    • Only available with an API key for the Routing API with extended guidance.
  • TrafficSection - Represents a route section with traffic information. It also provides:
    • The category of the incident. There will never be more than one incident in any section.
    • The delay caused by the incident (in seconds).
    • The magnitude of the delay caused by the incident.
    • Detailed information about the incident (TPEG2-TEC standard).
    • The average effective speed in that section (km/h).
  • VehicleRestrictedSection - Represents a route section restricted for the given vehicle.
  • SpeedLimitSection - Represents a route section with a speed limit.
    • Provides the speed limit in the section in kilometers per hour.
    • Only available with an API key for the Routing API with extended guidance.
  • TollSection - Represents a route section that requires a toll payment.
  • FerrySection - Represents a route section that is a ferry.
  • MotorwaySection - Represents a route section that is a motorway.
  • CarTrainSection - Represents a route section that has a car train.
  • TunnelSection - Represents a route section with a tunnel.
  • PedestrianSection - Represents a route section with a pedestrian area.
  • TollVignetteSection - Represents a route section that requires a toll vignette.
  • CountrySection - Represents a route section considered a country road.
  • RoadShieldSection - Represents a route section with a shield marked part of the road.
    • Only available with an API key for the Routing API with extended guidance.
  • UrbanSection - Represents a route section within urban areas.
  • CarpoolSection - Represents a route section that requires the use of carpool (HOV/High Occupancy Vehicle) lanes.
  • UnpavedSection - Represents a route section with an unpaved road.
  • LowEmissionZoneSection - Represents a route section that runs through a low-emission zone.