Opened 10 years ago
Closed 10 years ago
#3098 closed defect (fixed)
ST_GeomFromText() cannot read MultiPoint containing empty Points with Z or M coordinates
Reported by: | benmorel | Owned by: | pramsey |
---|---|---|---|
Priority: | low | Milestone: | PostGIS 2.1.8 |
Component: | postgis | Version: | 2.1.x |
Keywords: | ST_GeomFromText, MultiPoint, MultiLineString, MultiPolygon, Empty, Z, M, ZM | Cc: |
Description
Take the following MultiPoint ZM, made of an empty and a non-empty Point:
SELECT ST_AsText(ST_Collect( ST_GeomFromText('POINT ZM EMPTY'), ST_GeomFromText('POINT ZM (1 2 3 4)') ));
MULTIPOINT ZM (EMPTY,1 2 3 4)
Now if I try to read this geometry back, I get an error:
SELECT ST_AsText(ST_GeomFromText('MULTIPOINT ZM (EMPTY,1 2 3 4)'));
ERROR: can not mix dimensionality in a geometry HINT: "MULTIPOINT ZM (EMPTY,1 2 3 4)" ←- parse error at position 29 within geometry
As far as I understand it, PostGIS reads "EMPTY" as "EMPTY 2D geometry", whereas it's actually dependent on the dimensionality of the parent geometry.
This bug occurs with Z, M, and ZM geometries. The same bug occurs with MultiLineString and MultiPolygon.
Change History (5)
comment:1 by , 10 years ago
comment:2 by , 10 years ago
Priority: | critical → medium |
---|
Ok, you have a point. This is indeed a corner case, that I found while developing a GIS library. But still, IMHO it's important that PostGIS can read back any WKT it creates.
comment:3 by , 10 years ago
Milestone: | PostGIS 2.1.7 → PostGIS 2.1.8 |
---|---|
Priority: | medium → low |
someone forgot to flip our roadmap when he released 2.1.7. Not pointing any fingers .
Regarding this bug unless it is causing any problems I would consider it at best a low priority (and have flipped).
comment:4 by , 10 years ago
In a similar vein, it's possible to make one of these
GEOMETRYCOLLECTION Z (POINT Z (1 2 3), POINT M(3 4 5))
The dimensionality policing parts are trying to work on a case by case basis as components are added, and they don't have enough information to do it. I have a fix that can handle this
MULTIPOINT ZM (1 2 3 4,EMPTY)
but it cannot handle this
MULTIPOINT ZM (EMPTY,1 2 3 4)
because the first thing into the collection (the EMPTY) in this case, sets the base dimensionality against which everything else is then tested. To fix this I would need to rework the parser to do dimensionality tests at finalization time, which wouldn't be the end of the world. Because it's a big fix it can't go into 2.1, but could go into 2.2
What application is generating MULTIPOINT ZM (EMPTY,1 2 3 4)' such that this is a critical bug? This seems like a corner of a corner of a corner case to me.