Index: trunk/zoo-project/zoo-services/cgal/Makefile
===================================================================
--- trunk/zoo-project/zoo-services/cgal/Makefile	(revision 742)
+++ trunk/zoo-project/zoo-services/cgal/Makefile	(revision 743)
@@ -1,5 +1,5 @@
 ZRPATH=../..
 include ${ZRPATH}/zoo-kernel/ZOOMakefile.opts
-CFLAGS=${ZOO_CFLAGS} ${XML2CFLAGS} ${GDAL_CFLAGS} ${PYTHONCFLAGS} ${CGAL_CFLAGS} -frounding-math -fPIC -DLINUX_FREE_ISSUE #-DDEBUG
+CFLAGS=-I${INST_INCLUDE} ${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 -lgdal -lzoo_service
+	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${INST_LIB}
 
 cgal_service.o: cgal_service.c cgal_service.h
Index: trunk/zoo-project/zoo-services/data-api/cgi-env/query.zcfg
===================================================================
--- trunk/zoo-project/zoo-services/data-api/cgi-env/query.zcfg	(revision 743)
+++ trunk/zoo-project/zoo-services/data-api/cgi-env/query.zcfg	(revision 743)
@@ -0,0 +1,30 @@
+[query]
+ Title = Execute a query using DataAPI
+ Abstract = Execute a query through DataAPI.
+ processVersion = 2
+ storeSupported = true
+ statusSupported = true
+ serviceProvider = service
+ serviceType = Python
+ <DataInputs>
+  [query]
+   Title = JSON Query
+   Abstract = The query to be executed in JSON format.
+   minOccurs = 1
+   maxOccurs = 1
+   <LiteralData>
+    dataType = string
+    <Default />
+   </LiteralData>
+ </DataInputs>
+ <DataOutputs>
+  [Result]
+   Title = Response
+   Abstract = The response to the DataAPI query.
+   <ComplexData>
+    <Default>
+    mimeType = application/json
+    encoding = utf-8
+    </Default>
+   </ComplexData>
+ </DataOutputs>
Index: trunk/zoo-project/zoo-services/data-api/cgi-env/service.py
===================================================================
--- trunk/zoo-project/zoo-services/data-api/cgi-env/service.py	(revision 743)
+++ trunk/zoo-project/zoo-services/data-api/cgi-env/service.py	(revision 743)
@@ -0,0 +1,54 @@
+#!/usr/bin/python
+
+import zoo
+
+import logging
+import logging.config
+import sys
+import errno
+import os
+import json
+import geojson
+import csv
+import argparse
+
+from publicamundi.data.api import *
+
+ERROR_OK = 0
+ERROR_UNKNOWN = 1
+
+def configure_logging(filename):
+    if filename is None:
+        print 'Logging is not configured.'
+    else:
+        logging.config.fileConfig(filename)
+
+def parse_query(filename, text):
+    if not filename is None and os.path.isfile(filename):
+        with open(filename) as query_file:    
+            return json.load(query_file, cls=ShapelyJsonDecoder, encoding='utf-8')
+    if not text is None:
+        return json.loads(text, cls=ShapelyJsonDecoder, encoding='utf-8')
+        
+    return {}
+
+def query(conf,inputs,outputs):    
+    config = {
+        CONFIG_SQL_CATALOG : conf["data-api"]["catalog"],
+        CONFIG_SQL_DATA : conf["data-api"]["vectorstore"],
+        CONFIG_SQL_TIMEOUT : int(conf["data-api"]["timeout"]) * 1000
+    }
+
+    if inputs.keys().count("timeout")>0:
+        config["CONFIG_SQL_TIMEOUT"]=int(inputs["timeout"]["value"]) * 1000
+    
+    metadata = {}
+
+    configure_logging(conf["lenv"]["cwd"]+"/"+conf["lenv"]["metapath"]+"/service.ini")
+    
+    query_executor = QueryExecutor()
+    result = query_executor.execute(config, parse_query(None,inputs["query"]["value"]) )
+    
+    outputs["Result"]["value"]=geojson.dumps(result['data'][0], cls=ShapelyGeoJsonEncoder, encoding='utf-8')
+    return zoo.SERVICE_SUCCEEDED
+        
Index: trunk/zoo-project/zoo-services/data-api/query.zcfg
===================================================================
--- trunk/zoo-project/zoo-services/data-api/query.zcfg	(revision 743)
+++ trunk/zoo-project/zoo-services/data-api/query.zcfg	(revision 743)
@@ -0,0 +1,30 @@
+[query]
+ Title = Execute a query using DataAPI
+ Abstract = Execute a query through DataAPI.
+ processVersion = 2
+ storeSupported = true
+ statusSupported = true
+ serviceProvider = service
+ serviceType = Python
+ <DataInputs>
+  [query]
+   Title = JSON Query
+   Abstract = The query to be executed in JSON format.
+   minOccurs = 1
+   maxOccurs = 1
+   <LiteralData>
+    dataType = string
+    <Default />
+   </LiteralData>
+ </DataInputs>
+ <DataOutputs>
+  [Result]
+   Title = Response
+   Abstract = The response to the DataAPI query.
+   <ComplexData>
+    <Default>
+    mimeType = application/json
+    encoding = utf-8
+    </Default>
+   </ComplexData>
+ </DataOutputs>
Index: trunk/zoo-project/zoo-services/data-api/service.py
===================================================================
--- trunk/zoo-project/zoo-services/data-api/service.py	(revision 743)
+++ trunk/zoo-project/zoo-services/data-api/service.py	(revision 743)
@@ -0,0 +1,54 @@
+#!/usr/bin/python
+
+import zoo
+
+import logging
+import logging.config
+import sys
+import errno
+import os
+import json
+import geojson
+import csv
+import argparse
+
+from publicamundi.data.api import *
+
+ERROR_OK = 0
+ERROR_UNKNOWN = 1
+
+def configure_logging(filename):
+    if filename is None:
+        print 'Logging is not configured.'
+    else:
+        logging.config.fileConfig(filename)
+
+def parse_query(filename, text):
+    if not filename is None and os.path.isfile(filename):
+        with open(filename) as query_file:    
+            return json.load(query_file, cls=ShapelyJsonDecoder, encoding='utf-8')
+    if not text is None:
+        return json.loads(text, cls=ShapelyJsonDecoder, encoding='utf-8')
+        
+    return {}
+
+def query(conf,inputs,outputs):    
+    config = {
+        CONFIG_SQL_CATALOG : conf["data-api"]["catalog"],
+        CONFIG_SQL_DATA : conf["data-api"]["vectorstore"],
+        CONFIG_SQL_TIMEOUT : int(conf["data-api"]["timeout"]) * 1000
+    }
+
+    if inputs.keys().count("timeout")>0:
+        config["CONFIG_SQL_TIMEOUT"]=int(inputs["timeout"]["value"]) * 1000
+    
+    metadata = {}
+
+    configure_logging(conf["lenv"]["cwd"]+"/"+conf["lenv"]["metapath"]+"/service.ini")
+    
+    query_executor = QueryExecutor()
+    result = query_executor.execute(config, parse_query(None,inputs["query"]["value"]) )
+    
+    outputs["Result"]["value"]=geojson.dumps(result['data'][0], cls=ShapelyGeoJsonEncoder, encoding='utf-8')
+    return zoo.SERVICE_SUCCEEDED
+        
Index: trunk/zoo-project/zoo-services/gdal/contour/Makefile
===================================================================
--- trunk/zoo-project/zoo-services/gdal/contour/Makefile	(revision 742)
+++ trunk/zoo-project/zoo-services/gdal/contour/Makefile	(revision 743)
@@ -1,9 +1,9 @@
 ZRPATH=../../..
 include ${ZRPATH}/zoo-kernel/ZOOMakefile.opts
-CFLAGS=-DZOO_SERVICE ${ZOO_CFLAGS} ${XML2CFLAGS} ${GDAL_CFLAGS} ${PYTHONCFLAGS} -DLINUX_FREE_ISSUE #-DDEBUG
+CFLAGS=-DZOO_SERVICE -I${INST_INCLUDE} ${ZOO_CFLAGS} ${XML2CFLAGS} ${GDAL_CFLAGS} ${PYTHONCFLAGS} -DLINUX_FREE_ISSUE #-DDEBUG
 CC=gcc
 
 cgi-env/contour_service.zo: service.c
-	g++ ${CFLAGS} -shared -fpic -o cgi-env/contour_service.zo ./service.c ${GDAL_LIBS} ${MACOS_LD_FLAGS} -lzoo_service
+	g++ ${CFLAGS} -shared -fpic -o cgi-env/contour_service.zo ./service.c ${GDAL_LIBS} ${MACOS_LD_FLAGS} -L${INST_LIB} -lzoo_service ${FCGI_LDFLAGS}
 install:
 	install -d ${CGI_DIR}/gdal/contour
Index: trunk/zoo-project/zoo-services/gdal/contour/service.c
===================================================================
--- trunk/zoo-project/zoo-services/gdal/contour/service.c	(revision 742)
+++ trunk/zoo-project/zoo-services/gdal/contour/service.c	(revision 743)
@@ -36,4 +36,5 @@
 #ifdef ZOO_SERVICE
 #include "service.h"
+#include "service_internal.h"
 #endif
 CPL_CVSID("$Id: gdal_contour.cpp 25643 2013-02-12 13:50:42Z bishop $");
@@ -73,4 +74,22 @@
     exit( 1 );
 }
