stSPARQL Reference

On this page you can find the definitions of the spatial and temporal extension functions that we have defined in stSPARQL.

The following prefixes are used in this document:
PREFIX strdf: <http://strdf.di.uoa.gr/ontology#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>

Table of Contents
  1. Spatial extension functions complying with the OGC-Simple Features Access standard.
    1. Basic functions
    2. Functions for testing named topological relationships
    3. Functions for testing named topological relationships based on the minimum bounding boxes of geometries
    4. Functions for testing directional relationships based on the minimum bounding boxes of geometries
    5. Spatial analysis functions
  2. Spatial Extension Functions complying with the GeoSPARQL standard (to be completed)
  3. Temporal Extension Functions


Spatial Extension Functions

Basic Functions

The following functions enable the retrieval of a property of a geometry:
  • xsd:int strdf:dimension(strdf:geometry A): Returns the inherent dimension of geometry A, which must be less than or equal to the coordinate dimension.
  • xsd:string strdf:geometryType(strdf:geometry A): Returns the type of geometry A as a string.
  • xsd:int strdf:srid(strdf:geometry A): Returns the unique identifier of the coordinate reference system that is used when ecoding the coordinates of geometry A.

The following functions enable the retrieval of the desired representation of a geometry:
  • strdf:WKT strdf:asText(strdf:geometry A): Returns the Well-Known Text (WKT) serialization of geometry A.
  • strdf:GML strdf:asGML(strdf:geometry A): Returns the Geography Markup Language (GML) serialization of geometry A.

The following functions enable us to test whether a certain condition holds:
  • xsd:int strdf:isEmpty(strdf:geometry A): Returns true if geometry A is an empty geometry. If true, then this geometry represents an empty geometry collection, polygon, point etc.
  • xsd:string strdf:isSimple(strdf:geometry A): Returns true if geometry A has no anomalous geometric points, such as selfintersection or selftangency.

