Skip to main content

Handling Route Preferences

Last updated: April 7, 2026 | 8 minutes read

This guide explains how to customize routes using preferences, configure vehicle profiles, and apply routing constraints for different transport modes.

Configure route preferences

Set route options using RoutePreferencesObject to customize route calculations.

Generic route options:

PropertySetter / GetterDefault
accurateTrackMatchsetAccurateTrackMatch(_:) / getAccurateTrackMatch()true
allowOnlineCalculationsetAllowOnlineCalculation(_:) / getAllowOnlineCalculation()true
alternativeRoutesBalancedSortingsetAlternativeRoutesBalancedSorting(_:) / getAlternativeRoutesBalancedSorting()true
alternativesSchemasetAlternativesSchema(_:) / getAlternativesSchema()RouteAlternativesSchemaDefault
departureHeadingsetDepartureHeading(_:accuracy:) / getDepartureHeading() + getDepartureHeadingAccuracy()heading: -1, accuracy: 0
ignoreRestrictionsOverTracksetIgnoreRestrictionsOverTrack(_:) / getIgnoreRestrictionsOverTrack()false
maximumDistanceConstraintsetMaximumDistanceConstraint(_:) / getMaximumDistanceConstraint()true
pathAlgorithmsetPathAlgorithm(_:) / getPathAlgorithm()RoutePathAlgorithmTypeMagicLane
pathAlgorithmFlavorsetPathAlgorithmFlavor(_:) / getPathAlgorithmFlavor()RoutePathAlgorithmFlavorTypeMagicLane
resultDetailssetResultDetails(_:) / getResultDetails()RouteResultDetailsFull
routeRangessetRouteRanges(_:quality:) / getRouteRanges()[]
routeRangesQualitysetRouteRanges(_:quality:) / getRouteRangesQuality()100
routeTypesetRouteType(_:) / getRouteType()RouteTypeFastest
timestampsetTimestamp(_:) / getTimestamp()current time
transportModesetTransportMode(_:) / getTransportMode()RouteTransportModeCar

Complex structure creation options:

PropertySetter / GetterDefault
buildConnectionssetBuildConnections(_:maxLengthM:) / getBuildConnections()false
buildTerrainProfilesetBuildTerrainProfile(_:) / getBuildTerrainProfile()false

Vehicle profile options:

PropertySetter / GetterDefault
bikeProfilesetBikeProfile(_:) / getBikeProfile().road (BikeProfileRoad)
eBikeProfileDetailssetBikeProfile(_:withEBikeProfileDetails:) / getEBikeProfileDetails()
pedestrianProfilesetPedestrianProfile(_:) / getPedestrianProfile()PedestrianProfileWalk
truckProfilesetTruckProfile(_:) / getTruckProfile()all-zero struct

Route avoidance options:

PropertySetter / GetterDefault
avoidMotorwayssetAvoidMotorways(_:) / getAvoidMotorways()false
avoidTollRoadssetAvoidTollRoads(_:) / getAvoidTollRoads()false
avoidFerriessetAvoidFerries(_:) / getAvoidFerries()false
avoidCarpoolLanessetAvoidCarpoolLanes(_:) / getAvoidCarpoolLanes()false
avoidUnpavedRoadssetAvoidUnpavedRoads(_:) / getAvoidUnpavedRoads()false
avoidTurnAroundInstructionsetAvoidTurnAroundInstruction(_:) / getAvoidTurnAroundInstruction()false
avoidTrafficsetAvoidTrafficType(_:) / getAvoidTraffic()TrafficAvoidanceTypeNone

Emergency vehicle options:

PropertySetter / GetterDefault
emergencyVehicleModesetEmergencyVehicleMode(_:) / getEmergencyVehicleMode()false
emergencyVehicleExtraFreedomLevelssetEmergencyVehicleMode(_:extraFreedom:) / getEmergencyVehicleExtraFreedomLevels()0

Public transport options:

PropertySetter / GetterDefault
algorithmTypesetAlgorithmType(_:) / getAlgorithmType()RouteAlgorithmTypeDeparture
minimumTransferTimeInMinutessetMinimumTransferTimeInMinutes(_:) / getMinimumTransferTimeInMinutes()1
maximumTransferTimeInMinutessetMaximumTransferTimeInMinutes(_:) / getMaximumTransferTimeInMinutes()300
maximumWalkDistancesetMaximumWalkDistance(_:) / getMaximumWalkDistance()5000
sortingStrategysetSortingStrategy(_:) / getSortingStrategy()PTRouteSortingStrategyBestTime
routeTypePreferencessetRouteTypePreferences(_:) / getRouteTypePreferences()0 (none)
useBikessetUseBikes(_:) / getUseBikes()false
useWheelchairsetUseWheelchair(_:) / getUseWheelchair()false

