opengeospatial/ogc-geosparql

No function to collect geometries?

Opened this issue · 2 comments

In wake of the upcoming GeoSPARQL 1.1, I want to take the chance to clarify some things (maybe the answer is already clearly in the standard and I just missed it, in which case my apologies)

We found ourselves lacking in a collect aggregate function that accumulates geometries into a geometry collection. Would this be in scope for GeoSPARQL?

SELECT (geo:collect(?geom) as ?geomCollection) WHERE {
   ...
}

Nb, we made a sample implementation for use with Apache Jena here https://github.com/Scaseco/jenax/blob/jena-4.8.0/jenax-arq-parent/jenax-arq-plugins-parent/jenax-arq-plugins-bundle/src/main/java/org/aksw/jena_sparql_api/sparql/ext/geosparql/GeoSparqlExAggregators.java#L141

situx commented

Hi there,

if I understand correctly, this function will work on a geometry literal level. So you would convert, e.g., some POINT geometries defined as WKT literals to a GeometryCollection as defined in a WKT literal.

Even though we defined geometryN and numGeometries functions to access Multi-Geometry literals, I think we did not come across a use case in the working group that would involve the collect aggregate function.
Simply speaking, there was no demand by anyone as of yet.

However, as we are finishing our public comments phase, we can discuss this at our working group meeting next week.
In my opinion it would be a useful addition, especially given that there is already an implementation.

if I understand correctly, this function will work on a geometry literal level. So you would convert, e.g., some POINT geometries defined as WKT literals to a GeometryCollection as defined in a WKT literal.

This is correct, it would work similar to other accumulators defined in section 8.10. Spatial Aggregate Functions; I would assume it might either always return WKT or return GML if the majority of its collected geometries was in GML (our implementation always returns WKT)