New function suggestion: lineMerge
Opened this issue · 2 comments
As per #257 (comment)
We would like to suggest to have a geof:lineMerge
function in the standard, ( that could be used together with the collect function suggested by us in #400 ) .
Here is a sample query where we would like to use it, to assemble river line pieces from Openstreetmap into a single-(multi-)line river geometry:
SELECT (geof:lineMerge(geof:collect(?way_geom)) as ?elbe_geom) WHERE {
?s a osm:relation .
?s osmkey:name:de "Elbe" .
?s osmrel:member/osm:id ?m .
?m geo:hasGeometry/geo:asWKT ?way_geom
}
Our implementation can be found 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/GeoSparqlExFunctions.java#L94
@SimonBin Can you specify more precisely input/output conditions? My guesses:
- Input is MultiLineString (or LineString) where the end of each LineString is the same as the beginning of the next one
- Output is LineString
- Any other input returns UNBOUND
hi @VladimirAlexiev and thank you for your interest, similar to what you guessed, this is what we implemented:
- Input: (GeometryCollection of) Geometries
- Polygon uses the boundary line of the polygon
- Output: (Multi)LineString
- all lines are merged as good as possible, if they are disconnected we get multiline
- Point input returns unbound
as you can see, our implementation is just a wrapper to JTS LineMerger + OverlayNGRobust.union