Index: trunk/zoo-project/zoo-services/ogr/ogr2ogr/service.c
===================================================================
--- trunk/zoo-project/zoo-services/ogr/ogr2ogr/service.c	(revision 757)
+++ trunk/zoo-project/zoo-services/ogr/ogr2ogr/service.c	(revision 766)
@@ -33,4 +33,7 @@
 #include "cpl_string.h"
 #include "ogr_api.h"
+#if GDAL_VERSION_MAJOR >= 2
+#include <gdal_priv.h>
+#endif
 #ifdef ZOO_SERVICE
 #include "service.h"
@@ -50,17 +53,29 @@
 static void Usage();
 
-static int TranslateLayer( OGRDataSource *poSrcDS, 
-                           OGRLayer * poSrcLayer,
-                           OGRDataSource *poDstDS,
-                           char ** papszLSCO,
-                           const char *pszNewLayerName,
-                           int bTransform, 
-                           OGRSpatialReference *poOutputSRS,
-                           OGRSpatialReference *poSourceSRS,
-                           char **papszSelFields,
-                           int bAppend, int eGType,
-                           int bOverwrite,
-                           double dfMaxSegmentLength);
-
+static int TranslateLayer(
+#if GDAL_VERSION_MAJOR >= 2
+			  GDALDataset
+#else 
+			  OGRDataSource 
+#endif
+			  *poSrcDS, 
+			  OGRLayer * poSrcLayer,
+#if GDAL_VERSION_MAJOR >= 2
+			  GDALDataset
+#else 
+			  OGRDataSource 
+#endif
+			  *poDstDS,
+			  char ** papszLSCO,
+			  const char *pszNewLayerName,
+			  int bTransform, 
+			  OGRSpatialReference *poOutputSRS,
+			  OGRSpatialReference *poSourceSRS,
+			  char **papszSelFields,
+			  int bAppend, int eGType,
+			  int bOverwrite,
+			  double dfMaxSegmentLength
+			   );
+  
 static int bSkipFailures = FALSE;
 static int nGroupTransactions = 200;
@@ -575,7 +590,15 @@
 /*      Open data source.                                               */
 /* -------------------------------------------------------------------- */
-    OGRDataSource       *poDS;
-        
-    poDS = OGRSFDriverRegistrar::Open( pszDataSource, FALSE );
+#if GDAL_VERSION_MAJOR >= 2
+      GDALDataset *poDS;
+      GDALDataset *poODS;
+      GDALDriverManager* poR=GetGDALDriverManager();
+      GDALDriver          *poDriver = NULL;
+#else
+      OGRDataSource* poDS;
+      OGRDataSource *poODS;
+      OGRSFDriverRegistrar    *poR = OGRSFDriverRegistrar::GetRegistrar();
+      OGRSFDriver          *poDriver = NULL;
+#endif
 
 /* -------------------------------------------------------------------- */
