SPARQL Filter by distance

781 views Asked by At

Given some Buildings with their respective locations (lat and long), how can I get only the ones within certain distance?

Let's say I have an individual building0 located in an specific place.

ont1:building0 rdf:type ont1:Building 
ont1:building0 pos:lat 43.22 
ont1:building0 pos:lon -6.45

And I want to retrieve all the other buildings closer to 10km.

Does SPARQL allow to query this somehow?? Or at least show what the distance to other buildings is??

Thanks in advance

1

There are 1 answers

0
Kiran.B On BEST ANSWER

There is a formula to calculate distance based on Latitudes and Longitudes: http://andrew.hedges.name/experiments/haversine/

But, SPARQL does not support trigonometric functions.

GeoSPARQL has the goof:distance function to calculate distance between two geometric points (if you're able to use GeoSPARQL)