Changeset 127 for XMLIO_V2/dev/dev_rv/src/XMLIO/NetCDF4_data_output.hpp
- Timestamp:
- 10/07/10 16:17:04 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
XMLIO_V2/dev/dev_rv/src/XMLIO/NetCDF4_data_output.hpp
r126 r127 6 6 namespace XMLIOSERVER 7 7 { 8 9 static const char* TimeName = "time"; 10 8 11 class NetCDF4DataOutput : public AbstractDataOutput 9 12 { … … 74 77 } 75 78 76 void writeCoords(const string& id, const Array< float, 1>& cdata)79 void writeCoords(const string& id, const Array<double, 1>& cdata) 77 80 { 78 81 NcVar *cVar = dataFile->get_var(id.c_str()); … … 115 118 // Ajout de la dimension temporelle non limitée. 116 119 if (withTime) 117 if (NULL == dataFile->add_dim( "time"))120 if (NULL == dataFile->add_dim(TimeName)) 118 121 throw XMLIOUndefinedValueException("Impossible d'ajouter la dimension temporelle !"); 119 122 } … … 139 142 if (!(latVar = dataFile->add_var(latid.c_str(), ncFloat, dataFile->get_dim(latid.c_str())))) 140 143 throw XMLIOUndefinedValueException("Impossible d'ajouter la variable de latitude !"); 144 141 145 if (!(lonVar = dataFile->add_var(lonid.c_str(), ncFloat, dataFile->get_dim(lonid.c_str())))) 142 146 throw XMLIOUndefinedValueException("Impossible d'ajouter la variable de longitude !"); … … 147 151 hm["units"] = "degrees_north"; 148 152 hm["long_name"] = "Latitude" ; 149 addStringAttributesToVar(latVar, hm);153 this->addStringAttributesToVar(latVar, hm); 150 154 hm.clear(); 151 155 … … 155 159 hm["units"] = "degrees_east"; 156 160 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+"\"."); 159 171 } 160 172 … … 171 183 if ((*it)->long_name.hasValue()) hm["long_name"] = (*it)->long_name ; 172 184 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."); 175 191 } 176 192 } … … 228 244 { 229 245 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())))) 231 247 throw XMLIOUndefinedValueException("Impossible d'ajouter le champ "+ field->getId() +" !"); 232 248 } … … 234 250 { 235 251 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()), 237 253 dataFile->get_dim(latid.c_str()), dataFile->get_dim(lonid.c_str())))) 238 254 throw XMLIOUndefinedValueException("Impossible d'ajouter le champ "+ field->getId() +" !"); … … 258 274 if (field->long_name.hasValue()) hm["long_name"] = field->long_name ; 259 275 if (field->unit.hasValue()) hm["units"] = field->unit; 260 addStringAttributesToVar(var, hm);276 this->addStringAttributesToVar(var, hm); 261 277 hm.clear(); 262 278 } … … 265 281 private : 266 282 267 void addStringAttributesToVar(NcVar * var, const Poco::HashMap<string, string>& attr)283 void addStringAttributesToVar(NcVar * const var, const Poco::HashMap<string, string>& attr) 268 284 { 269 285 Poco::HashMap<string, string>::ConstIterator it;
Note: See TracChangeset
for help on using the changeset viewer.