PostGIS 中的 M 值

M-Values in PostGIS

我想知道如何在 Postgis 中创建 PolylineM-Geometries。

CREATE TABLE tabm (oid integer primary key);

SELECT AddGeometryColumn ('public','tabm','geom',25832,'MULTILINESTRING',3);

insert into tabm(oid,geom) values(
   1,
   ST_GeomFromText('MULTILINESTRINGM ((572929 5831262 300, 572929 5831562 400))')
);

以上代码导致

ERROR: FEHLER:  Column has Z dimension but geometry does not
SQL state: 22023

(PosgreSQL 13.3)

geom 列不是 MULTILINESTRINGM 类型。更改列,您将能够执行插入:

SELECT AddGeometryColumn ('public','tabm','geom',25832,'MULTILINESTRINGM',3);

演示:db<>fiddle

CREATE TABLE tabm (oid integer primary key);
SELECT AddGeometryColumn ('public','tabm','geom',25832,'MULTILINESTRINGM',3);
INSERT INTO tabm(oid,geom) VALUES 
(1,'SRID=25832;MULTILINESTRINGM ((572929 5831262 300, 572929 5831562 400))'::geometry); 

SELECT ST_AsText(i.geom),ST_M(i.geom) FROM tabm,
LATERAL ST_DumpPoints(geom) i(j);

st_astext                      st_m
-----------------------------------
POINT M (572929 5831262 300)    300
POINT M (572929 5831562 400)    400