Example — calculate the fastest car route with terrain profile:

let preferences = RoutePreferencesObject()
preferences.setTransportMode(.car)
preferences.setRouteType(.fastest)
preferences.setBuildTerrainProfile(true)

Configure vehicle profiles

Customize routing behavior for different vehicle types using profile configurations.

Truck profile

Define truck-specific routing preferences using the TruckProfileDetails C struct.

Available fields:

FieldTypeDefaultDescription
massInt320Truck weight in kg.
heightInt320Truck height in cm.
lengthInt320Truck length in cm.
widthInt320Truck width in cm.
axleLoadInt320Maximum load per axle in kg.
maxSpeedDouble0Maximum speed in m/s.

All fields default to 0, meaning they are not considered in routing. Set at least one field to a non-zero value to activate truck-specific restrictions.

Electric bike profile

Define electric bike routing preferences using the EBikeProfileDetails C struct together with a BikeProfile enum value.

Available EBikeProfileDetails fields:

FieldTypeDefaultDescription
typeEBikeProfileEBikeProfileNoneE-bike type.
bikeMassFloat0Bike mass in kg.
bikerMassFloat0Biker mass in kg.
auxConsumptionDayFloat0Auxiliary power consumption during day in Watts.
auxConsumptionNightFloat0Auxiliary power consumption during night in Watts.
batteryCapacityFloat1000Battery usable capacity in Wh.
departureSocFloatBattery state of charge at departure (0.01.0).
refSpeedFloat0Reference speed in m/s.
ignoreLegalRestrictionsBoolfalseIgnore country-based legal restrictions for e-bikes.

EBikeProfile values: EBikeProfileNone, EBikeProfilePedelec, EBikeProfilePowerOnDemand.

BikeProfile values: BikeProfileRoad, BikeProfileCross, BikeProfileCity, BikeProfileMountain.

PedestrianProfile values: PedestrianProfileWalk, PedestrianProfileHike.

Calculate truck routes

Compute routes optimized for trucks by setting truck-specific preferences and the lorry transport mode.

let departure = LandmarkObject.landmark(
withName: "Paris",
location: CoordinatesObject.coordinates(withLatitude: 48.87126, longitude: 2.33787)
)
let destination = LandmarkObject.landmark(
withName: "London",
location: CoordinatesObject.coordinates(withLatitude: 51.4739, longitude: -0.0302)
)

var truckProfile = TruckProfileDetails()
truckProfile.height = 180 // cm
truckProfile.length = 500 // cm
truckProfile.width = 200 // cm
truckProfile.axleLoad = 1500 // kg
truckProfile.maxSpeed = 60 // m/s
truckProfile.mass = 3000 // kg

let preferences = RoutePreferencesObject()
preferences.setTruckProfile(truckProfile)
preferences.setTransportMode(.lorry) // crucial
let nav = NavigationContext(preferences: preferences)
nav.calculateRoute(withWaypoints: [departure, destination],
statusHandler: { status in
// handle status,
}, completionHandler: { routes, code in
// handle routes
}
)

Calculate caravan routes

Compute routes for caravans and trailers with size and weight restrictions.

Caravans or trailers may be restricted on some roads due to size or weight, yet still permitted on roads where trucks are not. The key difference from a truck route is the transport mode: use .car instead of .lorry.

let departure = LandmarkObject.landmark(
withName: "Paris",
location: CoordinatesObject.coordinates(withLatitude: 48.87126, longitude: 2.33787)
)
let destination = LandmarkObject.landmark(
withName: "London",
location: CoordinatesObject.coordinates(withLatitude: 51.4739, longitude: -0.0302)
)

var caravanProfile = TruckProfileDetails()
caravanProfile.height = 180 // cm
caravanProfile.length = 500 // cm
caravanProfile.width = 200 // cm
caravanProfile.axleLoad = 1500 // kg

let preferences = RoutePreferencesObject()
preferences.setTruckProfile(caravanProfile)
preferences.setTransportMode(.car) // crucial — distinguishes caravan from truck

let nav = NavigationContext(preferences: preferences)
nav.calculateRoute(withWaypoints: [departure, destination],
statusHandler: { status in
// handle status,
}, completionHandler: { routes, code in
// handle routes
}
)
warning

Set at least one of height, length, width, or axleLoad to a non-zero value for restrictions to take effect. If all fields are 0, a normal car route is calculated.