[mapguide-commits] r6023 - trunk/MgDev/Server/src/Services/Mapping

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Wed Aug 3 02:11:06 EDT 2011


Author: hubu
Date: 2011-08-02 23:11:06 -0700 (Tue, 02 Aug 2011)
New Revision: 6023

Modified:
   trunk/MgDev/Server/src/Services/Mapping/LegendPlotUtil.cpp
   trunk/MgDev/Server/src/Services/Mapping/MappingUtil.cpp
Log:
Fix ticket  http://trac.osgeo.org/mapguide/ticket/1069
The new server API GetResourceContents() is used to reduce the request between web and server. However in server internal, we shouldn't invoke this API to get resource contents. There are overhead to prepare the layerIds and to get the these contents. You can see ImprovePerformance.patch, in MappingUtil.cpp/LegendUtil.cpp, there are some for statements are introduced. This will decline the performance.
This changeset revert the revision #4191

Modified: trunk/MgDev/Server/src/Services/Mapping/LegendPlotUtil.cpp
===================================================================
--- trunk/MgDev/Server/src/Services/Mapping/LegendPlotUtil.cpp	2011-08-01 14:33:58 UTC (rev 6022)
+++ trunk/MgDev/Server/src/Services/Mapping/LegendPlotUtil.cpp	2011-08-03 06:11:06 UTC (rev 6023)
@@ -256,7 +256,6 @@
 
     // build the list of layers that need to be processed
     Ptr<MgLayerCollection> layers = map->GetLayers();
-    Ptr<MgStringCollection> layerIds = new MgStringCollection();
     for (int i = 0; i < layers->GetCount(); i++)
     {
         Ptr<MgLayerBase> mapLayer = layers->GetItem(i);
@@ -276,56 +275,9 @@
         if (!bRequiredInLegend)
             continue;
 
-        Ptr<MgResourceIdentifier> layerId = mapLayer->GetLayerDefinition();
-        layerIds->Add(layerId->ToString());
-    }
+        Ptr<MgResourceIdentifier> layerid = mapLayer->GetLayerDefinition();
+        auto_ptr<MdfModel::LayerDefinition> ldf(MgLayerBase::GetLayerDefinition(m_svcResource, layerid));
 
-    // get resource data
-    if (layerIds->GetCount() != 0)
-    {
-        Ptr<MgStringCollection> layerContents = m_svcResource->GetResourceContents(layerIds, NULL);
-        for (int i = 0; i < layerIds->GetCount(); i++)
-        {
-            for (int j = 0; j < layers->GetCount(); j++)
-            {
-                Ptr<MgLayerBase> mapLayer = layers->GetItem(j);
-                Ptr<MgResourceIdentifier> layerId = mapLayer->GetLayerDefinition();
-                if (layerId->ToString() == layerIds->GetItem(i))
-                {
-                    mapLayer->SetLayerResourceContent(layerContents->GetItem(i));
-                    break;
-                }
-            }
-        }
-    }
-
-    // process the layers
-    for (int i = 0; i < layers->GetCount(); i++)
-    {
-        Ptr<MgLayerBase> mapLayer = layers->GetItem(i);
-
-        // layer is not currently visible -- don't add to legend
-        if (!mapLayer->IsVisible())
-            continue;
-
-        Ptr<MgLayerGroup> group = mapLayer->GetGroup();
-
-        bool bRequiredInLegend = false;
-        if (group == NULL && mggroup == NULL)
-            bRequiredInLegend = true;
-        else if (group.p && mggroup && group->GetObjectId() == mggroup->GetObjectId())
-            bRequiredInLegend = true;
-
-        if (!bRequiredInLegend)
-            continue;
-
-        STRING content = mapLayer->GetLayerResourceContent();
-        if (content.empty())
-            continue;
-
-        // get layer definition
-        auto_ptr<MdfModel::LayerDefinition> ldf(MgLayerBase::GetLayerDefinition(content));
-
         // Get bitmaps for rules/themes
         MdfModel::VectorLayerDefinition* vl = dynamic_cast<MdfModel::VectorLayerDefinition*>(ldf.get());
         MdfModel::DrawingLayerDefinition* dl = dynamic_cast<MdfModel::DrawingLayerDefinition*>(ldf.get());

Modified: trunk/MgDev/Server/src/Services/Mapping/MappingUtil.cpp
===================================================================
--- trunk/MgDev/Server/src/Services/Mapping/MappingUtil.cpp	2011-08-01 14:33:58 UTC (rev 6022)
+++ trunk/MgDev/Server/src/Services/Mapping/MappingUtil.cpp	2011-08-03 06:11:06 UTC (rev 6023)
@@ -375,10 +375,12 @@
     // stylization operation.
     TransformCacheMap transformCache;
 
-    Ptr<MgStringCollection> layerIds = new MgStringCollection();
     // Get the layers' resource content in a single request by adding them to a collection
     for (int i = layers->GetCount()-1; i >= 0; i--)
     {
+        auto_ptr<MdfModel::LayerDefinition> ldf;
+        RSMgFeatureReader* rsReader = NULL;
+
         Ptr<MgLayerBase> mapLayer = layers->GetItem(i);
 
         //don't send data if layer is not currently visible
@@ -399,55 +401,26 @@
                 continue;
         }
 
-        Ptr<MgResourceIdentifier> mapLayerId = mapLayer->GetLayerDefinition();
-        layerIds->Add(mapLayerId->ToString());
-    }
 
