[mapguide-commits] r7542 - trunk/MgDev/Server/src/Services/Feature

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Thu May 30 01:30:27 PDT 2013


Author: christinebao
Date: 2013-05-30 01:30:27 -0700 (Thu, 30 May 2013)
New Revision: 7542

Modified:
   trunk/MgDev/Server/src/Services/Feature/ServerFeatureService.cpp
Log:
#2258: Serve WFS in alternate CS: SRSNAME not respected in getfeature, alternate SRS not available
- If there is no coordinate system pass in, get the primary SRS in resource header.

Modified: trunk/MgDev/Server/src/Services/Feature/ServerFeatureService.cpp
===================================================================
--- trunk/MgDev/Server/src/Services/Feature/ServerFeatureService.cpp	2013-05-30 07:13:22 UTC (rev 7541)
+++ trunk/MgDev/Server/src/Services/Feature/ServerFeatureService.cpp	2013-05-30 08:30:27 UTC (rev 7542)
@@ -1827,8 +1827,39 @@
     }
 
     MgCoordinateSystemFactory fact;
-    Ptr<MgCoordinateSystem> mapCs = (srs.empty()) ? NULL : fact.Create(srs);
+    std::wstring wkt = srs;
+    if (wkt.empty())
+    {
+        //If there is no coordinate system pass in, get the default one in resource header.
+        MgServiceManager* serviceMan = MgServiceManager::GetInstance();
+        assert(NULL != serviceMan);
+        Ptr<MgResourceService> resourceService = dynamic_cast<MgResourceService*>(serviceMan->RequestService(MgServiceType::ResourceService));
+        assert(resourceService != NULL);
+        Ptr<MgByteReader> byteReaderHeader = resourceService->GetResourceHeader(fs);
+        Ptr<MgByteSink> byteSinkHeader = new MgByteSink(byteReaderHeader);
+        std::string resourceHeader;
+        byteSinkHeader->ToStringUtf8(resourceHeader);
+        //parse for default SRS of this WFS, the format is:
+        //<Property xsi:noNamespaceSchemaLocation="Property-1.0.0.xsd">
+        //  <Name>_PrimarySRS</Name>
+        //  <Value>EPSG:4326</Value>
+        //</Property>
+        std::string begin("EPSG:");
+        std::size_t beginPos = resourceHeader.find(begin);
+        if (beginPos != std::string::npos)
+        {
+            std::size_t endPos = resourceHeader.find("</Value>", beginPos);
+            if (endPos != std::string::npos)
+            {
+                std::string primarySRS = resourceHeader.substr(beginPos+begin.length(), endPos-beginPos-begin.length());
+                int epsgCode = atoi(primarySRS.c_str());
+                wkt = fact.ConvertEpsgCodeToWkt(epsgCode);
+            }
+        }
+    }
 
+    Ptr<MgCoordinateSystem> mapCs = (wkt.empty()) ? NULL : fact.Create(wkt);
+
     //get a transform from feature space to mapping space
     TransformCache* item = TransformCache::GetLayerToMapTransform(transformCache, lfeatureName, fs, mapCs, &fact, this);
     Ptr<MgCoordinateSystemTransform> trans = item? item->GetMgTransform() : NULL;



More information about the mapguide-commits mailing list