From ca21d3943610f1becd7c26eeb012e1994d9490b5 Mon Sep 17 00:00:00 2001 From: Sandro Santilli Date: Mon, 16 Jan 2012 11:22:27 +0000 Subject: [PATCH] Fix WKB output for POINT EMPTY with SRID or higher dims (#1478) git-svn-id: http://svn.osgeo.org/postgis/trunk@8835 b70326c6-7e19-0410-871a-916f4a2858ee --- liblwgeom/lwout_wkb.c | 6 +++++- regress/tickets.sql | 3 +++ regress/tickets_expected | 1 + regress/wkb_expected | 6 +++--- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/liblwgeom/lwout_wkb.c b/liblwgeom/lwout_wkb.c index 723ac75ae..3731a2bc2 100644 --- a/liblwgeom/lwout_wkb.c +++ b/liblwgeom/lwout_wkb.c @@ -287,7 +287,11 @@ static uint8_t* empty_to_wkb_buf(const LWGEOM *geom, uint8_t *buf, uint8_t varia uint32_t wkb_type = lwgeom_wkb_type(geom, variant); if ( geom->type == POINTTYPE ) - wkb_type = WKB_MULTIPOINT_TYPE; /* Change POINT to MULTIPOINT */ + { + /* Change POINT to MULTIPOINT */ + wkb_type &= ~WKB_POINT_TYPE; /* clear POINT flag */ + wkb_type |= WKB_MULTIPOINT_TYPE; /* set MULTIPOINT flag */ + } /* Set the endian flag */ buf = endian_to_wkb_buf(buf, variant); diff --git a/regress/tickets.sql b/regress/tickets.sql index a316f28f5..16173bea5 100644 --- a/regress/tickets.sql +++ b/regress/tickets.sql @@ -514,6 +514,9 @@ SELECT '#1454', st_orderingequals(g,g) from inp; -- #1414 SELECT '#1414', st_astext(st_force_3dz('CURVEPOLYGON EMPTY')); +-- #1478 +SELECT '#1478', 'SRID=1;POINT EMPTY'::geometry::text::geometry; + -- Clean up DELETE FROM spatial_ref_sys; diff --git a/regress/tickets_expected b/regress/tickets_expected index 14e978833..83cbfacd5 100644 --- a/regress/tickets_expected +++ b/regress/tickets_expected @@ -173,3 +173,4 @@ ERROR: MultiSurface cannot contain MultiPoint element #1453.2|f #1454|t #1414|CURVEPOLYGON Z EMPTY +#1478|01040000200100000000000000 diff --git a/regress/wkb_expected b/regress/wkb_expected index 43c3c9b11..d482fa789 100644 --- a/regress/wkb_expected +++ b/regress/wkb_expected @@ -1,7 +1,7 @@ POINT EMPTY|010400000000000000|f|000000000400000000 -POINT Z EMPTY|010400000000000000|f|000000000400000000 -POINT M EMPTY|010400000000000000|f|000000000400000000 -POINT ZM EMPTY|010400000000000000|f|000000000400000000 +POINT Z EMPTY|01ec03000000000000|f|00000003ec00000000 +POINT M EMPTY|01d407000000000000|f|00000007d400000000 +POINT ZM EMPTY|01bc0b000000000000|f|0000000bbc00000000 POINT(0 0)|010100000000000000000000000000000000000000|t|000000000100000000000000000000000000000000 POINT Z (1 2 3)|01e9030000000000000000f03f00000000000000400000000000000840|t|00000003e93ff000000000000040000000000000004008000000000000 POINT M (1 2 3)|01d1070000000000000000f03f00000000000000400000000000000840|t|00000007d13ff000000000000040000000000000004008000000000000 -- 2.40.0