Chapter 9. Temporal Types: Analytics Operations

Table of Contents

Simplification
Reduction
Similarity
Bounding Box Splitting
Multidimensional Tiling
Bin Operations
Tile Operations
Bounding Box Operations
Split Operations

Simplification

  • Return a temporal float or a temporal point simplified ensuring that consecutive values are at least a certain distance or time interval apart

    minDistSimplify({tfloat,tpoint},mindist float) → {tfloat,tpoint}

    minTimeDeltaSimplify({tfloat,tpoint},mint interval) → {tfloat,tpoint}

    In the case of temporal points, the distance is specified in the units of the coordinate system. Notice that simplification applies only to temporal sequences or sequence sets with linear interpolation. In all other cases, a copy of the given temporal value is returned.

    SELECT minDistSimplify(tfloat '[1@2001-01-01,2@2001-01-02,3@2001-01-04,4@2001-01-05]', 1);
    -- [1@2001-01-01, 3@2001-01-04, 4@2001-01-05]
    SELECT asText(minDistSimplify(tgeompoint '[Point(1 1 1)@2001-01-01,
      Point(2 2 2)@2001-01-02, Point(3 3 3)@2001-01-04, Point(5 5 5)@2001-01-05)', sqrt(3)));
    -- [POINT Z (1 1 1)@2001-01-01, POINT Z (3 3 3)@2001-01-04, POINT Z (5 5 5)@2001-01-05)
    SELECT asText(minDistSimplify(tgeompoint '[Point(1 1 1)@2001-01-01,
      Point(2 2 2)@2001-01-02, Point(3 3 3)@2001-01-04, Point(4 4 4)@2001-01-05)', sqrt(3)));
    -- [POINT Z (1 1 1)@2001-01-01, POINT Z (3 3 3)@2001-01-04, POINT Z (4 4 4)@2001-01-05]
    
    SELECT minTimeDeltaSimplify(tfloat '[1@2001-01-01, 2@2001-01-02, 3@2001-01-04,
      4@2001-01-05]', '1 day');
    -- [1@2001-01-01, 3@2001-01-04, 4@2001-01-05]
    SELECT asText(minTimeDeltaSimplify(tgeogpoint '[Point(1 1 1)@2001-01-01,
      Point(2 2 2)@2001-01-02, Point(3 3 3)@2001-01-04, Point(5 5 5)@2001-01-05)', '1 day'));
    -- [POINT Z (1 1 1)@2001-01-01, POINT Z (3 3 3)@2001-01-04, POINT Z (5 5 5)@2001-01-05]
    
  • Return a temporal float or a temporal point simplified using the Douglas-Peucker algorithm

    maxDistSimplify({tfloat,tgeompoint},maxdist float,syncdist=true) →

    {tfloat,tgeompoint}

    douglasPeuckerSimplify({tfloat,tgeompoint},maxdist float,syncdist=true) →

    {tfloat,tgeompoint}

    The difference between the two functions is that maxDistSimplify uses a single-pass version of the algorithm whereas douglasPeuckerSimplify uses the standard recursive algorithm.

    The function removes values or points that are less than or equal to the distance passed as second argument. In the case of temporal points, the distance is specified in the units of the coordinate system. The third argument applies only for temporal points and specifies whether the spatial or the synchronized distance is used. Notice that simplification applies only to temporal sequences or sequence sets with linear interpolation. In all other cases, a copy of the given temporal value is returned.

    -- Only synchronous distance for temporal floats
    SELECT maxDistSimplify(tfloat '[1@2001-01-01, 2@2001-01-02, 1@2001-01-03, 3@2001-01-04,
      1@2001-01-05]', 1, false);
    -- [1@2001-01-01, 1@2001-01-03, 3@2001-01-04, 1@2001-01-05]
    -- Synchronous distance by default for temporal points
    SELECT asText(maxDistSimplify(tgeompoint '[Point(1 1)@2001-01-01, Point(2 2)@2001-01-02,
      Point(3 1)@2001-01-03, Point(3 3)@2001-01-05, Point(5 1)@2001-01-06]', 2));
    -- [POINT(1 1)@2001-01-01, POINT(3 3)@2001-01-05, POINT(5 1)@2001-01-06]
    -- Spatial distance
    SELECT asText(maxDistSimplify(tgeompoint '[Point(1 1)@2001-01-01, Point(2 2)@2001-01-02,
      Point(3 1)@2001-01-03, Point(3 3)@2001-01-05, Point(5 1)@2001-01-06]', 2, false));
    -- [POINT(1 1)@2001-01-01, POINT(5 1)@2001-01-06]
    
    -- Spatial vs synchronized Euclidean distance
    SELECT asText(douglasPeuckerSimplify(tgeompoint '[Point(1 1)@2001-01-01,
      Point(6 1)@2001-01-06, Point(7 4)@2001-01-07]', 2.3, false));
    -- [POINT(1 1)@2001-01-01, POINT(7 4)@2001-01-07]
    SELECT asText(douglasPeuckerSimplify(tgeompoint '[Point(1 1)@2001-01-01,
      Point(6 1)@2001-01-06, Point(7 4)@2001-01-07]', 2.3, true));
    -- [POINT(1 1)@2001-01-01, POINT(6 1)@2001-01-06, POINT(7 4)@2001-01-07]
    

    The difference between the spatial and the synchronized distance is illustrated in the last two examples above and in Figure 9.1, “Difference between the spatial and the synchronous distance.”. In the first example, which uses the spatial distance, the second instant is removed since the perperdicular distance between POINT(6 1) and the line defined by POINT(1 1) and POINT(7 4) is equal to 2.23. On the contrary, in the second example the second instant is kept since the projection of Point(6 2) at timestamp 2001-01-06 over the temporal line segment results in Point(6 3.5) and the distance between the original point and its projection is 2.5.

    Figure 9.1. Difference between the spatial and the synchronous distance.

    Difference between the spatial and the synchronous distance.

    A typical use for the douglasPeuckerSimplify function is to reduce the size of a dataset, in particular for visualization purposes. If the visualization is static, then the spatial distance should be preferred, if the visualization is dynamic or animated, the synchronized distance should be preferred.