[mapguide-commits] r5337 - in trunk/MgDev/Common: . CoordinateSystem Geometry/GeometryConsoleTest

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Tue Oct 26 19:47:24 EDT 2010


Author: NormOlsen
Date: 2010-10-26 16:47:24 -0700 (Tue, 26 Oct 2010)
New Revision: 5337

Modified:
   trunk/MgDev/Common/Common.sln
   trunk/MgDev/Common/CoordinateSystem/ArbitraryCoordsys.cpp
   trunk/MgDev/Common/CoordinateSystem/CoordSys.cpp
   trunk/MgDev/Common/CoordinateSystem/CoordSysFormatConverter.cpp
   trunk/MgDev/Common/CoordinateSystem/MentorUtil.cpp
   trunk/MgDev/Common/CoordinateSystem/MentorUtil.h
   trunk/MgDev/Common/Geometry/GeometryConsoleTest/GeometryConsoleTest.cpp
Log:
This submission corrects MapGuide Trac ticket #1506.  A separate submission to CS-MAP corrects a related defect identified by CS-MAP Trac ticket #68.

Coordinate systems based on the NERTH and NRTHSRT projections require special processing at several points in the library.  NRTHSRT being an add-on, the are several places where special processing is required, applied to NERTH systems, but not to NRTHSRT systems.  This submission corrects this situation.


Modified: trunk/MgDev/Common/Common.sln
===================================================================
--- trunk/MgDev/Common/Common.sln	2010-10-26 22:52:27 UTC (rev 5336)
+++ trunk/MgDev/Common/Common.sln	2010-10-26 23:47:24 UTC (rev 5337)
@@ -50,6 +50,9 @@
 	EndProjectSection
 EndProject
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "GeometryConsoleTest", "Geometry\GeometryConsoleTest\GeometryConsoleTest.vcproj", "{F1285F4D-3CB7-427A-A2E8-43A575932C9F}"
+	ProjectSection(ProjectDependencies) = postProject
+		{D954DAAC-E305-40CE-B3F3-C229A0BEF4F0} = {D954DAAC-E305-40CE-B3F3-C229A0BEF4F0}
+	EndProjectSection
 EndProject
 Global
 	GlobalSection(SolutionConfigurationPlatforms) = preSolution

Modified: trunk/MgDev/Common/CoordinateSystem/ArbitraryCoordsys.cpp
===================================================================
--- trunk/MgDev/Common/CoordinateSystem/ArbitraryCoordsys.cpp	2010-10-26 22:52:27 UTC (rev 5336)
+++ trunk/MgDev/Common/CoordinateSystem/ArbitraryCoordsys.cpp	2010-10-26 23:47:24 UTC (rev 5337)
@@ -92,7 +92,7 @@
     {
         return NULL;
     }
-    if (ProjectionFromString(pcsDefPtr->prj_knm)!=MgCoordinateSystemProjectionCode::Nerth)
+    if (!ProjectionIsNerthType (pcsDefPtr->prj_knm))
     {
         return NULL;
     }

