From: Raúl Marín Rodríguez Date: Mon, 2 Sep 2019 12:09:59 +0000 (+0000) Subject: Fix ST_SnapToGrid output having an outdated bbox X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9030cca87ae2cf5381a9dc4f3d8cbaf0300fe796;p=postgis Fix ST_SnapToGrid output having an outdated bbox References #4495 git-svn-id: http://svn.osgeo.org/postgis/branches/2.5@17799 b70326c6-7e19-0410-871a-916f4a2858ee --- diff --git a/NEWS b/NEWS index 7c7cc98d0..8e363dbea 100644 --- a/NEWS +++ b/NEWS @@ -9,6 +9,7 @@ XXXX/XX/XX - #4492, Fix ST_Simplify ignoring the value of the 3rd parameter (Raúl Marín) - #4494, Fix ST_Simplify output having an outdated bbox (Raúl Marín) - #4493, Fix ST_RemoveRepeatedPoints output having an outdated bbox (Raúl Marín) + - #4495, Fix ST_SnapToGrid output having an outdated bbox (Raúl Marín) PostGIS 2.5.3 2019/08/11 diff --git a/postgis/lwgeom_functions_analytic.c b/postgis/lwgeom_functions_analytic.c index 2ca788e3f..0b67975d9 100644 --- a/postgis/lwgeom_functions_analytic.c +++ b/postgis/lwgeom_functions_analytic.c @@ -331,8 +331,7 @@ Datum LWGEOM_snaptogrid(PG_FUNCTION_ARGS) /* COMPUTE_BBOX TAINTING */ if ( in_lwgeom->bbox ) - lwgeom_add_bbox(out_lwgeom); - + lwgeom_refresh_bbox(out_lwgeom); POSTGIS_DEBUGF(3, "SnapToGrid made a %s", lwtype_name(out_lwgeom->type)); @@ -413,7 +412,10 @@ Datum LWGEOM_snaptogrid_pointoff(PG_FUNCTION_ARGS) if ( out_lwgeom == NULL ) PG_RETURN_NULL(); /* COMPUTE_BBOX TAINTING */ - if ( in_lwgeom->bbox ) lwgeom_add_bbox(out_lwgeom); + if (in_lwgeom->bbox) + { + lwgeom_refresh_bbox(out_lwgeom); + } POSTGIS_DEBUGF(3, "SnapToGrid made a %s", lwtype_name(out_lwgeom->type)); diff --git a/regress/chaikin.sql b/regress/chaikin.sql index f799c71fb..8bcd067b0 100644 --- a/regress/chaikin.sql +++ b/regress/chaikin.sql @@ -4,3 +4,10 @@ SELECT '3', ST_astext(ST_ChaikinSmoothing('LINESTRING(0 0, 8 8, 0 16)',0)); SELECT '4', ST_astext(ST_ChaikinSmoothing('LINESTRING(0 0, 8 8, 0 16)',2)); SELECT '5', ST_astext(ST_ChaikinSmoothing('POINT(0 0)')); SELECT '6', ST_astext(ST_ChaikinSmoothing('GEOMETRYCOLLECTION(POINT(1 1), LINESTRING(1 1, 1 3, 1 5), POLYGON((5 5, 5 10, 10 10, 10 5, 5 5), (6 6, 6 7, 7 7, 7 6, 6 6 )))', 2, 't')); + +-- The geometry bbox is updated +WITH geom AS +( + SELECT ST_ChaikinSmoothing('POLYGON((0 0, 8 8, 0 16, 0 0))') AS g +) +SELECT '7', ST_AsText(g) as geometry, postgis_getbbox(g) AS box from geom; \ No newline at end of file diff --git a/regress/chaikin_expected b/regress/chaikin_expected index b4d19f2f2..b6f2d3439 100644 --- a/regress/chaikin_expected +++ b/regress/chaikin_expected @@ -4,3 +4,4 @@ ERROR: Number of iterations must be between 1 and 5 : LWGEOM_ChaikinSmoothing 4|LINESTRING(0 0,4.5 4.5,6 7,6 9,4.5 11.5,0 16) 5|POINT(0 0) 6|GEOMETRYCOLLECTION(POINT(1 1),LINESTRING(1 1,1 2.125,1 2.75,1 3.25,1 3.875,1 5),POLYGON((5 5,5 7.8125,5.3125 9.0625,5.9375 9.6875,6.875 10,8.125 10,9.0625 9.6875,9.6875 9.0625,10 8.125,10 6.875,9.6875 5.9375,9.0625 5.3125,7.8125 5,5 5),(6 6,6 6.5625,6.0625 6.8125,6.1875 6.9375,6.375 7,6.625 7,6.8125 6.9375,6.9375 6.8125,7 6.625,7 6.375,6.9375 6.1875,6.8125 6.0625,6.5625 6,6 6))) +7|POLYGON((2 2,6 6,6 10,2 14,0 12,0 4,2 2))|BOX(0 2,6 14) diff --git a/regress/simplifyvw.sql b/regress/simplifyvw.sql index 68e16c92e..e349af1a8 100644 --- a/regress/simplifyvw.sql +++ b/regress/simplifyvw.sql @@ -12,3 +12,10 @@ SELECT '9', ST_astext(ST_Simplifyvw('POLYGON((0 0, 10 0, 10 10, 0 10, 0 0),(5 5, SELECT '10', ST_astext(ST_Simplifyvw('LINESTRING(0 0, 0 10)', 20)); SELECT '11', ST_astext(ST_Simplifyvw('MULTIPOLYGON(((100 100, 100 130, 130 130, 130 100, 100 100)), ((0 0, 10 0, 10 10, 0 10, 0 0),(5 5, 5 6, 6 6, 8 5, 5 5)) )', 20)); SELECT '12', ST_astext(ST_Simplifyvw('MULTIPOLYGON(((0 0, 10 0, 10 10, 0 10, 0 0),(5 5, 5 6, 6 6, 8 5, 5 5)),((100 100, 100 130, 130 130, 130 100, 100 100)))', 200)); + +-- The geometry bbox is updated +WITH geom AS +( + SELECT ST_Simplifyvw('MULTIPOLYGON(((0 0, 10 0, 10 10, 0 10, 0 0),(5 5, 5 6, 6 6, 8 5, 5 5)),((100 100, 100 130, 130 130, 130 131, 130 130, 130 100, 100 100)))', 200) AS g +) +SELECT '13', ST_AsText(g) as geometry, postgis_getbbox(g) AS box from geom; diff --git a/regress/simplifyvw_expected b/regress/simplifyvw_expected index a9ea8d69a..d37ee6ada 100644 --- a/regress/simplifyvw_expected +++ b/regress/simplifyvw_expected @@ -10,3 +10,4 @@ 10|LINESTRING(0 0,0 10) 11|MULTIPOLYGON(((100 100,100 130,130 130,130 100,100 100)),((0 0,10 0,10 10,0 10,0 0))) 12|MULTIPOLYGON(((0 0,10 10,0 10,0 0)),((100 100,100 130,130 130,130 100,100 100))) +13|MULTIPOLYGON(((0 0,10 10,0 10,0 0)),((100 100,100 130,130 130,130 100,100 100)))|BOX(0 0,130 130) diff --git a/regress/snaptogrid.sql b/regress/snaptogrid.sql index 571cd2c41..0b6f5bd97 100644 --- a/regress/snaptogrid.sql +++ b/regress/snaptogrid.sql @@ -10,3 +10,12 @@ SELECT ST_snaptogrid(orig, 0.002) ~= ST_snaptogrid(ST_snaptogrid(orig, 0.002), 0 SELECT ST_snaptogrid(orig, 0.003) ~= ST_snaptogrid(ST_snaptogrid(orig, 0.003), 0.003) FROM tmp; SELECT ST_snaptogrid(orig, 0.0002) ~= ST_snaptogrid(ST_snaptogrid(orig, 0.0002), 0.0002) FROM tmp; DROP TABLE tmp; + +-- The geometry bbox is updated +WITH geom AS +( + SELECT ST_SnapToGrid('POLYGON((0 0, 10 0, 10 10, 10.6 10, 10.5 10.5, 10 10, 0 10, 0 0))', 10) as g + UNION ALL + SELECT ST_SnapToGrid('POLYGON((0 0, 10 0, 10 10, 10.6 10, 10.5 10.5, 10 10, 0 10, 0 0))', 'POINT(0 0)', 10, 10, 10, 10) as g +) +Select ST_AsText(g) as geometry, postgis_getbbox(g) AS box from geom; diff --git a/regress/snaptogrid_expected b/regress/snaptogrid_expected index 04e7be33b..518c1734b 100644 --- a/regress/snaptogrid_expected +++ b/regress/snaptogrid_expected @@ -3,3 +3,5 @@ t t t t +POLYGON((0 0,10 0,10 10,0 10,0 0))|BOX(0 0,10 10) +POLYGON((0 0,10 0,10 10,0 10,0 0))|BOX(0 0,10 10)