2

RDF:

prefix ex: <http://www.example.org/> 
prefix geo: <http://www.opengis.net/ont/geosparql#> 

ex:b7 a sf:Line ;
geo:asWKT "<http://www.opengis.net/def/crs/EPSG/0/4326> LINESTRING(55.3 -160.5,55.3 -160.5)^^geo:wktLiteral .

SPARQL query:

prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns>
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix geo: <http://www.opengis.net/ont/geosparql#> 
prefix geof: <http://www.opengis.net/def/function/geosparql/>
prefix sf: <http://www.opengis.net/ont/sf#> 
prefix ex: <http://www.example.org/> 
prefix ogis: <http://www.opengis.net/def/uom/OGC/1.0/>

select * where {
  ?a a sf:Line .
  FILTER (geo:sfWithin(?a, "<http://www.opengis.net/def/crs/EPSG/0/4326> POLYGON((50 -170, 50 -140, 60 -140, 60 -170))"^^geo:wktLiteral))
}

In open-source edition of Virtuoso this results in the error:

Virtuoso 42000 Error RDFGE: RDF box with a geometry RDF type and a non-geometry content

Does the line also need to be declared as a geo:Geometry?

Edit: sf:Line is a subclass of geo:Geometry, so I assumed it could be used in the same fashion.

There
  • 498
  • 6
  • 18
  • 1
    you should use the WKT serialization in the filter. `select * where { ?a a sf:Line ; geo:asWKT ?lit . FILTER (geo:sfWithin(?lit, " POLYGON((50 -170, 50 -140, 60 -140, 60 -170))"^^geo:wktLiteral)) }` – UninformedUser Mar 15 '22 at 05:58
  • @UninformedUser Makes sense but still results in the same error. In the past I used geo:Geometry but I thought since sf:Line is a subclass of geo:Geometry, that it would work as well? – There Mar 15 '22 at 16:25
  • @UninformedUser I think it's an issue with the polygon coordinates. This polygon works and returns results: `FILTER (geo:sfWithin(?lit, " POLYGON((0 -160, 60 -160, 60 -20, 0 -20,0 -160))"^^geo:wktLiteral))` – There Mar 15 '22 at 16:41
  • Please change your comment to an answer (you can answer your own question) if this represents a solution. If not, please raise this on the [OpenLink Community Forum](https://community.openlinksw.com/) or on the [GitHub-hosted Virtuoso project](https://github.com/openlink/virtuoso-opensource/issues/), so we can better interact with you (these comments are VERY limiting) and find the solution. – TallTed Mar 16 '22 at 19:03
  • Also, I noticed that your initial RDF lacks the closing `"` in `-160.5)^^geo:wktLiteral` -- which should be `-160.5)"^^geo:wktLiteral` -- and this *may* be a contributing factor... – TallTed Mar 16 '22 at 19:08

0 Answers0