Skip to content

Commit aad8424

Browse files
committed
[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
1 parent 482716f commit aad8424

File tree

7 files changed

+3
-81
lines changed

7 files changed

+3
-81
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@ postgis/uninstall_sfcgal.sql
177177
*.pdf
178178
.idea/*
179179
.syntastic_c_config
180+
.vs/*
180181

181182
# LLVM JIT
182183
*.bc

NEWS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ PostGIS 3.0.0
2626
- #4211, Fix ST_Subdivide for minimal exterior ring with minimal hole (Darafei
2727
Praliaskouski)
2828
- #3457, Fix raster envelope shortcut in ST_Clip (Sai-bot)
29+
- #4215, Use floating point compare in ST_DumpAsPolygons (Darafei Praliaskouski)
2930

3031
PostGIS 2.5.0
3132
2018/09/23

configure.ac

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1396,14 +1396,6 @@ if test "x$with_raster" != "xno"; then
13961396
AC_SEARCH_LIBS([OGRRegisterAll], [gdal], [], [AC_MSG_ERROR([could not find OGR])], [])
13971397

13981398
LIBS="$LIBGDAL_LDFLAGS"
1399-
1400-
dnl Check if the new polygonize function is present
1401-
AC_SEARCH_LIBS(
1402-
[GDALFPolygonize],
1403-
[gdal],
1404-
[AC_DEFINE_UNQUOTED([GDALFPOLYGONIZE], [1], [Define to 1 if GDALFPolygonize function is available])],
1405-
[])
1406-
14071399
CPPFLAGS="$CPPFLAGS_SAVE"
14081400
CFLAGS="$CFLAGS_SAVE"
14091401
CC="$CC_SAVE"
@@ -1413,8 +1405,6 @@ if test "x$with_raster" != "xno"; then
14131405
AC_SUBST([LIBGDAL_LDFLAGS])
14141406
AC_SUBST([LIBGDAL_DEPLIBS_LDFLAGS])
14151407

1416-
AC_SUBST([GDALFPOLYGONIZE])
1417-
14181408
else
14191409
AC_MSG_RESULT([not found])
14201410
AC_MSG_ERROR([gdal-config not found. Use --without-raster or try --with-gdalconfig=<path to gdal-config>])

postgis_config.h.in

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@
1414
language is requested. */
1515
#undef ENABLE_NLS
1616

17-
/* Define to 1 if GDALFPolygonize function is available */
18-
#undef GDALFPOLYGONIZE
19-
2017
/* Define to 1 if you have the MacOS X function CFLocaleCopyCurrent in the
2118
CoreFoundation framework. */
2219
#undef HAVE_CFLOCALECOPYCURRENT

raster/raster_config.h.in

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,6 @@
2424
/* GDAL library version */
2525
#undef POSTGIS_GDAL_VERSION
2626

27-
/* Define to 1 if GDAL has GDALFPolygonize function. */
28-
#undef GDALFPOLYGONIZE
29-
3027
/* Enable development variable */
3128
#undef ENABLE_DEVELOPMENT
3229

raster/rt_core/rt_geometry.c

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1106,14 +1106,8 @@ rt_raster_gdal_polygonize(
11061106
return NULL;
11071107
}
11081108

1109-
/**
1110-
* We don't need a raster mask band. Each band has a nodata value.
1111-
**/
1112-
#ifdef GDALFPOLYGONIZE
1109+
/* We don't need a raster mask band. Each band has a nodata value. */
11131110
cplerr = GDALFPolygonize(gdal_band, NULL, hLayer, iPixVal, NULL, NULL, NULL);
1114-
#else
1115-
cplerr = GDALPolygonize(gdal_band, NULL, hLayer, iPixVal, NULL, NULL, NULL);
1116-
#endif
11171111

11181112
if (cplerr != CE_None) {
11191113
rterror("rt_raster_gdal_polygonize: Could not polygonize GDAL band");

raster/test/cunit/cu_gdal.c

Lines changed: 0 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -172,11 +172,7 @@ static void test_gdal_polygonize() {
172172
nPols = 0;
173173
gv = rt_raster_gdal_polygonize(rt, 0, TRUE, &nPols);
174174

175-
#ifdef GDALFPOLYGONIZE
176175
CU_ASSERT_DOUBLE_EQUAL(gv[0].val, 1.8, FLT_EPSILON);
177-
#else
178-
CU_ASSERT_DOUBLE_EQUAL(gv[0].val, 2.0, 1.);
179-
#endif
180176

181177
wkt = lwgeom_to_text((const LWGEOM *) gv[0].geom);
182178
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() {
187183
CU_ASSERT_STRING_EQUAL(wkt, "POLYGON((3 3,3 6,6 6,6 3,3 3))");
188184
rtdealloc(wkt);
189185

190-
#ifdef GDALFPOLYGONIZE
191186
CU_ASSERT_DOUBLE_EQUAL(gv[2].val, 2.8, FLT_EPSILON);
192-
#else
193-
CU_ASSERT_DOUBLE_EQUAL(gv[2].val, 3.0, 1.);
194-
#endif
195187

196188
wkt = lwgeom_to_text((const LWGEOM *) gv[2].geom);
197189
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() {
207199
cu_free_raster(rt);
208200

209201
/* Second test: NODATA value = 1.8 */
210-
#ifdef GDALFPOLYGONIZE
211202
rt = fillRasterToPolygonize(1, 1.8);
212-
#else
213-
rt = fillRasterToPolygonize(1, 2.0);
214-
#endif
215203

216204
/* We can check rt_raster_has_band here too */
217205
CU_ASSERT(rt_raster_has_band(rt, 0));
@@ -227,7 +215,6 @@ static void test_gdal_polygonize() {
227215
}
228216
*/
229217

230-
#ifdef GDALFPOLYGONIZE
231218
CU_ASSERT_DOUBLE_EQUAL(gv[1].val, 0.0, FLT_EPSILON);
232219
wkt = lwgeom_to_text((const LWGEOM *) gv[1].geom);
233220
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() {
242229
wkt = lwgeom_to_text((const LWGEOM *) gv[3].geom);
243230
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))");
244231
rtdealloc(wkt);
245-
#else
246-
CU_ASSERT_DOUBLE_EQUAL(gv[0].val, 0.0, 1.);
247-
wkt = lwgeom_to_text((const LWGEOM *) gv[0].geom);
248-
CU_ASSERT_STRING_EQUAL(wkt, "POLYGON((3 3,3 6,6 6,6 3,3 3))");
249-
rtdealloc(wkt);
250-
251-
CU_ASSERT_DOUBLE_EQUAL(gv[1].val, 3.0, 1.);
252-
wkt = lwgeom_to_text((const LWGEOM *) gv[1].geom);
253-
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))");
254-
rtdealloc(wkt);
255-
256-
CU_ASSERT_DOUBLE_EQUAL(gv[2].val, 0.0, 1.);
257-
wkt = lwgeom_to_text((const LWGEOM *) gv[2].geom);
258-
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))");
259-
rtdealloc(wkt);
260-
#endif
261232

