Opened 7 years ago

Last modified 7 years ago

#3777 closed defect

POINT EMPTY, POINT 0 0 anomaly — at Version 1

Reported by: robe Owned by: pramsey
Priority: medium Milestone: PostGIS 2.3.3
Component: postgis Version: 2.3.x
Keywords: Cc:

Description (last modified by robe)

As Pierre pointed out in:

https://lists.osgeo.org/pipermail/postgis-users/2017-June/042203.html

We've got what appears to be a bug with our handling of POINT EMPTY, POINT 0 0.

Tested on PostGIS 2.3 and 2.4

SELECT ST_AsText(geom) txt, count(*)
FROM (
SELECT 'POINT(0 0)'::geometry geom
UNION ALL
SELECT 'POINT(0 0)'::geometry geom
UNION ALL
SELECT 'POINT(0 0)'::geometry geom
UNION ALL
SELECT 'POINT(0 1)'::geometry geom
UNION ALL
SELECT 'LINESTRING(0 0,0 1)'::geometry geom
UNION ALL
SELECT 'GEOMETRYCOLLECTION EMPTY'::geometry geom
UNION ALL
SELECT 'POINT EMPTY'::geometry geom
) foo
GROUP BY geom;

Yields:

           txt            | count
--------------------------+-------
 POINT(0 0)               |     2
 POINT EMPTY              |     1
 POINT(0 0)               |     1
 LINESTRING(0 0,0 1)      |     1
 GEOMETRYCOLLECTION EMPTY |     1
 POINT(0 1)               |     1

when it should be yielding something along the lines of:

           txt            | count
--------------------------+-------
 POINT(0 0)               |     3
 LINESTRING(0 0,0 1)      |     1
 GEOMETRYCOLLECTION EMPTY |     2
 POINT(0 1)               |     1


Since POINT EMPTY and GEOMETRYCOLLECTION have null boxes they should aggregate together and since points and 2 point lines should have no boxes, they should be taken literally.

I did the same exercise in PostGIS 1.5.5 and got this:

           txt            | count
--------------------------+-------
 GEOMETRYCOLLECTION EMPTY |     4
 LINESTRING(0 0,0 1)      |     1
 GEOMETRYCOLLECTION EMPTY |     1
 POINT(0 1)               |     1
(4 rows)

which I attributed to the fact that at one point of time, since we had no concept of POINT EMPTY we always output the representation as GEOMETRYCOLLECTION EMPTY and I think there was one function that used POINT(0 0) as rep for POINT EMPTY. Though I could be mistaken.

Change History (1)

comment:1 by robe, 7 years ago

Description: modified (diff)
Note: See TracTickets for help on using tickets.