Peter, > To: support@xxxxxxxxxxxxxxxx > From: Peter Hollemans <Peter.Hollemans@xxxxxxxx> > Subject: Use of Java udunits package. > Organization: NOAA > Keywords: 200506031601.j53G1GZu004496 netCDF-Java UDUNITS The above message contained the following: > I recently became aware of the udunits Java port from this support message: > > http://my.unidata.ucar.edu/content/support/help/MailArchives/netcdf-java/msg00148.html > > I downloaded the source code file ncSrc-2.2.zip and created Javadocs for > the ucar.units package so I could read the API as it's not in the > standard online Javadocs (I guess because people are supposed to use the > ucar.nc2.units package). > > My question is this. The C language version of udunits contains the > utConvert() function, which returns the y=ax+b coefficients for a units > conversion. Is there an equivalent method in the Java API, or some way > to recover those coefficients? There are some ways that I can think of > to get them, such as using the Unit.convertTo(double,Unit) and passing > in zero to get the additive constant b, and then 1 to get the > multiplicative constant a as y-b. But I thought there must be some > better way supported by a Java API method. One of the goals of an object-oriented programming language like Java is to insulate the user of a class from the implementation of the class. The fact that a convertion between units might be Gaussian (y = ax + b) or linear (y = ax) or logarithmic (y = A lg(x)) is hidden from the user of the classs. Doing what you want would make the implementation visible and cast the implementation in concrete -- preventing better or different implementations. Why would you want the coefficients? > Peter. > > --------------000908080704010705090505 > Content-Type: text/x-vcard; charset=utf-8; > name="Peter.Hollemans.vcf" > Content-Transfer-Encoding: 7bit > Content-Disposition: attachment; > filename="Peter.Hollemans.vcf" > > begin:vcard > fn:Peter Hollemans > n:Hollemans;Peter > email;internet:Peter.Hollemans@xxxxxxxx > title:SP Systems, Inc. Consultant for NOAA/NESDIS > tel;work:(250) 478-1006 > version:2.1 > end:vcard > > > --------------000908080704010705090505-- Regards, Steve Emmerson > NOTE: All email exchanges with Unidata User Support are recorded in the > Unidata inquiry tracking system and then made publicly available > through the web. If you do not want to have your interactions made > available in this way, you must let us know in each email you send to us.