+
+#ifdef ZOO_SERVICE
+  int pfnProgress1( double dfComplete, const char *pszMessage, void *pData)
+  {
+    maps* conf=(maps*)pData;
+    map* tmpMap=getMapFromMaps(conf,"lenv","status");
+    char tmpStr[4];
+    sprintf(tmpStr,"%d",(int) (dfComplete*100));
+    if(tmpMap!=NULL && strcmp(tmpMap->value,tmpStr)!=0){
+      if( pszMessage != NULL && strlen(pszMessage)>1){
+	updateStatus(conf,(int) (dfComplete*100), pszMessage);
+      }      
+      else
+	updateStatus(conf,(int) (dfComplete*100), "Processing...");
+    }
+    return TRUE;
+  }
+#endif
 
 /************************************************************************/
@@ -106,7 +125,4 @@
     const char *pszNewLayerName = "contour";
     int bQuiet = FALSE;
-    GDALProgressFunc pfnProgress = NULL;
-    fprintf(stderr,"DEBUG HELLO %f %d\n",__FILE__,__LINE__);
-    fflush(stderr);
 #ifndef ZOO_SERVICE
     /* Check that we are running against at least GDAL 1.4 */
@@ -262,7 +278,7 @@
     }
     
-    if (!bQuiet)
-        pfnProgress = GDALTermProgress;
-
+    /*if (!bQuiet)
+      pfnProgress = GDALTermProgress;*/
+    //pfnProgress = GDALTermProgress;
 /* -------------------------------------------------------------------- */
 /*      Open source raster file.                                        */
