[mapguide-commits] r9468 - trunk/MgDev/Common/Geometry
svn_mapguide at osgeo.org
svn_mapguide at osgeo.org
Fri Jan 25 06:50:39 PST 2019
Author: jng
Date: 2019-01-25 06:50:39 -0800 (Fri, 25 Jan 2019)
New Revision: 9468
Modified:
trunk/MgDev/Common/Geometry/GeometrySimplifier.cpp
trunk/MgDev/Common/Geometry/GeosUtil.cpp
trunk/MgDev/Common/Geometry/PreparedGeometry.cpp
Log:
#2791: Fix up GeometryFactory usage in GEOS 3.6.0 (the system version of libgeos on Ubuntu 18.04)
Modified: trunk/MgDev/Common/Geometry/GeometrySimplifier.cpp
===================================================================
--- trunk/MgDev/Common/Geometry/GeometrySimplifier.cpp 2019-01-25 14:32:58 UTC (rev 9467)
+++ trunk/MgDev/Common/Geometry/GeometrySimplifier.cpp 2019-01-25 14:50:39 UTC (rev 9468)
@@ -46,8 +46,14 @@
STRING inputWKt = geom->ToAwkt(true);
PrecisionModel pm;
+// GEOS 3.6.0 onwards changes the C++ API around GeometryFactory
+#if (GEOS_VERSION_MAJOR == 3) && (GEOS_VERSION_MINOR >= 6)
+ GeometryFactory::unique_ptr gf = GeometryFactory::create(&pm, 10);
+ WKTReader r(gf.get());
+#else
GeometryFactory gf(&pm, 10);
WKTReader r(&gf);
+#endif
WKTWriter w;
gInput.reset(r.read(MgUtil::WideCharToMultiByte(inputWKt)));
Modified: trunk/MgDev/Common/Geometry/GeosUtil.cpp
===================================================================
--- trunk/MgDev/Common/Geometry/GeosUtil.cpp 2019-01-25 14:32:58 UTC (rev 9467)
+++ trunk/MgDev/Common/Geometry/GeosUtil.cpp 2019-01-25 14:50:39 UTC (rev 9468)
@@ -29,6 +29,7 @@
#include "GeometricEntityType.h"
using namespace geos;
+using namespace geos::io;
// Dummy class used to automate initialization/uninitialization of GEOS.
class CInitGeos
@@ -49,6 +50,20 @@
class GeosWktReader
{
public:
+// GEOS 3.6.0 onwards changes the C++ API around GeometryFactory
+#if (GEOS_VERSION_MAJOR == 3) && (GEOS_VERSION_MINOR >= 6)
+ GeosWktReader() : m_pm(NULL), m_reader(NULL)
+ {
+ m_pm = new PrecisionModel();
+ m_gf = GeometryFactory::create(m_pm, 10);
+ m_reader = new WKTReader(m_gf.get());
+ }
+ ~GeosWktReader()
+ {
+ delete m_reader;
+ delete m_pm;
+ }
+#else
GeosWktReader() : m_pm(NULL), m_reader(NULL), m_gf(NULL)
{
m_pm = new PrecisionModel();
@@ -61,6 +76,7 @@
delete m_gf;
delete m_pm;
}
+#endif
Geometry* Read(CREFSTRING wkt)
{
return m_reader->read(MgUtil::WideCharToMultiByte(wkt));
@@ -69,7 +85,10 @@
private:
PrecisionModel* m_pm;
WKTReader* m_reader;
- GeometryFactory* m_gf;
+// GEOS 3.6.0 onwards changes the C++ API around GeometryFactory
+#if (GEOS_VERSION_MAJOR == 3) && (GEOS_VERSION_MINOR >= 6)
+ GeometryFactory::unique_ptr m_gf;
+#endif
};
bool MgGeosUtil::Contains(MgGeometry* geom1, MgGeometry* geom2)
Modified: trunk/MgDev/Common/Geometry/PreparedGeometry.cpp
===================================================================
--- trunk/MgDev/Common/Geometry/PreparedGeometry.cpp 2019-01-25 14:32:58 UTC (rev 9467)
+++ trunk/MgDev/Common/Geometry/PreparedGeometry.cpp 2019-01-25 14:50:39 UTC (rev 9468)
@@ -16,6 +16,7 @@
//
#include "GeometryCommon.h"
+#include "GeosInclude.h"
#include <geos/geom/prep/PreparedGeometry.h>
#include <geos/geom/prep/PreparedGeometryFactory.h>
@@ -24,14 +25,25 @@
class MgPreparedGeometry::PreparedGeometryImpl
{
public:
+// GEOS 3.6.0 onwards changes the C++ API around GeometryFactory
+#if (GEOS_VERSION_MAJOR == 3) && (GEOS_VERSION_MINOR >= 6)
PreparedGeometryImpl()
: m_pg(NULL),
m_pm(new PrecisionModel()),
+ m_geom(NULL)
+ {
+ m_gf = GeometryFactory::create(m_pm.get(), 10);
+ }
+#else
+ PreparedGeometryImpl()
+ : m_pg(NULL),
+ m_pm(new PrecisionModel()),
m_gf(NULL),
m_geom(NULL)
{
m_gf.reset(new GeometryFactory(m_pm.get(), 10));
}
+#endif
~PreparedGeometryImpl()
{
PreparedGeometryFactory::destroy(m_pg);
@@ -59,7 +71,12 @@
private:
std::auto_ptr<Geometry> m_geom;
std::auto_ptr<PrecisionModel> m_pm;
+// GEOS 3.6.0 onwards changes the C++ API around GeometryFactory
+#if (GEOS_VERSION_MAJOR == 3) && (GEOS_VERSION_MINOR >= 6)
+ GeometryFactory::unique_ptr m_gf;
+#else
std::auto_ptr<GeometryFactory> m_gf;
+#endif
};
MgPreparedGeometry* MgPreparedGeometry::Create(MgGeometry* geom)
More information about the mapguide-commits
mailing list