Point-2-Point Route
Previous  Top  Next

(continued from click here)

This is an example, which calculates a route and then stores the route as SHP file at the end, which can be visualized.

NOTE: From v2.24 this can also be done with function RouteList instead - see sample.

Native coordinates of from and to positions
x1 = 100.12
y1 = 389.23
x2 = 193.49
y2 = 331.73

Calculate nearest start/end nodes
RWnetBase1.Coordinate2node(x1,y1,node1,dist1)
RWnetBase1.Coordinate2node(x2,y2,node2,dist2)

Actual route calculation - returns time (always minutes) and distance
routetime = RWcalc1.Route(node1,node2)
routedist = RWcalc1.GetNodeExtra(node2)

Scan the route to create the route as "output.shp"
RWcalc1.RouteFileCreate("output",1)
RWcalc1.RouteFileFieldAdd("linkID",2,0,0)
for i = RWcalc1.RouteFind(node2)-1 to 1 step -1
  t = rwcalc1.RouteGetLink(i)
  RWcalc1.RouteFileRecordAdd(1,str$(abs(t)))
  if t>0 then
    rwcalc1.RouteFileRecordAddSection(t,0,1)
  else
    rwcalc1.RouteFileRecordAddSection(-t,1,0)
  end if
next i
RWcalc1.RouteFileClose

Now you can show the route on a map together with the base street network and the route time & distance.