@@ -372,5 +388,5 @@
                                  OGR_FD_GetFieldIndex( OGR_L_GetLayerDefn( hLayer ), 
                                                        pszElevAttrib ), 
-                         pfnProgress, NULL );
+                         pfnProgress1, conf );
 
     OGR_DS_Destroy( hDS );
Index: trunk/zoo-project/zoo-services/gdal/dem/Makefile
===================================================================
--- trunk/zoo-project/zoo-services/gdal/dem/Makefile	(revision 742)
+++ trunk/zoo-project/zoo-services/gdal/dem/Makefile	(revision 743)
@@ -1,9 +1,9 @@
 ZRPATH=../../..
 include ${ZRPATH}/zoo-kernel/ZOOMakefile.opts
-CFLAGS=-DZOO_SERVICE ${ZOO_CFLAGS} ${XML2CFLAGS} ${GDAL_CFLAGS} ${PYTHONCFLAGS} -DLINUX_FREE_ISSUE #-DDEBUG
+CFLAGS=-DZOO_SERVICE -I${INST_INCLUDE} ${ZOO_CFLAGS} ${XML2CFLAGS} ${GDAL_CFLAGS} ${PYTHONCFLAGS} -DLINUX_FREE_ISSUE #-DDEBUG
 CC=gcc
 
 cgi-env/dem_service.zo: service.c
-	g++ ${CFLAGS} -shared -fpic -o cgi-env/dem_service.zo ./service.c ${GDAL_LIBS} ${MACOS_LD_FLAGS} -lzoo_service
+	g++ ${CFLAGS} -shared -fpic -o cgi-env/dem_service.zo ./service.c ${GDAL_LIBS} ${MACOS_LD_FLAGS} -L${INST_LIB} -lzoo_service
 
 install:
