[qgis] 01/02: Add patches for GDAL 2.2 support.
Bas Couwenberg
sebastic at debian.org
Sat Jul 1 18:44:46 UTC 2017
This is an automated email from the git hooks/post-receive script.
sebastic pushed a commit to branch master-2.14.15
in repository qgis.
commit d9e41f5a49bcd6a5283599b7970063b2f518e52c
Author: Bas Couwenberg <sebastic at xs4all.nl>
Date: Sat Jul 1 15:11:43 2017 +0200
Add patches for GDAL 2.2 support.
---
debian/changelog | 6 +
...Fix-build-of-dxf2shp-plugin-with-GDAL-2.2.patch | 588 +++++++++++++++++++++
...r-Use-OGR_F_IsFieldSetAndNotNull-when-ava.patch | 76 +++
debian/patches/series | 2 +
4 files changed, 672 insertions(+)
diff --git a/debian/changelog b/debian/changelog
index 738704c..bf61e5a 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
+qgis (2.14.15+dfsg-3) UNRELEASED; urgency=medium
+
+ * Add patches for GDAL 2.2 support.
+
+ -- Bas Couwenberg <sebastic at debian.org> Sat, 01 Jul 2017 14:19:27 +0200
+
qgis (2.14.15+dfsg-2) unstable; urgency=medium
* Disable openscenegraph & osgearth build dependencies,
diff --git a/debian/patches/0001-Fix-build-of-dxf2shp-plugin-with-GDAL-2.2.patch b/debian/patches/0001-Fix-build-of-dxf2shp-plugin-with-GDAL-2.2.patch
new file mode 100644
index 0000000..670f420
--- /dev/null
+++ b/debian/patches/0001-Fix-build-of-dxf2shp-plugin-with-GDAL-2.2.patch
@@ -0,0 +1,588 @@
+Description: Fix build of dxf2shp plugin with GDAL 2.2
+ Up to now the plugin relied on the fact that GDAL exported the symbols of
+ its internal shapelib. Since GDAL 2.2 this is no longer the case. So build
+ the internal copy of shapelib in the plugin, but to avoid symbol name clashes,
+ prefix the shapelib symbols with qgis_. And also use GDAL VSI large API for I/O
+ so that on Windows on particular non ASCII filenames are properly handled.
+Author: Even Rouault <even.rouault at spatialys.com>
+Origin: https://github.com/qgis/QGIS/commit/b3579abc1e4e117c249b0979208fde972d155373
+
+--- a/src/plugins/dxf2shp_converter/CMakeLists.txt
++++ b/src/plugins/dxf2shp_converter/CMakeLists.txt
+@@ -8,6 +8,8 @@ SET (dxf2shpconverter_SRCS
+ builder.cpp
+ dxflib/src/dl_dxf.cpp
+ dxflib/src/dl_writer_ascii.cpp
++ shapelib-1.2.10/dbfopen.c
++ shapelib-1.2.10/shpopen.c
+ )
+
+ SET (dxf2shpconverter_UIS dxf2shpconvertergui.ui)
+@@ -32,6 +34,7 @@ ADD_LIBRARY (dxf2shpconverterplugin MODU
+
+ INCLUDE_DIRECTORIES(
+ ${CMAKE_CURRENT_BINARY_DIR}
++ ${GDAL_INCLUDE_DIR}
+ ../../core
+ ../../core/geometry
+ ../../core/raster
+--- a/src/plugins/dxf2shp_converter/shapelib-1.2.10/dbfopen.c
++++ b/src/plugins/dxf2shp_converter/shapelib-1.2.10/dbfopen.c
+@@ -182,8 +182,10 @@
+ * Added header.
+ */
+
++#if 0
+ static char rcsid[] =
+ "$Id: dbfopen.c,v 1.48 2003/03/10 14:51:27 warmerda Exp $";
++#endif
+
+ #include "shapefil.h"
+
+@@ -256,9 +258,9 @@ static void DBFWriteHeader( DBFHandle ps
+ /* Write the initial 32 byte file header, and all the field */
+ /* descriptions. */
+ /* -------------------------------------------------------------------- */
+- fseek( psDBF->fp, 0, 0 );
+- fwrite( abyHeader, XBASE_FLDHDR_SZ, 1, psDBF->fp );
+- fwrite( psDBF->pszHeader, XBASE_FLDHDR_SZ, psDBF->nFields, psDBF->fp );
++ VSIFSeekL( psDBF->fp, 0, 0 );
++ VSIFWriteL( abyHeader, XBASE_FLDHDR_SZ, 1, psDBF->fp );
++ VSIFWriteL( psDBF->pszHeader, XBASE_FLDHDR_SZ, psDBF->nFields, psDBF->fp );
+
+ /* -------------------------------------------------------------------- */
+ /* Write out the newline character if there is room for it. */
+@@ -268,7 +270,7 @@ static void DBFWriteHeader( DBFHandle ps
+ char cNewline;
+
+ cNewline = 0x0d;
+- fwrite( &cNewline, 1, 1, psDBF->fp );
++ VSIFWriteL( &cNewline, 1, 1, psDBF->fp );
+ }
+ }
+
+@@ -290,8 +292,8 @@ static void DBFFlushRecord( DBFHandle ps
+ nRecordOffset = psDBF->nRecordLength * psDBF->nCurrentRecord
+ + psDBF->nHeaderLength;
+
+- fseek( psDBF->fp, nRecordOffset, 0 );
+- fwrite( psDBF->pszCurrentRecord, psDBF->nRecordLength, 1, psDBF->fp );
++ VSIFSeekL( psDBF->fp, nRecordOffset, 0 );
++ VSIFWriteL( psDBF->pszCurrentRecord, psDBF->nRecordLength, 1, psDBF->fp );
+ }
+ }
+
+@@ -342,12 +344,12 @@ DBFOpen( const char * pszFilename, const
+ sprintf( pszFullname, "%s.dbf", pszBasename );
+
+ psDBF = ( DBFHandle ) calloc( 1, sizeof( DBFInfo ) );
+- psDBF->fp = fopen( pszFullname, pszAccess );
++ psDBF->fp = VSIFOpenL( pszFullname, pszAccess );
+
+ if ( psDBF->fp == NULL )
+ {
+ sprintf( pszFullname, "%s.DBF", pszBasename );
+- psDBF->fp = fopen( pszFullname, pszAccess );
++ psDBF->fp = VSIFOpenL( pszFullname, pszAccess );
+ }
+
+ free( pszBasename );
+@@ -367,9 +369,9 @@ DBFOpen( const char * pszFilename, const
+ /* Read Table Header info */
+ /* -------------------------------------------------------------------- */
+ pabyBuf = ( unsigned char * ) malloc( 500 );
+- if ( fread( pabyBuf, 32, 1, psDBF->fp ) != 1 )
++ if ( VSIFReadL( pabyBuf, 32, 1, psDBF->fp ) != 1 )
+ {
+- fclose( psDBF->fp );
++ VSIFCloseL( psDBF->fp );
+ free( pabyBuf );
+ free( psDBF );
+ return NULL;
+@@ -389,12 +391,13 @@ DBFOpen( const char * pszFilename, const
+ /* Read in Field Definitions */
+ /* -------------------------------------------------------------------- */
+
+- pabyBuf = psDBF->pszHeader = ( unsigned char * ) SfRealloc( pabyBuf, nHeadLen );
++ psDBF->pszHeader = ( char * ) SfRealloc( pabyBuf, nHeadLen );
++ pabyBuf = ( unsigned char* )psDBF->pszHeader;
+
+- fseek( psDBF->fp, 32, 0 );
+- if ( fread( pabyBuf, nHeadLen - 32, 1, psDBF->fp ) != 1 )
++ VSIFSeekL( psDBF->fp, 32, 0 );
++ if ( VSIFReadL( pabyBuf, nHeadLen - 32, 1, psDBF->fp ) != 1 )
+ {
+- fclose( psDBF->fp );
++ VSIFCloseL( psDBF->fp );
+ free( pabyBuf );
+ free( psDBF );
+ return NULL;
+@@ -456,8 +459,8 @@ DBFClose( DBFHandle psDBF )
+ {
+ unsigned char abyFileHeader[32];
+
+- fseek( psDBF->fp, 0, 0 );
+- fread( abyFileHeader, 32, 1, psDBF->fp );
++ VSIFSeekL( psDBF->fp, 0, 0 );
++ VSIFReadL( abyFileHeader, 32, 1, psDBF->fp );
+
+ abyFileHeader[1] = 95; /* YY */
+ abyFileHeader[2] = 7; /* MM */
+@@ -468,14 +471,14 @@ DBFClose( DBFHandle psDBF )
+ abyFileHeader[6] = ( psDBF->nRecords / ( 256 * 256 ) ) % 256;
+ abyFileHeader[7] = ( psDBF->nRecords / ( 256 * 256 * 256 ) ) % 256;
+
+- fseek( psDBF->fp, 0, 0 );
+- fwrite( abyFileHeader, 32, 1, psDBF->fp );
++ VSIFSeekL( psDBF->fp, 0, 0 );
++ VSIFWriteL( abyFileHeader, 32, 1, psDBF->fp );
+ }
+
+ /* -------------------------------------------------------------------- */
+ /* Close, and free resources. */
+ /* -------------------------------------------------------------------- */
+- fclose( psDBF->fp );
++ VSIFCloseL( psDBF->fp );
+
+ if ( psDBF->panFieldOffset != NULL )
+ {
+@@ -509,7 +512,7 @@ DBFCreate( const char *pszFilename )
+
+ {
+ DBFHandle psDBF;
+- FILE *fp;
++ VSILFILE *fp;
+ char *pszFullname, *pszBasename;
+ int i;
+
+@@ -534,17 +537,20 @@ DBFCreate( const char *pszFilename )
+ /* -------------------------------------------------------------------- */
+ /* Create the file. */
+ /* -------------------------------------------------------------------- */
+- fp = fopen( pszFullname, "wb" );
++ fp = VSIFOpenL( pszFullname, "wb" );
+ if ( fp == NULL )
+ {
+ free( pszFullname );
+ return( NULL );
+ }
+
+- fputc( 0, fp );
+- fclose( fp );
++ {
++ char ch = 0;
++ VSIFWriteL( &ch, 1, 1, fp );
++ }
++ VSIFCloseL( fp );
+
+- fp = fopen( pszFullname, "rb+" );
++ fp = VSIFOpenL( pszFullname, "rb+" );
+ if ( fp == NULL )
+ {
+ free( pszFullname );
+@@ -716,17 +722,17 @@ static void *DBFReadAttribute( DBFHandle
+
+ nRecordOffset = psDBF->nRecordLength * hEntity + psDBF->nHeaderLength;
+
+- if ( fseek( psDBF->fp, nRecordOffset, 0 ) != 0 )
++ if ( VSIFSeekL( psDBF->fp, nRecordOffset, 0 ) != 0 )
+ {
+ fprintf( stderr, "fseek(%d) failed on DBF file.\n",
+ nRecordOffset );
+ return NULL;
+ }
+
+- if ( fread( psDBF->pszCurrentRecord, psDBF->nRecordLength,
+- 1, psDBF->fp ) != 1 )
++ if ( VSIFReadL( psDBF->pszCurrentRecord, psDBF->nRecordLength,
++ 1, psDBF->fp ) != 1 )
+ {
+- fprintf( stderr, "fread(%d) failed on DBF file.\n",
++ fprintf( stderr, "VSIFReadL(%d) failed on DBF file.\n",
+ psDBF->nRecordLength );
+ return NULL;
+ }
+@@ -790,7 +796,7 @@ static void *DBFReadAttribute( DBFHandle
+ }
+
+ /************************************************************************/
+-/* DBFReadIntAttribute() */
++/* DBFReadIntegerAttribute() */
+ /* */
+ /* Read an integer attribute. */
+ /************************************************************************/
+@@ -1013,8 +1019,8 @@ static int DBFWriteAttribute( DBFHandle
+
+ nRecordOffset = psDBF->nRecordLength * hEntity + psDBF->nHeaderLength;
+
+- fseek( psDBF->fp, nRecordOffset, 0 );
+- fread( psDBF->pszCurrentRecord, psDBF->nRecordLength, 1, psDBF->fp );
++ VSIFSeekL( psDBF->fp, nRecordOffset, 0 );
++ VSIFReadL( psDBF->pszCurrentRecord, psDBF->nRecordLength, 1, psDBF->fp );
+
+ psDBF->nCurrentRecord = hEntity;
+ }
+@@ -1073,7 +1079,7 @@ static int DBFWriteAttribute( DBFHandle
+ {
+ int nWidth = psDBF->panFieldSize[iField];
+
+- if ( sizeof( szSField ) - 2 < nWidth )
++ if (( int )sizeof( szSField ) - 2 < nWidth )
+ nWidth = sizeof( szSField ) - 2;
+
+ sprintf( szFormat, "%%%dd", nWidth );
+@@ -1091,7 +1097,7 @@ static int DBFWriteAttribute( DBFHandle
+ {
+ int nWidth = psDBF->panFieldSize[iField];
+
+- if ( sizeof( szSField ) - 2 < nWidth )
++ if (( int )sizeof( szSField ) - 2 < nWidth )
+ nWidth = sizeof( szSField ) - 2;
+
+ sprintf( szFormat, "%%%d.%df",
+@@ -1182,8 +1188,8 @@ int DBFWriteAttributeDirectly( DBFHandle
+
+ nRecordOffset = psDBF->nRecordLength * hEntity + psDBF->nHeaderLength;
+
+- fseek( psDBF->fp, nRecordOffset, 0 );
+- fread( psDBF->pszCurrentRecord, psDBF->nRecordLength, 1, psDBF->fp );
++ VSIFSeekL( psDBF->fp, nRecordOffset, 0 );
++ VSIFReadL( psDBF->pszCurrentRecord, psDBF->nRecordLength, 1, psDBF->fp );
+
+ psDBF->nCurrentRecord = hEntity;
+ }
+@@ -1328,8 +1334,8 @@ DBFWriteTuple( DBFHandle psDBF, int hEnt
+
+ nRecordOffset = psDBF->nRecordLength * hEntity + psDBF->nHeaderLength;
+
+- fseek( psDBF->fp, nRecordOffset, 0 );
+- fread( psDBF->pszCurrentRecord, psDBF->nRecordLength, 1, psDBF->fp );
++ VSIFSeekL( psDBF->fp, nRecordOffset, 0 );
++ VSIFReadL( psDBF->pszCurrentRecord, psDBF->nRecordLength, 1, psDBF->fp );
+
+ psDBF->nCurrentRecord = hEntity;
+ }
+@@ -1372,8 +1378,8 @@ DBFReadTuple( DBFHandle psDBF, int hEnti
+
+ nRecordOffset = psDBF->nRecordLength * hEntity + psDBF->nHeaderLength;
+
+- fseek( psDBF->fp, nRecordOffset, 0 );
+- fread( psDBF->pszCurrentRecord, psDBF->nRecordLength, 1, psDBF->fp );
++ VSIFSeekL( psDBF->fp, nRecordOffset, 0 );
++ VSIFReadL( psDBF->pszCurrentRecord, psDBF->nRecordLength, 1, psDBF->fp );
+
+ psDBF->nCurrentRecord = hEntity;
+ }
+--- a/src/plugins/dxf2shp_converter/shapelib-1.2.10/shapefil.h
++++ b/src/plugins/dxf2shp_converter/shapelib-1.2.10/shapefil.h
+@@ -116,10 +116,61 @@
+
+ #include <stdio.h>
+
++#include "cpl_vsi.h"
++
+ #ifdef USE_DBMALLOC
+ #include <dbmalloc.h>
+ #endif
+
++#define SHPOpen qgis_SHPOpen
++#define SHPCreate qgis_SHPCreate
++#define SHPGetInfo qgis_SHPGetInfo
++#define SHPReadObject qgis_SHPReadObject
++#define SHPWriteObject qgis_SHPWriteObject
++#define SHPDestroyObject qgis_SHPDestroyObject
++#define SHPComputeExtents qgis_SHPComputeExtents
++#define SHPCreateObject qgis_SHPCreateObject
++#define SHPCreateSimpleObject qgis_SHPCreateSimpleObject
++#define SHPRewindObject qgis_SHPRewindObject
++#define SHPClose qgis_SHPClose
++#define SHPTypeName qgis_SHPTypeName
++#define SHPPartTypeName qgis_SHPPartTypeName
++#define SHPCreateTree qgis_SHPCreateTree
++#define SHPDestroyTree qgis_SHPDestroyTree
++#define SHPWriteTree qgis_SHPWriteTree
++#define SHPReadTree qgis_SHPReadTree
++#define SHPTreeAddObject qgis_SHPTreeAddObject
++#define SHPTreeAddShapeId qgis_SHPTreeAddShapeId
++#define SHPTreeRemoveShapeId qgis_SHPTreeRemoveShapeId
++#define SHPTreeTrimExtraNodes qgis_SHPTreeTrimExtraNodes
++#define SHPTreeFindLikelyShapes qgis_SHPTreeFindLikelyShapes
++#define SHPCheckBoundsOverlap qgis_SHPCheckBoundsOverlap
++#define DBFOpen qgis_DBFOpen
++#define DBFCreate qgis_DBFCreate
++#define DBFGetFieldCount qgis_DBFGetFieldCount
++#define DBFGetRecordCount qgis_DBFGetRecordCount
++#define DBFAddField qgis_DBFAddField
++#define DBFFieldType qgis_DBFFieldType
++#define DBFGetFieldInfo qgis_DBFGetFieldInfo
++#define DBFGetFieldIndex qgis_DBFGetFieldIndex
++#define DBFReadIntegerAttribute qgis_DBFReadIntegerAttribute
++#define DBFReadDoubleAttribute qgis_DBFReadDoubleAttribute
++#define DBFReadStringAttribute qgis_DBFReadStringAttribute
++#define DBFReadLogicalAttribute qgis_DBFReadLogicalAttribute
++#define DBFIsAttributeNULL qgis_DBFIsAttributeNULL
++#define DBFWriteIntegerAttribute qgis_DBFWriteIntegerAttribute
++#define DBFWriteDoubleAttribute qgis_DBFWriteDoubleAttribute
++#define DBFWriteStringAttribute qgis_DBFWriteStringAttribute
++#define DBFWriteNULLAttribute qgis_DBFWriteNULLAttribute
++#define DBFWriteLogicalAttribute qgis_DBFWriteLogicalAttribute
++#define DBFWriteAttributeDirectly qgis_DBFWriteAttributeDirectly
++#define DBFReadTuple qgis_DBFReadTuple
++#define DBFWriteTuple qgis_DBFWriteTuple
++#define DBFCloneEmpty qgis_DBFCloneEmpty
++#define DBFClose qgis_DBFClose
++#define DBFGetNativeFieldType qgis_DBFGetNativeFieldType
++
++
+ #ifdef __cplusplus
+ extern "C"
+ {
+@@ -189,8 +240,8 @@ extern "C"
+ /************************************************************************/
+ typedef struct
+ {
+- FILE *fpSHP;
+- FILE *fpSHX;
++ VSILFILE *fpSHP;
++ VSILFILE *fpSHX;
+
+ int nShapeType; /* SHPT_* */
+
+@@ -382,7 +433,7 @@ extern "C"
+ /************************************************************************/
+ typedef struct
+ {
+- FILE *fp;
++ VSILFILE *fp;
+
+ int nRecords;
+
+--- a/src/plugins/dxf2shp_converter/shapelib-1.2.10/shpopen.c
++++ b/src/plugins/dxf2shp_converter/shapelib-1.2.10/shpopen.c
+@@ -158,8 +158,10 @@
+ *
+ */
+
++#if 0
+ static char rcsid[] =
+ "$Id: shpopen.c,v 1.39 2002/08/26 06:46:56 warmerda Exp $";
++#endif
+
+ #include "shapefil.h"
+
+@@ -299,8 +301,8 @@ static void SHPWriteHeader( SHPHandle ps
+ /* -------------------------------------------------------------------- */
+ /* Write .shp file header. */
+ /* -------------------------------------------------------------------- */
+- fseek( psSHP->fpSHP, 0, 0 );
+- fwrite( abyHeader, 100, 1, psSHP->fpSHP );
++ VSIFSeekL( psSHP->fpSHP, 0, 0 );
++ VSIFWriteL( abyHeader, 100, 1, psSHP->fpSHP );
+
+ /* -------------------------------------------------------------------- */
+ /* Prepare, and write .shx file header. */
+@@ -309,8 +311,8 @@ static void SHPWriteHeader( SHPHandle ps
+ ByteCopy( &i32, abyHeader + 24, 4 );
+ if ( !bBigEndian ) SwapWord( 4, abyHeader + 24 );
+
+- fseek( psSHP->fpSHX, 0, 0 );
+- fwrite( abyHeader, 100, 1, psSHP->fpSHX );
++ VSIFSeekL( psSHP->fpSHX, 0, 0 );
++ VSIFWriteL( abyHeader, 100, 1, psSHP->fpSHX );
+
+ /* -------------------------------------------------------------------- */
+ /* Write out the .shx contents. */
+@@ -325,7 +327,7 @@ static void SHPWriteHeader( SHPHandle ps
+ if ( !bBigEndian ) SwapWord( 4, panSHX + i*2 + 1 );
+ }
+
+- fwrite( panSHX, sizeof( int32 ) * 2, psSHP->nRecords, psSHP->fpSHX );
++ VSIFWriteL( panSHX, sizeof( int32 ) * 2, psSHP->nRecords, psSHP->fpSHX );
+
+ free( panSHX );
+ }
+@@ -395,11 +397,11 @@ SHPOpen( const char * pszLayer, const ch
+ /* -------------------------------------------------------------------- */
+ pszFullname = ( char * ) malloc( strlen( pszBasename ) + 5 );
+ sprintf( pszFullname, "%s.shp", pszBasename );
+- psSHP->fpSHP = fopen( pszFullname, pszAccess );
++ psSHP->fpSHP = VSIFOpenL( pszFullname, pszAccess );
+ if ( psSHP->fpSHP == NULL )
+ {
+ sprintf( pszFullname, "%s.SHP", pszBasename );
+- psSHP->fpSHP = fopen( pszFullname, pszAccess );
++ psSHP->fpSHP = VSIFOpenL( pszFullname, pszAccess );
+ }
+
+ if ( psSHP->fpSHP == NULL )
+@@ -411,16 +413,16 @@ SHPOpen( const char * pszLayer, const ch
+ }
+
+ sprintf( pszFullname, "%s.shx", pszBasename );
+- psSHP->fpSHX = fopen( pszFullname, pszAccess );
++ psSHP->fpSHX = VSIFOpenL( pszFullname, pszAccess );
+ if ( psSHP->fpSHX == NULL )
+ {
+ sprintf( pszFullname, "%s.SHX", pszBasename );
+- psSHP->fpSHX = fopen( pszFullname, pszAccess );
++ psSHP->fpSHX = VSIFOpenL( pszFullname, pszAccess );
+ }
+
+ if ( psSHP->fpSHX == NULL )
+ {
+- fclose( psSHP->fpSHP );
++ VSIFCloseL( psSHP->fpSHP );
+ free( psSHP );
+ free( pszBasename );
+ free( pszFullname );
+@@ -434,7 +436,7 @@ SHPOpen( const char * pszLayer, const ch
+ /* Read the file size from the SHP file. */
+ /* -------------------------------------------------------------------- */
+ pabyBuf = ( uchar * ) malloc( 100 );
+- fread( pabyBuf, 100, 1, psSHP->fpSHP );
++ VSIFReadL( pabyBuf, 100, 1, psSHP->fpSHP );
+
+ psSHP->nFileSize = ( pabyBuf[24] * 256 * 256 * 256
+ + pabyBuf[25] * 256 * 256
+@@ -444,15 +446,15 @@ SHPOpen( const char * pszLayer, const ch
+ /* -------------------------------------------------------------------- */
+ /* Read SHX file Header info */
+ /* -------------------------------------------------------------------- */
+- fread( pabyBuf, 100, 1, psSHP->fpSHX );
++ VSIFReadL( pabyBuf, 100, 1, psSHP->fpSHX );
+
+ if ( pabyBuf[0] != 0
+ || pabyBuf[1] != 0
+ || pabyBuf[2] != 0x27
+ || ( pabyBuf[3] != 0x0a && pabyBuf[3] != 0x0d ) )
+ {
+- fclose( psSHP->fpSHP );
+- fclose( psSHP->fpSHX );
++ VSIFCloseL( psSHP->fpSHP );
++ VSIFCloseL( psSHP->fpSHX );
+ free( psSHP );
+ free( pabyBuf );
+
+@@ -468,8 +470,8 @@ SHPOpen( const char * pszLayer, const ch
+ if ( psSHP->nRecords < 0 || psSHP->nRecords > 256000000 )
+ {
+ /* this header appears to be corrupt. Give up. */
+- fclose( psSHP->fpSHP );
+- fclose( psSHP->fpSHX );
++ VSIFCloseL( psSHP->fpSHP );
++ VSIFCloseL( psSHP->fpSHX );
+ free( psSHP );
+
+ free( pabyBuf );
+@@ -526,7 +528,7 @@ SHPOpen( const char * pszLayer, const ch
+ ( int * ) malloc( sizeof( int ) * MAX( 1, psSHP->nMaxRecords ) );
+
+ pabyBuf = ( uchar * ) malloc( 8 * MAX( 1, psSHP->nRecords ) );
+- fread( pabyBuf, 8, psSHP->nRecords, psSHP->fpSHX );
++ VSIFReadL( pabyBuf, 8, psSHP->nRecords, psSHP->fpSHX );
+
+ for ( i = 0; i < psSHP->nRecords; i++ )
+ {
+@@ -570,8 +572,8 @@ SHPClose( SHPHandle psSHP )
+ free( psSHP->panRecOffset );
+ free( psSHP->panRecSize );
+
+- fclose( psSHP->fpSHX );
+- fclose( psSHP->fpSHP );
++ VSIFCloseL( psSHP->fpSHX );
++ VSIFCloseL( psSHP->fpSHP );
+
+ if ( psSHP->pabyRec != NULL )
+ {
+@@ -622,7 +624,7 @@ SHPCreate( const char * pszLayer, int nS
+ {
+ char *pszBasename, *pszFullname;
+ int i;
+- FILE *fpSHP, *fpSHX;
++ VSILFILE *fpSHP, *fpSHX;
+ uchar abyHeader[100];
+ int32 i32;
+ double dValue;
+@@ -655,7 +657,7 @@ SHPCreate( const char * pszLayer, int nS
+ /* -------------------------------------------------------------------- */
+ pszFullname = ( char * ) malloc( strlen( pszBasename ) + 5 );
+ sprintf( pszFullname, "%s.shp", pszBasename );
+- fpSHP = fopen( pszFullname, "wb" );
++ fpSHP = VSIFOpenL( pszFullname, "wb" );
+ if ( fpSHP == NULL )
+ {
+ free( pszBasename );
+@@ -664,12 +666,12 @@ SHPCreate( const char * pszLayer, int nS
+ }
+
+ sprintf( pszFullname, "%s.shx", pszBasename );
+- fpSHX = fopen( pszFullname, "wb" );
++ fpSHX = VSIFOpenL( pszFullname, "wb" );
+ if ( fpSHX == NULL )
+ {
+ free( pszBasename );
+ free( pszFullname );
+- fclose( fpSHP );
++ VSIFCloseL( fpSHP );
+ return( NULL );
+ }
+
+@@ -706,7 +708,7 @@ SHPCreate( const char * pszLayer, int nS
+ /* -------------------------------------------------------------------- */
+ /* Write .shp file header. */
+ /* -------------------------------------------------------------------- */
+- fwrite( abyHeader, 100, 1, fpSHP );
++ VSIFWriteL( abyHeader, 100, 1, fpSHP );
+
+ /* -------------------------------------------------------------------- */
+ /* Prepare, and write .shx file header. */
+@@ -715,13 +717,13 @@ SHPCreate( const char * pszLayer, int nS
+ ByteCopy( &i32, abyHeader + 24, 4 );
+ if ( !bBigEndian ) SwapWord( 4, abyHeader + 24 );
+
+- fwrite( abyHeader, 100, 1, fpSHX );
++ VSIFWriteL( abyHeader, 100, 1, fpSHX );
+
+ /* -------------------------------------------------------------------- */
+ /* Close the files, and then open them as regular existing files. */
+ /* -------------------------------------------------------------------- */
+- fclose( fpSHP );
+- fclose( fpSHX );
++ VSIFCloseL( fpSHP );
++ VSIFCloseL( fpSHX );
+
+ return( SHPOpen( pszLayer, "r+b" ) );
+ }
+@@ -1237,10 +1239,10 @@ SHPWriteObject( SHPHandle psSHP, int nSh
+ /* -------------------------------------------------------------------- */
+ /* Write out record. */
+ /* -------------------------------------------------------------------- */
+- if ( fseek( psSHP->fpSHP, nRecordOffset, 0 ) != 0
+- || fwrite( pabyRec, nRecordSize, 1, psSHP->fpSHP ) < 1 )
++ if ( VSIFSeekL( psSHP->fpSHP, nRecordOffset, 0 ) != 0
++ || VSIFWriteL( pabyRec, nRecordSize, 1, psSHP->fpSHP ) < 1 )
+ {
+- printf( "Error in fseek() or fwrite().\n" );
++ printf( "Error in fseek() or VSIFWriteL().\n" );
+ free( pabyRec );
+ return -1;
+ }
+@@ -1308,8 +1310,8 @@ SHPReadObject( SHPHandle psSHP, int hEnt
+ /* -------------------------------------------------------------------- */
+ /* Read the record. */
+ /* -------------------------------------------------------------------- */
+- fseek( psSHP->fpSHP, psSHP->panRecOffset[hEntity], 0 );
+- fread( psSHP->pabyRec, psSHP->panRecSize[hEntity] + 8, 1, psSHP->fpSHP );
++ VSIFSeekL( psSHP->fpSHP, psSHP->panRecOffset[hEntity], 0 );
++ VSIFReadL( psSHP->pabyRec, psSHP->panRecSize[hEntity] + 8, 1, psSHP->fpSHP );
+
+ /* -------------------------------------------------------------------- */
+ /* Allocate and minimally initialize the object. */
+@@ -1738,6 +1740,7 @@ SHPRewindObject( SHPHandle hSHP, SHPObje
+
+ {
+ int iOpRing, bAltered = 0;
++ ( void )hSHP;
+
+ /* -------------------------------------------------------------------- */
+ /* Do nothing if this is not a polygon object. */
diff --git a/debian/patches/0001-OGR-provider-Use-OGR_F_IsFieldSetAndNotNull-when-ava.patch b/debian/patches/0001-OGR-provider-Use-OGR_F_IsFieldSetAndNotNull-when-ava.patch
new file mode 100644
index 0000000..25dd76e
--- /dev/null
+++ b/debian/patches/0001-OGR-provider-Use-OGR_F_IsFieldSetAndNotNull-when-ava.patch
@@ -0,0 +1,76 @@
+Description: [OGR provider] Use OGR_F_IsFieldSetAndNotNull() when available.
+ Starting with GDAL 2.2, there are 2 concepts: unset fields and null fields
+ whereas previously there was only unset fields. For QGIS purposes, both
+ states (unset/null) are equivalent.
+ .
+ Cherry-picked from 47dd83dd75c7f86fa59510a4b65c453f27fb3771
+Author: Even Rouault <even.rouault at spatialys.com>
+Origin: https://github.com/qgis/QGIS/commit/5fdde8a5ba89e4bb4ba4e008979a6b67742df9b0
+
+--- a/src/providers/ogr/qgsogrfeatureiterator.cpp
++++ b/src/providers/ogr/qgsogrfeatureiterator.cpp
+@@ -33,6 +33,12 @@
+ // - mAttributeFields
+ // - mEncoding
+
++// Starting with GDAL 2.2, there are 2 concepts: unset fields and null fields
++// whereas previously there was only unset fields. For QGIS purposes, both
++// states (unset/null) are equivalent.
++#ifndef OGRNullMarker
++#define OGR_F_IsFieldSetAndNotNull OGR_F_IsFieldSet
++#endif
+
+ QgsOgrFeatureIterator::QgsOgrFeatureIterator( QgsOgrFeatureSource* source, bool ownSource, const QgsFeatureRequest& request )
+ : QgsAbstractFeatureIteratorFromSource<QgsOgrFeatureSource>( source, ownSource, request )
+@@ -335,7 +341,7 @@ void QgsOgrFeatureIterator::getFeatureAt
+
+ QVariant value;
+
+- if ( OGR_F_IsFieldSet( ogrFet, attindex ) )
++ if ( OGR_F_IsFieldSetAndNotNull( ogrFet, attindex ) )
+ {
+ switch ( mSource->mFields.at( attindex ).type() )
+ {
+--- a/src/providers/ogr/qgsogrprovider.cpp
++++ b/src/providers/ogr/qgsogrprovider.cpp
+@@ -55,6 +55,13 @@ email : sherman at mrcc.c
+ #include <sys/vfs.h>
+ #endif
+
++// Starting with GDAL 2.2, there are 2 concepts: unset fields and null fields
++// whereas previously there was only unset fields. For QGIS purposes, both
++// states (unset/null) are equivalent.
++#ifndef OGRNullMarker
++#define OGR_F_IsFieldSetAndNotNull OGR_F_IsFieldSet
++#endif
++
+ static const QString TEXT_PROVIDER_KEY = "ogr";
+ static const QString TEXT_PROVIDER_DESCRIPTION =
+ QString( "OGR data provider" )
+@@ -2595,7 +2602,7 @@ void QgsOgrProvider::uniqueValues( int i
+ OGRFeatureH f;
+ while (( f = OGR_L_GetNextFeature( l ) ) )
+ {
+- uniqueValues << ( OGR_F_IsFieldSet( f, 0 ) ? convertValue( fld.type(), mEncoding->toUnicode( OGR_F_GetFieldAsString( f, 0 ) ) ) : QVariant( fld.type() ) );
++ uniqueValues << ( OGR_F_IsFieldSetAndNotNull( f, 0 ) ? convertValue( fld.type(), mEncoding->toUnicode( OGR_F_GetFieldAsString( f, 0 ) ) ) : QVariant( fld.type() ) );
+ OGR_F_Destroy( f );
+
+ if ( limit >= 0 && uniqueValues.size() >= limit )
+@@ -2637,7 +2644,7 @@ QVariant QgsOgrProvider::minimumValue( i
+ return QVariant();
+ }
+
+- QVariant value = OGR_F_IsFieldSet( f, 0 ) ? convertValue( fld.type(), mEncoding->toUnicode( OGR_F_GetFieldAsString( f, 0 ) ) ) : QVariant( fld.type() );
++ QVariant value = OGR_F_IsFieldSetAndNotNull( f, 0 ) ? convertValue( fld.type(), mEncoding->toUnicode( OGR_F_GetFieldAsString( f, 0 ) ) ) : QVariant( fld.type() );
+ OGR_F_Destroy( f );
+
+ OGR_DS_ReleaseResultSet( ogrDataSource, l );
+@@ -2676,7 +2683,7 @@ QVariant QgsOgrProvider::maximumValue( i
+ return QVariant();
+ }
+
+- QVariant value = OGR_F_IsFieldSet( f, 0 ) ? convertValue( fld.type(), mEncoding->toUnicode( OGR_F_GetFieldAsString( f, 0 ) ) ) : QVariant( fld.type() );
++ QVariant value = OGR_F_IsFieldSetAndNotNull( f, 0 ) ? convertValue( fld.type(), mEncoding->toUnicode( OGR_F_GetFieldAsString( f, 0 ) ) ) : QVariant( fld.type() );
+ OGR_F_Destroy( f );
+
+ OGR_DS_ReleaseResultSet( ogrDataSource, l );
diff --git a/debian/patches/series b/debian/patches/series
index 47d4596..4fbf133 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -9,3 +9,5 @@ qtermwidget-hurd.patch
qt4-without-qtwebkit.patch
columns-typo.patch
grass72.patch
+0001-Fix-build-of-dxf2shp-plugin-with-GDAL-2.2.patch
+0001-OGR-provider-Use-OGR_F_IsFieldSetAndNotNull-when-ava.patch
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-grass/qgis.git
More information about the Pkg-grass-devel
mailing list