GeoKnow / LinkedGeoData

OpenStreetMap for the Semantic Web
http://linkedgeodata.org
GNU General Public License v3.0
133 stars 32 forks source link

st_intersects() distance between points does not match with the precision parameter #34

Open JoaoAlmeida opened 4 years ago

JoaoAlmeida commented 4 years ago

The LinkedGeoData site has some examples of SPARQL queries. One example says it retrieves all amenities 100m from Leipzig Central Station. However, the SPARQL query results have much more distance than 100m from the Central Station.

The example's text is wrong, or the function is wrong?

Ps: I have verified the distance between the points using the OpenStreetMap site.

TallTed commented 3 years ago

There have been numerous improvements in Virtuoso's GeoSPARQL support (among other things) in the 4+ years since version 07.20.3215 built Jan 12 2016, which is backing the LinkedGeoData site.

It would be very helpful if the Virtuoso instance could be updated to a current build of Open Source Edition (as is currently in use), where I believe commits 82326dd and dc1e353 made in January 2020, may resolve the reported issue.

JoaoAlmeida commented 3 years ago

I believe "st_intersects()" returns the distance in unit degrees. So, I am using the following equation to convert the distance into meters: distance [m] = 6378137.0 [m] Pi distance [degree] / 180.0

I am using this equation in my applications, and the results look fine.

TallTed commented 3 years ago

@JoaoAlmeida -- Starting with your equation, I compute the intended 100m distance in the cited example should instead be 0.000898315284 degrees.

( 100 * 180.0 ) / ( 6378137.0 * Pi ) = 0.000898315284

Substituting that value into the example query, I get a zero row result set.

Bumping the distance to 500m, inserting the new degree value in the query, I get a reasonably sized result set which may allow you to confirm that the results are as desired/expected ... and if so, that should be a clear enough demonstration that either the documentation should be changed to match (i.e., that the distance is specified in degrees, as calculated by your formula), or the function should be redefined within Virtuoso such that the distance is indeed specified in meters.