]> granicus.if.org Git - postgis/commitdiff
Additional tests for rt_raster_surface()
authorBborie Park <bkpark at ucdavis.edu>
Fri, 13 Jul 2012 23:28:50 +0000 (23:28 +0000)
committerBborie Park <bkpark at ucdavis.edu>
Fri, 13 Jul 2012 23:28:50 +0000 (23:28 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@10057 b70326c6-7e19-0410-871a-916f4a2858ee

raster/test/core/testapi.c

index a2da802bd48759f9d5efe7c1cc0d105b8d96de2c..8b84ab93843f712b7f728d03f778f7058df1e7c9 100644 (file)
@@ -2995,6 +2995,53 @@ static void testRasterSurface() {
        lwmpoly_free(mpoly);
        mpoly = NULL;
 
+       /* plus 2,2 NODATA */
+       rt_band_set_pixel(band, 2, 2, 0);
+
+       mpoly = rt_raster_surface(rast, 0);
+       CHECK((mpoly != NULL));
+       wkt = lwgeom_to_text(lwmpoly_as_lwgeom(mpoly));
+       CHECK(!strcmp(wkt, "MULTIPOLYGON(((1 0,2 0,3 0,4 0,5 0,5 -1,5 -2,5 -3,5 -4,5 -5,4 -5,3 -5,2 -5,1 -5,0 -5,0 -4,0 -3,0 -2,0 -1,1 -1,1 0),(1 -1,1 -2,2 -2,2 -1,1 -1),(2 -2,2 -3,3 -3,3 -2,2 -2)))"));
+       rtdealloc(wkt);
+       lwmpoly_free(mpoly);
+       mpoly = NULL;
+
+       /* plus 3,3 NODATA */
+       rt_band_set_pixel(band, 3, 3, 0);
+
+       mpoly = rt_raster_surface(rast, 0);
+       CHECK((mpoly != NULL));
+       wkt = lwgeom_to_text(lwmpoly_as_lwgeom(mpoly));
+       CHECK(!strcmp(wkt, "MULTIPOLYGON(((1 0,2 0,3 0,4 0,5 0,5 -1,5 -2,5 -3,5 -4,5 -5,4 -5,3 -5,2 -5,1 -5,0 -5,0 -4,0 -3,0 -2,0 -1,1 -1,1 0),(1 -1,1 -2,2 -2,2 -1,1 -1),(2 -2,2 -3,3 -3,3 -2,2 -2),(3 -3,3 -4,4 -4,4 -3,3 -3)))"));
+       rtdealloc(wkt);
+       lwmpoly_free(mpoly);
+       mpoly = NULL;
+
+       /* plus 4,4 NODATA */
+       rt_band_set_pixel(band, 4, 4, 0);
+
+       mpoly = rt_raster_surface(rast, 0);
+       CHECK((mpoly != NULL));
+       wkt = lwgeom_to_text(lwmpoly_as_lwgeom(mpoly));
+       CHECK(!strcmp(wkt, "MULTIPOLYGON(((1 0,2 0,3 0,4 0,5 0,5 -1,5 -2,5 -3,5 -4,4 -4,4 -3,3 -3,3 -2,2 -2,2 -1,1 -1,1 0)),((0 -1,1 -1,1 -2,2 -2,2 -3,3 -3,3 -4,4 -4,4 -5,3 -5,2 -5,1 -5,0 -5,0 -4,0 -3,0 -2,0 -1)))"));
+       rtdealloc(wkt);
+       lwmpoly_free(mpoly);
+       mpoly = NULL;
+
+       /* a whole lot more NODATA */
+       rt_band_set_pixel(band, 4, 0, 0);
+       rt_band_set_pixel(band, 3, 1, 0);
+       rt_band_set_pixel(band, 1, 3, 0);
+       rt_band_set_pixel(band, 0, 4, 0);
+
+       mpoly = rt_raster_surface(rast, 0);
+       CHECK((mpoly != NULL));
+       wkt = lwgeom_to_text(lwmpoly_as_lwgeom(mpoly));
+       CHECK(!strcmp(wkt, "MULTIPOLYGON(((1 0,2 0,3 0,4 0,4 -1,3 -1,3 -2,2 -2,2 -1,1 -1,1 0)),((0 -1,1 -1,1 -2,2 -2,2 -3,1 -3,1 -4,0 -4,0 -3,0 -2,0 -1)),((4 -1,5 -1,5 -2,5 -3,5 -4,4 -4,4 -3,3 -3,3 -2,4 -2,4 -1)),((2 -3,3 -3,3 -4,4 -4,4 -5,3 -5,2 -5,1 -5,1 -4,2 -4,2 -3)))"));
+       rtdealloc(wkt);
+       lwmpoly_free(mpoly);
+       mpoly = NULL;
+
        deepRelease(rast);
 }