Static Point Clouds

The static types come from pgPointCloud. MobilityDB exposes the schema-aware coordinate accessors needed to project pgPointCloud values into the rest of the temporal-types ecosystem.

Input and Output

The text of a pcpoint and of a pcpatch is the hex of its pgPointCloud Well-Known Binary (WKB), the text the type input and output functions of pgPointCloud read and write, and every engine reads and writes it with the functions below.

  • Return the Hexadecimal Well-Known Binary (HexWKB) representation of a pcpoint or a pcpatch

    asHexWKB({pcpoint,pcpatch}) → text
    

    The result is the text the type output function of pgPointCloud writes, in the byte order of the machine.

    SELECT asHexWKB(pcpoint(1, 1.0, 2.0, 3.0));
    -- 010100000064000000C80000002C010000
    SELECT asHexWKB(pcpatch(pcpoint(1, 1.0, 1.0, 1.0), pcpoint(1, 2.0, 2.0, 2.0)));
    -- 01010000000000000002000000640000006400000064000000C8000000C8000000C8000000
    
  • Input of a pcpoint or a pcpatch from its Hexadecimal Well-Known Binary (HexWKB) representation

    pcpointFromHexWKB(text) → pcpoint
    pcpatchFromHexWKB(text) → pcpatch
    

    The input is read as the type input function of pgPointCloud reads it, in either byte order, under the schema of its pcid.

    SELECT getZ(pcpointFromHexWKB('010100000064000000C80000002C010000'));
    -- 3
    SELECT numPoints(pcpatchFromHexWKB('01010000000000000002000000640000006400000064000000C8000000C8000000C8000000'));
    -- 2
    

Constructors

pgPointCloud's pcpoint_in only accepts hex-WKB, so the canonical builder is PC_MakePoint(pcid, ARRAY[…]::float[]). MobilityDB ships two thin SQL overloads on top of it for shorter test literals and ad-hoc queries; the underlying schema-dimension validation still happens inside PC_MakePoint.

  • Build a 2D or 3D pcpoint directly from x/y(/z) coordinates

    pcpoint(pcid integer,x float,y float) → pcpoint
    pcpoint(pcid integer,x float,y float,z float) → pcpoint
    
    SELECT pcpoint(1, 10.0, 20.0, 30.0);
    -- Equivalent to pcpoint(1, 10.0, 20.0, 30.0)
    
  • Build a pcpoint from the coordinates of every dimension of the schema

    pcpoint(pcid integer,coordinates float[]) → pcpoint
    

    The layout of the schema states every dimension, inactive ones included, which is how a schema of more dimensions than the overloads above reach is given its values. That count is the one PC_MakePoint takes and is NOT the count of active dimensions that pointCloudSchemaNDims reports

    SELECT pcpoint(1, ARRAY[10.0, 20.0, 30.0]::float[]);
    
  • Build a pcpatch from the coordinates of its points, one point after another

    pcpatch(pcid integer,coordinates float[]) → pcpatch
    

    Every dimension of the layout of the schema is given for each point, inactive ones included. That count is the one PC_MakePatch takes and is NOT the count of active dimensions that pointCloudSchemaNDims reports; a count that divides evenly by the wrong one of the two builds a patch of the wrong points rather than reporting an error. A patch built this way states the schema itself, there being no point to read it from

    SELECT pcpatch(1, ARRAY[1.0, 1.0, 1.0, 2.0, 2.0, 2.0]::float[]);
    
  • Build a pcpatch from a variadic list of pcpoints sharing the same pcid

    pcpatch(VARIADIC points pcpoint[]) → pcpatch
    
    SELECT pcpatch(pcpoint(1, 1.0, 1.0, 1.0), pcpoint(1, 2.0, 2.0, 2.0));
    -- Equivalent to pcpatch(pcpoint(1, 1.0, 1.0, 1.0), pcpoint(1, 2.0, 2.0, 2.0))
    

Accessors

  • Return the schema id of a pcpoint or pcpatch

    pcid({pcpoint,pcpatch}) → integer
    
    SELECT pcid(pcpoint(1, 10.0, 20.0, 30.0));
    -- 1
    
  • Return a coordinate of a pcpoint, NULL if the dimension is absent from the schema

    getX(pcpoint) → float
    getY(pcpoint) → float
    getZ(pcpoint) → float
    
    WITH pt AS (SELECT pcpoint(1, 10.0, 20.0, 30.0) p)
      SELECT getX(p), getY(p), getZ(p) FROM pt;
    -- 10 | 20 | 30
    
  • Return any named dimension of a pcpoint, NULL if the name is unknown for the schema

    getDim(pcpoint,text) → float
    
    SELECT getDim(pcpoint(1, 10.0, 20.0, 30.0), 'X');
    -- 10
    
  • Return the spatial reference identifier (inherited from the schema)

    SRID({pcpoint,pcpatch}) → integer
    
    SELECT SRID(pcpoint(1, 10.0, 20.0, 30.0));
    -- 0
    SELECT SRID(pcpatch(pcpoint(1, 10.0, 20.0, 30.0), pcpoint(1, 11.0, 21.0, 31.0)));
    -- 0
    
  • Return the number of points of a pcpatch

    numPoints(pcpatch) → integer
    
    SELECT numPoints(pcpatch(pcpoint(1, 1.0, 1.0, 1.0), pcpoint(1, 2.0, 2.0, 2.0)));
    -- 2
    
  • Return the n-th point of a pcpatch

    pointN(pcpatch,integer) → pcpoint
    

    Points are numbered from one, a negative integer counts from the end of the patch, and an integer addressing no point returns NULL.

    SELECT pointN(pcpatch(pcpoint(1, 1.0, 1.0, 1.0), pcpoint(1, 2.0, 2.0, 2.0)), 2)
      = pcpoint(1, 2.0, 2.0, 2.0);
    -- true
    SELECT pointN(pcpatch(pcpoint(1, 1.0, 1.0, 1.0), pcpoint(1, 2.0, 2.0, 2.0)), 3)
      IS NULL;
    -- true
    
  • Return the multipoint of the positions the points of a patch occupy

    geometry(pcpatch) → geometry
    

    The schema the pcid names decides the SRID and whether the result carries a Z dimension

    SELECT ST_AsText(geometry(pcpatch(pcpoint(1, 1, 1, 1), pcpoint(1, 2, 2, 2))));
    -- MULTIPOINT Z ((1 1 1),(2 2 2))