The Complete Example
#include <ilviews/maps/projection/mercator.h>
void
showProjection(const IlvProjection& projection)
{
double lambda = IlvMaps::DegreeToRadian(-45.);
double phi = IlvMaps::DegreeToRadian(30.);
IlvCoordinate ll(lambda, phi);
IlvCoordinate xy;
// Forward projection (from long/lat to x/y).
IlvMapsError status = projection.forward(ll, xy);
if (status != IlvMaps::NoError())
IlvPrint("Projection exception for this data : %s",
IlvMaps::GetErrorMessageId(status));
// Printing the result.
IlvPrint("The projection of 45W 30N is \n"
" x = %d m\n"
" y = %d m",
(int) xy.x(),
(int) xy.y());
// Resetting ll.
ll.move(0., 0.);
// Inverse projection (from x/y to long/lat).
status = projection.inverse(xy, ll);
if (status != IlvMaps::NoError())
IlvPrint("Projection exception for this data : %s",
IlvMaps::GetErrorMessageId(status));
// Printing the result.
char buffer1[12];
char buffer2[12];
IlvPrint("The inverse projection is \n"
" %s %s",
IlvMaps::RadianToDMS(buffer1, ll.x(), IlFalse),
IlvMaps::RadianToDMS(buffer2, ll.y(), IlTrue));}
int
main(int , char**)
{
IlvMercatorProjection projection;
showProjection(projection);
return 0;
}