
-- 2D
SELECT ST_IsValidReason(ST_GeomFromEWKT('MULTIPOLYGON(((0 0, 1 0, 1 1, 0 1, 0 0)),((0 1, 1 1, 1 2, 0 2, 0 1)))'));
SELECT ST_IsValidReason(ST_GeomFromEWKT('MULTIPOLYGON(((0 0, 1 0, 1 1, 0 0.9, 0 0)),((0 1, 1 1, 1 2, 0 2, 0 1)))'));

-- 3D
SELECT ST_IsValidReason(ST_GeomFromEWKT('MULTIPOLYGON(((0 0 0, 1 0 0, 1 1 0, 0 1 0, 0 0 0)),((0 1 0, 1 1 0, 1 2 0, 0 2 0, 0 1 0)))'));

-- Some further tests with ST_Intersection

-- 2D
SELECT ST_AsEWKT(ST_intersection(ST_GeomFromEWKT('POLYGON((0 0, 1 0, 1 1, 0 1, 0 0))'),ST_GeomFromEWKT('POLYGON((0 1, 1 1, 1 2, 0 2, 0 1))')));
SELECT ST_AsEWKT(ST_intersection(ST_GeomFromEWKT('POLYGON((0 0, 1 0, 1 1, 0 0.9, 0 0))'),ST_GeomFromEWKT('POLYGON((0 1, 1 1, 1 2, 0 2, 0 1))')));

-- 3D
SELECT ST_AsEWKT(ST_intersection(ST_GeomFromEWKT('POLYGON((0 0 0, 1 0 0, 1 1 0, 0 1 0, 0 0 0))'),ST_GeomFromEWKT('POLYGON((0 1 1, 1 1 1, 1 2 1, 0 2 1, 0 1 1))')));
SELECT ST_AsEWKT(ST_intersection(ST_GeomFromEWKT('POLYGON((0 0 0, 1 0 0, 1 1 0, 0 0.9 0, 0 0 0))'),ST_GeomFromEWKT('POLYGON((0 1 1, 1 1 1, 1 2 1, 0 2 1, 0 1 1))')));

