[gdal] 09/29: Imported Upstream version 2.0.0~rc1+dfsg

Sebastiaan Couwenberg sebastic at moszumanska.debian.org
Sun Jun 14 20:19:45 UTC 2015


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

sebastic pushed a commit to branch experimental-2.0
in repository gdal.

commit caa4c70c5870aef17c457a7dcf7ccaa60a4fb8ff
Author: Bas Couwenberg <sebastic at xs4all.nl>
Date:   Sat Jun 13 21:25:04 2015 +0200

    Imported Upstream version 2.0.0~rc1+dfsg
---
 NEWS                                             | 26 +++++++--
 VERSION                                          |  2 +-
 alg/gdaltransformer.cpp                          | 10 ++--
 apps/gdal_translate.cpp                          | 12 ++++-
 apps/gdaldem.cpp                                 |  4 +-
 apps/gdalinfo.c                                  | 17 ++++--
 apps/ogr2ogr.cpp                                 | 68 ++++++++++++++++++++----
 apps/ogr_utilities.dox                           |  6 ++-
 apps/test_ogrsf.cpp                              |  6 +--
 frmts/gtiff/geotiff.cpp                          |  9 ++--
 frmts/jpeg/jpgdataset.cpp                        |  8 +--
 frmts/kea/keaband.h                              |  5 +-
 frmts/kea/keacopy.h                              |  6 ++-
 frmts/kea/keadataset.h                           |  5 +-
 frmts/kea/keamaskband.h                          |  5 +-
 frmts/kea/keaoverview.h                          |  6 ++-
 frmts/kea/kearat.h                               |  5 +-
 frmts/kmlsuperoverlay/kmlsuperoverlaydataset.cpp | 45 +++++++++-------
 frmts/nitf/rpftocfile.cpp                        | 20 +++++--
 frmts/rasterlite/rasterlitedataset.cpp           |  9 ++--
 frmts/raw/btdataset.cpp                          |  4 +-
 frmts/vrt/vrtdataset.cpp                         | 29 +++++++++-
 frmts/vrt/vrtdataset.h                           |  9 +++-
 frmts/vrt/vrtdriver.cpp                          |  5 +-
 frmts/vrt/vrtsources.cpp                         | 29 ++++++++--
 gcore/gdal_priv.h                                | 12 ++++-
 gcore/gdal_version.h                             |  4 +-
 gcore/gdaldataset.cpp                            | 39 ++++++++++++--
 gcore/gdalrasterband.cpp                         | 54 ++++++++++++++++---
 gcore/gdalrasterblock.cpp                        | 21 +++-----
 man/man1/gdal-config.1                           |  4 +-
 man/man1/gdal2tiles.1                            |  4 +-
 man/man1/gdal_calc.1                             |  4 +-
 man/man1/gdal_contour.1                          |  4 +-
 man/man1/gdal_edit.1                             |  4 +-
 man/man1/gdal_fillnodata.1                       |  4 +-
 man/man1/gdal_grid.1                             |  4 +-
 man/man1/gdal_merge.1                            |  4 +-
 man/man1/gdal_polygonize.1                       |  4 +-
 man/man1/gdal_proximity.1                        |  4 +-
 man/man1/gdal_rasterize.1                        |  4 +-
 man/man1/gdal_retile.1                           |  4 +-
 man/man1/gdal_sieve.1                            |  4 +-
 man/man1/gdal_translate.1                        |  4 +-
 man/man1/gdal_utilities.1                        |  4 +-
 man/man1/gdaladdo.1                              |  4 +-
 man/man1/gdalbuildvrt.1                          |  4 +-
 man/man1/gdalcompare.1                           |  4 +-
 man/man1/gdaldem.1                               |  4 +-
 man/man1/gdalinfo.1                              |  4 +-
 man/man1/gdallocationinfo.1                      |  4 +-
 man/man1/gdalmanage.1                            |  4 +-
 man/man1/gdalmove.1                              |  4 +-
 man/man1/gdalsrsinfo.1                           |  4 +-
 man/man1/gdaltindex.1                            |  4 +-
 man/man1/gdaltransform.1                         |  4 +-
 man/man1/gdalwarp.1                              |  4 +-
 man/man1/nearblack.1                             |  4 +-
 man/man1/ogr2ogr.1                               | 10 ++--
 man/man1/ogr_utilities.1                         |  4 +-
 man/man1/ogrinfo.1                               |  4 +-
 man/man1/ogrlineref.1                            |  4 +-
 man/man1/ogrtindex.1                             |  4 +-
 man/man1/pct2rgb.1                               |  4 +-
 man/man1/rgb2pct.1                               |  4 +-
 ogr/ogrsf_frmts/gml/ogrgmldatasource.cpp         | 24 ++++-----
 ogr/ogrsf_frmts/openair/ogropenairdriver.cpp     | 41 ++++++++++++--
 ogr/ogrsf_frmts/sqlite/ogrsqlitedriver.cpp       | 12 +++--
 ogr/ogrsf_frmts/sua/ogrsuadriver.cpp             | 41 ++++++++++++--
 ogr/ogrsf_frmts/wfs/drv_wfs.html                 |  5 +-
 ogr/ogrsf_frmts/wfs/ogr_wfs.h                    |  5 +-
 ogr/ogrsf_frmts/wfs/ogrwfsdatasource.cpp         |  9 +++-
 ogr/ogrsf_frmts/wfs/ogrwfsdriver.cpp             |  3 +-
 ogr/ogrsf_frmts/wfs/ogrwfslayer.cpp              | 29 +++++++---
 port/cpl_multiproc.cpp                           | 10 +++-
 port/cpl_strtod.cpp                              |  8 +--
 swig/python/samples/build_jp2_from_xml.py        |  5 +-
 swig/python/samples/ogr_layer_algebra.py         | 10 +++-
 swig/python/scripts/gdal_edit.py                 |  4 +-
 79 files changed, 601 insertions(+), 231 deletions(-)

diff --git a/NEWS b/NEWS
index 1a4f368..84cc106 100644
--- a/NEWS
+++ b/NEWS
@@ -1,6 +1,4 @@
-= GDAL/OGR 2.0 Release Notes (to r29246) =
-
-***** Work in progress ***** 
+= GDAL/OGR 2.0 Release Notes =
 
 == In a nutshell... ==
 
@@ -106,6 +104,7 @@ Port:
 Core:
  * Add imagery (satellite or aerial) metadata support (Alos, DigitalGlobe, Eros, GeoEye, OrbView, Landsat, Pleiades, Resurs-DK1, Spot/Formosat).
  * Reduce lock contention on the global cache mutex and make it possible to use spin lock instead with GDAL_RB_LOCK_TYPE=SPIN