Index: trunk/zoo-project/zoo-services/gdal/grid/Makefile
===================================================================
--- trunk/zoo-project/zoo-services/gdal/grid/Makefile	(revision 742)
+++ trunk/zoo-project/zoo-services/gdal/grid/Makefile	(revision 743)
@@ -1,9 +1,9 @@
 ZRPATH=../../..
 include ${ZRPATH}/zoo-kernel/ZOOMakefile.opts
-CFLAGS=${ZOO_CFLAGS} ${XML2CFLAGS} ${GDAL_CFLAGS} ${PYTHONCFLAGS} -DLINUX_FREE_ISSUE #-DDEBUG
+CFLAGS=-I${INST_INCLUDE} ${ZOO_CFLAGS} ${XML2CFLAGS} ${GDAL_CFLAGS} ${PYTHONCFLAGS} -DLINUX_FREE_ISSUE #-DDEBUG
 CC=gcc
 
 cgi-env/service.zo: service.c
-	g++  -DZOO_SERVICE ${CFLAGS} -shared -fpic -o cgi-env/gdal_grid_service.zo ./service.c ${GDAL_LIBS} ${MACOS_LD_FLAGS} -lzoo_service
+	g++  -DZOO_SERVICE ${CFLAGS} -shared -fpic -o cgi-env/gdal_grid_service.zo ./service.c ${GDAL_LIBS} ${MACOS_LD_FLAGS} -L${INST_LIB} -lzoo_service
 
 install:
Index: trunk/zoo-project/zoo-services/gdal/profile/Makefile
===================================================================
--- trunk/zoo-project/zoo-services/gdal/profile/Makefile	(revision 742)
+++ trunk/zoo-project/zoo-services/gdal/profile/Makefile	(revision 743)
@@ -1,9 +1,9 @@
 ZRPATH=../../..
 include ${ZRPATH}/zoo-kernel/ZOOMakefile.opts
-CFLAGS=${ZOO_CFLAGS} ${XML2CFLAGS} ${GDAL_CFLAGS} ${PYTHONCFLAGS} -DLINUX_FREE_ISSUE #-DDEBUG
+CFLAGS=-I${INST_INCLUDE} ${ZOO_CFLAGS} ${XML2CFLAGS} ${GDAL_CFLAGS} ${PYTHONCFLAGS} -DLINUX_FREE_ISSUE #-DDEBUG
 CC=gcc
 
 cgi-env/profile_service.zo: service.c
-	g++  -DZOO_SERVICE ${CFLAGS} -shared -fpic -o cgi-env/profile_service.zo ./service.c ${GDAL_LIBS} ${MACOS_LD_FLAGS} -lzoo_service
+	g++  -DZOO_SERVICE ${CFLAGS} -shared -fpic -o cgi-env/profile_service.zo ./service.c ${GDAL_LIBS} ${MACOS_LD_FLAGS} -L${INST_LIB} -lzoo_service
 
 install:
Index: trunk/zoo-project/zoo-services/gdal/translate/Makefile
===================================================================
--- trunk/zoo-project/zoo-services/gdal/translate/Makefile	(revision 742)
+++ trunk/zoo-project/zoo-services/gdal/translate/Makefile	(revision 743)
@@ -1,9 +1,9 @@
 ZRPATH=../../..
 include ${ZRPATH}/zoo-kernel/ZOOMakefile.opts
-CFLAGS=${ZOO_CFLAGS} ${XML2CFLAGS} ${GDAL_CFLAGS} ${PYTHONCFLAGS} -DLINUX_FREE_ISSUE #-DDEBUG
+CFLAGS=-I${INST_INCLUDE} ${ZOO_CFLAGS} ${XML2CFLAGS} ${GDAL_CFLAGS} ${PYTHONCFLAGS} -DLINUX_FREE_ISSUE #-DDEBUG
 CC=gcc
 
 cgi-env/translate_service.zo: service.c
-	g++ ${CFLAGS} -shared -fpic -o cgi-env/translate_service.zo ./service.c ${GDAL_LIBS} ${MACOS_LD_FLAGS} -lzoo_service
+	g++ ${CFLAGS} -shared -fpic -o cgi-env/translate_service.zo ./service.c ${GDAL_LIBS} ${MACOS_LD_FLAGS} -L${INST_LIB} -lzoo_service
 
 install:
