[mapguide-commits] r8355 - branches/2.6/MgDev/Server/src/Services/Kml

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Tue Sep 23 23:25:20 PDT 2014


Author: jng
Date: 2014-09-23 23:25:20 -0700 (Tue, 23 Sep 2014)
New Revision: 8355

Modified:
   branches/2.6/MgDev/Server/src/Services/Kml/ServerKmlService.cpp
Log:
#2486: Don't hard-code the WKT of the LL84 coordinate system for KML Service operations. History has shown this WKT string may change (even if slightly). We should use something that will never change (the CS-Map coordinate system code) and use that to create our MgCoordinateSystem objects.

Reviewed by Andy Zhang.

Modified: branches/2.6/MgDev/Server/src/Services/Kml/ServerKmlService.cpp
===================================================================
--- branches/2.6/MgDev/Server/src/Services/Kml/ServerKmlService.cpp	2014-09-24 06:22:24 UTC (rev 8354)
+++ branches/2.6/MgDev/Server/src/Services/Kml/ServerKmlService.cpp	2014-09-24 06:25:20 UTC (rev 8355)
@@ -32,8 +32,7 @@
 //Zip support from DWF toolkit
 #include "dwfcore/ZipFileDescriptor.h"
 
-const STRING LL84_WKT = L"GEOGCS[\"LL84\",DATUM[\"WGS84\",SPHEROID[\"WGS84\",6378137,298.25722293287],TOWGS84[0,0,0,0,0,0,0]],PRIMEM[\"Greenwich\",0],UNIT[\"Degrees\",0.01745329252]]";
-const STRING GOOGLE_EARTH_WKT = LL84_WKT;
+const STRING GOOGLE_EARTH_CS = L"LL84";
 
 IMPLEMENT_CREATE_SERVICE(MgServerKmlService)
 
@@ -103,7 +102,7 @@
         if(!mapWkt.empty())
         {
             Ptr<MgCoordinateSystem> mapCs = (mapWkt.empty()) ? NULL : m_csFactory->Create(mapWkt);
-            Ptr<MgCoordinateSystem> llCs = m_csFactory->Create(GOOGLE_EARTH_WKT);
+            Ptr<MgCoordinateSystem> llCs = m_csFactory->CreateFromCode(GOOGLE_EARTH_CS);
             Ptr<MgCoordinateSystemTransform> trans = m_csFactory->GetTransform(mapCs, llCs);
             trans->IgnoreDatumShiftWarning(true);
             trans->IgnoreOutsideDomainWarning(true);
@@ -159,7 +158,7 @@
     KmlContent kmlContent;
     kmlContent.StartDocument();
     kmlContent.WriteString("<visibility>1</visibility>");
-    Ptr<MgCoordinateSystem> destCs = m_csFactory->Create(GOOGLE_EARTH_WKT);
+    Ptr<MgCoordinateSystem> destCs = m_csFactory->CreateFromCode(GOOGLE_EARTH_CS);
     Ptr<MgEnvelope> destExtent = GetLayerExtent(ldf.get(), destCs);
     if(destExtent != NULL)
     {
@@ -264,7 +263,8 @@
         Ptr<MgUserInformation> userInfo = MgUserInformation::GetCurrentUserInfo();
         siteConn->Open(userInfo);
         Ptr<MgMap> map = new MgMap(siteConn);
-        map->Create(GOOGLE_EARTH_WKT, extents, L"Google Earth Map");
+        STRING mapWkt = m_csFactory->ConvertCoordinateSystemCodeToWkt(GOOGLE_EARTH_CS);
+        map->Create(mapWkt, extents, L"Google Earth Map");
         map->SetDisplayWidth(width);
         map->SetDisplayHeight(height);
         map->SetDisplayDpi((int)dpi);
@@ -465,7 +465,7 @@
                              layer->GetExpandInLegend(),
                             -layer->GetDisplayOrder(),
                              uig);
-    Ptr<MgCoordinateSystem> destCs = m_csFactory->Create(GOOGLE_EARTH_WKT);
+    Ptr<MgCoordinateSystem> destCs = m_csFactory->CreateFromCode(GOOGLE_EARTH_CS);
     double metersPerUnit = (destCs.p != NULL)? destCs->ConvertCoordinateSystemUnitsToMeters(1.0) : 1.0;
 
     Ptr<MgCoordinate> ll = extents->GetLowerLeftCoordinate();
@@ -551,7 +551,7 @@
 
 double MgServerKmlService::GetScale(MgEnvelope* llExtents, int width, int height, double dpi)
 {
-    Ptr<MgCoordinateSystem> destCs = m_csFactory->Create(GOOGLE_EARTH_WKT);
+    Ptr<MgCoordinateSystem> destCs = m_csFactory->CreateFromCode(GOOGLE_EARTH_CS);
     double mapWidth = destCs->ConvertCoordinateSystemUnitsToMeters(llExtents->GetWidth());
     double mapHeight = destCs->ConvertCoordinateSystemUnitsToMeters(llExtents->GetHeight());
     double screenWidth = width / dpi * METERS_PER_INCH;



More information about the mapguide-commits mailing list