[mapguide-commits] r5049 - trunk/MgDev/Web/src/HttpHandler

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Thu Jul 22 21:43:33 EDT 2010


Author: liuar
Date: 2010-07-23 01:43:33 +0000 (Fri, 23 Jul 2010)
New Revision: 5049

Modified:
   trunk/MgDev/Web/src/HttpHandler/HttpWmsGetFeatureInfo.cpp
   trunk/MgDev/Web/src/HttpHandler/HttpWmsGetMap.cpp
   trunk/MgDev/Web/src/HttpHandler/OgcWmsServer.cpp
   trunk/MgDev/Web/src/HttpHandler/WmsMapUtil.cpp
   trunk/MgDev/Web/src/HttpHandler/WmsMapUtil.h
Log:
Ticket #1392 OGC WMS 1.3.0 Support

[Motivation]
One significant change in WMS 1.3.0 is the axis orientation. In order to align with the definitions from the EPSG database, OGC WMS 1.3.0 specification reversed the axis sequence for some EPSG code include EPSG:4326. Which means for some EPSG CRS, the meaning of (x,y) is changed from (lon,lat) to (lat,lon) or even other orientations. 

[Implementation]
1) To obtain the axis orientation from a particular EPSG coordinate system, CS team enhances the Mentor_CS library and provides an API named MgCoordinateSystem::GetEpsgQuadrant

2) Because different coordinate system has different axis orientation, the request parameter boundingbox (coord1,coord2,coord3,coord4) may indicate 
different area. Therefore, after getting the quadrant of the EPSG coordinate system, it's necessary for MapGuide to process boundingbox (coord1,coord2,coord3,coord4) to 
the normal format (minX,minY,MaxX,MaxY). There are 3 methods to help handling the boundingbox axes orientation, and these method are implemented as utility 
methods

3) If the required wms version is higher than 1.3.0. then the request parameter boundingbox should be processed at three different places. When the request parameters are initializing in two MgHttpRequestResponseHandler: MgHttpWmsGetMap and MgHttpWmsGetFeatureInfo, and when it's need to validate the "GetMap" request request parameters in MgOgcWmsServer. Note that because the ValidateMapParameters is invoked by ValidateGetFeatureInfoParameters, so it's not necessary for ValidateGetFeatureInfoParameters to process the boundingbox axes.

Modified: trunk/MgDev/Web/src/HttpHandler/HttpWmsGetFeatureInfo.cpp
===================================================================
--- trunk/MgDev/Web/src/HttpHandler/HttpWmsGetFeatureInfo.cpp	2010-07-22 18:06:02 UTC (rev 5048)
+++ trunk/MgDev/Web/src/HttpHandler/HttpWmsGetFeatureInfo.cpp	2010-07-23 01:43:33 UTC (rev 5049)
@@ -77,6 +77,10 @@
 
     // Get the requested bounds
     m_bbox = GetRequestParameter(oServer,MgHttpResourceStrings::reqWmsBbox);
+    if(m_version >= _("1.3.0"))
+    {
+        MgWmsMapUtil::ProcessBoundingBoxAxes(m_crs,m_bbox);
+    }
 
     // Get width and convert to integer
     m_width = GetRequestParameterInt32(oServer,MgHttpResourceStrings::reqWmsWidth);

Modified: trunk/MgDev/Web/src/HttpHandler/HttpWmsGetMap.cpp
===================================================================
--- trunk/MgDev/Web/src/HttpHandler/HttpWmsGetMap.cpp	2010-07-22 18:06:02 UTC (rev 5048)
+++ trunk/MgDev/Web/src/HttpHandler/HttpWmsGetMap.cpp	2010-07-23 01:43:33 UTC (rev 5049)
@@ -100,6 +100,10 @@
     // Get the requested styles
     m_bbox = GetRequestParameter(oServer,MgHttpResourceStrings::reqWmsBbox);
 
+    if(m_version >= _("1.3.0"))
+    {
+        MgWmsMapUtil::ProcessBoundingBoxAxes(m_crs,m_bbox);
+    }
     // Get width and convert to integer
     STRING sParameter;
     sParameter = GetRequestParameter(oServer,MgHttpResourceStrings::reqWmsWidth);

