summarylogtreecommitdiffstats
path: root/fix-suppor_geos36.patch
blob: 31e3899cb280f7b0db593c2d9a03341fdb3e86d9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
From 6a3f724e3a19aa53ba7af40bcbce7e1e19477a8e Mon Sep 17 00:00:00 2001
From: Sandro Mani <manisandro@gmail.com>
Date: Mon, 20 Mar 2017 15:19:09 +0100
Subject: [PATCH] Add GEOS >= 3.6.0 compatibility

---
 src/osgEarthSymbology/GEOS     |  6 ++++++
 src/osgEarthSymbology/GEOS.cpp | 15 ++++++++++++++-
 2 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/src/osgEarthSymbology/GEOS b/src/osgEarthSymbology/GEOS
index 9921e65440..74471d2123 100644
--- a/src/osgEarthSymbology/GEOS
+++ b/src/osgEarthSymbology/GEOS
@@ -25,7 +25,9 @@
 #include <osgEarthFeatures/Common>
 #include <osgEarthSymbology/Style>
 #include <osgEarthSymbology/Geometry>
+#include <geos/version.h>
 #include <geos/geom/Geometry.h>
+#include <geos/geom/GeometryFactory.h>
 
 namespace osgEarth { namespace Symbology
 {
@@ -45,7 +47,11 @@ namespace osgEarth { namespace Symbology
         void disposeGeometry(geos::geom::Geometry* input);
 
     protected:
+#if GEOS_VERSION_MAJOR >= 3 && GEOS_VERSION_MINOR >= 6
+        geos::geom::GeometryFactory::unique_ptr _factory;
+#else
         geos::geom::GeometryFactory* _factory;
+#endif
     };
 
 } } // namespace osgEarth::Features
diff --git a/src/osgEarthSymbology/GEOS.cpp b/src/osgEarthSymbology/GEOS.cpp
index 9d7d27e521..db42f657ee 100644
--- a/src/osgEarthSymbology/GEOS.cpp
+++ b/src/osgEarthSymbology/GEOS.cpp
@@ -216,7 +216,11 @@ GEOSContext::GEOSContext()
     geos::geom::PrecisionModel* pm = new geos::geom::PrecisionModel(geom::PrecisionModel::FLOATING);
 
     // Factory will clone the PM
+#if GEOS_VERSION_MAJOR >= 3 && GEOS_VERSION_MINOR >= 6
+    _factory = geos::geom::GeometryFactory::create( pm );
+#else
     _factory = new geos::geom::GeometryFactory( pm );
+#endif
 
     // Delete the template.
     delete pm;
@@ -224,7 +228,9 @@ GEOSContext::GEOSContext()
 
 GEOSContext::~GEOSContext()
 {
+#if !(GEOS_VERSION_MAJOR >= 3 && GEOS_VERSION_MINOR >= 6)
     delete _factory;
+#endif
 }
 
 geom::Geometry*
@@ -233,12 +239,16 @@ GEOSContext::importGeometry(const Symbology::Geometry* input)
     geom::Geometry* output = 0L;
     if ( input && input->isValid() )
     {
+#if GEOS_VERSION_MAJOR >= 3 && GEOS_VERSION_MINOR >= 6
+        output = import( input, _factory.get() );
+#else
         output = import( input, _factory );
 
         // if output is ok, it will have a pointer to f. this is probably a leak.
         // TODO: Check whether this is a leak!! -gw
         //if ( !output )
         //    delete f;
+#endif
     }
     return output;
 }
@@ -335,10 +345,13 @@ GEOSContext::disposeGeometry(geom::Geometry* input)
 {
     if (input)
     {
-        geom::GeometryFactory* f = const_cast<geom::GeometryFactory*>(input->getFactory());
+#if GEOS_VERSION_MAJOR >= 3 && GEOS_VERSION_MINOR >= 6
         _factory->destroyGeometry(input);
+#else
+        geom::GeometryFactory* f = const_cast<geom::GeometryFactory*>(input->getFactory());
         if ( f != _factory )
             delete f;
+#endif
     }
 }