[mapguide-commits] r8295 - in trunk/MgDev: . Server/src/Services/Rendering Web/src/HttpHandler Web/src/viewerfiles

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Wed Jul 9 05:48:46 PDT 2014


Author: jng
Date: 2014-07-09 05:48:46 -0700 (Wed, 09 Jul 2014)
New Revision: 8295

Modified:
   trunk/MgDev/
   trunk/MgDev/Server/src/Services/Rendering/ServerRenderingService.cpp
   trunk/MgDev/Web/src/HttpHandler/HttpQueryMapFeatures.cpp
   trunk/MgDev/Web/src/viewerfiles/
   trunk/MgDev/Web/src/viewerfiles/ajaxmappane.templ
Log:
Merged revision(s) 8288 from branches/2.6/MgDev:
#2464: Fix QUERYMAPFEATURES for when the input is not geometry, but selection XML:
 - Make the GEOMETRY parameter optional. Don't attempt to parse an MgGeometry if there's nothing there. This allows selection XML to be passed without specifying a filter geometry WKT text.
 - Small refactor of MgServerRenderingService::RenderForSelection(). Before this change, there were several local variables with the same name but declared under different blocks, which may explain why the input selection XML passed was not reflected in the feature attributes and selection image rendered back.
 - Update the SetSelectionXML() viewer API to invoke QUERYMAPFEATURES directly with the correct parameters instead of going through the setselection helper script. That script is now redundant and will be removed in a future submission.
........



Property changes on: trunk/MgDev
___________________________________________________________________
Modified: svn:mergeinfo
   - /branches/2.4/MgDev:6749-6756,6777-6783,6785-6787,6789,6791-6794,6796-6801,6954-6962,6986-7006
/branches/2.6/MgDev:8276-8286
/sandbox/jng/convenience_apis:8263
/sandbox/jng/createruntimemap:7486-7555
/sandbox/jng/v30:8212,8214,8217,8220-8221,8223-8225
/sandbox/rfc94:5099-5163
   + /branches/2.4/MgDev:6749-6756,6777-6783,6785-6787,6789,6791-6794,6796-6801,6954-6962,6986-7006
/branches/2.6/MgDev:8276-8286,8288
/sandbox/jng/convenience_apis:8263
/sandbox/jng/createruntimemap:7486-7555
/sandbox/jng/v30:8212,8214,8217,8220-8221,8223-8225
/sandbox/rfc94:5099-5163

Modified: trunk/MgDev/Server/src/Services/Rendering/ServerRenderingService.cpp
===================================================================
--- trunk/MgDev/Server/src/Services/Rendering/ServerRenderingService.cpp	2014-07-09 12:46:45 UTC (rev 8294)
+++ trunk/MgDev/Server/src/Services/Rendering/ServerRenderingService.cpp	2014-07-09 12:48:46 UTC (rev 8295)
@@ -1260,6 +1260,15 @@
     bool bOnlyVisibleLayers = !((layerAttributeFilter & FILTER_VISIBLE) == 0);
     bool bOnlyTooltipLayers = !((layerAttributeFilter & FILTER_HASTOOLTIPS) == 0);
 
+    //If feature filter was passed in, init a temp MgSelection from so we can build layer filters
+    Ptr<MgSelection> selectionFilter;
+    Ptr<MgReadOnlyLayerCollection> selLayers;
+    if (!featureFilter.empty())
+    {
+        selectionFilter = new MgSelection(map, featureFilter);
+        selLayers = selectionFilter->GetLayers();
+    }
+
     //iterate over all map layers, but only do selection
     //if the layer is in the passed in collection
     for (int p=0; p<layers->GetCount(); p++)
@@ -1291,6 +1300,32 @@
                 continue;
         }
 
+        //If we have an initialized temp MgSelection, the current layer must be in it as well
+        Ptr<MgLayerBase> selLayer;
+        if (NULL != selLayers.p)
+        {
+            //It'd be nice if MgReadOnlyLayerCollection was indexable/accessible by layer name, but 
+            //it's not. So linear search for the currently looped layer here so we can apply the correct
+            //FDO filter for it later on
+            //
+            //TODO: As a future improvement, the code should be looping on this layer collection instead
+            //of the map's one if a feature filter is passed.
+            for (INT32 s = 0; s < selLayers->GetCount(); s++)
+            {
+                selLayer = selLayers->GetItem(s);
+                //If layer found, break so that the assigned layer remains for the code below
+                if (selLayer->GetName() == layer->GetName())
+                {
+                    break;
+                }
+                //Otherwise, null it so the check below will work if we've reached the end
+                selLayer = NULL;
+            }
+            //Current layer is not in this selection, so skip it
+            if (NULL == selLayer.p)
+                continue;
+        }
+
         //have we processed enough features already?
         if (maxFeatures <= 0)
             break;
