This is an example, which calculates a route with dynamic segmentation 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 locations
RWnetBase1.Coordinate2location(x1,y1,link1,percent1,side,dist,xnew,ynew)
RWnetBase1.Coordinate2location(x2,y2,link2,percent2,side,dist,xnew,ynew)
The routedyn function doesn't accept 0 or 1 as percentage, so we make this check first:
if percent1=0 then percent1 = 0.0001 else if percent1=1 then percent1=0.9999 end if
if percent2=0 then percent2 = 0.0001 else if percent2=1 then percent2=0.9999 end if
Actual route calculation - returns time (always minutes) and distance routetime = RWcalc1.RouteDyn(link1,link2,Percent1,Percent2,fromto1,fromto2,routelength,routedist)
(See function RouteFindDyn for further details for possible performance improvements)
Scan the route to create the route as "output.shp"
rwcalc1.RouteFileCreate("output",1)
rwcalc1.RouteFileFieldAdd("ID",2,0,0)
rwcalc1.RouteFileRecordAdd(1,"1")
if (link1=link2) and (routelength=0) then
rwcalc1.RouteFileRecordAddSection(link1,percent1,percent2)
else
if fromto1=0 then
rwcalc1.RouteFileRecordAddSection(link1,percent1,0)
else
rwcalc1.RouteFileRecordAddSection(link1,percent1,1)
end if
for i = routelength-1 to 1 step -1
rwcalc1.RouteFileRecordAdd(1,str$(routelength+1-i))
t = rwcalc1.RouteGetLink(i)
if t>0 then
rwcalc1.RouteFileRecordAddSection(t,0,1)
else
rwcalc1.RouteFileRecordAddSection(-t,1,0)
end if
next i
rwcalc1.RouteFileRecordAdd(1,str$(1+routelength))
if fromto2=0 then
rwcalc1.RouteFileRecordAddSection(link2,0,percent2)
else
rwcalc1.RouteFileRecordAddSection(link2,1,percent2)
end if
end if
RWcalc1.RouteFileClose
Now you can show the route on a map together with the base street network and the route time & distance.