Using Converters With Projections
Unit converters can be associated with a projection as shown in the following example, which is a modification of the useproj program that uses feet, instead of meters.
#include <ilviews/maps/projection/mercator.h>
main()
{
IlvUnitConverter* converter = IlvUnitConverter::FT();
IlvMercatorProjection projection;
projection.setUnitConverter(*converter);
const double lambda = IlvMaps::DegreeToRadian(-45.0);
const double phi = IlvMaps::DegreeToRadian(30.0);
IlvCoordinate ll(lambda, phi);
IlvCoordinate xy;
projection.forward(ll, xy);
IlvPrint("The projection of 45W 30N is \n"
" x = %f ft\n"
" y = %f ft",
xy.x(),
xy.y());
ll.moveTo(0, 0);
projection.inverse(xy, ll);
char buffer1[12];
char buffer2[12];
IlvPrint("The inverse projection is \n"
" %s %s",
IlvMaps::RadianToDMS(buffer1, ll.x(), IlFalseIlFalse),
IlvMaps::RadianToDMS(buffer2, ll.y(), IlTrue));
}
A call to setUnitConverter specifies that feet will be used as the measurement unit. The output of the forward method will then be expressed in feet. Similarly, the input to the inverse method must also be expressed in feet.
Version 5.5.1
Copyright © 2012, Rogue Wave Software, Inc. All Rights Reserved.