[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[UDUNITS #PKD-127901]: the library udunits2 : type(ut_converter), scale/offset(ut_converter)



Abara,

Revealing the implementation details of the converter abstraction has a cost: 
it greatly reduces the ability of the implementation to change yet maintain 
backward-compatibility. It can be done, but the benefit must outweigh the cost.

What is the benefit you're trying to achieve? Why do you need to know the type 
of the converter and its parameters?

> Hello,
> 
> I want use your library udunits2 for calculate the scale and/or offset of
> the converter. For that, I must use functions to determine the type of the
> converter (offset,scale,galilean, .....), and also access to structure
> ut_converter (conv->....).  the following example shows what I want to do.
> 
> int main (int argc, char * argv[])
> {
> ut_system * system = ut_read_xml
> ("/usr/local/share/doc/udunits/udunits2.xml");
> ut_unit * haveUnit = ut_get_unit_by_name (system, "degC"),
> * wantUnit  = ut_get_unit_by_name (system, "kelvin");
> 
> if (! ut_are_convertible (haveUnit, wantUnit))
> 
> ...
> 
> cv_converter * conv = ut_get_converter(haveUnit, wantUnit);
> 
> ...
> 
> double scale = -1.0, offset = -1.0;
> if (IS_SCALE(conv))
> scale = (conv->scale).value;
> else
> if (IS_OFFSET(conv))
> offset = (conv->offset).value;
> else
> {
> scale = (conv->galilean).slope;
> offset = (conv->galilean).intercept;
> }
> printf ("scale: %f, offset: %f\n", scale, offset);
> }
> 
> ...
> 
> does theses functions exist ?  in the contrary case, we can introduce
> theses functions in the converter.c and converter.h files.
> 
> Thank you very much for your help.
> 
> Abdelrezzak BARA.


Regards,
Steve Emmerson

Ticket Details
===================
Ticket ID: PKD-127901
Department: Support UDUNITS
Priority: Normal
Status: Closed