Index: branches/prototype-v0/zoo-project/zoo-services/cgal/Makefile
===================================================================
--- branches/prototype-v0/zoo-project/zoo-services/cgal/Makefile	(revision 856)
+++ branches/prototype-v0/zoo-project/zoo-services/cgal/Makefile	(revision 862)
@@ -1,5 +1,5 @@
 ZRPATH=../..
 include ${ZRPATH}/zoo-kernel/ZOOMakefile.opts
-CFLAGS=-I${INST_INCLUDE} ${ZOO_CFLAGS} ${XML2CFLAGS} ${GDAL_CFLAGS} ${PYTHONCFLAGS} ${CGAL_CFLAGS} -frounding-math -fPIC -DLINUX_FREE_ISSUE #-DDEBUG
+CFLAGS= ${ZOO_CFLAGS} ${XML2CFLAGS} ${GDAL_CFLAGS} ${PYTHONCFLAGS} ${CGAL_CFLAGS} -frounding-math -fPIC -DLINUX_FREE_ISSUE #-DDEBUG
 CC=gcc
 
@@ -7,5 +7,5 @@
 	g++ ${CFLAGS} -c ./delaunay.c
 	g++ ${CFLAGS} -c ./voronoi.c
-	g++ ${CFLAGS} -shared -o cgi-env/cgal_service.zo ./delaunay.o ./voronoi.o ./cgal_service.o ${GDAL_LIBS} ${MACOS_LD_FLAGS} ${CGAL_LDFLAGS} -lCGAL -lgmp ${GDAL_LIBS} -L${ZRPATH}/zoo-kernel/ -lzoo_service
+	g++ ${CFLAGS} -shared -o cgi-env/cgal_service.zo ./delaunay.o ./voronoi.o ./cgal_service.o ${GDAL_LIBS} ${CGAL_LDFLAGS} -lCGAL -lgmp ${GDAL_LIBS} -L${ZRPATH}/zoo-kernel/ -lzoo_service -lfcgi
 
 cgal_service.o: cgal_service.c cgal_service.h
Index: branches/prototype-v0/zoo-project/zoo-services/cgal/cgal_service.c
===================================================================
--- branches/prototype-v0/zoo-project/zoo-services/cgal/cgal_service.c	(revision 856)
+++ branches/prototype-v0/zoo-project/zoo-services/cgal/cgal_service.c	(revision 862)
@@ -24,5 +24,5 @@
 #include "cgal_service.h"
 