Modified: trunk/MgDev/Common/CoordinateSystem/CoordSys.cpp
===================================================================
--- trunk/MgDev/Common/CoordinateSystem/CoordSys.cpp	2010-10-26 22:52:27 UTC (rev 5336)
+++ trunk/MgDev/Common/CoordinateSystem/CoordSys.cpp	2010-10-26 23:47:24 UTC (rev 5337)
@@ -81,7 +81,7 @@
 {
     //if an arbitrary coordinate system it has to DT and no EL
     //it uses the NERTH projection
-    if (ProjectionFromString(csprm.csdef.prj_knm)==MgCoordinateSystemProjectionCode::Nerth)
+    if (ProjectionIsNerthType (csprm.csdef.prj_knm))
     {
         //Everything worked okay!  Copy the data into our member variables.
         Uninitialize();
@@ -108,7 +108,7 @@
 
     //if an arbitrary coordinate system it has to DT and no EL
     //it uses the NERTH projection
-    if (ProjectionFromString(csdef.prj_knm)==MgCoordinateSystemProjectionCode::Nerth)
+    if (ProjectionIsNerthType (csdef.prj_knm))
     {
         //Everything worked okay!  Copy the data into our member variables.
         Uninitialize();
@@ -202,7 +202,7 @@
         nCoordinateSystemType=MgCoordinateSystemType::Unknown;
     }
     //arbitrary systems, the one that use the NERTH projection
-    else if(ProjectionFromString(m_csprm.csdef.prj_knm)==MgCoordinateSystemProjectionCode::Nerth)
+    else if(ProjectionIsNerthType (m_csprm.csdef.prj_knm))
     {
         nCoordinateSystemType = MgCoordinateSystemType::Arbitrary;
     }
@@ -1120,7 +1120,7 @@
     }
 
     //in case of NERTH we have no datum and no ellipsoid
-    if (MgCoordinateSystemProjectionCode::Nerth==prjType)
+    if (ProjectionIsNerthType (prjType))
     {
         memset(m_csprm.csdef.dat_knm, 0, sizeof(m_csprm.csdef.dat_knm));
         memset(m_csprm.csdef.elp_knm, 0, sizeof(m_csprm.csdef.elp_knm));
@@ -1149,7 +1149,7 @@
 
     MG_TRY()
 
-    if (ProjectionFromString(m_csprm.csdef.prj_knm)==MgCoordinateSystemProjectionCode::Nerth)
+    if (ProjectionIsNerthType (m_csprm.csdef.prj_knm))
     {
         //It's an arbitrary system.
         assert(NULL==m_pDatum);
@@ -1207,7 +1207,7 @@
 
     MG_TRY()
 
-    if (ProjectionFromString(m_csprm.csdef.prj_knm)==MgCoordinateSystemProjectionCode::Nerth)
+    if (ProjectionIsNerthType (m_csprm.csdef.prj_knm))
     {
         //It's an arbitrary system.
         assert(NULL==m_pDatum);
@@ -1372,7 +1372,7 @@
 
     MG_TRY()
 
-    if (ProjectionFromString(m_csprm.csdef.prj_knm)==MgCoordinateSystemProjectionCode::Nerth)
+    if (ProjectionIsNerthType (m_csprm.csdef.prj_knm))
     {
         return true;
     }
@@ -1446,7 +1446,7 @@
     }
 
     //no DT or EL reference for NERTH
-    if (ProjectionFromString(m_csprm.csdef.prj_knm)==MgCoordinateSystemProjectionCode::Nerth)
+    if (ProjectionIsNerthType (m_csprm.csdef.prj_knm))
     {
         return true;
     }
@@ -2455,7 +2455,7 @@
         throw new MgCoordinateSystemInitializationFailedException(L"MgCoordinateSystem.SetDatum", __LINE__, __WFILE__, NULL, L"MgCoordinateSystemProtectedException", NULL);
     }
     //no DT or EL if NERTH projection is used
-    if (MgCoordinateSystemProjectionCode::Nerth==GetProjectionCode())
+    if (ProjectionIsNerthType (GetProjectionCode()))
     {
         throw new MgCoordinateSystemInitializationFailedException(L"MgCoordinateSystem.SetDatum", __LINE__, __WFILE__, NULL, L"MgCoordinateSystemNoDatumIfArbitraryException", NULL);
     }
@@ -2484,7 +2484,7 @@
         throw new MgCoordinateSystemInitializationFailedException(L"MgCoordinateSystem.SetEllipsoid", __LINE__, __WFILE__, NULL, L"MgCoordinateSystemProtectedException", NULL);
     }
     //no DT or EL if NERTH projection is used
-    if (MgCoordinateSystemProjectionCode::Nerth==GetProjectionCode())
+    if (ProjectionIsNerthType (GetProjectionCode()))
     {
         throw new MgCoordinateSystemInitializationFailedException(L"MgCoordinateSystem.SetEllipsoid", __LINE__, __WFILE__, NULL, L"MgCoordinateSystemNoDatumIfArbitraryException", NULL);
     }
@@ -2538,7 +2538,7 @@
     */
 
     //no DT or EL if NERTH projection is used
-    if (MgCoordinateSystemProjectionCode::Nerth==GetProjectionCode())
+    if (ProjectionIsNerthType (GetProjectionCode()))
     {
         throw new MgCoordinateSystemInitializationFailedException(L"MgCoordinateSystem.SetDatumDefinition", __LINE__, __WFILE__, NULL, L"MgCoordinateSystemNoDatumIfArbitraryException", NULL);
     }
@@ -2691,7 +2691,7 @@
     */
 
     //no DT or EL if NERTH projection is used
-    if (MgCoordinateSystemProjectionCode::Nerth==GetProjectionCode())
+    if (ProjectionIsNerthType (GetProjectionCode()))
     {
         throw new MgCoordinateSystemInitializationFailedException(L"MgCoordinateSystem.SetEllipsoidDefinition", __LINE__, __WFILE__, NULL, L"MgCoordinateSystemNoEllipsoidIfArbitraryException", NULL);
     }

Modified: trunk/MgDev/Common/CoordinateSystem/CoordSysFormatConverter.cpp
===================================================================
--- trunk/MgDev/Common/CoordinateSystem/CoordSysFormatConverter.cpp	2010-10-26 22:52:27 UTC (rev 5336)
+++ trunk/MgDev/Common/CoordinateSystem/CoordSysFormatConverter.cpp	2010-10-26 23:47:24 UTC (rev 5337)
@@ -74,7 +74,7 @@
         throw new MgCoordinateSystemInitializationFailedException(L"MgCoordinateSystemFormatConverter.DefinitionToWkt", __LINE__, __WFILE__, NULL, L"", NULL);
     }
 
