[pprepair] 05/05: Add patch to support GDAL 2.0.

Sebastiaan Couwenberg sebastic at moszumanska.debian.org
Fri Nov 6 21:30:56 UTC 2015


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

sebastic pushed a commit to branch master
in repository pprepair.

commit c0f3c35373cf85c4808d56db06b3491eb4f30700
Author: Bas Couwenberg <sebastic at xs4all.nl>
Date:   Fri Nov 6 21:36:54 2015 +0100

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

diff --git a/debian/changelog b/debian/changelog
index a44fc9f..cb47fc8 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -2,6 +2,7 @@ pprepair (0.0~20150624-82a2019-1) UNRELEASED; urgency=medium
 
   * New upstream git snapshot.
   * Add build dependency on libcgal-qt5-dev for libCGAL_Qt5.so.
+  * Add patch to support GDAL 2.0.
 
  -- Bas Couwenberg <sebastic at debian.org>  Fri, 06 Nov 2015 20:39:04 +0100
 
diff --git a/debian/patches/gdal-2.0.patch b/debian/patches/gdal-2.0.patch
new file mode 100644
index 0000000..91e0549
--- /dev/null
+++ b/debian/patches/gdal-2.0.patch
@@ -0,0 +1,168 @@
+Description: Add support for GDAL 2.0.
+Author: Bas Couwenberg <sebastic at debian.org>
+Bug: https://github.com/tudelft3d/pprepair/issues/29
+Bug-Debian: https://bugs.debian.org/802495
+Forwarded: https://github.com/tudelft3d/pprepair/pull/30
+
+--- a/IOWorker.cpp
++++ b/IOWorker.cpp
+@@ -27,17 +27,25 @@ IOWorker::IOWorker() {
+ 
+ bool IOWorker::addToTriangulation(Triangulation &triangulation, TaggingVector &edgesToTag, const char *file, unsigned int schemaIndex) {
+   // Open file
++#if GDAL_VERSION_MAJOR < 2
+ 	OGRDataSource *dataSource = OGRSFDriverRegistrar::Open(file, false);
++#else
++	GDALDataset *dataSource = (GDALDataset*) GDALOpenEx(file, GDAL_OF_READONLY, NULL, NULL, NULL);
++#endif
+ 	if (dataSource == NULL) {
+ 		std::cerr << "Error: Could not open file." << std::endl;
+ 		return false;
+ 	}
+   
+-  char *name = new char[strlen(dataSource->GetName())+1];
+-	strcpy(name, dataSource->GetName());
++  char *name = new char[strlen(file)+1];
++	strcpy(name, file);
+ 	fileNames.push_back(name);
+ 	std::cout << "\tPath: " << name << std::endl;
++#if GDAL_VERSION_MAJOR < 2
+ 	std::cout << "\tType: " << dataSource->GetDriver()->GetName() << std::endl;
++#else
++	std::cout << "\tType: " << dataSource->GetDriverName() << std::endl;
++#endif
+ 	int numberOfLayers = dataSource->GetLayerCount();
+ 	std::cout << "\tLayers: " << numberOfLayers << std::endl;
+   
+@@ -316,7 +324,11 @@ bool IOWorker::addToTriangulation(Triang
+   }
+   
+   // Free OGR data source
++#if GDAL_VERSION_MAJOR < 2
+ 	OGRDataSource::DestroyDataSource(dataSource);
++#else
++	GDALClose(dataSource);
++#endif
+   
+   return true;
+ }
+@@ -1248,23 +1260,43 @@ bool IOWorker::exportPolygons(std::vecto
+ 	
+ 	// Prepare file
+ 	const char *driverName = "ESRI Shapefile";
++#if GDAL_VERSION_MAJOR < 2
+ 	OGRSFDriver *driver = OGRSFDriverRegistrar::GetRegistrar()->GetDriverByName(driverName);
++#else
++	GDALDriver *driver = GetGDALDriverManager()->GetDriverByName(driverName);
++#endif
+ 	if (driver == NULL) {
+ 		std::cout << "\tError: OGR Shapefile driver not found." << std::endl;
+ 		return false;
+ 	}
+ 	
++#if GDAL_VERSION_MAJOR < 2
+ 	OGRDataSource *dataSource = driver->Open(file, false);
++#else
++	GDALDataset *dataSource = (GDALDataset*) GDALOpenEx(file, GDAL_OF_READONLY, NULL, NULL, NULL);
++#endif
+ 	if (dataSource != NULL) {
+ 		std::cout << "\tOverwriting file..." << std::endl;
++#if GDAL_VERSION_MAJOR < 2
+ 		if (driver->DeleteDataSource(dataSource->GetName())!= OGRERR_NONE) {
++#else
++		if (driver->Delete(file)!= CE_None) {
++#endif
+ 			std::cout << "\tError: Couldn't erase file with same name." << std::endl;
+ 			return false;
++#if GDAL_VERSION_MAJOR < 2
+ 		} OGRDataSource::DestroyDataSource(dataSource);
++#else
++		} GDALClose(dataSource);
++#endif
+ 	}
+ 	
+ 	std::cout << "\tWriting file... " << std::endl;
++#if GDAL_VERSION_MAJOR < 2
+ 	dataSource = driver->CreateDataSource(file, NULL);
++#else
++	dataSource = driver->Create(file,0,0,0,GDT_Unknown,NULL);
++#endif
+ 	if (dataSource == NULL) {
+ 		std::cout << "\tError: Could not create file." << std::endl;
+ 		return false;
+@@ -1356,7 +1388,11 @@ bool IOWorker::exportPolygons(std::vecto
+ 	}
+ 	
+ 	// Free OGR data source
++#if GDAL_VERSION_MAJOR < 2
+ 	OGRDataSource::DestroyDataSource(dataSource);
++#else
++	GDALClose(dataSource);
++#endif
+ 	
+ 	return true;
+ }
+@@ -1365,23 +1401,43 @@ bool IOWorker::exportTriangulation(Trian
+ 	
+ 	// Prepare file
+ 	const char *driverName = "ESRI Shapefile";
++#if GDAL_VERSION_MAJOR < 2
+ 	OGRSFDriver *driver = OGRSFDriverRegistrar::GetRegistrar()->GetDriverByName(driverName);
++#else
++	GDALDriver *driver = GetGDALDriverManager()->GetDriverByName(driverName);
++#endif
+ 	if (driver == NULL) {
+ 		std::cout << "Driver not found." << std::endl;
+ 		return false;
+ 	}
+-	
++
++#if GDAL_VERSION_MAJOR < 2
+ 	OGRDataSource *dataSource = driver->Open(file, false);
++#else
++	GDALDataset *dataSource = (GDALDataset*) GDALOpenEx(file, GDAL_OF_READONLY, NULL, NULL, NULL);
++#endif
+ 	if (dataSource != NULL) {
+ 		std::cout << "Erasing current file..." << std::endl;
++#if GDAL_VERSION_MAJOR < 2
+ 		if (driver->DeleteDataSource(dataSource->GetName())!= OGRERR_NONE) {
++#else
++		if (driver->Delete(file)!= CE_None) {
++#endif
+ 			std::cout << "Couldn't erase current file." << std::endl;
+ 			return false;
++#if GDAL_VERSION_MAJOR < 2
+ 		} OGRDataSource::DestroyDataSource(dataSource);
++#else
++		} GDALClose(dataSource);
++#endif
+ 	}
+ 	
+ 	std::cout << "Writing file... " << std::endl;
++#if GDAL_VERSION_MAJOR < 2
+ 	dataSource = driver->CreateDataSource(file, NULL);
++#else
++	dataSource = driver->Create(file,0,0,0,GDT_Unknown,NULL);
++#endif
+ 	if (dataSource == NULL) {
+ 		std::cout << "Could not create file." << std::endl;
+ 		return false;
+@@ -1496,7 +1552,11 @@ bool IOWorker::exportTriangulation(Trian
+ 	}
+ 	
+ 	// Free OGR data source
++#if GDAL_VERSION_MAJOR < 2
+ 	OGRDataSource::DestroyDataSource(dataSource);
++#else
++	GDALClose(dataSource);
++#endif
+ 	
+ 	return true;
+ }
+@@ -2073,4 +2133,4 @@ void IOWorker::insertTriangulationInfo(s
+   "\tOverlaps: " << multipletags << " triangles (" << 100.0*multipletags/total << " %)" << std::endl;
+ 	
+ 	// Other info?
+-}
+\ No newline at end of file
++}
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/pprepair.git



More information about the Pkg-grass-devel mailing list