RE: SPARQL & SemWeb

>> Another interesting query would be "Give me all pictures I took in  
>> city X".
>> In order to solve this puzzle, one would have to know the exact  
>> spatial data
>> of city X (a bounding rectangle would not be enough) and be able  
>> to pinpoint
>> Lat/Lon within that range, using a RDF-querylanguage... I think  
>> that's a
>> hard one to answer for.

Hey Group, I'd like to thank you all for the response I've gotten in
reference to this question.

Based on your notes, I've decided to write an algorithm that does this:
(the city is made out of one single geoPoint)

Input: 
-	Latitude range (-90 to 90) 
-	Longitude range (-180 to 180)
-	Range (in KM)

Work:
Calculate a rectangle around the geopoint using the formula of distance
between two points on a sphere (note that I make the assumption that the
globe is a perfect sphere.)

Then using the rectangle points as doubles, I plan to use them in SPARQL
with basic math functions. Something like:

SELECT ?object WHERE
{
	?object geo:lat ?lat .
	?object geo:lon ?lon
}
FILTER
{ botlat < ?lat && ?lat < toplat && leftlon < ?lon && ?lon < rightlon }

This will return all the objects within my rectangle. The rectangle was
bigger than the intended radiuscircle, thus it might return unwanted
geopoints in the far corners of the rectangle. This can still be dealt with
in main memory.... (where you do have the use of handy sine and cosine
functions to calculate which points are relevant, and which ain't.)

This method can be extended to spatial objects.. just calculate a bounding
box around your spatial object.. use the rectangle to query the RDF source
and filter the results in main memory.

I think this is the best method to do spatial queries in SPARQL, so far..
Perhaps better support for spatial queries will come along eventually?

If anybody would like the C# code of the things described above, I'd be
happy to provide.

Cheers,

Luk

Received on Tuesday, 18 April 2006 05:35:27 UTC