Skip to content

Allow geo predicates to operate on literals #640

@VladimirAlexiev

Description

@VladimirAlexiev

Use case: the user draws a polygon on the map and wants to find all features within.

  • The most natural way to do this is with a query where the polygon is given inline (rather than written to some temporary graph).
  • but you cannot specify or make triples in WHERE. You can only test triple patterns for existence
  • (You can make triples in CONSTRUCT, but only with "material" you already found with WHERE)
  • So the only way to test GeoSPARQL data against geometries specified inline, is to use geof functions but not geo predicates.
  • The problem is that functions are much slower: they can only test but cannot generate candidate solutions
  • So you have to fetch all geometries, then compare them against the inline polygon
  • in contrast, predicates can use the spatial index to quickly find only matching ontologies

GraphDB has such a non-standard extension but a customer challenged it, and asked instead "to allow functions to use the spatial index". But I don't see how this can be done: functions cannot take unbound arguments, and cannot generate candidate solutions.


To implement this in the ontology:

  • declare abstract Datatype ogc:geomLiteral as superclass of wktLiteral, gmlLiteral etc and subclass of rdf:Literal
    • I think but am not sure that literals can form class hierarchies
  • declare SpatialObjectOrGeometryLiteral as union of SpatialObject and ogc:geomLiteral
  • downgrade geo predicates from ObjectProperty to Property
  • redeclare their range to be SpatialObjectOrGeometryLiteral
    • let's leave the domain as is because this is not valid in RDF (it's only valid in "generalised RDF" but that's a hypothetical beast):
# invalid
"literal" geo:sfWithin "literal"
 
# valid
<geometry> geo:sfWithin "literal"

More important than the ontology: give examples! (and conformance tests)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions