[mapguide-commits] r7513 - trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Mapping

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Tue May 21 09:18:01 PDT 2013


Author: jng
Date: 2013-05-21 09:18:00 -0700 (Tue, 21 May 2013)
New Revision: 7513

Modified:
   trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Mapping/RuntimeMap.cs
   trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Mapping/RuntimeMapGroup.cs
   trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Mapping/RuntimeMapLayer.cs
Log:
This submission includes the following changes:
 - #2273: Fix improper parent group change tracking for RuntimeMapLayer and RuntimeMapGroup
 - #2274: Force groups of a RuntimeMap group to be serialized out in a certain order that will not trip up MgMap deserialization on the server-side for rendering operations (and other APIs that operate off of a MgMap)

Modified: trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Mapping/RuntimeMap.cs
===================================================================
--- trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Mapping/RuntimeMap.cs	2013-05-21 15:14:20 UTC (rev 7512)
+++ trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Mapping/RuntimeMap.cs	2013-05-21 16:18:00 UTC (rev 7513)
@@ -799,7 +799,49 @@
         protected void SerializeLayerData(MgBinarySerializer s)
         {
             s.Write((int)this.Groups.Count);
-            foreach (var g in this.Groups)
+            //Workaround a deserialization quirk in the MgMap. It deserializes groups sequentially
+            //without first checking if a parented group exists before doing the parent association
+            //
+            //We workaround this by re-ordering the groups, so that unparented groups are serialized first
+            var groups = new List<RuntimeMapGroup>();
+            var remaining = new List<RuntimeMapGroup>();
+            var processed = new Dictionary<string, RuntimeMapGroup>();
+            foreach (var grp in this.Groups)
+            {
+                if (string.IsNullOrEmpty(grp.Group)) //Un-parented
+                {
+                    groups.Add(grp);
+                    processed.Add(grp.Name, grp);
+                }
+                else
+                {
+                    remaining.Add(grp);
+                }
+            }
+            var indices = new List<int>();
+            //Whittle down this list until all parents are resolved
+            while (remaining.Count > 0)
+            {
+                indices.Clear();
+                //Collect the indices which can be added to the final list
+                for (int i = 0; i < remaining.Count; i++)
+                {
+                    var grp = remaining[i];
+                    if (processed.ContainsKey(grp.Group)) //Parent of a group already processed
+                        indices.Add(i);
+                }
+                //Reverse iterate so that higher indices are removed first
+                for (int i = indices.Count - 1; i >= 0; i--)
+                {
+                    var index = indices[i];
+                    var grp = remaining[index];
+                    remaining.RemoveAt(index);
+                    groups.Add(grp);
+                    processed.Add(grp.Name, grp);
+                }
+            }
+
+            foreach (var g in groups)
                 g.Serialize(s);
 
             s.Write(this.Layers.Count);
@@ -1294,6 +1336,8 @@
                     this.ResourceService.SetResourceData(resourceID, "LayerGroupData", ResourceDataType.Stream, ms2); //NOXLATE
 
                 SaveSelectionXml(resourceID);
+                //Our changes have been persisted. Wipe our change list
+                ClearChanges();
                 this.IsDirty = false;
             }
             finally
@@ -1360,6 +1404,8 @@
             var change = new Change(type, param);
             changes.Changes.Add(change);
 
+            Debug.WriteLine("Tracked change for " + (isLayer ? "Layer " : "Group ") + objectId + " (type: " + type + ", value: " + param + ")");
+
             this.IsDirty = true;
         }
 

Modified: trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Mapping/RuntimeMapGroup.cs
===================================================================
--- trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Mapping/RuntimeMapGroup.cs	2013-05-21 15:14:20 UTC (rev 7512)
+++ trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Mapping/RuntimeMapGroup.cs	2013-05-21 16:18:00 UTC (rev 7513)
@@ -281,7 +281,11 @@
             switch (propertyName)
             {
                 case "Group": //NOXLATE
-                    this.Parent.OnGroupParentChanged(this, this.ObjectId);
+                    var name = this.Group;
+                    if (this.Parent.Groups[name] != null)
+                        this.Parent.OnGroupParentChanged(this, this.Parent.Groups[name].ObjectId);
+                    else
+                        this.Parent.OnGroupParentChanged(this, string.Empty);
                     break;
                 case "Visible": //NOXLATE
                     this.Parent.OnGroupVisibilityChanged(this, this.Visible ? "1" : "0"); //NOXLATE

Modified: trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Mapping/RuntimeMapLayer.cs
===================================================================
--- trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Mapping/RuntimeMapLayer.cs	2013-05-21 15:14:20 UTC (rev 7512)
+++ trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Mapping/RuntimeMapLayer.cs	2013-05-21 16:18:00 UTC (rev 7513)
@@ -952,7 +952,11 @@
             switch (propertyName)
             {
                 case "Group": //NOXLATE
-                    this.Parent.OnLayerParentChanged(this, this.ObjectId);
+                    var name = this.Group;
+                    if (this.Parent.Groups[name] != null)
+                        this.Parent.OnLayerParentChanged(this, this.Parent.Groups[name].ObjectId);
+                    else
+                        this.Parent.OnLayerParentChanged(this, string.Empty);
                     break;
                 case "Visible": //NOXLATE
                     this.Parent.OnLayerVisibilityChanged(this, this.Visible ? "1" : "0"); //NOXLATE



More information about the mapguide-commits mailing list