From 544a78044fb61d74ecac5683268dccbb1320bd38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C4=81ris=20Narti=C5=A1s?= Date: Sun, 7 Apr 2024 18:45:50 +0300 Subject: [PATCH] r.in.pdal: use NoFileWriter class for PDAL > 2.7.0 (fixes #3552) (#3567) * r.in.pdal: use NoFileWriter class for PDAL > 2.7.0 (fixes #3552) Starting from PDAL 2.7.0 filename is mandatory for Writer class, but there is a NoFileWriter class that maintains old behavior. https://github.com/PDAL/PDAL/pull/4342 --------- Co-authored-by: Nicklas Larsson --- configure | 41 ++++++++++++++++++---------- configure.ac | 22 ++++++++++----- include/grass/config.h.in | 3 ++ raster/r.in.pdal/grassrasterwriter.h | 5 ++++ 4 files changed, 49 insertions(+), 22 deletions(-) diff --git a/configure b/configure index bc58bfe0df2..fc8d39a7a05 100755 --- a/configure +++ b/configure @@ -10473,42 +10473,53 @@ pdal::PointTable table; _ACEOF if ac_fn_cxx_try_link "$LINENO" then : - + PDAL_LIBS="$PDAL_LIBS" else $as_nop + as_fn_error $? "*** Unable to locate suitable (>=1.7.1) PDAL library." "$LINENO" 5 + +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam \ + conftest$ac_exeext conftest.$ac_ext + + +printf "%s\n" "#define HAVE_PDAL 1" >>confdefs.h + + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether to use PDAL NoFilenameWriter" >&5 +printf %s "checking whether to use PDAL NoFilenameWriter... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ -#include - #include - class St:public pdal::Streamable {}; +#include + class St:public pdal::NoFilenameWriter {}; int main (void) { -pdal::PointTable table; + + class NFWTest : public pdal::NoFilenameWriter {}; + ; return 0; } _ACEOF if ac_fn_cxx_try_link "$LINENO" then : - PDAL_LIBS="$PDAL_LIBS" -else $as_nop - as_fn_error $? "*** Unable to locate suitable (>=1.7.1) PDAL library." "$LINENO" 5 -fi -rm -f core conftest.err conftest.$ac_objext conftest.beam \ - conftest$ac_exeext conftest.$ac_ext +printf "%s\n" "#define HAVE_PDAL_NOFILENAMEWRITER 1" >>confdefs.h + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +printf "%s\n" "yes" >&6; } +else $as_nop + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext + LIBS=${ac_save_libs} CFLAGS=${ac_save_cflags} - - -printf "%s\n" "#define HAVE_PDAL 1" >>confdefs.h - fi diff --git a/configure.ac b/configure.ac index 57af5a5923a..d7f7b578282 100644 --- a/configure.ac +++ b/configure.ac @@ -1076,17 +1076,25 @@ else CFLAGS="$CFLAGS $PDAL_CFLAGS" AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include #include - class St:public pdal::Streamable {};]], [[pdal::PointTable table;]])],[],[ - AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include - #include - class St:public pdal::Streamable {};]], [[pdal::PointTable table;]])],[PDAL_LIBS="$PDAL_LIBS"],[ + class St:public pdal::Streamable {};]], [[pdal::PointTable table;]])], + [PDAL_LIBS="$PDAL_LIBS"],[ AC_MSG_ERROR([*** Unable to locate suitable (>=1.7.1) PDAL library.]) ]) - ]) - LIBS=${ac_save_libs} - CFLAGS=${ac_save_cflags} AC_DEFINE(HAVE_PDAL, 1, [Define to 1 if PDAL exists.]) + + AC_MSG_CHECKING(whether to use PDAL NoFilenameWriter) + AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include + class St:public pdal::NoFilenameWriter {};]], [[ + class NFWTest : public pdal::NoFilenameWriter {}; + ]])], + [ + AC_DEFINE(HAVE_PDAL_NOFILENAMEWRITER, 1, [Define to 1 if PDAL NoFilenameWriter is present.]) + AC_MSG_RESULT(yes) + ],[AC_MSG_RESULT(no)]) + + LIBS=${ac_save_libs} + CFLAGS=${ac_save_cflags} fi AC_SUBST(PDAL_LIBS) diff --git a/include/grass/config.h.in b/include/grass/config.h.in index 5730328ccb5..ca90ef601c5 100644 --- a/include/grass/config.h.in +++ b/include/grass/config.h.in @@ -158,6 +158,9 @@ /* Define to 1 if PDAL exists. */ #undef HAVE_PDAL +/* Define to 1 if PDAL NoFilenameWriter is present. */ +#undef HAVE_PDAL_NOFILENAMEWRITER + /* Define to 1 if glXCreateGLXPixmap exists. */ #undef HAVE_PIXMAPS diff --git a/raster/r.in.pdal/grassrasterwriter.h b/raster/r.in.pdal/grassrasterwriter.h index f3df8ef04b1..4db8852aa8a 100644 --- a/raster/r.in.pdal/grassrasterwriter.h +++ b/raster/r.in.pdal/grassrasterwriter.h @@ -32,7 +32,12 @@ extern "C" { #include /* Binning code wrapped as a PDAL Writer class */ +#ifdef HAVE_PDAL_NOFILENAMEWRITER +class GrassRasterWriter : public pdal::NoFilenameWriter, + public pdal::Streamable { +#else class GrassRasterWriter : public pdal::Writer, public pdal::Streamable { +#endif public: GrassRasterWriter() : n_processed(0) {}