]> granicus.if.org Git - postgis/commitdiff
Added SRID check to ST_NearestValue
authorBborie Park <bkpark at ucdavis.edu>
Tue, 22 May 2012 17:05:27 +0000 (17:05 +0000)
committerBborie Park <bkpark at ucdavis.edu>
Tue, 22 May 2012 17:05:27 +0000 (17:05 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@9787 b70326c6-7e19-0410-871a-916f4a2858ee

raster/rt_pg/rt_pg.c
raster/rt_pg/rtpostgis.sql.in.c

index 41d7cd93a6672b8b6730ca42cd4f128982c7942c..52480a0fa0cf201f55bf01b1d4d7799e9a80ebdf 100644 (file)
@@ -2420,6 +2420,13 @@ Datum RASTER_nearestValue(PG_FUNCTION_ARGS)
        if (!PG_ARGISNULL(3))
                exclude_nodata_value = PG_GETARG_BOOL(3);
 
+       /* SRIDs of raster and geometry must match  */
+       if (gserialized_get_srid(geom) != rt_raster_get_srid(raster)) {
+               elog(NOTICE, "SRIDs of geometry and raster do not match");
+               rt_raster_destroy(raster);
+               PG_RETURN_NULL();
+       }
+
        /* get band */
        band = rt_raster_get_band(raster, bandindex - 1);
        if (!band) {
index f6e6846ed7d9ceed661fd4db4950567de6ffc6bc..3a4b21ac24f623eca3a94830294c4b292dd0b4e4 100644 (file)
@@ -3520,7 +3520,7 @@ CREATE OR REPLACE FUNCTION st_nearestvalue(
        exclude_nodata_value boolean DEFAULT TRUE
 )
        RETURNS double precision
-       AS $$ SELECT st_nearestvalue($1, $2, st_makepoint(st_raster2worldcoordx($1, $3, $4), st_raster2worldcoordy($1, $3, $4)), $5) $$
+       AS $$ SELECT st_nearestvalue($1, $2, st_setsrid(st_makepoint(st_raster2worldcoordx($1, $3, $4), st_raster2worldcoordy($1, $3, $4)), st_srid($1)), $5) $$
        LANGUAGE 'SQL' IMMUTABLE STRICT;
 
 CREATE OR REPLACE FUNCTION st_nearestvalue(
@@ -3529,7 +3529,7 @@ CREATE OR REPLACE FUNCTION st_nearestvalue(
        exclude_nodata_value boolean DEFAULT TRUE
 )
        RETURNS double precision
-       AS $$ SELECT st_nearestvalue($1, 1, st_makepoint(st_raster2worldcoordx($1, $2, $3), st_raster2worldcoordy($1, $2, $3)), $4) $$
+       AS $$ SELECT st_nearestvalue($1, 1, st_setsrid(st_makepoint(st_raster2worldcoordx($1, $2, $3), st_raster2worldcoordy($1, $2, $3)), st_srid($1)), $4) $$
        LANGUAGE 'SQL' IMMUTABLE STRICT;
 
 -----------------------------------------------------------------------