]> granicus.if.org Git - postgis/commitdiff
Added SRID check of geometry for ST_World2RasterCoord variants
authorBborie Park <bkpark at ucdavis.edu>
Mon, 29 Oct 2012 22:23:05 +0000 (22:23 +0000)
committerBborie Park <bkpark at ucdavis.edu>
Mon, 29 Oct 2012 22:23:05 +0000 (22:23 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@10584 b70326c6-7e19-0410-871a-916f4a2858ee

raster/rt_pg/rtpostgis.sql.in.c
raster/test/regress/rt_utility_expected

index caf54a190420d855f5024bbeb271ab15fcb585c3..36d1277759d0fe644d3d4cfa2534c2136c0501d8 100644 (file)
@@ -4330,9 +4330,13 @@ CREATE OR REPLACE FUNCTION st_world2rastercoord(
                rx integer;
                ry integer;
        BEGIN
-               IF (st_geometrytype(pt) != 'ST_Point') THEN
+               IF st_geometrytype(pt) != 'ST_Point' THEN
                        RAISE EXCEPTION 'Attempting to compute raster coordinate with a non-point geometry';
                END IF;
+               IF ST_SRID(rast) != ST_SRID(pt) THEN
+                       RAISE EXCEPTION 'Raster and geometry do not have the same SRID';
+               END IF;
+
                SELECT rc.columnx AS x, rc.rowy AS y INTO columnx, rowy FROM _st_world2rastercoord($1, st_x(pt), st_y(pt)) AS rc;
                RETURN;
        END;
@@ -4377,6 +4381,9 @@ CREATE OR REPLACE FUNCTION st_world2rastercoordx(rast raster, pt geometry)
                IF ( st_geometrytype(pt) != 'ST_Point' ) THEN
                        RAISE EXCEPTION 'Attempting to compute raster coordinate with a non-point geometry';
                END IF;
+               IF ST_SRID(rast) != ST_SRID(pt) THEN
+                       RAISE EXCEPTION 'Raster and geometry do not have the same SRID';
+               END IF;
                SELECT columnx INTO xr FROM _st_world2rastercoord($1, st_x(pt), st_y(pt));
                RETURN xr;
        END;
@@ -4421,6 +4428,9 @@ CREATE OR REPLACE FUNCTION st_world2rastercoordy(rast raster, pt geometry)
                IF ( st_geometrytype(pt) != 'ST_Point' ) THEN
                        RAISE EXCEPTION 'Attempting to compute raster coordinate with a non-point geometry';
                END IF;
+               IF ST_SRID(rast) != ST_SRID(pt) THEN
+                       RAISE EXCEPTION 'Raster and geometry do not have the same SRID';
+               END IF;
                SELECT rowy INTO yr FROM _st_world2rastercoord($1, st_x(pt), st_y(pt));
                RETURN yr;
        END;
index 8b183b7fe4a92d417fc1a12526215980ef4d01ee..6b9155b543b4a0d6fd6769357712f246a463589f 100644 (file)
@@ -2,10 +2,16 @@ NOTICE:  Latitude and longitude required for computing pixel row and column of a
 NOTICE:  Latitude and longitude required for computing pixel row and column of a rotated raster
 test 2.4|2|1217x1156, ip:782325.5,26744042.5 scale:5,-5 skew:3,3 srid:9102707 width:1217 height:1156
 test 2.4|4|6000x6000, ip:-75.5533328537098,49.2824585505576 scale:0.000805965234044584,-0.00080596523404458 skew:0.000211812383858707,0.000211812383858704 srid:4326 width:6000 height:6000
+ERROR:  Raster and geometry do not have the same SRID
+ERROR:  Raster and geometry do not have the same SRID
+ERROR:  Raster and geometry do not have the same SRID
 NOTICE:  Latitude and longitude required for computing pixel row and column of a rotated raster
 NOTICE:  Latitude and longitude required for computing pixel row and column of a rotated raster
 test 5.4|2|1217x1156, ip:782325.5,26744042.5 scale:5,-5 skew:3,3 srid:9102707 width:1217 height:1156
 test 5.4|4|6000x6000, ip:-75.5533328537098,49.2824585505576 scale:0.000805965234044584,-0.00080596523404458 skew:0.000211812383858707,0.000211812383858704 srid:4326 width:6000 height:6000
+ERROR:  Raster and geometry do not have the same SRID
+ERROR:  Raster and geometry do not have the same SRID
+ERROR:  Raster and geometry do not have the same SRID
 NOTICE:  Pixel row and column required for computing longitude and latitude of a rotated raster
 NOTICE:  Pixel row and column required for computing longitude and latitude of a rotated raster
 test 8.3|2|1217x1156, ip:782325.5,26744042.5 scale:5,-5 skew:3,3 srid:9102707 width:1217 height:1156