Skip to content

Reference routes

Since a long time the MapTrip SDK provides the opportunity of using reference routes. You can force the SDK routing, to calculate a route along the reference route (RR). A RR is a csv file, that contains just points of a polyline in WGS coordinates, delimited by semicolon.

Format of CSV File

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
long;lat
8.703130;53.861257
8.703217;53.861303
8.703323;53.861308
8.703420;53.861328
8.703520;53.861362
8.703833;53.861607
8.703958;53.861695
8.703958;53.861695
...

There are two ways, how to activate a RR.

Reference routing by getting destination from the RR

Get all (way-) points of this file by

1
val itrRefRouteWaypoints = Waypoint.getWaypointsFromFile(pathToTheCsvFile)

Get the last waypoint:

1
2
3
4
val wptLast = itrRefRouteWaypoints.last()

// Tell the SDK that you want to reach this waypoint along the RR
wptLast.setInitialRoutingMode(RoutingMode.REFERENCE_ROUTE)

The waypoint wptLast has already a user attribute called "refRouteFile". This string attribute contains the path to the csv file.

Add the waypoint to (a new) itinerary.

1
2
val itinerary = Itinerary()
itinerary.appendWaypoint(wptLast)

Now you can start a new navigation with this itinerary. The route and all reroutes for this navigation are calculated along the RR.

Reference routing with a destination, that is not part of the RR

Create a destination waypoint with the mandatory attributes

1
2
3
4
5
val wptLast = Waypoint()
// Set position (latitude, longitude)
wptLast.setWgs84Position(Position.createWGS84Position(53.861695, 8.703958))
wptLast.setInitialRoutingMode(RoutingMode.REFERENCE_ROUTE)
wptLast.setUserAttribute("refRouteFile", pathToTheCsvFile)

Add the waypoint to (a new) itinerary.

1
2
val itinerary = Itinerary()
itinerary.appendWaypoint(wptLast)

Now you can start a new navigation with this itinerary.
The route and all reroutes for this navigation are calculated along the RR.

Good to know

  • If the RR is very long, the route calculation needs more time!
  • If there are circles in the RR, the calculated route does not use these circles.
    The routing always tries to find the fastest way along the RR.
  • If there are restrictions along the RR, the routing will not unblock it. They will be bypassed instead.
  • The special parameters for the reference routing must be set at the last waypoint of the itinerary.