[mapguide-commits] r8442 - in trunk/MgDev: Common/MapGuideCommon/Controller Web/src/HttpHandler

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Tue Nov 11 23:23:36 PST 2014


Author: jng
Date: 2014-11-11 23:23:36 -0800 (Tue, 11 Nov 2014)
New Revision: 8442

Modified:
   trunk/MgDev/Common/MapGuideCommon/Controller/Controller.cpp
   trunk/MgDev/Common/MapGuideCommon/Controller/Controller.h
   trunk/MgDev/Common/MapGuideCommon/Controller/DwfController.cpp
   trunk/MgDev/Common/MapGuideCommon/Controller/HtmlController.cpp
   trunk/MgDev/Common/MapGuideCommon/Controller/HtmlController.h
   trunk/MgDev/Web/src/HttpHandler/HttpGetMapImage.cpp
Log:
#2402: Allow SHOWLAYERS, HIDELAYERS, SHOWGROUPS and HIDEGROUPS parameters to work for GETMAPIMAGE when using a Map Definition ID instead of sessionID/mapname

Modified: trunk/MgDev/Common/MapGuideCommon/Controller/Controller.cpp
===================================================================
--- trunk/MgDev/Common/MapGuideCommon/Controller/Controller.cpp	2014-11-11 02:11:07 UTC (rev 8441)
+++ trunk/MgDev/Common/MapGuideCommon/Controller/Controller.cpp	2014-11-12 07:23:36 UTC (rev 8442)
@@ -58,7 +58,7 @@
 //////////////////////////////////////////////////////////////////
 // Apply the specified set of commands to the map.
 //
-void MgController::ApplyMapViewCommands(MgMap* map, MgPropertyCollection* mapViewCommands)
+void MgController::ApplyMapViewCommands(MgMap* map, MgPropertyCollection* mapViewCommands, bool layersAndGroupsAreIds)
 {
     if(mapViewCommands == NULL)
         return;
@@ -265,7 +265,7 @@
                 __LINE__, __WFILE__, &arguments, L"MgInvalidPropertyTypeForCommand", NULL);
         }
 
-        ShowLayers(map, ((MgStringProperty*)((MgProperty*)val))->GetValue(), true);
+        ShowLayers(map, ((MgStringProperty*)((MgProperty*)val))->GetValue(), true, layersAndGroupsAreIds);
     }
 
     //Hide layers
@@ -285,7 +285,7 @@
                 __LINE__, __WFILE__, &arguments, L"MgInvalidPropertyTypeForCommand", NULL);
         }
 
-        ShowLayers(map, ((MgStringProperty*)((MgProperty*)val))->GetValue(), false);
+        ShowLayers(map, ((MgStringProperty*)((MgProperty*)val))->GetValue(), false, layersAndGroupsAreIds);
     }
 
     //Show groups
@@ -305,7 +305,7 @@
                 __LINE__, __WFILE__, &arguments, L"MgInvalidPropertyTypeForCommand", NULL);
         }
 
-        ShowGroups(map, ((MgStringProperty*)((MgProperty*)val))->GetValue(), true);
+        ShowGroups(map, ((MgStringProperty*)((MgProperty*)val))->GetValue(), true, layersAndGroupsAreIds);
     }
 
     //Hide groups
@@ -325,7 +325,7 @@
                 __LINE__, __WFILE__, &arguments, L"MgInvalidPropertyTypeForCommand", NULL);
         }
 
-        ShowGroups(map, ((MgStringProperty*)((MgProperty*)val))->GetValue(), false);
+        ShowGroups(map, ((MgStringProperty*)((MgProperty*)val))->GetValue(), false, layersAndGroupsAreIds);
     }
 
     //Refresh layers - applies only to DwfController
@@ -334,7 +334,7 @@
 //////////////////////////////////////////////////////////////////
 // Show or Hide a set of layers in the specified map.
 //
-void MgController::ShowLayers(MgMap* map, CREFSTRING strLayers, bool show)
+void MgController::ShowLayers(MgMap* map, CREFSTRING strLayers, bool show, bool layersAndGroupsAreIds)
 {
     Ptr<MgStringCollection> layerIds = MgStringCollection::ParseCollection(strLayers, L",");
     if(layerIds != NULL && layerIds->GetCount() > 0)
@@ -342,20 +342,32 @@
         Ptr<MgLayerCollection> layers = map->GetLayers();
         for(INT32 index = 0; index < layerIds->GetCount(); index++)
         {
-            Ptr<MgLayer> layer;
+            Ptr<MgLayerBase> layer;
             STRING id = layerIds->GetItem(index);
-
-            for(INT32 li = 0; li < layers->GetCount(); li++)
+            if (layersAndGroupsAreIds)
             {
-                layer = (MgLayer*)layers->GetItem(li);
-                if(!layer->GetObjectId().compare(id))
+                for(INT32 li = 0; li < layers->GetCount(); li++)
                 {
-                    if (layer->GetLayerType() != MgLayerType::BaseMap)
-                        layer->SetVisible(show);
+                    layer = layers->GetItem(li);
+                    if(!layer->GetObjectId().compare(id))
+                    {
+                        if (layer->GetLayerType() != MgLayerType::BaseMap)
+                            layer->SetVisible(show);
 
-                    break;
+                        break;
+                    }
                 }
             }
+            else
+            {
+                //id is a name in this case
+                INT32 li = layers->IndexOf(id);
+                if (li >= 0)
+                {
+                    layer = layers->GetItem(li);
+                    layer->SetVisible(show);
+                }
+            }
         }
     }
 }
