-- complain if script is sourced in psql, rather than via CREATE EXTENSION \echo Use "CREATE EXTENSION pointcloud" to load this file. \quit ------------------------------------------------------------------- -- METADATA and SCHEMA ------------------------------------------------------------------- -- Confirm the XML representation of a schema has everything we need CREATE OR REPLACE FUNCTION PC_SchemaIsValid(xml text) RETURNS boolean AS 'MODULE_PATHNAME','PC_SchemaIsValid' LANGUAGE 'c' IMMUTABLE STRICT; -- Metadata table describing contents of pcpoints CREATE TABLE pointcloud_formats ( pcid INTEGER PRIMARY KEY, srid INTEGER, -- REFERENCES spatial_ref_sys(srid) schema TEXT CHECK ( PC_SchemaIsValid(schema) ) ); -- Register pointcloud_formats table so the contents are included in pg_dump output SELECT pg_catalog.pg_extension_config_dump('pointcloud_formats', ''); CREATE OR REPLACE FUNCTION PC_SchemaGetNDims(pcid integer) RETURNS integer AS 'MODULE_PATHNAME','PC_SchemaGetNDims' LANGUAGE 'c' IMMUTABLE STRICT; ------------------------------------------------------------------- -- PCPOINT ------------------------------------------------------------------- CREATE OR REPLACE FUNCTION pcpoint_in(cstring) RETURNS pcpoint AS 'MODULE_PATHNAME', 'pcpoint_in' LANGUAGE 'c' IMMUTABLE STRICT; CREATE OR REPLACE FUNCTION pcpoint_out(pcpoint) RETURNS cstring AS 'MODULE_PATHNAME', 'pcpoint_out' LANGUAGE 'c' IMMUTABLE STRICT; CREATE TYPE pcpoint ( internallength = variable, input = pcpoint_in, output = pcpoint_out, -- send = geometry_send, -- receive = geometry_recv, -- typmod_in = geometry_typmod_in, -- typmod_out = geometry_typmod_out, -- delimiter = ':', -- alignment = double, -- analyze = geometry_analyze, storage = main ); CREATE OR REPLACE FUNCTION PC_Get(point pcpoint, dimname text) RETURNS numeric AS 'MODULE_PATHNAME', 'PC_Get' LANGUAGE 'c' IMMUTABLE STRICT; -- Sample data INSERT INTO pointcloud_formats (pcid, srid, schema) VALUES (1, 4326, ' 1 4 X coordinate as a long integer. You must use the scale and offset information of the header to determine the double value. X int32_t 0.01 2 4 Y coordinate as a long integer. You must use the scale and offset information of the header to determine the double value. Y int32_t 0.01 3 4 Z coordinate as a long integer. You must use the scale and offset information of the header to determine the double value. Z int32_t 0.01 4 2 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. Intensity uint16_t 1 4326 ');