Ignore:
Timestamp:
10/07/10 16:17:04 (14 years ago)
Author:
hozdoba
Message:

suite du précédent commit

File:
1 edited

Legend:

Unmodified
Added
Removed
  • XMLIO_V2/dev/dev_rv/src/XMLIO/NetCDF4_data_output.hpp

    r126 r127  
    66namespace XMLIOSERVER 
    77{ 
     8 
     9   static const char* TimeName = "time"; 
     10 
    811   class NetCDF4DataOutput : public AbstractDataOutput 
    912   { 
     
    7477         } 
    7578 
    76          void writeCoords(const string& id, const Array<float, 1>& cdata) 
     79         void writeCoords(const string& id, const Array<double, 1>& cdata) 
    7780         { 
    7881            NcVar *cVar = dataFile->get_var(id.c_str()); 
     
    115118            // Ajout de la dimension temporelle non limitée. 
    116119            if (withTime) 
    117                if (NULL == dataFile->add_dim("time")) 
     120               if (NULL == dataFile->add_dim(TimeName)) 
    118121                  throw XMLIOUndefinedValueException("Impossible d'ajouter la dimension temporelle !"); 
    119122         } 
     
    139142               if (!(latVar = dataFile->add_var(latid.c_str(), ncFloat, dataFile->get_dim(latid.c_str())))) 
    140143                  throw XMLIOUndefinedValueException("Impossible d'ajouter la variable de latitude !"); 
     144 
    141145               if (!(lonVar = dataFile->add_var(lonid.c_str(), ncFloat, dataFile->get_dim(lonid.c_str())))) 
    142146                  throw XMLIOUndefinedValueException("Impossible d'ajouter la variable de longitude !"); 
     
    147151               hm["units"]         = "degrees_north"; 
    148152               hm["long_name"]     = "Latitude" ; 
    149                addStringAttributesToVar(latVar, hm); 
     153               this->addStringAttributesToVar(latVar, hm); 
    150154               hm.clear(); 
    151155 
     
    155159               hm["units"]          = "degrees_east"; 
    156160               hm["long_name"]      = "Longitude" ; 
    157                addStringAttributesToVar(lonVar, hm); 
    158                hm.clear(); 
     161               this->addStringAttributesToVar(lonVar, hm); 
     162               hm.clear(); 
     163 
     164               if ((*itt)->yvalue.hasValue()) 
     165                  this->writeCoords(lonid, (*itt)->xvalue); 
     166               else throw XMLIOUndefinedValueException("Les coordonnées de longitude (xvalue) ne sont pas définies pour le domaine \""+domid+"\"."); 
     167 
     168               if ((*itt)->xvalue.hasValue()) 
     169                  this->writeCoords(latid, (*itt)->yvalue); 
     170               else throw XMLIOUndefinedValueException("Les coordonnées de latitude (yvalue) ne sont pas définies pour le domaine \""+domid+"\"."); 
    159171            } 
    160172 
     
    171183               if ((*it)->long_name.hasValue())    hm["long_name"]     = (*it)->long_name ; 
    172184               if ((*it)->unit.hasValue())         hm["units"]         = (*it)->unit; 
    173                addStringAttributesToVar(othvar, hm); 
    174                hm.clear(); 
     185               this->addStringAttributesToVar(othvar, hm); 
     186               hm.clear(); 
     187 
     188               if ((*it)->value.hasValue()) 
     189                  this->writeCoords(axisid, (*it)->value); 
     190               else throw XMLIOUndefinedValueException("Les coordonnées de l'axe \""+axisid+"\" (value) ne sont pas définies."); 
    175191            } 
    176192         } 
     
    228244                  { 
    229245                     if (!(var = dataFile->add_var(fieldid.c_str(), tvar, 
    230                         dataFile->get_dim("time"), dataFile->get_dim(latid.c_str()), dataFile->get_dim(lonid.c_str())))) 
     246                        dataFile->get_dim(TimeName), dataFile->get_dim(latid.c_str()), dataFile->get_dim(lonid.c_str())))) 
    231247                        throw XMLIOUndefinedValueException("Impossible d'ajouter le champ "+ field->getId() +" !"); 
    232248                  } 
     
    234250                  { 
    235251                     if (!(var = dataFile->add_var(fieldid.c_str(), tvar, 
    236                         dataFile->get_dim("time"), dataFile->get_dim(axisid.c_str()), 
     252                        dataFile->get_dim(TimeName), dataFile->get_dim(axisid.c_str()), 
    237253                        dataFile->get_dim(latid.c_str()), dataFile->get_dim(lonid.c_str())))) 
    238254                        throw XMLIOUndefinedValueException("Impossible d'ajouter le champ "+ field->getId() +" !"); 
     
    258274               if (field->long_name.hasValue())    hm["long_name"]     = field->long_name ; 
    259275               if (field->unit.hasValue())         hm["units"]         = field->unit; 
    260                addStringAttributesToVar(var, hm); 
     276               this->addStringAttributesToVar(var, hm); 
    261277               hm.clear(); 
    262278            } 
     
    265281      private : 
    266282 
    267          void addStringAttributesToVar(NcVar * var, const Poco::HashMap<string, string>& attr) 
     283         void addStringAttributesToVar(NcVar * const var, const Poco::HashMap<string, string>& attr) 
    268284         { 
    269285            Poco::HashMap<string, string>::ConstIterator it; 
Note: See TracChangeset for help on using the changeset viewer.