Commit aad8424d authored by Darafei Praliaskouski's avatar Darafei Praliaskouski

[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/trunk@16946 b70326c6-7e19-0410-871a-916f4a2858ee
parent 482716f7
Pipeline #34169085 passed with stage
in 32 minutes and 9 seconds
......@@ -177,6 +177,7 @@ postgis/uninstall_sfcgal.sql
*.pdf
.idea/*
.syntastic_c_config
.vs/*
# LLVM JIT
*.bc
......
......@@ -26,6 +26,7 @@ PostGIS 3.0.0
- #4211, Fix ST_Subdivide for minimal exterior ring with minimal hole (Darafei
Praliaskouski)
- #3457, Fix raster envelope shortcut in ST_Clip (Sai-bot)
- #4215, Use floating point compare in ST_DumpAsPolygons (Darafei Praliaskouski)
PostGIS 2.5.0
2018/09/23
......
......@@ -1396,14 +1396,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"
CC="$CC_SAVE"
......@@ -1413,8 +1405,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=<path to gdal-config>])
......
......@@ -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
......
......@@ -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
......
......@@ -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");
......
......@@ -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))");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment