I'm creating a set of features and adding them to a QgsSpatialIndex to find the ones closest to a certain location.
Why does nearestNeighbor() always return [0L] instead of the correct feature id?
import random
index = QgsSpatialIndex()
for i in range(0,10):
feat = QgsFeature()
pt = QgsPoint(
random.randint(0,10),
random.randint(0,10))
feat.setGeometry(QgsGeometry.fromPoint(pt))
index.insertFeature(feat)
nearest = index.nearestNeighbor(QgsPoint(5,5),1)
print nearest