-int parseInput(maps* conf,maps* inputs, std::vector<Point>* points,char* filename){
+int parseInput(maps* conf,maps* inputs, std::vector<Pointz>* points,char* filename){
   map* tmpm=NULL;
   tmpm=getMapFromMaps(inputs,"InputPoints","value");
@@ -87,5 +87,5 @@
 	  break;
 	if(poFeature->GetGeometryRef() != NULL){
-	  points->push_back(Point(OGR_G_GetX(poFeature->GetGeometryRef(),0),OGR_G_GetY(poFeature->GetGeometryRef(),0)));
+	  points->push_back(Pointz(OGR_G_GetX(poFeature->GetGeometryRef(),0),OGR_G_GetY(poFeature->GetGeometryRef(),0)));
 	}
       }
Index: branches/prototype-v0/zoo-project/zoo-services/cgal/cgal_service.h
===================================================================
--- branches/prototype-v0/zoo-project/zoo-services/cgal/cgal_service.h	(revision 856)
+++ branches/prototype-v0/zoo-project/zoo-services/cgal/cgal_service.h	(revision 862)
@@ -38,7 +38,7 @@
 
 typedef CGAL::Exact_predicates_inexact_constructions_kernel            Kernel;
-typedef Kernel::Point_2                                                Point;
+typedef Kernel::Point_2                                                Pointz;
 
-int parseInput(maps*,maps*, std::vector<Point>*,char*);
+int parseInput(maps*,maps*, std::vector<Pointz>*,char*);
 
 #endif
Index: branches/prototype-v0/zoo-project/zoo-services/cgal/cgi-env/Voronoi.zcfg
===================================================================
--- branches/prototype-v0/zoo-project/zoo-services/cgal/cgi-env/Voronoi.zcfg	(revision 856)
+++ branches/prototype-v0/zoo-project/zoo-services/cgal/cgi-env/Voronoi.zcfg	(revision 862)
@@ -46,4 +46,10 @@
     </Default>
     <Supported>
+      mimeType = image/png
+      useMapserver = true
+      asReference = true
+      msStyle = STYLE COLOR 125 0 105 OUTLINECOLOR 0 0 0 WIDTH 0.3 OPACITY 65 END
+    </Supported>
+    <Supported>
      mimeType = text/xml
      encoding = base64
Index: branches/prototype-v0/zoo-project/zoo-services/cgal/delaunay.c
===================================================================
--- branches/prototype-v0/zoo-project/zoo-services/cgal/delaunay.c	(revision 856)
+++ branches/prototype-v0/zoo-project/zoo-services/cgal/delaunay.c	(revision 862)
@@ -40,5 +40,5 @@
     OGRRegisterAll();
 
-    std::vector<Point> points;
+    std::vector<Pointz> points;
     if(int res=parseInput(conf,inputs,&points,"/vsimem/tmp")!=SERVICE_SUCCEEDED)
       return res;
Index: branches/prototype-v0/zoo-project/zoo-services/cgal/voronoi.c
===================================================================
--- branches/prototype-v0/zoo-project/zoo-services/cgal/voronoi.c	(revision 856)
+++ branches/prototype-v0/zoo-project/zoo-services/cgal/voronoi.c	(revision 862)
@@ -24,7 +24,7 @@
 
 #include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
-#include <CGAL/Triangulation_euclidean_traits_xy_3.h>
+//#include <CGAL/Triangulation_euclidean_traits_2.h>
 #include <CGAL/Delaunay_triangulation_2.h>
-#include <CGAL/Constrained_Delaunay_triangulation_2.h>
+//#include <CGAL/Constrained_Delaunay_triangulation_2.h>
 #include <CGAL/Triangulation_conformer_2.h>
 #include <CGAL/Triangulation_face_base_2.h>
@@ -39,4 +39,5 @@
 
 typedef CGAL::Delaunay_triangulation_2<Kernel>  Triangulation;
+typedef Triangulation::Face_iterator  Face_iterator;
 typedef Triangulation::Edge_iterator  Edge_iterator;
 typedef Triangulation::Vertex_circulator Vertex_circulator;
@@ -45,7 +46,8 @@
 
   int Voronoi(maps*& conf,maps*& inputs,maps*& outputs){
-#ifdef DEBUG
+    //#ifdef DEBUG
     fprintf(stderr,"\nService internal print\nStarting\n");
-#endif
+    //#endif
+    //return SERVICE_FAILED;
     maps* cursor=inputs;
     OGRGeometryH geometry,res;
@@ -54,14 +56,22 @@
     tmpm=getMapFromMaps(inputs,"InputPoints","value");
 
+    fprintf(stderr," **** %s %d\n",__FILE__,__LINE__);
+    fflush(stderr);
+
     OGRRegisterAll();
 
-    std::vector<Point> points;
-    if(int res=parseInput(conf,inputs,&points,"/vsimem/tmp")!=SERVICE_SUCCEEDED)
-      return res;
+    std::vector<Pointz> points;
+    if(int res=parseInput(conf,inputs,&points,"/vsimem/tmp")!=SERVICE_SUCCEEDED){
+      fprintf(stderr," **** %s %d\n",__FILE__,__LINE__);
+      fflush(stderr);
+      return SERVICE_FAILED;
+    }
+    fprintf(stderr," **** %s %d\n",__FILE__,__LINE__);
+    fflush(stderr);
     
     Triangulation T;
     T.insert(points.begin(), points.end());
 
-    OGRRegisterAll();
+    //OGRRegisterAll();
     /* -------------------------------------------------------------------- */
     /*      Try opening the output datasource as an existing, writable      */
@@ -191,6 +201,6 @@
       CGAL::Object o = T.dual(eit);
       if (const Kernel::Segment_2 *tmp=CGAL::object_cast<Kernel::Segment_2>(&o)) {
-	const Point p1=tmp->source();
-	const Point p2=tmp->target();
+	const Pointz p1=tmp->source();
+	const Pointz p2=tmp->target();
 #ifdef DEBUG
 	fprintf(stderr,"P1 %d %d | P2 %d %d\n",p1.x(),p1.y(),p2.x(),p2.y());
@@ -210,6 +220,6 @@
       }
       else if (const Kernel::Ray_2 *tmp=CGAL::object_cast<Kernel::Ray_2>(&o)) { 
-	const Point p1=tmp->source();
-	const Point p2=tmp->point(2);
+	const Pointz p1=tmp->source();
+	const Pointz p2=tmp->point(2);
 	OGRFeatureH hFeature = OGR_F_Create( OGR_L_GetLayerDefn( poDstLayer ) );
 	OGRGeometryH currLine=OGR_G_CreateGeometry(wkbLineString);
@@ -250,5 +260,5 @@
     fprintf(stderr,"\nService internal print\n===\n");
 #endif
-    OGRCleanupAll();
+    //OGRCleanupAll();
     return SERVICE_SUCCEEDED;
   }
Index: branches/prototype-v0/zoo-project/zoo-services/ogr/ogr2ogr/service.c
===================================================================
--- branches/prototype-v0/zoo-project/zoo-services/ogr/ogr2ogr/service.c	(revision 856)
+++ branches/prototype-v0/zoo-project/zoo-services/ogr/ogr2ogr/service.c	(revision 862)
@@ -96,4 +96,5 @@
 #endif
 {
+    const char  *pszDialect = NULL;
     const char  *pszFormat = "ESRI Shapefile";
     const char  *pszDataSource = NULL;
@@ -155,5 +156,5 @@
       sprintf(serverAddress,"%s",tmpMap->value);
     }
-    
+
     tmpMap=NULL;
     char tmpurl[1024];
@@ -223,4 +224,9 @@
     if(tmpMap!=NULL && strncasecmp(tmpMap->value,"NULL",4)!=0){
       pszSQLStatement = tmpMap->value;
+    }
+
+    tmpMap=getMapFromMaps(inputs,"dialect","value");
+    if(tmpMap!=NULL){
+      pszDialect=strdup(tmpMap->value);
     }
 
@@ -367,4 +373,5 @@
     }*/
 
+   
     tmpMap=NULL;
     tmpMap=getMapFromMaps(inputs,"InputDSN","value");
@@ -825,5 +832,5 @@
         
         poResultSet = poDS->ExecuteSQL( pszSQLStatement, poSpatialFilter, 
-                                        NULL );
+                                        pszDialect );
 
         if( poResultSet != NULL )
