全部產品
Search
文件中心

ApsaraDB RDS:點雲模型

更新時間:Oct 16, 2024

點雲資料通常是由3D掃描器掃描資料並以點的形式輸出的記錄,每一個點包含有三維座標,有些可能含有顏色資訊(RGB)或反射強度資訊(Intensity),點雲資料含有空間座標資訊,且具有數量眾多、屬性維度複雜的特點。

概述

GanosBase PointCloud是對象關係型資料庫PostgreSQL的一個擴充,使PostgreSQL能夠有效快速儲存和管理點雲資料,並提供點雲資料壓縮、解壓縮、屬性統計等功能,同時聯合GanosBase Geometry模組提供點雲空間分析的能力。

點雲資料類型

點雲資料類型主要分為兩種,一種是pcpoint資料類型,一個點一行記錄儲存。點的維度資訊在中繼資料中定義。另一種是pcpatch資料類型,該類型將點以集合的方式進行儲存,支援壓縮,減少儲存空間,支援空間檢索。壓縮方式由中繼資料中的“compression”決定。

點雲中繼資料

表pointcloud_formats記錄了點雲的schema(中繼資料)資訊。中繼資料套件括點雲的屬性維度,以及每個維度資料大小、類型、名稱以及解釋說明等。

快速入門

  • 建立擴充

    Create extension ganos_pointcloud with schema public cascade;
    Create extension ganos_pointcloud_geometry with schema public cascade;
  • 插入點雲schema

    INSERT INTO pointcloud_formats (pcid, srid, schema) VALUES (1, 4326,
    '<?xml version="1.0" encoding="UTF-8"?>
    <pc:PointCloudSchema xmlns:pc="http://example.org/schemas/PC/1.1"
        xmlns:xsi="http://www.example.org/2001/XMLSchema-instance">
      <pc:dimension>
        <pc:position>1</pc:position>
        <pc:size>4</pc:size>
        <pc:description>X coordinate as a long integer. You must use the
                        scale and offset information of the header to
                        determine the double value.</pc:description>
        <pc:name>X</pc:name>
        <pc:interpretation>int32_t</pc:interpretation>
        <pc:scale>0.01</pc:scale>
      </pc:dimension>
      <pc:dimension>
        <pc:position>2</pc:position>
        <pc:size>4</pc:size>
        <pc:description>Y coordinate as a long integer. You must use the
                        scale and offset information of the header to
                        determine the double value.</pc:description>
        <pc:name>Y</pc:name>
        <pc:interpretation>int32_t</pc:interpretation>
        <pc:scale>0.01</pc:scale>
      </pc:dimension>
      <pc:dimension>
        <pc:position>3</pc:position>
        <pc:size>4</pc:size>
        <pc:description>Z coordinate as a long integer. You must use the
                        scale and offset information of the header to
                        determine the double value.</pc:description>
        <pc:name>Z</pc:name>
        <pc:interpretation>int32_t</pc:interpretation>
        <pc:scale>0.01</pc:scale>
      </pc:dimension>
      <pc:dimension>
        <pc:position>4</pc:position>
        <pc:size>2</pc:size>
        <pc:description>The intensity value is the integer representation
                        of the pulse return magnitude. This value is optional
                        and system specific. However, it should always be
                        included if available.</pc:description>
        <pc:name>Intensity</pc:name>
        <pc:interpretation>uint16_t</pc:interpretation>
        <pc:scale>1</pc:scale>
      </pc:dimension>
      <pc:metadata>
        <Metadata name="compression">dimensional</Metadata>
      </pc:metadata>
    </pc:PointCloudSchema>');
  • 建立點雲表

    -- 使用pcpoint資料類型
    CREATE TABLE points (
        id SERIAL PRIMARY KEY,
        pt PCPOINT(1)
    );
    
    -- 使用pcpatch資料類型
    CREATE TABLE patches (
        id SERIAL PRIMARY KEY,
        pa PCPATCH(1)
    );
  • 插入pcpoint類型資料

    INSERT INTO points (pt)
    SELECT ST_MakePoint(1, ARRAY[x,y,z,intensity])
    FROM (
      SELECT
      -127+a/100.0 AS x,
        45+a/100.0 AS y,
             1.0*a AS z,
              a/10 AS intensity
      FROM generate_series(1,100) AS a
    ) AS values;
    
    SELECT ST_MakePoint(1, ARRAY[-127, 45, 124.0, 4.0]);
    -------------------------
    010100000064CEFFFF94110000703000000400
    
    SELECT ST_AsText('010100000064CEFFFF94110000703000000400'::pcpoint);
    -------------------------
    {"pcid":1,"pt":[-127,45,124,4]}
  • 插入pcpatch類型資料

    INSERT INTO patches (pa)
    SELECT ST_Patch(pt) FROM points GROUP BY id/10;
    
    SELECT ST_AsText(ST_MakePatch(1, ARRAY[-126.99,45.01,1,0, -126.98,45.02,2,0, -126.97,45.03,3,0]));
    -------------------------
    {"pcid":1,"pts":[
     [-126.99,45.01,1,0],[-126.98,45.02,2,0],[-126.97,45.03,3,0]
    ]}
  • pcpatch屬性平均值計算

    SELECT ST_AsText(ST_PatchAvg(pa)) FROM patches WHERE id = 7;
    -------------------------
    {"pcid":1,"pt":[-126.46,45.54,54.5,5]}
  • 刪除擴充

    Drop extension ganos_pointcloud_geometry;
    Drop extension ganos_pointcloud cascade;

SQL參考

詳細SQL手冊請參見 PointCloud SQL參考