Maps > Map Projections > Projecting Data: An Example > Projecting the Data
 
Projecting the Data
When data is projected, the geographical coordinates (longitude and latitude) are transformed to projected coordinates. This operation is necessary for one of the following reasons:
*to align graphical elements to a pre-existing map or to an image which is itself already projected
*to benefit from the properties of a specially selected projection (conservation of angles, surfaces, or distances from a central point)
To project the data, we call the forward member function of the projection. This function will place the result in its second argument (xy in our example). As certain projections cannot be used on all of the earth surface, this function also returns an error code which must be taken into account. For instance, the Mercator projection cannot project points close to the north and south poles. If an error occurs, the value of xy must not be used because it has no meaning.
IlvCoordinate xy;
IlvMapsError status = projection.forward(ll, xy);
if (status != IlvMaps::NoError())
IlvPrint("Projection exception for this data : %s",
IlvMaps::GetErrorMessageId(status));
If an error occurs, the message can be interpreted by the error management functions of IlvMaps.
Here, we use GetErrorMessageId which returns a Rogue Wave Views message.
In the above example, we use the Rogue Wave Views IlvPrint function to print the messages. This function provides a portable way to display messages, either in a pure graphic environment (Microsoft® Windows® applications) or on a console-enabled environment (UNIX® applications).

Version 6.1
Copyright © 2016, Rogue Wave Software, Inc. All Rights Reserved.