Static Types pcpoint and pcpatch

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.

Ergonomic 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 PC_MakePoint(1, ARRAY[10.0, 20.0, 30.0]::float[])
    
  • Build a pcpatch from a variadic list of pcpoints sharing the same pcid

    pcpatch(pcid integer, VARIADIC points pcpoint[]) → pcpatch

    SELECT pcpatch(1, pcpoint(1, 1.0, 1.0, 1.0), pcpoint(1, 2.0, 2.0, 2.0));
    -- equivalent to PC_Patch(ARRAY[PC_MakePoint(1, ARRAY[1.0, 1.0, 1.0]::float[]),
    --                              PC_MakePoint(1, ARRAY[2.0, 2.0, 2.0]::float[])])
    

Accessors

  • Return the schema id of a pcpoint or pcpatch

    pcid(pcpoint) → integer

    pcid(pcpatch) → integer

    SELECT pcid(PC_MakePoint(1, ARRAY[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 PC_MakePoint(1, ARRAY[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(PC_MakePoint(1, ARRAY[10.0, 20.0, 30.0]), 'X');
    -- 10
    
  • Return the spatial reference identifier (inherited from the schema)

    SRID(pcpoint) → integer

    SRID(pcpatch) → integer

    SELECT SRID(PC_MakePoint(1, ARRAY[10.0, 20.0, 30.0]));
    -- 0