Does geof:buffer work? If so, can someone demonstrate a working query

32 views Asked by At

I am having trouble constructing a working query using geof:buffer

The definition of geof:buffer is "This function returns a geometric object that represents all Points whose distance from geom1 is less than or equal to the radius measured in units. Calculations are in the spatial reference system of geom1."

My dataset is 1000 1km square boxes in a 10km box. ex:center is the center of the 10km box.

Center:

<center>  geo:asWKT  "<http://www.opengis.net/def/crs/OGC/1.3/CRS84> POINT(138.5763200 -34.9500700)" .

An example box definition that is in the result set of query 3.

<box122>  a        geo:Geometry ;
        geo:asWKT  "<http://www.opengis.net/def/crs/OGC/1.3/CRS84> POLYGON((138.5559465 -34.9582197, 138.5778899 -34.9582197, 138.5778899 -34.9402337, 138.5559465 -34.9402337, 138.5559465 -34.9582197))"^^geo:wktLiteral .

Query 1: What I expect is to have about 37 results for this query, like query 3 returns, and for ?buffer to be a filled circle (maybe a polygon with a lot of edges?). It returns no results.

PREFIX geof: <http://www.opengis.net/def/function/geosparql/>
PREFIX geo: <http://www.opengis.net/ont/geosparql#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX uom: <http://www.opengis.net/def/uom/OGC/1.0/>
PREFIX ex: <http://example.com/>
select ?thing (geof:distance(?box,?center ,uom:metre) as ?distance) where { 
    ?thing geo:asWKT ?box.
    ex:center geo:asWKT ?center.
    bind (geof:buffer(?center,1000,uom:metre) as ?buffer).
    FILTER(geof:sfOverlaps(?box, ?buffer))
}  ORDER BY ?distance

Query 2: demonstrate that ?buffer is not bound

PREFIX geof: <http://www.opengis.net/def/function/geosparql/>
PREFIX geo: <http://www.opengis.net/ont/geosparql#>
PREFIX uom: <http://www.opengis.net/def/uom/OGC/1.0/>
PREFIX ex: <http://example.com/>
select ?center ?buffer where { 
    ex:center geo:asWKT ?center.
    bind (geof:buffer(?center,1000,uom:metre) as ?buffer).
    FILTER (!bound(?buffer))
}  ORDER BY ?distance

I get 1 row result as expected. If I change !bound to bound then I get no results.

Query 3: A query using geof:distance which should give me close to the same results I would expect query 1 to. I get 37 results for this query.

PREFIX geof: <http://www.opengis.net/def/function/geosparql/>
PREFIX geo: <http://www.opengis.net/ont/geosparql#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX uom: <http://www.opengis.net/def/uom/OGC/1.0/>
PREFIX ex: <http://example.com/>
select ?thing (geof:distance(?box,?center ,uom:metre) as ?distance) where { 
    ?thing geo:asWKT ?box.
    ex:center geo:asWKT ?center.
    FILTER (geof:distance(?box,?center ,uom:metre) < 1000)
}  ORDER BY ?distance

If geof:buffer does in fact work, can ?buffer be used with a sf:overLaps predicate rather than the function? Ultimately I want to query for boxes within certain distance from a point but don't want to use a filter as I expect performance will be poor since the filter will have to be evaluated for all geometries in the data set, whereas a predicate query would use the index.

1

There are 1 answers

0
Martina Dimova On

An issue related to the usage of geof:buffer has been raised, and you can find more details on Stack Overflow: Geosparql geof:distance measurement in query yields bad or no result.

This issue stems from the handling of measurement units provided as parameters. Presently, if measurement units are not provided, the query returns a polygonal result for the entire dataset. The negative or zero-distance buffer of lines and points always results in an empty polygon. This behavior is also observed for the buffers of degenerate (zero-area) polygons.

We acknowledge your concerns, and they will be addressed in a future version. Thank you for bringing this to our attention.