@@ -841,6 +848,13 @@
             }
             poDS->ReleaseResultSet( poResultSet );
-        }
-    }
+        }else{
+	  setMapInMaps(conf,"lenv","message","There was an error when running yoru SQL query.");
+	  if(pszDialect!=NULL)
+	    free(pszDialect);
+	  return SERVICE_FAILED;
+	}
+    }
+    if(pszDialect!=NULL)
+      free(pszDialect);
 
 /* -------------------------------------------------------------------- */
@@ -901,5 +915,6 @@
 
 #ifdef ZOO_SERVICE
-    outputs->content=createMap("value",(char*)pszwebDestData);
+    setMapInMaps(outputs,"OutputedDataSourceName","value",(char*)pszwebDestData);
+    //outputs->content=createMap("value",(char*)pszwebDestData);
 #endif
 
@@ -930,5 +945,5 @@
     fprintf(stderr,"%s %d\n",__FILE__,__LINE__);
 
-    OGRCleanupAll();
+    //OGRCleanupAll();
     fprintf(stderr,"%s %d\n",__FILE__,__LINE__);
 
@@ -939,4 +954,5 @@
     
 #ifdef ZOO_SERVICE
+    //sleep(10);
     return SERVICE_SUCCEEDED;
 #else
Index: branches/prototype-v0/zoo-project/zoo-services/utils/hpc/service.c
===================================================================
--- branches/prototype-v0/zoo-project/zoo-services/utils/hpc/service.c	(revision 856)
+++ branches/prototype-v0/zoo-project/zoo-services/utils/hpc/service.c	(revision 862)
@@ -2,5 +2,5 @@
  * Author : Gérald FENOY
  *
