- #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.4.8
/* COMPUTE_BBOX TAINTING */
if ( in_lwgeom->bbox )
+ {
+ lwgeom_drop_bbox(out_lwgeom);
lwgeom_add_bbox(out_lwgeom);
-
+ }
POSTGIS_DEBUGF(3, "SnapToGrid made a %s", lwtype_name(out_lwgeom->type));
if ( out_lwgeom == NULL ) PG_RETURN_NULL();
/* COMPUTE_BBOX TAINTING */
- if ( in_lwgeom->bbox ) lwgeom_add_bbox(out_lwgeom);
+ if (in_lwgeom->bbox)
+ {
+ lwgeom_drop_bbox(out_lwgeom);
+ lwgeom_add_bbox(out_lwgeom);
+ }
POSTGIS_DEBUGF(3, "SnapToGrid made a %s", lwtype_name(out_lwgeom->type));
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;
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)
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;
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)