Distance Matrix (curb approach)
Previous  Top  Next

(continued from click here)

This example is mostly for those that need a distance matrix for further calculations, where curb approach matters.

Make sure turnmode is true.

Set up N random locations, where link number is from 1 to 1000
for i = 1 to N
  rwcalc1.LocationListSet(i,trunc(random*1000)+1,0.5)
next i

Handle combinations where link1 <> link2
for approach1 = 1 to 2
  for i = 1 to N
    rwcalc1.LocationListGet(i,link1,percent1)
    rwcalc1.IsoCostDynLocationList2(link1,percent1,N,approach1*512)
    for j = 1 to N
      rwcalc1.LocationListGet(j,link2,percent2)
      if link1<>link2 then 
        for approach2 = 1 to 2
          matrix[approach1,approach2,i,j] =  rwcalc1.GetLinkCostDyn2(link2,percent2,extra,approach2*512)
        next approach2
      end if
    next j
  next i
next approach1

Handle combinations where link1 = link2
for i = 1 to N
  rwcalc1.LocationListGet(i,link1,percent1)
  for j = 1 to N
    rwcalc1.LocationListGet(j,link2,percent2)
    if link1=link2 then 
      for approach1 = 1 to 2
        for approach2 = 1 to 2
          c = rwcalc1.RouteDyn_Approach(link1,link2,percent1,percent2,
                                        approach1*512,approach2*512,
                                        fromto1,fromto2,rlength,extra)
          if c<0 then
            matrix[approach1,approach2,i,j] = 1e38
          else
            matrix[approach1,approach2,i,j] = c
          end if
        next approach2
      next approach1

    end if
  next j
next i

It is important to do it as 2 loops, or the calls to RouteDyn_Approach will clear the isochrone setup previously.