- * Copyright 2008-2009 GeoLabs SARL. All rights reserved.
+ * Copyright 2017 GeoLabs SARL. All rights reserved.
  *
  * This work was supported by public funds received in the framework of GEOSUD,
Index: branches/prototype-v0/zoo-project/zoo-services/utils/hpc/service2.c
===================================================================
--- branches/prototype-v0/zoo-project/zoo-services/utils/hpc/service2.c	(revision 856)
+++ branches/prototype-v0/zoo-project/zoo-services/utils/hpc/service2.c	(revision 862)
@@ -2,6 +2,10 @@
  * Author : Gérald FENOY
  *
- * Copyright 2008-2009 GeoLabs SARL. All rights reserved.
- * 
+ * Copyright 2017 GeoLabs SARL. All rights reserved.
+ *
+ * This work was supported by public funds received in the framework of GEOSUD,
+ * a project (ANR-10-EQPX-20) of the program "Investissements d'Avenir" managed
+ * by the French National Research Agency
+ *
  * This work was supported by public funds received in the framework of GEOSUD,
  * a project (ANR-10-EQPX-20) of the program "Investissements d'Avenir" managed
@@ -42,5 +46,47 @@
 
 #include <dirent.h>
+#include <string.h>
+#include <cerrno>
+
 extern "C" {
+
+  /** 
+   * Retrieve the error message which occured when trying to remove a file
+   * (return values can be EACCES, EBUSY, EFAULT, EIO, EISDIR, ELOOP, 
+   * ENAMETOOLONG, ENOENT, ENOMEM, ENOTDIR, EPERM, EROFS, UNKNOWN).
+   *
+   * @param errn
+   * @result a string corresponding to the error number 
+   */ 
+  char* fetchErrno(int errn){
+   switch(errn){
+    case EACCES:
+	return "EACCES";
+    case EBUSY:
+	return "EBUSY";
+    case EFAULT:
+	return "EFAULT";
+    case EIO:
+	return "EIO";
+    case EISDIR:
+	return "EISDIR";
+    case ELOOP:
+	return "ELOOP";
+    case ENAMETOOLONG:
+	return "ENAMETOOLONG";
+    case ENOENT:
+	return "ENOENT";
+    case ENOMEM:
+	return "ENOMEM";
+    case ENOTDIR:
+	return "ENOTDIR";
+    case EPERM:
+	return "EPERM";
+    case EROFS:
+	return "EROFS";
+    default:
+	return "UNKNOWN";
+   }
+  }
 
   /**
@@ -78,11 +124,16 @@
    */
   int tryDeleteDataFile(const char* storage,const char* filename){
-    char* fullpath=(char*)malloc((strlen(storage)+strlen(filename)+2)*sizeof(char));
-    sprintf(fullpath,"%s/%s",storage,filename);
+    char* fullpath=NULL;
+    if(filename!=NULL){
+      fullpath=(char*)malloc((strlen(storage)+strlen(filename)+2)*sizeof(char));
+      sprintf(fullpath,"%s/%s",storage,filename);
+    }
+    else
+      fullpath=zStrdup(storage);
     if(unlink(fullpath)==0){
       // TODO store the filename_full in the deletedfiles
-      fprintf(stderr,"#### DeleteData #### %s %d %s has been successfully deleted\n",__FILE__,__LINE__,filename);
+      fprintf(stderr,"#### DeleteData #### %s %d %s has been successfully deleted\n",__FILE__,__LINE__,(strlen(filename)>0?filename:fullpath));
     }else{
-      fprintf(stderr,"#### DeleteData #### unable to delete %s \n",fullpath);
+      fprintf(stderr,"#### DeleteData #### unable to delete %s %s \n",fullpath,fetchErrno(errno));
     }
     free(fullpath);
@@ -138,14 +189,11 @@
 	}
 	if(fcontent!=NULL && strcasecmp(fcontent,"SHARED")!=0){
-	  // Delete associated zcm and zcp
+	  // Delete associated zcm, zcp and maps files
 	  tryDeleteCacheFile(cacheDir->value,filename->value,"zca");
 	  tryDeleteCacheFile(cacheDir->value,filename->value,"zcm");
 	  tryDeleteCacheFile(cacheDir->value,filename->value,"zcp");
-	  // Delete ZOO_DATA_<input>_<sid>.data and <input>_<sid>.map
+	  tryDeleteCacheFile(tmpPath->value,filename->value,"maps");
+	  // Delete <input>_<sid>.map
 	  char* datafile=(char*)malloc((strlen(jobid->value)+strlen(ioname->value)+19)*sizeof(char));
-	  sprintf(datafile,"ZOO_DATA_%s_%s.data",ioname->value,jobid->value);
-	  tryDeleteDataFile(dataPath->value,datafile);
-	  free(datafile);
-	  datafile=(char*)malloc((strlen(jobid->value)+strlen(ioname->value)+19)*sizeof(char));
 	  sprintf(datafile,"%s_%s.map",ioname->value,jobid->value);
 	  tryDeleteDataFile(dataPath->value,datafile);
@@ -160,6 +208,25 @@
 	char tmp1[8];
 	snprintf(tmp1,7,"%s",filename->value);
-	if(strcasecmp(tmp1,"output")==0){
-	  tryDeleteDataFile(tmpPath->value,filename->value);
+	if(strcasecmp(tmp1,"output")==0 || strcasecmp(tmp1,"input_")==0){
+	  trydeletedatafile(tmppath->value,filename->value);
+          char *tmp=zStrdup(filename->value);
+	  tmp[strlen(tmp)-strlen(strrchr(tmp,'.'))]=0;
+	  char *mapsfile=(char*)malloc((strlen(tmp)+6)*sizeof(char));
+	  sprintf(mapsfile,"%s.maps",tmp);
+          char* mapPath=(char*)malloc((strlen(tmpPath->value)+strlen(mapsfile)+2)*sizeof(char));
+          sprintf(mapPath,"%s/%s",tmpPath->value,mapsfile);
+	  FILE* myMapsfile=fopen(mapPath,"r");
+          if(myMapsfile!=NULL){
+	    char *buffer=(char*)malloc(1024*sizeof(char));
+	    while(fgets(buffer, 1024, myMapsfile) != NULL){
+	      buffer[strlen(buffer)-1]=0;
+	      tryDeleteDataFile(buffer,NULL);
+	    }
+	    free(buffer);
+	    fclose(myMapsfile);
+          }
+          tryDeleteDataFile(mapPath,NULL);
+          free(mapPath);
+          free(mapsfile);
 	  // Delete ZOO_DATA_<output>_<sid>.data and <output>_<sid>.map
 	  char* datafile=(char*)malloc((strlen(jobid->value)+strlen(ioname->value)+19)*sizeof(char));
