[mapguide-commits] r6229 - in trunk/Tools/Maestro: OSGeo.MapGuide.MaestroAPI/Mapping SDK/SamplesWeb/SamplesWeb/Tasks

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Wed Nov 16 09:34:36 EST 2011


Author: jng
Date: 2011-11-16 06:34:35 -0800 (Wed, 16 Nov 2011)
New Revision: 6229

Modified:
   trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Mapping/Collections.cs
   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
   trunk/Tools/Maestro/SDK/SamplesWeb/SamplesWeb/Tasks/AddTracksLayer.aspx.cs
   trunk/Tools/Maestro/SDK/SamplesWeb/SamplesWeb/Tasks/FeatureInfo.aspx.cs
   trunk/Tools/Maestro/SDK/SamplesWeb/SamplesWeb/Tasks/SetSelectedFeatures.aspx.cs
   trunk/Tools/Maestro/SDK/SamplesWeb/SamplesWeb/Tasks/ToggleGroupVisibility.aspx.cs
   trunk/Tools/Maestro/SDK/SamplesWeb/SamplesWeb/Tasks/ToggleLayerVisibility.aspx.cs
   trunk/Tools/Maestro/SDK/SamplesWeb/SamplesWeb/Tasks/ToggleParcelsLayer.aspx.cs
Log:
Some post-#1852 API changes:
 - Make public ctor for RuntimeMapLayer and RuntimeMapGroup
 - Add a IndexOf(TKey) method for KeyValueCollection<TKey, TValue>
 - Make RuntimeMapLayerCollection.GetByObjectId() public
 - Update the SDK web sample to reflect proper usage, and update/remove usage of any deprecated APIs

Modified: trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Mapping/Collections.cs
===================================================================
--- trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Mapping/Collections.cs	2011-11-16 13:48:35 UTC (rev 6228)
+++ trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Mapping/Collections.cs	2011-11-16 14:34:35 UTC (rev 6229)
@@ -62,6 +62,19 @@
         }
 
         /// <summary>
+        /// Determines the index of a specific key in the collection
+        /// </summary>
+        /// <param name="key">The key of the object to locate in the collection</param>
+        /// <returns>
+        /// The index of <paramref name="key"/> if found in the list; otherwise, -1.
+        /// </returns>
+        public int IndexOf(TKey key)
+        {
+            var item = this[key];
+            return IndexOf(item);
+        }
+
+        /// <summary>
         /// Inserts an item to the <see cref="T:System.Collections.Generic.IList`1"/> at the specified index.
         /// </summary>
         /// <param name="index">The zero-based index at which <paramref name="item"/> should be inserted.</param>
@@ -434,7 +447,12 @@
             return value.Name;
         }
 
-        internal RuntimeMapLayer GetByObjectId(string id)
+        /// <summary>
+        /// Gets a runtime map layer by its object id.
+        /// </summary>
+        /// <param name="id">The object id.</param>
+        /// <returns></returns>
+        public RuntimeMapLayer GetByObjectId(string id)
         {
             return _layerIdMap.ContainsKey(id) ? _layerIdMap[id] : null;
         }

Modified: trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Mapping/RuntimeMap.cs
===================================================================
--- trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Mapping/RuntimeMap.cs	2011-11-16 13:48:35 UTC (rev 6228)
+++ trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Mapping/RuntimeMap.cs	2011-11-16 14:34:35 UTC (rev 6229)
@@ -1033,6 +1033,7 @@
         /// <param name="layerDefinitionId"></param>
         /// <param name="group"></param>
         /// <returns></returns>
+        [Obsolete("Use RuntimeMapLayer constructor")]
         public RuntimeMapLayer CreateLayer(string layerDefinitionId, RuntimeMapGroup group)
         {
             ILayerDefinition ldf = GetLayerDefinition(layerDefinitionId);

Modified: trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Mapping/RuntimeMapGroup.cs
===================================================================
--- trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Mapping/RuntimeMapGroup.cs	2011-11-16 13:48:35 UTC (rev 6228)
+++ trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Mapping/RuntimeMapGroup.cs	2011-11-16 14:34:35 UTC (rev 6229)
@@ -42,7 +42,7 @@
             this.ObjectId = Guid.NewGuid().ToString();
         }
 
-        internal RuntimeMapGroup(RuntimeMap map, string name) 
+        public RuntimeMapGroup(RuntimeMap map, string name) 
             : this()
         {
             this.Parent = map;

Modified: trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Mapping/RuntimeMapLayer.cs
===================================================================
--- trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Mapping/RuntimeMapLayer.cs	2011-11-16 13:48:35 UTC (rev 6228)
+++ trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Mapping/RuntimeMapLayer.cs	2011-11-16 14:34:35 UTC (rev 6229)
@@ -80,7 +80,7 @@
             this.Group = string.Empty;
         }
 
