ST_Force4D
Signature
GEOMETRY ST_Force4D(GEOMETRY geom);
GEOMETRY ST_Force4D(GEOMETRY geom, DOUBLE zValue, DOUBLE mValue);
Description
Forces a geometry geom to be in XYZM mode.
If geom has no Z or M component, then a Z and M value are tacked on.
User can set :
a default
Zvalue (zValue). If not specified,zValueis set to zero.a default
Mvalue (mValue). If not specified,mValueis set to zero.
If geom has already a Z or M values, then they are untouched and just completed with the missing one.
Already XYZM geometries are returned untouched.
Examples
No effect on XYZM geometries
SELECT ST_Force4D('POINT ZM(-10 10 2 6)');
-- Answer: POINT ZM(-10 10 2 6)
Adding M dimension
SELECT ST_Force4D('POINT(-10 10)');
-- Answer: POINT ZM(-10 10 0 0)
SELECT ST_Force4D('LINESTRING(-10 10, 10 10)');
-- Answer: LINESTRING ZM (-10 10 0 0, 10 10 0 0)
Specifying mValue
SELECT ST_Force4D('POLYGON((2 2, 10 0, 10 5, 0 5, 2 2))', 5, 3);
-- Answer: POLYGON ZM ((2 2 5 3, 10 0 5 3, 10 5 5 3, 0 5 5 3, 2 2 5 3))
Completing existing Z or M dimensions and adding the ZM one
SELECT ST_Force4D('POINT Z(-10 10 12)',3, 2);
-- Answer: POINT ZM (-10 10 12 2)
SELECT ST_Force4D('LINESTRING Z(-10 10 4, 10 10 6)', 2, 3);
-- Answer: LINESTRING ZM (-10 10 4 3, 10 10 6 3)
SELECT ST_Force4D('POLYGON M((2 2 4, 10 0 3, 10 5 2, 0 5 1, 2 2 4))', 2, 5);
-- Answer: POLYGON ZM ((2 2 2 4, 10 0 2 3, 10 5 2 2, 0 5 2 1, 2 2 2 4))