Changeset 465


Ignore:
Timestamp:
Apr 23, 2014, 3:05:01 AM (11 years ago)
Author:
djay
Message:

Add the optional YAML ZCFG support #4 and the zcfg2yaml converter. Return error messages that enable the service provider to quickly identify the root cause of errors due to configuration file syntax #90. Fix logic in addMapToMap #91. Enable multiple range definition using default and supported blocks. Add the lastest revision number in version.h (available from Python ZOO-API as zoo.VERSION).

Location:
trunk/zoo-project
Files:
2 added
17 edited

Legend:

Unmodified
Added
Removed
  • trunk/zoo-project/HISTORY.txt

    r434 r465  
     1Version 1.4.0-dev
     2  * Add the optional YAML ZCFG support #4 and the zcfg2yaml converter
     3  * Return error messages that enable the service provider to quickly identify the root cause of errors due to configuration file syntax (ticket #90)
     4  * Fix logic in addMapToMap (ticket #91)
     5  * Enable AllowedValue and multiple Range definitions using default and supported blocks
     6  * Add the lastest revision number in version.h (available in Python ZOO-API)
     7  * Add the optional Ruby Language Support to the ZOO-Kernel with an API similar to the Python ZOO-API
     8  * Small rewrite of Python support
     9  * Inputs can be requested over https protocol (ticket #86)
     10  * Add capability to define both percentage of execution and a message (ticket #87).
     11  * Add usid in lenv section used to generate an unique identifier based on time and the process identifier.
     12  * Add gdal_contour service
     13  * Add dynamic definition of serverAddress from the main section
     14
    115Version 1.3.0-rc2
    216  * Fix POST Request issue (ticket #34)
  • trunk/zoo-project/zoo-kernel/Makefile.in

    r459 r465  
    1212JAVA_FILE=@JAVA_FILE@
    1313
    14 CFLAGS=-fpic ${MACOS_CFLAGS} ${MS_CFLAGS} -I../../thirds/cgic206 -I. -DLINUX_FREE_ISSUE #-DDEBUG #-DDEBUG_SERVICE_CONF
    15 LDFLAGS=-lcurl -L../../thirds/cgic206 -lcgic ${GDAL_LIBS} ${XML2LDFLAGS} ${PYTHONLDFLAGS} ${PERLLDFLAGS}  ${PHPLDFLAGS} ${JAVALDFLAGS} ${JSLDFLAGS} -lfcgi -lcrypto ${MS_LDFLAGS} ${MACOS_LD_FLAGS}
     14CFLAGS=-fpic ${YAML_CFLAGS} ${MACOS_CFLAGS} ${MS_CFLAGS} -I../../thirds/cgic206 -I. -DLINUX_FREE_ISSUE #-DDEBUG #-DDEBUG_SERVICE_CONF
     15LDFLAGS=-lcurl -L../../thirds/cgic206 -lcgic ${GDAL_LIBS} ${XML2LDFLAGS} ${PYTHONLDFLAGS} ${PERLLDFLAGS}  ${PHPLDFLAGS} ${JAVALDFLAGS} ${JSLDFLAGS} -lfcgi -lcrypto ${MS_LDFLAGS} ${MACOS_LD_FLAGS} ${YAML_LDFLAGS}
    1616
    1717PHPCFLAGS=@PHP_CPPFLAGS@
     
    2727
    2828
    29 all: zoo_loader.cgi
     29all: version.h zoo_loader.cgi ${YAML_FILE1}
     30
     31version.h:
     32        echo "#define ZOO_VERSION \"`svnversion -q -c -n .`\"" > version.h
    3033
    3134main_conf_read.tab.c: main_conf_read.y service.h
     
    5760
    5861service_internal.o: service_internal.c service.h
    59         gcc ${JS_ENABLED} ${JSCFLAGS} ${XML2CFLAGS} ${CFLAGS} -fPIC -c service_internal.c
     62        g++ ${JS_ENABLED} ${JSCFLAGS} ${XML2CFLAGS} ${CFLAGS} -fPIC -c service_internal.c
     63
     64service_yaml.o: service_yaml.c service.h
     65        gcc ${YAML_CFLAGS} ${XML2CFLAGS} ${CFLAGS} -fPIC -c service_yaml.c
    6066
    6167service_internal_ms.o: service_internal_ms.c
     
    8692        g++ -g -O2 ${XML2CFLAGS} ${CFLAGS} ${PYTHONCFLAGS} ${JAVACFLAGS} ${JSCFLAGS} ${PERLCFLAGS} ${PHPCFLAGS} ${PYTHON_ENABLED} ${JS_ENABLED} ${PHP_ENABLED} ${PERL_ENABLED} ${JAVA_ENABLED} -c zoo_service_loader.c  -fno-common -DPIC -o zoo_service_loader.o
    8793
    88 zoo_loader.cgi: zoo_loader.c zoo_service_loader.o  ulinet.o service.h lex.sr.o service_conf.tab.o service_conf.y ulinet.o main_conf_read.tab.o lex.cr.o service_internal.o ${MS_FILE} ${PYTHON_FILE} ${PHP_FILE} ${JAVA_FILE} ${JS_FILE} ${PERL_FILE} ${RUBY_FILE}
     94zoo_loader.cgi: zoo_loader.c zoo_service_loader.o  ulinet.o service.h lex.sr.o service_conf.tab.o service_conf.y ulinet.o main_conf_read.tab.o lex.cr.o service_internal.o ${MS_FILE} ${PYTHON_FILE} ${PHP_FILE} ${JAVA_FILE} ${JS_FILE} ${PERL_FILE} ${RUBY_FILE} ${YAML_FILE}
    8995        g++ -g -O2 ${JSCFLAGS} ${PHPCFLAGS}  ${PERLCFLAGS} ${RUBYCFLAGS}  ${JAVACFLAGS} ${XML2CFLAGS} ${PYTHONCFLAGS} ${CFLAGS} -c zoo_loader.c  -fno-common -DPIC -o zoo_loader.o
    90         g++  ${JSCFLAGS} ${GDAL_CFLAGS} ${XML2CFLAGS} ${PHPCFLAGS} ${PERLCFLAGS} ${JAVACFLAGS} ${PYTHONCFLAGS} ${CFLAGS} zoo_loader.o zoo_service_loader.o service_internal.o ${MS_FILE} ${PYTHON_FILE}  ${PERL_FILE} ${PHP_FILE}  ${JS_FILE} ${JAVA_FILE} ulinet.o lex.cr.o lex.sr.o service_conf.tab.o main_conf_read.tab.o -o zoo_loader.cgi ${LDFLAGS}
     96        g++  ${JSCFLAGS} ${GDAL_CFLAGS} ${XML2CFLAGS} ${PHPCFLAGS} ${PERLCFLAGS} ${JAVACFLAGS} ${PYTHONCFLAGS} ${CFLAGS} zoo_loader.o zoo_service_loader.o service_internal.o ${MS_FILE} ${PYTHON_FILE}  ${PERL_FILE} ${PHP_FILE}  ${JS_FILE} ${JAVA_FILE} ${YAML_FILE} ulinet.o lex.cr.o lex.sr.o service_conf.tab.o main_conf_read.tab.o -o zoo_loader.cgi ${LDFLAGS}
     97
     98zcfg2yaml: zcfg2yaml.c  ulinet.o service.h lex.sr.o service_conf.tab.o service_conf.y ulinet.o main_conf_read.tab.o lex.cr.o service_internal.o ${MS_FILE} ${JS_FILE} ${RUBY_FILE}  ${YAML_FILE}
     99        g++ -g -O2 ${JSCFLAGS} ${RUBYCFLAGS} ${XML2CFLAGS} ${CFLAGS} -c zcfg2yaml.c  -fno-common -DPIC -o zcfg2yaml.o
     100        g++  ${JSCFLAGS} ${XML2CFLAGS} ${CFLAGS} zcfg2yaml.o service_internal.o ${MS_FILE} ${JS_FILE}  ulinet.o lex.cr.o lex.sr.o service_conf.tab.o main_conf_read.tab.o  ${YAML_FILE} -o zcfg2yaml ${LDFLAGS}
    91101
    92102install:
  • trunk/zoo-project/zoo-kernel/ZOOMakefile.opts.in

    r459 r465  
    55        MACOS_CFLAGS=-arch $(shell uname -m)
    66endif
     7
     8YAML_CFLAGS=@YAML_CPPFLAGS@
     9YAML_LDFLAGS=@YAML_LDFLAGS@
     10YAML_FILE=@YAML_FILE@
     11YAML_FILE1=@YAML_FILE1@
    712
    813GDAL_CFLAGS=@GDAL_CFLAGS@
  • trunk/zoo-project/zoo-kernel/configure.ac

    r459 r465  
    1414AC_CHECK_LIB([fl], [main])
    1515AC_CHECK_LIB([pthread], [main])
    16 AC_CHECK_LIB([fcgi], [main])
    1716AC_CHECK_LIB([ssl], [main])
    1817
     
    6867
    6968# ===========================================================================
     69# Detect if libyaml is available
     70# ===========================================================================
     71
     72AC_ARG_WITH([yaml],
     73        [AS_HELP_STRING([--with-yaml=PATH], [specify an alternative location for the fastcgi library])],
     74        [YAMLPATH="$withval"], [YAMLPATH=""])
     75
     76if test -z "$YAMLPATH"
     77then
     78        YAML_LDFLAGS=""
     79        YAML_CPPFLAGS=""
     80        YAML_FILE=""
     81        YAML_FILE1=""
     82else
     83
     84        # Extract the linker and include flags
     85        YAML_LDFLAGS="-L$YAMLPATH/lib -lyaml"
     86        YAML_CPPFLAGS="-I$YAMLPATH/include -DYAML"
     87        YAML_FILE="service_yaml.o"
     88        YAML_FILE1="zcfg2yaml"
     89       
     90        # Check headers file
     91        CPPFLAGS_SAVE="$CPPFLAGS"
     92        CPPFLAGS="$YAML_CPPFLAGS"
     93        LDFLAGS_SAVE="$LDFLAGS"
     94        LDFLAGS="YAML_LDFLAGS"
     95        AC_CHECK_LIB([yaml], [yaml_parser_initialize,yaml_parser_set_input_file,yaml_parser_scan])
     96        AC_CHECK_HEADERS([yaml.h],
     97                 [], [AC_MSG_ERROR([could not find headers include related to YAML])])
     98
     99fi
     100AC_SUBST([YAML_CPPFLAGS])
     101AC_SUBST([YAML_LDFLAGS])
     102AC_SUBST([YAML_FILE])
     103AC_SUBST([YAML_FILE1])
     104
     105# ===========================================================================
    70106# Detect if fastcgi is available
    71107# ===========================================================================
     
    73109AC_ARG_WITH([fastcgi],
    74110        [AS_HELP_STRING([--with-fastcgi=PATH], [specify an alternative location for the fastcgi library])],
    75         [FCGIPATH="$withval"], [FCGIPATH=""])
     111        [FCGIPATH="$withval"], [FCGIPATH="/usr"])
    76112
    77113# Extract the linker and include flags
     
    82118CPPFLAGS_SAVE="$CPPFLAGS"
    83119CPPFLAGS="$FCGI_CPPFLAGS"
     120LDFLAGS_SAVE="LDFLAGS"
     121LDFLAGS="$FCGI_LDFLAGS"
     122AC_CHECK_LIB([fcgi], [main])
    84123AC_CHECK_HEADERS([fcgi_stdio.h],
    85124                 [], [AC_MSG_ERROR([could not find headers include related to fastcgi])])
  • trunk/zoo-project/zoo-kernel/main.cfg

    r253 r465  
    1 [main]
    2 encoding = utf-8
    3 version = 1.0.0
    4 serverAddress = http://www.zoo-project.org/zoo/
    5 lang = fr-FR,en-CA
    6 tmpPath=/YourFullTmpPathHere/
    7 tmpUrl = ../TmpPathRelativeToServerAdress/
    8 dataPath = /YouFullDataPathHere/
     1[mm]
     2biLayerAlias=Carte,Ortophoto,Ortophoto 2005,Parcels,Etat Major,Cassini,Elev
     3editingToolbar=select,add,edit
     4navName=Authenticate,Permalink,Twitter sharing,Facebook sharing,Scroll,Pan,Geolocate,Track my position,Zoom Box,Zoom To Max Extent,Identify,Identify Circle,Mesure Distance,Mesure Area,Print,Profile
     5scales=443744273,221872136,110936068,55468034,27734017,13867008,6933504,3466752,1733376,866688,433344,216672,108336,54168,27084,13542,6771,3385,1692
     6rasterToolbarAlias=Profile,Contour,Shaded Relief,Color Relief,Slope Map,Clip
     7supportedDbs=PostGIS,MySQL
     8mapcacheUrl=http://127.0.0.1/cache/
     9biLayers=GEOGRAPHICALGRIDSYSTEMS.MAPS,ORTHOIMAGERY.ORTHOPHOTOS,ORTHOIMAGERY.ORTHOPHOTOS2000-2005,CADASTRALPARCELS.PARCELS,GEOGRAPHICALGRIDSYSTEMS.ETATMAJOR40,GEOGRAPHICALGRIDSYSTEMS.CASSINI,ELEVATION.SLOPES
     10bgLayers=google.maps.MapTypeId.TERRAIN,null,google.maps.MapTypeId.SATELLITE,google.maps.MapTypeId.HYBRID
     11bpDefault=g
     12bgName=Google
     13bbLayers=Road,Aerial,AerialWithLabels
     14navIcon=auth,permalink,tshare,fshare,scroll,pan,geoloc,track,zoom-in,zoomtomaxextent,info,infocircle,dist,area,print,terrain-profile
     15bbName=Bing
     16boLayerAlias=OpenStreetMap
     17bmLayerAlias=Streets,Satelite
     18toolbars=Vector
     19navId=authenticate,permalink,tshare,fshare,scroll,control,geolocate,track,zoomin,zoomtomaxextent,getFeature,getFeatureCircle,line,polygon,print,profile
     20navIdX=authenticate,permalink,tshare,fshare,zoomtomaxextent,print
     21navIdXX=scroll
     22navIdF=loadLoginForm,permalink,shareOnTwitter,shareOnFB,gotoMaxExtent,printIntoDocument
     23nvIID=getFeature,getFeatureCircle
     24osmApiUrl=http://open.mapquestapi.com/xapi/api/0.6/
     25vectorToolbar=buffer,spatial-buffer,centroid,boundary,convexhull,simplify,spatial-query
     26bmLayers=Map,Aerial
     27boName=OSM
     28editingToolbarAlias=Select feature,Add feature,Edit feature
     29boLayers=OSM
     30address=http://127.0.0.1/mm
     31bmName=MapQuest
     32bpList=g,b,i
     33uomsName=Foot,Meter,Deegree
     34adminTheme=green
     35vectorToolbarAlias=Buffer,BufferMask,Centroid,Boundary,ConvexHull,Simplify,SpatialQuery
     36mapcacheCfg=/Users/djay/Sites/mapcache.xml
     37dateFormat=%A %d %B %Y
     38uomsId=english,metric,geographic
     39oldToolbars=Editing,Raster
     40rasterToolbar=profile,contour,shaded_relief,color_relief,slope_map,clip
     41bgLayerAlias=Physical,Streets,Satelite,Hybrid
     42bbLayerAlias=Streets,Satelite,Hybrid
     43sizeLimit=100M
     44biName=IGN
     45
     46[headers]
     47X-Powered-By=ZOO-Project@MapMint
    948
    1049[identification]
    11 title = The Zoo WPS Development Server
    12 abstract = Development version of ZooWPS. See http://www.zoo-project.org
    13 fees = None
    14 accessConstraints = none
    15 keywords = WPS,GIS,buffer
     50keywords=WPS,GIS,buffer,MapMint,ZOO-Project
     51title=ZOO-Project WPS Production Server
     52abstract=Development version of ZooWPS. See http://www.zoo-project.org
     53accessConstraints=none
     54fees=None
    1655
    1756[provider]
    18 providerName=ZOO Project
    19 providerSite=http://www.zoo-project.org
     57positionName=Developer
     58providerName=GeoLabs SARL
     59addressAdministrativeArea=False
     60addressDeliveryPoint=1280, avenue des Platanes
     61addressCountry=fr
     62phoneVoice=+33 4 67 43 09 95
     63addressPostalCode=34970
     64role=Dev
     65providerSite=http://www.geolabs.fr
     66phoneFacsimile=False
     67addressElectronicMailAddress=gerald@geolabs.fr
     68addressCity=Lattes
    2069individualName=Gerald FENOY
    21 positionName=Developer
    22 role=Dev
    23 addressDeliveryPoint=1280, avenue des Platanes
    24 addressCity=Lattes
    25 addressAdministrativeArea=False
    26 addressPostalCode=34970
    27 addressCountry=fr
    28 addressElectronicMailAddress=gerald@geolabs.fr
    29 phoneVoice=False
    30 phoneFacsimile=False
     70
     71[main]
     72encoding=utf-8
     73isTrial=true
     74dataPath=/Users/djay/Sites/data
     75tmpPath=/Users/djay/Sites/tmp
     76supportedDbs=PostGIS,MySQL,WFS
     77cacheDir=/Users/djay/Sites/cache
     78rootUrl=/~djay/mm-np/public/
     79publicationUrl=/~djay/pm-np/
     80dblink=/Users/djay/Sites/mm.db
     81mmPath=/Users/djay/Sites/mm-np/
     82sessPath=/Users/djay/Sites/tmp
     83version=1.0.0
     84dbuser=npdb
     85dcount=3
     86dbuserName=np
     873D=false
     88Rpy2=true
     89applicationAddress=http://127.0.0.1/~djay/mm-np/
     90mmAddress=/~djay/mm-np/
     91publicationPath=/Users/djay/Sites/pm-np/
     92msOgcVersion=1.0.0
     93serverAddress=http://127.0.0.1/np-bin/zoo_loader.cgi
     94lang=fr-FR,en-US,ja-JP
     95mapserverAddress=http://127.0.0.1/np-bin/mapserv.cgi
     96tmpUrl=http://127.0.0.1/~djay/tmp/
     97templatesPath=/Users/djay/Sites/mm-np/templates/
     98templatesAddress=http://127.0.0.1/~djay/pm-np/tmpl/
     99crs=IGNF:LAMB93
     100jsCache=dev
     101cssCache=prod
     102cookiePrefix=MMID
     103
     104[npdb]
     105host=127.0.0.1
     106schema=velo
     107user=postgres
     108dbname=demogis
     109port=5432
     110
     111[oo]
     112external=true
     113path=/Applications/LibreOffice.app/Contents/program/python
     114ghostscript=/usr/local/bin/gs
  • trunk/zoo-project/zoo-kernel/main_conf_read.y

    r453 r465  
    88#include <service.h>
    99
    10 static int defaultsc=0;
    1110static maps* my_maps=NULL;
    1211static maps* current_maps=NULL;
    13 static map* previous_content=NULL;
    1412static map* current_content=NULL;
    15 static elements* current_element=NULL;
    16 static map* scontent=NULL;
    1713static char* curr_key;
    1814static int debug=0;
    19 static int previous_data=0;
    20 static int current_data=0;
    2115using namespace std;
    2216
  • trunk/zoo-project/zoo-kernel/makefile.vc

    r453 r465  
    99
    1010all:  zoo_loader.cgi
     11
     12version.h:
     13        svnversion -q -c -n . > version_0.h
     14        set /p VERS=<version_0.h
     15        rm version_0.h
     16        echo #define ZOO_VERSION "%VERS%" > version.h
    1117
    1218main_conf_read.tab.c: main_conf_read.y service.h
  • trunk/zoo-project/zoo-kernel/service.h

    r458 r465  
    8282#define SHMSZ     27
    8383
     84#include "version.h"
    8485
    8586#ifdef DEBUG_STACK
     
    133134  static void _dumpMap(map* t){
    134135    if(t!=NULL){
    135       fprintf(stderr,"[%s] => [%s] \n",t->name,t->value);
     136      fprintf(stderr,"%s: %s\n",t->name,t->value);
    136137      fflush(stderr);
    137138        }else{
     
    437438    map* tmp=mi;
    438439    map* _cursor=*mo;
    439     if(tmp==NULL){
    440       if(_cursor!=NULL){
    441         while(_cursor!=NULL)
    442           _cursor=_cursor->next;
    443         _cursor=NULL;
    444       }else
    445         *mo=NULL;
    446     }
    447440    while(tmp!=NULL){
    448441      if(_cursor==NULL){
    449         if(*mo==NULL)
    450           *mo=createMap(tmp->name,tmp->value);
    451         else
    452           addToMap(*mo,tmp->name,tmp->value);
     442        *mo=createMap(tmp->name,tmp->value);
     443        (*mo)->next=NULL;
    453444      }
    454445      else{
     
    457448        dumpMap(_cursor);
    458449#endif
    459         while(_cursor!=NULL)
     450        while(_cursor->next!=NULL)
    460451          _cursor=_cursor->next;
    461         _cursor=createMap(tmp->name,tmp->value);
    462         _cursor->next=NULL;
    463       }
     452        map* tmp1=getMap(_cursor,tmp->name);
     453        if(tmp1==NULL)
     454          _cursor->next=createMap(tmp->name,tmp->value);
     455        else{
     456          free(tmp1->value);
     457          tmp1->value=zStrdup(tmp->value);
     458        }
     459      }
     460      _cursor=*mo;
    464461      tmp=tmp->next;
    465462#ifdef DEBUG
     
    568565      if(_cursor==NULL){
    569566        *mo=dupMaps(&mi);
    570         (*mo)->next=NULL;
    571567      }
    572568      else{
     569        maps* tmp1=getMaps(*mo,tmp->name);
    573570        while(_cursor->next!=NULL)
    574571          _cursor=_cursor->next;
    575         _cursor->next=dupMaps(&tmp);
     572        if(tmp1==NULL)
     573          _cursor->next=dupMaps(&tmp);
     574        else
     575          addMapToMap(&tmp1->content,tmp->content);
     576        _cursor=*mo;
    576577      }
    577578      tmp=tmp->next;
     
    603604    else
    604605      sprintf(tmp,"%s",key);
    605     map* tmpSize=getMapArray(m,"size",index);
     606    map* tmpSize=getMapArray(m,(char*)"size",index);
    606607    if(tmpSize!=NULL && strncasecmp(key,"value",5)==0){
    607608#ifdef DEBUG
    608609      fprintf(stderr,"%s\n",tmpSize->value);
    609610#endif
    610       map* ptr=getMapOrFill(m,tmp,"");
     611      map* ptr=getMapOrFill(m,tmp,(char *)"");
    611612      free(ptr->value);
    612613      ptr->value=(char*)malloc((atoi(tmpSize->value)+1)*sizeof(char));
     
    618619
    619620  static map* getMapType(map* mt){
    620     map* tmap=getMap(mt,"mimeType");
     621    map* tmap=getMap(mt,(char *)"mimeType");
    621622    if(tmap==NULL){
    622623      tmap=getMap(mt,"dataType");
     
    646647
    647648    char *tmpV[8]={
    648       "size",
    649       "value",
    650       "uom",
    651       "Reference",
    652       "xlink:href",
     649      (char*)"size",
     650      (char*)"value",
     651      (char*)"uom",
     652      (char*)"Reference",
     653      (char*)"xlink:href",
    653654      typ,
    654       "schema",
    655       "encoding"
     655      (char*)"schema",
     656      (char*)"encoding"
    656657    };
    657658    sprintf(tmpLen,"%d",len+1);
     
    730731  }
    731732
     733  static void dumpElementsAsYAML(elements* e){
     734    elements* tmp=e;
     735    while(tmp!=NULL){
     736      for(int i=0;i<2;i++)
     737        fprintf(stderr," ");
     738      fprintf(stderr,"%s:\n",tmp->name);
     739      map* mcurs=tmp->content;
     740      while(mcurs!=NULL){
     741        for(int i=0;i<4;i++)
     742          fprintf(stderr," ");
     743        _dumpMap(mcurs);
     744        mcurs=mcurs->next;
     745      }
     746      mcurs=tmp->metadata;
     747      if(mcurs!=NULL){
     748        for(int i=0;i<4;i++)
     749          fprintf(stderr," ");
     750        fprintf(stderr,"MetaData:\n");
     751        while(mcurs!=NULL){
     752          for(int i=0;i<6;i++)
     753            fprintf(stderr," ");
     754          _dumpMap(mcurs);
     755          mcurs=mcurs->next;
     756        }
     757      }
     758      for(int i=0;i<4;i++)
     759        fprintf(stderr," ");
     760      fprintf(stderr,"%s:\n",tmp->format);
     761      iotype* tmpio=tmp->defaults;
     762      int ioc=0;
     763      while(tmpio!=NULL){
     764        for(int i=0;i<6;i++)
     765          fprintf(stderr," ");
     766        fprintf(stderr,"default:\n");
     767        mcurs=tmpio->content;
     768        while(mcurs!=NULL){
     769          for(int i=0;i<8;i++)
     770            fprintf(stderr," ");
     771          if(strcasecmp(mcurs->name,"range")==0){
     772            fprintf(stderr,"range: \"%s\"\n",mcurs->value);
     773          }else
     774            _dumpMap(mcurs);
     775          mcurs=mcurs->next;
     776        }
     777        tmpio=tmpio->next;
     778        ioc++;
     779      }
     780      tmpio=tmp->supported;
     781      ioc=0;
     782      while(tmpio!=NULL){
     783        for(int i=0;i<6;i++)
     784          fprintf(stderr," ");
     785        fprintf(stderr,"supported:\n");
     786        mcurs=tmpio->content;
     787        while(mcurs!=NULL){
     788          for(int i=0;i<8;i++)
     789            fprintf(stderr," ");
     790          if(strcasecmp(mcurs->name,"range")==0){
     791            fprintf(stderr,"range: \"%s\"\n",mcurs->value);
     792          }else
     793            _dumpMap(mcurs);
     794          mcurs=mcurs->next;
     795        }
     796        tmpio=tmpio->next;
     797        ioc++;
     798      }
     799      tmp=tmp->next;
     800    }
     801  }
     802
     803
    732804  static elements* dupElements(elements* e){
    733805    elements* cursor=e;
     
    805877    }
    806878    fprintf(stderr,"++++++++++++++++++\n");
     879  }
     880
     881  static void dumpServiceAsYAML(service* s){
     882    int level=0;
     883    fprintf(stderr,"# %s\n\n",s->name);
     884    if(s->content!=NULL){
     885      map* mcurs=s->content;
     886      dumpMap(mcurs);
     887      mcurs=s->metadata;
     888      if(mcurs!=NULL){
     889        fprintf(stderr,"MetaData:\n");
     890        while(mcurs!=NULL){
     891          for(int i=0;i<2;i++)
     892            fprintf(stderr," ");
     893          _dumpMap(mcurs);
     894          mcurs=mcurs->next;
     895        }
     896      }
     897    }
     898    if(s->inputs!=NULL){
     899      fprintf(stderr,"\ninputs:\n",s->name);
     900      dumpElementsAsYAML(s->inputs);
     901    }
     902    if(s->outputs!=NULL){
     903      fprintf(stderr,"\noutputs:\n",s->name);
     904      dumpElementsAsYAML(s->outputs);
     905    }
    807906  }
    808907
  • trunk/zoo-project/zoo-kernel/service_conf.l

    r229 r465  
    2222#endif
    2323
    24 
     24char *lmsg;
    2525int attentionImpossibleDeTrouverXMLDeclapres = 0 ;
    2626
     
    4141
    4242attname [a-zA-Z0-9_\-]+
    43 attvalue1       [\^\*\+,;@a-zA-Z0-9_\-::.:" "\"\'/\\\(\)\t\|\$\&>]+
     43attvalue1       [\^\*\+,;@a-zA-Z0-9_\-::.:" "\"\'/\\\(\)\t\|\$\&>\[\]]+
    4444
    4545attvalue                \"[^"]*\"|\'[^']*\'\(\)
     
    118118
    119119
    120 <INITIAL,DANSBALISE,HORSBALISE>.|\n     {fprintf(stderr,"error : ligne %d : caractere non reconnu '%s'\n",srlineno,yytext);}
     120<INITIAL,DANSBALISE,HORSBALISE>.|\n     {lmsg=(char*)malloc(1024*sizeof(char));sprintf(lmsg,"error: line %d: character not allowed '%s'",srlineno,yytext);fprintf(stderr,"%s \n",lmsg);srlval.chaine=lmsg;return -1;}
    121121
    122122%%
  • trunk/zoo-project/zoo-kernel/service_conf.y

    r453 r465  
    2424static bool wait_outputs=false;
    2525static bool wait_data=false;
    26 static int services_c=0;
    2726static service* my_service=NULL;
    28 static map* previous_content=NULL;
    2927static map* current_content=NULL;
    3028static elements* current_element=NULL;
    31 static map* scontent=NULL;
    3229static char* curr_key;
    3330static int debug=0;
     
    772769 * definition file.
    773770 */
    774 int getServiceFromFile(const char* file,service** service){
    775 
    776   freeMap(&previous_content);
    777   previous_content=NULL;
    778   freeMap(&current_content);
    779   current_content=NULL;
    780   freeMap(&scontent);
     771int getServiceFromFile(maps* conf,const char* file,service** service){
     772  if(current_content!=NULL){
     773    freeMap(&current_content);
     774    free(current_content);
     775    current_content=NULL;
     776  }
    781777#ifdef DEBUG_SERVICE_CONF
    782778  fprintf(stderr,"(STARTING)FREE current_element\n");
    783779#endif
    784   freeElements(&current_element);
    785   free(current_element);
    786   current_element=NULL;
     780  if(current_element!=NULL){
     781    freeElements(&current_element);
     782    free(current_element);
     783    current_element=NULL;
     784  }
    787785  my_service=NULL;
    788   scontent=NULL;
    789786
    790787  wait_maincontent=true;
     
    810807  int resultatYYParse = srparse() ;
    811808 
     809#ifdef DEBUG_SERVICE_CONF
     810  fprintf(stderr,"RESULT: %d %d\n",resultatYYParse,wait_outputs);
     811#endif
    812812  if(wait_outputs && current_element!=NULL && current_element->name!=NULL){
    813813    if(my_service->outputs==NULL){     
     
    848848  dumpService(my_service);
    849849#endif
    850   *service=my_service;
     850  if(wait_outputs<0 || my_service==NULL || my_service->name==NULL || my_service->content==NULL || my_service->inputs==NULL || my_service->outputs==NULL){
     851    setMapInMaps(conf,"lenv","message",srlval.chaine);
     852#ifndef WIN32
     853    srlex_destroy();
     854#endif
     855    return -1;
     856  }
     857  else
     858    *service=my_service;
    851859
    852860#ifndef WIN32
  • trunk/zoo-project/zoo-kernel/service_internal.c

    r464 r465  
    3434#define FALSE -1
    3535#endif
     36
     37int readServiceFile(maps* conf, char* file,service** service,char *name){
     38  int t=getServiceFromFile(conf,file,service);
     39#ifdef YAML
     40  if(t<0){
     41    t=getServiceFromYAML(conf,file,service,name);
     42  }
     43#endif
     44  return t;
     45}
    3646
    3747void printHeaders(maps* m){
     
    883893
    884894void printFullDescription(elements *elem,const char* type,xmlNsPtr ns_ows,xmlNodePtr nc1){
    885   char *orderedFields[12];
     895  char *orderedFields[13];
    886896  orderedFields[0]="mimeType";
    887897  orderedFields[1]="encoding";
     
    892902  orderedFields[6]="value";
    893903  orderedFields[7]="AllowedValues";
    894   orderedFields[8]="rangeMin";
    895   orderedFields[9]="rangeMax";
    896   orderedFields[10]="rangeClosure";
    897   orderedFields[11]="rangeSpace";
     904  orderedFields[8]="range";
     905  orderedFields[9]="rangeMin";
     906  orderedFields[10]="rangeMax";
     907  orderedFields[11]="rangeClosure";
     908  orderedFields[12]="rangeSpace";
    898909
    899910  xmlNodePtr nc2,nc3,nc4,nc5,nc6,nc7,nc8;
     
    935946        nc3 = xmlNewNode(NULL, BAD_CAST e->format);
    936947    }
     948    iotype* _tmp0=NULL;
    937949    iotype* _tmp=e->defaults;
    938950    int datatype=0;
     
    961973      int dcnt=0;
    962974      int oI=0;
    963       for(oI=0;oI<12;oI++)
     975      for(oI=0;oI<13;oI++)
    964976        if((tmp1=getMap(_tmp->content,orderedFields[oI]))!=NULL){
    965977          //while(tmp1!=NULL){
     
    10181030                  token=strtok_r(NULL,",",&saveptr1);
    10191031                }
    1020                 if(getMap(_tmp->content,"rangeMin")!=NULL ||
     1032                if(getMap(_tmp->content,"range")!=NULL ||
     1033                   getMap(_tmp->content,"rangeMin")!=NULL ||
    10211034                   getMap(_tmp->content,"rangeMax")!=NULL ||
    10221035                   getMap(_tmp->content,"rangeClosure")!=NULL )
     
    10291042                  nc6 = xmlNewNode(ns_ows, BAD_CAST "AllowedValues");
    10301043                doRange:
     1044                 
     1045                  /**
     1046                   * Range: Table 46 OGC Web Services Common Standard
     1047                   */
    10311048                  nc8 = xmlNewNode(ns_ows, BAD_CAST "Range");
    1032                   map *tmp0=getMap(tmp1,"rangeMin");
     1049
     1050                  map* tmp0=getMap(tmp1,"range");
     1051                  if(tmp0!=NULL){
     1052                    char* pToken;
     1053                    char* orig=zStrdup(tmp0->value);
     1054                    /**
     1055                     * RangeClosure: Table 47 OGC Web Services Common Standard
     1056                     */
     1057                    char *tmp="closed";
     1058                    if(orig[0]=='[' && orig[strlen(orig)-1]=='[')
     1059                      tmp="closed-open";
     1060                    else
     1061                      if(orig[0]==']' && orig[strlen(orig)-1]==']')
     1062                        tmp="open-closed";
     1063                      else
     1064                        if(orig[0]==']' && orig[strlen(orig)-1]=='[')
     1065                          tmp="open";
     1066                    xmlNewNsProp(nc8,ns_ows,BAD_CAST "rangeClosure",BAD_CAST tmp);
     1067                    pToken=strtok(orig,",");
     1068                    int nci0=0;
     1069                    while(pToken!=NULL){
     1070                      char *tmpStr=(char*) malloc((strlen(pToken))*sizeof(char));
     1071                      if(nci0==0){
     1072                        nc7 = xmlNewNode(ns_ows, BAD_CAST "MinimumValue");
     1073                        int nci=1;
     1074                        for(nci=1;nci<strlen(pToken);nci++){
     1075                          tmpStr[nci-1]=pToken[nci];
     1076                        }
     1077                      }else{
     1078                        nc7 = xmlNewNode(ns_ows, BAD_CAST "MaximumValue");
     1079                        int nci=0;
     1080                        for(nci=0;nci<strlen(pToken)-1;nci++){
     1081                          tmpStr[nci]=pToken[nci];
     1082                        }
     1083                      }
     1084                      xmlAddChild(nc7,xmlNewText(BAD_CAST tmpStr));
     1085                      xmlAddChild(nc8,nc7);
     1086                      nci0++;
     1087                      pToken = strtok(NULL,",");
     1088                    }               
     1089                    if(getMap(tmp1,"rangeSpacing")==NULL){
     1090                      nc7 = xmlNewNode(ns_ows, BAD_CAST "Spacing");
     1091                      xmlAddChild(nc7,xmlNewText(BAD_CAST "1"));
     1092                      xmlAddChild(nc8,nc7);
     1093                    }
     1094                  }else{
     1095
     1096                  tmp0=getMap(tmp1,"rangeMin");
    10331097                  if(tmp0!=NULL){
    10341098                    nc7 = xmlNewNode(ns_ows, BAD_CAST "MinimumValue");
     
    10681132                  }else
    10691133                    xmlNewNsProp(nc8,ns_ows,BAD_CAST "rangeClosure",BAD_CAST "closed");
     1134                  }
     1135                  if(_tmp0==NULL){
     1136                    xmlAddChild(nc6,nc8);
     1137                    _tmp0=e->supported;
     1138                    tmp1=_tmp0->content;
     1139                    goto doRange;
     1140                  }else{
     1141                    _tmp0=_tmp0->next;
     1142                    if(_tmp0!=NULL){
     1143                      xmlAddChild(nc6,nc8);
     1144                      tmp1=_tmp0->content;
     1145                      goto doRange;
     1146                    }
     1147                 
     1148                  }
     1149                  xmlAddChild(nc6,nc8);
     1150                  xmlAddChild(nc3,nc6);
     1151                  isAnyValue=-1;
    10701152                }
    1071                 xmlAddChild(nc6,nc8);
    1072                 xmlAddChild(nc3,nc6);
    1073                 isAnyValue=-1;
    10741153              }
    10751154            }
     
    10961175          avcnt++;
    10971176        }
     1177      }
     1178     
     1179      map* metadata=e->metadata;
     1180      xmlNodePtr n;
     1181      int xlinkId=zooXmlAddNs(n,"http://www.w3.org/1999/xlink","xlink");
     1182      xmlNsPtr ns_xlink=usedNs[xlinkId];
     1183
     1184      while(metadata!=NULL){
     1185        nc6=xmlNewNode(ns_ows, BAD_CAST "MetaData");
     1186        xmlNewNsProp(nc6,ns_xlink,BAD_CAST metadata->name,BAD_CAST metadata->value);
     1187        xmlAddChild(nc2,nc6);
     1188        metadata=metadata->next;
    10981189      }
    10991190    }
  • trunk/zoo-project/zoo-kernel/service_internal.h

    r459 r465  
    6565#include "ulinet.h"
    6666
    67 extern   int getServiceFromFile(const char*,service**);
     67extern   int getServiceFromFile(maps*,const char*,service**);
    6868extern   int conf_read(const char*,maps*);
    6969
     
    8888  static char* nsName[10];
    8989  static int nbNs=0;
     90
     91  int getServiceFromYAML(maps*,char*,service**,char *name);
     92  int readServiceFile(maps*, char*,service**,char *);
     93 
    9094
    9195  void printHeaders(maps*);
  • trunk/zoo-project/zoo-kernel/service_internal_python.c

    r458 r465  
    101101  tmp = PyInt_FromLong(4);
    102102  PyDict_SetItemString(d, "SERVICE_FAILED", tmp);
     103  Py_DECREF(tmp);
     104
     105  tmp = PyString_FromString(ZOO_VERSION);
     106  PyDict_SetItemString(d, "VERSION", tmp);
    103107  Py_DECREF(tmp);
    104108
  • trunk/zoo-project/zoo-kernel/zoo_loader.c

    r459 r465  
    117117    }else{
    118118      char *buffer=new char[cgiContentLength+1];
    119       int r=0;
    120119      if(fread(buffer,sizeof(char),cgiContentLength,cgiIn)>=0){
    121120        buffer[cgiContentLength]=0;
     
    223222          if(req!=NULL && req->nodeNr==1){
    224223            addToMap(tmpMap,"soap","true");
    225             int k=0;
    226             for(k;k < req->nodeNr;k++){
    227               xmlNsPtr ns=xmlNewNs(req->nodeTab[k],BAD_CAST "http://www.w3.org/2001/XMLSchema-instance",BAD_CAST "xsi");
     224            for(int k=0;k < req->nodeNr;k++){
     225              //xmlNsPtr ns=xmlNewNs(req->nodeTab[k],BAD_CAST "http://www.w3.org/2001/XMLSchema-instance",BAD_CAST "xsi");
    228226              xmlDocSetRootElement(doc, req->nodeTab[k]);
    229227              xmlChar *xmlbuff;
     
    231229              xmlDocDumpFormatMemoryEnc(doc, &xmlbuff, &buffersize, "utf-8", 1);
    232230              addToMap(tmpMap,"xrequest",(char*)xmlbuff);
    233               char *tmp=(char*)xmlbuff;
    234231              xmlFree(xmlbuff);
    235232            }
  • trunk/zoo-project/zoo-kernel/zoo_service_loader.c

    r459 r465  
    239239  map* r_inputs=NULL;
    240240#ifndef WIN32
    241   char* pntmp=getcwd(ntmp,1024);
     241  getcwd(ntmp,1024);
    242242#else
    243243  _getcwd(ntmp,1024);
     
    560560  char ntmp[1024];
    561561#ifndef WIN32
    562   char *pntmp=getcwd(ntmp,1024);
     562  getcwd(ntmp,1024);
    563563#else
    564564  _getcwd(ntmp,1024);
     
    760760    while ((dp = readdir(dirp)) != NULL)
    761761      if(strstr(dp->d_name,".zcfg")!=0){
     762        int t;
    762763        memset(tmps1,0,1024);
    763764        snprintf(tmps1,1024,"%s/%s",conf_dir,dp->d_name);
     
    769770        fprintf(stderr,"#################\n%s\n#################\n",tmps1);
    770771#endif
    771         t=getServiceFromFile(tmps1,&s1);
     772        t=readServiceFile(m,tmps1,&s1,dp->d_name);
     773        if(t<0){
     774          dumpMaps(m);
     775          map* tmp00=getMapFromMaps(m,"lenv","message");
     776          char tmp01[1024];
     777          sprintf(tmp01,_("Unable to parse the ZCFG file: %s (%s)"),dp->d_name,tmp00->value);
     778          dup2(saved_stdout,fileno(stdout));
     779          errorException(m, tmp01,"InternalError",NULL);
     780          freeMaps(&m);
     781          free(m);
     782          return 1;
     783        }
     784
    772785#ifdef DEBUG
    773786        dumpService(s1);
     
    828841
    829842      r_inputs=getMap(request_inputs,"Identifier");
    830       char *tmps=strtok(r_inputs->value,",");
     843     
     844      char *saveptr;
     845      char *orig=zStrdup(r_inputs->value);
     846      char *tmps=strtok_r(orig,",",&saveptr);
    831847     
    832848      char buff[256];
     
    839855        memset(buff1,0,1024);
    840856#ifdef DEBUG
    841         printf("\n#######%s\n########\n",buff1);
     857        printf("\n#######%s\n########\n",buff);
    842858#endif
    843859        while ((dp = readdir(dirp)) != NULL)
     
    852868            }
    853869#ifdef DEBUG
    854             printf("#################\n%s\n#################\n",buff1);
    855 #endif
    856             t=getServiceFromFile(buff1,&s1);
     870            printf("#################\n(%s) %s\n#################\n",r_inputs->value,buff1);
     871#endif
     872            char *tmp0=zStrdup(dp->d_name);
     873            tmp0[strlen(tmp0)-5]=0;
     874            t=readServiceFile(m,buff1,&s1,tmp0);
     875            free(tmp0);
     876            if(t<0){
     877              map* tmp00=getMapFromMaps(m,"lenv","message");
     878              char tmp01[1024];
     879              if(tmp00!=NULL)
     880                sprintf(tmp01,_("Unable to parse the ZCFG file: %s (%s)"),dp->d_name,tmp00->value);
     881              else
     882                sprintf(tmp01,_("Unable to parse the ZCFG file: %s."),dp->d_name);
     883              dup2(saved_stdout,fileno(stdout));
     884              errorException(m, tmp01,"InternalError",NULL);
     885              freeMaps(&m);
     886              free(m);
     887              return 1;
     888            }
    857889#ifdef DEBUG
    858890            dumpService(s1);
     
    861893            freeService(&s1);
    862894            free(s1);
     895            s1=NULL;
    863896            scount++;
    864897          }
    865898        rewinddir(dirp);
    866         tmps=strtok(NULL,",");
     899        tmps=strtok_r(NULL,",",&saveptr);
    867900      }
    868901      closedir(dirp);
    869902      fflush(stdout);
    870903      dup2(saved_stdout,fileno(stdout));
     904      free(orig);
    871905      printDocument(m,doc,getpid());
    872906      freeMaps(&m);
     
    917951  int saved_stdout = dup(fileno(stdout));
    918952  dup2(fileno(stderr),fileno(stdout));
    919   t=getServiceFromFile(tmps1,&s1);
     953  t=readServiceFile(m,tmps1,&s1,r_inputs->value);
    920954  fflush(stdout);
    921955  dup2(saved_stdout,fileno(stdout));
     
    21812215  addToMap(_tmpMaps->content,"sid",tmpBuff);
    21822216  addToMap(_tmpMaps->content,"status","0");
     2217  addToMap(_tmpMaps->content,"cwd",ntmp);
    21832218  addToMap(_tmpMaps->content,"message",_("No message provided"));
    2184   addToMap(_tmpMaps->content,"cwd",ntmp);
    21852219  map* ltmp=getMap(request_inputs,"soap");
    21862220  if(ltmp!=NULL)
     
    22482282  freeMaps(&_tmpMaps);
    22492283  free(_tmpMaps);
    2250 
     2284 
    22512285#ifdef DEBUG
    22522286  dumpMap(request_inputs);
     
    22652299  }
    22662300#endif
    2267   int hrstd=-1;
    22682301  char *fbkp,*fbkp1;
    22692302  FILE *f0,*f1;
  • trunk/zoo-project/zoo-services/ogr/base-vect-ops-py/cgi-env/CentroidPy.zcfg

    r106 r465  
    1 [CentroidPy]
    2  Title = Get the centroid of a polygon.
    3  Abstract = Compute the geometry centroid.
    4  Profile = urn:ogc:wps:1.0.0:centroid
    5  processVersion = 2
     1[Clean]
     2 Title = Extract the feature that have a valid geometry field.
     3 Abstract = Extract the feature that have a valid geometry field.
     4 processVersion = 1
    65 storeSupported = true
    76 statusSupported = true
    87 serviceProvider = ogr_sp
    98 serviceType = Python
    10  <MetaData>
    11    title = Demo
    12  </MetaData>
    139 <DataInputs>
    14   [InputPolygon]
     10  [InputData]
    1511   Title = Polygon to get the centroid
    1612   Abstract = The centroid which is not necessarily within the geometry.
    1713   minOccurs = 1
    1814   maxOccurs = 1
    19    <MetaData>
    20     title = Mon test 
    21    </MetaData>   
    2215   <ComplexData>
    2316    <Default>
     
    3730   Title = The Centroid
    3831   Abstract = JSON String / GML Entity of the centroid
    39    <MetaData>
    40     title = Mon test 
    41    </MetaData>   
    4232   <ComplexData>
    4333    <Default>
  • trunk/zoo-project/zoo-services/ogr/base-vect-ops-py/cgi-env/ogr_sp.py

    r447 r465  
    5252        print >> sys.stderr,e
    5353        return []
    54 
     54   
    5555def buildFeatureFromGeomtry(conf,geom,driverName,ext):
    5656    drv = osgeo.ogr.GetDriverByName( driverName )
     
    6969def createGeometryFromWFS(conf,my_wfs_response):
    7070    try:
    71         geom=osgeo.ogr.CreateGeometryFromGML(my_wfs_response.replace('<?xml version="1.0" encoding="utf-8"?>\n',''))
    72     except:
     71        geom=osgeo.ogr.CreateGeometryFromGML(my_wfs_response.replace('<?xml version="1.0" encoding="utf-8"?>\n','').replace('<?xml version=\'1.0\' encoding="utf-8"?>\n',''))
     72    except Exception,e:
     73        print >> sys.stderr,"**"
     74        print >> sys.stderr,e
    7375        geom=None
    7476    try:
     77        print >> sys.stderr,geom is None
    7578        if geom is None:
    7679            if not(conf["lenv"].has_key("cnt")):
     
    98101   
    99102def outputResult(conf,obj,geom):
    100     driverName = "GML"
    101     extension = [ ".xml" , ".xsd" ]
     103    if obj["mimeType"].count("text/xml")>0:
     104        driverName = "GML"
     105        extension = [ ".xml" , ".xsd" ]
     106        format_list = { "2.": 'GML2', "3.1.1": 'GML3', "3.1": 'GML3Deegree', "3.2": 'GML3.2' }
     107        opts=['FORMAT=%s,GML3_LONGSRS=YES',format_list["3.2"]]
     108        for i in format_list:
     109            if obj["mimeType"].count(i)>0:
     110                opts=['FORMAT=%s,GML3_LONGSRS=YES',format_list[i]]
    102111    if obj["mimeType"]=="application/json":
    103112        driverName = "GeoJSON"
    104113        extension = [ ".js" ]
     114        opts=None
    105115    if obj.keys().count("schema")>0 and \
    106116            obj["schema"]=="http://schemas.opengis.net/kml/2.2.0/ogckml22.xsd":
    107117        driverName = "KML"
    108118        extension = [ ".kml" ]
     119        opts=None
    109120    drv = osgeo.ogr.GetDriverByName( driverName )
    110     # Create virtual file
    111     ds = drv.CreateDataSource( "/vsimem/store"+conf["lenv"]["sid"]+extension[0] )
     121    print >> sys.stderr,drv
     122    # Create virtual file
     123    ds = drv.CreateDataSource( "/vsimem/store"+conf["lenv"]["sid"]+extension[0],options = opts)
     124    print >> sys.stderr,ds
    112125    lyr = ds.CreateLayer( "Result", None, osgeo.ogr.wkbUnknown )
    113     i=0
     126    print >> sys.stderr,lyr
     127    i=0
     128    print >> sys.stderr,driverName
     129    print >> sys.stderr,extension
    114130    while i < len(geom):
    115131        if i==0 and driverName!="GeoJSON":
     
    123139                    oFieldDefn.SetPrecision( poSrcFieldDefn.GetPrecision() )
    124140                    lyr.CreateField( oFieldDefn )
    125         lyr.CreateFeature(geom[i])
     141        try:
     142            lyr.CreateFeature(geom[i])
     143        except:
     144            pass
    126145        geom[i].Destroy()
    127146        i+=1
     
    157176    outputResult(conf,outputs["Result"],rgeometries)
    158177    i=0
     178    return zoo.SERVICE_SUCCEEDED
     179
     180def Clean(conf,inputs,outputs):
     181    from shapely.wkb import loads
     182    print >> sys.stderr, "Starting service ..."
     183    features=extractInputs(conf,inputs["InputData"])
     184    i=0
     185    rgeometries=[]
     186    while i < len(features):
     187        tmp=features[i].Clone()
     188        resg=features[i].GetGeometryRef()
     189        if resg is not None:
     190            geom = loads(resg.ExportToWkb())
     191            if geom.is_valid:
     192                tmp.SetGeometryDirectly(resg)
     193                rgeometries+=[tmp]
     194                print >> sys.stderr,"valid !"
     195            else:
     196                print >> sys.stderr,"invalid !"
     197                print >> sys.stderr,geom.wkt[0:50]
     198        features[i].Destroy()
     199        resg.thisown=False
     200        tmp.thisown=False
     201        i+=1
     202    outputResult(conf,outputs["Result"],rgeometries)
     203    i=0
     204    print >> sys.stderr,"Return"
     205    return zoo.SERVICE_SUCCEEDED
     206
     207def TransformService(conf,inputs,outputs):
     208    from osgeo import osr
     209    geometry=extractInputs(conf,inputs["InputData"])
     210    sourceRef = osr.SpatialReference()
     211    tmp=inputs["SourceCRS"]["value"].split(":")
     212    sourceRef.ImportFromEPSG(int(tmp[len(tmp)-1]))
     213    targetRef = osr.SpatialReference()   
     214    tmp=inputs["TargetCRS"]["value"].split(":")
     215    targetRef.ImportFromEPSG(int(tmp[len(tmp)-1]))
     216    transform = osr.CoordinateTransformation(sourceRef, targetRef)
     217    i=0
     218    rgeometries=[]
     219    while i < len(geometry):
     220        tmp=geometry[i].Clone()
     221        resg=geometry[i].GetGeometryRef()
     222        resg.Transform(transform)
     223        tmp.SetGeometryDirectly(resg.Clone())
     224        rgeometries+=[tmp]
     225        geometry[i].Destroy()
     226        i+=1
     227    outputResult(conf,outputs["TransformedData"],rgeometries)
    159228    return zoo.SERVICE_SUCCEEDED
    160229
Note: See TracChangeset for help on using the changeset viewer.

Search

Context Navigation

ZOO Sponsors

http://www.zoo-project.org/trac/chrome/site/img/geolabs-logo.pnghttp://www.zoo-project.org/trac/chrome/site/img/neogeo-logo.png http://www.zoo-project.org/trac/chrome/site/img/apptech-logo.png http://www.zoo-project.org/trac/chrome/site/img/3liz-logo.png http://www.zoo-project.org/trac/chrome/site/img/gateway-logo.png

Become a sponsor !

Knowledge partners

http://www.zoo-project.org/trac/chrome/site/img/ocu-logo.png http://www.zoo-project.org/trac/chrome/site/img/gucas-logo.png http://www.zoo-project.org/trac/chrome/site/img/polimi-logo.png http://www.zoo-project.org/trac/chrome/site/img/fem-logo.png http://www.zoo-project.org/trac/chrome/site/img/supsi-logo.png http://www.zoo-project.org/trac/chrome/site/img/cumtb-logo.png

Become a knowledge partner

Related links

http://zoo-project.org/img/ogclogo.png http://zoo-project.org/img/osgeologo.png