2

I'm need to write a query to check if a determined Point is inside a Polygon.

I'm trying to use GeoSparql, but isn't producing the expected results.

If I execute a simple query, like it:

PREFIX iot-lite: <http://purl.oclc.org/NET/UNIS/fiware/iot-lite#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX geo: <http://www.w3.org/2003/01/geo/wgs84_pos#>
PREFIX geof: <http://www.opengis.net/def/function/geosparql/>

SELECT ?poligono ?pointGeo
    WHERE{
    ?casa  iot-lite:hasPoint ?poligono ;
            rdf:type iot-lite:Polygon .
    ?point  rdf:type  geo:Point ;
            iot-lite:hasPoint ?pointGeo .  
}

The results are:

?poligon
    "POLYGON((-16.67362 -49.24468, -16.67363 -49.24466, -16.67365 -49.24468, -16.67364 -49.2447, -16.67364 -49.24468))"^^<http://www.opengis.net/ont/sf#wktLiteral>

?pointgeo    
    "POINT((-16.67363 -49.24468))"^^<http://www.opengis.net/ont/sf#wktLiteral> 

But if i add the filter below to the query, it return nothing. But the problem is: the point is within the polygon

FILTER (geof:sfWithin(?pointGeo, ?poligono))
Mayke Ferreira
  • 174
  • 2
  • 9

1 Answers1

1

Jena doesn't implement GeoSPARQL. See the documentation for the Jena specific spatial functions.

chrisis
  • 1,983
  • 5
  • 20
  • 17
  • Either when I run this query at CloudDB the results are the same. Why? It's not a Jena implementation, so it should works, right? – Mayke Ferreira Jul 18 '18 at 13:24
  • Don't know CloudDB but it would depend on what software they use to implement their SPARQL endpoint. GeoSparql support is far from universal. – chrisis Jul 18 '18 at 16:57
  • 1
    @MaykeFerreira what is CloudDB, where does it support SPARQL? and why do you assume that nay triple store supports GeoSPARQL? It's not part of the W3C SPARQL specs... – UninformedUser Jul 18 '18 at 18:01
  • 1
    by the way it is not so difficult to make support that Geosparql in jena, at least for that function: need just implement `org.apache.jena.sparql.function.Function` and register namespace 'geof:sfWithin' in the jena-system. Maybe there are already ready-made solutions in github or somewhere else. – ssz Jul 19 '18 at 15:50
  • @ssz do you have any idea how i can link a prefix geof:sfWithin with their respective method implementation?? I ask it, because I found some examples, and the link is made between the prefix and a java method, and, in this case, I don't have access to sfWithin function. – Mayke Ferreira Jul 20 '18 at 00:48
  • 1
    need to link full uri (not just prefixed form) with java-body. See `org.apache.jena.sparql.function.StandardFunctions` how it is made for xpath-functions (namespaces `fn` and `math`). – ssz Jul 20 '18 at 08:04
  • Hello....Is it possible to use geosparql in Python as mentioned like above in Java ? – Manoj Deshpande May 03 '20 at 18:09