Ignore:
Timestamp:
Aug 7, 2017, 2:56:24 PM (7 years ago)
Author:
djay
Message:

Update the source code for HPC support. Automatically adding nested outputs for the HPC support (should this be available for every support?). Add capability to store the metadata in the Collection DataBase?. Addition of the zcfg2sql to import any existing ZCFG file into the Collection DB. Add the support to invoke a callback (for history purpose) in case a [callback] section contains at least one parameter defined (url). Add support to convert maps and map to JSON (for callback use only by now). Fix some memory leaks (some are still there).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/prototype-v0/zoo-project/zoo-kernel/service_internal_ms.c

    r822 r839  
    131131 */
    132132void setReferenceUrl(maps* m,maps* tmpI){
    133   fprintf(stderr,"%s %D \n",__FILE__,__LINE__);
    134   fflush(stderr);
    135   dumpMaps(tmpI);
    136   fprintf(stderr,"%s %D \n",__FILE__,__LINE__);
    137   fflush(stderr);
    138133  outputMapfile(m,tmpI);
    139   fprintf(stderr,"%s %D \n",__FILE__,__LINE__);
    140   fflush(stderr);
    141   dumpMaps(tmpI);
    142   fprintf(stderr,"%s %D \n",__FILE__,__LINE__);
    143   fflush(stderr);
    144134  map *msUrl=getMapFromMaps(m,"main","mapserverAddress");
    145135  if(msUrl==NULL){
     
    169159  if(strncasecmp(rformat->value,"text/xml",8)==0)
    170160    proto=1;
    171   if(strncasecmp(rformat->value,"image/tiff",10)==0)
     161  if(strncasecmp(rformat->value,"image/tiff",10)==0 ||
     162     strncasecmp(rformat->value,"image/geotiff",10)==0)
    172163    proto=2;
    173164  if(protoMap!=NULL){
     
    478469    fprintf(stderr,"Unable to access the DataSource as ZIP File\n");
    479470    setMapInMaps(conf,"lenv","message","Unable to open datasource in read only mode");
    480     OGR_DS_Destroy(poDS1);
     471    //OGR_DS_Destroy(poDS1);
    481472  }else{
    482473#ifdef DEBUGMS
     
    549540#endif
    550541    setMapInMaps(conf,"lenv","message","Unable to open datasource in read only mode");
    551     OGR_DS_Destroy(poDS);
    552     OGRCleanupAll();
     542    //OGR_DS_Destroy(poDS);
     543    //OGRCleanupAll();
    553544#ifdef DEBUGMS
    554545    fprintf(stderr,"Unable to access the DataSource, exit! \n");
     
    652643    if (OGR_L_GetExtent(poLayer,&oExt, TRUE) == OGRERR_NONE){
    653644      setMsExtent(output,m,myLayer,oExt.MinX, oExt.MinY, oExt.MaxX, oExt.MaxY);
     645      char extent[1024];
     646      memset(&extent,0,1024);
     647      sprintf(extent,"%d,%d,%d,%d",oExt.MinX, oExt.MinY, oExt.MaxX, oExt.MaxY);
     648      addToMap(output->content,"boundingbox",extent);
    654649    }
    655650 
     
    724719  }
    725720
    726   OGR_DS_Destroy(poDS);
    727   OGRCleanupAll();
     721  //OGR_DS_Destroy(poDS);
     722  //OGRCleanupAll();
    728723
    729724  return 1;
     
    819814  }
    820815
    821 
    822816  /**
    823817   * Set extent
     
    836830        + adfGeoTransform[4] * GDALGetRasterXSize(hDataset);
    837831
    838        setMsExtent(output,m,myLayer,minX,minY,maxX,maxY);
    839 
     832      setMsExtent(output,m,myLayer,minX,minY,maxX,maxY);
     833      char extent[1024];
     834      memset(&extent,0,1024);
     835      sprintf(extent,"%d,%d,%d,%d",minX,minY,maxX,maxY);
     836      addToMap(output->content,"boundingbox",extent);
    840837    }
    841838  }
     
    846843   */
    847844  char nBands[3];
     845  memset(&nBands,0,3);
    848846  int nBandsI=GDALGetRasterCount( hDataset );
    849   sprintf(nBands,"%d",GDALGetRasterCount( hDataset ));
    850   msInsertHashTable(&(myLayer->metadata), "ows_bandcount", nBands);
     847  if(nBandsI<100){
     848    sprintf(nBands,"%d",GDALGetRasterCount( hDataset ));
     849    msInsertHashTable(&(myLayer->metadata), "ows_bandcount", nBands);
     850  }
    851851  if(nBandsI>=3)
    852852    msLayerAddProcessing(myLayer,"BANDS=1,2,3");
     
    860860   */
    861861  char lBands[7];
     862  memset(&nBands,0,7);
    862863  char *nameBands=NULL;
    863864  for( iBand = 0; iBand < nBandsI; iBand++ ){
    864     sprintf(lBands,"Band%d",iBand+1);
     865    sprintf(lBands,"Band%d",iBand+1);   
    865866    if(nameBands==NULL){
    866867      nameBands=(char*)malloc((strlen(lBands)+1)*sizeof(char));
     
    869870      if(iBand<4){
    870871        char *tmpS=zStrdup(nameBands);
    871         nameBands=(char*)realloc(nameBands,(strlen(nameBands)+strlen(lBands)+1)*sizeof(char));
     872        nameBands=(char*)realloc(nameBands,(strlen(tmpS)+strlen(lBands)+2)*sizeof(char));
    872873        sprintf(nameBands,"%s %s",tmpS,lBands);
    873874        free(tmpS);
     
    875876    }
    876877  }
    877   msInsertHashTable(&(myLayer->metadata), "ows_bandnames", nameBands);
    878  
     878  if(nameBands!=NULL){
     879    msInsertHashTable(&(myLayer->metadata), "ows_bandnames", nameBands);
     880    free(nameBands);
     881  }
     882
    879883  /**
    880884   * Loops over metadata information to setup specific information
     
    894898      char tmpMm[100];
    895899      sprintf(tmpMm,"%.3f %.3f",adfCMinMax[0],adfCMinMax[1]);
    896       char tmpI[21];
     900      char tmpI[31];     
    897901      sprintf(tmpI,"%s_interval",tmpN);
    898902      msInsertHashTable(&(myLayer->metadata), tmpI, tmpMm);
     
    977981    }
    978982    if( strlen(GDALGetRasterUnitType(hBand)) > 0 ){
    979       char tmpU[21];
     983      char tmpU[31];
    980984      sprintf(tmpU,"%s_band_uom",tmpN);
    981985      msInsertHashTable(&(myLayer->metadata), tmpU, GDALGetRasterUnitType(hBand));
     
    988992  GDALClose( hDataset );
    989993  GDALDestroyDriverManager();
     994
    990995  CPLCleanupTLS();
    991996  return 1;
     
    9991004 */
    10001005void outputMapfile(maps* conf,maps* outputs){
    1001   fprintf(stderr,"%s %D \n",__FILE__,__LINE__);
    1002   fflush(stderr);
    1003   dumpMaps(outputs);
    1004   fprintf(stderr,"%s %D \n",__FILE__,__LINE__);
    1005   fflush(stderr);
    10061006  /**
    10071007   * First store the value on disk
     
    10131013      ext="json";
    10141014
    1015   fprintf(stderr,"%s %D \n",__FILE__,__LINE__);
    1016   fflush(stderr);
    10171015  map* tmpMap=getMapFromMaps(conf,"main","dataPath");
    10181016  map* sidMap=getMapFromMaps(conf,"lenv","usid");
    10191017  char *pszDataSource=(char*)malloc((strlen(tmpMap->value)+strlen(sidMap->value)+strlen(outputs->name)+17)*sizeof(char));
    1020   sprintf(pszDataSource,"%s/ZOO_DATA_%s_%s.%s",tmpMap->value,outputs->name,sidMap->value,ext); 
     1018  sprintf(pszDataSource,"%s/ZOO_DATA_%s_%s.%s",tmpMap->value,outputs->name,sidMap->value,ext);
    10211019  int f=zOpen(pszDataSource,O_WRONLY|O_CREAT,S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH);
    10221020  map *gfile=getMap(outputs->content,"generated_file");
     
    10261024  map* sizeMap=getMap(outputs->content,"size");
    10271025  map* vData=getMap(outputs->content,"value");
    1028   fprintf(stderr,"%s %D \n",__FILE__,__LINE__);
    1029   fflush(stderr);
    10301026  if(sizeMap!=NULL){
    10311027    zWrite(f,vData->value,atoi(sizeMap->value)*sizeof(char));
     
    10341030    zWrite(f,vData->value,(strlen(vData->value)+1)*sizeof(char));
    10351031  }
    1036   fprintf(stderr,"%s %D \n",__FILE__,__LINE__);
    1037   fflush(stderr);
    10381032  close(f);
    1039   fprintf(stderr,"%s %D \n",__FILE__,__LINE__);
    1040   fflush(stderr);
    10411033  addToMap(outputs->content,"storage",pszDataSource);
    10421034  free(pszDataSource);
    1043   fprintf(stderr,"%s %D \n",__FILE__,__LINE__);
    1044   fflush(stderr);
    10451035
    10461036  /*
     
    10491039  mapObj *myMap=msNewMapObj();
    10501040  free(myMap->name);
    1051   fprintf(stderr,"%s %D \n",__FILE__,__LINE__);
    1052   fflush(stderr);
    10531041  myMap->name=zStrdup("ZOO-Project_WXS_Server");
    1054   fprintf(stderr,"%s %D \n",__FILE__,__LINE__);
    1055   fflush(stderr);
    10561042  msMapSetSize(myMap,2048,2048);
    1057   fprintf(stderr,"%s %D \n",__FILE__,__LINE__);
    1058   fflush(stderr);
    10591043  msMapSetExtent(myMap,-1,-1,1,1);
    1060   fprintf(stderr,"%s %D \n",__FILE__,__LINE__);
    1061   fflush(stderr);
    10621044 
    10631045  /*
     
    10681050  tmp1=getMapFromMaps(conf,"main","tmpUrl");
    10691051  myMap->web.imageurl=zStrdup(tmp1->value);
    1070   fprintf(stderr,"%s %D \n",__FILE__,__LINE__);
    1071   fflush(stderr);
    10721052 
    10731053  /*
     
    10801060  msAppendOutputFormat(myMap,msCloneOutputFormat(o1));
    10811061  msFreeOutputFormat(o1);
    1082   fprintf(stderr,"%s %D \n",__FILE__,__LINE__);
    1083   fflush(stderr);
    10841062
    10851063#ifdef USE_KML
     
    10941072  }
    10951073#endif
    1096   fprintf(stderr,"%s %D \n",__FILE__,__LINE__);
    1097   fflush(stderr);
    10981074
    10991075  outputFormatObj *o3=msCreateDefaultOutputFormat(NULL,"GDAL/GTiff","tiff");
     
    11061082    msFreeOutputFormat(o3);
    11071083  }
    1108   fprintf(stderr,"%s %D \n",__FILE__,__LINE__);
    1109   fflush(stderr);
    11101084
    11111085  outputFormatObj *o4=msCreateDefaultOutputFormat(NULL,"GDAL/AAIGRID","grd");
     
    11181092    msFreeOutputFormat(o4);
    11191093  }
    1120   fprintf(stderr,"%s %D \n",__FILE__,__LINE__);
    1121   fflush(stderr);
    11221094
    11231095#ifdef USE_CAIRO
     
    11331105  }
    11341106#endif
    1135   fprintf(stderr,"%s %D \n",__FILE__,__LINE__);
    1136   fflush(stderr);
    11371107
    11381108  /*
     
    11411111  msLoadProjectionStringEPSG(&myMap->projection,"EPSG:4326");
    11421112  myMap->transparent=1;
    1143   fprintf(stderr,"%s %D \n",__FILE__,__LINE__);
    1144   fflush(stderr);
    11451113
    11461114  /**
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