[mapguide-commits] r7506 - in trunk/Tools/Maestro: MaestroAPITests OSGeo.MapGuide.MaestroAPI/Mapping

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Mon May 20 04:55:57 PDT 2013


Author: jng
Date: 2013-05-20 04:55:56 -0700 (Mon, 20 May 2013)
New Revision: 7506

Modified:
   trunk/Tools/Maestro/MaestroAPITests/RuntimeMapTests.cs
   trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Mapping/RuntimeMapLayer.cs
Log:
#2233: This is actually fixed in trunk. Nevertheless, still worth merging in the cleaned up code and the updated unit tests.

Modified: trunk/Tools/Maestro/MaestroAPITests/RuntimeMapTests.cs
===================================================================
--- trunk/Tools/Maestro/MaestroAPITests/RuntimeMapTests.cs	2013-05-20 11:50:43 UTC (rev 7505)
+++ trunk/Tools/Maestro/MaestroAPITests/RuntimeMapTests.cs	2013-05-20 11:55:56 UTC (rev 7506)
@@ -173,6 +173,12 @@
             var map2 = mapSvc.CreateMap("Session:" + _conn.SessionID + "//TestCreate2.Map", "Library://UnitTests/Maps/Sheboygan.MapDefinition", 1.0);
             //var map3 = mapSvc.CreateMap("Library://UnitTests/Maps/Sheboygan.MapDefinition", 1.0);
 
+            Assert.NotNull(map.Layers["Parcels"]);
+            var parcelsLayers = map.Layers["Parcels"];
+            Assert.AreEqual(1, parcelsLayers.ScaleRanges.Length);
+            Assert.AreEqual(0.0, parcelsLayers.ScaleRanges[0].MinScale);
+            Assert.AreEqual(13000.0, parcelsLayers.ScaleRanges[0].MaxScale);
+
             Assert.NotNull(map);
             Assert.NotNull(map2);
             //Assert.NotNull(map3);
@@ -259,6 +265,11 @@
 
             //Tweak some settings
             var parcels = map2.Layers["Parcels"];
+            //Check these values still came through
+            Assert.AreEqual(1, parcels.ScaleRanges.Length);
+            Assert.AreEqual(0.0, parcels.ScaleRanges[0].MinScale);
+            Assert.AreEqual(13000.0, parcels.ScaleRanges[0].MaxScale);
+
             var rail = map2.Layers["Rail"];
             Assert.NotNull(parcels);
 

Modified: trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Mapping/RuntimeMapLayer.cs
===================================================================
--- trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Mapping/RuntimeMapLayer.cs	2013-05-20 11:50:43 UTC (rev 7505)
+++ trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Mapping/RuntimeMapLayer.cs	2013-05-20 11:55:56 UTC (rev 7506)
@@ -136,18 +136,8 @@
                 _featureSourceId = vl.ResourceId;
                 _filter = vl.Filter;
                 InitIdentityProperties(vl);
+                InitScaleRanges(vl);
                 _hasTooltips = !string.IsNullOrEmpty(vl.ToolTip);
-                if (vl.HasVectorScaleRanges())
-                {
-                    int vsrCount = vl.GetScaleRangeCount();
-                    _scaleRanges = new double[vsrCount * 2];
-                    for (int i = 0; i < vsrCount; i++)
-                    {
-                        var vsr = vl.GetScaleRangeAt(i);
-                        _scaleRanges[i * 2] = vsr.MinScale.HasValue ? vsr.MinScale.Value : 0;
-                        _scaleRanges[i * 2 + 1] = vsr.MaxScale.HasValue ? vsr.MaxScale.Value : InfinityScale;
-                    }
-                }
             }
             else if (ldf.SubLayer.LayerType == LayerType.Raster)
             {
@@ -155,22 +145,18 @@
                 _qualifiedClassName = rl.FeatureName;
                 _geometryPropertyName = rl.Geometry;
                 _featureSourceId = rl.ResourceId;
-
-                if (rl.GridScaleRangeCount > 0)
-                {
-                    _scaleRanges = new double[rl.GridScaleRangeCount * 2];
-                    int i = 0;
-                    foreach (var gsr in rl.GridScaleRange)
-                    {
-                        _scaleRanges[i * 2] = gsr.MinScale.HasValue ? gsr.MinScale.Value : 0;
-                        _scaleRanges[i * 2 + 1] = gsr.MaxScale.HasValue ? gsr.MaxScale.Value : InfinityScale;
-                        i++;
-                    }
-                }
+                InitScaleRanges(rl);
             }
             else if (ldf.SubLayer.LayerType == LayerType.Drawing)
             {
                 _featureSourceId = ldf.SubLayer.ResourceId;
+                var dl = ((IDrawingLayerDefinition)ldf.SubLayer);
+                _scaleRanges = new double[] 
+                {
+                    dl.MinScale,
+                    dl.MaxScale 
+                };
+                EnsureOrderedMinMaxScales();
             }
 
             _expandInLegend = false;
@@ -179,8 +165,6 @@
             _selectable = true;
             _showInLegend = true;
             _visible = true;
-
-            EnsureOrderedMinMaxScales();
         }
 
         /// <summary>
@@ -210,6 +194,44 @@
             _disableChangeTracking = false;
         }
 
+        private void InitScaleRanges(IRasterLayerDefinition rl)
+        {
+            List<double> scales = new List<double>();
+            foreach (var gsr in rl.GridScaleRange)
+            {
+                if (gsr.MinScale.HasValue)
+                    scales.Add(gsr.MinScale.Value);
+                else
+                    scales.Add(0.0);
+
+                if (gsr.MaxScale.HasValue)
+                    scales.Add(gsr.MaxScale.Value);
+                else
+                    scales.Add(InfinityScale);
+            }
+            _scaleRanges = scales.ToArray();
+            EnsureOrderedMinMaxScales();
+        }
+
+        private void InitScaleRanges(IVectorLayerDefinition vl)
+        {
+            List<double> scales = new List<double>();
+            foreach (var vsr in vl.VectorScaleRange)
+            {
+                if (vsr.MinScale.HasValue)
+                    scales.Add(vsr.MinScale.Value);
+                else
+                    scales.Add(0.0);
+
+                if (vsr.MaxScale.HasValue)
+                    scales.Add(vsr.MaxScale.Value);
+                else
+                    scales.Add(InfinityScale);
+            }
+            _scaleRanges = scales.ToArray();
+            EnsureOrderedMinMaxScales();
+        }
+
         /// <summary>
         /// Initializes a new instance of the <see cref="RuntimeMapLayer"/> class.
         /// </summary>



More information about the mapguide-commits mailing list