]> granicus.if.org Git - postgis/commitdiff
Fixed ticket #650. You need to update your GDAL copy to a release up to 22476 to...
authorJorge Arévalo <jorge.arevalo at deimos-space.com>
Wed, 1 Jun 2011 23:50:14 +0000 (23:50 +0000)
committerJorge Arévalo <jorge.arevalo at deimos-space.com>
Wed, 1 Jun 2011 23:50:14 +0000 (23:50 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@7308 b70326c6-7e19-0410-871a-916f4a2858ee

raster/rt_core/Makefile.in
raster/rt_core/rt_api.c
raster/test/core/testapi.c

index d2c4d60074f8428b75b7ccb79e4e0975fdf14da1..02fd7554585965c04f17eaea182d4a8762f132fa 100644 (file)
@@ -7,7 +7,7 @@
 # the terms of the GNU General Public Licence. See the COPYING file.
 #
 #############################################################################
+
 AR=ar rs
 
 CC=@CC@
@@ -16,10 +16,10 @@ LIBLWGEOM_CFLAGS=@LIBLWGEOM_CFLAGS@
 LIBGDAL_CFLAGS=@LIBGDAL_CFLAGS@
 LIBGDAL_LDFLAGS=@LIBGDAL_LDFLAGS@
 LDFLAGS=$(LIBLWGEOM_LDFLAGS) $(LIBGDAL_LDFLAGS)
-CFLAGS=@CFLAGS@ @PICFLAGS@ @WARNFLAGS@ $(LIBLWGEOM_CFLAGS) $(LIBGDAL_CFLAGS) 
+CFLAGS=@CFLAGS@ @PICFLAGS@ @WARNFLAGS@ $(LIBLWGEOM_CFLAGS) $(LIBGDAL_CFLAGS)
 
 # Standalone RTCORE objects
-RT_OBJS=rt_api.o 
+RT_OBJS=rt_api.o
 RT_LIB=librtcore.a
 RT_HEADERS=rt_api.h
 
@@ -27,7 +27,7 @@ all: $(RT_LIB)
 
 clean:
        $(RM) $(RT_OBJS)
-       $(RM) $(RT_LIB) 
+       $(RM) $(RT_LIB)
 
 distclean: clean
        $(RM) Makefile
index 43fdb8e2c78a00a99995ae7c9f54773b73d743fb..eac1cf42f15e9d8537fc27617c267e2f6a9e11f9 100644 (file)
@@ -3253,10 +3253,9 @@ struct rt_geomval_t {
 };
 
 rt_geomval
-rt_raster_dump_as_wktpolygons(rt_raster raster, int nband,
-        int * pnElements) {
-
-       char * pszQuery;
+rt_raster_dump_as_wktpolygons(rt_raster raster, int nband, int * pnElements)
+{
+    char * pszQuery;
     char * pszDataPointer;
     char szGdalOption[50];
     long j;
@@ -3502,7 +3501,7 @@ rt_raster_dump_as_wktpolygons(rt_raster raster, int nband,
      */
 
     /* First, create a field definition to create the field */
-    hFldDfn = OGR_Fld_Create("PixelValue", OFTInteger);
+    hFldDfn = OGR_Fld_Create("PixelValue", OFTReal);
 
     /* Second, create the field */
     if (OGR_L_CreateField(hLayer, hFldDfn, TRUE) !=
@@ -3543,7 +3542,7 @@ rt_raster_dump_as_wktpolygons(rt_raster raster, int nband,
     /**
      * We don't need a raster mask band. Each band has a nodata value.
      **/
-    GDALPolygonize(gdal_band, NULL, hLayer, iPixVal, NULL, NULL, NULL);
+    GDALFPolygonize(gdal_band, NULL, hLayer, iPixVal, NULL, NULL, NULL);
 
     /**
      * Optimization: Apply a OGR SQL filter to the layer to select the
@@ -3552,18 +3551,17 @@ rt_raster_dump_as_wktpolygons(rt_raster raster, int nband,
      * Thanks to David Zwarg.
      **/
     if (iBandHasNodataValue) {
-            pszQuery = (char *) rtalloc(50 * sizeof (char));
-            sprintf(pszQuery, "PixelValue != %f", dBandNoData );
-            OGRErr e = OGR_L_SetAttributeFilter(hLayer, pszQuery);
-            if (e != OGRERR_NONE) {
-                    rtwarn("Error filtering NODATA values for band. All values"
-                            " will be treated as data values");
-            }
-
+        pszQuery = (char *) rtalloc(50 * sizeof (char));
+        sprintf(pszQuery, "PixelValue != %f", dBandNoData );
+        OGRErr e = OGR_L_SetAttributeFilter(hLayer, pszQuery);
+        if (e != OGRERR_NONE) {
+                rtwarn("Error filtering NODATA values for band. All values"
+                        " will be treated as data values");
+        }
     }
 
     else {
-            pszQuery = NULL;
+        pszQuery = NULL;
     }
 
 
@@ -3607,7 +3605,7 @@ rt_raster_dump_as_wktpolygons(rt_raster raster, int nband,
         hFeature = OGR_L_GetNextFeature(hLayer);
         dValue = OGR_F_GetFieldAsDouble(hFeature, iPixVal);
 
-               hGeom = OGR_F_GetGeometryRef(hFeature);
+       hGeom = OGR_F_GetGeometryRef(hFeature);
        OGR_G_ExportToWkt(hGeom, &pszSrcText);
 
        pols[j].val = dValue;
@@ -3658,8 +3656,6 @@ rt_raster_get_convex_hull(rt_raster raster) {
     LWPOLY* ret = NULL;
     POINT4D p4d;
 
-
-
     assert(NULL != raster);
 
     RASTER_DEBUGF(3, "rt_raster_get_convex_hull: raster is %dx%d",
index 854eef7fd117c34e5ea834f6fb8629262afa4121..6e758f50602ed2e0d176b4944e066203600ab29c 100644 (file)
@@ -82,43 +82,44 @@ fillRasterToPolygonize(int hasnodata, double nodatavalue)
 
 
     /* Fill raster. Option 2: 9x9, 1 band */
-    rt_band band = addBand(raster, PT_32BUI, hasnodata, nodatavalue);
+    rt_band band = addBand(raster, PT_32BF, hasnodata, nodatavalue);
 
     {
         int x, y;
         for (x = 0; x < rt_band_get_width(band); ++x)
-             for (y = 0; y < rt_band_get_height(band); ++y)
-                       rt_band_set_pixel(band, x, y, 0);
-       }
+            for (y = 0; y < rt_band_get_height(band); ++y)
+                rt_band_set_pixel(band, x, y, 0.0);
+    }
+    
     /**/
-    rt_band_set_pixel(band, 3, 1, 1);
-    rt_band_set_pixel(band, 4, 1, 1);
-    rt_band_set_pixel(band, 5, 1, 2);
-    rt_band_set_pixel(band, 2, 2, 1);
-    rt_band_set_pixel(band, 3, 2, 1);
-    rt_band_set_pixel(band, 4, 2, 1);
-    rt_band_set_pixel(band, 5, 2, 2);
-    rt_band_set_pixel(band, 6, 2, 2);
-    rt_band_set_pixel(band, 1, 3, 1);
-    rt_band_set_pixel(band, 2, 3, 1);
-    rt_band_set_pixel(band, 6, 3, 2);
-    rt_band_set_pixel(band, 7, 3, 2);
-    rt_band_set_pixel(band, 1, 4, 1);
-    rt_band_set_pixel(band, 2, 4, 1);
-    rt_band_set_pixel(band, 6, 4, 2);
-    rt_band_set_pixel(band, 7, 4, 2);
-    rt_band_set_pixel(band, 1, 5, 1);
-    rt_band_set_pixel(band, 2, 5, 1);
-    rt_band_set_pixel(band, 6, 5, 2);
-    rt_band_set_pixel(band, 7, 5, 2);
-    rt_band_set_pixel(band, 2, 6, 1);
-    rt_band_set_pixel(band, 3, 6, 1);
-    rt_band_set_pixel(band, 4, 6, 1);
-    rt_band_set_pixel(band, 5, 6, 2);
-    rt_band_set_pixel(band, 6, 6, 2);
-    rt_band_set_pixel(band, 3, 7, 1);
-    rt_band_set_pixel(band, 4, 7, 1);
-    rt_band_set_pixel(band, 5, 7, 2);
+    rt_band_set_pixel(band, 3, 1, 1.5);
+    rt_band_set_pixel(band, 4, 1, 1.5);
+    rt_band_set_pixel(band, 5, 1, 2.5);
+    rt_band_set_pixel(band, 2, 2, 1.5);
+    rt_band_set_pixel(band, 3, 2, 1.5);
+    rt_band_set_pixel(band, 4, 2, 1.5);
+    rt_band_set_pixel(band, 5, 2, 2.5);
+    rt_band_set_pixel(band, 6, 2, 2.5);
+    rt_band_set_pixel(band, 1, 3, 1.5);
+    rt_band_set_pixel(band, 2, 3, 1.5);
+    rt_band_set_pixel(band, 6, 3, 2.5);
+    rt_band_set_pixel(band, 7, 3, 2.5);
+    rt_band_set_pixel(band, 1, 4, 1.5);
+    rt_band_set_pixel(band, 2, 4, 1.5);
+    rt_band_set_pixel(band, 6, 4, 2.5);
+    rt_band_set_pixel(band, 7, 4, 2.5);
+    rt_band_set_pixel(band, 1, 5, 1.5);
+    rt_band_set_pixel(band, 2, 5, 1.5);
+    rt_band_set_pixel(band, 6, 5, 2.5);
+    rt_band_set_pixel(band, 7, 5, 2.5);
+    rt_band_set_pixel(band, 2, 6, 1.5);
+    rt_band_set_pixel(band, 3, 6, 1.5);
+    rt_band_set_pixel(band, 4, 6, 1.5);
+    rt_band_set_pixel(band, 5, 6, 2.5);
+    rt_band_set_pixel(band, 6, 6, 2.5);
+    rt_band_set_pixel(band, 3, 7, 1.5);
+    rt_band_set_pixel(band, 4, 7, 1.5);
+    rt_band_set_pixel(band, 5, 7, 2.5);
 
 
 
@@ -1506,11 +1507,11 @@ main()
     {   /* Check ST_AsPolygon */
         printf("Testing polygonize function\n");
 
-               /* First test: NODATA value = -1 */
+       /* First test: NODATA value = -1 */
         rt_raster rt = fillRasterToPolygonize(1, -1.0);
 
-               /* We can check rt_raster_has_no_band here too */
-               CHECK(!rt_raster_has_no_band(rt, 1));
+       /* We can check rt_raster_has_no_band here too */
+       CHECK(!rt_raster_has_no_band(rt, 1));
 
         /**
          * Need to define again, to access the struct fields
@@ -1526,104 +1527,104 @@ main()
 
         rt_geomval gv = (rt_geomval) rt_raster_dump_as_wktpolygons(rt, 1, &nPols);
 
-        CHECK_EQUALS_DOUBLE(gv[0].val, 1.0);
+        CHECK_EQUALS_DOUBLE(gv[0].val, 1.5);
         CHECK(!strcmp(gv[0].geom, "POLYGON ((3 1,3 2,2 2,2 3,1 3,1 6,2 6,2 7,3 7,3 8,5 8,5 6,3 6,3 3,4 3,5 3,5 1,3 1))"));
 
-               CHECK_EQUALS_DOUBLE(gv[1].val, 0.0);
-               CHECK(!strcmp(gv[1].geom, "POLYGON ((3 3,3 6,6 6,6 3,3 3))"));
+       CHECK_EQUALS_DOUBLE(gv[1].val, 0.0);
+       CHECK(!strcmp(gv[1].geom, "POLYGON ((3 3,3 6,6 6,6 3,3 3))"));
 
-        CHECK_EQUALS_DOUBLE(gv[2].val, 2.0);
+        CHECK_EQUALS_DOUBLE(gv[2].val, 2.5);
         CHECK(!strcmp(gv[2].geom, "POLYGON ((5 1,5 3,6 3,6 6,5 6,5 8,6 8,6 7,7 7,7 6,8 6,8 3,7 3,7 2,6 2,6 1,5 1))"));
 
-               CHECK_EQUALS_DOUBLE(gv[3].val, 0.0);
-               CHECK(!strcmp(gv[3].geom, "POLYGON ((0 0,0 9,9 9,9 0,0 0),(6 7,6 8,3 8,3 7,2 7,2 6,1 6,1 3,2 3,2 2,3 2,3 1,6 1,6 2,7 2,7 3,8 3,8 6,7 6,7 7,6 7))"));
+       CHECK_EQUALS_DOUBLE(gv[3].val, 0.0);
+       CHECK(!strcmp(gv[3].geom, "POLYGON ((0 0,0 9,9 9,9 0,0 0),(6 7,6 8,3 8,3 7,2 7,2 6,1 6,1 3,2 3,2 2,3 2,3 1,6 1,6 2,7 2,7 3,8 3,8 6,7 6,7 7,6 7))"));
 
 
         rt_raster_destroy(rt);
 
 
-               /* Second test: NODATA value = 1 */
-        rt = fillRasterToPolygonize(1, 1.0);
+       /* Second test: NODATA value = 1.5 */
+        rt = fillRasterToPolygonize(1, 1.5);
 
-               /* We can check rt_raster_has_no_band here too */
-               CHECK(!rt_raster_has_no_band(rt, 1));
+       /* We can check rt_raster_has_no_band here too */
+       CHECK(!rt_raster_has_no_band(rt, 1));
 
         nPols = 0;
 
         gv = (rt_geomval) rt_raster_dump_as_wktpolygons(rt, 1, &nPols);
 
 
-               CHECK_EQUALS_DOUBLE(gv[0].val, 0.0);
-               CHECK(!strcmp(gv[0].geom, "POLYGON ((3 3,3 6,6 6,6 3,3 3))"));
+       CHECK_EQUALS_DOUBLE(gv[0].val, 0.0);
+       CHECK(!strcmp(gv[0].geom, "POLYGON ((3 3,3 6,6 6,6 3,3 3))"));
 
-        CHECK_EQUALS_DOUBLE(gv[1].val, 2.0);
+        CHECK_EQUALS_DOUBLE(gv[1].val, 2.5);
         CHECK(!strcmp(gv[1].geom, "POLYGON ((5 1,5 3,6 3,6 6,5 6,5 8,6 8,6 7,7 7,7 6,8 6,8 3,7 3,7 2,6 2,6 1,5 1))"));
 
-               CHECK_EQUALS_DOUBLE(gv[2].val, 0.0);
-               CHECK(!strcmp(gv[2].geom, "POLYGON ((0 0,0 9,9 9,9 0,0 0),(6 7,6 8,3 8,3 7,2 7,2 6,1 6,1 3,2 3,2 2,3 2,3 1,6 1,6 2,7 2,7 3,8 3,8 6,7 6,7 7,6 7))"));
+       CHECK_EQUALS_DOUBLE(gv[2].val, 0.0);
+       CHECK(!strcmp(gv[2].geom, "POLYGON ((0 0,0 9,9 9,9 0,0 0),(6 7,6 8,3 8,3 7,2 7,2 6,1 6,1 3,2 3,2 2,3 2,3 1,6 1,6 2,7 2,7 3,8 3,8 6,7 6,7 7,6 7))"));
         rt_raster_destroy(rt);
 
-               /* Third test: NODATA value = 2 */
-        rt = fillRasterToPolygonize(1, 2.0);
+       /* Third test: NODATA value = 2.5 */
+        rt = fillRasterToPolygonize(1, 2.5);
 
-               /* We can check rt_raster_has_no_band here too */
-               CHECK(!rt_raster_has_no_band(rt, 1));
+       /* We can check rt_raster_has_no_band here too */
+       CHECK(!rt_raster_has_no_band(rt, 1));
 
         nPols = 0;
 
         gv = (rt_geomval) rt_raster_dump_as_wktpolygons(rt, 1, &nPols);
 
-        CHECK_EQUALS_DOUBLE(gv[0].val, 1.0);
+        CHECK_EQUALS_DOUBLE(gv[0].val, 1.5);
         CHECK(!strcmp(gv[0].geom, "POLYGON ((3 1,3 2,2 2,2 3,1 3,1 6,2 6,2 7,3 7,3 8,5 8,5 6,3 6,3 3,4 3,5 3,5 1,3 1))"));
 
-               CHECK_EQUALS_DOUBLE(gv[1].val, 0.0);
-               CHECK(!strcmp(gv[1].geom, "POLYGON ((3 3,3 6,6 6,6 3,3 3))"));
+       CHECK_EQUALS_DOUBLE(gv[1].val, 0.0);
+       CHECK(!strcmp(gv[1].geom, "POLYGON ((3 3,3 6,6 6,6 3,3 3))"));
 
-               CHECK_EQUALS_DOUBLE(gv[2].val, 0.0);
-               CHECK(!strcmp(gv[2].geom, "POLYGON ((0 0,0 9,9 9,9 0,0 0),(6 7,6 8,3 8,3 7,2 7,2 6,1 6,1 3,2 3,2 2,3 2,3 1,6 1,6 2,7 2,7 3,8 3,8 6,7 6,7 7,6 7))"));
+       CHECK_EQUALS_DOUBLE(gv[2].val, 0.0);
+       CHECK(!strcmp(gv[2].geom, "POLYGON ((0 0,0 9,9 9,9 0,0 0),(6 7,6 8,3 8,3 7,2 7,2 6,1 6,1 3,2 3,2 2,3 2,3 1,6 1,6 2,7 2,7 3,8 3,8 6,7 6,7 7,6 7))"));
         rt_raster_destroy(rt);
 
 
-               /* Fourth test: NODATA value = 0 */
+       /* Fourth test: NODATA value = 0 */
         rt = fillRasterToPolygonize(1, 0.0);
 
-               /* We can check rt_raster_has_no_band here too */
-               CHECK(!rt_raster_has_no_band(rt, 1));
+        /* We can check rt_raster_has_no_band here too */
+       CHECK(!rt_raster_has_no_band(rt, 1));
 
         nPols = 0;
 
         gv = (rt_geomval) rt_raster_dump_as_wktpolygons(rt, 1, &nPols);
 
-        CHECK_EQUALS_DOUBLE(gv[0].val, 1.0);
+        CHECK_EQUALS_DOUBLE(gv[0].val, 1.5);
         CHECK(!strcmp(gv[0].geom, "POLYGON ((3 1,3 2,2 2,2 3,1 3,1 6,2 6,2 7,3 7,3 8,5 8,5 6,3 6,3 3,4 3,5 3,5 1,3 1))"));
 
-               CHECK_EQUALS_DOUBLE(gv[1].val, 2.0);
+       CHECK_EQUALS_DOUBLE(gv[1].val, 2.5);
         CHECK(!strcmp(gv[1].geom, "POLYGON ((5 1,5 3,6 3,6 6,5 6,5 8,6 8,6 7,7 7,7 6,8 6,8 3,7 3,7 2,6 2,6 1,5 1))"));
 
-               rt_raster_destroy(rt);
+       rt_raster_destroy(rt);
 
-               /* Last test: There is no NODATA value (all values are valid) */
-        rt = fillRasterToPolygonize(0, 1.0);
+        /* Last test: There is no NODATA value (all values are valid) */
+        rt = fillRasterToPolygonize(0, 0.0);
 
-               /* We can check rt_raster_has_no_band here too */
-               CHECK(!rt_raster_has_no_band(rt, 1));
+       /* We can check rt_raster_has_no_band here too */
+       CHECK(!rt_raster_has_no_band(rt, 1));
 
         nPols = 0;
 
         gv = (rt_geomval) rt_raster_dump_as_wktpolygons(rt, 1, &nPols);
 
-        CHECK_EQUALS_DOUBLE(gv[0].val, 1.0);
+        CHECK_EQUALS_DOUBLE(gv[0].val, 1.5);
         CHECK(!strcmp(gv[0].geom, "POLYGON ((3 1,3 2,2 2,2 3,1 3,1 6,2 6,2 7,3 7,3 8,5 8,5 6,3 6,3 3,4 3,5 3,5 1,3 1))"));
 
-               CHECK_EQUALS_DOUBLE(gv[1].val, 0.0);
-               CHECK(!strcmp(gv[1].geom, "POLYGON ((3 3,3 6,6 6,6 3,3 3))"));
+       CHECK_EQUALS_DOUBLE(gv[1].val, 0.0);
+       CHECK(!strcmp(gv[1].geom, "POLYGON ((3 3,3 6,6 6,6 3,3 3))"));
 
-        CHECK_EQUALS_DOUBLE(gv[2].val, 2.0);
+        CHECK_EQUALS_DOUBLE(gv[2].val, 2.5);
         CHECK(!strcmp(gv[2].geom, "POLYGON ((5 1,5 3,6 3,6 6,5 6,5 8,6 8,6 7,7 7,7 6,8 6,8 3,7 3,7 2,6 2,6 1,5 1))"));
 
-               CHECK_EQUALS_DOUBLE(gv[3].val, 0.0);
-               CHECK(!strcmp(gv[3].geom, "POLYGON ((0 0,0 9,9 9,9 0,0 0),(6 7,6 8,3 8,3 7,2 7,2 6,1 6,1 3,2 3,2 2,3 2,3 1,6 1,6 2,7 2,7 3,8 3,8 6,7 6,7 7,6 7))"));
-               rt_raster_destroy(rt);
+       CHECK_EQUALS_DOUBLE(gv[3].val, 0.0);
+       CHECK(!strcmp(gv[3].geom, "POLYGON ((0 0,0 9,9 9,9 0,0 0),(6 7,6 8,3 8,3 7,2 7,2 6,1 6,1 3,2 3,2 2,3 2,3 1,6 1,6 2,7 2,7 3,8 3,8 6,7 6,7 7,6 7))"));
+       rt_raster_destroy(rt);
 
     }