@@ -584,6 +607,4 @@
     if( poDS == NULL )
     {
-        OGRSFDriverRegistrar    *poR = OGRSFDriverRegistrar::GetRegistrar();
-        
         fprintf( stderr, "FAILURE:\n"
                 "Unable to open datasource `%s' with the following drivers.\n",
@@ -592,5 +613,9 @@
         for( int iDriver = 0; iDriver < poR->GetDriverCount(); iDriver++ )
         {
-            fprintf( stderr, "  -> %s\n", poR->GetDriver(iDriver)->GetName() );
+#if GDAL_VERSION_MAJOR >= 2
+	    fprintf( stderr, "  -> %s\n", poR->GetDriver(iDriver)->GetDescription() );
+#else
+	    fprintf( stderr, "  -> %s\n", poR->GetDriver(iDriver)->GetName() );
+#endif
         }
 #ifdef ZOO_SERVICE
@@ -607,9 +632,15 @@
 /*      Try opening the output datasource as an existing, writable      */
 /* -------------------------------------------------------------------- */
-    OGRDataSource       *poODS;
-    
     if( bUpdate )
     {
-        poODS = OGRSFDriverRegistrar::Open( pszDestDataSource, TRUE );
+        poODS = 
+#if GDAL_VERSION_MAJOR >= 2
+	  (GDALDataset*) GDALOpenEx( pszDestDataSource,
+				     GDAL_OF_UPDATE | GDAL_OF_VECTOR,
+				     NULL, NULL, NULL )
+#else
+	  OGRSFDriverRegistrar::Open( pszDestDataSource, TRUE )
+#endif
+	  ;
         if( poODS == NULL )
         {
@@ -639,6 +670,4 @@
     else
     {
-        OGRSFDriverRegistrar *poR = OGRSFDriverRegistrar::GetRegistrar();
-        OGRSFDriver          *poDriver = NULL;
         int                  iDriver;
 
@@ -647,5 +676,9 @@
              iDriver++ )
         {
-            if( EQUAL(poR->GetDriver(iDriver)->GetName(),pszFormat) )
+#if GDAL_VERSION_MAJOR >=2
+	    if( EQUAL(poR->GetDriver(iDriver)->GetDescription(),pszFormat) )
+#else
+	    if( EQUAL(poR->GetDriver(iDriver)->GetName(),pszFormat) )
+#endif
             {
                 poDriver = poR->GetDriver(iDriver);
@@ -660,5 +693,9 @@
             for( iDriver = 0; iDriver < poR->GetDriverCount(); iDriver++ )
             {
-                fprintf( stderr,  "  -> `%s'\n", poR->GetDriver(iDriver)->GetName() );
+#if GDAL_VERSION_MAJOR >= 2
+	      fprintf( stderr, "  -> %s\n", poR->GetDriver(iDriver)->GetDescription() );
+#else
+	      fprintf( stderr, "  -> %s\n", poR->GetDriver(iDriver)->GetName() );
+#endif
             }
 #ifdef ZOO_SERVICE
@@ -672,5 +709,9 @@
         }
 
-        if( !poDriver->TestCapability( ODrCCreateDataSource ) )
+#if GDAL_VERSION_MAJOR >=2
+	if( !CPLTestBool( CSLFetchNameValueDef(poDriver->GetMetadata(), GDAL_DCAP_CREATE, "FALSE") ) )
+#else
+	if( !poDriver->TestCapability( ODrCCreateDataSource ) )
+#endif
         {
             fprintf( stderr,  "%s driver does not support data source creation.\n",
@@ -689,5 +730,9 @@
 /*      Create the output data source.                                  */
 /* -------------------------------------------------------------------- */
-        poODS = poDriver->CreateDataSource( pszDestDataSource, papszDSCO );
+#if GDAL_VERSION_MAJOR >=2
+        poODS = poDriver->Create( pszDestDataSource, 0, 0, 0, GDT_Unknown, papszDSCO );
+#else
+	poODS = poDriver->CreateDataSource( pszDestDataSource, papszDSCO );
+#endif
         if( poODS == NULL )
         {
@@ -887,5 +932,15 @@
 
 {
-    OGRSFDriverRegistrar        *poR = OGRSFDriverRegistrar::GetRegistrar();
+#if GDAL_VERSION_MAJOR >= 2
+      GDALDataset *poDS;
+      GDALDataset *poODS;
+      GDALDriverManager* poR=GetGDALDriverManager();
+      GDALDriver          *poDriver = NULL;
+#else
+      OGRDataSource* poDS;
+      OGRDataSource *poODS;
+      OGRSFDriverRegistrar    *poR = OGRSFDriverRegistrar::GetRegistrar();
+      OGRSFDriver          *poDriver = NULL;
+#endif
 
 #ifdef ZOO_SERVICE
@@ -908,8 +963,16 @@
     for( int iDriver = 0; iDriver < poR->GetDriverCount(); iDriver++ )
     {
-        OGRSFDriver *poDriver = poR->GetDriver(iDriver);
-
-        if( poDriver->TestCapability( ODrCCreateDataSource ) )
-            printf( "     -f \"%s\"\n", poDriver->GetName() );
+        poDriver = poR->GetDriver(iDriver);
+
+#if GDAL_VERSION_MAJOR >=2
+	if( !CPLTestBool( CSLFetchNameValueDef(poDriver->GetMetadata(), GDAL_DCAP_CREATE, "FALSE") ) )
+#else
+	if( !poDriver->TestCapability( ODrCCreateDataSource ) )
+#endif
+#if GDAL_VERSION_MAJOR >= 2
+	    fprintf( stderr, "  -> %s\n", poDriver->GetDescription() );
+#else
+	    fprintf( stderr, "  -> %s\n", poDriver->GetName() );
+#endif
     }
 
@@ -962,15 +1025,26 @@
 /************************************************************************/
 
-static int TranslateLayer( OGRDataSource *poSrcDS, 
-                           OGRLayer * poSrcLayer,
-                           OGRDataSource *poDstDS,
-                           char **papszLCO,
-                           const char *pszNewLayerName,
-                           int bTransform, 
-                           OGRSpatialReference *poOutputSRS,
-                           OGRSpatialReference *poSourceSRS,
-                           char **papszSelFields,
-                           int bAppend, int eGType, int bOverwrite,
-                           double dfMaxSegmentLength)
+static int TranslateLayer(
+#if GDAL_VERSION_MAJOR >= 2
+			  GDALDataset
+#else 
+			  OGRDataSource 
+#endif
+			  *poSrcDS, 
+			  OGRLayer * poSrcLayer,
+#if GDAL_VERSION_MAJOR >= 2
+			  GDALDataset
+#else 
+			  OGRDataSource 
+#endif
+			  *poDstDS,
+			  char **papszLCO,
+			  const char *pszNewLayerName,
+			  int bTransform, 
+			  OGRSpatialReference *poOutputSRS,
+			  OGRSpatialReference *poSourceSRS,
+			  char **papszSelFields,
+			  int bAppend, int eGType, int bOverwrite,
+			  double dfMaxSegmentLength)
 		
 {
