Index: trunk/zoo-project/HISTORY.txt
===================================================================
--- trunk/zoo-project/HISTORY.txt	(revision 765)
+++ trunk/zoo-project/HISTORY.txt	(revision 766)
@@ -1,3 +1,4 @@
 Version 1.6.0-dev
+  * Support GDAL version 2.1.0.
   * Add the MapServer 7.0.1 internal support.
   * Support for exotic location of openssl.
Index: trunk/zoo-project/zoo-api/java/zoo-api.c
===================================================================
--- trunk/zoo-project/zoo-api/java/zoo-api.c	(revision 765)
+++ trunk/zoo-project/zoo-api/java/zoo-api.c	(revision 766)
@@ -5,21 +5,29 @@
 
 JNIEXPORT jstring JNICALL Java_ZOO__1
-  (JNIEnv *env, jclass class, jstring msg){
-  const char *message = (*env)->GetStringUTFChars(env,msg, 0);
+  (JNIEnv *env, jclass _class, jstring msg){
+  const char *message = 
+#ifdef JAVA7
+    (*env).GetStringUTFChars(msg,0);
+  return (*env).NewStringUTF(_(message));
+#else
+    (*env)->GetStringUTFChars(env,msg, 0);
   return (*env)->NewStringUTF(env, _(message));
+#endif
 
 }
 
 JNIEXPORT jobject JNICALL Java_ZOO_updateStatus
-  (JNIEnv *env, jclass class, jobject conf, jstring pourc, jstring msg){
+  (JNIEnv *env, jclass _class, jobject conf, jstring pourc, jstring msg){
 
   jclass scHashMapClass,scHashMap_class;
 #ifdef JAVA7
   scHashMapClass = (*env).FindClass("java/util/HashMap");
+  const char *pourcent = (*env).GetStringUTFChars(pourc,0);
+  const char *message = (*env).GetStringUTFChars(msg,0);
 #else
   scHashMapClass = (*env)->FindClass(env, "java/util/HashMap");
-#endif
   const char *pourcent = (*env)->GetStringUTFChars(env,pourc, 0);
   const char *message = (*env)->GetStringUTFChars(env,msg, 0);
+#endif
   maps* m = mapsFromHashMap(env,conf,scHashMapClass);
   setMapInMaps(m,"lenv","status",pourcent);
Index: trunk/zoo-project/zoo-services/gdal/contour/service.c
===================================================================
--- trunk/zoo-project/zoo-services/gdal/contour/service.c	(revision 765)
+++ trunk/zoo-project/zoo-services/gdal/contour/service.c	(revision 766)
@@ -388,5 +388,5 @@
                                  OGR_FD_GetFieldIndex( OGR_L_GetLayerDefn( hLayer ), 
                                                        pszElevAttrib ), 
-                         pfnProgress1, conf );
+				(GDALProgressFunc)pfnProgress1, conf );
 
     OGR_DS_Destroy( hDS );
Index: trunk/zoo-project/zoo-services/ogr/base-vect-ops/service.c
===================================================================
--- trunk/zoo-project/zoo-services/ogr/base-vect-ops/service.c	(revision 765)
+++ trunk/zoo-project/zoo-services/ogr/base-vect-ops/service.c	(revision 766)
@@ -26,4 +26,7 @@
 #include "ogr_api.h"
 #include "ogr_geometry.h"
+#if GDAL_VERSION_MAJOR >= 2
+#include <gdal_priv.h>
+#endif
 
 #include "cpl_minixml.h"
@@ -41,9 +44,10 @@
 #include <libxml/xpathInternals.h>
 
-#include <openssl/sha.h>
+/*#include <openssl/sha.h>
 #include <openssl/hmac.h>
 #include <openssl/evp.h>
 #include <openssl/bio.h>
 #include <openssl/buffer.h>
+*/
 
   void printExceptionReportResponse(maps*,map*);
@@ -119,5 +123,9 @@
     OGRLayer *poDstLayer;
     const char *oDriver1;
-    OGRDataSource       *poODS;
+#if GDAL_VERSION_MAJOR >= 2
+    GDALDataset *poODS;
+#else
+    OGRDataSource *poODS;
+#endif
     map* tmp=getMapFromMaps(inputs,"InputPolygon","value");
     if(!tmp){
@@ -138,10 +146,21 @@
     VSILFILE *ifile=VSIFileFromMemBuffer(filename,(GByte*)tmp->value,strlen(tmp->value),FALSE);
     VSIFCloseL(ifile);
-    OGRDataSource* ipoDS = OGRSFDriverRegistrar::Open(filename,FALSE);
+
+#if GDAL_VERSION_MAJOR >= 2
+      GDALDataset *ipoDS =
+	(GDALDataset*) GDALOpenEx( filename,
+				   GDAL_OF_READONLY | GDAL_OF_VECTOR,
+				   NULL, NULL, NULL );
+      GDALDriverManager* poR=GetGDALDriverManager();
+      GDALDriver          *poDriver = NULL;
+#else
+      OGRDataSource* ipoDS = 
+	OGRSFDriverRegistrar::Open(filename,FALSE);
+      OGRSFDriverRegistrar    *poR = OGRSFDriverRegistrar::GetRegistrar();
+      OGRSFDriver          *poDriver = NULL;
+#endif
     char pszDestDataSource[100];
     if( ipoDS == NULL )
       {
-	OGRSFDriverRegistrar    *poR = OGRSFDriverRegistrar::GetRegistrar();
-	
 	fprintf( stderr, "FAILURE:\n"
 		 "Unable to open datasource `%s' with the following drivers.\n",
@@ -150,5 +169,9 @@
 	for( int iDriver = 0; iDriver < poR->GetDriverCount(); iDriver++ )
 	  {
+#if GDAL_VERSION_MAJOR >= 2
+	    fprintf( stderr, "  -> %s\n", poR->GetDriver(iDriver)->GetDescription() );
+#else
 	    fprintf( stderr, "  -> %s\n", poR->GetDriver(iDriver)->GetName() );
+#endif
 	  }
 	char tmp[1024];
@@ -173,7 +196,5 @@
 	
 	OGRFeature  *poFeature;
-	
-	OGRSFDriverRegistrar *poR = OGRSFDriverRegistrar::GetRegistrar();
-	OGRSFDriver          *poDriver = NULL;
+
 	int                  iDriver;
 	
@@ -192,5 +213,9 @@
 	     iDriver++ )
 	  {
+#if GDAL_VERSION_MAJOR >=2
+	    if( EQUAL(poR->GetDriver(iDriver)->GetDescription(),oDriver1) )
+#else
 	    if( EQUAL(poR->GetDriver(iDriver)->GetName(),oDriver1) )
+#endif
 	      {
 		poDriver = poR->GetDriver(iDriver);
@@ -206,5 +231,9 @@
 	    for( iDriver = 0; iDriver < poR->GetDriverCount(); iDriver++ )
 	      {
+#if GDAL_VERSION_MAJOR >=2
+		sprintf( emessage,  "%s  -> `%s'\n", emessage, poR->GetDriver(iDriver)->GetDescription() );
+#else
 		sprintf( emessage,  "%s  -> `%s'\n", emessage, poR->GetDriver(iDriver)->GetName() );
+#endif
 	      }
 	    
@@ -214,14 +243,23 @@
 	  }
 	
-	if( !poDriver->TestCapability( ODrCCreateDataSource ) ){
-	  char emessage[1024];
-	  sprintf( emessage,  "%s driver does not support data source creation.\n",
-		   "json" );
-	  setMapInMaps(conf,"lenv","message",emessage);
-	  return SERVICE_FAILED;
-	}
+#if GDAL_VERSION_MAJOR >=2
+	if( !CPLTestBool( CSLFetchNameValueDef(poDriver->GetMetadata(), GDAL_DCAP_CREATE, "FALSE") ) )
+#else
+	if( !poDriver->TestCapability( ODrCCreateDataSource ) )
+#endif
+	  {
+	    char emessage[1024];
+	    sprintf( emessage,  "%s driver does not support data source creation.\n",
+	      "json" );
+	    setMapInMaps(conf,"lenv","message",emessage);
+	    return SERVICE_FAILED;
+	  }
 	
 	char **papszDSCO=NULL;
+#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 ){
 	  char emessage[1024];      
@@ -326,9 +364,10 @@
 
     OGRCleanupAll();
+    dumpMaps(outputs);
     return SERVICE_SUCCEEDED;
 
 }
 
-  int applyOne(maps*& conf,maps*& inputs,maps*& outputs,OGRGeometry* (OGRGeometry::*myFunc)() const,const char* schema){
+int applyOne(maps*& conf,maps*& inputs,maps*& outputs,OGRGeometry* (OGRGeometry::*myFunc)() const,const char* schema){
     OGRRegisterAll();
 
@@ -337,5 +376,9 @@
     OGRLayer *poDstLayer;
     const char *oDriver1;
-    OGRDataSource       *poODS;
+#if GDAL_VERSION_MAJOR >= 2
+    GDALDataset *poODS;
+#else
+    OGRDataSource *poODS;
+#endif
     map* tmp=getMapFromMaps(inputs,"InputPolygon","value");
     if(!tmp){
@@ -356,23 +399,40 @@
     VSILFILE *ifile=VSIFileFromMemBuffer(filename,(GByte*)tmp->value,strlen(tmp->value),FALSE);
     VSIFCloseL(ifile);
-    OGRDataSource* ipoDS = OGRSFDriverRegistrar::Open(filename,FALSE);
+#if GDAL_VERSION_MAJOR >= 2
+    GDALDataset *ipoDS =
+      (GDALDataset*) GDALOpenEx( filename,
+				 GDAL_OF_READONLY | GDAL_OF_VECTOR,
+				 NULL, NULL, NULL );
+    GDALDriverManager* poR=GetGDALDriverManager();
+    GDALDriver          *poDriver = NULL;
+#else
+    OGRDataSource* ipoDS = 
+      OGRSFDriverRegistrar::Open(filename,FALSE);
+    OGRSFDriverRegistrar    *poR = OGRSFDriverRegistrar::GetRegistrar();
+    OGRSFDriver          *poDriver = NULL;
+#endif
     char pszDestDataSource[100];
     if( ipoDS == NULL )
       {
-	OGRSFDriverRegistrar    *poR = OGRSFDriverRegistrar::GetRegistrar();
-	
 	fprintf( stderr, "FAILURE:\n"
 		 "Unable to open datasource `%s' with the following drivers.\n",
 		 filename );
-	
+	char emessage[1024];	
 	for( int iDriver = 0; iDriver < poR->GetDriverCount(); iDriver++ )
 	  {
-	    fprintf( stderr, "  -> %s\n", poR->GetDriver(iDriver)->GetName() );
+#if GDAL_VERSION_MAJOR >=2
+		sprintf( emessage,  "%s  -> `%s'\n", emessage, poR->GetDriver(iDriver)->GetDescription() );
+		fprintf( stderr, "  -> %s\n", poR->GetDriver(iDriver)->GetDescription() );
+#else
+		sprintf( emessage,  "%s  -> `%s'\n", emessage, poR->GetDriver(iDriver)->GetName() );
+		fprintf( stderr, "  -> %s\n", poR->GetDriver(iDriver)->GetName() );
+#endif
 	  }
 	char tmp[1024];
-	sprintf(tmp,"Unable to open datasource `%s' with the following drivers.",filename);
+	sprintf(tmp,"Unable to open datasource `%s' with the following drivers.\n%s",filename,emessage);
 	setMapInMaps(conf,"lenv","message",tmp);
 	return SERVICE_FAILED;
       }
+
     for( int iLayer = 0; iLayer < ipoDS->GetLayerCount();
 	 iLayer++ )
@@ -396,6 +456,4 @@
 	/* -------------------------------------------------------------------- */
 	
-	OGRSFDriverRegistrar *poR = OGRSFDriverRegistrar::GetRegistrar();
-	OGRSFDriver          *poDriver = NULL;
 	int                  iDriver;
 	
@@ -414,5 +472,12 @@
 	     iDriver++ )
 	  {
-	    if( EQUAL(poR->GetDriver(iDriver)->GetName(),oDriver1) )
+
+	    if( EQUAL(
+#if GDAL_VERSION_MAJOR >=2
+		      poR->GetDriver(iDriver)->GetDescription()
+#else
+		      poR->GetDriver(iDriver)->GetName()
+#endif
+		      ,oDriver1) )
 	      {
 		poDriver = poR->GetDriver(iDriver);
@@ -425,8 +490,11 @@
 	    sprintf( emessage, "Unable to find driver `%s'.\n", oDriver );
 	    sprintf( emessage,  "%sThe following drivers are available:\n",emessage );
-	    
-	    for( iDriver = 0; iDriver < poR->GetDriverCount(); iDriver++ )
-	      {
+	    for( iDriver = 0;iDriver < poR->GetDriverCount();iDriver++ )	    
+	      {
+#if GDAL_VERSION_MAJOR >=2
+		sprintf( emessage,  "%s  -> `%s'\n", emessage, poR->GetDriver(iDriver)->GetDescription() );
+#else
 		sprintf( emessage,  "%s  -> `%s'\n", emessage, poR->GetDriver(iDriver)->GetName() );
+#endif
 	      }
 	    
@@ -436,5 +504,10 @@
 	  }
 	
-	if( !poDriver->TestCapability( ODrCCreateDataSource ) ){
+#if GDAL_VERSION_MAJOR >=2
+	if( !CPLTestBool( CSLFetchNameValueDef(poDriver->GetMetadata(), GDAL_DCAP_CREATE, "FALSE") ) )
+#else
+	if( !poDriver->TestCapability( ODrCCreateDataSource ) )
+#endif
+	{
 	  char emessage[1024];
 	  sprintf( emessage,  "%s driver does not support data source creation.\n",
@@ -449,5 +522,9 @@
 	//map* tpath=getMapFromMaps(conf,"main","tmpPath");
 	char **papszDSCO=NULL;
+#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 ){
 	  char emessage[1024];      
@@ -471,5 +548,4 @@
 	  }
 	
-	//CPLErrorReset();
 	
 	poDstLayer = poODS->CreateLayer( "Result", NULL,wkbUnknown,NULL);
@@ -566,5 +642,9 @@
     OGRLayer *poDstLayer;
     const char *oDriver1;
-    OGRDataSource       *poODS;
+#if GDAL_VERSION_MAJOR >= 2
+    GDALDataset *poODS;
+#else
+    OGRDataSource *poODS;
+#endif
     map* tmp=getMapFromMaps(inputs,"InputPolygon","value");
     if(!tmp){
@@ -585,9 +665,20 @@
     VSILFILE *ifile=VSIFileFromMemBuffer(filename,(GByte*)tmp->value,strlen(tmp->value),FALSE);
     VSIFCloseL(ifile);
-    OGRDataSource* ipoDS = OGRSFDriverRegistrar::Open(filename,FALSE);
+#if GDAL_VERSION_MAJOR >= 2
+      GDALDataset *ipoDS =
+	(GDALDataset*) GDALOpenEx( filename,
+				   GDAL_OF_READONLY | GDAL_OF_VECTOR,
+				   NULL, NULL, NULL );
+      GDALDriverManager* poR=GetGDALDriverManager();
+      GDALDriver          *poDriver = NULL;
+#else
+      OGRDataSource* ipoDS = 
+	OGRSFDriverRegistrar::Open(filename,FALSE);
+      OGRSFDriverRegistrar    *poR = OGRSFDriverRegistrar::GetRegistrar();
+      OGRSFDriver          *poDriver = NULL;
+#endif
     char pszDestDataSource[100];
     if( ipoDS == NULL )
       {
-	OGRSFDriverRegistrar    *poR = OGRSFDriverRegistrar::GetRegistrar();
 	
 	fprintf( stderr, "FAILURE:\n"
@@ -597,5 +688,9 @@
 	for( int iDriver = 0; iDriver < poR->GetDriverCount(); iDriver++ )
 	  {
+#if GDAL_VERSION_MAJOR >= 2
+	    fprintf( stderr, "  -> %s\n", poR->GetDriver(iDriver)->GetDescription() );
+#else
 	    fprintf( stderr, "  -> %s\n", poR->GetDriver(iDriver)->GetName() );
+#endif
 	  }
 	char tmp[1024];
@@ -625,6 +720,4 @@
 	/* -------------------------------------------------------------------- */
 	
-	OGRSFDriverRegistrar *poR = OGRSFDriverRegistrar::GetRegistrar();
-	OGRSFDriver          *poDriver = NULL;
 	int                  iDriver;
 	
@@ -643,5 +736,9 @@
 	     iDriver++ )
 	  {
+#if GDAL_VERSION_MAJOR >=2
+	    if( EQUAL(poR->GetDriver(iDriver)->GetDescription(),oDriver1) )
+#else
 	    if( EQUAL(poR->GetDriver(iDriver)->GetName(),oDriver1) )
+#endif
 	      {
 		poDriver = poR->GetDriver(iDriver);
@@ -657,5 +754,9 @@
 	    for( iDriver = 0; iDriver < poR->GetDriverCount(); iDriver++ )
 	      {
+#if GDAL_VERSION_MAJOR >=2
+		sprintf( emessage,  "%s  -> `%s'\n", emessage, poR->GetDriver(iDriver)->GetDescription() );
+#else
 		sprintf( emessage,  "%s  -> `%s'\n", emessage, poR->GetDriver(iDriver)->GetName() );
+#endif
 	      }
 	    
@@ -665,5 +766,10 @@
 	  }
 	
-	if( !poDriver->TestCapability( ODrCCreateDataSource ) ){
+#if GDAL_VERSION_MAJOR >=2
+	if( !CPLTestBool( CSLFetchNameValueDef(poDriver->GetMetadata(), GDAL_DCAP_CREATE, "FALSE") ) )
+#else
+	if( !poDriver->TestCapability( ODrCCreateDataSource ) )
+#endif
+	{
 	  char emessage[1024];
 	  sprintf( emessage,  "%s driver does not support data source creation.\n",
@@ -678,5 +784,9 @@
 	//map* tpath=getMapFromMaps(conf,"main","tmpPath");
 	char **papszDSCO=NULL;
+#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 ){
 	  char emessage[1024];      
@@ -779,36 +889,5 @@
   __declspec(dllexport)
 #endif
-  int Boundary(maps*& conf,maps*& inputs,maps*& outputs){
-    return applyOne(conf,inputs,outputs,&OGRGeometry::Boundary,"http://fooa/gml/3.1.0/polygon.xsd");
-  }
-
-#ifdef WIN32
-  __declspec(dllexport)
-#endif
-  int ConvexHull(maps*& conf,maps*& inputs,maps*& outputs){
-    return applyOne(conf,inputs,outputs,&OGRGeometry::ConvexHull,"http://fooa/gml/3.1.0/polygon.xsd");
-  }
-
-
-  OGRDataSource* loadEntity(maps* conf,maps* inputs,char **filename,const char **oDriver,const char *entity,int iter){
-    map* tmp=getMapFromMaps(inputs,entity,"value");
-    map* tmp1=getMapFromMaps(inputs,entity,"mimeType");
-    *oDriver="GeoJSON";
-    sprintf(*filename,"/vsimem/input_%d.json",getpid()+iter);
-    if(tmp1!=NULL){
-      if(strcmp(tmp1->value,"text/xml")==0){
-	sprintf(*filename,"/vsimem/input_%d.xml",getpid()+iter);
-	*oDriver="GML";
-      }
-    }
-    VSILFILE *ifile=VSIFileFromMemBuffer(*filename,(GByte*)tmp->value,strlen(tmp->value),FALSE);
-    VSIFCloseL(ifile);
-    return OGRSFDriverRegistrar::Open(*filename,FALSE);    
-  }
-
-  int applyOneBool(maps*& conf,maps*& inputs,maps*& outputs,OGRBoolean (OGRGeometry::*myFunc)() const){
-#ifdef DEBUG
-    fprintf(stderr,"\nService internal print\n");
-#endif
+int Centroid(maps*& conf,maps*& inputs,maps*& outputs){
     OGRRegisterAll();
 
@@ -817,7 +896,8 @@
     OGRLayer *poDstLayer;
     const char *oDriver1;
-    OGRDataSource       *poODS;
-#ifdef DEBUG
-    dumpMaps(cursor);
+#if GDAL_VERSION_MAJOR >= 2
+    GDALDataset *poODS;
+#else
+    OGRDataSource *poODS;
 #endif
     map* tmp=getMapFromMaps(inputs,"InputPolygon","value");
@@ -839,9 +919,20 @@
     VSILFILE *ifile=VSIFileFromMemBuffer(filename,(GByte*)tmp->value,strlen(tmp->value),FALSE);
     VSIFCloseL(ifile);
-    OGRDataSource* ipoDS = OGRSFDriverRegistrar::Open(filename,FALSE);
+#if GDAL_VERSION_MAJOR >= 2
+      GDALDataset *ipoDS =
+	(GDALDataset*) GDALOpenEx( filename,
+				   GDAL_OF_READONLY | GDAL_OF_VECTOR,
+				   NULL, NULL, NULL );
+      GDALDriverManager* poR=GetGDALDriverManager();
+      GDALDriver          *poDriver = NULL;
+#else
+      OGRDataSource* ipoDS = 
+	OGRSFDriverRegistrar::Open(filename,FALSE);
+      OGRSFDriverRegistrar    *poR = OGRSFDriverRegistrar::GetRegistrar();
+      OGRSFDriver          *poDriver = NULL;
+#endif
     char pszDestDataSource[100];
     if( ipoDS == NULL )
       {
-	OGRSFDriverRegistrar    *poR = OGRSFDriverRegistrar::GetRegistrar();
 	
 	fprintf( stderr, "FAILURE:\n"
@@ -851,5 +942,304 @@
 	for( int iDriver = 0; iDriver < poR->GetDriverCount(); iDriver++ )
 	  {
+#if GDAL_VERSION_MAJOR >= 2
+	    fprintf( stderr, "  -> %s\n", poR->GetDriver(iDriver)->GetDescription() );
+#else
 	    fprintf( stderr, "  -> %s\n", poR->GetDriver(iDriver)->GetName() );
+#endif
+	  }
+	char tmp[1024];
+	sprintf(tmp,"Unable to open datasource `%s' with the following drivers.",filename);
+	setMapInMaps(conf,"lenv","message",tmp);
+	return SERVICE_FAILED;
+      }
+    for( int iLayer = 0; iLayer < ipoDS->GetLayerCount();
+	 iLayer++ )
+      {
+	OGRLayer        *poLayer = ipoDS->GetLayer(iLayer);
+	
+	if( poLayer == NULL )
+	  {
+	    fprintf( stderr, "FAILURE: Couldn't fetch advertised layer %d!\n",
+		     iLayer );
+	    char tmp[1024];
+	    sprintf(tmp,"Couldn't fetch advertised layer %d!",iLayer);
+	    setMapInMaps(conf,"lenv","message",tmp);
+	    return SERVICE_FAILED;
+	  }
+	
+	OGRFeature  *poFeature;
+
+	/* -------------------------------------------------------------------- */
+	/*      Try opening the output datasource as an existing, writable      */
+	/* -------------------------------------------------------------------- */
+	
+	int                  iDriver;
+	
+	map* tmpMap=getMapFromMaps(outputs,"Result","mimeType");
+	oDriver1="GeoJSON";
+	sprintf(pszDestDataSource,"/vsimem/result_%d.json",getpid());
+	if(tmpMap!=NULL){
+	  if(strcmp(tmpMap->value,"text/xml")==0){
+	    sprintf(pszDestDataSource,"/vsimem/result_%d.xml",getpid());
+	    oDriver1="GML";
+	  }
+	}
+	
+	for( iDriver = 0;
+	     iDriver < poR->GetDriverCount() && poDriver == NULL;
+	     iDriver++ )
+	  {
+#if GDAL_VERSION_MAJOR >=2
+	    if( EQUAL(poR->GetDriver(iDriver)->GetDescription(),oDriver1) )
+#else
+	    if( EQUAL(poR->GetDriver(iDriver)->GetName(),oDriver1) )
+#endif
+	      {
+		poDriver = poR->GetDriver(iDriver);
+	      }
+	  }
+	
+	if( poDriver == NULL )
+	  {
+	    char emessage[8192];
+	    sprintf( emessage, "Unable to find driver `%s'.\n", oDriver );
+	    sprintf( emessage,  "%sThe following drivers are available:\n",emessage );
+	    
+	    for( iDriver = 0; iDriver < poR->GetDriverCount(); iDriver++ )
+	      {
+#if GDAL_VERSION_MAJOR >=2
+		sprintf( emessage,  "%s  -> `%s'\n", emessage, poR->GetDriver(iDriver)->GetDescription() );
+#else
+		sprintf( emessage,  "%s  -> `%s'\n", emessage, poR->GetDriver(iDriver)->GetName() );
+#endif
+	      }
+	    
+	    setMapInMaps(conf,"lenv","message",emessage);
+	    return SERVICE_FAILED;
+	    
+	  }
+	
+#if GDAL_VERSION_MAJOR >=2
+	if( !CPLTestBool( CSLFetchNameValueDef(poDriver->GetMetadata(), GDAL_DCAP_CREATE, "FALSE") ) )
+#else
+	if( !poDriver->TestCapability( ODrCCreateDataSource ) )
+#endif
+	{
+	  char emessage[1024];
+	  sprintf( emessage,  "%s driver does not support data source creation.\n",
+		   "json" );
+	  setMapInMaps(conf,"lenv","message",emessage);
+	  return SERVICE_FAILED;
+	}
+	
+	/* -------------------------------------------------------------------- */
+	/*      Create the output data source.                                  */
+	/* -------------------------------------------------------------------- */
+	//map* tpath=getMapFromMaps(conf,"main","tmpPath");
+	char **papszDSCO=NULL;
+#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 ){
+	  char emessage[1024];      
+	  sprintf( emessage,  "%s driver failed to create %s\n", 
+		   "json", pszDestDataSource );
+	  setMapInMaps(conf,"lenv","message",emessage);
+	  return SERVICE_FAILED;
+	}
+	
+	/* -------------------------------------------------------------------- */
+	/*      Create the layer.                                               */
+	/* -------------------------------------------------------------------- */
+	if( !poODS->TestCapability( ODsCCreateLayer ) )
+	  {
+	    char emessage[1024];
+	    sprintf( emessage, 
+		     "Layer %s not found, and CreateLayer not supported by driver.", 
+		     "Result" );
+	    setMapInMaps(conf,"lenv","message",emessage);
+	    return SERVICE_FAILED;
+	  }
+
+	poDstLayer = poODS->CreateLayer( "Result", NULL,wkbUnknown,NULL);
+	if( poDstLayer == NULL ){
+	  setMapInMaps(conf,"lenv","message","Layer creation failed.\n");
+	  return SERVICE_FAILED;
+	}
+	
+	OGRFeatureDefn *poFDefn = poLayer->GetLayerDefn();
+	int iField;
+	int hasMmField=0;
+	
+	for( iField = 0; iField < poFDefn->GetFieldCount(); iField++ )
+	  {
+	    OGRFieldDefn *tmp=poFDefn->GetFieldDefn(iField);
+            if (iField >= 0)
+                poDstLayer->CreateField( poFDefn->GetFieldDefn(iField) );
+            else
+            {
+                fprintf( stderr, "Field '%s' not found in source layer.\n", 
+                        iField );
+		return SERVICE_FAILED;
+            }
+	  }
+
+	while(TRUE){
+	  OGRFeature      *poDstFeature = NULL;
+	  poFeature = poLayer->GetNextFeature();
+	  if( poFeature == NULL )
+	    break;
+	  if(poFeature->GetGeometryRef() != NULL){
+	    poDstFeature = OGRFeature::CreateFeature( poDstLayer->GetLayerDefn() );
+	    if( poDstFeature->SetFrom( poFeature, TRUE ) != OGRERR_NONE )
+	      {
+		char tmpMsg[1024];
+		sprintf( tmpMsg,"Unable to translate feature %ld from layer %s.\n",
+			 poFeature->GetFID(), poFDefn->GetName() );
+		
+		OGRFeature::DestroyFeature( poFeature );
+		OGRFeature::DestroyFeature( poDstFeature );
+		return SERVICE_FAILED;
+	      }
+	    OGRPoint* poPoint=new OGRPoint();
+	    poDstFeature->GetGeometryRef()->Centroid(poPoint);
+	    if(poDstFeature->SetGeometryDirectly(poPoint)!= OGRERR_NONE ){
+	      char tmpMsg[1024];
+	      sprintf( tmpMsg,"Unable to translate feature %ld from layer %s.\n",
+		       poFeature->GetFID(), poFDefn->GetName() );
+	      
+	      OGRFeature::DestroyFeature( poFeature );
+	      OGRFeature::DestroyFeature( poDstFeature );
+	      return SERVICE_FAILED;
+	    }
+	    OGRFeature::DestroyFeature( poFeature );
+	    if( poDstLayer->CreateFeature( poDstFeature ) != OGRERR_NONE )
+	      {		
+		OGRFeature::DestroyFeature( poDstFeature );
+		return SERVICE_FAILED;
+	      }
+	    OGRFeature::DestroyFeature( poDstFeature );
+	  }
+	}
+
+      }
+
+    delete poODS;
+    delete ipoDS;
+
+    char *res1=readVSIFile(conf,pszDestDataSource);
+    if(res1==NULL)
+      return SERVICE_FAILED;
+    setMapInMaps(outputs,"Result","value",res1);
+    free(res1);
+
+    OGRCleanupAll();
+    return SERVICE_SUCCEEDED;
+
+}
+
+#ifdef WIN32
+  __declspec(dllexport)
+#endif
+  int Boundary(maps*& conf,maps*& inputs,maps*& outputs){
+    return applyOne(conf,inputs,outputs,&OGRGeometry::Boundary,"http://fooa/gml/3.1.0/polygon.xsd");
+  }
+
+#ifdef WIN32
+  __declspec(dllexport)
+#endif
+  int ConvexHull(maps*& conf,maps*& inputs,maps*& outputs){
+    return applyOne(conf,inputs,outputs,&OGRGeometry::ConvexHull,"http://fooa/gml/3.1.0/polygon.xsd");
+  }
+
+#if GDAL_VERSION_MAJOR >= 2
+GDALDataset*
+#else
+OGRDataSource* 
+#endif
+  loadEntity(maps* conf,maps* inputs,char **filename,const char **oDriver,const char *entity,int iter){
+    map* tmp=getMapFromMaps(inputs,entity,"value");
+    map* tmp1=getMapFromMaps(inputs,entity,"mimeType");
+    *oDriver="GeoJSON";
+    sprintf(*filename,"/vsimem/input_%d.json",getpid()+iter);
+    if(tmp1!=NULL){
+      if(strcmp(tmp1->value,"text/xml")==0){
+	sprintf(*filename,"/vsimem/input_%d.xml",getpid()+iter);
+	*oDriver="GML";
+      }
+    }
+    VSILFILE *ifile=VSIFileFromMemBuffer(*filename,(GByte*)tmp->value,strlen(tmp->value),FALSE);
+    VSIFCloseL(ifile);
+#if GDAL_VERSION_MAJOR >= 2
+    return (GDALDataset*) GDALOpenEx( *filename,
+				      GDAL_OF_READONLY | GDAL_OF_VECTOR,
+				      NULL, NULL, NULL );
+#else
+    return OGRSFDriverRegistrar::Open(*filename,FALSE);    
+#endif
+  }
+
+  int applyOneBool(maps*& conf,maps*& inputs,maps*& outputs,OGRBoolean (OGRGeometry::*myFunc)() const){
+#ifdef DEBUG
+    fprintf(stderr,"\nService internal print\n");
+#endif
+    OGRRegisterAll();
+
+    maps* cursor=inputs;
+    OGRGeometryH geometry,res;
+    OGRLayer *poDstLayer;
+    const char *oDriver1;
+    OGRDataSource       *poODS;
+#ifdef DEBUG
+    dumpMaps(cursor);
+#endif
+    map* tmp=getMapFromMaps(inputs,"InputPolygon","value");
+    if(!tmp){
+      setMapInMaps(conf,"lenv","message",_ss("Unable to parse the input geometry from InputPolygon"));
+      return SERVICE_FAILED;
+    }
+    char filename[1024];
+    map* tmp1=getMapFromMaps(inputs,"InputPolygon","mimeType");
+    const char *oDriver;
+    oDriver="GeoJSON";
+    sprintf(filename,"/vsimem/input_%d.json",getpid());
+    if(tmp1!=NULL){
+      if(strcmp(tmp1->value,"text/xml")==0){
+	sprintf(filename,"/vsimem/input_%d.xml",getpid());
+	oDriver="GML";
+      }
+    }
+    VSILFILE *ifile=VSIFileFromMemBuffer(filename,(GByte*)tmp->value,strlen(tmp->value),FALSE);
+    VSIFCloseL(ifile);
+
+#if GDAL_VERSION_MAJOR >= 2
+      GDALDataset *ipoDS =
+	(GDALDataset*) GDALOpenEx( filename,
+				   GDAL_OF_READONLY | GDAL_OF_VECTOR,
+				   NULL, NULL, NULL );
+      GDALDriverManager* poR=GetGDALDriverManager();
+      GDALDriver          *poDriver = NULL;
+#else
+      OGRDataSource* ipoDS = 
+	OGRSFDriverRegistrar::Open(filename,FALSE);
+      OGRSFDriverRegistrar    *poR = OGRSFDriverRegistrar::GetRegistrar();
+      OGRSFDriver          *poDriver = NULL;
+#endif
+    char pszDestDataSource[100];
+    if( ipoDS == NULL )
+      {	
+	fprintf( stderr, "FAILURE:\n"
+		 "Unable to open datasource `%s' with the following drivers.\n",
+		 filename );
+	
+	for( int iDriver = 0; iDriver < poR->GetDriverCount(); iDriver++ )
+	  {
+#if GDAL_VERSION_MAJOR >= 2
+	    fprintf( stderr, "  -> %s\n", poR->GetDriver(iDriver)->GetDescription() );
+#else
+	    fprintf( stderr, "  -> %s\n", poR->GetDriver(iDriver)->GetName() );
+#endif
 	  }
 	char tmp[1024];
@@ -933,5 +1323,4 @@
     OGRLayer *poDstLayer;
     //const char *oDriver1;
-    OGRDataSource       *poODS;
 #ifdef DEBUG
     dumpMaps(cursor);
@@ -940,14 +1329,31 @@
     char *filename=(char*)malloc(1024*sizeof(char));
     const char *oDriver1;
-    OGRDataSource* ipoDS1 = loadEntity(conf,inputs,&filename,&oDriver1,"InputEntity1",1);
-
+#if GDAL_VERSION_MAJOR >= 2
+    GDALDataset*
+#else
+    OGRDataSource* 
+#endif
+      ipoDS1 = loadEntity(conf,inputs,&filename,&oDriver1,"InputEntity1",1);
     char *filename1=(char*)malloc(1024*sizeof(char));
     const char *oDriver2;
-    OGRDataSource* ipoDS2 = loadEntity(conf,inputs,&filename1,&oDriver2,"InputEntity2",2);
+#if GDAL_VERSION_MAJOR >= 2
+    GDALDataset*
+#else
+    OGRDataSource* 
+#endif
+      ipoDS2 = loadEntity(conf,inputs,&filename1,&oDriver2,"InputEntity2",2);
     const char *oDriver3;
     char pszDestDataSource[100];
+#if GDAL_VERSION_MAJOR >= 2
+      GDALDriverManager* poR=GetGDALDriverManager();
+      GDALDriver          *poDriver = NULL;
+      GDALDataset *poODS;
+#else
+      OGRDataSource       *poODS;
+      OGRSFDriverRegistrar    *poR = OGRSFDriverRegistrar::GetRegistrar();
+      OGRSFDriver          *poDriver = NULL;
+#endif
     if( ipoDS1 == NULL || ipoDS2 == NULL )
       {
-	OGRSFDriverRegistrar    *poR = OGRSFDriverRegistrar::GetRegistrar();
 	
 	fprintf( stderr, "FAILURE:\n"
@@ -957,5 +1363,9 @@
 	for( int iDriver = 0; iDriver < poR->GetDriverCount(); iDriver++ )
 	  {
+#if GDAL_VERSION_MAJOR >= 2
+	    fprintf( stderr, "  -> %s\n", poR->GetDriver(iDriver)->GetDescription() );
+#else
 	    fprintf( stderr, "  -> %s\n", poR->GetDriver(iDriver)->GetName() );
+#endif
 	  }
 	char tmp[1024];
@@ -1003,6 +1413,4 @@
 	    /* -------------------------------------------------------------------- */
 	    
-	    OGRSFDriverRegistrar *poR = OGRSFDriverRegistrar::GetRegistrar();
-	    OGRSFDriver          *poDriver = NULL;
 	    int                  iDriver;
 	    
@@ -1021,8 +1429,9 @@
 		 iDriver++ )
 	      {
-#ifdef DEBUG
-		fprintf(stderr,"D:%s\n",poR->GetDriver(iDriver)->GetName());
-#endif
-		if( EQUAL(poR->GetDriver(iDriver)->GetName(),oDriver3) )
+#if GDAL_VERSION_MAJOR >=2
+		if( EQUAL(poR->GetDriver(iDriver)->GetDescription(),oDriver1) )
+#else
+		if( EQUAL(poR->GetDriver(iDriver)->GetName(),oDriver1) )
+#endif
 		  {
 		    poDriver = poR->GetDriver(iDriver);
@@ -1038,5 +1447,9 @@
 		for( iDriver = 0; iDriver < poR->GetDriverCount(); iDriver++ )
 		  {
+#if GDAL_VERSION_MAJOR >= 2
+		    sprintf( emessage,  "%s  -> `%s'\n", emessage, poR->GetDriver(iDriver)->GetDescription() );
+#else
 		    sprintf( emessage,  "%s  -> `%s'\n", emessage, poR->GetDriver(iDriver)->GetName() );
+#endif
 		  }
 		
@@ -1046,11 +1459,16 @@
 	      }
 	    
-	    if( !poDriver->TestCapability( ODrCCreateDataSource ) ){
-	      char emessage[1024];
-	      sprintf( emessage,  "%s driver does not support data source creation.\n",
-		       "json" );
-	      setMapInMaps(conf,"lenv","message",emessage);
-	      return SERVICE_FAILED;
-	    }
+#if GDAL_VERSION_MAJOR >= 2
+	    if( !CPLTestBool( CSLFetchNameValueDef(poDriver->GetMetadata(), GDAL_DCAP_CREATE, "FALSE") ) )
+#else
+	    if( !poDriver->TestCapability( ODrCCreateDataSource ) )
+#endif
+	      {
+		char emessage[1024];
+		sprintf( emessage,  "%s driver does not support data source creation.\n",
+			 "json" );
+		setMapInMaps(conf,"lenv","message",emessage);
+		return SERVICE_FAILED;
+	      }
 	    
 	    /* -------------------------------------------------------------------- */
@@ -1059,5 +1477,9 @@
 	    //map* tpath=getMapFromMaps(conf,"main","tmpPath");
 	    char **papszDSCO=NULL;
+#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 ){
 	      char emessage[1024];      
@@ -1204,19 +1626,39 @@
     OGRGeometryH geometry,res;
     OGRLayer *poDstLayer;
-    OGRDataSource       *poODS;
+#if GDAL_VERSION_MAJOR >= 2
+    GDALDataset *poODS;
+#else
+    OGRDataSource *poODS;
+#endif
 
     char *filename=(char*)malloc(1024*sizeof(char));
     const char *oDriver1;
-    OGRDataSource* ipoDS1 = loadEntity(conf,inputs,&filename,&oDriver1,"InputEntity1",1);
+#if GDAL_VERSION_MAJOR >= 2
+    GDALDataset*
+#else
+    OGRDataSource*
+#endif
+      ipoDS1 = loadEntity(conf,inputs,&filename,&oDriver1,"InputEntity1",1);
 
     char *filename1=(char*)malloc(1024*sizeof(char));
     const char *oDriver2;
-    OGRDataSource* ipoDS2 = loadEntity(conf,inputs,&filename1,&oDriver2,"InputEntity2",2);
+#if GDAL_VERSION_MAJOR >= 2
+    GDALDataset*
+#else
+    OGRDataSource*
+#endif
+      ipoDS2 = loadEntity(conf,inputs,&filename1,&oDriver2,"InputEntity2",2);
     const char *oDriver3;
     char pszDestDataSource[100];
+#if GDAL_VERSION_MAJOR >= 2
+      GDALDriverManager* poR=GetGDALDriverManager();
+      GDALDriver          *poDriver = NULL;
+#else
+      OGRSFDriverRegistrar    *poR = OGRSFDriverRegistrar::GetRegistrar();
+      OGRSFDriver          *poDriver = NULL;
+#endif
+
     if( ipoDS1 == NULL || ipoDS2 == NULL )
       {
-	OGRSFDriverRegistrar    *poR = OGRSFDriverRegistrar::GetRegistrar();
-	
 	fprintf( stderr, "FAILURE:\n"
 		 "Unable to open datasource `%s' with the following drivers.\n",
@@ -1225,5 +1667,9 @@
 	for( int iDriver = 0; iDriver < poR->GetDriverCount(); iDriver++ )
 	  {
+#if GDAL_VERSION_MAJOR >= 2
+	    fprintf( stderr, "  -> %s\n", poR->GetDriver(iDriver)->GetDescription() );
+#else
 	    fprintf( stderr, "  -> %s\n", poR->GetDriver(iDriver)->GetName() );
+#endif
 	  }
 	char tmp[1024];
Index: trunk/zoo-project/zoo-services/ogr/ogr2ogr/service.c
===================================================================
--- trunk/zoo-project/zoo-services/ogr/ogr2ogr/service.c	(revision 765)
+++ 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)
 		
 {
