Permalink
Browse files

Check GEOS version is <= 3.5.

The current code only works with GEOS up to 3.5, because there were
changes in the C++ API of GEOS that we are using. Using the C++ API was
probably a bad idea anyway, because the GEOS project doesn't consider
the C++ API to be a stable external API. It would be better to use the
stable C API of GEOS, but until somebody needs that and is willing
to implement it, we will not have that.
  • Loading branch information...
joto committed Nov 2, 2016
1 parent aee9f9d commit 3424a7400d70d3b9c5b27b7f704eee2c1725450d
Showing with 22 additions and 2 deletions.
  1. +15 −1 include/osmium/geom/geos.hpp
  2. +7 −1 test/t/geom/test_geos.cpp
@@ -33,12 +33,22 @@ DEALINGS IN THE SOFTWARE.
*/
+#include <geos/version.h>
+#if defined(GEOS_VERSION_MAJOR) && defined(GEOS_VERSION_MINOR) && (GEOS_VERSION_MAJOR < 3 || (GEOS_VERSION_MAJOR == 3 && GEOS_VERSION_MINOR <= 5))
+
+#define OSMIUM_WITH_GEOS
+
/**
* @file
*
- * This file contains code for conversion of OSM geometries into GDAL
+ * This file contains code for conversion of OSM geometries into GEOS
* geometries.
*
+ * Note that everything in this file is deprecated and only works up to
+ * GEOS 3.5. It uses the GEOS C++ API which the GEOS project does not consider
+ * to be a stable, external API. We probably should have used the GEOS C API
+ * instead.
+ *
* @attention If you include this file, you'll need to link with `libgeos`.
*/
@@ -88,6 +98,7 @@ namespace osmium {
namespace detail {
+ /// @deprecated
class GEOSFactoryImpl {
std::unique_ptr<const geos::geom::PrecisionModel> m_precision_model;
@@ -245,6 +256,7 @@ namespace osmium {
} // namespace detail
+ /// @deprecated
template <typename TProjection = IdentityProjection>
using GEOSFactory = GeometryFactory<osmium::geom::detail::GEOSFactoryImpl, TProjection>;
@@ -254,4 +266,6 @@ namespace osmium {
#undef THROW
+#endif
+
#endif // OSMIUM_GEOM_GEOS_HPP
@@ -1,6 +1,10 @@
-#include "catch.hpp"
#include <osmium/geom/geos.hpp>
+
+#ifdef OSMIUM_WITH_GEOS
+
+#include "catch.hpp"
+
#include <osmium/geom/mercator_projection.hpp>
#include "area_helper.hpp"
@@ -144,3 +148,5 @@ TEST_CASE("GEOS geometry factory - create area with two outer and two inner ring
REQUIRE(5 == l1e->getNumPoints());
}
+#endif
+

0 comments on commit 3424a74

Please sign in to comment.