[postgis-tickets] [SCM] PostGIS branch stable-3.0 updated. 3.0.2-7-gb22956b
git at osgeo.org
git at osgeo.org
Sat Sep 26 23:02:28 PDT 2020
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "PostGIS".
The branch, stable-3.0 has been updated
via b22956b993b6f4110c72130b5c8c415597a835e8 (commit)
from 7c4106c5a3a0118f1b928c960df10cd8210e7e44 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit b22956b993b6f4110c72130b5c8c415597a835e8
Author: Regina Obe <lr at pcorp.us>
Date: Sun Sep 27 02:02:20 2020 -0400
Fail fast when srids of geometry/raster are different, schema qualify. Closes #4719 for PostGIS 3.0.3
diff --git a/NEWS b/NEWS
index 59caccf..c10662b 100644
--- a/NEWS
+++ b/NEWS
@@ -3,6 +3,8 @@ PostGIS 3.0.3dev
* Bug Fixes and Enhancements *
- #4742 tiger geocoder reverted to 2018 version on tiger upgrade
- #4757, Handle line collapse due to snap-to-existing node (Sandro Santilli)
+ - #4719, Fail fast when srids don't match ST_Intersection(geometry,raster)
+ Also schema qualify calls in function. (Regina Obe)
PostGIS 3.0.2
2020/08/15
diff --git a/raster/rt_pg/rtpostgis.sql.in b/raster/rt_pg/rtpostgis.sql.in
index acb3ecf..b5e7a09 100644
--- a/raster/rt_pg/rtpostgis.sql.in
+++ b/raster/rt_pg/rtpostgis.sql.in
@@ -6679,14 +6679,20 @@ CREATE OR REPLACE FUNCTION ST_Disjoint(rast1 raster, rast2 raster)
-----------------------------------------------------------------------
-- ST_Intersection(geometry, raster) in geometry-space
+-- Changed: 3.0.3, fail fast on mismatch srid and schema qualify funcs
-----------------------------------------------------------------------
-
CREATE OR REPLACE FUNCTION ST_Intersection(geomin geometry, rast raster, band integer DEFAULT 1)
RETURNS SETOF geomval AS $$
DECLARE
- intersects boolean := FALSE;
+ intersects boolean := FALSE; same_srid boolean := FALSE;
BEGIN
- intersects := ST_Intersects(geomin, rast, band);
+ same_srid := (@extschema at .ST_SRID(geomin) = @extschema at .ST_SRID(rast));
+ IF NOT same_srid THEN
+ RAISE EXCEPTION 'SRIDS of geometry: % and raster: % are not the same',
+ @extschema at .ST_SRID(geomin), @extschema at .ST_SRID(rast)
+ USING HINT = 'Verify using ST_SRID function';
+ END IF;
+ intersects := @extschema at .ST_Intersects(geomin, rast, band);
IF intersects THEN
-- Return the intersections of the geometry with the vectorized parts of
-- the raster and the values associated with those parts, if really their
@@ -6697,12 +6703,12 @@ CREATE OR REPLACE FUNCTION ST_Intersection(geomin geometry, rast raster, band in
val
FROM (
SELECT
- ST_Intersection((gv).geom, geomin) AS intgeom,
+ @extschema at .ST_Intersection((gv).geom, geomin) AS intgeom,
(gv).val
- FROM ST_DumpAsPolygons(rast, band) gv
- WHERE ST_Intersects((gv).geom, geomin)
+ FROM @extschema at .ST_DumpAsPolygons(rast, band) gv
+ WHERE @extschema at .ST_Intersects((gv).geom, geomin)
) foo
- WHERE NOT ST_IsEmpty(intgeom);
+ WHERE NOT @extschema at .ST_IsEmpty(intgeom);
ELSE
-- If the geometry does not intersect with the raster, return an empty
-- geometry and a null value
diff --git a/raster/test/regress/rt_intersection.sql b/raster/test/regress/rt_intersection.sql
index 46344e0..1dd9a48 100644
--- a/raster/test/regress/rt_intersection.sql
+++ b/raster/test/regress/rt_intersection.sql
@@ -161,5 +161,12 @@ FROM (
) foo
ORDER BY 1, 2, 3, 4, 5, 6, 7;
+-- test for mismatched srid geom/raster https://trac.osgeo.org/postgis/ticket/4719
+SELECT '#4719' AS ticker, r1.rid, ST_Intersection(
+ r1.rast, ST_Buffer(ST_SetSRID(ST_Point(1,2), 4326),0.5)
+ )
+ FROM raster_intersection AS r1
+ WHERE r1.rid = 10;
+
DROP TABLE IF EXISTS raster_intersection;
DROP TABLE IF EXISTS raster_intersection_out;
diff --git a/raster/test/regress/rt_intersection_expected b/raster/test/regress/rt_intersection_expected
index 67161ba..0f819fa 100644
--- a/raster/test/regress/rt_intersection_expected
+++ b/raster/test/regress/rt_intersection_expected
@@ -118,3 +118,4 @@
10|13|2|1|2|4|POLYGON((0.1 -0.8,1.1 -0.7,1.2 0.3,0.2 0.2,0.1 -0.8))
10|13|2|2|1|4|POLYGON((1 -1.7,2 -1.6,2.1 -0.6,1.1 -0.7,1 -1.7))
10|13|2|2|2|4|POLYGON((1.1 -0.7,2.1 -0.6,2.2 0.4,1.2 0.3,1.1 -0.7))
+ERROR: SRIDS of geometry: 4326 and raster: 0 are not the same
-----------------------------------------------------------------------
Summary of changes:
NEWS | 2 ++
raster/rt_pg/rtpostgis.sql.in | 20 +++++++++++++-------
raster/test/regress/rt_intersection.sql | 7 +++++++
raster/test/regress/rt_intersection_expected | 1 +
4 files changed, 23 insertions(+), 7 deletions(-)
hooks/post-receive
--
PostGIS
More information about the postgis-tickets
mailing list