Nearest N locations
Previous  Top  Next

(continued from click here)

When you want to know the nearest N objects in a store-theme for every object in a customer-theme, you should use function IsoCostDynLocationListN:

For simplicity, we assume access to the coordinates of the point objects in 2 arrays (x1,y1 for customer-theme and x2,y2 for store-theme):

Enter stores into location list
for j = 1 to storetheme.count
  RWnetBase1.Coordinate2location(x2[j],y2[j],link2,percent2,side,dist,xnew,ynew)
  RWcalc1.locationlistset(j,link2,percent2)
next j

for i = 1 to customertheme.count
  RWnetBase1.Coordinate2location(x1[i],y1[i],link1,percent1,side,dist,xnew,ynew)
Locate 5 nearest objects
  found = RWcalc1.isocostdynlocationlistN(link1,percent1,storetheme.count,5,0)
  if found > 0 then
    for j = 1 to found
      index = rwcalc1.LocationListGetNewPos(j);
      rwcalc1.locationlistget(index,link2,percent2);
      print "Customer "+str$(i)+": "+str$(j)+": "+str$(rwcalc1.getlinkcostdyn(link2,percent2))
    next
  else
    print "Nothing found for customer "+str$(i)
  end if
  print " "
next i