Ignore:
Timestamp:
Mar 28, 2015, 12:58:00 AM (9 years ago)
Author:
djay
Message:

Fix for OTB support when input was passed by value rather than reference.

Location:
trunk/zoo-project/zoo-kernel
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/zoo-project/zoo-kernel/service.h

    r607 r618  
    104104#include <string.h>
    105105#ifndef WIN32
     106#include <ctype.h>
    106107#ifndef bool
    107108#define bool int
     
    115116   * Local false definition
    116117   */
    117 #define false -1
     118#define false 0
    118119#endif
    119120#endif
     
    12671268   */
    12681269  static void dumpService(service* s){
     1270    if(s==NULL)
     1271      return;
    12691272    fprintf(stderr,"++++++++++++++++++\nSERVICE [%s]\n++++++++++++++++++\n",s->name);
    12701273    if(s->content!=NULL){
  • trunk/zoo-project/zoo-kernel/service_conf.l

    r550 r618  
    2222#endif
    2323
    24 char *lmsg;
     24char *lmsg=NULL;
    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                \"[^"]*\"|\'[^']*\'\(\)
  • trunk/zoo-project/zoo-kernel/service_conf.y

    r607 r618  
    2020static bool wait_defaults=false;
    2121static bool wait_supporteds=false;
    22 static bool wait_outputs=-1;
     22static bool wait_outputs=false;
    2323static bool wait_data=false;
    2424static service* my_service=NULL;
     
    805805  dumpElements(current_element);
    806806#endif
    807   if(wait_outputs>0 && current_element!=NULL && current_element->name!=NULL){
     807  if(wait_outputs && current_element!=NULL && current_element->name!=NULL){
    808808    if(my_service->outputs==NULL){ 
    809809#ifdef DEBUG_SERVICE_CONF
     
    834834    current_element=NULL;
    835835  }
    836   int contentOnly=-1;
     836  int contentOnly=false;
    837837  if(current_content!=NULL){
    838838    if(my_service->content==NULL){
    839839      addMapToMap(&my_service->content,current_content);
    840       contentOnly=1;
     840      contentOnly=true;
     841      wait_maincontent=false;
    841842    }
    842843    freeMap(&current_content);
     
    848849  dumpService(my_service);
    849850#endif
    850   if(contentOnly<0 && ((wait_outputs<0 && current_data==2 && my_service->outputs==NULL) || my_service==NULL || my_service->name==NULL || my_service->content==NULL)){
     851  if(wait_maincontent==true || (contentOnly==false && ((!wait_outputs && current_data==2 && my_service->outputs==NULL) || my_service==NULL || my_service->name==NULL || my_service->content==NULL))){
    851852    setMapInMaps(conf,"lenv","message",srlval.chaine);
    852853#ifndef WIN32
  • trunk/zoo-project/zoo-kernel/service_internal.c

    r607 r618  
    27882788            map *ext=getMap(tmpI->content,"extension");
    27892789            char *file_path;
    2790                 char file_ext[32];
     2790            char file_ext[32];
    27912791
    27922792            if( ext != NULL && ext->value != NULL) {
    2793                         strncpy(file_ext, ext->value, 32);
    2794                 }
    2795                 else {
     2793              strncpy(file_ext, ext->value, 32);
     2794            }
     2795            else {
    27962796              // Obtain default file extension (see mimetypes.h).             
    27972797              // If the MIME type is not recognized, txt is used as the default extension
    27982798              map* mtype=getMap(tmpI->content,"mimeType");
    2799                   getFileExtension(mtype != NULL ? mtype->value : NULL, file_ext, 32);
     2799              getFileExtension(mtype != NULL ? mtype->value : NULL, file_ext, 32);
    28002800            }
    28012801               
    2802                 file_name=(char*)malloc((strlen(s->name)+strlen(file_ext)+strlen(tmpI->name)+1024)*sizeof(char));
     2802            file_name=(char*)malloc((strlen(s->name)+strlen(file_ext)+strlen(tmpI->name)+1024)*sizeof(char));
    28032803            int cpid0=cpid+time(NULL);     
    2804                 sprintf(file_name,"%s_%s_%i.%s",s->name,tmpI->name,cpid0,file_ext);
     2804            sprintf(file_name,"%s_%s_%i.%s",s->name,tmpI->name,cpid0,file_ext);
    28052805            file_path=(char*)malloc((strlen(tmp1->value)+strlen(file_name)+2)*sizeof(char));
    28062806            sprintf(file_path,"%s/%s",tmp1->value,file_name);
  • trunk/zoo-project/zoo-kernel/service_internal_otb.c

    r580 r618  
    158158                char tmp[1024];
    159159                map* tmpVal=getMapFromMaps(outputs,paramKey.c_str(),"mimeType");
     160                maps* tmpMaps=getMaps(outputs,paramKey.c_str());
    160161                if(test!=NULL && test->value!=NULL && strncasecmp(test->value,"true",4)==0){
    161162                  test=getMapFromMaps(inputs,paramKey.c_str(),"value");
     
    190191                    dynamic_cast<OutputImageParameter *> (param.GetPointer())->SetPixelType(outPixType);
    191192                  }else{
    192                     if(test->value!=NULL)
    193                       m_Application->SetParameterString(paramKey, test->value);
     193                    map* tmpVal=getMapFromMaps(inputs,paramKey.c_str(),"mimeType");
     194                    char file_ext[32];
     195                    getFileExtension(tmpVal != NULL ? tmpVal->value : NULL, file_ext, 32);
     196                    if(type == ParameterType_InputImageList){
     197                      values.push_back(test->value);
     198                      map* tmpLength=getMapFromMaps(inputs,paramKey.c_str(),"length");
     199                      if(tmpLength!=NULL){
     200                        int len=atoi(tmpLength->value);
     201                        for(int k=1;k<len;k++){
     202                          char *val=(char*)malloc((strlen(tmpPath->value)+strlen(s->name)+strlen(tmpSid->value)+strlen(file_ext)+13)*sizeof(char));
     203                          sprintf(val,"%s/Input_%s_%s_%d.%s",tmpPath->value,s->name,tmpSid->value,k,file_ext);
     204                          FILE* of=fopen(val,"wb");
     205                          int length=0;
     206                          map* tmpSize=getMap(test,"size");
     207                          if(tmpSize!=NULL){
     208                            length=atoi(tmpSize->value);
     209                          }
     210                          fwrite(test->value,sizeof(char),length,of);
     211                          fclose(of);
     212                          values.push_back(val);
     213                          free(val);
     214                        }
     215                      }
     216                      dynamic_cast<InputImageListParameter *> (param.GetPointer())->SetListFromFileName(values);
     217                    }
     218                    else
     219                      if(type == ParameterType_InputVectorData || type == ParameterType_InputImage
     220                           || type == ParameterType_ComplexInputImage || type == ParameterType_InputVectorData
     221                           || type == ParameterType_InputFilename){
     222                        map* tmpPath=getMapFromMaps(m,"main","tmpPath");
     223                        map* tmpSid=getMapFromMaps(m,"lenv","sid");
     224                        char tmp[1024];
     225                        char* ext="json";
     226                        if(tmpVal!=NULL){
     227                          char *val=(char*)malloc((strlen(tmpPath->value)+strlen(s->name)+strlen(tmpSid->value)+strlen(file_ext)+10)*sizeof(char));
     228                          sprintf(val,"%s/Input_%s_%s.%s",tmpPath->value,s->name,tmpSid->value,file_ext);
     229                          FILE* of=fopen(val,"wb");
     230                          int length=0;
     231                          map* tmpSize=getMap(test,"size");
     232                          if(tmpSize!=NULL){
     233                            length=atoi(tmpSize->value);
     234                          }
     235                          fwrite(test->value,sizeof(char),length,of);
     236                          fclose(of);
     237
     238                          if(strncasecmp(tmpVal->value,"application/zip",14)==0){
     239
     240                            char tmpName[1024];
     241                            sprintf(tmpName,"/vsizip/%s",val);
     242                            char **files=VSIReadDir(tmpName);
     243                            int nFiles = CSLCount( files );
     244                            char tmpSSName[1024];
     245                            sprintf(tmpSSName,"%s/Input_%s_%s",tmpPath->value,s->name,tmpSid->value);
     246                            mkdir(tmpSSName,0777);
     247                           
     248                            char tmpSName[1024];
     249                            for(int kk=0;kk<nFiles;kk++){
     250                              sprintf(tmpSName,"%s/%s",tmpName,files[kk]);
     251                              VSILFILE* fmain=VSIFOpenL(tmpSName, "rb");
     252                              if(fmain!=NULL){
     253                                VSIFSeekL(fmain,0,SEEK_END);
     254                                long count=VSIFTellL(fmain);
     255                                VSIRewindL(fmain);
     256                               
     257                                char *content=(char*) malloc((count+1)*sizeof(char)); 
     258                                VSIFReadL(content,1,count*sizeof(char),fmain);
     259                               
     260                                char tmpSSSName[1024];
     261                                sprintf(tmpSSSName,"%s/%s",tmpSSName,files[kk]);
     262                               
     263                                FILE* fx=fopen(tmpSSSName, "wb");
     264                                fwrite(content,1,count,fx);
     265                                fclose(fx);
     266                                VSIFCloseL(fmain);
     267                                free(content);
     268                                std::string test1(tmpSSSName);
     269                                if(test1.find(".shp")!=std::string::npos){
     270                                  setMapInMaps(inputs,paramKey.c_str(),"cache_file",tmpSSSName);
     271                                  test=getMapFromMaps(inputs,paramKey.c_str(),"cache_file");
     272                                }
     273                              }
     274                            }
     275                            m_Application->SetParameterString(paramKey, test->value);
     276                          }else{
     277                            m_Application->SetParameterString(paramKey, val);
     278                          }
     279                          free(val);
     280                        }
     281                      }
     282                      else
     283                        if(test->value!=NULL)
     284                          m_Application->SetParameterString(paramKey, test->value);
    194285                  }
    195286
     
    316407                       || type == ParameterType_InputFilename){
    317408                      m_Application->SetParameterString(paramKey, test->value);
    318                   }               
     409                  }
    319410              }
    320411            }
  • trunk/zoo-project/zoo-kernel/service_internal_otb.h

    r580 r618  
    3434#include "otbZooWatcher.h"
    3535#include "service_internal.h"
     36#include "mimetypes.h"
    3637#include "service.h"
    3738#include "cgic.h"
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