Index: trunk/zoo-project/zoo-services/gdal/warp/Makefile
===================================================================
--- trunk/zoo-project/zoo-services/gdal/warp/Makefile	(revision 742)
+++ trunk/zoo-project/zoo-services/gdal/warp/Makefile	(revision 743)
@@ -1,9 +1,9 @@
 ZRPATH=../../..
 include ${ZRPATH}/zoo-kernel/ZOOMakefile.opts
-CFLAGS=${ZOO_CFLAGS} ${XML2CFLAGS} ${GDAL_CFLAGS} ${PYTHONCFLAGS} -DLINUX_FREE_ISSUE #-DDEBUG
+CFLAGS=-I${INST_INCLUDE} ${ZOO_CFLAGS} ${XML2CFLAGS} ${GDAL_CFLAGS} ${PYTHONCFLAGS} -DLINUX_FREE_ISSUE #-DDEBUG
 CC=gcc
 
 cgi-env/warp_service.zo: service.c
-	g++ ${CFLAGS} -shared -fpic -o cgi-env/warp_service.zo ./service.c ${GDAL_LIBS} ${MACOS_LD_FLAGS} -lzoo_service
+	g++ ${CFLAGS} -shared -fpic -o cgi-env/warp_service.zo ./service.c ${GDAL_LIBS} ${MACOS_LD_FLAGS} -L${INST_LIB} -lzoo_service
 
 install:
Index: trunk/zoo-project/zoo-services/hello-py/cgi-env/test_service.py
===================================================================
--- trunk/zoo-project/zoo-services/hello-py/cgi-env/test_service.py	(revision 742)
+++ trunk/zoo-project/zoo-services/hello-py/cgi-env/test_service.py	(revision 743)
@@ -30,2 +30,9 @@
 	return zoo.SERVICE_SUCCEEDED
 
+def geopaposm(conf,inputs,outputs):
+	outputs["result"]["value"]=inputs["inputvector"]["value"]
+	return zoo.SERVICE_SUCCEEDED
+    
+def publish(conf,inputs,outputs):
+    outputs["Result"]["value"]=inputs["in"]["value"]
+    return zoo.SERVICE_SUCCEEDED
Index: trunk/zoo-project/zoo-services/ogr/ogr2ogr/Makefile
===================================================================
--- trunk/zoo-project/zoo-services/ogr/ogr2ogr/Makefile	(revision 742)
+++ trunk/zoo-project/zoo-services/ogr/ogr2ogr/Makefile	(revision 743)
@@ -1,9 +1,9 @@
 ZRPATH=../../..
 include ${ZRPATH}/zoo-kernel/ZOOMakefile.opts
-CFLAGS=-DZOO_SERVICE ${ZOO_CFLAGS} ${XML2CFLAGS} ${GDAL_CFLAGS} ${PYTHONCFLAGS} -DLINUX_FREE_ISSUE #-DDEBUG
+CFLAGS=-DZOO_SERVICE -I${INST_INCLUDE} ${ZOO_CFLAGS} ${XML2CFLAGS} ${GDAL_CFLAGS} ${PYTHONCFLAGS} -DLINUX_FREE_ISSUE #-DDEBUG
 CC=gcc
 
 cgi-env/ogr2ogr_service.zo: service.c $(DEP_LIBS)
-	g++ $(CFLAGS) $(CPPFLAGS) -shared -fpic $<  -o $@ ${GDAL_LIBS} -lzoo_service
+	g++ $(CFLAGS) $(CPPFLAGS) -shared -fpic $<  -o $@ ${GDAL_LIBS} -L${INST_LIB} -lzoo_service
 
 install:
Index: trunk/zoo-project/zoo-services/qrencode/Makefile
===================================================================
--- trunk/zoo-project/zoo-services/qrencode/Makefile	(revision 742)
+++ trunk/zoo-project/zoo-services/qrencode/Makefile	(revision 743)
@@ -1,9 +1,9 @@
 ZRPATH=../..
 include ${ZRPATH}/zoo-kernel/ZOOMakefile.opts
-CFLAGS=${ZOO_CFLAGS} ${XML2CFLAGS} ${GDAL_CFLAGS} ${PYTHONCFLAGS} -DLINUX_FREE_ISSUE #-DDEBUG
+CFLAGS=-I${INST_INCLUDE} ${ZOO_CFLAGS} ${XML2CFLAGS} ${GDAL_CFLAGS} ${PYTHONCFLAGS} -DLINUX_FREE_ISSUE #-DDEBUG
 CC=gcc
 
 cgi-env/qrencode.zo: qrenc-service.c