@@ -1357,21 +1392,13 @@
 
             try
             {
-                if (!featureFilter.empty())
+                //Set the feature filter, if any
+                if (NULL != selLayer.p)
                 {
-                    //set the feature filter, if any
-                    MgSelection selectionFilter(map, featureFilter);
-                    Ptr<MgReadOnlyLayerCollection> layers = selectionFilter.GetLayers();
-                    if (layers != NULL)
-                    {
-                        for (int i = 0; i < layers->GetCount(); i++)
-                        {
-                            Ptr<MgLayerBase> layer = layers->GetItem(i);
-                            STRING className = layer->GetFeatureClassName();
-                            STRING filter = selectionFilter.GenerateFilter(layer, className);
-                            options->SetFilter(filter);
-                        }
-                    }
+                    STRING className = selLayer->GetFeatureClassName();
+                    STRING filter = selectionFilter->GenerateFilter(selLayer, className);
+                    ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%t) Set filter for class (%W):\n%W\n\n"), className.c_str(), filter.c_str()));
+                    options->SetFilter(filter);
                 }
                 else if (!vl->GetFilter().empty())
                 {

Modified: trunk/MgDev/Web/src/HttpHandler/HttpQueryMapFeatures.cpp
===================================================================
--- trunk/MgDev/Web/src/HttpHandler/HttpQueryMapFeatures.cpp	2014-07-09 12:46:45 UTC (rev 8294)
+++ trunk/MgDev/Web/src/HttpHandler/HttpQueryMapFeatures.cpp	2014-07-09 12:48:46 UTC (rev 8295)
@@ -102,10 +102,14 @@
     // Create the list of layers to include in the selection
     Ptr<MgStringCollection> layerNames = MgStringCollection::ParseCollection(m_layerNames, L",");
 
-    // Create the selection geometry
-    MgWktReaderWriter wktReader;
-    Ptr<MgGeometry> filterGeometry = wktReader.Read(m_geometry);
-
+    // Create the selection geometry if specified, otherwise we assume this query is driven by XML selection
+    // string that we assume will be provided (server will check for this)
+    Ptr<MgGeometry> filterGeometry;
+    if (!m_geometry.empty())
+    {
+        MgWktReaderWriter wktReader;
+        filterGeometry = wktReader.Read(m_geometry);
+    }
     // Create the selection variant
     INT32 selectionVariant = 0;
     if(m_selectionVariant.length() > 0)


Property changes on: trunk/MgDev/Web/src/viewerfiles
___________________________________________________________________
Modified: svn:mergeinfo
   - /branches/2.4/MgDev/Web/src/viewerfiles:6738-6741,6749-6756,6777-6783,6785-6787,6789,6791-6794,6796-6801,6954-6962,6986-7006
/sandbox/adsk/2.2gp/Web/src/viewerfiles:5392
/sandbox/jng/createruntimemap/Web/src/viewerfiles:7486-7555
   + /branches/2.4/MgDev/Web/src/viewerfiles:6738-6741,6749-6756,6777-6783,6785-6787,6789,6791-6794,6796-6801,6954-6962,6986-7006
/branches/2.6/MgDev/Web/src/viewerfiles:8288
/sandbox/adsk/2.2gp/Web/src/viewerfiles:5392
/sandbox/jng/createruntimemap/Web/src/viewerfiles:7486-7555

Modified: trunk/MgDev/Web/src/viewerfiles/ajaxmappane.templ
===================================================================
--- trunk/MgDev/Web/src/viewerfiles/ajaxmappane.templ	2014-07-09 12:46:45 UTC (rev 8294)
+++ trunk/MgDev/Web/src/viewerfiles/ajaxmappane.templ	2014-07-09 12:48:46 UTC (rev 8295)
@@ -430,9 +430,7 @@
 function SetSelectionXML(xmlSet)
 {
     xmlOut = SetSelection(xmlSet, true);
-    xmlDoc = (new DOMParser()).parseFromString(xmlSet, "text/xml");
-    ProcessFeatureInfo(xmlDoc.documentElement, false, 1);
-    ProcessFeatureInfo(xmlOut, false, 2);
+    ProcessFeatureInfo(xmlOut, false, 1 | 2);
 }
 
 function IsEnglishUnits()
@@ -3264,13 +3262,37 @@
 
 function SetSelection(selText, requery)
 {
-    var reqParams = "SESSION=" + sessionId + "&MAPNAME=" + encodeURIComponent(mapName) + "&SEQ=" + Math.random() + "&SELECTION=" + encodeURIComponent(selText) + "&QUERYINFO=" + (requery? "1": "0");
-    reqHandler = CreateRequestHandler();
-    reqHandler.open("POST", setSelScript, false);
-    reqHandler.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
-    reqHandler.send(reqParams);
-    if(requery)
-        return reqHandler.responseXML;
+    var reqData = 0;
+    //We use the same QUERYMAPFEATURES operation for selection persistence, but omit filter geometry 
+    //and layer names as the selection XML string will drive all of that
+    var reqParams = "OPERATION=QUERYMAPFEATURES&VERSION=2.6.0&PERSIST=1&MAXFEATURES=-1&MAPNAME=" + encodeURIComponent(mapName) + "&SESSION=" + sessionId + "&SEQ=" + Math.random();
+    reqParams += "&CLIENTAGENT=" + encodeURIComponent(clientAgent);
+    reqParams += "&LAYERATTRIBUTEFILTER=0"; //0 = Everything
+    if (requery)
+    {
+        reqData |= 1; //attributes
+        if (msie8plus || !msie)
+            reqData |= 2; //inline selection
+        reqParams += "&SELECTIONCOLOR=" + selectionColor + "&SELECTIONFORMAT=" + selectionImgFormat;
+    }
+    else
+    {
+        //Even though we don't care about the return value, we still have to supply something for REQUESTDATA, so 
+        //request for the smallest piece of data possible: Hyperlinks or Tooltips. This value is for hyperlinks.
+        reqData |= 8;
+    }
+    reqParams += "&REQUESTDATA=" + reqData;
+    //Despite the deceptive name, FEATUREFILTER is for any XML selection string you want to drive the whole
+    //query from, when not specifying input geometry
+    reqParams += "&FEATUREFILTER=" + encodeURIComponent(selText);
+    
+    var selRequest = CreateRequestHandler();
+    selRequest.open("POST", webAgent, false);
+    selRequest.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
+    selRequest.send(reqParams);
+    
+    if (requery)
+        return selRequest.responseXML;
 }
 
 function ZoomSelection()



More information about the mapguide-commits mailing list