@@ -363,7 +375,7 @@
 //////////////////////////////////////////////////////////////////
 // Show or Hide a set of groups in the specified map.
 //
-void MgController::ShowGroups(MgMap* map, CREFSTRING strGroups, bool show)
+void MgController::ShowGroups(MgMap* map, CREFSTRING strGroups, bool show, bool layersAndGroupsAreIds)
 {
     Ptr<MgStringCollection> groupIds = MgStringCollection::ParseCollection(strGroups, L",");
     if(groupIds != NULL && groupIds->GetCount() > 0)
@@ -373,14 +385,26 @@
         {
             Ptr<MgLayerGroup> group;
             STRING id = groupIds->GetItem(index);
-
-            for(INT32 gi = 0; gi < groups->GetCount(); gi++)
+            if (layersAndGroupsAreIds)
             {
-                group = (MgLayerGroup*)groups->GetItem(gi);
-                if(!group->GetObjectId().compare(id))
+                for(INT32 gi = 0; gi < groups->GetCount(); gi++)
                 {
+                    group = (MgLayerGroup*)groups->GetItem(gi);
+                    if(!group->GetObjectId().compare(id))
+                    {
+                        group->SetVisible(show);
+                        break;
+                    }
+                }
+            }
+            else
+            {
+                //id is a name in this case
+                INT32 gi = groups->IndexOf(id);
+                if (gi >= 0)
+                {
+                    group = groups->GetItem(gi);
                     group->SetVisible(show);
-                    break;
                 }
             }
         }

Modified: trunk/MgDev/Common/MapGuideCommon/Controller/Controller.h
===================================================================
--- trunk/MgDev/Common/MapGuideCommon/Controller/Controller.h	2014-11-11 02:11:07 UTC (rev 8441)
+++ trunk/MgDev/Common/MapGuideCommon/Controller/Controller.h	2014-11-12 07:23:36 UTC (rev 8442)
@@ -83,19 +83,19 @@
     /// \brief
     /// Apply the specified set of commands to a map view.
     ///
-    virtual void ApplyMapViewCommands(MgMap* map, MgPropertyCollection* mapViewCommands);
+    virtual void ApplyMapViewCommands(MgMap* map, MgPropertyCollection* mapViewCommands, bool layersAndGroupsAreIds);
 
     //////////////////////////////////////////////////////////////////
     /// \brief
     /// Show or Hide a set of layers in the specified map.
     ///
-    void ShowLayers(MgMap* map, CREFSTRING strLayers, bool show);
+    void ShowLayers(MgMap* map, CREFSTRING strLayers, bool show, bool layersAndGroupsAreIds);
 
     //////////////////////////////////////////////////////////////////
     /// \brief
     /// Show or Hide a set of groups in the specified map.
     ///
-    void ShowGroups(MgMap* map, CREFSTRING strGroups, bool show);
+    void ShowGroups(MgMap* map, CREFSTRING strGroups, bool show, bool layersAndGroupsAreIds);
 
     //////////////////////////////////////////////////////////////////
     /// \brief

Modified: trunk/MgDev/Common/MapGuideCommon/Controller/DwfController.cpp
===================================================================
--- trunk/MgDev/Common/MapGuideCommon/Controller/DwfController.cpp	2014-11-11 02:11:07 UTC (rev 8441)
+++ trunk/MgDev/Common/MapGuideCommon/Controller/DwfController.cpp	2014-11-12 07:23:36 UTC (rev 8442)
@@ -78,7 +78,7 @@
         return;
 
     //apply commands common to both type of viewers
-    MgController::ApplyMapViewCommands(map, mapViewCommands);
+    MgController::ApplyMapViewCommands(map, mapViewCommands, true);
 
     //apply commands specific to ADV
     Ptr<MgProperty> val;

Modified: trunk/MgDev/Common/MapGuideCommon/Controller/HtmlController.cpp
===================================================================
--- trunk/MgDev/Common/MapGuideCommon/Controller/HtmlController.cpp	2014-11-11 02:11:07 UTC (rev 8441)
+++ trunk/MgDev/Common/MapGuideCommon/Controller/HtmlController.cpp	2014-11-12 07:23:36 UTC (rev 8442)
@@ -60,7 +60,7 @@
     selection->Open(resourceService, mapName);
 
     // Apply map view commands
-    ApplyMapViewCommands(map, mapViewCommands);
+    ApplyMapViewCommands(map, mapViewCommands, true);
 
     // Make sure we clear any track changes - these are not applicable for AJAX.
     map->ClearChanges();
@@ -81,17 +81,17 @@
 MgByteReader* MgHtmlController::GetMapImage(MgMap* map, MgSelection* selection,
     CREFSTRING format, MgPropertyCollection* mapViewCommands, bool bKeepSelection, bool bClip)
 {
-    return GetMapImage(map, selection, format, mapViewCommands, bKeepSelection, bClip, NULL);
+    return GetMapImage(map, selection, format, mapViewCommands, bKeepSelection, bClip, NULL, true);
 }
 
 //////////////////////////////////////////////////////////////////
 // Processes a GetMapImage request from the Viewer and returns an image of the specified map.
 //
 MgByteReader* MgHtmlController::GetMapImage(MgMap* map, MgSelection* selection,
-    CREFSTRING format, MgPropertyCollection* mapViewCommands, bool bKeepSelection, bool bClip, MgColor* selectionColor)
+    CREFSTRING format, MgPropertyCollection* mapViewCommands, bool bKeepSelection, bool bClip, MgColor* selectionColor, bool layersAndGroupsAreIds)
 {
     // Apply map view commands
-    ApplyMapViewCommands(map, mapViewCommands);
+    ApplyMapViewCommands(map, mapViewCommands, layersAndGroupsAreIds);
 
     // Make sure we clear any track changes - these are not applicable for AJAX.
     if (NULL != map)
@@ -118,7 +118,7 @@
     map->Open(resourceService, mapName);
 
     // Apply map view commands
-    ApplyMapViewCommands(map, mapViewCommands);
+    ApplyMapViewCommands(map, mapViewCommands, true);
 
     // Make sure we clear any track changes - these are not applicable for AJAX.
     map->ClearChanges();
@@ -740,13 +740,13 @@
 //////////////////////////////////////////////////////////////////
 // Apply the specified set of commands to the map.
 //
-void MgHtmlController::ApplyMapViewCommands(MgMap* map, MgPropertyCollection* mapViewCommands)
+void MgHtmlController::ApplyMapViewCommands(MgMap* map, MgPropertyCollection* mapViewCommands, bool layersAndGroupsAreIds)
 {
     if(mapViewCommands == NULL)
         return;
 
     //apply commands common to both type of viewers
-    MgController::ApplyMapViewCommands(map, mapViewCommands);
+    MgController::ApplyMapViewCommands(map, mapViewCommands, layersAndGroupsAreIds);
 }
 
 //////////////////////////////////////////////////////////////////

Modified: trunk/MgDev/Common/MapGuideCommon/Controller/HtmlController.h
===================================================================
--- trunk/MgDev/Common/MapGuideCommon/Controller/HtmlController.h	2014-11-11 02:11:07 UTC (rev 8441)
+++ trunk/MgDev/Common/MapGuideCommon/Controller/HtmlController.h	2014-11-12 07:23:36 UTC (rev 8442)
@@ -125,7 +125,8 @@
         MgPropertyCollection* mapViewCommands,
         bool bKeepSelection,
         bool bClip,
-        MgColor* selectionColor);
+        MgColor* selectionColor,
+        bool layersAndGroupsAreIds);
 
     //////////////////////////////////////////////////////////////////
     /// \brief
