From: Darafei Praliaskouski Date: Wed, 24 Oct 2018 14:04:14 +0000 (+0000) Subject: [raster] Use GDALFPolygonize unconditionally X-Git-Tag: 2.4.6~17 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7e42bb8fb0de26a3bab058d2ec39ef9e9397c167;p=postgis [raster] Use GDALFPolygonize unconditionally GDAL 1.10 is already required and 1.9 contains it, so no check needed. Closes #4215 git-svn-id: http://svn.osgeo.org/postgis/branches/2.4@16948 b70326c6-7e19-0410-871a-916f4a2858ee --- diff --git a/.gitignore b/.gitignore index 3608c9cd1..f06f1bef2 100644 --- a/.gitignore +++ b/.gitignore @@ -167,6 +167,7 @@ postgis/uninstall_sfcgal.sql *.pdf .idea/* .syntastic_c_config +.vs/* # LLVM JIT *.bc diff --git a/NEWS b/NEWS index 9e5703709..5405e94e2 100644 --- a/NEWS +++ b/NEWS @@ -11,6 +11,7 @@ PostGIS 2.4.6 - #4020, Fix leftovers in topology upgrade from 2.1 (Sandro Santilli) - #4206, Fix support for PostgreSQL 12 dev branch (Laurenz Albe) - #3457, Fix raster envelope shortcut in ST_Clip (Sai-bot) + - #4215, Use floating point compare in ST_DumpAsPolygons (Darafei Praliaskouski) PostGIS 2.4.5 diff --git a/configure.ac b/configure.ac index 8b2f71311..da15498d3 100644 --- a/configure.ac +++ b/configure.ac @@ -1357,14 +1357,6 @@ if test "x$with_raster" != "xno"; then AC_SEARCH_LIBS([OGRRegisterAll], [gdal], [], [AC_MSG_ERROR([could not find OGR])], []) LIBS="$LIBGDAL_LDFLAGS" - - dnl Check if the new polygonize function is present - AC_SEARCH_LIBS( - [GDALFPolygonize], - [gdal], - [AC_DEFINE_UNQUOTED([GDALFPOLYGONIZE], [1], [Define to 1 if GDALFPolygonize function is available])], - []) - CPPFLAGS="$CPPFLAGS_SAVE" CFLAGS="$CFLAGS_SAVE" LIBS="$LIBS_SAVE" @@ -1373,8 +1365,6 @@ if test "x$with_raster" != "xno"; then AC_SUBST([LIBGDAL_LDFLAGS]) AC_SUBST([LIBGDAL_DEPLIBS_LDFLAGS]) - AC_SUBST([GDALFPOLYGONIZE]) - else AC_MSG_RESULT([not found]) AC_MSG_ERROR([gdal-config not found. Use --without-raster or try --with-gdalconfig=]) diff --git a/postgis_config.h.in b/postgis_config.h.in index 6ba1eb6be..a84f482dc 100644 --- a/postgis_config.h.in +++ b/postgis_config.h.in @@ -14,9 +14,6 @@ language is requested. */ #undef ENABLE_NLS -/* Define to 1 if GDALFPolygonize function is available */ -#undef GDALFPOLYGONIZE - /* Define to 1 if you have the MacOS X function CFLocaleCopyCurrent in the CoreFoundation framework. */ #undef HAVE_CFLOCALECOPYCURRENT diff --git a/raster/raster_config.h.in b/raster/raster_config.h.in index a4bfdf1c4..91d8d08e2 100644 --- a/raster/raster_config.h.in +++ b/raster/raster_config.h.in @@ -24,9 +24,6 @@ /* GDAL library version */ #undef POSTGIS_GDAL_VERSION -/* Define to 1 if GDAL has GDALFPolygonize function. */ -#undef GDALFPOLYGONIZE - /* Enable development variable */ #undef ENABLE_DEVELOPMENT diff --git a/raster/rt_core/rt_geometry.c b/raster/rt_core/rt_geometry.c index 3db311d6d..e300952fe 100644 --- a/raster/rt_core/rt_geometry.c +++ b/raster/rt_core/rt_geometry.c @@ -1106,14 +1106,8 @@ rt_raster_gdal_polygonize( return NULL; } - /** - * We don't need a raster mask band. Each band has a nodata value. - **/ -#ifdef GDALFPOLYGONIZE + /* We don't need a raster mask band. Each band has a nodata value. */ cplerr = GDALFPolygonize(gdal_band, NULL, hLayer, iPixVal, NULL, NULL, NULL); -#else - cplerr = GDALPolygonize(gdal_band, NULL, hLayer, iPixVal, NULL, NULL, NULL); -#endif if (cplerr != CE_None) { rterror("rt_raster_gdal_polygonize: Could not polygonize GDAL band"); diff --git a/raster/test/cunit/cu_gdal.c b/raster/test/cunit/cu_gdal.c index c4ebbe227..bfc22a29a 100644 --- a/raster/test/cunit/cu_gdal.c +++ b/raster/test/cunit/cu_gdal.c @@ -172,11 +172,7 @@ static void test_gdal_polygonize() { nPols = 0; gv = rt_raster_gdal_polygonize(rt, 0, TRUE, &nPols); -#ifdef GDALFPOLYGONIZE CU_ASSERT_DOUBLE_EQUAL(gv[0].val, 1.8, FLT_EPSILON); -#else - CU_ASSERT_DOUBLE_EQUAL(gv[0].val, 2.0, 1.); -#endif wkt = lwgeom_to_text((const LWGEOM *) gv[0].geom); CU_ASSERT_STRING_EQUAL(wkt, "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))"); @@ -187,11 +183,7 @@ static void test_gdal_polygonize() { CU_ASSERT_STRING_EQUAL(wkt, "POLYGON((3 3,3 6,6 6,6 3,3 3))"); rtdealloc(wkt); -#ifdef GDALFPOLYGONIZE CU_ASSERT_DOUBLE_EQUAL(gv[2].val, 2.8, FLT_EPSILON); -#else - CU_ASSERT_DOUBLE_EQUAL(gv[2].val, 3.0, 1.); -#endif wkt = lwgeom_to_text((const LWGEOM *) gv[2].geom); CU_ASSERT_STRING_EQUAL(wkt, "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))"); @@ -207,11 +199,7 @@ static void test_gdal_polygonize() { cu_free_raster(rt); /* Second test: NODATA value = 1.8 */ -#ifdef GDALFPOLYGONIZE rt = fillRasterToPolygonize(1, 1.8); -#else - rt = fillRasterToPolygonize(1, 2.0); -#endif /* We can check rt_raster_has_band here too */ CU_ASSERT(rt_raster_has_band(rt, 0)); @@ -227,7 +215,6 @@ static void test_gdal_polygonize() { } */ -#ifdef GDALFPOLYGONIZE CU_ASSERT_DOUBLE_EQUAL(gv[1].val, 0.0, FLT_EPSILON); wkt = lwgeom_to_text((const LWGEOM *) gv[1].geom); CU_ASSERT_STRING_EQUAL(wkt, "POLYGON((3 3,3 6,6 6,6 3,3 3))"); @@ -242,33 +229,13 @@ static void test_gdal_polygonize() { wkt = lwgeom_to_text((const LWGEOM *) gv[3].geom); CU_ASSERT_STRING_EQUAL(wkt, "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))"); rtdealloc(wkt); -#else - CU_ASSERT_DOUBLE_EQUAL(gv[0].val, 0.0, 1.); - wkt = lwgeom_to_text((const LWGEOM *) gv[0].geom); - CU_ASSERT_STRING_EQUAL(wkt, "POLYGON((3 3,3 6,6 6,6 3,3 3))"); - rtdealloc(wkt); - - CU_ASSERT_DOUBLE_EQUAL(gv[1].val, 3.0, 1.); - wkt = lwgeom_to_text((const LWGEOM *) gv[1].geom); - CU_ASSERT_STRING_EQUAL(wkt, "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))"); - rtdealloc(wkt); - - CU_ASSERT_DOUBLE_EQUAL(gv[2].val, 0.0, 1.); - wkt = lwgeom_to_text((const LWGEOM *) gv[2].geom); - CU_ASSERT_STRING_EQUAL(wkt, "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))"); - rtdealloc(wkt); -#endif for (i = 0; i < nPols; i++) lwgeom_free((LWGEOM *) gv[i].geom); rtdealloc(gv); cu_free_raster(rt); /* Third test: NODATA value = 2.8 */ -#ifdef GDALFPOLYGONIZE rt = fillRasterToPolygonize(1, 2.8); -#else - rt = fillRasterToPolygonize(1, 3.0); -#endif /* We can check rt_raster_has_band here too */ CU_ASSERT(rt_raster_has_band(rt, 0)); @@ -284,21 +251,12 @@ static void test_gdal_polygonize() { } */ -#ifdef GDALFPOLYGONIZE CU_ASSERT_DOUBLE_EQUAL(gv[0].val, 1.8, FLT_EPSILON); CU_ASSERT_DOUBLE_EQUAL(gv[3].val, 0.0, FLT_EPSILON); wkt = lwgeom_to_text((const LWGEOM *) gv[3].geom); CU_ASSERT_STRING_EQUAL(wkt, "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))"); rtdealloc(wkt); -#else - CU_ASSERT_DOUBLE_EQUAL(gv[0].val, 2.0, 1.); - - CU_ASSERT_DOUBLE_EQUAL(gv[2].val, 0.0, 1.); - wkt = lwgeom_to_text((const LWGEOM *) gv[2].geom); - CU_ASSERT_STRING_EQUAL(wkt, "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))"); - rtdealloc(wkt); -#endif wkt = lwgeom_to_text((const LWGEOM *) gv[0].geom); CU_ASSERT_STRING_EQUAL(wkt, "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))"); @@ -329,21 +287,13 @@ static void test_gdal_polygonize() { } */ -#ifdef GDALFPOLYGONIZE CU_ASSERT_DOUBLE_EQUAL(gv[0].val, 1.8, FLT_EPSILON); -#else - CU_ASSERT_DOUBLE_EQUAL(gv[0].val, 2.0, 1.); -#endif wkt = lwgeom_to_text((const LWGEOM *) gv[0].geom); CU_ASSERT_STRING_EQUAL(wkt, "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))"); rtdealloc(wkt); -#ifdef GDALFPOLYGONIZE CU_ASSERT_DOUBLE_EQUAL(gv[1].val, 2.8, FLT_EPSILON); -#else - CU_ASSERT_DOUBLE_EQUAL(gv[1].val, 3.0, 1.); -#endif wkt = lwgeom_to_text((const LWGEOM *) gv[1].geom); CU_ASSERT_STRING_EQUAL(wkt, "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))"); @@ -369,11 +319,7 @@ static void test_gdal_polygonize() { } */ -#ifdef GDALFPOLYGONIZE CU_ASSERT_DOUBLE_EQUAL(gv[0].val, 1.8, FLT_EPSILON); -#else - CU_ASSERT_DOUBLE_EQUAL(gv[0].val, 2.0, 1.); -#endif wkt = lwgeom_to_text((const LWGEOM *) gv[0].geom); CU_ASSERT_STRING_EQUAL(wkt, "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))"); @@ -384,11 +330,7 @@ static void test_gdal_polygonize() { CU_ASSERT_STRING_EQUAL(wkt, "POLYGON((3 3,3 6,6 6,6 3,3 3))"); rtdealloc(wkt); -#ifdef GDALFPOLYGONIZE CU_ASSERT_DOUBLE_EQUAL(gv[2].val, 2.8, FLT_EPSILON); -#else - CU_ASSERT_DOUBLE_EQUAL(gv[2].val, 3.0, 1.); -#endif wkt = lwgeom_to_text((const LWGEOM *) gv[2].geom); CU_ASSERT_STRING_EQUAL(wkt, "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))");