-    // request the collection from resource service and add ResourceContent to the individual layers
-    if(layerIds->GetCount() != 0)
-    {
-        Ptr<MgStringCollection> layerContents = svcResource->GetResourceContents(layerIds, NULL);
-        for(int i = 0; i < layerIds->GetCount(); i ++)
-        {
-            for(int j = 0; j < layers->GetCount(); j ++)
-            {
-                Ptr<MgLayerBase> mapLayer = layers->GetItem(j);
-                Ptr<MgResourceIdentifier> mapLayerId = mapLayer->GetLayerDefinition();
-                if(mapLayerId->ToString() == layerIds->GetItem(i))
-                {
-                    mapLayer->SetLayerResourceContent(layerContents->GetItem(i));
-                    break;
-                }
-            }
-        }
-    }
-
-    // cycle over the layers and do stylization
-    for (int i = layers->GetCount()-1; i >= 0; i--)
-    {
-        auto_ptr<MdfModel::LayerDefinition> ldf;
-        RSMgFeatureReader* rsReader = NULL;
-
-        Ptr<MgLayerBase> mapLayer = layers->GetItem(i);
-
         #ifdef _DEBUG
         long dwLayerStart = GetTickCount();
         ACE_DEBUG((LM_INFO, L"(%t)  StylizeLayers(%d) **LAYERSTART** Name:%W  VAS:%W\n", i, (mapLayer->GetName()).c_str(), mapLayer->IsVisibleAtScale(scale)? L"True" : L"False"));
         #endif
 
-        if(mapLayer->GetLayerResourceContent() == L"")
-            continue;
 
+
         MG_SERVER_MAPPING_SERVICE_TRY()
 
-            // get layer definition using SAX XML Parser
-            ldf.reset(MgLayerBase::GetLayerDefinition(mapLayer->GetLayerResourceContent()));
 
+            //get layer definition
+            Ptr<MgResourceIdentifier> layerid = mapLayer->GetLayerDefinition();
+            ldf.reset(MgLayerBase::GetLayerDefinition(svcResource, layerid));
+
             Ptr<MgLayerGroup> group = mapLayer->GetGroup();
 
             MgLogDetail logDetail(MgServiceType::MappingService, MgLogDetail::InternalTrace, L"MgMappingUtil.StylizeLayers", mgStackParams);
             logDetail.AddString(L"Map",map->GetName());
-            Ptr<MgResourceIdentifier> layerid = mapLayer->GetLayerDefinition();
+
             logDetail.AddResourceIdentifier(L"LayerId",layerid);
             logDetail.Create();
 



More information about the mapguide-commits mailing list