+ * Block cache: make block cache manager safe with respect to writing dirty blocks (#5983)
  * EXIF reader: fix memleak in error code path
  * EXIF reader: add missing validation for some data types (#3078)
  * Fix crash in GDALPamRasterBand::SerializeToXML() when saving an empty RAT (#5451)
@@ -158,6 +157,7 @@ Algorithms:
  * Warper: fix integer overflow when reprojecting into an area with (part of) bounds completely outside of the source projection (#5789)
  * Warper: add min,max,med,q1 and q3 resampling algorithms (#5868)
  * Warper: add a SRC_COORD_PRECISION warping option to help getting more reproducable output when -wm parameter changes (#5925)
+ * Warper: fix failure in GDALSuggestedWarpOut2() when top-left and bottom-right corners tranform to the same point (#5980)
  * GDALReprojectImage(): takes into account nodata values set on destination dataset
  * Median cut and dithering: optimizations and enhancements to deal with 8-bit precision (only if using internal interface for now)
  * rasterfill: add option to specify driver to use for temporary files
@@ -177,6 +177,7 @@ Utilities:
  * gdal_translate: adjust RPC metadata (pixel/line offset/scale) when subsetting/rescaling, instead of just discarding it
  * gdal_translate: don't recopy band units if rescaling or unscaling is involved (#3085)
  * gdal_translate: increase GDAL_MAX_DATASET_POOL_SIZE default value to 450. (#5828)
+ * gdal_translate: preserve NBITS image structure metadata when possible
  * gdalwarp: add -oo option per RFC 46
  * gdalwarp: add -te_srs option to specify -te in a SRS which isn't the target SRS
  * gdalwarp: add a -ovr option to select which overview level to use, and default to AUTO. Also add a generic OVERVIEW_LEVEL=level open option, and make it available in standard VRT (#5688)
@@ -302,6 +303,7 @@ Fixes:
  * serialize RPC in PAM .aux.xml file if using PROFILE != GDALGeoTIFF and RPB = NO
  * fix clearing of GCPs (#5945)
  * avoid generated corrupted right-most and bottom-most tiles for 12-bit JPEG-compressed (#5971)
+ * make sure to use scanline write API when writing single-band single-strip 1-bit datasets
 
 GRASS driver:
  * fix compilation issues against GRASS 7
@@ -389,6 +391,7 @@ JPIPKAK driver:
 
 KMLSuperOverlay driver:
  * fix truncated raster on 32 bit builds (#5683)
+ * make Identify() more restrictive to avoid false positives
 
 L1B driver:
  * add support for little-endian LRPT datasets (#5645)
@@ -462,6 +465,9 @@ PostgisRaster driver:
 Rasterlite driver:
  * accept space in filename
 
+RPFTOC driver:
+ * add tweak for weird relative directory names in the A.TOC file (#5979)
+
 VRT driver:
  * VRT warp: make selection of source overview work (#5688)
  * VRT warp: expose as many overviews in warped dataset as there are in source dataset, and make warped VRT honour -ovr parameter of gdalwarp (#5688)
@@ -475,7 +481,8 @@ VRT driver:
  * do not output empty <Metadata> node on VRTDataset and VRTRasterBand elements
  * fix rounding of output window size on VRTSimpleSource (#5874)
  * add trick to make relativeToVRT works for a VRT-in-VRT
- * VRT: add more checks to CheckCompatibleForDatasetIO() to avoid issues with overview bands (#5954)
+ * add more checks to CheckCompatibleForDatasetIO() to avoid issues with overview bands (#5954)
+ * preserves relative links on reserialization of existing VRT (#5985)
 
 USGSDEM driver:
  * take into account horizontal unit = ft in the UTM case (#5819)
@@ -528,6 +535,7 @@ Utilities:
  * ogrinfo: display dataset and layer metadata. Add -nomdd, -listmdd, -mdd all|domain options, like in gdalinfo. OGR VRT: add dataset and layer metadata support
  * ogrinfo: add -nocount and -noextent options
  * ogr2ogr: add -oo and -doo options per RFC 46
+ * ogr2ogr: add -spat_srs option
  * ogr2ogr: turn string value to one element list if destination field is stringlist
  * ogr2ogr: fix problem with SRS when copying layers with multiple geometry columns with different SRS (#5546)
  * ogr2ogr: add special case for -update and GPKG and input=output
@@ -537,6 +545,7 @@ Utilities:
  * ogr2ogr: add -ds_transaction to force dataset transactions, mainly for FileGDB driver
  * ogr2ogr: fix crash with -clipdst when a reprojection fails before (#5973)
  * ogrlineref: fix project if reper lies on first point or last point of line
+ * ogr_layer_algebra.py: for Update, Clip and Erase, only creates attribute of input layer by default (#5976)
 
 Other:
  * OGR WCTS removed from tree
@@ -629,6 +638,7 @@ GML driver:
  * make Expat parser accept trailing nul characters
  * correctly record path to attribute in case of attribute located on a nested element when .gfs is created with GML_ATTRIBUTES_TO_OGR_FIELDS=YES
  * fix GML_ATTRIBUTES_TO_OGR_FIELDS=YES to work correctly with xlink:href too (#5970
+ * make GML_EXPOSE_GML_ID to be honoured on WFS documents
 
 GPKG driver:
  * add support for non-spatial layers via the gdal_aspatial extension (#5521)
@@ -745,6 +755,9 @@ ODBC driver:
 ODS driver:
  * fix export of OFTDate fields that were exported as string
 
+OpenAir driver:
+ * tweak detection logic to read beyond first 10KB bytes when needed (#5975)
+
 OpenFileGDB driver:
  * add compatibility with .gdbtable files bigger than 4 GB (#5615)
  * support opening files with ConfigurationKeyword=MAX_FILE_SIZE_4GB or MAX_FILE_SIZE_256TB (#5615)
@@ -826,6 +839,9 @@ SQLite/Spatialite driver:
  * emit warning when reading text values in a integer/real field (possible since SQLite has no strong typing)
  * support reading date/datetime from Julian day floating point representation
 
+SUA driver:
+ * tweak detection logic to read beyond first 10KB bytes when needed (#5975)
+
 SXF driver:
  * Fix SXF file version check (#5456)
  * Fix wrong Miller Cylindrical projection string
@@ -859,7 +875,7 @@ WFS driver:
  * automatically enable paging if WFS 2.0 capabilities report paging support
  * evaluate SELECT with JOIN on server-side for a Join-capable WFS 2.0 server
  * add a TRUST_CAPABILITIES_BOUNDS open option, that can be set to YES to trust layer bounds declared in GetCapabilities response, for faster GetExtent() runtime (#4041)
- * add INVERT_AXIS_ORDER_IF_LAT_LONG, CONSIDER_EPSG_AS_URN open options
+ * add INVERT_AXIS_ORDER_IF_LAT_LONG, CONSIDER_EPSG_AS_URN and EXPOSE_GML_ID open options
  * add capability to use spatial functions ST_xxxxx() as server-side filters
  * add dataset and layer metadata
  * allow SELECT with several ORDER BY columns
diff --git a/VERSION b/VERSION
index d0cb2f2..227cea2 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-2.0.0beta2
+2.0.0
diff --git a/alg/gdaltransformer.cpp b/alg/gdaltransformer.cpp
index d692b9c..c4e5774 100644
--- a/alg/gdaltransformer.cpp
+++ b/alg/gdaltransformer.cpp
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: gdaltransformer.cpp 29207 2015-05-18 17:23:45Z mloskot $
+ * $Id: gdaltransformer.cpp 29271 2015-06-01 14:17:30Z rouault $
  *
  * Project:  Mapinfo Image Warper
  * Purpose:  Implementation of one or more GDALTrasformerFunc types, including
@@ -38,7 +38,7 @@
 #include "cpl_list.h"
 #include "cpl_multiproc.h"
 
-CPL_CVSID("$Id: gdaltransformer.cpp 29207 2015-05-18 17:23:45Z mloskot $");
+CPL_CVSID("$Id: gdaltransformer.cpp 29271 2015-06-01 14:17:30Z rouault $");
 CPL_C_START
 void *GDALDeserializeGCPTransformer( CPLXMLNode *psTree );
 void *GDALDeserializeTPSTransformer( CPLXMLNode *psTree );
@@ -701,14 +701,16 @@ retry:
 /*      compute an approximate pixel size in the output                 */
 /*      georeferenced coordinates.                                      */
 /* -------------------------------------------------------------------- */
-    double dfDiagonalDist, dfDeltaX, dfDeltaY;
+    double dfDiagonalDist, dfDeltaX = 0.0, dfDeltaY = 0.0;
 
     if( pabSuccess[0] && pabSuccess[nSamplePoints - 1] )
     {
         dfDeltaX = padfX[nSamplePoints-1] - padfX[0];
         dfDeltaY = padfY[nSamplePoints-1] - padfY[0];
+        // In some cases this can result in 0 values. See #5980
+        // so fallback to safer method in that case
     }
-    else
+    if( dfDeltaX == 0.0 || dfDeltaX == 0.0 )
     {
         dfDeltaX = dfMaxXOut - dfMinXOut;
         dfDeltaY = dfMaxYOut - dfMinYOut;
diff --git a/apps/gdal_translate.cpp b/apps/gdal_translate.cpp
index 354a701..d4f61c7 100644
--- a/apps/gdal_translate.cpp
+++ b/apps/gdal_translate.cpp
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: gdal_translate.cpp 29144 2015-05-04 09:22:47Z rouault $
+ * $Id: gdal_translate.cpp 29259 2015-05-28 22:21:55Z rouault $
  *
  * Project:  GDAL Utilities
  * Purpose:  GDAL Image Translator Program
@@ -36,7 +36,7 @@
 #include "vrtdataset.h"
 #include "commonutils.h"
 
-CPL_CVSID("$Id: gdal_translate.cpp 29144 2015-05-04 09:22:47Z rouault $");
+CPL_CVSID("$Id: gdal_translate.cpp 29259 2015-05-28 22:21:55Z rouault $");
 
 static int ArgIsNumeric( const char * );
 static void AttachMetadata( GDALDatasetH, char ** );
@@ -1601,6 +1601,14 @@ static int ProxyMain( int argc, char ** argv )
             continue;
         }
 
+        // Preserve nbits if no option change values
+        const char* pszNBits = poSrcBand->GetMetadataItem("NBITS", "IMAGE_STRUCTURE");
+        if( pszNBits && nRGBExpand == 0 && nScaleRepeat == 0 &&
+            !bUnscale && eOutputType == GDT_Unknown && pszResampling == NULL )
+        {
+            poVRTBand->SetMetadataItem("NBITS", pszNBits, "IMAGE_STRUCTURE");
+        }
+
 /* -------------------------------------------------------------------- */
 /*      Do we need to collect scaling information?                      */
 /* -------------------------------------------------------------------- */
diff --git a/apps/gdaldem.cpp b/apps/gdaldem.cpp
index 12f8c14..231042d 100644
--- a/apps/gdaldem.cpp
+++ b/apps/gdaldem.cpp
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: gdaldem.cpp 28496 2015-02-16 10:33:55Z rouault $
+ * $Id: gdaldem.cpp 29284 2015-06-03 13:26:10Z rouault $
  *
  * Project:  GDAL DEM Utilities
  * Purpose:  
@@ -92,7 +92,7 @@
 #include "gdal_priv.h"
 #include "commonutils.h"
 
-CPL_CVSID("$Id: gdaldem.cpp 28496 2015-02-16 10:33:55Z rouault $");
+CPL_CVSID("$Id: gdaldem.cpp 29284 2015-06-03 13:26:10Z rouault $");
 
 #ifndef M_PI
 # define M_PI  3.1415926535897932384626433832795
diff --git a/apps/gdalinfo.c b/apps/gdalinfo.c
index 837989d..28cc240 100644
--- a/apps/gdalinfo.c
+++ b/apps/gdalinfo.c
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: gdalinfo.c 29243 2015-05-24 15:53:26Z rouault $
+ * $Id: gdalinfo.c 29268 2015-05-30 11:46:44Z rouault $
  *
  * Project:  GDAL Utilities
  * Purpose:  Commandline application to list info about a file.
@@ -38,7 +38,7 @@
 #include "json.h"
 #include "ogrgeojsonwriter.h"
 
-CPL_CVSID("$Id: gdalinfo.c 29243 2015-05-24 15:53:26Z rouault $");
+CPL_CVSID("$Id: gdalinfo.c 29268 2015-05-30 11:46:44Z rouault $");
 
 static int 
 GDALInfoReportCorner( GDALDatasetH hDataset, 
@@ -1431,13 +1431,20 @@ static void GDALInfoPrintMetadata( GDALMajorObjectH hObject,
             if(bJson)
             {
                 if(bIsxml)
+                {
                     poValue = json_object_new_string( papszMetadata[i] );
+                    break;
+                }
                 else
                 {
+                    pszKey = NULL;
                     pszValue = CPLParseNameValue( papszMetadata[i], &pszKey );
-                    poValue = json_object_new_string( pszValue );
-                    json_object_object_add( poDomain, pszKey, poValue );
-                    CPLFree( pszKey );
+                    if( pszKey )
+                    {
+                        poValue = json_object_new_string( pszValue );
+                        json_object_object_add( poDomain, pszKey, poValue );
+                        CPLFree( pszKey );
+                    }
                 }
             }
             else
diff --git a/apps/ogr2ogr.cpp b/apps/ogr2ogr.cpp
index 0461c95..b9a824c 100644
--- a/apps/ogr2ogr.cpp
+++ b/apps/ogr2ogr.cpp
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: ogr2ogr.cpp 29236 2015-05-22 19:39:48Z rouault $
+ * $Id: ogr2ogr.cpp 29251 2015-05-25 21:24:45Z rouault $
  *
  * Project:  OpenGIS Simple Features Reference Implementation
  * Purpose:  Simple client for translating between formats.
@@ -39,7 +39,7 @@
 #include <map>
 #include <vector>
 
-CPL_CVSID("$Id: ogr2ogr.cpp 29236 2015-05-22 19:39:48Z rouault $");
+CPL_CVSID("$Id: ogr2ogr.cpp 29251 2015-05-25 21:24:45Z rouault $");
 
 static int bSkipFailures = FALSE;
 static int bLayerTransaction = -1;
@@ -838,21 +838,38 @@ public:
 /************************************************************************/
 
 void ApplySpatialFilter(OGRLayer* poLayer, OGRGeometry* poSpatialFilter,
-                        const char* pszGeomField)
+                        OGRSpatialReference* poSpatSRS,
+                        const char* pszGeomField,
+                        OGRSpatialReference* poSourceSRS)
 {
     if( poSpatialFilter != NULL )
     {
+        OGRGeometry* poSpatialFilterReprojected = NULL;
+        if( poSpatSRS )
+        {
+            poSpatialFilterReprojected = poSpatialFilter->clone();
+            poSpatialFilterReprojected->assignSpatialReference(poSpatSRS);
+            OGRSpatialReference* poSpatialFilterTargetSRS  = poSourceSRS ? poSourceSRS : poLayer->GetSpatialRef();
+            if( poSpatialFilterTargetSRS )
+                poSpatialFilterReprojected->transformTo(poSpatialFilterTargetSRS);
+            else
+                fprintf(stderr, "Warning: cannot determine layer SRS for %s.\n", poLayer->GetDescription());
+        }
+
         if( pszGeomField != NULL )
         {
             int iGeomField = poLayer->GetLayerDefn()->GetGeomFieldIndex(pszGeomField);
             if( iGeomField >= 0 )
-                poLayer->SetSpatialFilter( iGeomField, poSpatialFilter );
+                poLayer->SetSpatialFilter( iGeomField,
+                    poSpatialFilterReprojected ? poSpatialFilterReprojected : poSpatialFilter );
             else
                 printf("WARNING: Cannot find geometry field %s.\n",
                     pszGeomField);
         }
         else
-            poLayer->SetSpatialFilter( poSpatialFilter );
+            poLayer->SetSpatialFilter( poSpatialFilterReprojected ? poSpatialFilterReprojected : poSpatialFilter );
+
+        delete poSpatialFilterReprojected;
     }
 }
              
@@ -984,6 +1001,8 @@ int main( int nArgc, char ** papszArgv )
     int          bPreserveFID = FALSE;
     int          bCopyMD = TRUE;
     char       **papszMetadataOptions = NULL;
+    CPLString    osSpatSRSDef;
+    OGRSpatialReference* poSpatSRS = NULL;
 
     int          nGCPCount = 0;
     GDAL_GCP    *pasGCPs = NULL;
@@ -1222,6 +1241,11 @@ int main( int nArgc, char ** papszArgv )
             ((OGRPolygon *) poSpatialFilter)->addRing( &oRing );
             iArg += 4;
         }
+        else if( EQUAL(papszArgv[iArg],"-spat_srs") )
+        {
+            CHECK_HAS_ENOUGH_ADDITIONAL_ARGS(1);
+            osSpatSRSDef = papszArgv[++iArg];
+        }
         else if( EQUAL(papszArgv[iArg],"-geomfield") )
         {
             CHECK_HAS_ENOUGH_ADDITIONAL_ARGS(1);
@@ -1571,9 +1595,9 @@ int main( int nArgc, char ** papszArgv )
         Usage("-fieldTypeToString and -mapFieldType are exclusive.");
     }
 
-    if( pszSourceSRSDef != NULL && pszOutputSRSDef == NULL )
+    if( pszSourceSRSDef != NULL && pszOutputSRSDef == NULL && osSpatSRSDef.size() == 0 )
     {
-        Usage("if -s_srs is specified, -t_srs must also be specified");
+        Usage("if -s_srs is specified, -t_srs and/or -spat_srs must also be specified.");
     }
 
     if( bClipSrc && pszClipSrcDS != NULL)
@@ -1853,7 +1877,28 @@ int main( int nArgc, char ** papszArgv )
             exit( 1 );
         }
     }
- 
+
+/* -------------------------------------------------------------------- */
+/*      Parse spatial filter SRS if needed.                             */
+/* -------------------------------------------------------------------- */
+    if( poSpatialFilter != NULL && osSpatSRSDef.size() )
+    {
+        if( pszSQLStatement )
+        {
+            fprintf(stderr, "-spat_srs not compatible with -sql.\n");
+            exit(1);
+        }
+        OGREnvelope sEnvelope;
+        poSpatialFilter->getEnvelope(&sEnvelope);
+        poSpatSRS = new OGRSpatialReference();
+        if( poSpatSRS->SetFromUserInput( osSpatSRSDef ) != OGRERR_NONE )
+        {
+            fprintf( stderr,  "Failed to process SRS definition: %s\n", 
+                    osSpatSRSDef.c_str() );
+            exit( 1 );
+        }
+    }
+
 /* -------------------------------------------------------------------- */
 /*      Create a transformation object from the source to               */
 /*      destination coordinate system.                                  */
@@ -2145,7 +2190,7 @@ int main( int nArgc, char ** papszArgv )
                     }
                 }
 
-                ApplySpatialFilter(poLayer, poSpatialFilter, pszGeomField);
+                ApplySpatialFilter(poLayer, poSpatialFilter, poSpatSRS, pszGeomField, poSourceSRS );
 
                 TargetLayerInfo* psInfo = oSetup.Setup(poLayer,
                                                        pszNewLayerName);
@@ -2318,7 +2363,7 @@ int main( int nArgc, char ** papszArgv )
                 }
             }
 
-            ApplySpatialFilter(poLayer, poSpatialFilter, pszGeomField);
+            ApplySpatialFilter(poLayer, poSpatialFilter, poSpatSRS, pszGeomField, poSourceSRS);
 
             if (bDisplayProgress && !bSrcIsOSM)
             {
@@ -2465,6 +2510,7 @@ int main( int nArgc, char ** papszArgv )
     /* Destroy them after the last potential user */
     OGRSpatialReference::DestroySpatialReference(poOutputSRS);
     OGRSpatialReference::DestroySpatialReference(poSourceSRS);
+    OGRSpatialReference::DestroySpatialReference(poSpatSRS);
 
     CSLDestroy(papszSelFields);
     CSLDestroy( papszFieldMap );
@@ -2507,7 +2553,7 @@ static void Usage(const char* pszAdditionalMsg, int bShort)
             "               [-select field_list] [-where restricted_where]\n"
             "               [-progress] [-sql <sql statement>] [-dialect dialect]\n"
             "               [-preserve_fid] [-fid FID]\n"
-            "               [-spat xmin ymin xmax ymax] [-geomfield field]\n"
+            "               [-spat xmin ymin xmax ymax] [-spat_srs srs_def] [-geomfield field]\n"
             "               [-a_srs srs_def] [-t_srs srs_def] [-s_srs srs_def]\n"
             "               [-f format_name] [-overwrite] [[-dsco NAME=VALUE] ...]\n"
             "               dst_datasource_name src_datasource_name\n"
diff --git a/apps/ogr_utilities.dox b/apps/ogr_utilities.dox
index 5a89191..59b5315 100644
--- a/apps/ogr_utilities.dox
+++ b/apps/ogr_utilities.dox
@@ -184,7 +184,7 @@ Usage: ogr2ogr [--help-general] [-skipfailures] [-append] [-update]
                [-select field_list] [-where restricted_where] 
                [-progress] [-sql <sql statement>] [-dialect dialect]
                [-preserve_fid] [-fid FID]
-               [-spat xmin ymin xmax ymax] [-geomfield field]
+               [-spat xmin ymin xmax ymax] [-spat_srs srs_def] [-geomfield field]
                [-a_srs srs_def] [-t_srs srs_def] [-s_srs srs_def]
                [-f format_name] [-overwrite] [[-dsco NAME=VALUE] ...]
                dst_datasource_name src_datasource_name
@@ -249,8 +249,10 @@ The resulting table/layer will be saved to the output.</dd>
 Starting with GDAL 1.10, the "SQLITE" dialect can also be used with any datasource.</dd>
 <dt> <b>-where</b><em> restricted_where</em>:</dt><dd> Attribute query (like SQL WHERE)</dd>
 <dt> <b>-skipfailures</b>:</dt><dd>Continue after a failure, skipping the failed feature.</dd>
-<dt> <b>-spat</b><em> xmin ymin xmax ymax</em>:</dt><dd> spatial query extents. Only features
+<dt> <b>-spat</b><em> xmin ymin xmax ymax</em>:</dt><dd> spatial query extents, in the
+SRS of the source layer(s) (or the one specified with -spat_srs). Only features
 whose geometry intersects the extents will be selected. The geometries will not be clipped unless -clipsrc is specified</dd>
+<dt> <b>-spat_srs</b><em> srs_def</em>:</dt><dd> (OGR >= 2.0) Override spatial filter SRS.</dd>
 <dt> <b>-geomfield</b> <i>field</i>:</dt><dd> (OGR >= 1.11) Name of the geometry field
 on which the spatial filter operates on.</dd>
 <dt> <b>-dsco</b> <em>NAME=VALUE</em>:</dt><dd> Dataset creation option (format specific)</dd>
diff --git a/apps/test_ogrsf.cpp b/apps/test_ogrsf.cpp
index 8608775..9fdf23e 100644
--- a/apps/test_ogrsf.cpp
+++ b/apps/test_ogrsf.cpp
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: test_ogrsf.cpp 28849 2015-04-05 14:05:18Z goatbar $
+ * $Id: test_ogrsf.cpp 29262 2015-05-29 09:28:38Z rouault $
  *
  * Project:  OpenGIS Simple Features Reference Implementation
  * Purpose:  Formal test harnass for OGRLayer implementations.
@@ -35,7 +35,7 @@
 #include "ogr_p.h"
 #include "commonutils.h"
 
-CPL_CVSID("$Id: test_ogrsf.cpp 28849 2015-04-05 14:05:18Z goatbar $");
+CPL_CVSID("$Id: test_ogrsf.cpp 29262 2015-05-29 09:28:38Z rouault $");
 
 int     bReadOnly = FALSE;
 int     bVerbose = TRUE;
@@ -2145,7 +2145,7 @@ static int TestSpatialFilter( OGRLayer *poLayer )
 /*      filter that doesn't include this feature, and test again.       */
 /************************************************************************/
 
-static int TestAttributeFilter( GDALDataset* poDS, OGRLayer *poLayer )
+static int TestAttributeFilter( CPL_UNUSED GDALDataset* poDS, OGRLayer *poLayer )
 
 {
     int bRet = TRUE;
diff --git a/frmts/gtiff/geotiff.cpp b/frmts/gtiff/geotiff.cpp
index 22dc7e4..99df074 100644
--- a/frmts/gtiff/geotiff.cpp
+++ b/frmts/gtiff/geotiff.cpp
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: geotiff.cpp 29228 2015-05-21 19:45:55Z rouault $
+ * $Id: geotiff.cpp 29257 2015-05-28 18:35:39Z rouault $
  *
  * Project:  GeoTIFF Driver
  * Purpose:  GDAL GeoTIFF support.
@@ -63,7 +63,7 @@
 #include "tiffiop.h"
 #endif
 
-CPL_CVSID("$Id: geotiff.cpp 29228 2015-05-21 19:45:55Z rouault $");
+CPL_CVSID("$Id: geotiff.cpp 29257 2015-05-28 18:35:39Z rouault $");
 
 #if SIZEOF_VOIDP == 4
 static int bGlobalStripIntegerOverflow = FALSE;
@@ -9470,8 +9470,7 @@ CPLErr GTiffDataset::OpenOffset( TIFF *hTIFFIn,
         // Lets treat large "one row" bitmaps using the scanline api.
         if( !TIFFIsTiled(hTIFF) 
             && nBlockYSize == nYSize 
-            && nYSize > 2000 
-            && bAllowRGBAInterface )
+            && nYSize > 2000 )
             bTreatAsSplitBitmap = TRUE;
     }
 
@@ -12517,7 +12516,7 @@ GTiffDataset::CreateCopy( const char * pszFilename, GDALDataset *poSrcDS,
         else
         {
             int iBand, j;
-            GByte* pabyScanline = (GByte *) CPLMalloc(TIFFScanlineSize(hTIFF));
+            GByte* pabyScanline = (GByte *) CPLMalloc(nXSize);
             eErr = CE_None;
             for(iBand=1;iBand<=nBands && eErr == CE_None;iBand++)
             {
diff --git a/frmts/jpeg/jpgdataset.cpp b/frmts/jpeg/jpgdataset.cpp
index 19fff42..60edbff 100644
--- a/frmts/jpeg/jpgdataset.cpp
+++ b/frmts/jpeg/jpgdataset.cpp
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: jpgdataset.cpp 29017 2015-04-25 19:32:11Z rouault $
+ * $Id: jpgdataset.cpp 29267 2015-05-29 20:47:00Z rouault $
  *
  * Project:  JPEG JFIF Driver
  * Purpose:  Implement GDAL JPEG Support based on IJG libjpeg.
@@ -57,7 +57,7 @@ typedef struct {
         GUInt32  tiff_diroff;    /* byte offset to first directory */
 } TIFFHeader;
 
-CPL_CVSID("$Id: jpgdataset.cpp 29017 2015-04-25 19:32:11Z rouault $");
+CPL_CVSID("$Id: jpgdataset.cpp 29267 2015-05-29 20:47:00Z rouault $");
 
 CPL_C_START
 #ifdef LIBJPEG_12_PATH 
@@ -1998,7 +1998,9 @@ CPLErr JPGDatasetCommon::IRasterIO( GDALRWFlag eRWFlag,
        (eBufType == GDT_Byte) && (GetDataPrecision() != 12) &&
        (pData != NULL) &&
        (panBandMap != NULL) &&
-       (panBandMap[0] == 1) && (panBandMap[1] == 2) && (panBandMap[2] == 3))
+       (panBandMap[0] == 1) && (panBandMap[1] == 2) && (panBandMap[2] == 3) &&
+       /* those color spaces need transformation to RGB */
+       GetOutColorSpace() != JCS_YCCK && GetOutColorSpace() != JCS_CMYK )
     {
         Restart();
         int y;
diff --git a/frmts/kea/keaband.h b/frmts/kea/keaband.h
index 2931e2d..24b556e 100644
--- a/frmts/kea/keaband.h
+++ b/frmts/kea/keaband.h
@@ -1,5 +1,5 @@
 /*
- * $Id: keaband.h 28011 2014-11-26 13:47:09Z rouault $
+ * $Id: keaband.h 29258 2015-05-28 22:08:43Z rouault $
  *  keaband.h
  *
  *  Created by Pete Bunting on 01/08/2012.
@@ -32,6 +32,9 @@
 #define KEABAND_H
 
 #include "gdal_pam.h"
+#if defined(USE_GCC_VISIBILITY_FLAG) && !defined(DllExport)
+#define DllExport CPL_DLL
+#endif
 #include "keadataset.h"
 
 class KEAOverview;
diff --git a/frmts/kea/keacopy.h b/frmts/kea/keacopy.h
index 24f9cd7..d2c6825 100644
--- a/frmts/kea/keacopy.h
+++ b/frmts/kea/keacopy.h
@@ -1,5 +1,5 @@
 /*
- * $Id: keacopy.h 28011 2014-11-26 13:47:09Z rouault $
+ * $Id: keacopy.h 29258 2015-05-28 22:08:43Z rouault $
  *  keacopy.h
  *
  *  Created by Pete Bunting on 01/08/2012.
@@ -31,6 +31,10 @@
 #ifndef KEACOPY_H
 #define KEACOPY_H
 
+#include "gdal_priv.h"
+#if defined(USE_GCC_VISIBILITY_FLAG) && !defined(DllExport)
+#define DllExport CPL_DLL
+#endif
 #include "libkea/KEAImageIO.h"
 
 bool KEACopyFile( GDALDataset *pDataset, kealib::KEAImageIO *pImageIO, GDALProgressFunc pfnProgress, void *pProgressData );
diff --git a/frmts/kea/keadataset.h b/frmts/kea/keadataset.h
index b46d466..836cfab 100644
--- a/frmts/kea/keadataset.h
+++ b/frmts/kea/keadataset.h
@@ -1,5 +1,5 @@
 /*
- * $Id: keadataset.h 28011 2014-11-26 13:47:09Z rouault $
+ * $Id: keadataset.h 29258 2015-05-28 22:08:43Z rouault $
  *  keadataset.h
  *
  *  Created by Pete Bunting on 01/08/2012.
@@ -32,6 +32,9 @@
 #define KEADATASET_H
 
 #include "gdal_pam.h"
+#if defined(USE_GCC_VISIBILITY_FLAG) && !defined(DllExport)
+#define DllExport CPL_DLL
+#endif
 #include "libkea/KEAImageIO.h"
 
 // class that implements a GDAL dataset
diff --git a/frmts/kea/keamaskband.h b/frmts/kea/keamaskband.h
index 20db9ed..06ce911 100644
--- a/frmts/kea/keamaskband.h
+++ b/frmts/kea/keamaskband.h
@@ -1,5 +1,5 @@
 /*
- * $Id: keamaskband.h 28011 2014-11-26 13:47:09Z rouault $
+ * $Id: keamaskband.h 29258 2015-05-28 22:08:43Z rouault $
  *  keamaskband.h
  *
  *  Created by Pete Bunting on 01/08/2012.
@@ -32,6 +32,9 @@
 #define KEAMASKBAND_H
 
 #include "gdal_priv.h"
+#if defined(USE_GCC_VISIBILITY_FLAG) && !defined(DllExport)
+#define DllExport CPL_DLL
+#endif
 #include "libkea/KEAImageIO.h"
 
 class KEAMaskBand : public GDALRasterBand
diff --git a/frmts/kea/keaoverview.h b/frmts/kea/keaoverview.h
index 70428e8..b3f8c2d 100644
--- a/frmts/kea/keaoverview.h
+++ b/frmts/kea/keaoverview.h
@@ -1,5 +1,5 @@
 /*
- * $Id: keaoverview.h 28011 2014-11-26 13:47:09Z rouault $
+ * $Id: keaoverview.h 29258 2015-05-28 22:08:43Z rouault $
  *  keaoverview.h
  *
  *  Created by Pete Bunting on 01/08/2012.
@@ -31,6 +31,10 @@
 #ifndef KEAOVERVIEW_H
 #define KEAOVERVIEW_H
 
+#include "cpl_port.h"
+#if defined(USE_GCC_VISIBILITY_FLAG) && !defined(DllExport)
+#define DllExport CPL_DLL
+#endif
 #include "keaband.h"
 
 // overview class. Derives from our band class
diff --git a/frmts/kea/kearat.h b/frmts/kea/kearat.h
index 47e5d8e..2213de1 100644
--- a/frmts/kea/kearat.h
+++ b/frmts/kea/kearat.h
@@ -1,5 +1,5 @@
 /*
- * $Id: kearat.h 28011 2014-11-26 13:47:09Z rouault $
+ * $Id: kearat.h 29258 2015-05-28 22:08:43Z rouault $
  *  kearat.h
  *
  *  Created by Pete Bunting on 01/08/2012.
@@ -33,6 +33,9 @@
 
 #include "gdal_priv.h"
 #include "gdal_rat.h"
+#if defined(USE_GCC_VISIBILITY_FLAG) && !defined(DllExport)
+#define DllExport CPL_DLL
+#endif
 #include "keaband.h"
 
 class KEARasterAttributeTable : public GDALRasterAttributeTable
diff --git a/frmts/kmlsuperoverlay/kmlsuperoverlaydataset.cpp b/frmts/kmlsuperoverlay/kmlsuperoverlaydataset.cpp
index c13ca09..860f9e7 100644
--- a/frmts/kmlsuperoverlay/kmlsuperoverlaydataset.cpp
+++ b/frmts/kmlsuperoverlay/kmlsuperoverlaydataset.cpp
@@ -1201,9 +1201,7 @@ CPLErr KmlSuperOverlayReadDataset::IRasterIO( GDALRWFlag eRWFlag,
                         }
                         else
                         {
-                            osSubFilename = CPLGetPath(pszBaseFilename);
-                            osSubFilename += "/";
-                            osSubFilename += pszHref;
+                            osSubFilename = CPLFormFilename(CPLGetPath(pszBaseFilename), pszHref, NULL);
                         }
                         osSubFilename = KMLRemoveSlash(osSubFilename);
                     }
@@ -1545,13 +1543,30 @@ int KmlSuperOverlayReadDataset::Identify(GDALOpenInfo * poOpenInfo)
 {
     const char* pszExt = CPLGetExtension(poOpenInfo->pszFilename);
     if( EQUAL(pszExt, "kmz") )
-        return TRUE;
+        return -1;
     if( poOpenInfo->nHeaderBytes == 0 )
         return FALSE;
-    if( EQUAL(pszExt, "kml") &&
-        strstr((const char*)poOpenInfo->pabyHeader, "<kml") != NULL )
-        return TRUE;
-    return FALSE;
+    if( !EQUAL(pszExt, "kml") ||
+        strstr((const char*)poOpenInfo->pabyHeader, "<kml") == NULL )
+        return FALSE;
+    
+    for( int i=0;i<2;i++ )
+    {
+        if( strstr((const char*)poOpenInfo->pabyHeader, "<NetworkLink>") != NULL &&
+            strstr((const char*)poOpenInfo->pabyHeader, "<Region>") != NULL &&
+            strstr((const char*)poOpenInfo->pabyHeader, "<Link>") != NULL )
+            return TRUE;
+        
+        if( strstr((const char*)poOpenInfo->pabyHeader, "<Document>") != NULL &&
+            strstr((const char*)poOpenInfo->pabyHeader, "<Region>") != NULL &&
+            strstr((const char*)poOpenInfo->pabyHeader, "<GroundOverlay>") != NULL )
+            return TRUE;
+
+        if( i == 0 && !poOpenInfo->TryToIngest(1024*10) )
+            return FALSE;
+    }
+    
+    return -1;
 }
 
 /************************************************************************/
@@ -1561,7 +1576,7 @@ int KmlSuperOverlayReadDataset::Identify(GDALOpenInfo * poOpenInfo)
 GDALDataset *KmlSuperOverlayReadDataset::Open(GDALOpenInfo * poOpenInfo)
 
 {
-    if( !Identify(poOpenInfo) )
+    if( Identify(poOpenInfo) == FALSE )
         return NULL;
 
     return Open(poOpenInfo->pszFilename);
@@ -1587,9 +1602,7 @@ GDALDataset* KmlSuperOverlayLoadIcon(const char* pszBaseFilename, const char* ps
         osSubFilename = CPLSPrintf("/vsicurl_streaming/%s", pszIcon);
     else
     {
-        osSubFilename = CPLGetPath(pszBaseFilename);
-        osSubFilename += "/";
-        osSubFilename += pszIcon;
+        osSubFilename = CPLFormFilename(CPLGetPath(pszBaseFilename), pszIcon, NULL);
         osSubFilename = KMLRemoveSlash(osSubFilename);
     }
 
@@ -1652,9 +1665,7 @@ static void KmlSuperOverlayComputeDepth(CPLString osFilename,
                     osSubFilename = CPLSPrintf("/vsicurl_streaming/%s", pszHref);
                 else
                 {
-                    osSubFilename = CPLGetPath(osFilename);
-                    osSubFilename += "/";
-                    osSubFilename += pszHref;
+                    osSubFilename = CPLFormFilename(CPLGetPath(osFilename), pszHref, NULL),
                     osSubFilename = KMLRemoveSlash(osSubFilename);
                 }
 
@@ -2324,9 +2335,7 @@ GDALDataset *KmlSuperOverlayReadDataset::Open(const char* pszFilename,
             osSubFilename = CPLSPrintf("/vsicurl_streaming/%s", pszHref);
         else
         {
-            osSubFilename = CPLGetPath(osFilename);
-            osSubFilename += "/";
-            osSubFilename += pszHref;
+            osSubFilename = CPLFormFilename(CPLGetPath(osFilename), pszHref, NULL);
             osSubFilename = KMLRemoveSlash(osSubFilename);
         }
 
diff --git a/frmts/nitf/rpftocfile.cpp b/frmts/nitf/rpftocfile.cpp
index 464d2f6..bc2cda2 100644
--- a/frmts/nitf/rpftocfile.cpp
+++ b/frmts/nitf/rpftocfile.cpp
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: rpftocfile.cpp 27044 2014-03-16 23:41:27Z rouault $
+ * $Id: rpftocfile.cpp 29260 2015-05-29 09:13:17Z rouault $
  *
  * Project:  RPF A.TOC read Library
  * Purpose:  Module responsible for opening a RPF TOC file, populating RPFToc
@@ -49,7 +49,7 @@
 #include "cpl_conv.h"
 #include "cpl_string.h"
 
-CPL_CVSID("$Id: rpftocfile.cpp 27044 2014-03-16 23:41:27Z rouault $");
+CPL_CVSID("$Id: rpftocfile.cpp 29260 2015-05-29 09:13:17Z rouault $");
 
 /************************************************************************/
 /*                        RPFTOCTrim()                                    */
@@ -497,10 +497,22 @@ RPFToc* RPFTOCReadFromBuffer(const char* pszFilename, VSILFILE* fp, const char*
         frameEntry->directory[pathLength] = 0;
         if (pathLength > 0 && frameEntry->directory[pathLength-1] == '/')
             frameEntry->directory[pathLength-1] = 0;
-        
+
         if (frameEntry->directory[0] == '.' && frameEntry->directory[1] == '/')
+        {
             memmove(frameEntry->directory, frameEntry->directory+2, strlen(frameEntry->directory+2)+1);
-        
+
+            // Some A.TOC have subdirectory names like ".//X/" ... (#5979)
+            // Check if it wasn't intended to be "./X/" instead
+            VSIStatBufL sStatBuf;
+            if( frameEntry->directory[0] == '/' &&
+                VSIStatL(CPLFormFilename(CPLGetDirname(pszFilename), frameEntry->directory+1, NULL), &sStatBuf) == 0 &&
+                VSI_ISDIR(sStatBuf.st_mode) )
+            {
+                memmove(frameEntry->directory, frameEntry->directory+1, strlen(frameEntry->directory+1)+1);
+            }
+        }
+
         {
             char* baseDir = CPLStrdup(CPLGetDirname(pszFilename));
             VSIStatBufL sStatBuf;
diff --git a/frmts/rasterlite/rasterlitedataset.cpp b/frmts/rasterlite/rasterlitedataset.cpp
index ee1076c..90f6913 100644
--- a/frmts/rasterlite/rasterlitedataset.cpp
+++ b/frmts/rasterlite/rasterlitedataset.cpp
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: rasterlitedataset.cpp 28027 2014-11-30 11:45:46Z rouault $
+ * $Id: rasterlitedataset.cpp 29265 2015-05-29 10:49:34Z rouault $
  *
  * Project:  GDAL Rasterlite driver
  * Purpose:  Implement GDAL Rasterlite support using OGR SQLite driver
@@ -34,7 +34,7 @@
 
 #include "rasterlitedataset.h"
 
-CPL_CVSID("$Id: rasterlitedataset.cpp 28027 2014-11-30 11:45:46Z rouault $");
+CPL_CVSID("$Id: rasterlitedataset.cpp 29265 2015-05-29 10:49:34Z rouault $");
 
 
 /************************************************************************/
@@ -933,7 +933,8 @@ int RasterliteDataset::Identify(GDALOpenInfo* poOpenInfo)
         poOpenInfo->nHeaderBytes >= 1024 &&
         EQUALN((const char*)poOpenInfo->pabyHeader, "SQLite Format 3", 15))
     {
-        return TRUE;
+        // Could be a SQLite/Spatialite file as well
+        return -1;
     }
     else if (EQUALN(poOpenInfo->pszFilename, "RASTERLITE:", 11))
     {
@@ -957,7 +958,7 @@ GDALDataset* RasterliteDataset::Open(GDALOpenInfo* poOpenInfo)
     int bMinXSet = FALSE, bMinYSet = FALSE, bMaxXSet = FALSE, bMaxYSet = FALSE;
     int nReqBands = 0;
 
-    if (!Identify(poOpenInfo))
+    if( Identify(poOpenInfo) == FALSE )
         return NULL;
 
 /* -------------------------------------------------------------------- */
diff --git a/frmts/raw/btdataset.cpp b/frmts/raw/btdataset.cpp
index 13581fb..0044a23 100644
--- a/frmts/raw/btdataset.cpp
+++ b/frmts/raw/btdataset.cpp
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: btdataset.cpp 27942 2014-11-11 00:57:41Z rouault $
+ * $Id: btdataset.cpp 29284 2015-06-03 13:26:10Z rouault $
  *
  * Project:  VTP .bt Driver
  * Purpose:  Implementation of VTP .bt elevation format read/write support.
@@ -32,7 +32,7 @@
 #include "rawdataset.h"
 #include "ogr_spatialref.h"
 
-CPL_CVSID("$Id: btdataset.cpp 27942 2014-11-11 00:57:41Z rouault $");
+CPL_CVSID("$Id: btdataset.cpp 29284 2015-06-03 13:26:10Z rouault $");
 
 CPL_C_START
 void    GDALRegister_BT(void);
diff --git a/frmts/vrt/vrtdataset.cpp b/frmts/vrt/vrtdataset.cpp
index 48beb5d..29a4431 100644
--- a/frmts/vrt/vrtdataset.cpp
+++ b/frmts/vrt/vrtdataset.cpp
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: vrtdataset.cpp 29192 2015-05-14 10:07:42Z rouault $
+ * $Id: vrtdataset.cpp 29294 2015-06-05 08:52:15Z rouault $
  *
  * Project:  Virtual GDAL Datasets
  * Purpose:  Implementation of VRTDataset
@@ -33,7 +33,7 @@
 #include "cpl_minixml.h"
 #include "ogr_spatialref.h"
 
-CPL_CVSID("$Id: vrtdataset.cpp 29192 2015-05-14 10:07:42Z rouault $");
+CPL_CVSID("$Id: vrtdataset.cpp 29294 2015-06-05 08:52:15Z rouault $");
 
 /************************************************************************/
 /*                            VRTDataset()                             */
@@ -1372,3 +1372,28 @@ CPLErr VRTDataset::IRasterIO( GDALRWFlag eRWFlag,
                                   nBandCount, panBandMap,
                                   nPixelSpace, nLineSpace, nBandSpace, psExtraArg);
 }
+
+/************************************************************************/
+/*                  UnsetPreservedRelativeFilenames()                   */
+/************************************************************************/
+
+void VRTDataset::UnsetPreservedRelativeFilenames()
+{
+    for(int iBand = 0; iBand < nBands; iBand++)
+    {
+        if (!((VRTRasterBand *) papoBands[iBand])->IsSourcedRasterBand())
+            continue;
+
+        VRTSourcedRasterBand* poBand = (VRTSourcedRasterBand* )papoBands[iBand];
+        int nSources = poBand->nSources;
+        VRTSource** papoSources = poBand->papoSources;
+        for(int iSource = 0; iSource < nSources; iSource++)
+        {
+            if (!papoSources[iSource]->IsSimpleSource())
+                continue;
+
+            VRTSimpleSource* poSource = (VRTSimpleSource* )papoSources[iSource];
+            poSource->UnsetPreservedRelativeFilenames();
+        }
+    }
+}
diff --git a/frmts/vrt/vrtdataset.h b/frmts/vrt/vrtdataset.h
index b7a81ea..cf45bef 100644
--- a/frmts/vrt/vrtdataset.h
+++ b/frmts/vrt/vrtdataset.h
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: vrtdataset.h 28899 2015-04-14 09:27:00Z rouault $
+ * $Id: vrtdataset.h 29294 2015-06-05 08:52:15Z rouault $
  *
  * Project:  Virtual GDAL Datasets
  * Purpose:  Declaration of virtual gdal dataset classes.
@@ -191,6 +191,8 @@ class CPL_DLL VRTDataset : public GDALDataset
 
     /* Used by PDF driver for example */
     GDALDataset*        GetSingleSimpleSource();
+    
+    void                UnsetPreservedRelativeFilenames();
  
     static int          Identify( GDALOpenInfo * );
     static GDALDataset *Open( GDALOpenInfo * );
@@ -606,6 +608,9 @@ protected:
     int                 bNoDataSet;
     double              dfNoDataValue;
     CPLString           osResampling;
+    
+    int                 bRelativeToVRTOri;
+    CPLString           osSourceFileNameOri;
 
 public:
             VRTSimpleSource();
@@ -669,6 +674,8 @@ public:
                                GSpacing nPixelSpace, GSpacing nLineSpace,
                                GSpacing nBandSpace,
                                GDALRasterIOExtraArg* psExtraArg);
+
+    void             UnsetPreservedRelativeFilenames();
 };
 
 /************************************************************************/
diff --git a/frmts/vrt/vrtdriver.cpp b/frmts/vrt/vrtdriver.cpp
index 89781ed..38f9523 100644
--- a/frmts/vrt/vrtdriver.cpp
+++ b/frmts/vrt/vrtdriver.cpp
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: vrtdriver.cpp 28979 2015-04-23 10:25:51Z rouault $
+ * $Id: vrtdriver.cpp 29294 2015-06-05 08:52:15Z rouault $
  *
  * Project:  Virtual GDAL Datasets
  * Purpose:  Implementation of VRTDriver
@@ -33,7 +33,7 @@
 #include "cpl_string.h"
 #include "gdal_alg_priv.h"
 
-CPL_CVSID("$Id: vrtdriver.cpp 28979 2015-04-23 10:25:51Z rouault $");
+CPL_CVSID("$Id: vrtdriver.cpp 29294 2015-06-05 08:52:15Z rouault $");
 
 /************************************************************************/
 /*                             VRTDriver()                              */
@@ -186,6 +186,7 @@ VRTCreateCopy( const char * pszFilename,
     /*      Convert tree to a single block of XML text.                     */
     /* -------------------------------------------------------------------- */
         char *pszVRTPath = CPLStrdup(CPLGetPath(pszFilename));
+        ((VRTDataset *) poSrcDS)->UnsetPreservedRelativeFilenames();
         CPLXMLNode *psDSTree = ((VRTDataset *) poSrcDS)->SerializeToXML( pszVRTPath );
 
         char *pszXML = CPLSerializeXMLTree( psDSTree );
diff --git a/frmts/vrt/vrtsources.cpp b/frmts/vrt/vrtsources.cpp
index 3ad8af2..7876c90 100644
--- a/frmts/vrt/vrtsources.cpp
+++ b/frmts/vrt/vrtsources.cpp
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: vrtsources.cpp 29204 2015-05-16 21:49:02Z rouault $
+ * $Id: vrtsources.cpp 29294 2015-06-05 08:52:15Z rouault $
  *
  * Project:  Virtual GDAL Datasets
  * Purpose:  Implementation of VRTSimpleSource, VRTFuncSource and 
@@ -43,7 +43,7 @@
 #define isnan std::isnan
 #endif
 
-CPL_CVSID("$Id: vrtsources.cpp 29204 2015-05-16 21:49:02Z rouault $");
+CPL_CVSID("$Id: vrtsources.cpp 29294 2015-06-05 08:52:15Z rouault $");
 
 /************************************************************************/
 /* ==================================================================== */
@@ -83,6 +83,7 @@ VRTSimpleSource::VRTSimpleSource()
     poMaskBandMainBand = NULL;
     bNoDataSet = FALSE;
     dfNoDataValue = VRT_NODATA_UNSET;
+    bRelativeToVRTOri = -1;
 }
 
 /************************************************************************/
@@ -112,6 +113,16 @@ VRTSimpleSource::~VRTSimpleSource()
 }
 
 /************************************************************************/
+/*                    UnsetPreservedRelativeFilenames()                 */
+/************************************************************************/
+
+void VRTSimpleSource::UnsetPreservedRelativeFilenames()
+{
+    bRelativeToVRTOri = -1;
+    osSourceFileNameOri = "";
+}
+
+/************************************************************************/
 /*                             SetSrcBand()                             */
 /************************************************************************/
 
@@ -230,7 +241,12 @@ CPLXMLNode *VRTSimpleSource::SerializeToXML( const char *pszVRTPath )
 
     VSIStatBufL sStat;
     CPLString osTmp;
-    if ( strstr(poDS->GetDescription(), "/vsicurl/http") != NULL ||
+    if( bRelativeToVRTOri >= 0 )
+    {
+        pszRelativePath = osSourceFileNameOri;
+        bRelativeToVRT = bRelativeToVRTOri;
+    }
+    else if ( strstr(poDS->GetDescription(), "/vsicurl/http") != NULL ||
          strstr(poDS->GetDescription(), "/vsicurl/ftp") != NULL )
     {
         /* Testing the existence of remote resources can be excruciating */
@@ -386,8 +402,13 @@ CPLErr VRTSimpleSource::XMLInit( CPLXMLNode *psSrc, const char *pszVRTPath )
         return CE_Failure;
     }
     
+    // Backup original filename and relativeToVRT so as to be able to
+    // serialize them identically again (#5985)
+    osSourceFileNameOri = pszFilename;
+    bRelativeToVRTOri = atoi(CPLGetXMLValue( psSourceFileNameNode, "relativetoVRT", "0"));
+    
     if( pszVRTPath != NULL
-        && atoi(CPLGetXMLValue( psSourceFileNameNode, "relativetoVRT", "0")) )
+        && bRelativeToVRTOri )
     {
         int bDone = FALSE;
         for( size_t i = 0; i < sizeof(apszSpecialSyntax) / sizeof(apszSpecialSyntax[0]); i ++)
diff --git a/gcore/gdal_priv.h b/gcore/gdal_priv.h
index 1f4940e..0ceb9db 100644
--- a/gcore/gdal_priv.h
+++ b/gcore/gdal_priv.h
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: gdal_priv.h 29097 2015-05-01 20:13:36Z rouault $
+ * $Id: gdal_priv.h 29284 2015-06-03 13:26:10Z rouault $
  *
  * Name:     gdal_priv.h
  * Project:  GDAL Core
@@ -350,6 +350,10 @@ class CPL_DLL GDALDataset : public GDALMajorObject
 
     friend class GDALRasterBand;
     
+    int                 EnterReadWrite(GDALRWFlag eRWFlag);
+    void                LeaveReadWrite();
+    
+    
   public:
     virtual     ~GDALDataset();
 
@@ -639,7 +643,7 @@ class CPL_DLL GDALRasterBand : public GDALMajorObject
     GDALRasterBand *poMask;
     bool        bOwnMask;
     int         nMaskFlags;
-    
+
     void        InvalidateMaskBand();
 
     friend class GDALDataset;
@@ -649,6 +653,10 @@ class CPL_DLL GDALRasterBand : public GDALMajorObject
     CPLErr RasterIOResampled( GDALRWFlag, int, int, int, int,
                               void *, int, int, GDALDataType,
                               GSpacing, GSpacing, GDALRasterIOExtraArg* psExtraArg );
+
+    int          EnterReadWrite(GDALRWFlag eRWFlag);
+    void         LeaveReadWrite();
+
   protected:
     virtual CPLErr IReadBlock( int, int, void * ) = 0;
     virtual CPLErr IWriteBlock( int, int, void * );
diff --git a/gcore/gdal_version.h b/gcore/gdal_version.h
index fbae6a9..bb85ef6 100644
--- a/gcore/gdal_version.h
+++ b/gcore/gdal_version.h
@@ -22,8 +22,8 @@
 #endif
 
 #ifndef GDAL_RELEASE_DATE
-#  define GDAL_RELEASE_DATE     20150525
+#  define GDAL_RELEASE_DATE     20150605
 #endif
 #ifndef GDAL_RELEASE_NAME
-#  define GDAL_RELEASE_NAME     "2.0.0beta2"
+#  define GDAL_RELEASE_NAME     "2.0.0"
 #endif
diff --git a/gcore/gdaldataset.cpp b/gcore/gdaldataset.cpp
index 5c78fca..574313a 100644
--- a/gcore/gdaldataset.cpp
+++ b/gcore/gdaldataset.cpp
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: gdaldataset.cpp 29161 2015-05-06 10:18:19Z rouault $
+ * $Id: gdaldataset.cpp 29284 2015-06-03 13:26:10Z rouault $
  *
  * Project:  GDAL Core
  * Purpose:  Base class for raster file formats.  
@@ -46,7 +46,7 @@
 
 #include <map>
 
-CPL_CVSID("$Id: gdaldataset.cpp 29161 2015-05-06 10:18:19Z rouault $");
+CPL_CVSID("$Id: gdaldataset.cpp 29284 2015-06-03 13:26:10Z rouault $");
 
 CPL_C_START
 GDALAsyncReader *
@@ -1801,6 +1801,8 @@ CPLErr GDALDataset::RasterIO( GDALRWFlag eRWFlag,
     }
 
 
+    int bCallLeaveReadWrite = EnterReadWrite(eRWFlag);
+
 /* -------------------------------------------------------------------- */
 /*      We are being forced to use cached IO instead of a driver        */
 /*      specific implementation.                                        */
@@ -1828,6 +1830,8 @@ CPLErr GDALDataset::RasterIO( GDALRWFlag eRWFlag,
                        psExtraArg );
     }
 
+    if( bCallLeaveReadWrite ) LeaveReadWrite();
+
 /* -------------------------------------------------------------------- */
 /*      Cleanup                                                         */
 /* -------------------------------------------------------------------- */
@@ -2554,7 +2558,9 @@ GDALDatasetH CPL_STDCALL GDALOpenEx( const char* pszFilename,
             oOpenInfo.papszOpenOptions = papszTmpOpenOptions;
         }
 
-        if( poDriver->pfnIdentify && poDriver->pfnIdentify(&oOpenInfo) > 0 )
+        int bIdentifyRes =
+            ( poDriver->pfnIdentify && poDriver->pfnIdentify(&oOpenInfo) > 0 );
+        if( bIdentifyRes )
         {
             GDALValidateOpenOptions( poDriver, oOpenInfo.papszOpenOptions );
         }
@@ -2562,6 +2568,10 @@ GDALDatasetH CPL_STDCALL GDALOpenEx( const char* pszFilename,
         if ( poDriver->pfnOpen != NULL )
         {
             poDS = poDriver->pfnOpen( &oOpenInfo );
+            // If we couldn't determine for sure with Identify() (it returned -1)
+            // but that Open() managed to open the file, post validate options.
+            if( poDS != NULL && poDriver->pfnIdentify && !bIdentifyRes )
+                GDALValidateOpenOptions( poDriver, oOpenInfo.papszOpenOptions );
         }
         else if( poDriver->pfnOpenWithDriverArg != NULL )
         {
@@ -5725,3 +5735,26 @@ OGRErr GDALDatasetRollbackTransaction(GDALDatasetH hDS)
 
     return ((GDALDataset*) hDS)->RollbackTransaction();
 }
+
+/************************************************************************/
+/*                          EnterReadWrite()                            */
+/************************************************************************/
+
+int GDALDataset::EnterReadWrite(GDALRWFlag eRWFlag)
+{
+    if( eAccess == GA_Update && (eRWFlag == GF_Write || m_hMutex != NULL) )
+    {
+        CPLCreateOrAcquireMutex(&m_hMutex, 1000.0);
+        return TRUE;
+    }
+    return FALSE;
+}
+
+/************************************************************************/
+/*                         LeaveReadWrite()                             */
+/************************************************************************/
+
+void GDALDataset::LeaveReadWrite()
+{
+    CPLReleaseMutex(m_hMutex);
+}
diff --git a/gcore/gdalrasterband.cpp b/gcore/gdalrasterband.cpp
index 2d730bc..2305a49 100644
--- a/gcore/gdalrasterband.cpp
+++ b/gcore/gdalrasterband.cpp
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: gdalrasterband.cpp 28899 2015-04-14 09:27:00Z rouault $
+ * $Id: gdalrasterband.cpp 29284 2015-06-03 13:26:10Z rouault $
  *
  * Project:  GDAL Core
  * Purpose:  Base class for format specific band class implementation.  This
@@ -37,7 +37,7 @@
 #define TO_SUBBLOCK(x) ((x) >> 6)
 #define WITHIN_SUBBLOCK(x) ((x) & 0x3f)
 
-CPL_CVSID("$Id: gdalrasterband.cpp 28899 2015-04-14 09:27:00Z rouault $");
+CPL_CVSID("$Id: gdalrasterband.cpp 29284 2015-06-03 13:26:10Z rouault $");
 
 /************************************************************************/
 /*                           GDALRasterBand()                           */
@@ -266,14 +266,22 @@ CPLErr GDALRasterBand::RasterIO( GDALRWFlag eRWFlag,
 /* -------------------------------------------------------------------- */
 /*      Call the format specific function.                              */
 /* -------------------------------------------------------------------- */
+    CPLErr eErr;
+
+    int bCallLeaveReadWrite = EnterReadWrite(eRWFlag);
+
     if( bForceCachedIO )
-        return GDALRasterBand::IRasterIO(eRWFlag, nXOff, nYOff, nXSize, nYSize,
+        eErr = GDALRasterBand::IRasterIO(eRWFlag, nXOff, nYOff, nXSize, nYSize,
                                          pData, nBufXSize, nBufYSize, eBufType,
                                          nPixelSpace, nLineSpace, psExtraArg );
     else
-        return IRasterIO( eRWFlag, nXOff, nYOff, nXSize, nYSize,
+        eErr = IRasterIO( eRWFlag, nXOff, nYOff, nXSize, nYSize,
                           pData, nBufXSize, nBufYSize, eBufType,
                           nPixelSpace, nLineSpace, psExtraArg ) ;
+
+    if( bCallLeaveReadWrite) LeaveReadWrite();
+
+    return eErr;
 }
 
 /************************************************************************/
@@ -456,7 +464,10 @@ CPLErr GDALRasterBand::ReadBlock( int nXBlockOff, int nYBlockOff,
 /* -------------------------------------------------------------------- */
 /*      Invoke underlying implementation method.                        */
 /* -------------------------------------------------------------------- */
-    return( IReadBlock( nXBlockOff, nYBlockOff, pImage ) );
+    int bCallLeaveReadWrite = EnterReadWrite(GF_Read);
+    CPLErr eErr = IReadBlock( nXBlockOff, nYBlockOff, pImage );
+    if( bCallLeaveReadWrite) LeaveReadWrite();
+    return eErr;
 }
 
 /************************************************************************/
@@ -577,7 +588,12 @@ CPLErr GDALRasterBand::WriteBlock( int nXBlockOff, int nYBlockOff,
 /* -------------------------------------------------------------------- */
 /*      Invoke underlying implementation method.                        */
 /* -------------------------------------------------------------------- */
-    return( IWriteBlock( nXBlockOff, nYBlockOff, pImage ) );
+
+    int bCallLeaveReadWrite = EnterReadWrite(GF_Write);
+    CPLErr eErr = IWriteBlock( nXBlockOff, nYBlockOff, pImage );
+    if( bCallLeaveReadWrite ) LeaveReadWrite();
+
+    return eErr;
 }
 
 /************************************************************************/
@@ -1449,6 +1465,8 @@ CPLErr GDALRasterBand::Fill(double dfRealValue, double dfImaginaryValue) {
     GDALCopyWords(complexSrc, GDT_CFloat64, 0,
                   srcBlock, eDataType, elementSize, blockSize);
 
+    int bCallLeaveReadWrite = EnterReadWrite(GF_Write);
+
     // Write block to block cache
     for (int j = 0; j < nBlocksPerColumn; ++j) {
 	for (int i = 0; i < nBlocksPerRow; ++i) {
@@ -1471,6 +1489,8 @@ CPLErr GDALRasterBand::Fill(double dfRealValue, double dfImaginaryValue) {
             destBlock->DropLock();
 	}
     }
+    
+    if( bCallLeaveReadWrite ) LeaveReadWrite();
 
     // Free up the source block
     VSIFree(srcBlock);
@@ -5410,3 +5430,25 @@ CPLVirtualMem * GDALGetVirtualMemAuto( GDALRasterBandH hBand,
     return poBand->GetVirtualMemAuto(eRWFlag, pnPixelSpace,
                                      pnLineSpace, papszOptions);
 }
+
+
+/************************************************************************/
+/*                          EnterReadWrite()                            */
+/************************************************************************/
+
+int GDALRasterBand::EnterReadWrite(GDALRWFlag eRWFlag)
+{
+    if( poDS != NULL )
+        return poDS->EnterReadWrite(eRWFlag);
+    return FALSE;
+}
+
+/************************************************************************/
+/*                         LeaveReadWrite()                             */
+/************************************************************************/
+
+void GDALRasterBand::LeaveReadWrite()
+{
+    if( poDS != NULL )
+        poDS->LeaveReadWrite();
+}
diff --git a/gcore/gdalrasterblock.cpp b/gcore/gdalrasterblock.cpp
index 16fe4e3..d665a88 100644
--- a/gcore/gdalrasterblock.cpp
+++ b/gcore/gdalrasterblock.cpp
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: gdalrasterblock.cpp 28894 2015-04-13 14:55:20Z rouault $
+ * $Id: gdalrasterblock.cpp 29284 2015-06-03 13:26:10Z rouault $
  *
  * Project:  GDAL Core
  * Purpose:  Implementation of GDALRasterBlock class and related global 
@@ -32,7 +32,7 @@
 #include "gdal_priv.h"
 #include "cpl_multiproc.h"
 
-CPL_CVSID("$Id: gdalrasterblock.cpp 28894 2015-04-13 14:55:20Z rouault $");
+CPL_CVSID("$Id: gdalrasterblock.cpp 29284 2015-06-03 13:26:10Z rouault $");
 
 static int bCacheMaxInitialized = FALSE;
 static GIntBig nCacheMax = 40 * 1024*1024;
@@ -371,11 +371,6 @@ int GDALRasterBlock::FlushCacheBlock(int bDirtyBlocksOnly)
         poTarget->GetBand()->UnreferenceBlock(poTarget->GetXOff(),poTarget->GetYOff());
     }
 
-    /* Note: flushing dirty blocks to disk is not really safe */
-    /* if the underlying dataset is being read/written by another thread */
-    /* This issue has always existed and has no obvious fix */
-    /* So only read-only operations should be considered thread-safe with */
-    /* the global cache */
     if( poTarget->GetDirty() )
     {
         CPLErr eErr = poTarget->Write();
@@ -599,7 +594,12 @@ CPLErr GDALRasterBlock::Write()
     MarkClean();
 
     if (poBand->eFlushBlockErr == CE_None)
-        return poBand->IWriteBlock( nXOff, nYOff, pData );
+    {
+        int bCallLeaveReadWrite = poBand->EnterReadWrite(GF_Write);
+        CPLErr eErr = poBand->IWriteBlock( nXOff, nYOff, pData );
+        if( bCallLeaveReadWrite ) poBand->LeaveReadWrite();
+        return eErr;
+    }
     else
         return poBand->eFlushBlockErr;
 }
@@ -745,11 +745,6 @@ CPLErr GDALRasterBlock::Internalize()
     {
         GDALRasterBlock *poBlock = apoBlocksToFree[i];
 
-        /* Note: flushing dirty blocks to disk is not really safe */
-        /* if the underlying dataset is being read/written by another thread */
-        /* This issue has always existed and has no obvious fix */
-        /* So only read-only operations should be considered thread-safe with */
-        /* the global cache */
         if( poBlock->GetDirty() )
         {
             CPLErr eErr = poBlock->Write();
diff --git a/man/man1/gdal-config.1 b/man/man1/gdal-config.1
index 34f17ba..7f9ee46 100644
--- a/man/man1/gdal-config.1
+++ b/man/man1/gdal-config.1
@@ -1,8 +1,8 @@
-.TH "gdal-config" 1 "Mon May 25 2015" "GDAL" \" -*- nroff -*-
+.TH "gdal-config" 1 "Fri Jun 5 2015" "GDAL" \" -*- nroff -*-
 .ad l
 .nh
 .SH NAME
-gdal-config \- .TH "gdal-config" 1 "Mon May 25 2015" "GDAL" \" -*- nroff -*-
+gdal-config \- .TH "gdal-config" 1 "Fri Jun 5 2015" "GDAL" \" -*- nroff -*-
 .ad l
 .nh
 .SH NAME
diff --git a/man/man1/gdal2tiles.1 b/man/man1/gdal2tiles.1
index 894be80..092f702 100644
--- a/man/man1/gdal2tiles.1
+++ b/man/man1/gdal2tiles.1
@@ -1,8 +1,8 @@
-.TH "gdal2tiles" 1 "Mon May 25 2015" "GDAL" \" -*- nroff -*-
+.TH "gdal2tiles" 1 "Fri Jun 5 2015" "GDAL" \" -*- nroff -*-
 .ad l
 .nh
 .SH NAME
-gdal2tiles \- .TH "gdal2tiles" 1 "Mon May 25 2015" "GDAL" \" -*- nroff -*-
+gdal2tiles \- .TH "gdal2tiles" 1 "Fri Jun 5 2015" "GDAL" \" -*- nroff -*-
 .ad l
 .nh
 .SH NAME
diff --git a/man/man1/gdal_calc.1 b/man/man1/gdal_calc.1
index 3666875..ac0a61e 100644
--- a/man/man1/gdal_calc.1
+++ b/man/man1/gdal_calc.1
@@ -1,8 +1,8 @@
-.TH "gdal_calc" 1 "Mon May 25 2015" "GDAL" \" -*- nroff -*-
+.TH "gdal_calc" 1 "Fri Jun 5 2015" "GDAL" \" -*- nroff -*-
 .ad l
 .nh
 .SH NAME
-gdal_calc \- .TH "gdal_calc" 1 "Mon May 25 2015" "GDAL" \" -*- nroff -*-
+gdal_calc \- .TH "gdal_calc" 1 "Fri Jun 5 2015" "GDAL" \" -*- nroff -*-
 .ad l
 .nh
 .SH NAME
diff --git a/man/man1/gdal_contour.1 b/man/man1/gdal_contour.1
index 58f5927..ffd5cd5 100644
--- a/man/man1/gdal_contour.1
+++ b/man/man1/gdal_contour.1
@@ -1,8 +1,8 @@
-.TH "gdal_contour" 1 "Mon May 25 2015" "GDAL" \" -*- nroff -*-
+.TH "gdal_contour" 1 "Fri Jun 5 2015" "GDAL" \" -*- nroff -*-
 .ad l
 .nh
 .SH NAME
-gdal_contour \- .TH "gdal_contour" 1 "Mon May 25 2015" "GDAL" \" -*- nroff -*-
+gdal_contour \- .TH "gdal_contour" 1 "Fri Jun 5 2015" "GDAL" \" -*- nroff -*-
 .ad l
 .nh
 .SH NAME
diff --git a/man/man1/gdal_edit.1 b/man/man1/gdal_edit.1
index 7918829..657507d 100644
--- a/man/man1/gdal_edit.1
+++ b/man/man1/gdal_edit.1
@@ -1,8 +1,8 @@
-.TH "gdal_edit" 1 "Mon May 25 2015" "GDAL" \" -*- nroff -*-
+.TH "gdal_edit" 1 "Fri Jun 5 2015" "GDAL" \" -*- nroff -*-
 .ad l
 .nh
 .SH NAME
-gdal_edit \- .TH "gdal_edit" 1 "Mon May 25 2015" "GDAL" \" -*- nroff -*-
+gdal_edit \- .TH "gdal_edit" 1 "Fri Jun 5 2015" "GDAL" \" -*- nroff -*-
 .ad l
 .nh
 .SH NAME
diff --git a/man/man1/gdal_fillnodata.1 b/man/man1/gdal_fillnodata.1
index ff1e4a4..48f604b 100644
--- a/man/man1/gdal_fillnodata.1
+++ b/man/man1/gdal_fillnodata.1
@@ -1,8 +1,8 @@
-.TH "gdal_fillnodata" 1 "Mon May 25 2015" "GDAL" \" -*- nroff -*-
+.TH "gdal_fillnodata" 1 "Fri Jun 5 2015" "GDAL" \" -*- nroff -*-
 .ad l
 .nh
 .SH NAME
-gdal_fillnodata \- .TH "gdal_fillnodata" 1 "Mon May 25 2015" "GDAL" \" -*- nroff -*-
+gdal_fillnodata \- .TH "gdal_fillnodata" 1 "Fri Jun 5 2015" "GDAL" \" -*- nroff -*-
 .ad l
 .nh
 .SH NAME
diff --git a/man/man1/gdal_grid.1 b/man/man1/gdal_grid.1
index 8d7dadf..5bacc87 100644
--- a/man/man1/gdal_grid.1
+++ b/man/man1/gdal_grid.1
@@ -1,8 +1,8 @@
-.TH "gdal_grid" 1 "Mon May 25 2015" "GDAL" \" -*- nroff -*-
+.TH "gdal_grid" 1 "Fri Jun 5 2015" "GDAL" \" -*- nroff -*-
 .ad l
 .nh
 .SH NAME
-gdal_grid \- .TH "gdal_grid" 1 "Mon May 25 2015" "GDAL" \" -*- nroff -*-
+gdal_grid \- .TH "gdal_grid" 1 "Fri Jun 5 2015" "GDAL" \" -*- nroff -*-
 .ad l
 .nh
 .SH NAME
diff --git a/man/man1/gdal_merge.1 b/man/man1/gdal_merge.1
index acbe2a5..1a2edb9 100644
--- a/man/man1/gdal_merge.1
+++ b/man/man1/gdal_merge.1
@@ -1,8 +1,8 @@
-.TH "gdal_merge" 1 "Mon May 25 2015" "GDAL" \" -*- nroff -*-
+.TH "gdal_merge" 1 "Fri Jun 5 2015" "GDAL" \" -*- nroff -*-
 .ad l
 .nh
 .SH NAME
-gdal_merge \- .TH "gdal_merge" 1 "Mon May 25 2015" "GDAL" \" -*- nroff -*-
+gdal_merge \- .TH "gdal_merge" 1 "Fri Jun 5 2015" "GDAL" \" -*- nroff -*-
 .ad l
 .nh
 .SH NAME
diff --git a/man/man1/gdal_polygonize.1 b/man/man1/gdal_polygonize.1
index 8aac1d4..ffc9a23 100644
--- a/man/man1/gdal_polygonize.1
+++ b/man/man1/gdal_polygonize.1
@@ -1,8 +1,8 @@
-.TH "gdal_polygonize" 1 "Mon May 25 2015" "GDAL" \" -*- nroff -*-
+.TH "gdal_polygonize" 1 "Fri Jun 5 2015" "GDAL" \" -*- nroff -*-
 .ad l
 .nh
 .SH NAME
-gdal_polygonize \- .TH "gdal_polygonize" 1 "Mon May 25 2015" "GDAL" \" -*- nroff -*-
+gdal_polygonize \- .TH "gdal_polygonize" 1 "Fri Jun 5 2015" "GDAL" \" -*- nroff -*-
 .ad l
 .nh
 .SH NAME
diff --git a/man/man1/gdal_proximity.1 b/man/man1/gdal_proximity.1
index c8b1c6a..c165086 100644
--- a/man/man1/gdal_proximity.1
+++ b/man/man1/gdal_proximity.1
@@ -1,8 +1,8 @@
-.TH "gdal_proximity" 1 "Mon May 25 2015" "GDAL" \" -*- nroff -*-
+.TH "gdal_proximity" 1 "Fri Jun 5 2015" "GDAL" \" -*- nroff -*-
 .ad l
 .nh
 .SH NAME
-gdal_proximity \- .TH "gdal_proximity" 1 "Mon May 25 2015" "GDAL" \" -*- nroff -*-
+gdal_proximity \- .TH "gdal_proximity" 1 "Fri Jun 5 2015" "GDAL" \" -*- nroff -*-
 .ad l
 .nh
 .SH NAME
diff --git a/man/man1/gdal_rasterize.1 b/man/man1/gdal_rasterize.1
index 0e4bc60..6b756f1 100644
--- a/man/man1/gdal_rasterize.1
+++ b/man/man1/gdal_rasterize.1
@@ -1,8 +1,8 @@
-.TH "gdal_rasterize" 1 "Mon May 25 2015" "GDAL" \" -*- nroff -*-
+.TH "gdal_rasterize" 1 "Fri Jun 5 2015" "GDAL" \" -*- nroff -*-
 .ad l
 .nh
 .SH NAME
-gdal_rasterize \- .TH "gdal_rasterize" 1 "Mon May 25 2015" "GDAL" \" -*- nroff -*-
+gdal_rasterize \- .TH "gdal_rasterize" 1 "Fri Jun 5 2015" "GDAL" \" -*- nroff -*-
 .ad l
 .nh
 .SH NAME
diff --git a/man/man1/gdal_retile.1 b/man/man1/gdal_retile.1
index 1c483c6..331b6f1 100644
--- a/man/man1/gdal_retile.1
+++ b/man/man1/gdal_retile.1
@@ -1,8 +1,8 @@
-.TH "gdal_retile" 1 "Mon May 25 2015" "GDAL" \" -*- nroff -*-
+.TH "gdal_retile" 1 "Fri Jun 5 2015" "GDAL" \" -*- nroff -*-
 .ad l
 .nh
 .SH NAME
-gdal_retile \- .TH "gdal_retile" 1 "Mon May 25 2015" "GDAL" \" -*- nroff -*-
+gdal_retile \- .TH "gdal_retile" 1 "Fri Jun 5 2015" "GDAL" \" -*- nroff -*-
 .ad l
 .nh
 .SH NAME
diff --git a/man/man1/gdal_sieve.1 b/man/man1/gdal_sieve.1
index f365756..c5eed23 100644
--- a/man/man1/gdal_sieve.1
+++ b/man/man1/gdal_sieve.1
@@ -1,8 +1,8 @@
-.TH "gdal_sieve" 1 "Mon May 25 2015" "GDAL" \" -*- nroff -*-
+.TH "gdal_sieve" 1 "Fri Jun 5 2015" "GDAL" \" -*- nroff -*-
 .ad l
 .nh
 .SH NAME
-gdal_sieve \- .TH "gdal_sieve" 1 "Mon May 25 2015" "GDAL" \" -*- nroff -*-
+gdal_sieve \- .TH "gdal_sieve" 1 "Fri Jun 5 2015" "GDAL" \" -*- nroff -*-
 .ad l
 .nh
 .SH NAME
diff --git a/man/man1/gdal_translate.1 b/man/man1/gdal_translate.1
index 4217870..9c1eb24 100644
--- a/man/man1/gdal_translate.1
+++ b/man/man1/gdal_translate.1
@@ -1,8 +1,8 @@
-.TH "gdal_translate" 1 "Mon May 25 2015" "GDAL" \" -*- nroff -*-
+.TH "gdal_translate" 1 "Fri Jun 5 2015" "GDAL" \" -*- nroff -*-
 .ad l
 .nh
 .SH NAME
-gdal_translate \- .TH "gdal_translate" 1 "Mon May 25 2015" "GDAL" \" -*- nroff -*-
+gdal_translate \- .TH "gdal_translate" 1 "Fri Jun 5 2015" "GDAL" \" -*- nroff -*-
 .ad l
 .nh
 .SH NAME
diff --git a/man/man1/gdal_utilities.1 b/man/man1/gdal_utilities.1
index 0b34f67..a85b555 100644
--- a/man/man1/gdal_utilities.1
+++ b/man/man1/gdal_utilities.1
@@ -1,8 +1,8 @@
-.TH "gdal_utilities" 1 "Mon May 25 2015" "GDAL" \" -*- nroff -*-
+.TH "gdal_utilities" 1 "Fri Jun 5 2015" "GDAL" \" -*- nroff -*-
 .ad l
 .nh
 .SH NAME
-gdal_utilities \- .TH "gdal_utilities" 1 "Mon May 25 2015" "GDAL" \" -*- nroff -*-
+gdal_utilities \- .TH "gdal_utilities" 1 "Fri Jun 5 2015" "GDAL" \" -*- nroff -*-
 .ad l
 .nh
 .SH NAME
diff --git a/man/man1/gdaladdo.1 b/man/man1/gdaladdo.1
index 65aa395..805ed35 100644
--- a/man/man1/gdaladdo.1
+++ b/man/man1/gdaladdo.1
@@ -1,8 +1,8 @@
-.TH "gdaladdo" 1 "Mon May 25 2015" "GDAL" \" -*- nroff -*-
+.TH "gdaladdo" 1 "Fri Jun 5 2015" "GDAL" \" -*- nroff -*-
 .ad l
 .nh
 .SH NAME
-gdaladdo \- .TH "gdaladdo" 1 "Mon May 25 2015" "GDAL" \" -*- nroff -*-
+gdaladdo \- .TH "gdaladdo" 1 "Fri Jun 5 2015" "GDAL" \" -*- nroff -*-
 .ad l
 .nh
 .SH NAME
diff --git a/man/man1/gdalbuildvrt.1 b/man/man1/gdalbuildvrt.1
index 1b7721b..c9b21d4 100644
--- a/man/man1/gdalbuildvrt.1
+++ b/man/man1/gdalbuildvrt.1
@@ -1,8 +1,8 @@
-.TH "gdalbuildvrt" 1 "Mon May 25 2015" "GDAL" \" -*- nroff -*-
+.TH "gdalbuildvrt" 1 "Fri Jun 5 2015" "GDAL" \" -*- nroff -*-
 .ad l
 .nh
 .SH NAME
-gdalbuildvrt \- .TH "gdalbuildvrt" 1 "Mon May 25 2015" "GDAL" \" -*- nroff -*-
+gdalbuildvrt \- .TH "gdalbuildvrt" 1 "Fri Jun 5 2015" "GDAL" \" -*- nroff -*-
 .ad l
 .nh
 .SH NAME
diff --git a/man/man1/gdalcompare.1 b/man/man1/gdalcompare.1
index 46d3245..d39fca4 100644
--- a/man/man1/gdalcompare.1
+++ b/man/man1/gdalcompare.1
@@ -1,8 +1,8 @@
-.TH "gdalcompare" 1 "Mon May 25 2015" "GDAL" \" -*- nroff -*-
+.TH "gdalcompare" 1 "Fri Jun 5 2015" "GDAL" \" -*- nroff -*-
 .ad l
 .nh
 .SH NAME
-gdalcompare \- .TH "gdalcompare" 1 "Mon May 25 2015" "GDAL" \" -*- nroff -*-
+gdalcompare \- .TH "gdalcompare" 1 "Fri Jun 5 2015" "GDAL" \" -*- nroff -*-
 .ad l
 .nh
 .SH NAME
diff --git a/man/man1/gdaldem.1 b/man/man1/gdaldem.1
index 3a36aae..8b5304d 100644
--- a/man/man1/gdaldem.1
+++ b/man/man1/gdaldem.1
@@ -1,8 +1,8 @@
-.TH "gdaldem" 1 "Mon May 25 2015" "GDAL" \" -*- nroff -*-
+.TH "gdaldem" 1 "Fri Jun 5 2015" "GDAL" \" -*- nroff -*-
 .ad l
 .nh
 .SH NAME
-gdaldem \- .TH "gdaldem" 1 "Mon May 25 2015" "GDAL" \" -*- nroff -*-
+gdaldem \- .TH "gdaldem" 1 "Fri Jun 5 2015" "GDAL" \" -*- nroff -*-
 .ad l
 .nh
 .SH NAME
diff --git a/man/man1/gdalinfo.1 b/man/man1/gdalinfo.1
index 2535790..d74cbd1 100644
--- a/man/man1/gdalinfo.1
+++ b/man/man1/gdalinfo.1
@@ -1,8 +1,8 @@
-.TH "gdalinfo" 1 "Mon May 25 2015" "GDAL" \" -*- nroff -*-
+.TH "gdalinfo" 1 "Fri Jun 5 2015" "GDAL" \" -*- nroff -*-
 .ad l
 .nh
 .SH NAME
-gdalinfo \- .TH "gdalinfo" 1 "Mon May 25 2015" "GDAL" \" -*- nroff -*-
+gdalinfo \- .TH "gdalinfo" 1 "Fri Jun 5 2015" "GDAL" \" -*- nroff -*-
 .ad l
 .nh
 .SH NAME
diff --git a/man/man1/gdallocationinfo.1 b/man/man1/gdallocationinfo.1
index a7b523b..87ace96 100644
--- a/man/man1/gdallocationinfo.1
+++ b/man/man1/gdallocationinfo.1
@@ -1,8 +1,8 @@
-.TH "gdallocationinfo" 1 "Mon May 25 2015" "GDAL" \" -*- nroff -*-
+.TH "gdallocationinfo" 1 "Fri Jun 5 2015" "GDAL" \" -*- nroff -*-
 .ad l
 .nh
 .SH NAME
-gdallocationinfo \- .TH "gdallocationinfo" 1 "Mon May 25 2015" "GDAL" \" -*- nroff -*-
+gdallocationinfo \- .TH "gdallocationinfo" 1 "Fri Jun 5 2015" "GDAL" \" -*- nroff -*-
 .ad l
 .nh
 .SH NAME
diff --git a/man/man1/gdalmanage.1 b/man/man1/gdalmanage.1
index 4f4fd5d..268fcda 100644
--- a/man/man1/gdalmanage.1
+++ b/man/man1/gdalmanage.1
@@ -1,8 +1,8 @@
-.TH "gdalmanage" 1 "Mon May 25 2015" "GDAL" \" -*- nroff -*-
+.TH "gdalmanage" 1 "Fri Jun 5 2015" "GDAL" \" -*- nroff -*-
 .ad l
 .nh
 .SH NAME
-gdalmanage \- .TH "gdalmanage" 1 "Mon May 25 2015" "GDAL" \" -*- nroff -*-
+gdalmanage \- .TH "gdalmanage" 1 "Fri Jun 5 2015" "GDAL" \" -*- nroff -*-
 .ad l
 .nh
 .SH NAME
diff --git a/man/man1/gdalmove.1 b/man/man1/gdalmove.1
index dedde99..f87b3da 100644
--- a/man/man1/gdalmove.1
+++ b/man/man1/gdalmove.1
@@ -1,8 +1,8 @@
-.TH "gdalmove" 1 "Mon May 25 2015" "GDAL" \" -*- nroff -*-
+.TH "gdalmove" 1 "Fri Jun 5 2015" "GDAL" \" -*- nroff -*-
 .ad l
 .nh
 .SH NAME
-gdalmove \- .TH "gdalmove" 1 "Mon May 25 2015" "GDAL" \" -*- nroff -*-
+gdalmove \- .TH "gdalmove" 1 "Fri Jun 5 2015" "GDAL" \" -*- nroff -*-
 .ad l
 .nh
 .SH NAME
diff --git a/man/man1/gdalsrsinfo.1 b/man/man1/gdalsrsinfo.1
index 4d8977e..6bca5af 100644
--- a/man/man1/gdalsrsinfo.1
+++ b/man/man1/gdalsrsinfo.1
@@ -1,8 +1,8 @@
-.TH "gdalsrsinfo" 1 "Mon May 25 2015" "GDAL" \" -*- nroff -*-
+.TH "gdalsrsinfo" 1 "Fri Jun 5 2015" "GDAL" \" -*- nroff -*-
 .ad l
 .nh
 .SH NAME
-gdalsrsinfo \- .TH "gdalsrsinfo" 1 "Mon May 25 2015" "GDAL" \" -*- nroff -*-
+gdalsrsinfo \- .TH "gdalsrsinfo" 1 "Fri Jun 5 2015" "GDAL" \" -*- nroff -*-
 .ad l
 .nh
 .SH NAME
diff --git a/man/man1/gdaltindex.1 b/man/man1/gdaltindex.1
index 15fa377..e9834f4 100644
--- a/man/man1/gdaltindex.1
+++ b/man/man1/gdaltindex.1
@@ -1,8 +1,8 @@
-.TH "gdaltindex" 1 "Mon May 25 2015" "GDAL" \" -*- nroff -*-
+.TH "gdaltindex" 1 "Fri Jun 5 2015" "GDAL" \" -*- nroff -*-
 .ad l
 .nh
 .SH NAME
-gdaltindex \- .TH "gdaltindex" 1 "Mon May 25 2015" "GDAL" \" -*- nroff -*-
+gdaltindex \- .TH "gdaltindex" 1 "Fri Jun 5 2015" "GDAL" \" -*- nroff -*-
 .ad l
 .nh
 .SH NAME
diff --git a/man/man1/gdaltransform.1 b/man/man1/gdaltransform.1
index 5fc1fd7..bdf2dbb 100644
--- a/man/man1/gdaltransform.1
+++ b/man/man1/gdaltransform.1
@@ -1,8 +1,8 @@
-.TH "gdaltransform" 1 "Mon May 25 2015" "GDAL" \" -*- nroff -*-
+.TH "gdaltransform" 1 "Fri Jun 5 2015" "GDAL" \" -*- nroff -*-
 .ad l
 .nh
 .SH NAME
-gdaltransform \- .TH "gdaltransform" 1 "Mon May 25 2015" "GDAL" \" -*- nroff -*-
+gdaltransform \- .TH "gdaltransform" 1 "Fri Jun 5 2015" "GDAL" \" -*- nroff -*-
 .ad l
 .nh
 .SH NAME
diff --git a/man/man1/gdalwarp.1 b/man/man1/gdalwarp.1
index 7ce8fa8..346a3bf 100644
--- a/man/man1/gdalwarp.1
+++ b/man/man1/gdalwarp.1
@@ -1,8 +1,8 @@
-.TH "gdalwarp" 1 "Mon May 25 2015" "GDAL" \" -*- nroff -*-
+.TH "gdalwarp" 1 "Fri Jun 5 2015" "GDAL" \" -*- nroff -*-
 .ad l
 .nh
 .SH NAME
-gdalwarp \- .TH "gdalwarp" 1 "Mon May 25 2015" "GDAL" \" -*- nroff -*-
+gdalwarp \- .TH "gdalwarp" 1 "Fri Jun 5 2015" "GDAL" \" -*- nroff -*-
 .ad l
 .nh
 .SH NAME
diff --git a/man/man1/nearblack.1 b/man/man1/nearblack.1
index b68cbc9..115b692 100644
--- a/man/man1/nearblack.1
+++ b/man/man1/nearblack.1
@@ -1,8 +1,8 @@
-.TH "nearblack" 1 "Mon May 25 2015" "GDAL" \" -*- nroff -*-
+.TH "nearblack" 1 "Fri Jun 5 2015" "GDAL" \" -*- nroff -*-
 .ad l
 .nh
 .SH NAME
-nearblack \- .TH "nearblack" 1 "Mon May 25 2015" "GDAL" \" -*- nroff -*-
+nearblack \- .TH "nearblack" 1 "Fri Jun 5 2015" "GDAL" \" -*- nroff -*-
 .ad l
 .nh
 .SH NAME
diff --git a/man/man1/ogr2ogr.1 b/man/man1/ogr2ogr.1
index dec78ca..a049b58 100644
--- a/man/man1/ogr2ogr.1
+++ b/man/man1/ogr2ogr.1
@@ -1,8 +1,8 @@
-.TH "ogr2ogr" 1 "Mon May 25 2015" "GDAL" \" -*- nroff -*-
+.TH "ogr2ogr" 1 "Fri Jun 5 2015" "GDAL" \" -*- nroff -*-
 .ad l
 .nh
 .SH NAME
-ogr2ogr \- .TH "ogr2ogr" 1 "Mon May 25 2015" "GDAL" \" -*- nroff -*-
+ogr2ogr \- .TH "ogr2ogr" 1 "Fri Jun 5 2015" "GDAL" \" -*- nroff -*-
 .ad l
 .nh
 .SH NAME
@@ -17,7 +17,7 @@ Usage: ogr2ogr [--help-general] [-skipfailures] [-append] [-update]
                [-select field_list] [-where restricted_where] 
                [-progress] [-sql <sql statement>] [-dialect dialect]
                [-preserve_fid] [-fid FID]
-               [-spat xmin ymin xmax ymax] [-geomfield field]
+               [-spat xmin ymin xmax ymax] [-spat_srs srs_def] [-geomfield field]
                [-a_srs srs_def] [-t_srs srs_def] [-s_srs srs_def]
                [-f format_name] [-overwrite] [[-dsco NAME=VALUE] ...]
                dst_datasource_name src_datasource_name
@@ -85,7 +85,9 @@ Attribute query (like SQL WHERE)
 .IP "\fB\fB-skipfailures\fP:\fP" 1c
 Continue after a failure, skipping the failed feature. 
 .IP "\fB\fB-spat\fP\fI xmin ymin xmax ymax\fP:\fP" 1c
-spatial query extents. Only features whose geometry intersects the extents will be selected. The geometries will not be clipped unless -clipsrc is specified 
+spatial query extents, in the SRS of the source layer(s) (or the one specified with -spat_srs). Only features whose geometry intersects the extents will be selected. The geometries will not be clipped unless -clipsrc is specified 
+.IP "\fB\fB-spat_srs\fP\fI srs_def\fP:\fP" 1c
+(OGR >= 2.0) Override spatial filter SRS. 
 .IP "\fB\fB-geomfield\fP \fIfield\fP:\fP" 1c
 (OGR >= 1.11) Name of the geometry field on which the spatial filter operates on. 
 .IP "\fB\fB-dsco\fP \fINAME=VALUE\fP:\fP" 1c
diff --git a/man/man1/ogr_utilities.1 b/man/man1/ogr_utilities.1
index c86582d..040b719 100644
--- a/man/man1/ogr_utilities.1
+++ b/man/man1/ogr_utilities.1
@@ -1,8 +1,8 @@
-.TH "ogr_utilities" 1 "Mon May 25 2015" "GDAL" \" -*- nroff -*-
+.TH "ogr_utilities" 1 "Fri Jun 5 2015" "GDAL" \" -*- nroff -*-
 .ad l
 .nh
 .SH NAME
-ogr_utilities \- .TH "ogr_utilities" 1 "Mon May 25 2015" "GDAL" \" -*- nroff -*-
+ogr_utilities \- .TH "ogr_utilities" 1 "Fri Jun 5 2015" "GDAL" \" -*- nroff -*-
 .ad l
 .nh
 .SH NAME
diff --git a/man/man1/ogrinfo.1 b/man/man1/ogrinfo.1
index 3844416..48a0177 100644
--- a/man/man1/ogrinfo.1
+++ b/man/man1/ogrinfo.1
@@ -1,8 +1,8 @@
-.TH "ogrinfo" 1 "Mon May 25 2015" "GDAL" \" -*- nroff -*-
+.TH "ogrinfo" 1 "Fri Jun 5 2015" "GDAL" \" -*- nroff -*-
 .ad l
 .nh
 .SH NAME
-ogrinfo \- .TH "ogrinfo" 1 "Mon May 25 2015" "GDAL" \" -*- nroff -*-
+ogrinfo \- .TH "ogrinfo" 1 "Fri Jun 5 2015" "GDAL" \" -*- nroff -*-
 .ad l
 .nh
 .SH NAME
diff --git a/man/man1/ogrlineref.1 b/man/man1/ogrlineref.1
index 7ea8539..9efd9c5 100644
--- a/man/man1/ogrlineref.1
+++ b/man/man1/ogrlineref.1
@@ -1,8 +1,8 @@
-.TH "ogrlineref" 1 "Mon May 25 2015" "GDAL" \" -*- nroff -*-
+.TH "ogrlineref" 1 "Fri Jun 5 2015" "GDAL" \" -*- nroff -*-
 .ad l
 .nh
 .SH NAME
-ogrlineref \- .TH "ogrlineref" 1 "Mon May 25 2015" "GDAL" \" -*- nroff -*-
+ogrlineref \- .TH "ogrlineref" 1 "Fri Jun 5 2015" "GDAL" \" -*- nroff -*-
 .ad l
 .nh
 .SH NAME
diff --git a/man/man1/ogrtindex.1 b/man/man1/ogrtindex.1
index e8ce9c8..7d52046 100644
--- a/man/man1/ogrtindex.1
+++ b/man/man1/ogrtindex.1
@@ -1,8 +1,8 @@
-.TH "ogrtindex" 1 "Mon May 25 2015" "GDAL" \" -*- nroff -*-
+.TH "ogrtindex" 1 "Fri Jun 5 2015" "GDAL" \" -*- nroff -*-
 .ad l
 .nh
 .SH NAME
-ogrtindex \- .TH "ogrtindex" 1 "Mon May 25 2015" "GDAL" \" -*- nroff -*-
+ogrtindex \- .TH "ogrtindex" 1 "Fri Jun 5 2015" "GDAL" \" -*- nroff -*-
 .ad l
 .nh
 .SH NAME
diff --git a/man/man1/pct2rgb.1 b/man/man1/pct2rgb.1
index 6755d7a..ce383c5 100644
--- a/man/man1/pct2rgb.1
+++ b/man/man1/pct2rgb.1
@@ -1,8 +1,8 @@
-.TH "pct2rgb" 1 "Mon May 25 2015" "GDAL" \" -*- nroff -*-
+.TH "pct2rgb" 1 "Fri Jun 5 2015" "GDAL" \" -*- nroff -*-
 .ad l
 .nh
 .SH NAME
-pct2rgb \- .TH "pct2rgb" 1 "Mon May 25 2015" "GDAL" \" -*- nroff -*-
+pct2rgb \- .TH "pct2rgb" 1 "Fri Jun 5 2015" "GDAL" \" -*- nroff -*-
 .ad l
 .nh
 .SH NAME
diff --git a/man/man1/rgb2pct.1 b/man/man1/rgb2pct.1
index f2e4f9f..ff3057a 100644
--- a/man/man1/rgb2pct.1
+++ b/man/man1/rgb2pct.1
@@ -1,8 +1,8 @@
-.TH "rgb2pct" 1 "Mon May 25 2015" "GDAL" \" -*- nroff -*-
+.TH "rgb2pct" 1 "Fri Jun 5 2015" "GDAL" \" -*- nroff -*-
 .ad l
 .nh
 .SH NAME
-rgb2pct \- .TH "rgb2pct" 1 "Mon May 25 2015" "GDAL" \" -*- nroff -*-
+rgb2pct \- .TH "rgb2pct" 1 "Fri Jun 5 2015" "GDAL" \" -*- nroff -*-
 .ad l
 .nh
 .SH NAME
diff --git a/ogr/ogrsf_frmts/gml/ogrgmldatasource.cpp b/ogr/ogrsf_frmts/gml/ogrgmldatasource.cpp
index 3a6ebe0..dd495b1 100644
--- a/ogr/ogrsf_frmts/gml/ogrgmldatasource.cpp
+++ b/ogr/ogrsf_frmts/gml/ogrgmldatasource.cpp
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: ogrgmldatasource.cpp 29240 2015-05-24 10:58:38Z rouault $
+ * $Id: ogrgmldatasource.cpp 29273 2015-06-02 08:08:38Z rouault $
  *
  * Project:  OGR
  * Purpose:  Implements OGRGMLDataSource class.
@@ -47,7 +47,7 @@
 
 #include <vector>
 
-CPL_CVSID("$Id: ogrgmldatasource.cpp 29240 2015-05-24 10:58:38Z rouault $");
+CPL_CVSID("$Id: ogrgmldatasource.cpp 29273 2015-06-02 08:08:38Z rouault $");
 
 static int ExtractSRSName(const char* pszXML, char* szSRSName,
                           size_t sizeof_szSRSName);
@@ -488,18 +488,18 @@ int OGRGMLDataSource::Open( GDALOpenInfo* poOpenInfo )
                         strstr(szPtr, " gml:id='") != NULL;
         bExposeFid = strstr(szPtr, " fid=\"") != NULL ||
                         strstr(szPtr, " fid='") != NULL;
-        
-        const char* pszExposeGMLId = CSLFetchNameValueDef(poOpenInfo->papszOpenOptions,
-            "EXPOSE_GML_ID", CPLGetConfigOption("GML_EXPOSE_GML_ID", NULL));
-        if (pszExposeGMLId)
-            bExposeGMLId = CSLTestBoolean(pszExposeGMLId);
-
-        const char* pszExposeFid = CSLFetchNameValueDef(poOpenInfo->papszOpenOptions,
-            "EXPOSE_FID", CPLGetConfigOption("GML_EXPOSE_FID", NULL));
-        if (pszExposeFid)
-            bExposeFid = CSLTestBoolean(pszExposeFid);
     }
 
+    const char* pszExposeGMLId = CSLFetchNameValueDef(poOpenInfo->papszOpenOptions,
+        "EXPOSE_GML_ID", CPLGetConfigOption("GML_EXPOSE_GML_ID", NULL));
+    if (pszExposeGMLId)
+        bExposeGMLId = CSLTestBoolean(pszExposeGMLId);
+
+    const char* pszExposeFid = CSLFetchNameValueDef(poOpenInfo->papszOpenOptions,
+        "EXPOSE_FID", CPLGetConfigOption("GML_EXPOSE_FID", NULL));
+    if (pszExposeFid)
+        bExposeFid = CSLTestBoolean(pszExposeFid);
+
     bHintConsiderEPSGAsURN = strstr(szPtr, "xmlns:fme=\"http://www.safe.com/gml/fme\"") != NULL;
 
     /* MTKGML */
diff --git a/ogr/ogrsf_frmts/openair/ogropenairdriver.cpp b/ogr/ogrsf_frmts/openair/ogropenairdriver.cpp
index b54403c..61ef2ef 100644
--- a/ogr/ogrsf_frmts/openair/ogropenairdriver.cpp
+++ b/ogr/ogrsf_frmts/openair/ogropenairdriver.cpp
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: ogropenairdriver.cpp 27384 2014-05-24 12:28:12Z rouault $
+ * $Id: ogropenairdriver.cpp 29253 2015-05-27 08:49:16Z rouault $
  *
  * Project:  OpenAir Translator
  * Purpose:  Implements OGROpenAirDriver.
@@ -30,7 +30,7 @@
 #include "ogr_openair.h"
 #include "cpl_conv.h"
 
-CPL_CVSID("$Id: ogropenairdriver.cpp 27384 2014-05-24 12:28:12Z rouault $");
+CPL_CVSID("$Id: ogropenairdriver.cpp 29253 2015-05-27 08:49:16Z rouault $");
 
 extern "C" void RegisterOGROpenAir();
 
@@ -51,7 +51,42 @@ static GDALDataset *OGROpenAirDriverOpen( GDALOpenInfo* poOpenInfo )
                   strstr((const char*)poOpenInfo->pabyHeader, "\nAL ") != NULL &&
                   strstr((const char*)poOpenInfo->pabyHeader, "\nAH") != NULL);
     if( !bIsOpenAir )
-        return NULL;
+    {
+        /* Some files such http://soaringweb.org/Airspace/CZ/CZ_combined_2014_05_01.txt */
+        /* have very long comments in the header, so we will have to check */
+        /* further, but only do this is we have a hint that the file might be */
+        /* a candidate */
+        int nLen = poOpenInfo->nHeaderBytes;
+        if( nLen < 10000 )
+            return NULL;
+        /* Check the 'Airspace' word in the header */
+        if( strstr((const char*)poOpenInfo->pabyHeader, "Airspace") == NULL )
+            return NULL;
+        // Check that the header is at least UTF-8
+        // but do not take into account partial UTF-8 characters at the end
+        int nTruncated = 0;
+        while(nLen > 0)
+        {
+            if( (poOpenInfo->pabyHeader[nLen-1] & 0xc0) != 0x80 )
+            {
+                break;
+            }
+            nLen --;
+            nTruncated ++;
+            if( nTruncated == 7 )
+                return NULL;
+        }
+        if( !CPLIsUTF8((const char*)poOpenInfo->pabyHeader, nLen) )
+            return NULL;
+        if( !poOpenInfo->TryToIngest(30000) )
+            return NULL;
+        bIsOpenAir = (strstr((const char*)poOpenInfo->pabyHeader, "\nAC ") != NULL &&
+                  strstr((const char*)poOpenInfo->pabyHeader, "\nAN ") != NULL &&
+                  strstr((const char*)poOpenInfo->pabyHeader, "\nAL ") != NULL &&
+                  strstr((const char*)poOpenInfo->pabyHeader, "\nAH") != NULL);
+        if( !bIsOpenAir )
+            return NULL;
+    }
 
     OGROpenAirDataSource   *poDS = new OGROpenAirDataSource();
 
diff --git a/ogr/ogrsf_frmts/sqlite/ogrsqlitedriver.cpp b/ogr/ogrsf_frmts/sqlite/ogrsqlitedriver.cpp
index 441271f..b2ee957 100644
--- a/ogr/ogrsf_frmts/sqlite/ogrsqlitedriver.cpp
+++ b/ogr/ogrsf_frmts/sqlite/ogrsqlitedriver.cpp
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: ogrsqlitedriver.cpp 28612 2015-03-04 15:22:08Z rouault $
+ * $Id: ogrsqlitedriver.cpp 29265 2015-05-29 10:49:34Z rouault $
  *
  * Project:  OpenGIS Simple Features Reference Implementation
  * Purpose:  Implements OGRSQLiteDriver class.
@@ -42,7 +42,7 @@
 #include "spatialite.h"
 #endif
 
-CPL_CVSID("$Id: ogrsqlitedriver.cpp 28612 2015-03-04 15:22:08Z rouault $");
+CPL_CVSID("$Id: ogrsqlitedriver.cpp 29265 2015-05-29 10:49:34Z rouault $");
 
 /************************************************************************/
 /*                          OGRSQLiteDriverUnload()                     */
@@ -78,7 +78,11 @@ static int OGRSQLiteDriverIdentify( GDALOpenInfo* poOpenInfo )
     if( poOpenInfo->nHeaderBytes < 16 )
         return FALSE;
 
-    return( strncmp( (const char*)poOpenInfo->pabyHeader, "SQLite format 3", 15 ) == 0 );
+    if( strncmp( (const char*)poOpenInfo->pabyHeader, "SQLite format 3", 15 ) != 0 )
+        return FALSE;
+    
+    // Could be a Rasterlite file as well
+    return -1;
 }
 
 /************************************************************************/
@@ -88,7 +92,7 @@ static int OGRSQLiteDriverIdentify( GDALOpenInfo* poOpenInfo )
 static GDALDataset *OGRSQLiteDriverOpen( GDALOpenInfo* poOpenInfo )
 
 {
-    if( !OGRSQLiteDriverIdentify(poOpenInfo) )
+    if( OGRSQLiteDriverIdentify(poOpenInfo) == FALSE )
         return NULL;
 
 /* -------------------------------------------------------------------- */
diff --git a/ogr/ogrsf_frmts/sua/ogrsuadriver.cpp b/ogr/ogrsf_frmts/sua/ogrsuadriver.cpp
index 5f92368..9e66592 100644
--- a/ogr/ogrsf_frmts/sua/ogrsuadriver.cpp
+++ b/ogr/ogrsf_frmts/sua/ogrsuadriver.cpp
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: ogrsuadriver.cpp 27384 2014-05-24 12:28:12Z rouault $
+ * $Id: ogrsuadriver.cpp 29253 2015-05-27 08:49:16Z rouault $
  *
  * Project:  SUA Translator
  * Purpose:  Implements OGRSUADriver.
@@ -30,7 +30,7 @@
 #include "ogr_sua.h"
 #include "cpl_conv.h"
 
-CPL_CVSID("$Id: ogrsuadriver.cpp 27384 2014-05-24 12:28:12Z rouault $");
+CPL_CVSID("$Id: ogrsuadriver.cpp 29253 2015-05-27 08:49:16Z rouault $");
 
 extern "C" void RegisterOGRSUA();
 
@@ -51,7 +51,42 @@ static GDALDataset *OGRSUADriverOpen( GDALOpenInfo* poOpenInfo )
             (strstr((const char*)poOpenInfo->pabyHeader, "\nPOINT=") != NULL ||
             strstr((const char*)poOpenInfo->pabyHeader, "\nCIRCLE ") != NULL));
     if( !bIsSUA )
-        return NULL;
+    {
+        /* Some files such http://soaringweb.org/Airspace/CZ/CZ_combined_2014_05_01.sua */
+        /* have very long comments in the header, so we will have to check */
+        /* further, but only do this is we have a hint that the file might be */
+        /* a candidate */
+        int nLen = poOpenInfo->nHeaderBytes;
+        if( nLen < 10000 )
+            return NULL;
+        /* Check the 'Airspace' word in the header */
+        if( strstr((const char*)poOpenInfo->pabyHeader, "Airspace") == NULL )
+            return NULL;
+        // Check that the header is at least UTF-8
+        // but do not take into account partial UTF-8 characters at the end
+        int nTruncated = 0;
+        while(nLen > 0)
+        {
+            if( (poOpenInfo->pabyHeader[nLen-1] & 0xc0) != 0x80 )
+            {
+                break;
+            }
+            nLen --;
+            nTruncated ++;
+            if( nTruncated == 7 )
+                return NULL;
+        }
+        if( !CPLIsUTF8((const char*)poOpenInfo->pabyHeader, nLen) )
+            return NULL;
+        if( !poOpenInfo->TryToIngest(30000) )
+            return NULL;
+        bIsSUA = ( strstr((const char*)poOpenInfo->pabyHeader, "\nTYPE=") != NULL &&
+                   strstr((const char*)poOpenInfo->pabyHeader, "\nTITLE=") != NULL &&
+                   (strstr((const char*)poOpenInfo->pabyHeader, "\nPOINT=") != NULL ||
+                   strstr((const char*)poOpenInfo->pabyHeader, "\nCIRCLE ") != NULL) );
+        if( !bIsSUA )
+            return NULL;
+    }
 
     OGRSUADataSource   *poDS = new OGRSUADataSource();
 
diff --git a/ogr/ogrsf_frmts/wfs/drv_wfs.html b/ogr/ogrsf_frmts/wfs/drv_wfs.html
index cd6ba10..d9d206f 100644
--- a/ogr/ogrsf_frmts/wfs/drv_wfs.html
+++ b/ogr/ogrsf_frmts/wfs/drv_wfs.html
@@ -9,7 +9,7 @@
 
 (GDAL/OGR >= 1.8.0)<p>
 
-This driver can connect to a OGC WFS service. It supports WFS 1.0.0 and WFS 1.1.0 protocols. GDAL/OGR must be built with Curl support in order to the
+This driver can connect to a OGC WFS service. It supports WFS 1.0, 1.1 and 2.0 protocols. GDAL/OGR must be built with Curl support in order to the
 WFS driver to be compiled. Usually WFS requests return results in GML format, so the GML driver should generally be set-up for read support
 (thus requiring GDAL/OGR to be built with Xerces or Expat support). It is sometimes possible to use alternate underlying formats when the server supports them
 (such as OUTPUTFORMAT=json).<p>
@@ -226,6 +226,9 @@ and mandatory fields being reported as not nullable.</li>
 present SRS and coordinate ordering in traditional GIS order. Defaults to YES.</li>
 <li> <b>CONSIDER_EPSG_AS_URN=YES/NO/AUTO</b>: (GDAL >=2.0) Whether to
 consider srsName like EPSG:XXXX as respecting EPSG axis order. Defaults to AUTO.</li>
+<li> <b>EXPOSE_GML_ID=YES/NO</b>: (GDAL >=2.0) Whether to expose the gml:id
+attribute of a GML feature as the gml_id OGR field. Note that hiding gml_id will prevent
+WFS-T from working. Defaults to YES.</li>
 </ul>
 
 <h2>Examples</h2>
diff --git a/ogr/ogrsf_frmts/wfs/ogr_wfs.h b/ogr/ogrsf_frmts/wfs/ogr_wfs.h
index 59b93ca..8030072 100644
--- a/ogr/ogrsf_frmts/wfs/ogr_wfs.h
+++ b/ogr/ogrsf_frmts/wfs/ogr_wfs.h
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: ogr_wfs.h 29241 2015-05-24 10:58:54Z rouault $
+ * $Id: ogr_wfs.h 29273 2015-06-02 08:08:38Z rouault $
  *
  * Project:  WFS Translator
  * Purpose:  Definition of classes for OGR WFS driver.
@@ -329,6 +329,7 @@ class OGRWFSDataSource : public OGRDataSource
     
     int                 bInvertAxisOrderIfLatLong;
     CPLString           osConsiderEPSGAsURN;
+    int                 bExposeGMLId;
 
     CPLHTTPResult*      SendGetCapabilities(const char* pszBaseURL,
                                             CPLString& osTypeName);
@@ -393,6 +394,8 @@ class OGRWFSDataSource : public OGRDataSource
     int                         IsEmptyAsNull() const { return bEmptyAsNull; }
     int                         InvertAxisOrderIfLatLong() const { return bInvertAxisOrderIfLatLong; }
     const CPLString&            GetConsiderEPSGAsURN() const { return osConsiderEPSGAsURN; }
+    
+    int                         ExposeGMLId() const { return bExposeGMLId; }
 
     virtual char**              GetMetadataDomainList();
     virtual char**              GetMetadata( const char * pszDomain = "" );
diff --git a/ogr/ogrsf_frmts/wfs/ogrwfsdatasource.cpp b/ogr/ogrsf_frmts/wfs/ogrwfsdatasource.cpp
index a6cb4a4..4fb5c97 100644
--- a/ogr/ogrsf_frmts/wfs/ogrwfsdatasource.cpp
+++ b/ogr/ogrsf_frmts/wfs/ogrwfsdatasource.cpp
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: ogrwfsdatasource.cpp 29241 2015-05-24 10:58:54Z rouault $
+ * $Id: ogrwfsdatasource.cpp 29273 2015-06-02 08:08:38Z rouault $
  *
  * Project:  WFS Translator
  * Purpose:  Implements OGRWFSDataSource class
@@ -37,7 +37,7 @@
 #include "swq.h"
 #include "ogr_p.h"
 
-CPL_CVSID("$Id: ogrwfsdatasource.cpp 29241 2015-05-24 10:58:54Z rouault $");
+CPL_CVSID("$Id: ogrwfsdatasource.cpp 29273 2015-06-02 08:08:38Z rouault $");
 
 #define DEFAULT_BASE_START_INDEX     0
 #define DEFAULT_PAGE_SIZE            100
@@ -195,6 +195,7 @@ OGRWFSDataSource::OGRWFSDataSource()
     bEmptyAsNull = TRUE;
     
     bInvertAxisOrderIfLatLong = TRUE;
+    bExposeGMLId = TRUE;
 }
 
 /************************************************************************/
@@ -1108,6 +1109,10 @@ int OGRWFSDataSource::Open( const char * pszFilename, int bUpdateIn,
         CSLFetchNameValueDef(papszOpenOptions,
             "CONSIDER_EPSG_AS_URN",
             CPLGetConfigOption("GML_CONSIDER_EPSG_AS_URN", "AUTO"));
+    bExposeGMLId =
+        CSLTestBoolean(CSLFetchNameValueDef(papszOpenOptions,
+            "EXPOSE_GML_ID",
+            CPLGetConfigOption("GML_EXPOSE_GML_ID", "YES")));
 
     CPLXMLNode* psStrippedXML = CPLCloneXMLTree(psXML);
     CPLStripXMLNamespace( psStrippedXML, NULL, TRUE );
diff --git a/ogr/ogrsf_frmts/wfs/ogrwfsdriver.cpp b/ogr/ogrsf_frmts/wfs/ogrwfsdriver.cpp
index 4101af4..e308a47 100644
--- a/ogr/ogrsf_frmts/wfs/ogrwfsdriver.cpp
+++ b/ogr/ogrsf_frmts/wfs/ogrwfsdriver.cpp
@@ -32,7 +32,7 @@
 
 // g++ -fPIC -g -Wall ogr/ogrsf_frmts/wfs/*.cpp -shared -o ogr_WFS.so -Iport -Igcore -Iogr -Iogr/ogrsf_frmts -Iogr/ogrsf_frmts/gml -Iogr/ogrsf_frmts/wfs -L. -lgdal
 
-CPL_CVSID("$Id: ogrwfsdriver.cpp 29241 2015-05-24 10:58:54Z rouault $");
+CPL_CVSID("$Id: ogrwfsdriver.cpp 29273 2015-06-02 08:08:38Z rouault $");
 
 extern "C" void RegisterOGRWFS();
 
@@ -113,6 +113,7 @@ void RegisterOGRWFS()
 "    <Value>YES</Value>"
 "    <Value>NO</Value>"
 "  </Option>"
+"  <Option name='EXPOSE_GML_ID' type='boolean' description='Whether to make feature gml:id as a gml_id attribute.' default='YES'/>"
 "</OpenOptionList>" );
 
         poDriver->SetMetadataItem( GDAL_DCAP_VIRTUALIO, "YES" );
diff --git a/ogr/ogrsf_frmts/wfs/ogrwfslayer.cpp b/ogr/ogrsf_frmts/wfs/ogrwfslayer.cpp
index 23c5e89..2944bfd 100644
--- a/ogr/ogrsf_frmts/wfs/ogrwfslayer.cpp
+++ b/ogr/ogrsf_frmts/wfs/ogrwfslayer.cpp
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: ogrwfslayer.cpp 29241 2015-05-24 10:58:54Z rouault $
+ * $Id: ogrwfslayer.cpp 29273 2015-06-02 08:08:38Z rouault $
  *
  * Project:  WFS Translator
  * Purpose:  Implements OGRWFSLayer class.
@@ -34,7 +34,7 @@
 #include "cpl_http.h"
 #include "parsexsd.h"
 
-CPL_CVSID("$Id: ogrwfslayer.cpp 29241 2015-05-24 10:58:54Z rouault $");
+CPL_CVSID("$Id: ogrwfslayer.cpp 29273 2015-06-02 08:08:38Z rouault $");
 
 
 /************************************************************************/
@@ -329,9 +329,12 @@ OGRFeatureDefn* OGRWFSLayer::BuildLayerDefnFromFeatureClass(GMLFeatureClass* poC
 /* -------------------------------------------------------------------- */
 /*      Added attributes (properties).                                  */
 /* -------------------------------------------------------------------- */
-    OGRFieldDefn oField( "gml_id", OFTString );
-    oField.SetNullable(FALSE);
-    poFDefn->AddFieldDefn( &oField );
+    if( poDS->ExposeGMLId() )
+    {
+        OGRFieldDefn oField( "gml_id", OFTString );
+        oField.SetNullable(FALSE);
+        poFDefn->AddFieldDefn( &oField );
+    }
 
     for( int iField = 0; iField < poGMLFeatureClass->GetPropertyCount(); iField++ )
     {
@@ -739,7 +742,7 @@ GDALDataset* OGRWFSLayer::FetchGetFeature(int nRequestMaxFeatures)
         }
 
         const char* const apszAllowedDrivers[] = { "GML", NULL };
-        const char* apszOpenOptions[5] = { NULL, NULL, NULL, NULL, NULL };
+        const char* apszOpenOptions[6] = { NULL, NULL, NULL, NULL, NULL, NULL };
         apszOpenOptions[0] = CPLSPrintf("XSD=%s", osXSDFileName.c_str());
         apszOpenOptions[1] = CPLSPrintf("EMPTY_AS_NULL=%s", poDS->IsEmptyAsNull() ? "YES" : "NO");
         int iGMLOOIdex = 2;
@@ -755,6 +758,12 @@ GDALDataset* OGRWFSLayer::FetchGetFeature(int nRequestMaxFeatures)
                                             poDS->GetConsiderEPSGAsURN().c_str());
             iGMLOOIdex ++;
         }
+        if( CPLGetConfigOption("GML_EXPOSE_GML_ID", NULL) == NULL )
+        {
+            apszOpenOptions[iGMLOOIdex] = CPLSPrintf("EXPOSE_GML_ID=%s",
+                                            poDS->ExposeGMLId() ? "YES" : "NO");
+            iGMLOOIdex ++;
+        }
 
         GDALDataset* poGML_DS = (GDALDataset*)
                 GDALOpenEx(pszStreamingName, GDAL_OF_VECTOR, apszAllowedDrivers,
@@ -964,7 +973,7 @@ GDALDataset* OGRWFSLayer::FetchGetFeature(int nRequestMaxFeatures)
     CPLHTTPDestroyResult(psResult);
 
     const char* const * papszOpenOptions = NULL;
-    const char* apszGMLOpenOptions[3] = { NULL, NULL, NULL };
+    const char* apszGMLOpenOptions[4] = { NULL, NULL, NULL, NULL };
     int iGMLOOIdex = 0;
     if( CPLGetConfigOption("GML_INVERT_AXIS_ORDER_IF_LAT_LONG", NULL) == NULL )
     {
@@ -978,6 +987,12 @@ GDALDataset* OGRWFSLayer::FetchGetFeature(int nRequestMaxFeatures)
                                         poDS->GetConsiderEPSGAsURN().c_str());
         iGMLOOIdex ++;
     }
+    if( CPLGetConfigOption("GML_EXPOSE_GML_ID", NULL) == NULL )
+    {
+        apszGMLOpenOptions[iGMLOOIdex] = CPLSPrintf("EXPOSE_GML_ID=%s",
+                                        poDS->ExposeGMLId() ? "YES" : "NO");
+        iGMLOOIdex ++;
+    }
 
     GDALDriverH hDrv = GDALIdentifyDriver(osTmpFileName, NULL);
     if( hDrv != NULL && hDrv == GDALGetDriverByName("GML") )
diff --git a/port/cpl_multiproc.cpp b/port/cpl_multiproc.cpp
index e844b03..8f3169b 100644
--- a/port/cpl_multiproc.cpp
+++ b/port/cpl_multiproc.cpp
@@ -1,5 +1,5 @@
 /**********************************************************************
- * $Id: cpl_multiproc.cpp 28471 2015-02-12 21:16:10Z rouault $
+ * $Id: cpl_multiproc.cpp 29269 2015-06-01 13:23:14Z rouault $
  *
  * Project:  CPL - Common Portability Library
  * Purpose:  CPL Multi-Threading, and process handling portability functions.
@@ -42,7 +42,7 @@
 #  include <wce_time.h>
 #endif
 
-CPL_CVSID("$Id: cpl_multiproc.cpp 28471 2015-02-12 21:16:10Z rouault $");
+CPL_CVSID("$Id: cpl_multiproc.cpp 29269 2015-06-01 13:23:14Z rouault $");
 
 #if defined(CPL_MULTIPROC_STUB) && !defined(DEBUG)
 #  define MUTEX_NONE
@@ -2001,6 +2001,9 @@ CPLLock *CPLCreateLock( CPLLockType eType )
             CPLLock* psLock = (CPLLock*)malloc(sizeof(CPLLock));
             psLock->eType = eType;
             psLock->u.hMutex = hMutex;
+#ifdef DEBUG_CONTENTION
+            psLock->bDebugPerf = FALSE;
+#endif
             return psLock;
         }
         case LOCK_SPIN:
@@ -2011,6 +2014,9 @@ CPLLock *CPLCreateLock( CPLLockType eType )
             CPLLock* psLock = (CPLLock*)malloc(sizeof(CPLLock));
             psLock->eType = eType;
             psLock->u.hSpinLock = hSpinLock;
+#ifdef DEBUG_CONTENTION
+            psLock->bDebugPerf = FALSE;
+#endif
             return psLock;
         }
         default:
diff --git a/port/cpl_strtod.cpp b/port/cpl_strtod.cpp
index 75c5a92..a077e63 100644
--- a/port/cpl_strtod.cpp
+++ b/port/cpl_strtod.cpp
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: cpl_strtod.cpp 28849 2015-04-05 14:05:18Z goatbar $
+ * $Id: cpl_strtod.cpp 29252 2015-05-26 10:00:08Z rouault $
  *
  * Project:  CPL - Common Portability Library
  * Purpose:  Functions to convert ASCII string to floating point number.
@@ -34,7 +34,7 @@
 
 #include "cpl_conv.h"
 
-CPL_CVSID("$Id: cpl_strtod.cpp 28849 2015-04-05 14:05:18Z goatbar $");
+CPL_CVSID("$Id: cpl_strtod.cpp 29252 2015-05-26 10:00:08Z rouault $");
 
 // XXX: with GCC 2.95 strtof() function is only available when in c99 mode.
 // Fix it here not touching the compiler options.
@@ -271,7 +271,7 @@ double CPLStrtodDelim(const char *nptr, char **endptr, char point)
         }
 
         if (strcmp(nptr,"-inf") == 0 ||
-            strcmp(nptr,"-1.#INF") == 0)
+            EQUALN (nptr,"-1.#INF",strlen("-1.#INF")))
         {
             if( endptr ) *endptr = (char*)nptr + strlen(nptr);
             return NEG_INFINITY;
@@ -284,7 +284,7 @@ double CPLStrtodDelim(const char *nptr, char **endptr, char point)
             if( endptr ) *endptr = (char*)nptr + strlen(nptr);
             return NAN;
         }
-        if (strcmp (nptr,"1.#INF") == 0)
+        if( EQUALN (nptr,"1.#INF",strlen("1.#INF")) )
         {
             if( endptr ) *endptr = (char*)nptr + strlen(nptr);
             return INFINITY;
diff --git a/swig/python/samples/build_jp2_from_xml.py b/swig/python/samples/build_jp2_from_xml.py
index acf949c..d0a0be7 100644
--- a/swig/python/samples/build_jp2_from_xml.py
+++ b/swig/python/samples/build_jp2_from_xml.py
@@ -1,7 +1,7 @@
 #!/usr/bin/env python
 # -*- coding: utf-8 -*-
 #******************************************************************************
-#  $Id: build_jp2_from_xml.py 28891 2015-04-13 09:42:46Z rouault $
+#  $Id: build_jp2_from_xml.py 29270 2015-06-01 13:35:43Z rouault $
 # 
 #  Project:  GDAL
 #  Purpose:  Build a JPEG2000 file from the XML structure dumped by dump_jp2.py
@@ -318,8 +318,7 @@ def parse_jp2_box(xml_tree, out_f, src_jp2file):
             print('Cannot decode VRTDataset. Outputing empty content')
             binary_content = ''
         else:
-            out_ds = gdal.GetDriverByName('GTiff').CreateCopy('/vsimem/out.tif', vrt_ds)
-            del out_ds
+            gdal.GetDriverByName('GTiff').CreateCopy('/vsimem/out.tif', vrt_ds)
             tif_f = gdal.VSIFOpenL('/vsimem/out.tif', 'rb')
             binary_content = gdal.VSIFReadL(1, 10000, tif_f)
             gdal.VSIFCloseL(tif_f)
diff --git a/swig/python/samples/ogr_layer_algebra.py b/swig/python/samples/ogr_layer_algebra.py
index c357bd6..8ae63c2 100644
--- a/swig/python/samples/ogr_layer_algebra.py
+++ b/swig/python/samples/ogr_layer_algebra.py
@@ -1,7 +1,7 @@
 #!/usr/bin/env python
 # -*- coding: utf-8 -*-
 #******************************************************************************
-#  $Id: ogr_layer_algebra.py 28391 2015-01-30 19:57:31Z rouault $
+#  $Id: ogr_layer_algebra.py 29254 2015-05-27 12:45:56Z rouault $
 # 
 #  Project:  GDAL Python Interface
 #  Purpose:  Application for executing OGR layer algebra operations
@@ -131,7 +131,7 @@ def main(argv = None):
     opt = []
     overwrite = False
     input_fields = 'ALL'
-    method_fields = 'ALL'
+    method_fields = None
     geom_type = ogr.wkbUnknown
     srs_name = None
     srs = None
@@ -287,6 +287,12 @@ def main(argv = None):
        op_str is None:
            return Usage()
 
+    if method_fields is None:
+        if op_str in ( 'Update', 'Clip', 'Erase' ):
+            method_fields = 'NONE'
+        else:
+            method_fields = 'ALL'
+
     if input_fields == 'NONE' and method_fields == 'NONE':
         print('Warning: -input_fields NONE and -method_fields NONE results in all fields being added')
 
diff --git a/swig/python/scripts/gdal_edit.py b/swig/python/scripts/gdal_edit.py
index 1ff1e58..c2834f1 100755
--- a/swig/python/scripts/gdal_edit.py
+++ b/swig/python/scripts/gdal_edit.py
@@ -1,7 +1,7 @@
 #!/usr/bin/env python
 # -*- coding: utf-8 -*-
 ###############################################################################
-# $Id: gdal_edit.py 28676 2015-03-08 09:03:15Z rouault $
+# $Id: gdal_edit.py 29248 2015-05-25 09:57:17Z rouault $
 #
 #  Project:  GDAL samples
 #  Purpose:  Edit in place various information of an existing GDAL dataset
@@ -153,7 +153,7 @@ def gdal_edit(argv):
 
     if (srs is None and lry is None and yres is None and not unsetgt
             and not unsetstats and not stats and nodata is None
-            and len(molist) == 0 and not unsetmd):
+            and len(molist) == 0 and not unsetmd and len(gcp_list) == 0):
         print('No option specified')
         print('')
         return Usage()

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



More information about the Pkg-grass-devel mailing list