Skip to content

Commit

Permalink
Add compile-time flags to turn on OverlayNG
Browse files Browse the repository at this point in the history
In autoconf, --enable-overlayng
In cmake, use -DDISABLE_OVERLAYNG=OFF
  • Loading branch information
pramsey committed Jul 29, 2020
1 parent a375140 commit c6774a6
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 1 deletion.
11 changes: 11 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,17 @@ else()
"GEOS: DISABLING inlining of small functions")
endif()

#-----------------------------------------------------------------------------
# Target geos_cxx_flags: overlayng code
#-----------------------------------------------------------------------------
option(DISABLE_OVERLAYNG "Disable overlayng algorithms" ON)
if(NOT DISABLE_OVERLAYNG)
target_compile_definitions(geos_cxx_flags INTERFACE USE_OVERLAYNG)
else()
message(STATUS
"GEOS: DISABLING overlayng algorithms")
endif()

#-----------------------------------------------------------------------------
# Target geos_developer_cxx_flags: developer mode compilation flags
#-----------------------------------------------------------------------------
Expand Down
24 changes: 23 additions & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,26 @@ else
AC_MSG_RESULT([no])
fi


dnl --------------------------------------------------------------------
dnl - check whether user has requested overlayng
dnl --------------------------------------------------------------------

AC_ARG_ENABLE([overlayng], [ --enable-overlayng Enable use of new overlay],
[case "${enableval}" in
yes) use_overlayng=true ;;
no) use_overlayng=false ;;
*) AC_MSG_ERROR(bad value ${enableval} for --enable-overlayng) ;;
esac],
[use_overlayng=false]
)

if test x"$use_overlayng" = xtrue; then
OVERLAYNG_FLAGS="-DUSE_OVERLAYNG"
else
OVERLAYNG_FLAGS=""
fi

dnl --------------------------------------------------------------------
dnl - Append default C++ and C flags
dnl --------------------------------------------------------------------
Expand Down Expand Up @@ -183,7 +203,7 @@ NUMERICFLAGS=""
AC_LIBTOOL_COMPILER_OPTION([if $compiler supports -ffloat-store], [dummy_cv_ffloat_store], [-ffloat-store], [], [NUMERICFLAGS="$NUMERICFLAGS -ffloat-store"], [])

HUSHWARNING="-DUSE_UNSTABLE_GEOS_CPP_API"
DEFAULTFLAGS="${WARNFLAGS} ${NUMERICFLAGS} ${HUSHWARNING}"
DEFAULTFLAGS="${WARNFLAGS} ${NUMERICFLAGS} ${HUSHWARNING} ${OVERLAYNG_FLAGS}"

AM_CXXFLAGS="${AM_CXXFLAGS} ${DEFAULTFLAGS}"
AM_CFLAGS="${AM_CFLAGS} ${DEFAULTFLAGS}"
Expand Down Expand Up @@ -294,6 +314,7 @@ if test x"$use_ruby" = xtrue; then
fi
AM_CONDITIONAL(ENABLE_RUBY, [ test x"$use_ruby" = xtrue ])


dnl --------------------------------------------------------------------
dnl - do operating-system specific things
dnl --------------------------------------------------------------------
Expand Down Expand Up @@ -482,5 +503,6 @@ dnl -- echo "Boost UTF: $use_boost_utf"
echo "Swig: $use_swig"
echo "Python bindings: $use_python"
echo "Ruby bindings: $use_ruby"
echo "OverlayNG: $use_overlayng"

dnl -- echo "---------------------------------------"
22 changes: 22 additions & 0 deletions src/geom/Geometry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
#include <geos/operation/buffer/BufferOp.h>
#include <geos/operation/distance/DistanceOp.h>
#include <geos/operation/IsSimpleOp.h>
#include <geos/operation/overlayng/OverlayNGSnapIfNeeded.h>
#include <geos/io/WKBWriter.h>
#include <geos/io/WKTWriter.h>
#include <geos/version.h>
Expand Down Expand Up @@ -550,7 +551,11 @@ Geometry::intersection(const Geometry* other) const
}
#endif

#ifdef USE_OVERLAYNG
return operation::overlayng::OverlayNGSnapIfNeeded::Intersection(this, other);
#else
return BinaryOp(this, other, overlayOp(OverlayOp::opINTERSECTION));
#endif
}

std::unique_ptr<Geometry>
Expand Down Expand Up @@ -602,15 +607,23 @@ Geometry::Union(const Geometry* other) const
}
#endif

#ifdef USE_OVERLAYNG
return operation::overlayng::OverlayNGSnapIfNeeded::Union(this, other);
#else
return BinaryOp(this, other, overlayOp(OverlayOp::opUNION));
#endif
}

/* public */
Geometry::Ptr
Geometry::Union() const
{
using geos::operation::geounion::UnaryUnionOp;
#ifdef USE_OVERLAYNG
return operation::overlayng::OverlayNGSnapIfNeeded::Union(this);
#else
return UnaryUnionOp::Union(*this);
#endif
}

std::unique_ptr<Geometry>
Expand All @@ -625,7 +638,11 @@ Geometry::difference(const Geometry* other) const
return clone();
}

#ifdef USE_OVERLAYNG
return operation::overlayng::OverlayNGSnapIfNeeded::Difference(this, other);
#else
return BinaryOp(this, other, overlayOp(OverlayOp::opDIFFERENCE));
#endif
}

std::unique_ptr<Geometry>
Expand Down Expand Up @@ -673,7 +690,12 @@ Geometry::symDifference(const Geometry* other) const
return std::unique_ptr<Geometry>(_factory->buildGeometry(v));
}

#ifdef USE_OVERLAYNG
return operation::overlayng::OverlayNGSnapIfNeeded::SymDifference(this, other);
#else
return BinaryOp(this, other, overlayOp(OverlayOp::opSYMDIFFERENCE));
#endif

}

int
Expand Down

0 comments on commit c6774a6

Please sign in to comment.