Route sections

VERSION 0.2.2822
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. Using sections, you can show users where these things lie on a planned route. Moreover, sections can be used to see if specific avoids were observed or if a route contains an avoided segment type.

Sections are requested by default. The lane, speed limit, and road shields sections can be retrieved if you have 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: .init(coordinate: amsterdamCoordinate),
5 destination: .init(coordinate: berlinCoordinate)
6)
7
8let options: RoutePlanningOptions
9do {
10 options = try .init(
11 itinerary: itinerary,
12 guidanceOptions: .init(extendedSections: .all)
13 )
14} catch {
15 print("Invalid planning options: \(error.localizedDescription)")
16 return
17}

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

1guard let route = response.routes?.first else { return }
2let laneSections = route.sections.laneSections
3let motorwaySections = route.sections.motorwaySections
4let trafficSections = route.sections.trafficSections

Each section in the response has three basic properties:

However, some of the 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 (in 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.
  • TollRoadSection - 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 pedestrian area.
  • TollVignetteSection - Represents a route section that requires a toll vignette.
  • CountrySection - Represents a route section that is considered as a country road.
  • RoadShieldSection - Represents a route section with shield marked part of the road.
    • Only available with an API key for the Routing API with extended guidance.
  • UrbanSection - Represents a route section that is location within urban areas.
  • CarpoolSection - Represents a route section that requires use of carpool (HOV/High Occupancy Vehicle) lanes.
  • UnpavedSection - Represents a route section with an unpaved road.