[osmcoastline] 01/01: Add patch to support GDAL 2.0.

Sebastiaan Couwenberg sebastic at moszumanska.debian.org
Sat Nov 7 00:44:02 UTC 2015


This is an automated email from the git hooks/post-receive script.

sebastic pushed a commit to branch master
in repository osmcoastline.

commit 40bd55bcfa63afffd5cbcbd52725e03f14f185e4
Author: Bas Couwenberg <sebastic at xs4all.nl>
Date:   Sat Nov 7 01:07:02 2015 +0100

    Add patch to support GDAL 2.0.
---
 debian/changelog              |   6 +
 debian/patches/gdal-2.0.patch | 289 ++++++++++++++++++++++++++++++++++++++++++
 debian/patches/series         |   1 +
 3 files changed, 296 insertions(+)

diff --git a/debian/changelog b/debian/changelog
index ae23291..de4a1a5 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
+osmcoastline (2.1.1-2) UNRELEASED; urgency=medium
+
+  * Add patch to support GDAL 2.0.
+
+ -- Bas Couwenberg <sebastic at debian.org>  Sat, 07 Nov 2015 01:06:59 +0100
+
 osmcoastline (2.1.1-1) unstable; urgency=medium
 
   * New upstream release.
diff --git a/debian/patches/gdal-2.0.patch b/debian/patches/gdal-2.0.patch
new file mode 100644
index 0000000..124cf3a
--- /dev/null
+++ b/debian/patches/gdal-2.0.patch
@@ -0,0 +1,289 @@
+Description: Add support for GDAL 2.0.
+Author: Bas Couwenberg <sebastic at debian.org>
+Bug: https://github.com/osmcode/osmcoastline/issues/15
+Bug-Debian: https://bugs.debian.org/802813
+Forwarded: https://github.com/osmcode/osmcoastline/pull/16
+
+--- a/src/ogr_include.hpp
++++ b/src/ogr_include.hpp
+@@ -31,6 +31,7 @@
+ # pragma GCC diagnostic pop
+ #endif
+ 
++#if GDAL_VERSION_MAJOR < 2
+ struct OGRDataSourceDestroyer {
+     void operator()(OGRDataSource* ptr) {
+         if (ptr) {
+@@ -38,5 +39,14 @@ struct OGRDataSourceDestroyer {
+         }
+     }
+ };
++#else
++struct GDALDatasetDestroyer {
++    void operator()(GDALDataset* ptr) {
++        if (ptr) {
++            GDALClose(ptr);
++        }
++    }
++};
++#endif
+ 
+ #endif // OGR_INCLUDE_HPP
+--- a/src/osmcoastline_segments.cpp
++++ b/src/osmcoastline_segments.cpp
+@@ -92,9 +92,15 @@ void add_segment(OGRLayer* layer, int ch
+ }
+ 
+ void output_ogr(const std::string& filename, const std::string& driver_name, const segvec& removed_segments, const segvec& added_segments) {
++#if GDAL_VERSION_MAJOR < 2
+     OGRRegisterAll();
+ 
+     OGRSFDriver* driver = OGRSFDriverRegistrar::GetRegistrar()->GetDriverByName(driver_name.c_str());
++#else
++    GDALAllRegister();
++
++    GDALDriver* driver = GetGDALDriverManager()->GetDriverByName(driver_name.c_str());
++#endif
+     if (!driver) {
+         std::cerr << driver_name << " driver not available.\n";
+         exit(return_code_fatal);
+@@ -102,7 +108,11 @@ void output_ogr(const std::string& filen
+ 
+     //const char* options[] = { "SPATIALITE=yes", "OGR_SQLITE_SYNCHRONOUS=OFF", "INIT_WITH_EPSG=no", nullptr };
+     const char* options[] = { nullptr };
++#if GDAL_VERSION_MAJOR < 2
+     auto data_source = std::unique_ptr<OGRDataSource, OGRDataSourceDestroyer>(driver->CreateDataSource(filename.c_str(), const_cast<char**>(options)));
++#else
++    auto data_source = std::unique_ptr<GDALDataset, GDALDatasetDestroyer>(driver->Create(filename.c_str(), 0, 0, 0, GDT_Unknown, NULL));
++#endif
+     if (!data_source) {
+         std::cerr << "Creation of output file failed.\n";
+         exit(return_code_fatal);
+--- a/src/osmcoastline_ways.cpp
++++ b/src/osmcoastline_ways.cpp
+@@ -40,7 +40,11 @@ class CoastlineWaysHandler : public osmi
+ 
+     double m_length;
+ 
++#if GDAL_VERSION_MAJOR < 2
+     std::unique_ptr<OGRDataSource, OGRDataSourceDestroyer> m_data_source;
++#else
++    std::unique_ptr<GDALDataset, GDALDatasetDestroyer> m_data_source;
++#endif
+     OGRLayer* m_layer_ways;
+ 
+     osmium::geom::OGRFactory<> m_factory;
+@@ -49,10 +53,18 @@ public:
+ 
+     CoastlineWaysHandler(const std::string& db_filename) :
+         m_length(0.0) {
++#if GDAL_VERSION_MAJOR < 2
+         OGRRegisterAll();
++#else
++        GDALAllRegister();
++#endif
+ 
+         const char* driver_name = "SQLite";
++#if GDAL_VERSION_MAJOR < 2
+         OGRSFDriver* driver = OGRSFDriverRegistrar::GetRegistrar()->GetDriverByName(driver_name);
++#else
++        GDALDriver *driver = GetGDALDriverManager()->GetDriverByName(driver_name);
++#endif
+         if (!driver) {
+             std::cerr << driver_name << " driver not available.\n";
+             exit(return_code_fatal);
+@@ -60,7 +72,11 @@ public:
+ 
+         CPLSetConfigOption("OGR_SQLITE_SYNCHRONOUS", "FALSE");
+         const char* options[] = { "SPATIALITE=TRUE", nullptr };
++#if GDAL_VERSION_MAJOR < 2
+         m_data_source.reset(driver->CreateDataSource(db_filename.c_str(), const_cast<char**>(options)));
++#else
++        m_data_source.reset(driver->Create(db_filename.c_str(), 0, 0, 0, GDT_Unknown, const_cast<char**>(options)));
++#endif
+         if (!m_data_source) {
+             std::cerr << "Creation of output file failed.\n";
+             exit(return_code_fatal);
+--- a/src/output_database.hpp
++++ b/src/output_database.hpp
+@@ -51,7 +51,11 @@ class OutputDatabase {
+ 
+     bool m_with_index;
+ 
++#if GDAL_VERSION_MAJOR < 2
+     std::unique_ptr<OGRDataSource, OGRDataSourceDestroyer> m_data_source;
++#else
++    std::unique_ptr<GDALDataset, GDALDatasetDestroyer> m_data_source;
++#endif
+ 
+     std::unique_ptr<LayerErrorPoints> m_layer_error_points;
+     std::unique_ptr<LayerErrorLines>  m_layer_error_lines;
+--- a/src/output_layers.cpp
++++ b/src/output_layers.cpp
+@@ -47,7 +47,11 @@ void Layer::commit() {
+ 
+ /***************************************************************/
+ 
++#if GDAL_VERSION_MAJOR < 2
+ LayerErrorPoints::LayerErrorPoints(OGRDataSource* data_source, const char** options) :
++#else
++LayerErrorPoints::LayerErrorPoints(GDALDataset* data_source, const char** options) :
++#endif
+     Layer() {
+     m_layer = data_source->CreateLayer("error_points", srs.out(), wkbPoint, const_cast<char**>(options));
+     if (!m_layer) {
+@@ -91,7 +95,11 @@ void LayerErrorPoints::add(OGRPoint* poi
+ 
+ /***************************************************************/
+ 
++#if GDAL_VERSION_MAJOR < 2
+ LayerErrorLines::LayerErrorLines(OGRDataSource* data_source, const char** options) :
++#else
++LayerErrorLines::LayerErrorLines(GDALDataset* data_source, const char** options) :
++#endif
+     Layer() {
+     m_layer = data_source->CreateLayer("error_lines", srs.out(), wkbLineString, const_cast<char**>(options));
+     if (!m_layer) {
+@@ -135,7 +143,11 @@ void LayerErrorLines::add(OGRLineString*
+ 
+ /***************************************************************/
+ 
++#if GDAL_VERSION_MAJOR < 2
+ LayerRings::LayerRings(OGRDataSource* data_source, const char** options) :
++#else
++LayerRings::LayerRings(GDALDataset* data_source, const char** options) :
++#endif
+     Layer() {
+     m_layer = data_source->CreateLayer("rings", srs.out(), wkbPolygon, const_cast<char**>(options));
+     if (!m_layer) {
+@@ -264,7 +276,11 @@ void LayerRings::add(OGRPolygon* polygon
+ 
+ /***************************************************************/
+ 
++#if GDAL_VERSION_MAJOR < 2
+ LayerPolygons::LayerPolygons(OGRDataSource* data_source, const char** options, const char* name) :
++#else
++LayerPolygons::LayerPolygons(GDALDataset* data_source, const char** options, const char* name) :
++#endif
+     Layer(),
+     m_name(name) {
+     m_layer = data_source->CreateLayer(name, srs.out(), wkbPolygon, const_cast<char**>(options));
+@@ -293,7 +309,11 @@ void LayerPolygons::add(OGRPolygon* poly
+ 
+ /***************************************************************/
+ 
++#if GDAL_VERSION_MAJOR < 2
+ LayerLines::LayerLines(OGRDataSource* data_source, const char** options) :
++#else
++LayerLines::LayerLines(GDALDataset* data_source, const char** options) :
++#endif
+     Layer() {
+     m_layer = data_source->CreateLayer("lines", srs.out(), wkbLineString, const_cast<char**>(options));
+     if (!m_layer) {
+--- a/src/output_layers.hpp
++++ b/src/output_layers.hpp
+@@ -29,7 +29,11 @@
+ extern SRS srs;
+ 
+ class OGRLayer;
++#if GDAL_VERSION_MAJOR < 2
+ class OGRDataSource;
++#else
++class GDALDataset;
++#endif
+ class OGRPoint;
+ class OGRLineString;
+ class OGRPolygon;
+@@ -60,7 +64,11 @@ class LayerErrorPoints : public Layer {
+ 
+ public:
+ 
++#if GDAL_VERSION_MAJOR < 2
+     LayerErrorPoints(OGRDataSource* data_source, const char** options);
++#else
++    LayerErrorPoints(GDALDataset* data_source, const char** options);
++#endif
+     void add(OGRPoint* point, const char* error, osmium::object_id_type id);
+ 
+ };
+@@ -72,7 +80,11 @@ class LayerErrorLines : public Layer {
+ 
+ public:
+ 
++#if GDAL_VERSION_MAJOR < 2
+     LayerErrorLines(OGRDataSource* data_source, const char** options);
++#else
++    LayerErrorLines(GDALDataset* data_source, const char** options);
++#endif
+     void add(OGRLineString* linestring, const char* error, osmium::object_id_type id);
+ 
+ };
+@@ -88,7 +100,11 @@ class LayerRings : public Layer {
+ 
+ public:
+ 
++#if GDAL_VERSION_MAJOR < 2
+     LayerRings(OGRDataSource* data_source, const char** options);
++#else
++    LayerRings(GDALDataset* data_source, const char** options);
++#endif
+     void add(OGRPolygon* polygon, int id, int nways, int npoints, bool fixed, LayerErrorPoints* layer_error_points);
+ 
+ };
+@@ -103,7 +119,11 @@ class LayerPolygons : public Layer {
+ 
+ public:
+ 
++#if GDAL_VERSION_MAJOR < 2
+     LayerPolygons(OGRDataSource* data_source, const char** options, const char* name);
++#else
++    LayerPolygons(GDALDataset* data_source, const char** options, const char* name);
++#endif
+     void add(OGRPolygon* polygon);
+ 
+ };
+@@ -116,7 +136,11 @@ class LayerLines : public Layer {
+ 
+ public:
+ 
++#if GDAL_VERSION_MAJOR < 2
+     LayerLines(OGRDataSource* data_source, const char** options);
++#else
++    LayerLines(GDALDataset* data_source, const char** options);
++#endif
+     void add(OGRLineString* lines);
+ 
+ };
+--- a/src/output_database.cpp
++++ b/src/output_database.cpp
+@@ -45,17 +45,30 @@ OutputDatabase::OutputDatabase(const std
+     m_layer_land_polygons(),
+     m_layer_water_polygons(),
+     m_layer_lines() {
++
++#if GDAL_VERSION_MAJOR < 2
+     OGRRegisterAll();
++#else
++    GDALAllRegister();
++#endif
+ 
+     const char* driver_name = "SQLite";
++#if GDAL_VERSION_MAJOR < 2
+     OGRSFDriver* driver = OGRSFDriverRegistrar::GetRegistrar()->GetDriverByName(driver_name);
++#else
++    GDALDriver* driver = GetGDALDriverManager()->GetDriverByName(driver_name);
++#endif
+     if (!driver) {
+         std::cerr << driver_name << " driver not available.\n";
+         exit(return_code_fatal);
+     }
+ 
+     const char* options[] = { "SPATIALITE=yes", "OGR_SQLITE_SYNCHRONOUS=OFF", "INIT_WITH_EPSG=no", nullptr };
++#if GDAL_VERSION_MAJOR < 2
+     m_data_source.reset(driver->CreateDataSource(outdb.c_str(), const_cast<char**>(options)));
++#else
++    m_data_source.reset(driver->Create(outdb.c_str(), 0, 0, 0, GDT_Unknown, const_cast<char**>(options)));
++#endif
+     if (!m_data_source) {
+         std::cerr << "Creation of output file failed.\n";
+         exit(return_code_fatal);
diff --git a/debian/patches/series b/debian/patches/series
new file mode 100644
index 0000000..261dade
--- /dev/null
+++ b/debian/patches/series
@@ -0,0 +1 @@
+gdal-2.0.patch

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-grass/osmcoastline.git



More information about the Pkg-grass-devel mailing list