[mapguide-commits] r1053 - in trunk/MgDev: Common/MapGuideCommon/Controller Common/MapGuideCommon/MapLayer Server/src/Services/Mapping

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Tue Jan 16 08:57:15 EST 2007


Author: waltweltonlair
Date: 2007-01-16 08:57:15 -0500 (Tue, 16 Jan 2007)
New Revision: 1053

Modified:
   trunk/MgDev/Common/MapGuideCommon/Controller/Controller.cpp
   trunk/MgDev/Common/MapGuideCommon/Controller/DwfController.cpp
   trunk/MgDev/Common/MapGuideCommon/MapLayer/Map.cpp
   trunk/MgDev/Server/src/Services/Mapping/StylizationUtil.cpp
Log:
A server-side bug was preventing the DWF Viewer from getting properly refreshed after
panning the view.  The DWF Viewer was including the updated map center and data extent
with the GetMapUpdate request, and the MgMap's layer refresh mode was getting properly
set to refreshAll in the agent.  But when the MgMap was serialized to send to the server
the refresh information was getting lost.

In PackLayersAndGroups, the layer refresh mode is processed, but only if there are
layers in the MgMap.  Due to optimzations that were done a while back, layers are now
only loaded on demand.  In the DWF Viewer case of panning the view they are not loaded,
and therefore PackLayersAndGroups was not processing the refresh mode (it was not
setting the refresh flag on the individual layers).  When the server generated the
update nothing was returned because all the layer refresh flags were false.

The fix which preserves the lazy loading of layers is to serialize the layer refresh
mode with the MgMap, and update the server refresh logic to also take into account
this mode.  Because it's serialized with the MgMap we also no longer have to process
it in PackLayersAndGroups.

With these updates in place I was also able to optimize some more cases.  When the
scale was getting set as part of a map-view-command the code was getting the layers
and setting the ForceRefresh flag on each one to true.  Now it simply needs to set
the layer refresh mode on the map to refreshAll.  This optimization applies to both
DWF and AJAX Viewers.  Same thing when specifying a refresh of the map in the DWF
Viewer (REFRESHLAYERS = "*").  No need to iterate over all layers.


Modified: trunk/MgDev/Common/MapGuideCommon/Controller/Controller.cpp
===================================================================
--- trunk/MgDev/Common/MapGuideCommon/Controller/Controller.cpp	2007-01-16 11:42:47 UTC (rev 1052)
+++ trunk/MgDev/Common/MapGuideCommon/Controller/Controller.cpp	2007-01-16 13:57:15 UTC (rev 1053)
@@ -149,12 +149,7 @@
         map->SetViewScale(scale);
 
         //refresh all layers that are visible
-        Ptr<MgLayerCollection> layers = map->GetLayers();
-        for(int layerIndex = 0; layerIndex < layers->GetCount(); layerIndex++)
-        {
-            Ptr<MgLayerBase> layer = layers->GetItem(layerIndex);
-            layer->ForceRefresh(true);
-        }
+        map->SetLayerRefreshMode(MgMap::refreshAll);
     }
 
     //Set display dpi