-	g++ -DZOO_SERVICE_PROVIDER ${CFLAGS} -shared -fpic -o cgi-env/qrencode.zo ./qrenc-service.c -lqrencode ${GDAL_LIBS} -lpng ${MACOS_LD_FLAGS}
+	g++ -DZOO_SERVICE_PROVIDER ${CFLAGS} -shared -fpic -o cgi-env/qrencode.zo ./qrenc-service.c -lqrencode ${GDAL_LIBS} -lpng ${MACOS_LD_FLAGS} -L${INST_LIB} -lzoo_service
 
 clean:
Index: trunk/zoo-project/zoo-services/qrencode/qrenc-service.c
===================================================================
--- trunk/zoo-project/zoo-services/qrencode/qrenc-service.c	(revision 742)
+++ trunk/zoo-project/zoo-services/qrencode/qrenc-service.c	(revision 743)
@@ -25,8 +25,10 @@
 # include "config.h"
 #endif
+#include "string.h"
 #include <stdio.h>
 #include <stdlib.h>
 #include <png.h>
 #include <getopt.h>
+#include "qrencode.h"
 
 #ifdef ZOO_SERVICE_PROVIDER
@@ -41,5 +43,4 @@
 #endif
 
-#include "qrencode.h"
 
 #define INCHES_PER_METER (100.0/2.54)
Index: trunk/zoo-project/zoo-services/utils/status/Makefile
===================================================================
--- trunk/zoo-project/zoo-services/utils/status/Makefile	(revision 742)
+++ trunk/zoo-project/zoo-services/utils/status/Makefile	(revision 743)
@@ -1,8 +1,8 @@
 ZRPATH=../../..
 include ${ZRPATH}/zoo-kernel/ZOOMakefile.opts
-CFLAGS=${ZOO_CFLAGS} ${XML2CFLAGS} ${GDAL_CFLAGS} ${PYTHONCFLAGS} -DLINUX_FREE_ISSUE #-DDEBUG
+CFLAGS=-I${INST_INCLUDE} ${ZOO_CFLAGS} ${XML2CFLAGS} ${GDAL_CFLAGS} ${PYTHONCFLAGS} -DLINUX_FREE_ISSUE #-DDEBUG
 
 cgi-env/wps_status.zo: service.c
-	g++ ${CFLAGS} -shared -fpic -o cgi-env/wps_status.zo ./service.c ${GDAL_LIBS} ${XML2LDFLAGS} ${MACOS_LD_FLAGS} ${ZOO_LDFLAGS} ${MACOS_LD_NET_FLAGS} ${XSLT_LDFLAGS} -lfcgi -lzoo_service
+	g++ ${CFLAGS} -shared -fpic -o cgi-env/wps_status.zo ./service.c ${GDAL_LIBS} ${XML2LDFLAGS} ${MACOS_LD_FLAGS} ${ZOO_LDFLAGS} ${MACOS_LD_NET_FLAGS} ${XSLT_LDFLAGS} ${FCGI_LDFLAGS} -L${INST_LIB} -lzoo_service
 
 install:
