Maps > Map Projections > Creating a New Projection > Step 1: Defining a New Projection
 
Step 1: Defining a New Projection
The first step explains the minimum requirement to subtype a projection. It focuses on how to implement the forward and inverse functions of a projection.
The complete code of this projection is in the files proj_step1.h and proj_step1.cpp.
The Class Declaration
The Mercator projection is declared in the file proj_step1.h.
You must include the <ilviews/maps/projection/project.h> file that declares the projection base class IlvProjection.
Then, you must declare the projection features that you are going to implement:
*sForward implements the forward projection in the most simple case, that is to say, when the earth is modeled as a sphere. Implementing this feature is mandatory since the IlvProjection::sForward function is abstract.
Declaring and implementing the following functions is not mandatory. The new projection will simply not support the features that are not implemented and returns an error code if they are required by the application.
*sInverse implements the inverse projection when the earth is modeled as a sphere.
*eForward implements the forward projection when the earth is modeled as a nonspherical ellipsoid.
*eInverse implements the inverse projection when the earth is modeled as a nonspherical ellipsoid.
In the projection declaration, you must also use the IlvMapsDeclareProjectionIO macro. This macro declares the IlvProjectionClassInfo of the class and some mandatory members to support input and output operations.
You must also add the IlvMapsInitProjectionIO in the file after the projection declaration. This macro ensures that the IlvProjectionClassInfo will be initialized during the static initialization phase.
#include <ilviews/maps/projection/project.h>
class Mercator : public IlvProjection
{
public:
Mercator();
protected:
virtual IlvMapsError sForward(IlvCoordinate &) const;
virtual IlvMapsError sInverse(IlvCoordinate &) const;
virtual IlvMapsError eForward(IlvCoordinate &) const;
virtual IlvMapsError eInverse(IlvCoordinate &) const;
IlvMapsDeclareProjectionIO(Mercator);
};
// Enable IO initialization.
IlvMapsInitProjectionIO(Mercator);

Version 5.8
Copyright © 2014, Rogue Wave Software, Inc. All Rights Reserved.