Hey!
I've written this Python script that is comparing three diffrent path distances from a starting point and the three nearest target Points, and choosing the shortest one to be output. Does anyone have a clue if I can make it more efficient? Atm it takes a long time since it iterates through ca 82000*82000 features...
class FeatureProcessor(object):
def __init__(self):
self.featureList = ]
def input(self,feature):
self.featureList.append(feature)
def close(self):
r = int(len(self.featureList)/3)
for i in range(1, r+1):
valueList = a]
nearestList = a]
for feature in self.featureList:
j = int(feature.getAttribute('gid'))
if j == i:
nearestList.append(feature)
for feature in nearestList:
value = feature.getAttribute('Totalt_Avstånd')
valueList.append(value)
minValue = min(valueList)
for feature in nearestList:
if feature.getAttribute('Totalt_Avstånd') == minValue:
self.pyoutput(feature)
If someone has a different solution than using Python for this, please feel free to suggest it!
Thank you!