From: Bborie Park Date: Mon, 29 Oct 2012 22:23:05 +0000 (+0000) Subject: Added SRID check of geometry for ST_World2RasterCoord variants X-Git-Tag: 2.1.0beta2~442 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=36a1a9ab394ac20423673ba15e0fe100465e6c2d;p=postgis Added SRID check of geometry for ST_World2RasterCoord variants git-svn-id: http://svn.osgeo.org/postgis/trunk@10584 b70326c6-7e19-0410-871a-916f4a2858ee --- diff --git a/raster/rt_pg/rtpostgis.sql.in.c b/raster/rt_pg/rtpostgis.sql.in.c index caf54a190..36d127775 100644 --- a/raster/rt_pg/rtpostgis.sql.in.c +++ b/raster/rt_pg/rtpostgis.sql.in.c @@ -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; diff --git a/raster/test/regress/rt_utility_expected b/raster/test/regress/rt_utility_expected index 8b183b7fe..6b9155b54 100644 --- a/raster/test/regress/rt_utility_expected +++ b/raster/test/regress/rt_utility_expected @@ -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