262233
for (i = 0; i < nPols; i++) lwgeom_free((LWGEOM *) gv[i].geom);
263234
rtdealloc(gv);
264235
cu_free_raster(rt);
265236

266237
/* Third test: NODATA value = 2.8 */
267-
#ifdef GDALFPOLYGONIZE
268238
rt = fillRasterToPolygonize(1, 2.8);
269-
#else
270-
rt = fillRasterToPolygonize(1, 3.0);
271-
#endif
272239

273240
/* We can check rt_raster_has_band here too */
274241
CU_ASSERT(rt_raster_has_band(rt, 0));
@@ -284,21 +251,12 @@ static void test_gdal_polygonize() {
284251
}
285252
*/
286253

287-
#ifdef GDALFPOLYGONIZE
288254
CU_ASSERT_DOUBLE_EQUAL(gv[0].val, 1.8, FLT_EPSILON);
289255

290256
CU_ASSERT_DOUBLE_EQUAL(gv[3].val, 0.0, FLT_EPSILON);
291257
wkt = lwgeom_to_text((const LWGEOM *) gv[3].geom);
292258
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))");
293259
rtdealloc(wkt);
294-
#else
295-
CU_ASSERT_DOUBLE_EQUAL(gv[0].val, 2.0, 1.);
296-
297-
CU_ASSERT_DOUBLE_EQUAL(gv[2].val, 0.0, 1.);
298-
wkt = lwgeom_to_text((const LWGEOM *) gv[2].geom);
299-
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))");
300-
rtdealloc(wkt);
301-
#endif
302260

303261
wkt = lwgeom_to_text((const LWGEOM *) gv[0].geom);
304262
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() {
329287
}
330288
*/
331289

332-
#ifdef GDALFPOLYGONIZE
333290
CU_ASSERT_DOUBLE_EQUAL(gv[0].val, 1.8, FLT_EPSILON);
334-
#else
335-
CU_ASSERT_DOUBLE_EQUAL(gv[0].val, 2.0, 1.);
336-
#endif
337291

338292
wkt = lwgeom_to_text((const LWGEOM *) gv[0].geom);
339293
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))");
340294
rtdealloc(wkt);
341295

342-
#ifdef GDALFPOLYGONIZE
343296
CU_ASSERT_DOUBLE_EQUAL(gv[1].val, 2.8, FLT_EPSILON);
344-
#else
345-
CU_ASSERT_DOUBLE_EQUAL(gv[1].val, 3.0, 1.);
346-
#endif
347297

348298
wkt = lwgeom_to_text((const LWGEOM *) gv[1].geom);
349299
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() {
369319
}
370320
*/
371321

372-
#ifdef GDALFPOLYGONIZE
373322
CU_ASSERT_DOUBLE_EQUAL(gv[0].val, 1.8, FLT_EPSILON);
374-
#else
375-
CU_ASSERT_DOUBLE_EQUAL(gv[0].val, 2.0, 1.);
376-
#endif
377323

378324
wkt = lwgeom_to_text((const LWGEOM *) gv[0].geom);
379325
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() {
384330
CU_ASSERT_STRING_EQUAL(wkt, "POLYGON((3 3,3 6,6 6,6 3,3 3))");
385331
rtdealloc(wkt);
386332

387-
#ifdef GDALFPOLYGONIZE
388333
CU_ASSERT_DOUBLE_EQUAL(gv[2].val, 2.8, FLT_EPSILON);
389-
#else
390-
CU_ASSERT_DOUBLE_EQUAL(gv[2].val, 3.0, 1.);
391-
#endif
392334

393335
wkt = lwgeom_to_text((const LWGEOM *) gv[2].geom);
394336
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))");

0 commit comments

Comments
 (0)