Ignore:
Timestamp:
Feb 1, 2018, 11:27:28 AM (6 years ago)
Author:
djay
Message:

Add the capability to publish heatmap or any templated mapfile using the epecific msInclude and msLayer keys for an output. For MapServer? published output, define 4096 as the default maxsize and use pixel width or height for raster files. use the correct MapServer? imagemode depending on GDALGetRasterDataType (MS_IMAGEMODE_BYTE for GDT_Byte, MS_IMAGEMODE_INT16 for GDT_Int16 and MS_IMAGEMODE_FLOAT32 for GDT_Float32). Create a text file (.maps) listing every mapfiles created for a MapServer? published output (or inputs) using saveMapNames function. Fixes in ulinet, use uuid for naming temporary files. Add dialect input to the ogr2ogr service. Use the .maps file for removing a file from the DeleteData? service

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/prototype-v0/zoo-project/zoo-services/utils/hpc/service2.c

    r854 r862  
    22 * Author : Gérald FENOY
    33 *
    4  * Copyright 2008-2009 GeoLabs SARL. All rights reserved.
    5  *
     4 * Copyright 2017 GeoLabs SARL. All rights reserved.
     5 *
     6 * This work was supported by public funds received in the framework of GEOSUD,
     7 * a project (ANR-10-EQPX-20) of the program "Investissements d'Avenir" managed
     8 * by the French National Research Agency
     9 *
    610 * This work was supported by public funds received in the framework of GEOSUD,
    711 * a project (ANR-10-EQPX-20) of the program "Investissements d'Avenir" managed
     
    4246
    4347#include <dirent.h>
     48#include <string.h>
     49#include <cerrno>
     50
    4451extern "C" {
     52
     53  /**
     54   * Retrieve the error message which occured when trying to remove a file
     55   * (return values can be EACCES, EBUSY, EFAULT, EIO, EISDIR, ELOOP,
     56   * ENAMETOOLONG, ENOENT, ENOMEM, ENOTDIR, EPERM, EROFS, UNKNOWN).
     57   *
     58   * @param errn
     59   * @result a string corresponding to the error number
     60   */
     61  char* fetchErrno(int errn){
     62   switch(errn){
     63    case EACCES:
     64        return "EACCES";
     65    case EBUSY:
     66        return "EBUSY";
     67    case EFAULT:
     68        return "EFAULT";
     69    case EIO:
     70        return "EIO";
     71    case EISDIR:
     72        return "EISDIR";
     73    case ELOOP:
     74        return "ELOOP";
     75    case ENAMETOOLONG:
     76        return "ENAMETOOLONG";
     77    case ENOENT:
     78        return "ENOENT";
     79    case ENOMEM:
     80        return "ENOMEM";
     81    case ENOTDIR:
     82        return "ENOTDIR";
     83    case EPERM:
     84        return "EPERM";
     85    case EROFS:
     86        return "EROFS";
     87    default:
     88        return "UNKNOWN";
     89   }
     90  }
    4591
    4692  /**
     
    78124   */
    79125  int tryDeleteDataFile(const char* storage,const char* filename){
    80     char* fullpath=(char*)malloc((strlen(storage)+strlen(filename)+2)*sizeof(char));
    81     sprintf(fullpath,"%s/%s",storage,filename);
     126    char* fullpath=NULL;
     127    if(filename!=NULL){
     128      fullpath=(char*)malloc((strlen(storage)+strlen(filename)+2)*sizeof(char));
     129      sprintf(fullpath,"%s/%s",storage,filename);
     130    }
     131    else
     132      fullpath=zStrdup(storage);
    82133    if(unlink(fullpath)==0){
    83134      // TODO store the filename_full in the deletedfiles
    84       fprintf(stderr,"#### DeleteData #### %s %d %s has been successfully deleted\n",__FILE__,__LINE__,filename);
     135      fprintf(stderr,"#### DeleteData #### %s %d %s has been successfully deleted\n",__FILE__,__LINE__,(strlen(filename)>0?filename:fullpath));
    85136    }else{
    86       fprintf(stderr,"#### DeleteData #### unable to delete %s \n",fullpath);
     137      fprintf(stderr,"#### DeleteData #### unable to delete %s %s \n",fullpath,fetchErrno(errno));
    87138    }
    88139    free(fullpath);
     
    138189        }
    139190        if(fcontent!=NULL && strcasecmp(fcontent,"SHARED")!=0){
    140           // Delete associated zcm and zcp
     191          // Delete associated zcm, zcp and maps files
    141192          tryDeleteCacheFile(cacheDir->value,filename->value,"zca");
    142193          tryDeleteCacheFile(cacheDir->value,filename->value,"zcm");
    143194          tryDeleteCacheFile(cacheDir->value,filename->value,"zcp");
    144           // Delete ZOO_DATA_<input>_<sid>.data and <input>_<sid>.map
     195          tryDeleteCacheFile(tmpPath->value,filename->value,"maps");
     196          // Delete <input>_<sid>.map
    145197          char* datafile=(char*)malloc((strlen(jobid->value)+strlen(ioname->value)+19)*sizeof(char));
    146           sprintf(datafile,"ZOO_DATA_%s_%s.data",ioname->value,jobid->value);
    147           tryDeleteDataFile(dataPath->value,datafile);
    148           free(datafile);
    149           datafile=(char*)malloc((strlen(jobid->value)+strlen(ioname->value)+19)*sizeof(char));
    150198          sprintf(datafile,"%s_%s.map",ioname->value,jobid->value);
    151199          tryDeleteDataFile(dataPath->value,datafile);
     
    160208        char tmp1[8];
    161209        snprintf(tmp1,7,"%s",filename->value);
    162         if(strcasecmp(tmp1,"output")==0){
    163           tryDeleteDataFile(tmpPath->value,filename->value);
     210        if(strcasecmp(tmp1,"output")==0 || strcasecmp(tmp1,"input_")==0){
     211          trydeletedatafile(tmppath->value,filename->value);
     212          char *tmp=zStrdup(filename->value);
     213          tmp[strlen(tmp)-strlen(strrchr(tmp,'.'))]=0;
     214          char *mapsfile=(char*)malloc((strlen(tmp)+6)*sizeof(char));
     215          sprintf(mapsfile,"%s.maps",tmp);
     216          char* mapPath=(char*)malloc((strlen(tmpPath->value)+strlen(mapsfile)+2)*sizeof(char));
     217          sprintf(mapPath,"%s/%s",tmpPath->value,mapsfile);
     218          FILE* myMapsfile=fopen(mapPath,"r");
     219          if(myMapsfile!=NULL){
     220            char *buffer=(char*)malloc(1024*sizeof(char));
     221            while(fgets(buffer, 1024, myMapsfile) != NULL){
     222              buffer[strlen(buffer)-1]=0;
     223              tryDeleteDataFile(buffer,NULL);
     224            }
     225            free(buffer);
     226            fclose(myMapsfile);
     227          }
     228          tryDeleteDataFile(mapPath,NULL);
     229          free(mapPath);
     230          free(mapsfile);
    164231          // Delete ZOO_DATA_<output>_<sid>.data and <output>_<sid>.map
    165232          char* datafile=(char*)malloc((strlen(jobid->value)+strlen(ioname->value)+19)*sizeof(char));
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