I am new to GeoIndex. Currently I have ~1600 geo-tagged images, I am working with GeoIndex to find all images within a certain radius of my point(or my current location), all is working fine, it is returning the points which match the query. However as each image has a unique URL I need to be able to maintain the link between Geo coordinate and the URL.
For example:
def find_distance(index,myLocation,arraySearch,radius):
myUrlArray = []
for coords in arraySearch:
index.add_point(GeoPoint(coords[0],coords[1]))
for point,distance in index.get_nearest_points(myLocation,radius,'km'):
print point
myLocation is passed in as a paramter as is an array called arraySearch which contains data read from a JSON file in the following format:
arraySearch = [(latitudecoordinate,longitudecoordinate,url)]
when running the above function I get the following output:
Point(54.573307, -5.998721)
Point(54.600225, -5.920579)
Point(54.598671, -5.918605)
Point(54.598671, -5.918605)
Point(54.598671, -5.918605)
Point(54.598671, -5.918605)
Point(54.598671, -5.918605)
Point(54.598671, -5.918605)
Point(54.601469, -5.921652)
Point(54.601493, -5.920901)
Ideally I would like:
(Point(x,y),URL)
thanks in advance!
Edited to correct indentation errors in code
Then you simply need to include the url in the ref
slot available in the object structure:
def find_distance(index,myLocation,arraySearch,radius):
myUrlArray = []
for value in arraySearch:
index.add_point(GeoPoint(value[0],value[1], ref=value[2]))
for point,distance in index.get_nearest_points(myLocation,radius,'km'):
print point, point.ref
As the Point
object doesn't include this attribute in their __repr__
method, you will need to add it in your print
statement as above.