[postgis-tickets] [SCM] PostGIS branch master updated. 3.1.0alpha2-71-gbf932db

git at osgeo.org git at osgeo.org
Sat Sep 26 22:49:49 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, master has been updated
       via  bf932db36f78a25b7a0869baa03cb000d2cbf4c6 (commit)
      from  3bcbbee1324e0efe574481a59a603b4be85f962a (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 bf932db36f78a25b7a0869baa03cb000d2cbf4c6
Author: Regina Obe <lr at pcorp.us>
Date:   Sun Sep 27 01:49:42 2020 -0400

    Fail fast when srids of geometry/raster are different. References #4719 for PostGIS 3.1 master

diff --git a/NEWS b/NEWS
index fb8ff3f..9a352a3 100644
--- a/NEWS
+++ b/NEWS
@@ -31,6 +31,8 @@ Only tickets not included in 3.1.0alpha2
   - #4737, Improve performance and reduce memory usage in ST_AsMVT, especially in
            queries involving parallelism (Raúl Marín)
   - #4746, Micro optimizations to the serialization process (Raúl Marín)
+  - #4719, Fail fast when srids don't match ST_Intersection(geometry,raster)
+            Also schema qualify calls in function. (Regina Obe)
 
 * Bug fixes *
   - #4691, Fix segfault during gist index creation with empty geometries (Raúl Marín)
diff --git a/raster/rt_pg/rtpostgis.sql.in b/raster/rt_pg/rtpostgis.sql.in
index bfb91b5..ab1669b 100644
--- a/raster/rt_pg/rtpostgis.sql.in
+++ b/raster/rt_pg/rtpostgis.sql.in
@@ -6671,9 +6671,15 @@ CREATE OR REPLACE FUNCTION ST_Disjoint(rast1 raster, rast2 raster)
 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
@@ -6684,12 +6690,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                | 18 ++++++++++++------
 raster/test/regress/rt_intersection.sql      |  7 +++++++
 raster/test/regress/rt_intersection_expected |  1 +
 4 files changed, 22 insertions(+), 6 deletions(-)


hooks/post-receive
-- 
PostGIS


More information about the postgis-tickets mailing list