-        internal RuntimeMapLayer(RuntimeMap parent, ILayerDefinition ldf)
+        public RuntimeMapLayer(RuntimeMap parent, ILayerDefinition ldf)
             : this(parent)
         {
             Check.NotNull(ldf, "ldf");

Modified: trunk/Tools/Maestro/SDK/SamplesWeb/SamplesWeb/Tasks/AddTracksLayer.aspx.cs
===================================================================
--- trunk/Tools/Maestro/SDK/SamplesWeb/SamplesWeb/Tasks/AddTracksLayer.aspx.cs	2011-11-16 13:48:35 UTC (rev 6228)
+++ trunk/Tools/Maestro/SDK/SamplesWeb/SamplesWeb/Tasks/AddTracksLayer.aspx.cs	2011-11-16 14:34:35 UTC (rev 6229)
@@ -53,17 +53,19 @@
 
             RuntimeMap rtMap = mpSvc.OpenMap(rtMapId);
 
-            RuntimeMapLayer tracks = rtMap.GetLayerByName("Tracks");
+            RuntimeMapLayer tracks = rtMap.Layers["Tracks"];
             if (tracks != null)
             {
                 lblMessage.Text = "Tracks layer already added";
             }
             else
             {
-                RuntimeMapGroup group = rtMap.GetGroupByName("Transportation");
+                string groupName = "Transportation";
+                RuntimeMapGroup group = rtMap.Groups[groupName];
                 if (group == null)
                 {
-                    group = rtMap.AddGroup("Transportation");
+                    group = new RuntimeMapGroup(rtMap, groupName);
+                    rtMap.Groups.Add(group);
                     throw new Exception("Layer group not found");
                 }
 
@@ -79,8 +81,10 @@
 
                 CreateTracksLayer(conn, fsId, layerId);
 
-                RuntimeMapLayer layer = rtMap.CreateLayer(layerId, group);
+                ILayerDefinition layerDef = (ILayerDefinition)conn.ResourceService.GetResource(layerId);
+                RuntimeMapLayer layer = new RuntimeMapLayer(rtMap, layerDef);
 
+                layer.Group = groupName;
                 layer.LegendLabel = "Tracks";
                 layer.ShowInLegend = true;
                 layer.ExpandInLegend = true;
@@ -92,8 +96,8 @@
                 //So for a layer to be drawn above something else, its draw order must be
                 //less than that particular layer.
 
-                int index = rtMap.IndexOfLayer("Districts");
-                rtMap.InsertLayer(index, layer);
+                int index = rtMap.Layers.IndexOf("Districts");
+                rtMap.Layers.Insert(index, layer);
 
                 rtMap.Save();
 

Modified: trunk/Tools/Maestro/SDK/SamplesWeb/SamplesWeb/Tasks/FeatureInfo.aspx.cs
===================================================================
--- trunk/Tools/Maestro/SDK/SamplesWeb/SamplesWeb/Tasks/FeatureInfo.aspx.cs	2011-11-16 13:48:35 UTC (rev 6228)
+++ trunk/Tools/Maestro/SDK/SamplesWeb/SamplesWeb/Tasks/FeatureInfo.aspx.cs	2011-11-16 14:34:35 UTC (rev 6229)
@@ -54,7 +54,7 @@
             string rtMapId = "Session:" + conn.SessionID + "//" + mapName + ".Map";
 
             RuntimeMap rtMap = mpSvc.OpenMap(rtMapId);
-            RuntimeMapLayer layer = rtMap.GetLayerByObjectId(layerId);
+            RuntimeMapLayer layer = rtMap.Layers.GetByObjectId(layerId);
 
             //The values returned are in the same order as the array from the IdentityProperties
             object[] values = layer.ParseSelectionValues(id);

Modified: trunk/Tools/Maestro/SDK/SamplesWeb/SamplesWeb/Tasks/SetSelectedFeatures.aspx.cs
===================================================================
--- trunk/Tools/Maestro/SDK/SamplesWeb/SamplesWeb/Tasks/SetSelectedFeatures.aspx.cs	2011-11-16 13:48:35 UTC (rev 6228)
+++ trunk/Tools/Maestro/SDK/SamplesWeb/SamplesWeb/Tasks/SetSelectedFeatures.aspx.cs	2011-11-16 14:34:35 UTC (rev 6229)
@@ -77,7 +77,7 @@
             RuntimeMap rtMap = mpSvc.OpenMap(rtMapId);
             
             //Get the selected layer
-            RuntimeMapLayer rtLayer = rtMap.GetLayerByObjectId(ddlLayers.SelectedValue);
+            RuntimeMapLayer rtLayer = rtMap.Layers.GetByObjectId(ddlLayers.SelectedValue);
 
             //Query using the user filter
             IFeatureReader reader = conn.FeatureService.QueryFeatureSource(

Modified: trunk/Tools/Maestro/SDK/SamplesWeb/SamplesWeb/Tasks/ToggleGroupVisibility.aspx.cs
===================================================================
--- trunk/Tools/Maestro/SDK/SamplesWeb/SamplesWeb/Tasks/ToggleGroupVisibility.aspx.cs	2011-11-16 13:48:35 UTC (rev 6228)
+++ trunk/Tools/Maestro/SDK/SamplesWeb/SamplesWeb/Tasks/ToggleGroupVisibility.aspx.cs	2011-11-16 14:34:35 UTC (rev 6229)
@@ -49,7 +49,7 @@
 
             RuntimeMap rtMap = mpSvc.OpenMap(rtMapId);
 
-            RuntimeMapGroup group = rtMap.GetGroupByName(Request.Params["GROUPNAME"]);
+            RuntimeMapGroup group = rtMap.Groups[Request.Params["GROUPNAME"]];
             if (group != null)
             {
                 group.Visible = !group.Visible;

Modified: trunk/Tools/Maestro/SDK/SamplesWeb/SamplesWeb/Tasks/ToggleLayerVisibility.aspx.cs
===================================================================
--- trunk/Tools/Maestro/SDK/SamplesWeb/SamplesWeb/Tasks/ToggleLayerVisibility.aspx.cs	2011-11-16 13:48:35 UTC (rev 6228)
+++ trunk/Tools/Maestro/SDK/SamplesWeb/SamplesWeb/Tasks/ToggleLayerVisibility.aspx.cs	2011-11-16 14:34:35 UTC (rev 6229)
@@ -49,7 +49,7 @@
 
             RuntimeMap rtMap = mpSvc.OpenMap(rtMapId);
 
-            RuntimeMapLayer layer = rtMap.GetLayerByName(Request.Params["LAYERNAME"]);
+            RuntimeMapLayer layer = rtMap.Layers[Request.Params["LAYERNAME"]];
             if (layer != null)
             {
                 layer.Visible = !layer.Visible;

Modified: trunk/Tools/Maestro/SDK/SamplesWeb/SamplesWeb/Tasks/ToggleParcelsLayer.aspx.cs
===================================================================
--- trunk/Tools/Maestro/SDK/SamplesWeb/SamplesWeb/Tasks/ToggleParcelsLayer.aspx.cs	2011-11-16 13:48:35 UTC (rev 6228)
+++ trunk/Tools/Maestro/SDK/SamplesWeb/SamplesWeb/Tasks/ToggleParcelsLayer.aspx.cs	2011-11-16 14:34:35 UTC (rev 6229)
@@ -31,6 +31,7 @@
 using OSGeo.MapGuide.MaestroAPI.Services;
 using OSGeo.MapGuide.MaestroAPI.Mapping;
 using System.Text;
+using OSGeo.MapGuide.ObjectModels.LayerDefinition;
 
 namespace SamplesWeb.Tasks
 {
@@ -50,10 +51,10 @@
 
             RuntimeMap rtMap = mpSvc.OpenMap(rtMapId);
 
-            RuntimeMapLayer parcels = rtMap.GetLayerByName("Parcels");
+            RuntimeMapLayer parcels = rtMap.Layers["Parcels"];
             if (parcels != null)
             {
-                rtMap.RemoveLayer(parcels);
+                rtMap.Layers.Remove(parcels);
 
                 rtMap.Save();
 
@@ -66,15 +67,19 @@
             }
             else
             {
-                RuntimeMapGroup group = rtMap.GetGroupByName("Municipal");
+                string groupName = "Municipal";
+                RuntimeMapGroup group = rtMap.Groups[groupName];
                 if (group == null)
                 {
-                    group = rtMap.AddGroup("Municipal");
+                    group = new RuntimeMapGroup(rtMap, groupName);
+                    rtMap.Groups.Add(group);
                     throw new Exception("Layer group not found");
                 }
 
-                RuntimeMapLayer layer = rtMap.CreateLayer("Library://Samples/Sheboygan/Layers/Parcels.LayerDefinition", group);
+                ILayerDefinition layerDef = (ILayerDefinition)conn.ResourceService.GetResource("Library://Samples/Sheboygan/Layers/Parcels.LayerDefinition");
+                RuntimeMapLayer layer = new RuntimeMapLayer(rtMap, layerDef);
 
+                layer.Group = group.Name;
                 layer.LegendLabel = "Parcels";
                 layer.ShowInLegend = true;
                 layer.ExpandInLegend = true;
@@ -86,8 +91,8 @@
                 //So for a layer to be drawn above something else, its draw order must be
                 //less than that particular layer.
 
-                int index = rtMap.IndexOfLayer("Islands");
-                rtMap.InsertLayer(index, layer);
+                int index = rtMap.Layers.IndexOf("Islands");
+                rtMap.Layers.Insert(index, layer);
 
                 rtMap.Save();
 



More information about the mapguide-commits mailing list