[postgis-tickets] r16946 - [raster] Use GDALFPolygonize unconditionally
Darafei
komzpa at gmail.com
Wed Oct 24 07:02:34 PDT 2018
Author: komzpa
Date: 2018-10-24 07:02:34 -0700 (Wed, 24 Oct 2018)
New Revision: 16946
Modified:
trunk/.gitignore
trunk/NEWS
trunk/configure.ac
trunk/postgis_config.h.in
trunk/raster/raster_config.h.in
trunk/raster/rt_core/rt_geometry.c
trunk/raster/test/cunit/cu_gdal.c
Log:
[raster] Use GDALFPolygonize unconditionally
GDAL 1.10 is already required and 1.9 contains it, so no check needed.
Closes #4215
Modified: trunk/.gitignore
===================================================================
--- trunk/.gitignore 2018-10-23 13:08:58 UTC (rev 16945)
+++ trunk/.gitignore 2018-10-24 14:02:34 UTC (rev 16946)
@@ -177,6 +177,7 @@
*.pdf
.idea/*
.syntastic_c_config
+.vs/*
# LLVM JIT
*.bc
Modified: trunk/NEWS
===================================================================
--- trunk/NEWS 2018-10-23 13:08:58 UTC (rev 16945)
+++ trunk/NEWS 2018-10-24 14:02:34 UTC (rev 16946)
@@ -26,6 +26,7 @@
- #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
Modified: trunk/configure.ac
===================================================================
--- trunk/configure.ac 2018-10-23 13:08:58 UTC (rev 16945)
+++ trunk/configure.ac 2018-10-24 14:02:34 UTC (rev 16946)
@@ -1396,14 +1396,6 @@
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 @@
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>])
Modified: trunk/postgis_config.h.in
===================================================================
--- trunk/postgis_config.h.in 2018-10-23 13:08:58 UTC (rev 16945)
+++ trunk/postgis_config.h.in 2018-10-24 14:02:34 UTC (rev 16946)
@@ -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
Modified: trunk/raster/raster_config.h.in
===================================================================
--- trunk/raster/raster_config.h.in 2018-10-23 13:08:58 UTC (rev 16945)
+++ trunk/raster/raster_config.h.in 2018-10-24 14:02:34 UTC (rev 16946)
@@ -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
Modified: trunk/raster/rt_core/rt_geometry.c
===================================================================
--- trunk/raster/rt_core/rt_geometry.c 2018-10-23 13:08:58 UTC (rev 16945)
+++ trunk/raster/rt_core/rt_geometry.c 2018-10-24 14:02:34 UTC (rev 16946)
@@ -1106,14 +1106,8 @@
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");
Modified: trunk/raster/test/cunit/cu_gdal.c
===================================================================
--- trunk/raster/test/cunit/cu_gdal.c 2018-10-23 13:08:58 UTC (rev 16945)
+++ trunk/raster/test/cunit/cu_gdal.c 2018-10-24 14:02:34 UTC (rev 16946)
@@ -172,11 +172,7 @@
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 @@
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 @@
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 @@
}
*/
-#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 @@
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,7 +251,6 @@
}
*/
-#ifdef GDALFPOLYGONIZE
CU_ASSERT_DOUBLE_EQUAL(gv[0].val, 1.8, FLT_EPSILON);
CU_ASSERT_DOUBLE_EQUAL(gv[3].val, 0.0, FLT_EPSILON);
@@ -291,15 +257,7 @@
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))");
rtdealloc(wkt);
@@ -329,21 +287,13 @@
}
*/
-#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 @@
}
*/
-#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 @@
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))");
More information about the postgis-tickets
mailing list