Turn restrictions
RW Net can perform calculations in two modes: With and without support for turn restrictions. Which mode
to use has to be decided before a network is loaded through the use of property "TurnMode", where "true" means
support for turn restrictions. The internal working of the two modes are quite different, which means
performance and requirements are quite different:
- Turn restriction mode is appr. 2 times as slow as normal mode.
- Allowing U-turns slow the calculations down further (appr. 30%).
- Turn restriction mode takes up more RAM - see Function NWload for details.
Querying a route
In normal mode, each intersection/node can only be visited once on a route. In turn restriction mode each
link can only be travelled once in each direction, but the intersections can be visited several times - even
on the same route.
This has some implications when mixing the two modes in the same application:
If you call Route with the same from- and tonode, you will get an error code in normal mode, while
turn restriction mode will return a valid path, which may be just one link travelled in both directions (if you
allow U-turns) or something a little more complicated otherwise depending on your network.
In normal mode you would use a loop like this to query the cost along a route (pascal-code):
route(node1,node2);
length:= RouteFind(node2);
for i:= length downto 1 do
begin
writeln('Node: ',RouteGetNode(i),' ',GetNodeCost(RouteGetNode(i)),' km');
end;
Writeln('Total cost: ',GetNodeCost(node2));
Since a node can be part of a route more than once in turn restriction mode, you can not use the loop
above, but has to use a loop like this instead. The advantage is that this loop will also work in normal
mode and produce the same results as above:
Route(node1,node2);
length:= Routefind(node2);
for i:= length downto 1 do
begin
write('Node: ',RouteGetNode(i));
if i=length then writeln(' 0 km') else
writeln(' ',GetLinkCost(RouteGetLink(i)),' km');
end;
Writeln('Total cost: ',GetNodeCost(node2));
Adding turn restrictions
When adding restrictions to the network you can choose between either a 100% restriction (a negative value)
or a delay expressed in the same unit as costs. If cost is measured in minutes, using "1" would add a delay
of 1 minute for a specific turn. This could be e.g. left-turns.
When querying a route the delay is added after the turn has been performed: A delay of 2 minutes at node B has
no impact on the cost of going from node A to node B, whereas if you move on to another node, the 2 minutes are
reflected in the next node on the route.
Restrictions can be added, updated and deleted using the same function (TurnRestriction). It is also possible
to add restrictions to a normal 4-road intersection in one step by using function TurnStandard. Then no turns
are allowed except driving straight through.
It is the users decision where to keep the information about turn restrictions since these are not written to
any of the network files. They will have to be applied each time the network is loaded, but this is really fast.