WRAPPER_API void set_Callback(GC_progress_callback callback, void *pData)
typedef void (*GC_progress_callback)(long index, long totalCount, void *pData)
The set_Callback method sets the method that will be called to give regular updates on the progress of the GetValidDatumShifts method. This method requires two arguments, the first of which is a pointer to the callback method, and the second of which is a pointer to the data associated with the callback. This contents of this data is for the developer's convenience. This data is delivered to the callback method as the third argument.
void ProgressCallback(long index, long totalCount, void * pData)
{
CString * path = (CString *)pData;
CString description;
description += "Finding DatumShifts from ";
description += *path;
char prog[256];
sprintf(prog, ": %i of %i", index, totalCount);
description += prog;
AfxMessageBox(description);
}
void DatumShiftPreferencesEx_setCallback(GeoCalcPBW::DatumShiftPreferencesEx & shiftPrefs, GeoCalcPBW::DataSource & data)
{
GeoCalcPBW::CoordSys * source = data.GetGeodeticCoordSys(_towchar("BMG").c_str(), _towchar("AK83-9").c_str());
GeoCalcPBW::CoordSys * target = data.GetProjectedCoordSys(_towchar("BMG").c_str(), _towchar("AK9-27").c_str());
GeoCalcPBW::Envelope * area = data.GetEnvelope(L"BMG", L"STANDARD_ENVELOPE");
GeoCalcPBW::DatumShiftPreferencesEx shiftPrefs;
int flags = GeoCalcPBW::DatumShiftPreferencesEx::BitFlag::BursaWolfe_flag |
GeoCalcPBW::DatumShiftPreferencesEx::BitFlag::Molodensky_flag;
shiftPrefs.set_BitFlags((GeoCalcPBW::DatumShiftPreferencesEx::BitFlag)flags);
shiftPrefs.set_IntermediateIssuer(L"BMG");
shiftPrefs.set_IntermediateCode(L"WGS84");
shiftPrefs.set_OnlyGoThruIntermediate(false);
shiftPrefs.set_Area(*area);
CString path;
path += source->get_Name();
path += " to ";
path += target->get_Name();
if(shiftPrefs.get_Callback() == NULL)
{
shiftPrefs.set_Callback(ProgressCallback, &path);
}
GeoCalcPBW::DatumShiftInfoSetCollection shiftSets;
if(! data.GetValidDatumShifts(*source, *target, shiftPrefs, shiftSets))
{
AfxMessageBox("GetValidDatumShifts failed");
}
delete source;
delete target;
delete area;
}