[mapguide-commits] r9873 - sandbox/adsk/trunk/Common/CoordinateSystem

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Thu Sep 23 19:20:31 PDT 2021


Author: simonliu
Date: 2021-09-23 19:20:30 -0700 (Thu, 23 Sep 2021)
New Revision: 9873

Modified:
   sandbox/adsk/trunk/Common/CoordinateSystem/CoordSysTransform.cpp
Log:
CS: Update method CCoordinateSystemTransform::GetExplicitGeodeticPath().
If it is an implicitly constructed path, we'll now create a [GeodeticPathDefinition] on-the-fly

Modified: sandbox/adsk/trunk/Common/CoordinateSystem/CoordSysTransform.cpp
===================================================================
--- sandbox/adsk/trunk/Common/CoordinateSystem/CoordSysTransform.cpp	2021-09-17 08:54:03 UTC (rev 9872)
+++ sandbox/adsk/trunk/Common/CoordinateSystem/CoordSysTransform.cpp	2021-09-24 02:20:30 UTC (rev 9873)
@@ -22,6 +22,8 @@
 #include "CoordSysTransform.h"          //for CCoordinateSystemTransform
 #include "CoordSysUtil.h"               //for CsDictionaryOpenMode
 #include "MentorUtil.h"                 //for IsLegalMentorName
+#include "CoordSysGeodeticPath.h"
+#include "CoordSysGeodeticPathElement.h"
 
 using namespace CSLibrary;
 
@@ -961,10 +963,9 @@
 MgCoordinateSystemGeodeticPath* CCoordinateSystemTransform::GetExplicitGeodeticPath()
 {
     STRING pathDefName;
-   	Ptr<MgCoordinateSystemCatalog> pCatalog;
+    Ptr<MgCoordinateSystemCatalog> pCatalog;
     Ptr<MgCoordinateSystemGeodeticPath> rtnValue;
     Ptr<MgCoordinateSystemGeodeticPathDictionary> pGpDefDict;
-    
     MgCoordinateSystemFactory csFactory;
 
     // index parameter is valid, get a pointer to the appropriate
@@ -979,6 +980,73 @@
         MgDisposable* tmpPtr = pGpDefDict.p->Get(pathDefName);
         rtnValue = dynamic_cast<MgCoordinateSystemGeodeticPath*>(tmpPtr);
     }
+    else
+    {
+        //this is an implicitly constructed path
+        //we'll now be creating a [GeodeticPathDefinition] on-the-fly
+        pCatalog = csFactory.GetCatalog();
+        Ptr<CCoordinateSystemGeodeticPath> geodeticPath = new CCoordinateSystemGeodeticPath(pCatalog);
+        geodeticPath->Reset();
+        geodeticPath->SetDescription(L"Auto-generated geodetic path");  // NOXLATE
+        geodeticPath->SetSourceDatum(this->GetSource()->GetDatum());
+        geodeticPath->SetTargetDatum(this->GetTarget()->GetDatum());
+
+        Ptr<MgDisposableCollection> pathElements = new MgDisposableCollection();
+        bool isError = false;
+        for (int i = 0; i < m_pDtcprm->xfrmCount; i++)
+        {
+            //iterate through all the transformations that CSMAP has given us
+            //and put them into the [pathElements] array
+            cs_GxXform_* pTransformation = m_pDtcprm->xforms[i];
+            if (nullptr == pTransformation)
+            {
+                isError = true;
+                break;
+            }
+
+            //we only support transformations, that are in the dictionaries;
+            //that is, we'll be try loading the definition from the catalog
+            cs_GeodeticTransform_ const& geoTransformDef = pTransformation->gxDef;
+            wchar_t* pwszXformName = Convert_UTF8_To_Wide(geoTransformDef.xfrmName);
+            STRING xformDefName = pwszXformName;
+            delete[] pwszXformName;
+            Ptr<MgCoordinateSystemGeodeticTransformDefDictionary> pGxDefDict = pCatalog->GetGeodeticTransformDefDictionary();
+            MgDisposable* tmpPtr = pGxDefDict.p->Get(xformDefName);
+            Ptr<MgCoordinateSystemGeodeticTransformDef> xform = dynamic_cast<MgCoordinateSystemGeodeticTransformDef*>(tmpPtr);
+            if (nullptr == xform)
+            {
+                isError = true;
+                break;
+            }
+
+            //the transformation exists in our dictionary - now initialize the single path element with that information
+            Ptr<MgCoordinateSystemGeodeticPathElement> pathElement = geodeticPath->NewPathElement();
+
+            bool pathElementIsInversed;
+            if (cs_DTCDIR_INV == pTransformation->userDirection)
+                pathElementIsInversed = true;
+            else if (cs_DTCDIR_FWD == pTransformation->userDirection)
+                pathElementIsInversed = false;
+            else /*if (cs_DTCDIR_NONE == pTransformation->userDirection)*/
+            {
+                isError = true;
+                break;
+            }
+
+            pathElement->SetIsInversed(pathElementIsInversed);
+            pathElement->SetTransformName(xformDefName);
+
+            pathElements->Add(pathElement);
+            pathElement.Detach();
+        }
+
+        if (!isError && 0 != pathElements->GetCount())
+        {
+            geodeticPath->SetPathElements(pathElements);
+            rtnValue = geodeticPath.Detach();
+        }
+    }
+
     return rtnValue.Detach ();
 }
 



More information about the mapguide-commits mailing list