Modified: trunk/MgDev/Web/src/HttpHandler/OgcWmsServer.cpp
===================================================================
--- trunk/MgDev/Web/src/HttpHandler/OgcWmsServer.cpp	2010-07-22 18:06:02 UTC (rev 5048)
+++ trunk/MgDev/Web/src/HttpHandler/OgcWmsServer.cpp	2010-07-23 01:43:33 UTC (rev 5049)
@@ -557,7 +557,18 @@
         }
         else
         {
-            Ptr<MgStringCollection> bboxParams = MgStringCollection::ParseCollection(bbox, _(","));
+            STRING sVersion = RequestParameter(kpszQueryStringVersion);
+            STRING sBBox(bbox);
+            if(sVersion >= _("1.3.0"))
+            {
+                CPSZ crs = RequestParameter(kpszQueryStringCrs);
+                if(crs == NULL || szlen(crs) == 0)
+                {
+                    crs = RequestParameter(kpszQueryStringSrs);
+                }
+                MgWmsMapUtil::ProcessBoundingBoxAxes(crs,sBBox);
+            }
+            Ptr<MgStringCollection> bboxParams = MgStringCollection::ParseCollection(sBBox, _(","));
             if(bboxParams != NULL && bboxParams->GetCount() == 4)
             {
                 double minX = MgUtil::StringToDouble(bboxParams->GetItem(0));

Modified: trunk/MgDev/Web/src/HttpHandler/WmsMapUtil.cpp
===================================================================
--- trunk/MgDev/Web/src/HttpHandler/WmsMapUtil.cpp	2010-07-22 18:06:02 UTC (rev 5048)
+++ trunk/MgDev/Web/src/HttpHandler/WmsMapUtil.cpp	2010-07-23 01:43:33 UTC (rev 5049)
@@ -220,6 +220,83 @@
     return (oWms.MapValue(_("SRS.WKT.map"),sSrs.c_str(),sWkt));
 }
 
+void MgWmsMapUtil::ProcessBoundingBoxAxes(STRING sSrs,REFSTRING bbox)
+{
+    if(sSrs.empty() || bbox.empty())
+        return;
+
+    Ptr<MgCoordinateSystemFactory> factory = new MgCoordinateSystemFactory();
+    STRING wkt = factory->ConvertCoordinateSystemCodeToWkt(sSrs);
+    Ptr<MgCoordinateSystem> cs = factory->Create(wkt);
+
+    INT16 quadrant = cs->GetEpsgQuadrant();
+
+    //X increases to the East,  Y increases to the North 
+    if(0 == quadrant || 1 == quadrant)
+        return;
+
+    Ptr<MgStringCollection> bounds = MgStringCollection::ParseCollection(bbox, L",");
+    if(bounds->GetCount() == 4)
+    {
+        double coords[4];
+        for(INT32 i = 0; i < bounds->GetCount(); i++)
+        {
+            coords[i] = MgUtil::StringToDouble(bounds->GetItem(i));
+        }
+        
+        switch(quadrant)
+        {
+            //X increases to the West,  Y increases to the North
+            case 2: 
+                ReverseCoords(coords[0],coords[2]);
+                break;
+            //X increases to the West,  Y increases to the South
+            case 3:
+                ReverseCoords(coords[0],coords[2]);
+                ReverseCoords(coords[1],coords[3]);
+                break;
+            //X increases to the East,  Y increases to the South
+            case 4:
+                ReverseCoords(coords[1],coords[3]);
+                break;
+            //X increases to the North, Y increases to the East
+            case -1:
+                SwapCoords(coords);
+                break;
+            //X increases to the North, Y increases to the West
+            case -2:
+                SwapCoords(coords);
+                ReverseCoords(coords[0],coords[2]);
+                break;
+            //X increases to the South, Y increases to the West
+            case -3:
+                SwapCoords(coords);
+                ReverseCoords(coords[0],coords[2]);
+                ReverseCoords(coords[1],coords[3]);
+                break;
+            //X increases to the South, Y increases to the East
+            case -4:
+                SwapCoords(coords);
+                ReverseCoords(coords[1],coords[3]);
+                break;
+            //X increases to the East,  Y increases to the North
+            case 1:
+            case 0:
+            default:
+                break;
+        }
+       
+        bbox.clear();
+        for(INT32 i=0;i<4;i++)
+        {
+            STRING doubleStr;
+            MgUtil::DoubleToString(coords[i], doubleStr);
+            bbox.append(doubleStr);
+            if(i != 3)
+                bbox.append(_(","));
+        }
+    }
+}
 /*
 STRING MgWmsMapUtil::SrsToWkt(CREFSTRING srs)
 {
@@ -227,4 +304,19 @@
     return srsMappings[srs];
 }
 */
+void MgWmsMapUtil::SwapCoords(double(& coord)[4])
+{
+    double temp = coord[0];
+    coord[0] = coord[1];
+    coord[1] = temp;
 
+    temp = coord[2];
+    coord[2] = coord[3];
+    coord[3] = temp;
+}
+
+void MgWmsMapUtil::ReverseCoords(double& coord1, double& coord2)
+{
+    coord1 = 0.0- coord1;
+    coord2 = 0.0- coord2;
+}

Modified: trunk/MgDev/Web/src/HttpHandler/WmsMapUtil.h
===================================================================
--- trunk/MgDev/Web/src/HttpHandler/WmsMapUtil.h	2010-07-22 18:06:02 UTC (rev 5048)
+++ trunk/MgDev/Web/src/HttpHandler/WmsMapUtil.h	2010-07-23 01:43:33 UTC (rev 5049)
@@ -41,6 +41,12 @@
     static void SrsToWktMapping(MgOgcServer& oWms,STRING sSrs,REFSTRING sWkt);
     // Converts srs (ostensibly an "EPSG:xxxx" string) into WKT.
     static bool UserDefinedSrsToWktMapping(MgOgcServer& oWms,STRING sSrs,REFSTRING sWkt);
+    // Handle the CRS(SRS) which have their axis orientation changed
+    static void ProcessBoundingBoxAxes(STRING sSrs,REFSTRING bbox);
+    // Help method to swap coordinates in boundingbox
+    static void SwapCoords(double(& coord)[4]);
+    // Help method to make coordinates about-turn
+    static void ReverseCoords(double& coord1, double& coord2);
 };
 
 #endif  // _FS_WMS_MAP_UTIL_H



More information about the mapguide-commits mailing list