Index: trunk/zoo-project/zoo-services/wcps-proxy/cgi-env/WCPS.py
===================================================================
--- trunk/zoo-project/zoo-services/wcps-proxy/cgi-env/WCPS.py	(revision 743)
+++ trunk/zoo-project/zoo-services/wcps-proxy/cgi-env/WCPS.py	(revision 743)
@@ -0,0 +1,109 @@
+# -*- coding: utf-8 -*-
+#
+# Author : Vlad Merticariu <merticariu@rasdaman.com>
+#
+# Copyright 2015 rasdaman GmbH. All rights reserved.
+#
+# Permission is hereby granted, free of charge, to any person obtaining a
+# copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including with
+# out limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+import zoo
+import requests
+
+WCPS_REQUEST_TEMPLATE = "%endPoint%?service=WCS&version=2.0.1&request=ProcessCoverages&query=%query%"
+
+def WCPS(conf,inputs,outputs):
+	end_point = validate_end_point(inputs["endPoint"]["value"])
+        query = get_correct_query(inputs["query"]["value"],outputs["Response"]["mimeType"])
+        response_data_type = get_data_type(query)
+        status, response = execute_wcps_request(end_point, query)
+	import sys    
+	print >> sys.stderr,query
+	#handle errors
+	if status:
+		conf["lenv"]["message"] = zoo._("The end point at " + end_point + " could not be reached.")
+		return zoo.SERVICE_FAILED
+ 	if "ows:ExceptionReport" in response:
+		conf["lenv"]["message"] = parse_error_message(response)
+		return zoo.SERVICE_FAILED
+		
+	#no errors, everything ok 	
+        outputs["Response"]["value"] = remove_trailing_characters(response, response_data_type)
+        #outputs["Response"]["mimeType"] = response_data_type
+        #outputs["Response"]["encoding"] = get_encoding(outputs["Response"]["mimeType"])
+	return zoo.SERVICE_SUCCEEDED
+
+def parse_error_message(response):
+	return response.split("<ows:ExceptionText>")[1].split("</ows:ExceptionText>")[0]
+
+def validate_end_point(end_point):
+	ret = end_point
+	if not end_point.startswith("http"):
+        	ret = "http://" + end_point
+	return ret
+
+def get_data_type(query):
+	ret = "text/plain"
+	if "\"png\"" in query:
+		ret = "image/png"
+	if "\"csv\"" in query:
+		ret = "text/csv"
+	if "\"tiff\"" in query:
+		ret = "image/tiff"
+	if "\"jpeg\"" in query or "\"jpg\"" in query:
+		ret = "image/jpeg"
+	return ret
+
+def get_correct_query(query,mimeType):
+    return query.replace("[format]",get_data_ext(mimeType))
+
+def get_data_ext(mimeType):
+	ret = "csv"
+	for i in ["png","csv","tiff","jpeg"]:
+		if i in mimeType:
+			ret = i
+			break
+	return ret
+
+def get_encoding(data_type):
+	ret = "utf-8"
+	if data_type.startswith("image"):
+		ret = "base64"
+	return ret
+
+def remove_trailing_characters(response, data_type):
+        response_start = 27
+        if data_type.startswith("image"):
+		response_start += len(data_type)
+	else:
+		response_start += 10
+        ret = response[response_start:-17]
+	return ret
+
+def execute_wcps_request(end_point, query):
+        composed_url = WCPS_REQUEST_TEMPLATE.replace("%endPoint%", end_point).replace("%query%", query) 
+	try:
+		response = requests.get(composed_url)
+	except:
+		#can not open url
+		return 1, ""
+	#all ok
+	return 0, response.content
+
+    
Index: trunk/zoo-project/zoo-services/wcps-proxy/cgi-env/WCPS.zcfg
===================================================================
--- trunk/zoo-project/zoo-services/wcps-proxy/cgi-env/WCPS.zcfg	(revision 743)
+++ trunk/zoo-project/zoo-services/wcps-proxy/cgi-env/WCPS.zcfg	(revision 743)
@@ -0,0 +1,54 @@
+[WCPS]
+ Title = Execute WCPS queries
+ Abstract = Execute a Web Coverage Processing Service request, through a WPS process.
+ processVersion = 2
+ storeSupported = true
+ statusSupported = true
+ serviceProvider = WCPS
+ serviceType = Python
+ <MetaData>
+   title = WCPS
+ </MetaData>
+ <DataInputs>
+  [endPoint]
+   Title = WCPS End Point
+   Abstract = The WCPS End Point against which the WCPS query is executed.
+   minOccurs = 1
+   maxOccurs = 1
+   <LiteralData>
+    dataType = string
+    <Default />
+   </LiteralData>
+  [query]
+   Title = WCPS Query
+   Abstract = The query to be executed at the provided end point.
+   minOccurs = 1
+   maxOccurs = 1
+   <LiteralData>
+    dataType = string
+    <Default />
+   </LiteralData>
+ </DataInputs>
+ <DataOutputs>
+  [Response]
+   Title = WCPS Response
+   Abstract = The response to the WCPS query.
+   <ComplexData>
+    <Default>
+    mimeType = text/csv
+    encoding = utf-8
+    </Default>
+    <Supported>
+    mimeType = image/png
+    encoding = base64
+    </Supported>
+    <Supported>
+    mimeType = image/tiff
+    encoding = base64
+    </Supported>
+    <Supported>
+    mimeType = image/jpeg
+    encoding = base64
+    </Supported>
+   </ComplexData>
+ </DataOutputs>
