Map Projections > Unit Converters > Using Unit Converters Directly
 
Using Unit Converters Directly
To convert meters to feet, you can use a static member of the class IlvUnitConverter.
The following code converts meters to feet.
IlvUnitConverter* converter = IlvUnitConverter::FT();
IlvDouble meters = 100;
IlvDouble feet= converter->fromMeters(meters);
IlvPrint("100 m = %f ft", feet);
feet = 100;
meters = converter->toMeters(feet);
IlvPrint("100 ft = %f m", meters);
The toMeters method of the class IlvUnitConverter converts the current measurement unit to meters, while the fromMeters method converts meters to the current measurement unit.
You can either use a static member of the class IlvUnitConverter that defines commonly used converters or create your own converter as explained in the section Defining Unit Converters.You can also use one of the predefined converters listed in the section Using Predefined Unit Converters.

Version 5.7
Copyright © 2013, Rogue Wave Software, Inc. All Rights Reserved.