Topological Relationships

    The following functions enable us to test whether a topological relation holds among two geometries:
    • xsd:boolean strdf:equals(strdf:geometry A, strdf:geometry B): Returns true if the given geometries are identical.
    • xsd:boolean strdf:disjoint(strdf:geometry A, strdf:geometry B): Returns true if the the given geometries are disjoint, meaning that they do not share any space together.
    • xsd:boolean strdf:intersects(strdf:geometry A, strdf:geometry B): Returns true if the given geometries "spatially intersect", meaning that they share some portion of space.
    • xsd:boolean strdf:touches(strdf:geometry A, strdf:geometry B): Returns true if the given geometries have at least one boundary point in common, but their interiors do not intersect.
    • xsd:boolean strdf:crosses(strdf:geometry A, strdf:geometry B): Takes two geometries and return true if they "spatially cross", that is, the geometries have some, but not all interior points in common. In addition, the intersection of the interiors of the geometries must not be the empty set and must have a dimensionality less than the the maximum dimension of the two input geometries. Finally, the intersection of the two geometries must not equal either of the source geometries. Otherwise, it returns false.
    • xsd:boolean strdf:within(strdf:geometry A, strdf:geometry B): Returns true if geometry A is completely inside geometry B. If strdf:within(A, B) is true and strdf:within(B,A) is true, then the two geometries are considered spatially equal.
    • xsd:boolean strdf:contains(strdf:geometry A, strdf:geometry B): Returns true if and only if no points of B lie in the exterior of A, and at least one point of the interior of B lies in the interior of A.
    • xsd:boolean strdf:overlaps(strdf:geometry A, strdf:geometry B): Returns true if the geometries share space, are of the same dimension, but are not completely contained by each other.
    • xsd:boolean strdf:relate(strdf:geometry A, strdf:geometry B, xsd:string intersectionPatternMatrix): Returns true if geometry A is spatially related to geometry B, by testing for intersections between the interior, boundary and exterior of the two geometries as specified by the values in the intersectionPatternMatrix.

    Topological Relationships (based on minimum bounding boxes)

    The following functions can be used to test whether the bounding boxes of two geometries satisfy a topological relationship:
    • xsd:boolean strdf:mbbIntersects(strdf:geometry A, strdf:geometry B): Returns true if the minimum bounding box of geometry A intersects the minimum bounding box of geometry B.
    • xsd:boolean strdf:mbbEquals(strdf:geometry A, strdf:geometry B): Returns true if the minimum bounding box of geometry A is equal to the minimum bounding box of geometry B.
    • xsd:boolean strdf:mbbWithin(strdf:geometry A, strdf:geometry B): Returns true if the minimum bounding box of geometry A is within the minimum bounding box of geometry B
    • xsd:boolean strdf:mbbContains(strdf:geometry A, strdf:geometry B): Returns true if the minimum bounding box of geometry A contains the minimum bounding box of geometry B

    Directional Relationships (based on minimum bounding boxes)

    The following functions can be used to test whether two geometries satisfy a directional relationship. The directional relationships covered are defined using the minimun bounding box of the geometries.
    • xsd:boolean strdf:left(strdf:geometry A, strdf:geometry B): Returns true if the minumum bounding box of geometry A is strictly on the left of the minimum bounding box of geometry B.
    • xsd:boolean strdf:right(strdf:geometry A, strdf:geometry B): Returns true if the minumum bounding box of geometry A is strictly on the right of the minimum bounding box of geometry B.
    • xsd:boolean strdf:above(strdf:geometry A, strdf:geometry B): Returns true if the minumum bounding box of geometry A is strictly above the minimum bounding box of geometry B.
    • xsd:boolean strdf:below(strdf:geometry A, strdf:geometry B): Returns true if the minumum bounding box of geometry A is strictly below the minimum bounding box of geometry B.

    Spatial Analysis Functions


    The following functions can be used to construct new geometric objects from existing geometric objects:
    • strdf:geometry strdf:buffer(strdf:geometry A, xsd:double distance, xsd:anyURI units): Returns a geometry that represents all points whose distance from this geometry is less than or equal to distance.  The supported measurement units are metres (<http://www.opengis.net/def/uom/OGC/1.0/metre>) and degrees (<http://www.opengis.net/def/uom/OGC/1.0/degree>)
    • strdf:geometry strdf:boundary(strdf:geometry A): Returns the closure of the combinatorial boundary of this Geometry.
    • strdf:geometry strdf:envelope(strdf:geometry A): Returns the minimum bounding box for the supplied geometry, as a geometry. The polygon is defined by the corner points of the bounding box ((MINX, MINY), (MINX, MAXY), (MAXX, MAXY), (MAXX, MINY), (MINX, MINY)).
    • strdf:geometry strdf:convexHull(strdf:geometry A): The convex hull of a geometry represents the minimum convex geometry that encloses all geometries within the set.
    • strdf:geometry strdf:intersection (strdf:geometry A, strdf:geometry B): Returns a geometry that represents the point set intersection of the geometries.
    • strdf:geometry strdf:union(strdf:geometry A, strdf:geometry B): Returns a geometry that represents the point set union of the geometries.
    • strdf:geometry strdf:difference(strdf:geometry A, strdf:geometry B): Returns a geometry that represents that part of geometry A that does not intersect with geometry B.
    • strdf:geometry strdf:symDifference (strdf:geometry A, strdf:geometry B): Returns a geometry that represents the portions of A and B that do not intersect. One can think of  this as Union(A,B) - Intersection(A,B).

    The folllowing are spatial metric functions:
    • xsd:float strdf:distance(strdf:geometry A, strdf:geometry B, xsd:anyURI units): Returns the 2-dimensional cartesian minimum distance (based on spatial ref) between two geometries in projected units. The supported measurement units are metres (<http://www.opengis.net/def/uom/OGC/1.0/metre>) and degrees (<http://www.opengis.net/def/uom/OGC/1.0/degree>).
    • xsd:float strdf:area(strdf:geometry A): Returns the area of the surface if it is a polygon or multi-polygon.

    The folllowing are spatial aggregate functions:
    • strdf:geometry strdf:union(set of strdf:geometry A): Returns the union of a set of geometries.
    • strdf:geometry strdf:intersection(set of strdf:geometry A) : Returns the intersection of a set of geometries.
    • strdf:geometry strdf:extent(set of strdf:geometry A): Returns the bounding box that bounds a set of geometries.

    Temporal Extension Functions

    The following functions can be used with values of datatype strdf:period that is used to model the valid time of a triple. The first set of such functions available are the following ones that allow us to test if a qualitative temporal relation holds among two given periods. The set of these functions is a superset of Allen's interval algebra.
    • xsd:boolean strdf:after(strdf:period i1, strdf:period i2): returns true if i1 happens after i2.
    • xsd:boolean strdf:before(strdf:period i1, strdf:period i2): returns true if i1 happens before i2.
    • xsd:boolean strdf:PeriodOverlaps(strdf:period i1, strdf:period i2): returns true if i1 overlaps with period i2.
    • xsd:boolean strdf:starts(strdf:period i1, strdf:period i2): returns true if i1 starts at the same time as period i2. 
    • xsd:boolean strdf:during(strdf:period i1, strdf:period i2): returns true if i1 is contained by with period i2.
    • xsd:boolean strdf:finishes(strdf:period i1, strdf:period i2): returns true if i1 finishes at the same time as period i2. 
    • xsd:boolean strdf:PeriodContains(strdf:period i1, strdf:period i2): returns true if i1 contains period i2.
    • xsd:boolen strdf:PeriodContains(strdf:period i1, xsd:dateTime i2)}: returns true if period i1 contains instant i2
    • xsd:boolean strdf:meets(strdf:period i1, strdf:period i2): returns true if i1 meets period i2.
    • xsd:boolean strdf:isMetBy(strdf:period i1, strdf:period i2): returns true if i2 meets period i1.
    • xsd:boolean strdf:equalsPeriod(strdf:period i1, strdf:period i2): returns true if i1 is cotemporal with period i2.

    The following functions are also defined:
    • xsd:boolen strdf:overright(strdf:period i1, strdf:period i2): returns true if all values of i1 are greater than or equal to the start of  period i2.
    • xsd:boolen strdf:overleft(strdf:period i1, strdf:period i2): returns true if all values of i1 are greater than or equal to the end of  period i2.
    • xsd:boolen strdf:nequalsPeriod(strdf:period i1, strdf:period i2): returns true if i1 is not contemporal with period i2.
    • xsd:boolean strdf:meetsBefore(strdf:period i1, strdf:period i2): returns true if i1 meets period i2 and i1  started before i2.
    • xsd:boolean strdf:meetsAfter(strdf:period i1, strdf:period i2): returns true if i1 meets period i2 and i1  started after i2.

    Apart from the functions that express temporal relations between periods, stSPARQL also supports a set of functions on periods that construct a new temporal element (period or instant) from existing ones. These functions are the following:
    • strdf:validTime strdf:period_intersect(strdf:period p1, strdf:period p2):This function returns the temporal intersection of period p1 with period p2. A literal of strdf:period or xsd:dateTime will be returned.
    • strdf:period strdf:period_union(strdf:period p1, strdf:period p2):This function returns the temporal union of period p1 with period p2. 
    • strdf:period strdf:minus(strdf:period p1, strdf:period p2):This function returns the temporal difference of period p1 temporally minus period p2. 
    • strdf:period strdf:period_preceding(strdf:period p1, strdf:period p2): This function returns the part of period p1 that preceeds period p2.
    • strdf:period strdf:period_succeding(strdf:period p1, strdf:period p2): This function returns the part of period p1 that succeeds period p2.
    • strdf:period strdf:period(xsd:dateTime i1, xsd:dateTime i2): This function constructs a period starting from instant i1 and ending to instant i2 .
    • xsd:dateTime strdf:period_start(strdf:period p): This function returns the starting point of period p.
    • xsd:dateTime strdf:period_end(strdf:period p): This function returns the ending point of period p.

    Moreover, stSPARQL defines the following temporal aggregate functions:
    • strdf:period strdf:intersectAll(set of strdf:period P): Computes the intersection of all periods present each group of the result set. 
    • strdf:period strdf:maxDuration(set of strdf:period P): Computes the maximum duration of the periods in each group. strdf:period
    • strdf:period strdf:maximalPeriod(set of strdf:period P): Computes the maximal interval given the periods of each group.