Step 3: Defining a New Projection
This step explains how to add the accessor support for the specific parameters of a projection.
The complete code of this projection is in the files proj_step3.h and proj_step3.cpp.
Adding Accessor Support
Accessors provide run-time information about the parameters of a projection. They are generally used to build generic projection editors in map applications.
To add an accessor to a projection you must write a getter and a setter function for this parameter and add the accessor to the IlvProjectionClassInfo during the static initialization phase.
// The getter for the latitudeOfTrueScale accessor.
static void _getter(const IlvProjection* p, IlvValue& v)
{
Mercator* mercator = (Mercator*) p;
char buffer[12];
v = IlvMaps::RadianToDMS(buffer,
mercator->getLatitudeOfTrueScale(),
IlTrue);
}
// The setter for the latitudeOfTrueScale accessor.
static IlvBoolean _setter(IlvProjection* p, const IlvValue& v)
{
Mercator* mercator = (Mercator*) p;
IlvDouble value;
IlvMapsError error = IlvMaps::DMSToRadian(v, value);
if (error != IlvMaps::NoError())
return IlFalse;
mercator->setLatitudeOfTrueScale(value);
return IlTrue;
}
void
Mercator::InitClass()
{
_polarZoneError =
IlvMaps::CreateError("&MercatorPolarZoneError");
ClassInfo()->addAccessor(IlvGetSymbol("latitudeOfTrueScale"),
IlvValueStringType,
_getter,
_setter);
}
Version 5.7
Copyright © 2013, Rogue Wave Software, Inc. All Rights Reserved.