@@ -298,7 +299,7 @@
     /// \brief
     /// Apply the specified set of commands to a map view.
     ///
-    virtual void ApplyMapViewCommands(MgMap* map, MgPropertyCollection* mapViewCommands);
+    virtual void ApplyMapViewCommands(MgMap* map, MgPropertyCollection* mapViewCommands, bool layersAndGroupsAreIds);
 
     //////////////////////////////////////////////////////////////////
     /// \brief

Modified: trunk/MgDev/Web/src/HttpHandler/HttpGetMapImage.cpp
===================================================================
--- trunk/MgDev/Web/src/HttpHandler/HttpGetMapImage.cpp	2014-11-11 02:11:07 UTC (rev 8441)
+++ trunk/MgDev/Web/src/HttpHandler/HttpGetMapImage.cpp	2014-11-12 07:23:36 UTC (rev 8442)
@@ -88,6 +88,7 @@
     // Create MgMap and selection
     Ptr<MgMap> map = new MgMap();
     Ptr<MgSelection> selection;
+    bool bLayersAndGroupsAreIds = true;
     if (!m_mapName.empty() && !sessionId.empty())
     {
         openedMap = true;
@@ -104,6 +105,7 @@
         map->Create(resourceService, resId, resId->GetName());
 
         // No selection in this case
+        bLayersAndGroupsAreIds = false;
     }
 
     // Get the commands
@@ -124,7 +126,7 @@
         }
     }
 
-    Ptr<MgByteReader> reader = controller.GetMapImage(map, selection, m_mapFormat, commands, m_bKeepSelection, m_bClip, selColor);
+    Ptr<MgByteReader> reader = controller.GetMapImage(map, selection, m_mapFormat, commands, m_bKeepSelection, m_bClip, selColor, bLayersAndGroupsAreIds);
 
     // If we opened the map from the repository then save it back to ensure
     // any track changes are removed from the persisted version, since these



More information about the mapguide-commits mailing list