A number of changes have been made to how conversions are handled by GeoCalc as well as the classes used to support conversions and transformations. When upgrading from 6.x to 7.x users will have to be mindful of these changes and make sure that they update their code appropriately. The following items have been removed, replaced or renamed in GeoCalc 7.x:
DataBrowser - Use DataSourceEditor
DatumShiftPicker - Use TransformPicker
ObjectPicker - Use DataSourcePicker
ATSDisplaySettings - Use DLSDisplaySettings
DatumShift - Use DatumTransform
DatumShiftCollection - Use ConcatenatedTransform's SerializableCollection of Transforms.
DatumShiftCollectionChangeDetail - Use SerializableCollectionChangeDetail
DatumShiftGenerator - Use DatumTransformGenerator
DatumShiftInfo - Use TransformInfo
DatumShiftPreferences - Use TransformPreferences
DatumShiftPreferencesEx - Use TransformPreferences
Envelope - Use AreaOfUse
HeightModel - Use VerticalTransform
VerticalReference - Use VerticalCoordSys
The MathTransform ClassTypes have also been changed in GeoCalc 7.x and users will have to update any code that used the previous definition. The following MathTransform ClassTypes have been removed or replaced in GeoCalc 7.x:
FirstOrderPolynomial - Use Affine
LinearPolynomial2D - Use Affine
QuadraticPolynomial2D - Use SecondOrderPolynomial
CubicPolynomial2D - Use ThirdOrderPolynomial
QuarticPolynomial2D - Use FourthOrderPolynomial
QuinticPolynomial2D - Use FifthOrderPolynomial
Helmert4Param - Use FourParameterHelmert3D
Beyond the items that have been removed or replaced, interfaces have been changed for some classes that have not been renamed in the upgrade. There are also a few new classes that have not been mentioned. The biggest change between the GeoCalc 6.x and 7.x SDK is the new ConcatenatedTransform that has replaced the old CoordTransform object type. This new transform allows the user to populate a source and target system list with complete horizontal and vertical CRS, and coordinate transform definitions. Once the new ConcatenatedTransform is full populated, we can call GeneratePointTransformer() and create a PointTransformer which can then be used to perform all of our required conversions. For examples of how these new classes please refer to the upgrade examples below, as well as the updated lessons in the getting started guide.
If your current code was based on a previous version of the getting started guide examples you can refer to the current examples in each section. They've all been updated to reflect similar functionality using GeoCalc 7.x.
In order to support the new structure of GeoCalc users will have to use a new version of geodata.xml datasource XML file. It is still possible to load previous versions of the view and custom data source files. They will be automatically upgraded to work with the current GeoCalc and a log of changes will be added to a specified archive directory. If you are worried about the upgrade process please make copies of your custom files before hand.
A new method has been added to DataSource allowing us to check if our base of custom datasource is of the new form, or old. This method is called CheckIfNeedsUpgrade(), and should be called before we load any old datasource. Here is how to use the new check and set the directory that the upgrade log will be written to:
if (dataSource->CheckIfNeedsUpgrade(BMG_T("C:\\bmg\\GeoCalcPBW\\data\\geodata.xml")))
{
// Main data source file needs to be ugraded, so don't load.
return false;
}
else if(! dataSource->LoadFile(BMG_T("C:\\bmg\\GeoCalcPBW\\data\\geodata.xml"), BMG_T("C:\\bmg\\GeoCalcPBW\\data\\geodata.xvw"), true, BMG_T("C:\\bmg\\GeoCalcPBW\\data\custom.xml"), 0, 0, 0))
{
// Then GeoCalc was unable to load the specified data source file
return;
}
The StringCoordSys, and StringCoordPoint types are new in version 7.x of GeoCalc. These will replace any cases where the location string of a coordinate point was being used in the older versions of GeoCalc. The following example demonstrates how to upgrade from GeoCalc 6.x syntax to the new GeoCalc 7.x interface:
// *Old Code*
// GeodeticCoordSys * wgs84 = dataSource->GetGeodeticCoordSys(L"WGS84_coordinate_system");
// GeodeticCoordSys * gars = dataSource->GetGeodeticCoordSys(L"058c09a4-fc3d-46af-81d5-97cc84d999f0");
// ProjectedCoordSys * mgrs = dataSource->GetProjectedCoordSys(L"MGRS");
//
// CoordPoint * wgs84Pt = wgs84->get_PointStyle().CloneCoordPoint();
// GeodeticPoint * garsPt = (GeodeticPoint *)gars->get_PointStyle().CloneCoordPoint();
// ProjectedPoint * mgrsPt = (ProjectedPoint *)mgrs->get_PointStyle().CloneCoordPoint();
//
// CoordTransform * fromGarsTrans = CoordTransform::CreateCoordTransform(*gars, *wgs84);
// CoordTransform * fromMgrsTrans = CoordTransform::CreateCoordTransform(*mgrs, *wgs84);
//
// garsPt->set_LocationString(L"221ME19");
// mgrsPt->set_LocationString(L"19TDK3695704122");
//
// fromGarsTrans->ConvertAhead(*garsPt, *wgs84Pt);
// fromMgrsTrans->ConvertAhead(*mgrsPt, *wgs84Pt);
//
// if (fromMgrsTrans) Disposal::Dispose(fromMgrsTrans);
// if (fromGarsTrans) Disposal::Dispose(fromGarsTrans);
// if (mgrsPt) Disposal::Dispose(mgrsPt);
// if (garsPt) Disposal::Dispose(garsPt);
// if (wgs84Pt) Disposal::Dispose(wgs84Pt);
// if (mgrs) Disposal::Dispose(mgrs);
// if (gars) Disposal::Dispose(gars);
// if (wgs84) Disposal::Dispose(wgs84);
// *End Old Code*
const DLSDisplaySettings forMatch;
BmgChar * garsIssuer = 0;
if (!dataSource->MatchOldStringFormat(BMG_T("058c09a4-fc3d-46af-81d5-97cc84d999f0"), forMatch, &garsIssuer))
{
garsIssuer = BMG_T("GARS_coordinate_system");
}
BmgChar * mgrsIssuer = 0;
if (!dataSource->MatchOldStringFormat(BMG_T("MGRS"), forMatch, &mgrsIssuer))
{
mgrsIssuer = BMG_T("MGRS_coordinate_system");
}
GeodeticCoordSys * wgs84 = dataSource->GetGeodeticCoordSys(BMG_T("WGS84_coordinate_system"));
StringCoordSys * gars = dataSource->GetStringCoordSys(garsIssuer);
StringCoordSys * mgrs = dataSource->GetStringCoordSys(mgrsIssuer);
ConcatenatedTransform * fromGarsTrans = ConcatenatedTransform::CreateConcatenatedTransform();
fromGarsTrans->get_Sources().AddBack(*gars);
fromGarsTrans->get_Targets().AddBack(*wgs84);
ConcatenatedTransform * fromMgrsTrans = ConcatenatedTransform::CreateConcatenatedTransform();
fromMgrsTrans->get_Sources().AddBack(*mgrs);
fromMgrsTrans->get_Targets().AddBack(*wgs84);
PointTransformer * fromGarsPtTrans = fromGarsTrans->GeneratePointTransformer();
PointTransformer * fromMgrsPtTrans = fromMgrsTrans->GeneratePointTransformer();
StringPoint * garsPt = dynamic_cast<StringPoint *>(fromGarsPtTrans->GetSourceCoordPoint());
CoordPoint * garsWgs84Pt = fromGarsPtTrans->GetTargetCoordPoint();
StringPoint * mgrsPt = dynamic_cast<StringPoint *>(fromMgrsPtTrans->GetSourceCoordPoint());
CoordPoint * mgrsWgs84Pt = fromMgrsPtTrans->GetTargetCoordPoint();
garsPt->set_Location(BMG_T("221ME19"));
mgrsPt->set_Location(BMG_T("19TDK3695704122"));
fromGarsPtTrans->ConvertSourceToTarget(*garsPt, *garsWgs84Pt);
fromMgrsPtTrans->ConvertSourceToTarget(*mgrsPt, *mgrsWgs84Pt);
if (mgrsWgs84Pt) Disposal::Dispose(mgrsWgs84Pt);
if (mgrsPt) Disposal::Dispose(mgrsPt);
if (garsWgs84Pt) Disposal::Dispose(garsWgs84Pt);
if (garsPt) Disposal::Dispose(garsPt);
if (fromMgrsPtTrans) Disposal::Dispose(fromMgrsPtTrans);
if (fromGarsPtTrans) Disposal::Dispose(fromGarsPtTrans);
if (fromMgrsTrans) Disposal::Dispose(fromMgrsTrans);
if (fromGarsTrans) Disposal::Dispose(fromGarsTrans);
if (mgrs) Disposal::Dispose(mgrs);
if (gars) Disposal::Dispose(gars);
if (wgs84) Disposal::Dispose(wgs84);
GeoCalc 7.x also introduces the concept of vertical coordinate systems and points with the addition of a VerticalCoordSys, and VerticalCoordPoint. These objects will replace the VerticalReference class that existed in previous versions of GeoCalc. Here is how to upgrade from vertical references to vertical coordinate systems:
// *Old Code*
// GeodeticCoordSys * wgs84Ellipsoid = dataSource->GetGeodeticCoordSys(L"WGS84_coordinate_system");
// GeodeticCoordSys * wgs84Egm96 = dataSource->GetGeodeticCoordSys(L"WGS84_coordinate_system");
// VerticalReference * ellipsoid = dataSource->GetVerticalReference(L"ELLIPSOID_HEIGHT");
// VerticalReference * egm96 = dataSource->GetVerticalReference(L"EGM96");
//
// CoordPoint * wgs84EllipsoidPt = wgs84Ellipsoid->get_PointStyle().CloneCoordPoint();
// CoordPoint * wgs84Egm96Pt = wgs84Egm96->get_PointStyle().CloneCoordPoint();
//
// CoordTransform * ellipsoidToEgm96 = CoordTransform::CreateCoordTransform(*wgs84Ellipsoid, *wgs84Egm96);
//
// wgs84Ellipsoid->set_VerticalReference(ellipsoid);
// wgs84Egm96->set_VerticalReference(egm96);
//
// wgs84EllipsoidPt->set_InUnits(-69.79015278, 44.28761111, 0.0);
//
// if (ellipsoidToEgm96->InitializeVerticalTransform())
// {
// ellipsoidToEgm96->ConvertAhead(*wgs84EllipsoidPt, *wgs84Egm96Pt);
// }
//
// if (ellipsoidToEgm96) Disposal::Dispose(ellipsoidToEgm96);
// if (wgs84Egm96Pt) Disposal::Dispose(wgs84Egm96Pt);
// if (wgs84EllipsoidPt) Disposal::Dispose(wgs84EllipsoidPt);
// if (egm96) Disposal::Dispose(egm96);
// if (ellipsoid) Disposal::Dispose(ellipsoid);
// if (wgs84Egm96) Disposal::Dispose(wgs84Egm96);
// if (wgs84Ellipsoid) Disposal::Dispose(wgs84Ellipsoid);
// *End Old Code*
BmgChar * ellipsoidIssuer = 0;
std::vector<BmgChar *> ellipsoidTransforms;
if (!dataSource->MatchOldVerticalReference(BMG_T("ELLIPSOID_HEIGHT"), &ellipsoidIssuer, ellipsoidTransforms))
{
ellipsoidIssuer = BMG_T("ELLIPSOIDAL_HEIGHT_VERTICAL_COORD_SYS");
}
BmgChar * egm96Issuer = 0;
std::vector<BmgChar *> egm96Transforms;
if (!dataSource->MatchOldVerticalReference(BMG_T("EGM96"), &egm96Issuer, egm96Transforms))
{
egm96Issuer = BMG_T("c7f0dd7c-521d-11e3-8ed6-cbfc96f5453b");
}
GeodeticCoordSys * wgs84 = dataSource->GetGeodeticCoordSys(BMG_T("WGS84_coordinate_system"));
VerticalCoordSys * ellipsoid = dataSource->GetVerticalCoordSys(ellipsoidIssuer);
VerticalCoordSys * egm96 = dataSource->GetVerticalCoordSys(egm96Issuer);
ConcatenatedTransform * concatTrans = ConcatenatedTransform::CreateConcatenatedTransform();
concatTrans->get_Sources().AddBack(*wgs84);
concatTrans->get_Sources().AddBack(*ellipsoid);
concatTrans->get_Targets().AddBack(*wgs84);
concatTrans->get_Targets().AddBack(*egm96);
for (std::vector<BmgChar *>::iterator it = ellipsoidTransforms.begin(); it != ellipsoidTransforms.end(); ++it)
{
VerticalTransform * vertTrans = dataSource->GetVerticalTransform(*it);
concatTrans->get_Transforms().AddBack(*vertTrans);
if (vertTrans) Disposal::Dispose(vertTrans);
}
for (std::vector<BmgChar *>::iterator it = egm96Transforms.begin(); it != egm96Transforms.end(); ++it)
{
VerticalTransform * vertTrans = dataSource->GetVerticalTransform(*it);
concatTrans->get_Transforms().AddBack(*vertTrans);
if (vertTrans) Disposal::Dispose(vertTrans);
}
PointTransformer * ptTrans = concatTrans->GeneratePointTransformer();
CoordPoint * srcPt = ptTrans->GetSourceCoordPoint();
CoordPoint * tgtPt = ptTrans->GetTargetCoordPoint();
srcPt->set_InUnits(-69.79015278, 44.28761111, 0.0);
ptTrans->ConvertSourceToTarget(*srcPt, *tgtPt);
if (tgtPt) Disposal::Dispose(tgtPt);
if (srcPt) Disposal::Dispose(srcPt);
if (ptTrans) Disposal::Dispose(ptTrans);
if (concatTrans) Disposal::Dispose(concatTrans);
if (egm96) Disposal::Dispose(egm96);
if (ellipsoid) Disposal::Dispose(ellipsoid);
if (wgs84) Disposal::Dispose(wgs84);
DatumShifts have been replaced with DatumTransforms in GeoCalc 7.x, and the DatumShiftCollection object type has been removed. If you’re using a single DatumShift you can use the DatumTransform in a similar fashion, but you’ll have to move to using a ConcatenatedTransform and PointTransformer in place of a DatumShiftCollection. Here is how to upgrade code using DatumShifts and DatumShiftCollections:
// *Old Code*
// DatumShift * wgs72ToWgs84 = dataSource->GetDatumShift(L"1238");
// DatumShift * nad27ToNad83 = dataSource->GetDatumShift(L"1241");
// DatumShift * nad83ToWgs84 = dataSource->GetDatumShift(L"1721");
// DatumShiftCollection * nad27ToWgs84 = DatumShiftCollection::CreateDatumShiftCollection();
// GeodeticPoint * wgs84Pt = GeodeticPoint::CreateGeodeticPoint();
// GeodeticPoint * wgs72Pt = GeodeticPoint::CreateGeodeticPoint();
// GeodeticPoint * nad27Pt = GeodeticPoint::CreateGeodeticPoint();
//
// wgs84Pt->set_InUnits(-69.79015278, 44.28761111);
//
// wgs72ToWgs84->ShiftForward(*wgs84Pt, *wgs72Pt);
//
// nad27ToWgs84->AddBack(*nad27ToNad83);
// nad27ToWgs84->AddBack(*nad83ToWgs84);
// nad27ToWgs84->ShiftBack(*wgs84Pt, *nad27Pt);
//
// if (nad27Pt) Disposal::Dispose(nad27Pt);
// if (wgs72Pt) Disposal::Dispose(wgs72Pt);
// if (wgs84Pt) Disposal::Dispose(wgs84Pt);
// if (nad27ToWgs84) Disposal::Dispose(nad27ToWgs84);
// if (nad83ToWgs84) Disposal::Dispose(nad83ToWgs84);
// if (nad27ToNad83) Disposal::Dispose(nad27ToNad83);
// if (wgs72ToWgs84) Disposal::Dispose(wgs72ToWgs84);
// *End Old Code*
DatumTransform * wgs72ToWgs84 = dataSource->GetDatumTransform(BMG_T("1238"));
DatumTransform * nad27ToNad83 = dataSource->GetDatumTransform(BMG_T("1241"));
DatumTransform * nad83ToWgs84 = dataSource->GetDatumTransform(BMG_T("1721"));
ConcatenatedTransform * nad27ToWgs84 = ConcatenatedTransform::CreateConcatenatedTransform();
nad27ToWgs84->get_Sources().AddBack(nad27ToNad83->get_SourceCoordSys());
nad27ToWgs84->get_Targets().AddBack(nad83ToWgs84->get_TargetCoordSys());
nad27ToWgs84->get_Transforms().AddBack(*nad27ToNad83);
nad27ToWgs84->get_Transforms().AddBack(*nad83ToWgs84);
PointTransformer * nad27ToWgs84PtTrans = nad27ToWgs84->GeneratePointTransformer();
GeodeticPoint * wgs84Pt = GeodeticPoint::CreateGeodeticPoint();
GeodeticPoint * wgs72Pt = GeodeticPoint::CreateGeodeticPoint();
GeodeticPoint * nad27Pt = GeodeticPoint::CreateGeodeticPoint();
wgs84Pt->set_InUnits(-69.79015278, 44.28761111);
wgs72ToWgs84->ConvertSourceToTarget(*wgs84Pt, *wgs72Pt);
nad27ToWgs84PtTrans->ConvertTargetToSource(*wgs84Pt, *nad27Pt);
if (nad27Pt) Disposal::Dispose(nad27Pt);
if (wgs72Pt) Disposal::Dispose(wgs72Pt);
if (wgs84Pt) Disposal::Dispose(wgs84Pt);
if (nad27ToWgs84PtTrans) Disposal::Dispose(nad27ToWgs84PtTrans);
if (nad27ToWgs84) Disposal::Dispose(nad27ToWgs84);
if (nad83ToWgs84) Disposal::Dispose(nad83ToWgs84);
if (nad27ToNad83) Disposal::Dispose(nad27ToNad83);
if (wgs72ToWgs84) Disposal::Dispose(wgs72ToWgs84);
ConcatenatedTransform and PointTransformer have replaced the CoordTransform interface used in GeoCalc version 6.x. In version 7.x of GeoCalc, the idea of a CoordTransform has changed. Now each CoordTransform is a single operation that provides a mechanism to go between two coordinate reference systems. There are currently three types of CoordinateTransforms defined in version 7.x. These are a VerticalTransform, DatumTransform, and ParametericTransform. In addition, there is a new ConcatenatedTransform type that contains a collection of coordinate systems and CoordTransforms. If you were previously were using the GetCoordTransform call to retrieve CoordTransforms, you will now want to use the GetConcatenatedTransform method. The 7.x GetCoordTransform call returns a single CT of one of three single operation types just mentioned. Here is how to upgrade your code to use GetCoordTransform, you could also use get_ObjectType to check the object type of the Serializable object returned:
// *Old Code*
// CoordTransform * affineTrans = dataSource->GetCoordTransform(L"15857");
// CoordPoint * affineSrcPt = affineTrans->get_SourceCoordSys().get_PointStyle().CloneCoordPoint();
// CoordPoint * affineTgtPt = affineTrans->get_TargetCoordSys().get_PointStyle().CloneCoordPoint();
//
// affineSrcPt->set_InUnits(500000.00, 1990012.39);
// affineTrans->ConvertAhead(*affineSrcPt, *affineTgtPt);
//
// if (affineTgtPt) Disposal::Dispose(affineTgtPt);
// if (affineSrcPt) Disposal::Dispose(affineSrcPt);
// if (affineTrans) Disposal::Dispose(affineTrans);
//
// CoordTransform * datumTrans = dataSource->GetCoordTransform(L"8604");
// CoordPoint * datumSrcPt = datumTrans->get_SourceCoordSys().get_PointStyle().CloneCoordPoint();
// CoordPoint * datumTgtPt = datumTrans->get_TargetCoordSys().get_PointStyle().CloneCoordPoint();
//
// datumSrcPt->set_InUnits(-69.79015278, 44.28761111);
// datumTrans->ConvertAhead(*datumSrcPt, *datumTgtPt);
//
// if (datumTgtPt) Disposal::Dispose(datumTgtPt);
// if (datumSrcPt) Disposal::Dispose(datumSrcPt);
// if (datumTrans) Disposal::Dispose(datumTrans);
// *End Old Code*
Serializable * trans = dataSource->GetCoordinateTransform(BMG_T("GC"), BMG_T("15857"));
if (trans->get_ObjectType());
CoordTransform * affineTrans = dynamic_cast<CoordTransform *>(trans);
if (affineTrans)
{
CoordPoint * affineSrcPt = affineTrans->get_SourceCoordSys().get_PointStyle().CloneCoordPoint();
CoordPoint * affineTgtPt = affineTrans->get_TargetCoordSys().get_PointStyle().CloneCoordPoint();
affineSrcPt->set_InUnits(500000.00, 1990012.39);
affineTrans->ConvertSourceToTarget(*affineSrcPt, *affineTgtPt);
if (affineTgtPt) Disposal::Dispose(affineTgtPt);
if (affineSrcPt) Disposal::Dispose(affineSrcPt);
}
if (trans) Disposal::Dispose(trans);
trans = 0;
trans = dataSource->GetCoordinateTransform(BMG_T("GC"), BMG_T("8604"));
ConcatenatedTransform * datumTrans = dynamic_cast<ConcatenatedTransform *>(trans);
if (datumTrans)
{
PointTransformer * ptTrans = datumTrans->GeneratePointTransformer();
CoordPoint * datumSrcPt = ptTrans->GetSourceCoordPoint();
CoordPoint * datumTgtPt = ptTrans->GetTargetCoordPoint();
datumSrcPt->set_InUnits(-69.79015278, 44.28761111);
ptTrans->ConvertSourceToTarget(*datumSrcPt, *datumTgtPt);
if (datumTgtPt) Disposal::Dispose(datumTgtPt);
if (datumSrcPt) Disposal::Dispose(datumSrcPt);
if (ptTrans) Disposal::Dispose(ptTrans);
}
if (trans) Disposal::Dispose(trans);
If you were previously using the DatumShiftPicker with a CoordTransform we will need to update our code to use a TransformPicker and ConcatenatedTransform respectively. This will also require us to swap any includes referencing "WDatumShiftPicker.h" with "WTransformPicker.h". The new picker now populates the passed in ConcatenatedTransform with the selected transform(s) which differs from the previous behavior of creating a new CoordTransform. Here is how to update such code:
// *Old Code*
// GeodeticCoordSys * wgs84 = dataSource->GetGeodeticCoordSys(L"WGS84_coordinate_system");
// GeodeticCoordSys * nad27 = dataSource->GetGeodeticCoordSys(L"NAD27_coordinate_system");
//
// CoordPoint * wgs84Pt = wgs84->get_PointStyle().CloneCoordPoint();
// CoordPoint * nad27Pt = nad27->get_PointStyle().CloneCoordPoint();
//
// DatumShiftPreferencesEx * prefs = DatumShiftPreferencesEx::CreateDatumShiftPreferencesEx();
// wgs84Pt->set_InUnits(-69.79015279, 44.28761110);
// prefs->get_Area().set_MinPoint(*wgs84Pt);
// wgs84Pt->set_InUnits(-69.79015278, 44.28761111);
// prefs->get_Area().set_MaxPoint(*wgs84Pt);
// prefs->get_Area().set_AlwaysAccept(false);
// prefs->set_IntermediateIssuer(L"GC");
// prefs->set_IntermediateCode(L"NAD83");
//
// CoordTransform * init = CoordTransform::CreateCoordTransform(*wgs84, *nad27);
// CoordTransform * wgs84ToNad27 = 0;
// DatumShiftPicker * picker = DatumShiftPicker::CreateDatumShiftPicker(dataSource, init, *prefs);
// EDialogState state = picker->Show(&wgs84ToNad27);
//
// if((state == eDialogStateNoChoices) || (state == eDialogStateCancel))
// {
// if (wgs84ToNad27) Disposal::Dispose(wgs84ToNad27);
// wgs84ToNad27 = 0;
// return;
// }
//
// if (wgs84ToNad27)
// {
// wgs84ToNad27->ConvertAhead(*wgs84Pt, *nad27Pt);
// Disposal::Dispose(wgs84ToNad27);
// }
//
// if (picker) Disposal::Dispose(picker);
// if (init) Disposal::Dispose(init);
// if (prefs) Disposal::Dispose(prefs);
// if (nad27Pt) Disposal::Dispose(nad27Pt);
// if (wgs84Pt) Disposal::Dispose(wgs84Pt);
// if (nad27) Disposal::Dispose(nad27);
// if (wgs84) Disposal::Dispose(wgs84);
// *End Old Code*
GeodeticCoordSys * wgs84 = dataSource->GetGeodeticCoordSys(BMG_T("WGS84_coordinate_system"));
GeodeticCoordSys * nad27 = dataSource->GetGeodeticCoordSys(BMG_T("NAD27_coordinate_system"));
CoordPoint * areaPt = GeodeticPoint::CreateGeodeticPoint(2);
TransformPreferences * prefs = TransformPreferences::CreateTransformPreferences();
areaPt->set_InUnits(-69.79015279, 44.28761110);
prefs->get_Area().set_MinPoint(*areaPt);
areaPt->set_InUnits(-69.79015278, 44.28761111);
prefs->get_Area().set_MaxPoint(*areaPt);
prefs->get_Area().set_AlwaysAccept(false);
prefs->set_IntermediateGCHorizontal(BMG_T("NAD83_coordinate_system"));
ConcatenatedTransform * wgs84ToNad27 = ConcatenatedTransform::CreateConcatenatedTransform();
wgs84ToNad27->get_Sources().AddBack(*wgs84);
wgs84ToNad27->get_Targets().AddBack(*nad27);
TransformPicker * picker = TransformPicker::CreateTransformPicker(dataSource, wgs84ToNad27, prefs);
EDialogState state = picker->Show(wgs84ToNad27);
if((state != eDialogStateNoChoices) && (state != eDialogStateCancel))
{
PointTransformer * wgs84ToNad27PtTrans = wgs84ToNad27->GeneratePointTransformer();
CoordPoint * wgs84Pt = wgs84ToNad27PtTrans->GetSourceCoordPoint();
CoordPoint * nad27Pt = wgs84ToNad27PtTrans->GetTargetCoordPoint();
wgs84Pt->set_InUnits(-69.79015278, 44.28761111);
wgs84ToNad27PtTrans->ConvertSourceToTarget(*wgs84Pt, *nad27Pt);
if (nad27Pt) Disposal::Dispose(nad27Pt);
if (wgs84Pt) Disposal::Dispose(wgs84Pt);
if (wgs84ToNad27PtTrans) Disposal::Dispose(wgs84ToNad27PtTrans);
}
if (picker) Disposal::Dispose(picker);
if (wgs84ToNad27) Disposal::Dispose(wgs84ToNad27);
if (prefs) Disposal::Dispose(prefs);
if (areaPt) Disposal::Dispose(areaPt);
if (nad27) Disposal::Dispose(nad27);
if (wgs84) Disposal::Dispose(wgs84);
EstablishCoordTransform has been replaced with EstablishTransform, which works with a ConcatenatedTransform and TransformPreferences. Besides the name updates the big change is the new method returns a boolean value indicating if it succeeded and populates the passed in ConcatenatedTransform with the transform(s) selected by EstablishTransform. Here is how to upgrade code using EstablishCoordTransform:
// *Old Code*
// GeodeticCoordSys * wgs84 = dataSource->GetGeodeticCoordSys(L"WGS84_coordinate_system");
// GeodeticCoordSys * nad27 = dataSource->GetGeodeticCoordSys(L"NAD27_coordinate_system");
//
// CoordPoint * wgs84Pt = wgs84->get_PointStyle().CloneCoordPoint();
// CoordPoint * nad27Pt = nad27->get_PointStyle().CloneCoordPoint();
//
// DatumShiftPreferencesEx * prefs = DatumShiftPreferencesEx::CreateDatumShiftPreferencesEx();
// wgs84Pt->set_InUnits(-69.79015279, 44.28761110);
// prefs->get_Area().set_MinPoint(*wgs84Pt);
// wgs84Pt->set_InUnits(-69.79015278, 44.28761111);
// prefs->get_Area().set_MaxPoint(*wgs84Pt);
// prefs->get_Area().set_AlwaysAccept(false);
// prefs->set_IntermediateIssuer(L"GC");
// prefs->set_IntermediateCode(L"NAD83");
//
// CoordTransform * init = CoordTransform::CreateCoordTransform(*wgs84, *nad27);
// CoordTransform * wgs84ToNad27 = dataSource->EstablishCoordTransform(*init, *prefs);
//
// if (wgs84ToNad27)
// {
// wgs84ToNad27->ConvertAhead(*wgs84Pt, *nad27Pt);
// Disposal::Dispose(wgs84ToNad27);
// }
//
// if (init) Disposal::Dispose(init);
// if (prefs) Disposal::Dispose(prefs);
// if (nad27Pt) Disposal::Dispose(nad27Pt);
// if (wgs84Pt) Disposal::Dispose(wgs84Pt);
// if (nad27) Disposal::Dispose(nad27);
// if (wgs84) Disposal::Dispose(wgs84);
// *End Old Code*
GeodeticCoordSys * wgs84 = dataSource->GetGeodeticCoordSys(BMG_T("WGS84_coordinate_system"));
GeodeticCoordSys * nad27 = dataSource->GetGeodeticCoordSys(BMG_T("NAD27_coordinate_system"));
CoordPoint * areaPt = GeodeticPoint::CreateGeodeticPoint(2);
TransformPreferences * prefs = TransformPreferences::CreateTransformPreferences();
areaPt->set_InUnits(-69.79015279, 44.28761110);
prefs->get_Area().set_MinPoint(*areaPt);
areaPt->set_InUnits(-69.79015278, 44.28761111);
prefs->get_Area().set_MaxPoint(*areaPt);
prefs->get_Area().set_AlwaysAccept(false);
prefs->set_IntermediateGCHorizontal(BMG_T("NAD83_coordinate_system"));
ConcatenatedTransform * wgs84ToNad27 = ConcatenatedTransform::CreateConcatenatedTransform();
wgs84ToNad27->get_Sources().AddBack(*wgs84);
wgs84ToNad27->get_Targets().AddBack(*nad27);
if (dataSource->EstablishTransform(*prefs, *wgs84ToNad27))
{
PointTransformer * wgs84ToNad27PtTrans = wgs84ToNad27->GeneratePointTransformer();
CoordPoint * wgs84Pt = wgs84ToNad27PtTrans->GetSourceCoordPoint();
CoordPoint * nad27Pt = wgs84ToNad27PtTrans->GetTargetCoordPoint();
wgs84Pt->set_InUnits(-69.79015278, 44.28761111);
wgs84ToNad27PtTrans->ConvertSourceToTarget(*wgs84Pt, *nad27Pt);
if (nad27Pt) Disposal::Dispose(nad27Pt);
if (wgs84Pt) Disposal::Dispose(wgs84Pt);
if (wgs84ToNad27PtTrans) Disposal::Dispose(wgs84ToNad27PtTrans);
}
if (wgs84ToNad27) Disposal::Dispose(wgs84ToNad27);
if (prefs) Disposal::Dispose(prefs);
if (areaPt) Disposal::Dispose(areaPt);
if (nad27) Disposal::Dispose(nad27);
if (wgs84) Disposal::Dispose(wgs84);