-    if (ProjectionFromString(pCsDef->prj_knm)==MgCoordinateSystemProjectionCode::Nerth)
+    if (ProjectionIsNerthType (pCsDef->prj_knm))
     {
         //Get the coordinate system definition.
         ConvertArbitraryToWkt(pSource, sWkt);
@@ -516,7 +516,7 @@
     }
 
     INT32 prj=pCsCoordinateSystemDef->GetProjectionCode();
-    if (MgCoordinateSystemProjectionCode::Nerth==prj)
+    if (ProjectionIsNerthType (prj))
     {
         ConvertArbitraryToWkt(pCsCoordinateSystemDef, sWkt);
     }

Modified: trunk/MgDev/Common/CoordinateSystem/MentorUtil.cpp
===================================================================
--- trunk/MgDev/Common/CoordinateSystem/MentorUtil.cpp	2010-10-26 22:52:27 UTC (rev 5336)
+++ trunk/MgDev/Common/CoordinateSystem/MentorUtil.cpp	2010-10-26 23:47:24 UTC (rev 5337)
@@ -588,6 +588,20 @@
     return NULL;
 }
 
+// Returns true if th indictaed project, via projection key name
+// or projection code, is of the non-earth referenced type.  That
+// is, the projection type is either NERTH or NRTHSRT.
+bool ProjectionIsNerthType (const char *kpStr)
+{
+    INT32 prjCode = ProjectionFromString (kpStr);
+    return ProjectionIsNerthType (prjCode);
+}
+bool ProjectionIsNerthType (INT32 prjCode)
+{
+    bool isNerth = (prjCode == cs_PRJCOD_NERTH) || (prjCode == cs_PRJCOD_NRTHSRT);
+    return isNerth;
+}
+
 struct UnitStrPair
 {
     INT32 unit;
@@ -1107,7 +1121,7 @@
 //Builds a cs_Csprm_ struct from a cs_Csdef_ structure.
 bool BuildCsprmFromArbitraryDef(const cs_Csdef_& csdef, cs_Csprm_& csprm)
 {
-    if (MgCoordinateSystemProjectionCode::Nerth!=ProjectionFromString(csdef.prj_knm))
+    if (!ProjectionIsNerthType (csdef.prj_knm))
     {
         return false;
     }
@@ -1137,7 +1151,7 @@
     if (!bResult) return bResult;
 
     struct cs_Csprm_ *pCsprm = NULL;
-    if (MgCoordinateSystemProjectionCode::Nerth==ProjectionFromString(csdef.prj_knm))
+    if (ProjectionIsNerthType (csdef.prj_knm))
     {
         pCsprm = (struct cs_Csprm_ *)CS_malc (sizeof(struct cs_Csprm_));
         if (NULL == pCsprm) return false; //E_OUTOFMEMORY;
@@ -1232,7 +1246,7 @@
         return bResult;
     }
 
-    if (MgCoordinateSystemProjectionCode::Nerth!=ProjectionFromString(pCsDef->prj_knm))
+    if (ProjectionIsNerthType (pCsDef->prj_knm))
     {
         //Try to get a datum from the coordsys.
         Ptr<MgCoordinateSystemDatum> pDatum = pSrc->GetDatumDefinition();

Modified: trunk/MgDev/Common/CoordinateSystem/MentorUtil.h
===================================================================
--- trunk/MgDev/Common/CoordinateSystem/MentorUtil.h	2010-10-26 22:52:27 UTC (rev 5336)
+++ trunk/MgDev/Common/CoordinateSystem/MentorUtil.h	2010-10-26 23:47:24 UTC (rev 5337)
@@ -101,7 +101,13 @@
 //INT32 value.
 const char * StringFromProjection(INT32 prj);
 
+// Returns true if th indictaed project, via projection key name
+// or projection code, is of the non-earth referenced type.  That
+// is, the projection type is either NERTH or NRTHSRT.
+bool ProjectionIsNerthType (const char *kpStr);
+bool ProjectionIsNerthType (INT32 prjCode);
 
+
 //Returns the MgCoordinateSystemUnitCode value associated with a given unit
 //key name.  Returns MgCoordinateSystemUnitCode::Unknown if it's not a recognized string.
 INT32 UnitFromString(const char *kpStr);

Modified: trunk/MgDev/Common/Geometry/GeometryConsoleTest/GeometryConsoleTest.cpp
===================================================================
--- trunk/MgDev/Common/Geometry/GeometryConsoleTest/GeometryConsoleTest.cpp	2010-10-26 22:52:27 UTC (rev 5336)
+++ trunk/MgDev/Common/Geometry/GeometryConsoleTest/GeometryConsoleTest.cpp	2010-10-26 23:47:24 UTC (rev 5337)
@@ -11,6 +11,89 @@
 
 int _tmain(int argc, _TCHAR* argv[])
 {
+#ifndef __SKIP__
+    // Some Catalog/Dictionary testing and timing.
+    clock_t startTime;
+    clock_t endTime;
+
+    MgCoordinateSystemFactory factory;
+    MgCoordinateSystemCatalog* catalog;
+
+    MgCoordinateSystemCategoryDictionary* categoryDict;
+    MgCoordinateSystemEllipsoidDictionary* ellipsoidDict;
+    MgCoordinateSystemDatumDictionary* datumDict;
+    MgCoordinateSystemDictionary* coordsysDict;
+    MgCoordinateSystemGeodeticTransformDefDictionary* xformDict;
+    MgCoordinateSystemGeodeticPathDictionary* pathDict;
+    
+    MgCoordinateSystemEnum* categoryEnum;
+    MgCoordinateSystemEnum* ellipsoidEnum;
+    MgCoordinateSystemEnum* datumEnum;
+    MgCoordinateSystemEnum* coordsysEnum;
+    MgCoordinateSystemEnum* xformEnum;
+    MgCoordinateSystemEnum* pathEnum;
+
+    MgStringCollection* stringCollection;
+
+    startTime = clock ();
+    catalog = factory.GetCatalog ();
+    categoryDict = catalog->GetCategoryDictionary ();
+    ellipsoidDict = catalog->GetEllipsoidDictionary ();
+    datumDict = catalog->GetDatumDictionary ();
+    coordsysDict = catalog->GetCoordinateSystemDictionary ();
+    xformDict = catalog->GetGeodeticTransformDefDictionary ();
+    pathDict = catalog->GetGeodeticPathDictionary ();
+
+    categoryEnum = categoryDict->GetEnum ();
+    ellipsoidEnum = ellipsoidDict->GetEnum ();
+    datumEnum = datumDict->GetEnum ();
+    coordsysEnum = coordsysDict->GetEnum ();
+    xformEnum = xformDict->GetEnum ();
+    pathEnum = pathDict->GetEnum ();
+
+    do
+    {
+        stringCollection = coordsysEnum->NextName (1);
+        if (stringCollection->GetCount () > 0)
+        {
+            STRING code = stringCollection->GetItem (0);
+            Ptr<MgCoordinateSystem> coordSysPtr = factory.CreateFromCode (code);
+        }
+    } while (stringCollection->GetCount () > 0);
+
+    Ptr<MgCoordinateSystemGeodeticTransformDef> xformDef;
+    xformDef = xformDict->GetGeodeticTransformationDef (L"NAD83_to_HPGN");
+    Ptr<MgCoordinateSystemGeodeticInterpolationTransformDefParams>interpParms;
+    interpParms = static_cast<MgCoordinateSystemGeodeticInterpolationTransformDefParams*>(xformDef->GetParameters ());
+    Ptr<MgDisposableCollection>gridFiles = interpParms->GetGridFiles ();
+    Ptr<MgCoordinateSystemGeodeticTransformGridFile>gridFile;
+    for (INT32 idx = 0;idx < gridFiles->GetCount ();idx += 1)
+    {
+        gridFile = static_cast<MgCoordinateSystemGeodeticTransformGridFile*>(gridFiles->GetItem (idx));
+    }
+
+    endTime = clock ();
+    printf ("Dictionary enumeration time = %ld milliseconds.\n",endTime - startTime);
+#endif
+
+#ifdef __SKIP__
+    // testing a special WKT string for proer operation.
+    clock_t startTime;
+    clock_t endTime;
+
+    MgCoordinateSystemFactory factory;
+
+    wchar_t wktTest [2048] = L"PROJCS[\"UTM83-10F\",GEOGCS[\"LL83\",DATUM[\"NAD83\",SPHEROID[\"GRS1980\",6378137.000,298.25722210]],PRIMEM[\"Greenwich\",0],UNIT[\"Degree\",0.017453292519943295]],PROJECTION[\"Transverse_Mercator\"],PARAMETER[\"false_easting\",1640416.667],PARAMETER[\"false_northing\",0.000],PARAMETER[\"central_meridian\",-123.00000000000000],PARAMETER[\"scale_factor\",0.9996],PARAMETER[\"latitude_of_origin\",0.000],UNIT[\"Foot_US\",0.30480060960122]]";
+    //wchar_t wktTest [2048] = L"PROJCS[\"WGS84.PseudoMercator\",GEOGCS[\"LL84\",DATUM[\"WGS84\",SPHEROID[\"WGS84\",6378137.000,298.25722293]],PRIMEM[\"Greenwich\",0],UNIT[\"Degree\",0.017453292519943295]],PROJECTION[\"Popular Visualisation Pseudo Mercator\"],PARAMETER[\"false_easting\",0.000],PARAMETER[\"false_northing\",0.000],PARAMETER[\"central_meridian\",0.00000000000000],UNIT[\"Meter\",1.00000000000000]]";
+    startTime = clock ();
+    INT32 epsgCode = factory.ConvertWktToEpsgCode (wktTest);
+    endTime = clock ();
+    printf ("ConvertWktToEpsgCode time = %ld milliseconds.\n",endTime - startTime);
+#endif
+
+#ifdef __SKIP__
+    // Test/Debug bed for the MGRS Grid functionality.
+
     INT32 index1;
     INT32 index2;
     INT32 index3;
@@ -21,9 +104,6 @@
     INT32 gridLineCount;
     INT32 lineSegmentCount;
 
-    clock_t startTime;
-    clock_t endTime;
-
     double xx;
     double yy;
     double uu;
@@ -31,13 +111,6 @@
     double value;
 
     MgCoordinateSystemFactory factory;
-    MgCoordinateSystemCatalog* catalog;
-    MgCoordinateSystemCategoryDictionary* categoryDict;
-    MgCoordinateSystemEnum* categoryEnum;
-    MgCoordinateSystemDictionary* coordsysDict;
-    MgCoordinateSystemEnum* coordsysEnum;
-    MgDisposableCollection* coordsysCollection;
-    MgStringCollection* stringCollection;
 
     MgCoordinate* pCoordinate;
     MgCoordinateIterator* coordItr;
@@ -53,32 +126,6 @@
     MgCoordinateSystemGridTick* pGridTick;
     MgCoordinateSystemGridTickCollection* pGridTicks;
 
-startTime = clock ();
-catalog = factory.GetCatalog ();
-categoryDict = catalog->GetCategoryDictionary ();
-categoryEnum = categoryDict->GetEnum ();
-coordsysDict = catalog->GetCoordinateSystemDictionary ();
-coordsysEnum = coordsysDict->GetEnum ();
-do
-{
-    stringCollection = coordsysEnum->NextName (1);
-    if (stringCollection->GetCount () > 0)
-    {
-        STRING code = stringCollection->GetItem (0);
-        Ptr<MgCoordinateSystem> coordSysPtr = factory.CreateFromCode (code);
-    }
-} while (stringCollection->GetCount () > 0);
-endTime = clock ();
-printf ("Dictionary enumeration time = %ld milliseconds.\n",endTime - startTime);
-
-wchar_t wktTest [2048] = L"PROJCS[\"UTM83-10F\",GEOGCS[\"LL83\",DATUM[\"NAD83\",SPHEROID[\"GRS1980\",6378137.000,298.25722210]],PRIMEM[\"Greenwich\",0],UNIT[\"Degree\",0.017453292519943295]],PROJECTION[\"Transverse_Mercator\"],PARAMETER[\"false_easting\",1640416.667],PARAMETER[\"false_northing\",0.000],PARAMETER[\"central_meridian\",-123.00000000000000],PARAMETER[\"scale_factor\",0.9996],PARAMETER[\"latitude_of_origin\",0.000],UNIT[\"Foot_US\",0.30480060960122]]";
-//wchar_t wktTest [2048] = L"PROJCS[\"WGS84.PseudoMercator\",GEOGCS[\"LL84\",DATUM[\"WGS84\",SPHEROID[\"WGS84\",6378137.000,298.25722293]],PRIMEM[\"Greenwich\",0],UNIT[\"Degree\",0.017453292519943295]],PROJECTION[\"Popular Visualisation Pseudo Mercator\"],PARAMETER[\"false_easting\",0.000],PARAMETER[\"false_northing\",0.000],PARAMETER[\"central_meridian\",0.00000000000000],UNIT[\"Meter\",1.00000000000000]]";
-startTime = clock ();
-INT32 epsgCode = factory.ConvertWktToEpsgCode (wktTest);
-endTime = clock ();
-printf ("ConvertWktToEpsgCode time = %ld milliseconds.\n",endTime - startTime);
-exit (0);
-
     pGridSpecification = factory.GridSpecification ();
     pGridSpecification->SetGridBase (0.0,0.0);
     pGridSpecification->SetGridIncrement (1.0,1.0);
@@ -235,6 +282,7 @@
     pMgrs->Release ();
 
     pGridSpecification->Release ();
+#endif 
 
     return 0;
 }



More information about the mapguide-commits mailing list