Ticket #1041 (closed defect: fixed)

Opened 2 years ago

Last modified 17 months ago

ST_Collect is screwy with M dimension

Reported by: robe Owned by: pramsey
Priority: medium Milestone: PostGIS 2.0.0
Component: postgis Version: 1.5.X
Keywords: Cc:

Description

SELECT ST_AsEWKT(ST_Collect(ST_GeomFromEWKT('SRID=4326;POLYGONM((-71.1261 42.2703 1,-71.1257 42.2703 1,-71.1257 42.2701 2,-71.126 42.2701 1,-71.1261 42.2702 1,-71.1261 42.2703 1))'),

	ST_GeomFromEWKT('SRID=4326;MULTIPOLYGONM(((-71.0821 42.3036 2,-71.0822 42.3036 3,-71.082 42.3038 2,-71.0819 42.3037 2,-71.0821 42.3036 2)))') ));

Yields:

SRID=4326;GEOMETRYCOLLECTIONM(POLYGON((-71.1261 42.2703 1,-71.1257 42.2703 1,-71.1257 42.2701 2,-71.126 42.2701 1,-71.1261 42.2702 1,-71.1261 42.2703 1)),MULTIPOLYGON(((-71.0821 42.3036 2,-71.0822 42.3036 3,-71.082 42.3038 2,-71.0819 42.3037 2,-71.0821 42.3036 2))))

Which causes this

SELECT ST_GeogFromText(ST_AsEWKT(ST_Collect(ST_GeomFromEWKT('SRID=4326;POLYGONM((-71.1261 42.2703 1,-71.1257 42.2703 1,-71.1257 42.2701 2,-71.126 42.2701 1,-71.1261 42.2702 1,-71.1261 42.2703 1))'),

	ST_GeomFromEWKT('SRID=4326;MULTIPOLYGONM(((-71.0821 42.3036 2,-71.0822 42.3036 3,-71.082 42.3038 2,-71.0819 42.3037 2,-71.0821 42.3036 2)))') )));

To fail with error:

ERROR:  can not mix dimensionality in a geometry
HINT:  "...0819 42.3037 2,-71.0821 42.3036 2))))" <-- parse error at position 266 within geometry

It's the same issue in 1.5, but 1.5 doesn't error out with ST_Geog because evidentally 1.5 c\geog check doesn't care as much about dimensionality as 2.0 does.

Change History

Changed 2 years ago by pramsey

This is a WKT parser "problem". I guess in the spirit of backwards compatibility it needs to be resolved. As the parser works up from the inside, it's not clear that the 3d coordinate sets are XYM and now XYZ until it gets to the final type tag at the top. I've fought with this issue a number of times. Back into the guts.

Changed 17 months ago by strk

  • status changed from new to closed
  • resolution set to fixed

This should be fixed with r8741

Note: See TracTickets for help on using tickets.