Chapter 8. Temporal Geometry Types (Part 2)

Table of Contents

Restrictions
Spatial Reference System
Bounding Box Operations
Distance Operations
Ever and Always Relationships
Spatiotemporal Relationships

Restrictions

  • Restrict to (the complement of) a geometry

    atGeometry(tgeom,geometry) → tgeom
    minusGeometry(tgeom,geometry) → tgeom
    

    The geometry must be in 2D and the computation with respect to it is done in 2D. The result preserves the Z dimension of the temporal point, if it exists.

    A geodetic point is restricted to a geography, which must be a polygon or a multipolygon, and the computation is done on the sphere: the point travels the great circle between two positions and the region is bounded by the great circles through its own vertices, so the trip enters and leaves where those paths cross. The difference grows with latitude, a trip along a parallel standing well to the north of it.

    SELECT asText(atGeometry(tgeompoint '[Point(0 0)@2001-01-01, Point(3 3)@2001-01-04)',
      geometry 'Polygon((1 1,1 2,2 2,2 1,1 1))'));
    -- {"[POINT(1 1)@2001-01-02, POINT(2 2)@2001-01-03]"}
    SELECT astext(atGeometry(tgeompoint '[Point(0 0 0)@2001-01-01, Point(4 4 4)@2001-01-05]',
      geometry 'Polygon((1 1,1 2,2 2,2 1,1 1))'));
    -- {[POINT Z (1 1 1)@2001-01-02, POINT Z (2 2 2)@2001-01-03]}
    SELECT asText(atGeometry(tgeompoint '[Point(1 1 1)@2001-01-01, Point(3 1 1)@2001-01-03,
      Point(3 1 3)@2001-01-05]', 'Polygon((2 0,2 2,2 4,4 0,2 0))'));
    -- {[POINT Z (2 1 1)@2001-01-02, POINT Z (3 1 1)@2001-01-03, POINT Z (3 1 3)@2001-01-05]}
    SELECT asText(atGeometry(tgeometry 'Linestring(1 1,10 1)@2001-01-01',
      'Polygon((0 0,0 5,5 5,5 0,0 0))'));
    -- LINESTRING(1 1,5 1)@2001-01-01
    
    SELECT asText(minusGeometry(tgeompoint '[Point(0 0)@2001-01-01, Point(3 3)@2001-01-04)',
      geometry 'Polygon((1 1,1 2,2 2,2 1,1 1))'));
    /* {[POINT(0 0)@2001-01-01, POINT(1 1)@2001-01-02), (POINT(2 2)@2001-01-03,
       POINT(3 3)@2001-01-04)} */
    SELECT astext(minusGeometry(tgeompoint '[Point(0 0 0)@2001-01-01,
      Point(4 4 4)@2001-01-05]', geometry 'Polygon((1 1,1 2,2 2,2 1,1 1))'));
    /* {[POINT Z (0 0 0)@2001-01-01, POINT Z (1 1 1)@2001-01-02),
       (POINT Z (2 2 2)@2001-01-03, POINT Z (4 4 4)@2001-01-05]} */
    SELECT asText(minusGeometry(tgeompoint '[Point(1 1 1)@2001-01-01, Point(3 1 1)@2001-01-03,
      Point(3 1 3)@2001-01-05]', 'Polygon((2 0,2 2,2 4,4 0,2 0))'));
    -- {[POINT Z (1 1 1)@2001-01-01, POINT Z (2 1 1)@2001-01-02)}
    SELECT asText(minusGeometry(tgeometry 'Linestring(1 1,10 1)@2001-01-01',
      'Polygon((0 0,0 5,5 5,5 0,0 0))'));
    -- LINESTRING(5 1,10 1)@2001-01-01
    
    SELECT asText(atGeometry(tgeogpoint 'SRID=4326;[Point(-170 65)@2001-01-01,
      Point(-100 65)@2001-01-03]',
      geography 'SRID=4326;Polygon((-150 60,-150 70,-120 70,-120 60,-150 60))'), 6);
    /* {[POINT(-150 68.423603)@2001-01-01 14:39:22.550164,
       POINT(-120 68.423603)@2001-01-02 09:20:37.449835]} */
    
  • Restrict to (the complement of) an stbox

    atStbox(tgeom,stbox,borderInc boolean=true) → tgeompoint
    minusStbox(tgeom,stbox,borderInc boolean=true) → tgeompoint
    

    The third optional argument is used for multidimensional tiling (see the section called “Multidimensional Tiling”) to exclude the upper border of the tiles when a temporal value is split in multiple tiles, so that all fragments of the temporal geometry are exclusive.

    A temporal point is restricted in 3D. The Z dimension is taken into account only when both the temporal point and the box have it, so that 2D and 3D arguments can be mixed, and the result preserves the Z dimension of the temporal point. The body of a temporal geometry is instead clipped in 2D: a box holding coordinates refuses a temporal geometry having Z dimension, while a box holding only a period restricts it in time as for any other temporal type. The restriction of a tgeography to a spatiotemporal box is not implemented.

    A geodetic temporal point travels the great circle between two positions, and the box holds it where that circle enters and leaves the box: a trip from Point(10 60) to Point(50 60) reaches latitude 61.518762, and a trip across the antimeridian sweeps the longitudes the short way round. Two boxes meeting at a crossing state the same instant for it, so the pieces of a trip hold the period of the trip and its positions.

    SELECT asText(atStbox(tgeogpoint '[Point(10 60)@2001-01-01, Point(50 60)@2001-01-02]',
      stbox 'SRID=4326;GEODSTBOX X((0 55),(60 61))', false), 6);
    /* {[POINT(10 60)@2001-01-01, POINT(18.168064 61)@2001-01-01 05:02:50.433397),
       [POINT(41.831936 61)@2001-01-01 18:57:09.566602, POINT(50 60)@2001-01-02]} */
    
    SELECT asText(atStbox(tgeompoint '[Point(0 0)@2001-01-01, Point(3 3)@2001-01-04)',
      stbox 'STBOX XT(((0,0),(2,2)),[2001-01-02, 2001-01-04])'));
    -- {[POINT(1 1)@2001-01-02, POINT(2 2)@2001-01-03]}
    SELECT asText(atStbox(tgeompoint '[Point(1 1 1)@2001-01-01, Point(3 3 3)@2001-01-03,
      Point(3 3 2)@2001-01-04, Point(3 3 7)@2001-01-09]', stbox 'STBOX Z((2,2,2),(3,3,3))'));
    /* {[POINT Z (2 2 2)@2001-01-02, POINT Z (3 3 3)@2001-01-03, POINT Z (3 3 2)@2001-01-04,
       POINT Z (3 3 3)@2001-01-05]} */
    SELECT asText(atStbox(tgeometry '[Point(1 1)@2001-01-01, Linestring(1 1,3 3)@2001-01-03,
      Point(2 2)@2001-01-04, Linestring(3 3,4 4)@2001-01-09]', stbox 'STBOX X((2,2),(3,3))'));
    -- {[LINESTRING(2 2,3 3)@2001-01-03, POINT(2 2)@2001-01-04, POINT(3 3)@2001-01-09]}
    
    SELECT asText(minusStbox(tgeompoint '[Point(1 1)@2001-01-01, Point(4 4)@2001-01-04)',
      stbox 'STBOX XT(((1,1),(2,2)),[2001-01-03,2001-01-04])'));
    -- {(POINT(2 2)@2001-01-02, POINT(3 3)@2001-01-03)}
    SELECT asText(minusStbox(tgeompoint '[Point(1 1 1)@2001-01-01, Point(3 3 3)@2001-01-03,
      Point(3 3 2)@2001-01-04, Point(3 3 7)@2001-01-09]', stbox 'STBOX Z((2,2,2),(3,3,3))'));
    /* {[POINT Z (1 1 1)@2001-01-01, POINT Z (2 2 2)@2001-01-02), 
       (POINT Z (3 3 3)@2001-01-05, POINT Z (3 3 7)@2001-01-09]} */
    SELECT asText(minusStbox(tgeometry '[Point(1 1)@2001-01-01,
      Linestring(1 1,3 3)@2001-01-03, Point(2 2)@2001-01-04, Linestring(1 1,4 4)@2001-01-09]',
      stbox 'STBOX X((2,2),(3,3))'));
    /* {[POINT(1 1)@2001-01-01, LINESTRING(1 1,2 2)@2001-01-03, 
       LINESTRING(1 1,2 2)@2001-01-04),[MULTILINESTRING((1 1,2 2),(3 3,4 4))@2001-01-09]} */
    
  • Restrict to (the complement of) an elevation span

    atElevation(tgeom,zspan) → tgeom
    minusElevation(tgeom,zspan) → tgeom
    

    The elevation of a temporal point is its Z coordinate, which runs linearly in time whether the point is planar or geodetic, so the periods the span admits are the same for both. The positions at the bounds of those periods are not: a geodetic point travels the great circle between two positions and reaches the elevation of a bound there rather than on the straight line in longitude and latitude.

    SELECT astext(atElevation(tgeompoint '[Point(1 1 1)@2001-01-01, Point(4 4 4)@2001-01-04,
      Point(1 1 1)@2001-01-07]', floatspan '[2,3]'));
    /* {[POINT Z (2 2 2)@2001-01-02, POINT Z (3 3 3)@2001-01-03],
       [POINT Z (3 3 3)@2001-01-05, POINT Z (2 2 2)@2001-01-06]} */
    SELECT astext(minusElevation(tgeompoint '[Point(1 1 1)@2001-01-01,
      Point(4 4 4)@2001-01-04, Point(1 1 1)@2001-01-07]', floatspan '[2,3]'));
    /* {[POINT Z (1 1 1)@2001-01-01, POINT Z (2 2 2)@2001-01-02),
       (POINT Z (3 3 3)@2001-01-03, POINT Z (4 4 4)@2001-01-04,
       POINT Z (3 3 3)@2001-01-05), (POINT Z (2 2 2)@2001-01-06,
       POINT Z (1 1 1)@2001-01-07]} */
    
    SELECT asText(atElevation(tgeogpoint 'SRID=4326;[Point(1 1 1)@2001-01-01,
      Point(4 4 4)@2001-01-04, Point(1 1 1)@2001-01-07]', floatspan '[2,3]'), 6);
    /* {[POINT Z (1.998577 2.00071 2)@2001-01-02, POINT Z (2.998373 3.000812 3)@2001-01-03],
       [POINT Z (2.998373 3.000812 3)@2001-01-05, POINT Z (1.998577 2.00071 2)@2001-01-06]} */