Skip to content

Commit

Permalink
Check GEOS version is <= 3.5.
Browse files Browse the repository at this point in the history
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 3424a74
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
16 changes: 15 additions & 1 deletion include/osmium/geom/geos.hpp
Expand Up @@ -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`.
*/

Expand Down Expand Up @@ -88,6 +98,7 @@ namespace osmium {

namespace detail {

/// @deprecated
class GEOSFactoryImpl {

std::unique_ptr<const geos::geom::PrecisionModel> m_precision_model;
Expand Down Expand Up @@ -245,6 +256,7 @@ namespace osmium {

} // namespace detail

/// @deprecated
template <typename TProjection = IdentityProjection>
using GEOSFactory = GeometryFactory<osmium::geom::detail::GEOSFactoryImpl, TProjection>;

Expand All @@ -254,4 +266,6 @@ namespace osmium {

#undef THROW

#endif

#endif // OSMIUM_GEOM_GEOS_HPP
8 changes: 7 additions & 1 deletion test/t/geom/test_geos.cpp
@@ -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"
Expand Down Expand Up @@ -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.