]> granicus.if.org Git - postgis/commitdiff
Addition of ST_PixelAsPoints and ST_PixelAsCentroids
authorBborie Park <bkpark at ucdavis.edu>
Tue, 3 Jul 2012 22:30:13 +0000 (22:30 +0000)
committerBborie Park <bkpark at ucdavis.edu>
Tue, 3 Jul 2012 22:30:13 +0000 (22:30 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@10024 b70326c6-7e19-0410-871a-916f4a2858ee

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

index b2822f1785c4a37a2481fdb9453d052d2ef3f299..3c0dbe58d3b119ecb25ba1b41c5874c700167569 100644 (file)
@@ -2532,7 +2532,7 @@ CREATE OR REPLACE FUNCTION st_pixelaspolygons(
        LANGUAGE 'sql' IMMUTABLE STRICT;
 
 -----------------------------------------------------------------------
--- ST_PixelAsPolygons
+-- ST_PixelAsPolygon
 -----------------------------------------------------------------------
 
 CREATE OR REPLACE FUNCTION st_pixelaspolygon(rast raster, x integer, y integer)
@@ -2540,6 +2540,58 @@ CREATE OR REPLACE FUNCTION st_pixelaspolygon(rast raster, x integer, y integer)
        AS $$ SELECT geom FROM _st_pixelaspolygons($1, NULL, $2, $3) $$
        LANGUAGE 'sql' IMMUTABLE STRICT;
 
+-----------------------------------------------------------------------
+-- ST_PixelAsPoints
+-----------------------------------------------------------------------
+
+CREATE OR REPLACE FUNCTION st_pixelaspoints(
+       rast raster,
+       band integer DEFAULT 1,
+       exclude_nodata_value boolean DEFAULT TRUE,
+       OUT geom geometry,
+       OUT val double precision,
+       OUT x int,
+       OUT y int
+)
+       RETURNS SETOF record
+       AS $$ SELECT ST_PointN(ST_ExteriorRing(geom), 1), val, x, y FROM _st_pixelaspolygons($1, $2, NULL, NULL, $3) $$
+       LANGUAGE 'sql' IMMUTABLE STRICT;
+
+-----------------------------------------------------------------------
+-- ST_PixelAsPoint
+-----------------------------------------------------------------------
+
+CREATE OR REPLACE FUNCTION st_pixelaspoint(rast raster, x integer, y integer)
+       RETURNS geometry
+       AS $$ SELECT ST_PointN(ST_ExteriorRing(geom), 1) FROM _st_pixelaspolygons($1, NULL, $2, $3) $$
+       LANGUAGE 'sql' IMMUTABLE STRICT;
+
+-----------------------------------------------------------------------
+-- ST_PixelAsCentroids
+-----------------------------------------------------------------------
+
+CREATE OR REPLACE FUNCTION st_pixelascentroids(
+       rast raster,
+       band integer DEFAULT 1,
+       exclude_nodata_value boolean DEFAULT TRUE,
+       OUT geom geometry,
+       OUT val double precision,
+       OUT x int,
+       OUT y int
+)
+       RETURNS SETOF record
+       AS $$ SELECT ST_Centroid(geom), val, x, y FROM _st_pixelaspolygons($1, $2, NULL, NULL, $3) $$
+       LANGUAGE 'sql' IMMUTABLE STRICT;
+
+-----------------------------------------------------------------------
+-- ST_PixelAsCentroid
+-----------------------------------------------------------------------
+
+CREATE OR REPLACE FUNCTION st_pixelascentroid(rast raster, x integer, y integer)
+       RETURNS geometry
+       AS $$ SELECT ST_Centroid(geom) FROM _st_pixelaspolygons($1, NULL, $2, $3) $$
+       LANGUAGE 'sql' IMMUTABLE STRICT;
+
 -----------------------------------------------------------------------
 -- Raster Utility Functions
 -----------------------------------------------------------------------
index 0a33b117b9d74e46a44d827eb723e8ce355b58ac..17f1d8c407b3e4ed24f231d7e7a7fd0c1487dd61 100644 (file)
@@ -83,7 +83,9 @@ TEST_BANDPROPS = \
        rt_neighborhood \
        rt_nearestvalue \
        rt_pixelofvalue \
-       rt_pixelaspolygons.sql
+       rt_pixelaspolygons \
+       rt_pixelaspoints \
+       rt_pixelascentroids
 
 TEST_UTILITY = \
        rt_utility \