From: Sandro Santilli Date: Fri, 13 Apr 2012 21:04:15 +0000 (+0000) Subject: fix ST_SymDifference(empty, geom) to return geom (#1776) X-Git-Tag: 2.0.1~131 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5a74e2c988ff9a1c6d1c151c02e4bcd865fa7dd3;p=postgis fix ST_SymDifference(empty, geom) to return geom (#1776) git-svn-id: http://svn.osgeo.org/postgis/trunk@9641 b70326c6-7e19-0410-871a-916f4a2858ee --- diff --git a/NEWS b/NEWS index cfc0c8f43..d59a719d2 100644 --- a/NEWS +++ b/NEWS @@ -3,6 +3,7 @@ PostGIS 2.0.1 * Bug Fixes * + - #1776, fix ST_SymDifference(empty, geom) to return geom - #1708, improve restore of PosgreSQL 9.1 backups - #1766, don't let ST_RemEdge* destroy peripheral TopoGeometry objects. - #1714, more robust handling of high topology tolerance. diff --git a/liblwgeom/lwgeom_geos.c b/liblwgeom/lwgeom_geos.c index fdf0c9f14..149ea926c 100644 --- a/liblwgeom/lwgeom_geos.c +++ b/liblwgeom/lwgeom_geos.c @@ -583,9 +583,9 @@ lwgeom_symdifference(const LWGEOM* geom1, const LWGEOM* geom2) if ( lwgeom_is_empty(geom2) ) return lwgeom_clone(geom1); - /* Empty.DymDifference(B) == Empty */ + /* Empty.DymDifference(B) == B */ if ( lwgeom_is_empty(geom1) ) - return lwgeom_clone(geom1); + return lwgeom_clone(geom2); /* ensure srids are identical */ srid = (int)(geom1->srid); diff --git a/regress/tickets.sql b/regress/tickets.sql index eaa133e89..75b4356fa 100644 --- a/regress/tickets.sql +++ b/regress/tickets.sql @@ -657,5 +657,13 @@ DROP table eg; -- #1755 -- select '#1755', st_geographyFromText('SRID=4326;Point(85 35 0)'); +-- #1776 -- +with inp as ( SELECT + 'POLYGON EMPTY'::geometry as A, + 'POLYGON((0 0, 10 0, 10 10, 0 0))'::geometry as B ) +SELECT '#1776', + ST_AsText(ST_SymDifference(A,B)), ST_AsText(ST_SymDifference(B, A)) +FROM inp; + -- Clean up DELETE FROM spatial_ref_sys; diff --git a/regress/tickets_expected b/regress/tickets_expected index bab85102f..cb13d9acb 100644 --- a/regress/tickets_expected +++ b/regress/tickets_expected @@ -215,3 +215,4 @@ NOTICE: SRID value -1 converted to the officially unknown SRID value 0 #1697.3|1024 #1734.1|1026 #1755|01010000A0E6100000000000000040554000000000008041400000000000000000 +#1776|POLYGON((0 0,10 0,10 10,0 0))|POLYGON((0 0,10 0,10 10,0 0))