Hi All,
Having some trouble with a query using the st_distance function so I'm
hoping that someone can help me clarify things.

I'm using Virtuoso 7.2.6 installed via
https://sourceforge.net/projects/virtuoso/files/virtuoso/7.2.6-dev/virtuoso-opensource.x86_64-generic_glibc25-linux-gnu.tar.gz/download

The virtuoso documentation refers to the st_distance function as returning
"the shortest distance between two points such that the first point is part
of g1 and the second of g2." I've interpreted this to mean that the
function should work for any two geometries - in my case I'd like to apply
it to compare a point and a poly line. I've been unsuccessful so far, to
demonstrate a simple example, if I pose the following query:
  PREFIX transit: <http://ontology.eil.utoronto.ca/icity/PublicTransit/>
  PREFIX spatial: <http://ontology.eil.utoronto.ca/icity/SpatialLoc/>
  PREFIX geo: <http://www.opengis.net/ont/geosparql#>
  PREFIX bif: <http://www.openlinksw.com/schemas/bif#>

  SELECT ?x ?d WHERE
{
  ?x a transit:TransitVehicle.
  ?x transit:onRoute <100>.
  ?x spatial:hasLocation ?f.
  ?f geo:hasGeometry ?g.
  ?g geo:asWKT ?g_wkt.

  BIND(bif:st_distance(bif:st_geomfromtext(bif:st_astext(?g_wkt)),
bif:st_geomfromtext("LINESTRING(-79.339383 43.722233,-79.339534
43.722787,-79.339601 43.723018)")) AS ?d)

}
LIMIT 10
Virtuoso returns the following error:
"Virtuoso 22023 Error GEO..: Function st_distance() expects a geometry of
type 1 as argument 1, not geometry of type 2"

However, Virtuoso returns the results for the following query successfully:
  PREFIX transit: <http://ontology.eil.utoronto.ca/icity/PublicTransit/>
  PREFIX spatial: <http://ontology.eil.utoronto.ca/icity/SpatialLoc/>
  PREFIX geo: <http://www.opengis.net/ont/geosparql#>
  PREFIX bif: <http://www.openlinksw.com/schemas/bif#>

  SELECT ?x ?d WHERE
{
  ?x a transit:TransitVehicle.
  ?x transit:onRoute <100>.
  ?x spatial:hasLocation ?f.
  ?f geo:hasGeometry ?g.
  ?g geo:asWKT ?g_wkt.

  BIND(bif:st_distance(bif:st_geomfromtext(bif:st_astext(?g_wkt)),
bif:st_geomfromtext("POINT(-79.339383 43.722233)")) AS ?d)

}
LIMIT 10

This leads me to believe that perhaps there is an issue with the
st_distance function. Or, perhaps my implementation is missing something?
_______________________________________________
Virtuoso-users mailing list
Virtuoso-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/virtuoso-users

Reply via email to