WRAPPER_API bool EstablishDatumShift(CoordTransform &coordTransform, DatumShiftPreferences &shiftPrefs)
The EstablishDatumShift method finds DatumShifts for the specified CoordTransform that coincide with the settings passed in the DatumShiftPreferences argument. These DatumShifts are then stored in the CoordTransform::DatumShifts property. This method returns a boolean value indicating the success of the operation.
See also the DataSource::GetValidDatumShifts method for selecting datum shifts.
void DataSource_EstablishDatumShift(GeoCalcPBW::DataSource & data)
{
GeoCalcPBW::CoordTransform ct;
GeoCalcPBW::GeodeticCoordSys * source = data.GetGeodeticCoordSys(_towchar("BMG").c_str(), _towchar("WGS84_coordinate_system").c_str());
GeoCalcPBW::ProjectedCoordSys * target = data.GetProjectedCoordSys(_towchar("BMG").c_str(), _towchar("IA-27W").c_str());
ct.set_SourceCoordSys(*source);
ct.set_TargetCoordSys(*target);
GeoCalcPBW::DatumShiftPreferences shiftPrefs;
int opt = GeoCalcPBW::DatumShiftPreferences::ProcFlags::Direct |
GeoCalcPBW::DatumShiftPreferences::ProcFlags::ViaIntermediary |
GeoCalcPBW::DatumShiftPreferences::ProcFlags::IgnoreArea |
GeoCalcPBW::DatumShiftPreferences::ProcFlags::IgnoreMethod;
shiftPrefs.set_Options(opt);
if(! data.EstablishDatumShift(ct, shiftPrefs))
{
AfxMessageBox("EstablishDatumShift failed");
}
GeoCalcPBW::CoordPoint * sourcePt = ct.get_SourceCoordSys().get_PointStyle().CloneCoordPoint();
GeoCalcPBW::CoordPoint * targetPt = ct.get_TargetCoordSys().get_PointStyle().CloneCoordPoint();
sourcePt->set_InUnits(-14.27, 45.76);
if(! ct.ConvertAhead(*sourcePt, *targetPt))
{
AfxMessageBox("ConvertAhead failed");
}
delete source;
delete target;
delete sourcePt;
delete targetPt;
}