31 #ifndef ODIM_QUANTITY_MAP
32 #define ODIM_QUANTITY_MAP
34 #include <drain/Log.h>
35 #include <drain/Type.h>
41 #include <drain/util/ReferenceMap.h>
54 typedef std::map<std::string, Quantity> map_t;
64 mout.
attention(
"? copy const <QuantityMap>");
95 EncodingODIM & set(
const std::string & key,
char typecode){
97 return q.
set(typecode);
111 Quantity & copy(
const std::string & key,
const Quantity & dst){
112 Quantity & q = (*this)[key];
120 bool hasQuantity(
const std::string & key)
const {
121 return find(key) != end();
126 const Quantity & get(
const std::string & key)
const {
128 const const_iterator it = find(key);
136 static Quantity empty;
143 Quantity & get(
const std::string & key) {
145 const iterator it = find(key);
153 static Quantity empty;
166 bool setQuantityDefaults(EncodingODIM & dst,
const std::string & quantity,
const std::string & values =
"")
const;
188 const std::string & q = !quantity.empty() ? quantity : dstData.odim.quantity;
192 if (dstData.odim.quantity.empty()){
194 dstData.odim.quantity = q;
197 mout.
warn(
"quantity neither given nor set already" );
202 mout.
warn(
"conf for " , quantity ,
"[" , dstData.odim.type ,
"] not found" );
205 dstData.data.setType(dstData.odim.type);
208 dstData.data.setScaling(dstData.odim.scaling);
211 if ((q ==
"QIND") || (q ==
"PROB")){
214 dstData.data.getScaling().setPhysicalRange(0.0, 1.0);
216 else if (q ==
"CLASS"){
224 if (dstData.data.getName().empty())
225 dstData.data.setName(dstData.odim.quantity);
227 mout.
debug2(
"final scaling for " , dstData.odim.quantity ,
'[' , quantity ,
']' , dstData.data.getScaling() );
236 const Quantity & q = get(odim.quantity);
239 mout.
warn(
"no default type for quantity:" , odim.quantity );
248 std::ostream & toOstr(std::ostream & ostr)
const {
249 for (const_iterator it = begin(); it != end(); ++it){
250 ostr << it->first <<
'\n' << it->second;
260 std::ostream & operator<<(std::ostream & ostr,
const QuantityMap & map){
261 return map.toOstr(ostr);
264 QuantityMap & getQuantityMap();
LogSourc e is the means for a function or any program segment to "connect" to a Log.
Definition: Log.h:308
Logger & attention(const TT &... args)
Possible error, but execution can continue. Special type of Logger::warn().
Definition: Log.h:472
Logger & warn(const TT &... args)
Possible error, but execution can continue.
Definition: Log.h:426
Logger & debug2(const TT &... args)
Debug information.
Definition: Log.h:686
T getTypeMax() const
Returns the maximum value supported by the current storage type.
Definition: ImageConf.h:281
void setPhysicalRange(const Range< double > &range, bool rescale=false)
Sets the supported range for physical values and optionally adjusts the scaling for maximal resolutio...
Definition: ImageFrame.h:106
Class for multi-channel digital images. Supports dynamic typing with base types (char,...
Definition: Image.h:184
Structure for data storage type, scaling and marker codes. Does not contain quantity.
Definition: EncodingODIM.h:75
static bool haveSimilarEncoding(const EncodingODIM &odim1, const EncodingODIM &odim2)
Checks if data encoding is similar (storage type, gain, offset, undetect and nodata are the same).
Definition: EncodingODIM.h:167
Essential class for storing radar data.
Definition: Data.h:302
Definition: QuantityMap.h:50
bool setQuantityDefaults(PlainData< D > &dstData, const std::string &quantity="", const std::string &values="") const
Definition: QuantityMap.h:184
bool setQuantityDefaults(EncodingODIM &dst, const std::string &quantity, const std::string &values="") const
Sets default values of given quantity - but not the quantity itself. Optionally overrides with user v...
Definition: QuantityMap.cpp:398
bool isNormalized(const M odim) const
Checks if data.
Definition: QuantityMap.h:235
Quantity & add(const std::string &key)
Sets quantity encoding. If gain=0.0, default values for the given type will be set as defined in drai...
Definition: QuantityMap.h:88
Structure for defining.
Definition: Quantity.h:53
const EncodingODIM & get(char typecode='\0') const
Retrieve the scaling for a given storage type.
Definition: Quantity.h:108
char defaultType
Default storage type.
Definition: Quantity.h:63
EncodingODIM & set(char typecode)
Declare encoding (a storage type and scaling) for this quantity.
Definition: Quantity.cpp:87
Definition: DataSelector.cpp:44