1

def linearMatrix(self, writer, provider1, provider2, index1, index2, nearest, distArea, matType, sindex, progressBar):

2

if nearest > 1:

3

inFeat = QgsFeature()

4

outFeat = QgsFeature()

5

inGeom = QgsGeometry()

6

outGeom = QgsGeometry()

7

start = 15.00

8

add = 85.00 / provider1.featureCount()

9

while provider1.nextFeature(inFeat):

10

inGeom = inFeat.geometry()

11

inID = inFeat.attributeMap()[index1].toString()

12

featList = sindex.nearestNeighbor(inGeom.asPoint(), nearest)

13

distList = []

14

vari = 0.00

15

for i in featList:

16

provider2.featureAtId(int(i), outFeat, True, [index2])

17

outID = outFeat.attributeMap()[index2].toString()

18

outGeom = outFeat.geometry()

19

dist = distArea.measureLine(inGeom.asPoint(), outGeom.asPoint())

20

if dist > 0:

21

if matType == "Linear": writer.writerow([unicode(inID), unicode(outID), str(dist)])

22

else: distList.append(float(dist))

23

if matType == "Summary":

24

mean = sum(distList) / len(distList)

25

for i in distList:

26

vari = vari + ((i  mean)*(i  mean))

27

vari = sqrt(vari / len(distList))

28

writer.writerow([unicode(inID), str(mean), str(vari), str(min(distList)), str(max(distList))])

29

start = start + add

30

progressBar.setValue(start)

31

del writer

32

else:

33


34

break
