Ignore:
Timestamp:
Nov 21, 2017, 10:24:14 AM (6 years ago)
Author:
djay
Message:

HPC support update. Add inputs for create options in Gdal_Dem.

File:
1 edited

Legend:

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

    r851 r854  
    138138    exit(-1);
    139139  }
     140  int finalProto=-1;
    140141  map *msOgcVersion=getMapFromMaps(m,"main","msOgcVersion");
    141142  map *dataPath=getMapFromMaps(m,"main","dataPath");
     
    147148  map* protoMap=getMap(tmpI->content,"msOgc");
    148149  map* versionMap=getMap(tmpI->content,"msOgcVersion");
    149   char options[3][5][25]={
     150  char options[4][5][25]={
    150151    {"WMS","1.3.0","GetMap","layers=%s","wms_extent"},
    151152    {"WFS","1.1.0","GetFeature","typename=%s","wcs_extent"},
    152     //{"WCS","1.1.0","GetCoverage","coverage=%s","wcs_extent"}
    153     {"WCS","2.0.0","GetCoverage","coverageid=%s","wcs_extent"}
     153    {"WCS","2.0.0","GetCoverage","coverageid=%s","wcs_extent"},
     154    {"WCS","1.1.0","GetCoverage","coverage=%s","wcs_extent"}
    154155  };
     156  map* datatype=getMap(tmpI->content,"geodatatype");
     157  if(datatype==NULL || strncmp(datatype->value,"other",5)==0){
     158    setMapInMaps(m,"lenv","mapError","true");
     159    setMapInMaps(m,"lenv","locator",tmpI->name);
     160    setMapInMaps(m,"lenv","message",_("The ZOO-Kernel was able to retrieve the data but could not read it as geographic data."));
     161    if(getMapFromMaps(m,"lenv","state")==NULL)
     162      errorException (m, _("Unable to find any geographic data"), "WrongInputData", tmpI->name);
     163    return;
     164  }
    155165  int proto=0;
    156166  if(rformat==NULL){
     
    194204
    195205  char* webService_url=(char*)malloc((strlen(msUrl->value)+strlen(format->value)+strlen(tmpI->name)+strlen(width->value)+strlen(height->value)+strlen(extent->value)+256)*sizeof(char));
    196   map* datatype=getMap(tmpI->content,"geodatatype");
    197206 
    198207  if(proto>0){
     208    if(proto==2)
     209      finalProto=1;
    199210    sprintf(webService_url,
    200211            "%s?map=%s/%s_%s.map&request=%s&service=%s&version=%s&%s&format=%s&bbox=%s&crs=%s",
     
    248259  }
    249260  addToMap(tmpI->content,"Reference",webService_url);
    250 
     261  memset(layers,0,128);
     262  sprintf(layers,options[proto][3],tmpI->name);
    251263  protoVersion=options[proto][1];
    252264  extent=getMap(tmpI->content,options[proto][4]);
    253265  memset(webService_url,0,strlen(webService_url));
    254266  if(proto>0){
     267    if(proto==2)
     268      finalProto=1;
    255269    sprintf(webService_url,
    256270            "%s?map=%s/%s_%s.map&request=%s&service=%s&version=%s&%s&format=%s&bbox=%s&crs=%s",
     
    292306    addToMap(tmpI->content,"ref_wms_link",webService_url);
    293307  }
     308  if(finalProto>0){
     309    proto=3;
     310    memset(layers,0,128);
     311    sprintf(layers,options[proto][3],tmpI->name);
     312    protoVersion=options[proto][1];
     313    extent=getMap(tmpI->content,options[proto][4]);
     314    memset(webService_url,0,strlen(webService_url));
     315    sprintf(webService_url,
     316            "%s?map=%s/%s_%s.map&request=%s&service=%s&version=%s&%s&format=%s&bbox=%s&crs=%s",
     317            msUrl->value,
     318            dataPath->value,
     319            tmpI->name,
     320            sid->value,
     321            options[proto][2],
     322            options[proto][0],
     323            protoVersion,
     324            layers,
     325            rformat->value,
     326            extent->value,
     327            crs->value
     328            );
     329    addToMap(tmpI->content,"ref_wcs_preview_link",webService_url);
     330  }
    294331  if(hasCRS==0){
    295332    freeMap(&crs);
     
    299336  free(rformat);
    300337  free(webService_url);
    301   dumpMaps(tmpI);
    302338}
    303339
     
    492528  /**
    493529   * Try to load the file as ZIP
    494    */
    495 
     530   *
    496531  OGRDataSourceH poDS1 = NULL;
    497532  OGRSFDriverH *poDriver1 = NULL;
     
    534569    fprintf(stderr,"Unable to access the DataSource as ZIP File\n");
    535570    setMapInMaps(conf,"lenv","message","Unable to open datasource in read only mode");
     571    fprintf(stderr,"Remove ZIP File!\n");
     572    unlink(odsName);
    536573    //OGR_DS_Destroy(poDS1);
    537574  }else{
     
    594631    }
    595632    OGR_DS_Destroy(poDS1);
    596   }
     633    }
    597634  free(sdsName);
    598   free(dsName);
     635  free(dsName);*/
    599636 
    600637  OGRDataSourceH poDS = NULL;
     
    649686    myLayer->status = MS_ON;
    650687    msConnectLayer(myLayer,MS_OGR,pszDataSource);
     688
     689    addIntToMap(output->content,"nb_features",OGR_L_GetFeatureCount(poLayer,1));
    651690
    652691    /**
     
    811850   */
    812851  GDALAllRegister();
    813   hDataset = GDALOpen( pszFilename, GA_ReadOnly );
     852  hDataset = GDALOpen( pszFilename, GA_Update );
    814853  if( hDataset == NULL ){
    815854#ifdef DEBUGMS
     
    866905  m->width=GDALGetRasterXSize( hDataset );
    867906  m->height=GDALGetRasterYSize( hDataset );
     907  addIntToMap(output->content,"nb_pixels",GDALGetRasterXSize( hDataset )*GDALGetRasterYSize( hDataset ));
    868908 
    869909  /**
     
    880920    setSrsInformations(output,m,myLayer,pszProjection);
    881921  }else{
    882     fprintf(stderr,"NO SRS FOUND ! %s\n",GDALGetProjectionRef( hDataset ));   
     922    fprintf(stderr,"NO SRS FOUND ! %s\n",GDALGetProjectionRef( hDataset ));
     923    CPLErr sp=GDALSetProjection( hDataset , "+init=epsg:4326" );
     924    if(sp!=CE_None){
     925      fprintf(stderr,"NO SRS FOUND ! %s\n",CPLGetLastErrorMsg());
     926    }
    883927  }
    884928
     
    905949      addToMap(output->content,"boundingbox",extent);
    906950    }
     951  }else{
     952    int scale=1;
     953    if(m->width>2048){
     954      addIntToMap(output->content,"width",2048);
     955      scale=2048/m->width;
     956    }else
     957      addIntToMap(output->content,"width",m->width);
     958    addIntToMap(output->content,"height",m->height*scale);
    907959  }
    908960
     
    919971  }
    920972  if(nBandsI>=3)
    921     msLayerAddProcessing(myLayer,"BANDS=1,2,3");
     973    if(nBandsI==4)
     974      msLayerAddProcessing(myLayer,"BANDS=1,2,3,4");
     975    else
     976      msLayerAddProcessing(myLayer,"BANDS=1,2,3");
    922977  else if(nBandsI>=2)
    923978    msLayerAddProcessing(myLayer,"BANDS=1,2");
    924979  else
    925980    msLayerAddProcessing(myLayer,"BANDS=1");
     981 
    926982
    927983  /**
     
    929985   */
    930986  char lBands[7];
    931   memset(&nBands,0,7);
    932987  char *nameBands=NULL;
    933988  for( iBand = 0; iBand < nBandsI; iBand++ ){
     989    memset(&lBands,0,7);
    934990    sprintf(lBands,"Band%d",iBand+1);   
    935991    if(nameBands==NULL){
     
    937993      sprintf(nameBands,"%s",lBands);
    938994    }else{
    939       if(iBand<4){
     995      /*if(iBand<4)*/{
    940996        char *tmpS=zStrdup(nameBands);
    941997        nameBands=(char*)realloc(nameBands,(strlen(tmpS)+strlen(lBands)+2)*sizeof(char));
     
    9541010   */
    9551011  for( iBand = 0; iBand < nBandsI; iBand++ ){
    956     //int         bGotNodata;//, bSuccess;
    957     double      adfCMinMax[2]/*, dfNoData*/;
    958     //int         nBlockXSize, nBlockYSize, nMaskFlags;
    959     //double      /*dfMean, dfStdDev*/;
     1012    double      pdfMin, pdfMax, pdfMean, pdfStdDev;
    9601013    hBand = GDALGetRasterBand( hDataset, iBand+1 );
    9611014
    9621015    CPLErrorReset();
    963     GDALComputeRasterMinMax( hBand, FALSE, adfCMinMax );
     1016    GDALComputeRasterStatistics( hBand, TRUE, &pdfMin, &pdfMax, &pdfMean, &pdfStdDev, NULL,NULL);
    9641017    char tmpN[21];
    9651018    sprintf(tmpN,"Band%d",iBand+1);
    9661019    if (CPLGetLastErrorType() == CE_None){
    967       char tmpMm[100];
    968       sprintf(tmpMm,"%.3f %.3f",adfCMinMax[0],adfCMinMax[1]);
     1020      char tmpMm[100],tmpMp[100];
     1021      sprintf(tmpMm,"%.3f %.3f",pdfMin,pdfMax);
     1022      sprintf(tmpMp,"SCALE_%d=%.3f,%.3f",iBand+1,pdfMean-(2*pdfStdDev),pdfMean+(2*pdfStdDev));
    9691023      char tmpI[31];     
    9701024      sprintf(tmpI,"%s_interval",tmpN);
    9711025      msInsertHashTable(&(myLayer->metadata), tmpI, tmpMm);
    972 
     1026      if(pdfMax>255)
     1027        msLayerAddProcessing(myLayer,tmpMp);
    9731028      map* test=getMap(output->content,"msClassify");
    9741029      if(test!=NULL && strncasecmp(test->value,"true",4)==0){
     
    9901045         
    9911046        if(nBandsI==1){
    992           double delta=adfCMinMax[1]-adfCMinMax[0];
     1047          double delta=pdfMax-pdfMin;
    9931048          double interval=delta/10;
    994           double cstep=adfCMinMax[0];
     1049          double cstep=pdfMin;
    9951050          for(i=0;i<10;i++){
    9961051            /**
     
    10361091         
    10371092          char tmpMm[100];
    1038           sprintf(tmpMm,"%.3f %.3f",adfCMinMax[0],adfCMinMax[1]);
     1093          sprintf(tmpMm,"%.3f %.3f",pdfMin,pdfMax);
    10391094         
    10401095        }
     
    10461101          myLayer->offsite.blue=0;
    10471102        }
    1048         msLayerAddProcessing(myLayer,"RESAMPLE=BILINEAR");
    10491103      }
    10501104    }
     
    10561110
    10571111  }
     1112  msLayerAddProcessing(myLayer,"RESAMPLE=BILINEAR");
    10581113
    10591114  m->layerorder[m->numlayers] = m->numlayers;
     
    10811136      ext="json";
    10821137
    1083   map* tmpMap=getMapFromMaps(conf,"main","dataPath");
    1084   map* sidMap=getMapFromMaps(conf,"lenv","usid");
    1085   char *pszDataSource=(char*)malloc((strlen(tmpMap->value)+strlen(sidMap->value)+strlen(outputs->name)+17)*sizeof(char));
    1086   sprintf(pszDataSource,"%s/ZOO_DATA_%s_%s.%s",tmpMap->value,outputs->name,sidMap->value,ext);
    1087   int f=zOpen(pszDataSource,O_WRONLY|O_CREAT,S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH);
    1088   map *gfile=getMap(outputs->content,"generated_file");
    1089   if(gfile!=NULL){
    1090     readGeneratedFile(conf,outputs->content,gfile->value);         
    1091   }
    1092   map* sizeMap=getMap(outputs->content,"size");
    1093   map* vData=getMap(outputs->content,"value");
    1094   if(sizeMap!=NULL){
    1095     zWrite(f,vData->value,atoi(sizeMap->value)*sizeof(char));
    1096   }
    1097   else{
    1098     zWrite(f,vData->value,(strlen(vData->value)+1)*sizeof(char));
    1099   }
    1100   close(f);
    1101   addToMap(outputs->content,"storage",pszDataSource);
    1102   free(pszDataSource);
     1138  map* storage=getMap(outputs->content,"storage");
     1139  if(storage==NULL){
     1140    map* tmpMap=getMapFromMaps(conf,"main","dataPath");
     1141    map* sidMap=getMapFromMaps(conf,"lenv","usid");
     1142    char *pszDataSource=(char*)malloc((strlen(tmpMap->value)+strlen(sidMap->value)+strlen(outputs->name)+17)*sizeof(char));
     1143    sprintf(pszDataSource,"%s/ZOO_DATA_%s_%s.%s",tmpMap->value,outputs->name,sidMap->value,ext);
     1144    int f=zOpen(pszDataSource,O_WRONLY|O_CREAT,S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH);
     1145    map *gfile=getMap(outputs->content,"generated_file");
     1146    if(gfile!=NULL){
     1147      readGeneratedFile(conf,outputs->content,gfile->value);       
     1148    }
     1149    map* sizeMap=getMap(outputs->content,"size");
     1150    map* vData=getMap(outputs->content,"value");
     1151    if(sizeMap!=NULL){
     1152      zWrite(f,vData->value,atoi(sizeMap->value)*sizeof(char));
     1153    }
     1154    else{
     1155      zWrite(f,vData->value,(strlen(vData->value)+1)*sizeof(char));
     1156    }
     1157    close(f);
     1158    addToMap(outputs->content,"storage",pszDataSource);
     1159    free(pszDataSource);
     1160  }
    11031161
    11041162  /*
     
    11741232#endif
    11751233
     1234  outputFormatObj *o6=msCreateDefaultOutputFormat(NULL,"GDAL/GTiff","geotiff");
     1235  if(!o6)
     1236    fprintf(stderr,"Unable to initialize GDAL driver !\n");
     1237  else{
     1238    o6->imagemode=MS_IMAGEMODE_BYTE;
     1239    o6->mimetype=strdup("image/geotiff");
     1240    o6->inmapfile=MS_TRUE;
     1241    msAppendOutputFormat(myMap,msCloneOutputFormat(o6));
     1242    msFreeOutputFormat(o6);
     1243  }
     1244
    11761245  /*
    11771246   * Set default projection to EPSG:4326
     
    12621331  msSaveMap(myMap,mapPath);
    12631332  free(mapPath);
     1333  //msFreeSymbolSet(&myMap->symbolset);
     1334  msFreeMap(myMap);
     1335  //msFree(myMap);
    12641336  msGDALCleanup();
    1265   msFreeMap(myMap);
    12661337}
    12671338
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