Modified: trunk/MgDev/Common/MapGuideCommon/Controller/DwfController.cpp
===================================================================
--- trunk/MgDev/Common/MapGuideCommon/Controller/DwfController.cpp	2007-01-16 11:42:47 UTC (rev 1052)
+++ trunk/MgDev/Common/MapGuideCommon/Controller/DwfController.cpp	2007-01-16 13:57:15 UTC (rev 1053)
@@ -193,19 +193,21 @@
             if(layerIds != NULL && layerIds->GetCount() > 0)
             {
                 bool forceAll = (layerIds->GetCount() == 1) && (layerIds->GetItem(0) == L"*");
-
-                Ptr<MgLayerCollection> layers = map->GetLayers();
-                for(INT32 index = 0; index < layerIds->GetCount(); index++)
+                if (forceAll)
                 {
-                    Ptr<MgLayer> layer;
-                    for(INT32 li = 0; li < layers->GetCount(); li++)
+                    map->SetLayerRefreshMode(MgMap::refreshAll);
+                }
+                else
+                {
+                    Ptr<MgLayerCollection> layers = map->GetLayers();
+                    for(INT32 index = 0; index < layerIds->GetCount(); index++)
                     {
-                        layer = (MgLayer*)layers->GetItem(li);
-                        if(forceAll)
-                            layer->ForceRefresh(true);
-                        else
+                        STRING id = layerIds->GetItem(index);
+
+                        Ptr<MgLayerBase> layer;
+                        for(INT32 li = 0; li < layers->GetCount(); li++)
                         {
-                            STRING id = layerIds->GetItem(index);
+                            layer = layers->GetItem(li);
                             if(!layer->GetObjectId().compare(id))
                             {
                                 layer->ForceRefresh(true);
@@ -213,8 +215,6 @@
                             }
                         }
                     }
-                    if(forceAll)
-                        break;
                 }
             }
         }

Modified: trunk/MgDev/Common/MapGuideCommon/MapLayer/Map.cpp
===================================================================
--- trunk/MgDev/Common/MapGuideCommon/MapLayer/Map.cpp	2007-01-16 11:42:47 UTC (rev 1052)
+++ trunk/MgDev/Common/MapGuideCommon/MapLayer/Map.cpp	2007-01-16 13:57:15 UTC (rev 1053)
@@ -43,7 +43,7 @@
 // This method is used for Mg Viewers or for offline map production.
 //
 void MgMap::Create(MgResourceService* resourceService, MgResourceIdentifier* mapDefinition, CREFSTRING mapName)
