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-kernel/ulinet.c

    r860 r862  
    2929#define MAX_WAIT_MSECS 180*1000 /* Wait max. 180 seconds */
    3030#include "ulinet.h"
     31#include "server_internal.h"
    3132#include <assert.h>
    3233#include <ctype.h>
     
    6768  return realsize;
    6869}
     70
     71/**
     72 * Write the downloaded content to a _HINTERNET structure
     73 *
     74 * @param buffer the buffer to read
     75 * @param size size of each member
     76 * @param nmemb number of element to read
     77 * @param data the _HINTERNET structure to write in
     78 * @return the size red, -1 if buffer is NULL
     79 */
     80size_t write_data_into_file(void *buffer, size_t size, size_t nmemb, void *data)
     81{
     82   size_t realsize = size * nmemb;
     83   int writen=0;
     84   _HINTERNET *psInternet;
     85   if(buffer==NULL){
     86     buffer=NULL;
     87     return -1;
     88   }
     89   psInternet=(_HINTERNET *)data;
     90   writen+=fwrite(buffer, size, nmemb, psInternet->file);
     91   if(psInternet->nDataLen>0){
     92     psInternet->nDataAlloc+=psInternet->nDataLen+writen+1;
     93     psInternet->nDataLen += realsize;
     94   }else
     95     psInternet->nDataLen=realsize+1;
     96   buffer=NULL;
     97   return realsize;
     98}
     99
    69100
    70101/**
     
    363394        fclose(handle.file);
    364395        unlink(handle.filename);
     396        free(handle.filename);
    365397      }
    366398      else{
     
    411443 * @param dwFlags desired download mode (INTERNET_FLAG_NO_CACHE_WRITE for not using cache file)
    412444 * @param dwContext not used
     445 * @return the updated HINTERNET
    413446 */
    414447HINTERNET InternetOpenUrl(HINTERNET* hInternet,LPCTSTR lpszUrl,LPCTSTR lpszHeaders,size_t dwHeadersLength,size_t dwFlags,size_t dwContext){
     
    447480  curl_easy_setopt(hInternet->ihandle[hInternet->nb].handle, CURLOPT_VERBOSE, 1);
    448481#endif
    449 
    450482     
    451483  switch(dwFlags)
    452484    {
    453485    case INTERNET_FLAG_NO_CACHE_WRITE:
    454       hInternet->ihandle[hInternet->nb].hasCacheFile=-1;
    455486      curl_easy_setopt(hInternet->ihandle[hInternet->nb].handle, CURLOPT_WRITEFUNCTION, write_data_into);
    456487      curl_easy_setopt(hInternet->ihandle[hInternet->nb].handle, CURLOPT_WRITEDATA, (void*)&hInternet->ihandle[hInternet->nb]);
     488      hInternet->ihandle[hInternet->nb].hasCacheFile=-1;
    457489      break;
    458490    default:
    459       sprintf(hInternet->ihandle[hInternet->nb].filename,"/tmp/ZOO_Cache%d",(int)time(NULL));
    460       hInternet->ihandle[hInternet->nb].filename[24]=0;
    461 #ifdef MSG_LAF_VERBOSE
    462       fprintf(stderr,"file=%s",hInternet->ihandle[hInternet->nb].filename);
    463 #endif
    464       hInternet->ihandle[hInternet->nb].filename=filename;
     491      memset(filename,0,255);
     492      char* tmpUuid=get_uuid();
     493      sprintf(filename,"/tmp/ZOO_Cache%s", tmpUuid);
     494      free(tmpUuid);
     495      hInternet->ihandle[hInternet->nb].filename=strdup(filename);
    465496      hInternet->ihandle[hInternet->nb].file=fopen(hInternet->ihandle[hInternet->nb].filename,"w+");
    466    
    467497      hInternet->ihandle[hInternet->nb].hasCacheFile=1;
    468       curl_easy_setopt(hInternet->ihandle[hInternet->nb].handle, CURLOPT_WRITEFUNCTION, NULL);
    469       curl_easy_setopt(hInternet->ihandle[hInternet->nb].handle, CURLOPT_WRITEDATA, hInternet->ihandle[hInternet->nb].file);
    470       hInternet->ihandle[hInternet->nb].nDataLen=0;
     498      curl_easy_setopt(hInternet->ihandle[hInternet->nb].handle, CURLOPT_WRITEFUNCTION, write_data_into_file);
     499      curl_easy_setopt(hInternet->ihandle[hInternet->nb].handle, CURLOPT_WRITEDATA, (void*)&hInternet->ihandle[hInternet->nb]);
    471500      break;
    472501    }
     
    514543 */
    515544int processDownloads(HINTERNET* hInternet){
    516   int still_running=0;
     545  int still_running=0,numfds;
    517546  int msgs_left=0;
    518547  int i=0;
    519548  do{
    520     if(curl_multi_perform(hInternet->handle, &still_running)==CURLM_OK)
    521       if(still_running){
    522         zSleep(10);
    523       }
     549    CURLMcode mc;
     550    mc = curl_multi_perform(hInternet->handle, &still_running);
     551    if(mc==CURLM_OK){
     552      mc = curl_multi_wait(hInternet->handle, NULL, 0, 1000, &numfds);
     553    }
     554    if(mc != CURLM_OK) {
     555      fprintf(stderr, "curl_multi failed, code %d.n", mc);
     556      break;
     557    }
    524558  }while(still_running); 
    525559  for(i=0;i<hInternet->nb;i++){
     
    565599    fseek (hInternet.file , 0 , SEEK_END);
    566600    dwDataSize=ftell(hInternet.file); //taille du ficher
    567     rewind (hInternet.file);
     601    //dwDataSize=hInternet.nDataLen;
     602    //rewind (hInternet.file);
     603    fseek(hInternet.file, 0, SEEK_SET);
    568604  }
    569605  else{
     
    575611  }
    576612
    577   if( dwNumberOfBytesToRead /* buffer size */ < dwDataSize )
     613  if( dwNumberOfBytesToRead /* buffer size */ < dwDataSize ){
    578614    return 0;
     615  }
    579616
    580617#ifdef MSG_LAF_VERBOSE
    581   printf("\nfile size : %dko\n",dwDataSize/1024);
     618  fprintf(stderr,"\nfile size : %dko\n",dwDataSize/1024);
    582619#endif
    583620
    584621  if(hInternet.hasCacheFile>0){
    585     *lpdwNumberOfBytesRead = fread(lpBuffer,1,dwDataSize,hInternet.file);
     622    int freadRes = fread(lpBuffer,dwDataSize+1,1,hInternet.file);
     623    *lpdwNumberOfBytesRead = hInternet.nDataLen;
    586624  }
    587625  else{
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