Skip to content

Commit 3424a74

Browse files
committed
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.
1 parent aee9f9d commit 3424a74

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

include/osmium/geom/geos.hpp

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,22 @@ DEALINGS IN THE SOFTWARE.
3333
3434
*/
3535

36+
#include <geos/version.h>
37+
#if defined(GEOS_VERSION_MAJOR) && defined(GEOS_VERSION_MINOR) && (GEOS_VERSION_MAJOR < 3 || (GEOS_VERSION_MAJOR == 3 && GEOS_VERSION_MINOR <= 5))
38+
39+
#define OSMIUM_WITH_GEOS
40+
3641
/**
3742
* @file
3843
*
39-
* This file contains code for conversion of OSM geometries into GDAL
44+
* This file contains code for conversion of OSM geometries into GEOS
4045
* geometries.
4146
*
47+
* Note that everything in this file is deprecated and only works up to
48+
* GEOS 3.5. It uses the GEOS C++ API which the GEOS project does not consider
49+
* to be a stable, external API. We probably should have used the GEOS C API
50+
* instead.
51+
*
4252
* @attention If you include this file, you'll need to link with `libgeos`.
4353
*/
4454

@@ -88,6 +98,7 @@ namespace osmium {
8898

8999
namespace detail {
90100

101+
/// @deprecated
91102
class GEOSFactoryImpl {
92103

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

246257
} // namespace detail
247258

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

@@ -254,4 +266,6 @@ namespace osmium {
254266

255267
#undef THROW
256268

269+
#endif
270+
257271
#endif // OSMIUM_GEOM_GEOS_HPP

test/t/geom/test_geos.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1-
#include "catch.hpp"
21

32
#include <osmium/geom/geos.hpp>
3+
4+
#ifdef OSMIUM_WITH_GEOS
5+
6+
#include "catch.hpp"
7+
48
#include <osmium/geom/mercator_projection.hpp>
59

610
#include "area_helper.hpp"
@@ -144,3 +148,5 @@ TEST_CASE("GEOS geometry factory - create area with two outer and two inner ring
144148
REQUIRE(5 == l1e->getNumPoints());
145149
}
146150

151+
#endif
152+

0 commit comments

Comments
 (0)