-{    
+{
     MG_TRY()
 
     m_trackChangesDisabled = true;
@@ -465,7 +465,7 @@
 /// If none of the collections contain data then they are assumed to be unchanged.
 ///
 /// The same applies to the Save.  If the collections do not contain data then they
-/// will not be saved. 
+/// will not be saved.
 ///
 void MgMap::UnpackLayersAndGroups()
 {
@@ -484,7 +484,7 @@
         if (NULL != (MgResourceService*) m_resourceService)
         {
             Ptr<MgByteReader> breader = m_resourceService->GetResourceData(m_resId, m_layerGroupTag);
-   
+
             MgByteSink sink(breader);
             bytes = sink.ToBuffer();
             m_layerGroupHelper = new MgMemoryStreamHelper((INT8*) bytes->Bytes(), bytes->GetLength(), false);
@@ -539,7 +539,7 @@
     m_changeLists->SetCheckForDuplicates(true);
 
     //groups
-    //this maps speeds up the process of attaching groups together and attaching layers to groups
+    //this map speeds up the process of attaching groups together and attaching layers to groups
     map<STRING, MgLayerGroup*> knownGroups;
 
     map<STRING, MgLayerGroup*>::const_iterator itKg;
@@ -651,19 +651,9 @@
     //layers
     INT32 layerCount = m_layers->GetCount();
     stream->WriteInt32(layerCount);
-
     for(int layerIndex = 0; layerIndex < layerCount; layerIndex++)
     {
         Ptr<MgLayerBase> layer = m_layers->GetItem(layerIndex);
-        //if the refresh flag must be globally set or reset, do it for this layer
-        //before it's serialized
-        if(m_layerRefreshMode != unspecified)
-        {
-            if(m_layerRefreshMode == refreshNone)
-                layer->ForceRefresh(false);
-            else
-                layer->ForceRefresh(true);
-        }
 
         Ptr<MgLayerGroup> parent = layer->GetGroup();
         stream->WriteString(parent != NULL? parent->GetName(): L"");
@@ -714,6 +704,8 @@
     stream->WriteString(m_backColor);
     //meters per unit
     stream->WriteDouble(m_metersPerUnit);
+    //layer refresh mode
+    stream->WriteInt32((INT32)m_layerRefreshMode);
 
     //finite display scales
     INT32 scaleCount = (INT32)m_finiteDisplayScales.size();
@@ -785,6 +777,8 @@
     streamReader->GetString(m_backColor);
     //meters per unit
     streamReader->GetDouble(m_metersPerUnit);
+    //layer refresh mode
+    streamReader->GetInt32((INT32&)m_layerRefreshMode);
 
     //finite display scales
     INT32 scaleCount;
@@ -796,7 +790,6 @@
         m_finiteDisplayScales.push_back(displayScale);
     }
 
-       
     INT32 nBytes = 0;
     streamReader->GetInt32(nBytes);
     m_layerGroupHelper = NULL;

Modified: trunk/MgDev/Server/src/Services/Mapping/StylizationUtil.cpp
===================================================================
--- trunk/MgDev/Server/src/Services/Mapping/StylizationUtil.cpp	2007-01-16 11:42:47 UTC (rev 1052)
+++ trunk/MgDev/Server/src/Services/Mapping/StylizationUtil.cpp	2007-01-16 13:57:15 UTC (rev 1053)
@@ -252,7 +252,7 @@
     }
 
 #ifdef _DEBUG
-    printf("  ExecuteFeatureQuery() total time = %6.4f (s)\n", (GetTickCount()-dwStart)/1000.0); 
+    printf("  ExecuteFeatureQuery() total time = %6.4f (s)\n", (GetTickCount()-dwStart)/1000.0);
 #endif
 
     return SAFE_ADDREF(rdr.p);
@@ -422,11 +422,23 @@
         #endif
 
         //don't send data if layer is not currently visible
-        if (!mapLayer->IsVisibleAtScale(scale)) continue;
+        if (!mapLayer->IsVisibleAtScale(scale))
+            continue;
 
         //don't send data if the refresh flag is not set
-        if (checkRefreshFlag && !mapLayer->NeedsRefresh()) continue;
+        if (checkRefreshFlag)
+        {
+            bool needsRefresh = false;
+            MgMapBase::LayerRefreshMode refreshMode = map->GetLayerRefreshMode();
+            if (refreshMode == MgMapBase::unspecified)
+                needsRefresh = mapLayer->NeedsRefresh();
+            else
+                needsRefresh = (refreshMode == MgMapBase::refreshAll);
 
+            if (!needsRefresh)
+                continue;
+        }
+
         MG_SERVER_MAPPING_SERVICE_TRY()
 
             //get layer definition
@@ -574,7 +586,7 @@
                     }
                     else
                     {
-                        // No coordinate system!!! 
+                        // No coordinate system!!!
                         // We fail here and do not use a default
                     }
 
@@ -858,7 +870,7 @@
                     }
                     else
                     {
-                        // No coordinate system!!! 
+                        // No coordinate system!!!
                         // We fail here and do not use a default
                     }
 
@@ -946,14 +958,14 @@
                     size_t i0 = st.find(L"<CoordinateSpace>");
                     size_t i1 = st.find(L"</CoordinateSpace>");
 
-                    if (   i0 != STRING::npos 
+                    if (   i0 != STRING::npos
                         && i1 != STRING::npos)
                     {
                         i0 += wcslen(L"<CoordinateSpace>");
                         STRING cs = st.substr(i0, i1 - i0);
 
                         if (!cs.empty() && cs != dstCs->ToString())
-                        {             
+                        {
                             //construct cs transformer if needed
                             Ptr<MgCoordinateSystem> srcCs = csFactory->Create(cs);
                             xformer = new MgCSTrans(srcCs, dstCs);
@@ -976,7 +988,7 @@
         MG_SERVER_MAPPING_SERVICE_CATCH(L"MgStylizationUtil.StylizeLayers");
         if (mgException.p)
         {
-            // TODO: Eventually this should be used to indicate visually to the client what 
+            // TODO: Eventually this should be used to indicate visually to the client what
             //       layer failed in addition to logging the error.
             MgServerManager* serverManager = MgServerManager::GetInstance();
             STRING locale = (NULL == serverManager) ?  MgResources::DefaultLocale : serverManager->GetDefaultLocale();



More information about the mapguide-commits mailing list