Changeset 961


Ignore:
Timestamp:
Sep 8, 2020, 4:51:09 PM (4 years ago)
Author:
djay
Message:

Make sure not to try accessing mimetype and provenance in case a local file is used. Fix issue with addMapsToMaps. Produce value string only when memory=load for Python support. Make gdal/profile service usable in case memory=protect.

Location:
trunk/zoo-project
Files:
7 edited

Legend:

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

    r960 r961  
    11Version 1.8.0-dev
     2  * Produce value string only when memory=load for Python support.
     3  * Make local files uris usable when cache is used
     4  * Make GDAL/prilfe service usable in case memory=protect
    25  * Add Dockerfile and docker-compose environment with pgbouncer, see #177
    36  * Add documentation on how to use asyncrhonous execution using the Javascript
  • trunk/zoo-project/zoo-kernel/caching.c

    r955 r961  
    403403  if(strncasecmp(request,"file://",7)==0){
    404404    char* tmpStr=zStrdup(request+7);
    405     fprintf(stderr,"**** %s %d %s \n",__FILE__,__LINE__,tmpStr);
     405    setMapInMaps(conf,"lenv",tmpStr,"local");
    406406    return tmpStr;
    407407  }
     
    709709      unlockFile(*m,lck);
    710710    }
    711     cached[strlen(cached)-1]='m';
    712     s=zStat(cached, &f_status);
    713     if(s==0){
    714       zooLock* lck=lockFile(*m,cached,'r');
    715       if(lck==NULL)
    716         return -1;
    717       mimeType=(char*)malloc(sizeof(char)*(f_status.st_size+1));
    718       FILE* f=fopen(cached,"rb");
    719       fread(mimeType,f_status.st_size,1,f);
    720       mimeType[f_status.st_size]=0;
    721       fclose(f);
    722       unlockFile(*m,lck);
    723     }
    724     cached[strlen(cached)-1]='p';
    725     s=zStat(cached, &f_status);
    726     if(s==0){
    727       zooLock* lck=lockFile(*m,cached,'r');
    728       if(lck==NULL)
    729         return -1;
    730       origin=(char*)malloc(sizeof(char)*(f_status.st_size+1));
    731       FILE* f=fopen(cached,"rb");
    732       fread(origin,f_status.st_size,1,f);
    733       mimeType[f_status.st_size]=0;
    734       fclose(f);
    735       unlockFile(*m,lck);
    736     }
     711    map* isLocalFile=getMapFromMaps(*m,"lenv",cached);
     712    if(isLocalFile==NULL){
     713      cached[strlen(cached)-1]='m';
     714      s=zStat(cached, &f_status);
     715      if(s==0){
     716        zooLock* lck=lockFile(*m,cached,'r');
     717        if(lck==NULL)
     718          return -1;
     719        mimeType=(char*)malloc(sizeof(char)*(f_status.st_size+1));
     720        FILE* f=fopen(cached,"rb");
     721        fread(mimeType,f_status.st_size,1,f);
     722        mimeType[f_status.st_size]=0;
     723        fclose(f);
     724        unlockFile(*m,lck);
     725      }
     726      cached[strlen(cached)-1]='p';
     727      s=zStat(cached, &f_status);
     728      if(s==0){
     729        zooLock* lck=lockFile(*m,cached,'r');
     730        if(lck==NULL)
     731          return -1;
     732        origin=(char*)malloc(sizeof(char)*(f_status.st_size+1));
     733        FILE* f=fopen(cached,"rb");
     734        fread(origin,f_status.st_size,1,f);
     735        mimeType[f_status.st_size]=0;
     736        fclose(f);
     737        unlockFile(*m,lck);
     738      }
     739    }   
    737740  }else{   
    738741    addRequestToQueue(m,hInternet,url,true);
  • trunk/zoo-project/zoo-kernel/main_conf_read.y

    r917 r961  
    162162    freeMap(&current_content);
    163163    free(current_content);
     164  }else{
     165    current_maps->next=NULL;
    164166  }
    165167  if(curr_key!=NULL){
  • trunk/zoo-project/zoo-kernel/server_internal.c

    r921 r961  
    373373    return ;
    374374  }
    375   fseek(file, 0, SEEK_END);
    376375  zStatStruct f_status;
    377376  int s=zStat(filename, &f_status);
    378377  sprintf(rsize,"%lld",f_status.st_size);
    379   rewind(file);
    380378  if(getMap(content,"storage")==NULL){
    381379    map* memUse=getMapFromMaps(m,"main","memory");
     
    390388      if(tmpMap1->value==NULL){
    391389        setMapInMaps(m,"lenv","message","Unable to allocate the memory required to read the produced file.");
     390        return;
    392391      }
    393392      fread(&tmpMap1->value,1,f_status.st_size,file);
     
    395394    }
    396395  }
    397   fclose(file); 
    398   addToMap(content,"size",rsize);
     396  fclose(file);
     397  if(content!=NULL)
     398    addToMap(content,"size",rsize);
    399399}
    400400
  • trunk/zoo-project/zoo-kernel/service.c

    r957 r961  
    328328    fprintf(stderr,"freeMap\n");
    329329#endif
    330     free(_cursor->name);
    331     free(_cursor->value);
     330    if(_cursor->name!=NULL)
     331      free(_cursor->name);
     332    if(_cursor->value!=NULL)
     333      free(_cursor->value);
    332334    if(_cursor->next!=NULL){
    333335      freeMap(&_cursor->next);
    334       free(_cursor->next);
     336      if(_cursor->next!=NULL)
     337        free(_cursor->next);
    335338    }
    336339  }
     
    825828    else{
    826829      maps* tmp1=getMaps(*mo,tmp->name);
    827       while(_cursor->next!=NULL)
    828         _cursor=_cursor->next;
    829830      if(tmp1==NULL){
     831        while(_cursor->next!=NULL)
     832          _cursor=_cursor->next;
    830833        _cursor->next=dupMaps(&tmp);
    831834        if(tmp->child!=NULL)
  • trunk/zoo-project/zoo-kernel/service_internal_python.c

    r943 r961  
    468468  while(tmp!=NULL){
    469469    PyObject* name=PyString_FromString(tmp->name);
    470     if(strcasecmp(tmp->name,"value")==0) {
     470    if(strcasecmp(tmp->name,"value")==0 && strlen(tmp->value)>0) {
    471471      if(isArray!=NULL){
    472472        map* len=getMap(tmp,"length");
  • trunk/zoo-project/zoo-services/gdal/profile/service.c

    r945 r961  
    3535#include "cpl_conv.h"
    3636#include "ogr_api.h"
     37#if GDAL_VERSION_MAJOR >= 2
     38#include <gdal_priv.h>
     39#endif
    3740
    3841#ifdef ZOO_SERVICE
     
    8790          GDALComputeRasterMinMax( hBand, TRUE, adfMinMax );
    8891#ifdef ZOO_SERVICE
     92        OGRGeometryH geometry=NULL;
     93        // Verify if there is a cache file for this input, use it if available
     94        tmp1=getMapFromMaps(inputs,"Geometry","cache_file");
     95        if(tmp1!=NULL){
     96#if GDAL_VERSION_MAJOR >= 2
     97          char* pszDataSource=strdup(tmp1->value);
     98          GDALDatasetH poDS
     99            = GDALOpenEx( pszDataSource,
     100                          GDAL_OF_READONLY | GDAL_OF_VECTOR,
     101                          NULL, NULL, NULL );
     102#endif
     103          for( int iLayer = 0; iLayer < OGR_DS_GetLayerCount(poDS) ;
     104               iLayer++ )
     105            {
     106              OGRLayerH        poLayer = OGR_DS_GetLayer(poDS,iLayer);
     107
     108              if( poLayer == NULL )
     109                {
     110                  fprintf( stderr, "FAILURE: Couldn't fetch advertised layer %d!\n",
     111                           iLayer );
     112                  char tmp[1024];
     113                  sprintf(tmp,"Couldn't fetch advertised layer %d!",iLayer);
     114                  setMapInMaps(conf,"lenv","message",tmp);
     115                  return SERVICE_FAILED;
     116                }
     117              OGRFeatureH  poFeature;
     118              int         nFeaturesInTransaction = 0;
     119              int fCount=0;
     120              OGR_L_ResetReading(poLayer);
     121              while( TRUE )
     122                {
     123                  poFeature = OGR_L_GetNextFeature(poLayer);
     124                  if( poFeature == NULL ){
     125                    break;
     126                  }
     127                  geometry=OGR_G_Clone(OGR_F_GetGeometryRef(poFeature));
     128                  OGR_F_Destroy( poFeature );
     129                }
     130             
     131            }
     132        }
     133        else{
    89134          tmp1=getMapFromMaps(inputs,"Geometry","value");
    90           OGRGeometryH geometry=OGR_G_CreateGeometryFromJson(tmp1->value);
     135          geometry=OGR_G_CreateGeometryFromJson(tmp1->value);
     136        }
    91137#else
    92138          OGRGeometryH geometry=OGR_G_CreateGeometryFromJson(argv[2]);
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