[mapguide-commits] r6338 - in trunk/Tools/Maestro: Maestro.Base/Resources MaestroAPITests MaestroAPITests/UserTestData OSGeo.MapGuide.MaestroAPI/Mapping

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Thu Dec 15 07:10:42 EST 2011


Author: jng
Date: 2011-12-15 04:10:42 -0800 (Thu, 15 Dec 2011)
New Revision: 6338

Added:
   trunk/Tools/Maestro/MaestroAPITests/UserTestData/TestTiledMap.xml
Modified:
   trunk/Tools/Maestro/Maestro.Base/Resources/Contributors.txt
   trunk/Tools/Maestro/MaestroAPITests/MaestroAPITests.csproj
   trunk/Tools/Maestro/MaestroAPITests/RuntimeMapTests.cs
   trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Mapping/RuntimeMapLayer.cs
Log:
#1886: Actually have our own private backing fields instead of having properties with auto-generated backing fields. Modify deserialize and serialize to read and write to/from these backing fields instead of going through its properties (thus not triggering the exception when setting base layer visibility). Add a new unit test to verify this. Also includes an update for contributors.txt

Modified: trunk/Tools/Maestro/Maestro.Base/Resources/Contributors.txt
===================================================================
(Binary files differ)

Modified: trunk/Tools/Maestro/MaestroAPITests/MaestroAPITests.csproj
===================================================================
--- trunk/Tools/Maestro/MaestroAPITests/MaestroAPITests.csproj	2011-12-15 08:00:10 UTC (rev 6337)
+++ trunk/Tools/Maestro/MaestroAPITests/MaestroAPITests.csproj	2011-12-15 12:10:42 UTC (rev 6338)
@@ -579,6 +579,9 @@
     <Content Include="UserTestData\wms_config_example2.xml">
       <CopyToOutputDirectory>Always</CopyToOutputDirectory>
     </Content>
+    <Content Include="UserTestData\TestTiledMap.xml">
+      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+    </Content>
   </ItemGroup>
   <ItemGroup>
     <BootstrapperPackage Include="Microsoft.Net.Client.3.5">

Modified: trunk/Tools/Maestro/MaestroAPITests/RuntimeMapTests.cs
===================================================================
--- trunk/Tools/Maestro/MaestroAPITests/RuntimeMapTests.cs	2011-12-15 08:00:10 UTC (rev 6337)
+++ trunk/Tools/Maestro/MaestroAPITests/RuntimeMapTests.cs	2011-12-15 12:10:42 UTC (rev 6338)
@@ -88,6 +88,7 @@
             resSvc.DeleteResource("Library://UnitTests/");
 
             resSvc.SetResourceXmlData("Library://UnitTests/Maps/Sheboygan.MapDefinition", File.OpenRead("TestData/MappingService/UT_Sheboygan.mdf"));
+            resSvc.SetResourceXmlData("Library://UnitTests/Maps/SheboyganTiled.MapDefinition", File.OpenRead("UserTestData/TestTiledMap.xml"));
 
             resSvc.SetResourceXmlData("Library://UnitTests/Layers/HydrographicPolygons.LayerDefinition", File.OpenRead("TestData/MappingService/UT_HydrographicPolygons.ldf"));
             resSvc.SetResourceXmlData("Library://UnitTests/Layers/Rail.LayerDefinition", File.OpenRead("TestData/MappingService/UT_Rail.ldf"));
@@ -922,7 +923,6 @@
             Assert.AreEqual(0, map.Groups.Count);
         }
 
-        [Test]
         public virtual void TestMapManipulation4()
         {
             IServerConnection conn = CreateTestConnection();
@@ -941,6 +941,17 @@
             RuntimeMap mymap = mapSvc.OpenMap(mapid); 
         }
 
+        public virtual void TestMapManipulation5()
+        {
+            IServerConnection conn = CreateTestConnection();
+            IMappingService mapSvc = (IMappingService)conn.GetService((int)ServiceType.Mapping);
+            string mapdefinition = "Library://UnitTests/Maps/SheboyganTiled.MapDefinition";
+            IMapDefinition mdef = (IMapDefinition)conn.ResourceService.GetResource(mapdefinition);
+            RuntimeMap rtm = mapSvc.CreateMap(mdef); // Create new runtime map
+            rtm.Save();
+            RuntimeMap mymap = mapSvc.OpenMap("Session:" + conn.SessionID + "//" + rtm.Name + ".Map");
+        }
+
         public virtual void TestResourceEvents()
         {
             bool deleteCalled = false;
@@ -1100,6 +1111,12 @@
         {
             base.TestMapManipulation4();
         }
+
+        [Test]
+        public override void TestMapManipulation5()
+        {
+            base.TestMapManipulation5();
+        }
     }
 
     [TestFixture(Ignore = TestControl.IgnoreLocalRuntimeMapTests)]

Added: trunk/Tools/Maestro/MaestroAPITests/UserTestData/TestTiledMap.xml
===================================================================
--- trunk/Tools/Maestro/MaestroAPITests/UserTestData/TestTiledMap.xml	                        (rev 0)
+++ trunk/Tools/Maestro/MaestroAPITests/UserTestData/TestTiledMap.xml	2011-12-15 12:10:42 UTC (rev 6338)
@@ -0,0 +1,60 @@
+<?xml version="1.0" encoding="utf-8"?>
+<MapDefinition xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xsi:noNamespaceSchemaLocation="MapDefinition-1.0.0.xsd">
+    <Name>New Map</Name>
+    <CoordinateSystem>GEOGCS["WGS84 Lat/Long's, Degrees, -180 ==&gt; +180",DATUM["D_WGS_1984",SPHEROID["World_Geodetic_System_of_1984",6378137,298.257222932867]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]]</CoordinateSystem>
+    <Extents>
+        <MinX>-87.770746109180749</MinX>
+        <MaxX>-87.6957605384125</MaxX>
+        <MinY>43.686899685828813</MinY>
+        <MaxY>43.805498742206247</MaxY>
+    </Extents>
+    <BackgroundColor>ffffffff</BackgroundColor>
+    <BaseMapDefinition>
+        <FiniteDisplayScale>100</FiniteDisplayScale>
+        <FiniteDisplayScale>5427</FiniteDisplayScale>
+        <FiniteDisplayScale>10753</FiniteDisplayScale>
+        <FiniteDisplayScale>16080</FiniteDisplayScale>
+        <FiniteDisplayScale>21407</FiniteDisplayScale>
+        <FiniteDisplayScale>26733</FiniteDisplayScale>
+        <FiniteDisplayScale>32060</FiniteDisplayScale>
+        <FiniteDisplayScale>37387</FiniteDisplayScale>
+        <FiniteDisplayScale>42713</FiniteDisplayScale>
+        <FiniteDisplayScale>48040</FiniteDisplayScale>
+        <FiniteDisplayScale>53367</FiniteDisplayScale>
+        <FiniteDisplayScale>58693</FiniteDisplayScale>
+        <FiniteDisplayScale>64020</FiniteDisplayScale>
+        <FiniteDisplayScale>69347</FiniteDisplayScale>
+        <FiniteDisplayScale>80000</FiniteDisplayScale>
+        <BaseMapLayerGroup>
+            <Name>Base Layer Group</Name>
+            <Visible>true</Visible>
+            <ShowInLegend>true</ShowInLegend>
+            <ExpandInLegend>true</ExpandInLegend>
+            <LegendLabel>Base Layer Group</LegendLabel>
+            <BaseMapLayer>
+                <Name>Rail</Name>
+                <ResourceId>Library://UnitTests/Layers/Rail.LayerDefinition</ResourceId>
+                <Selectable>true</Selectable>
+                <ShowInLegend>true</ShowInLegend>
+                <LegendLabel>Rail</LegendLabel>
+                <ExpandInLegend>true</ExpandInLegend>
+            </BaseMapLayer>
+            <BaseMapLayer>
+                <Name>Parcels</Name>
+                <ResourceId>Library://UnitTests/Layers/Parcels.LayerDefinition</ResourceId>
+                <Selectable>true</Selectable>
+                <ShowInLegend>true</ShowInLegend>
+                <LegendLabel>Parcels</LegendLabel>
+                <ExpandInLegend>true</ExpandInLegend>
+            </BaseMapLayer>
+            <BaseMapLayer>
+                <Name>HydrographicPolygons</Name>
+                <ResourceId>Library://UnitTests/Layers/HydrographicPolygons.LayerDefinition</ResourceId>
+                <Selectable>true</Selectable>
+                <ShowInLegend>true</ShowInLegend>
+                <LegendLabel>HydrographicPolygons</LegendLabel>
+                <ExpandInLegend>true</ExpandInLegend>
+            </BaseMapLayer>
+        </BaseMapLayerGroup>
+    </BaseMapDefinition>
+</MapDefinition>
\ No newline at end of file

Modified: trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Mapping/RuntimeMapLayer.cs
===================================================================
--- trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Mapping/RuntimeMapLayer.cs	2011-12-15 08:00:10 UTC (rev 6337)
+++ trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Mapping/RuntimeMapLayer.cs	2011-12-15 12:10:42 UTC (rev 6338)
@@ -101,11 +101,11 @@
         internal RuntimeMapLayer(RuntimeMap parent) 
         {
             _scaleRanges = new double[] { 0.0, InfinityScale };
-            this.Type = kDynamic;
+            _type = kDynamic;
             this.IdentityProperties = new PropertyInfo[0];
-            this.ObjectId = Guid.NewGuid().ToString();
+            _objectId = Guid.NewGuid().ToString();
             this.Parent = parent;
-            this.Group = string.Empty;
+            _group = string.Empty;
         }
 
         /// <summary>
@@ -122,27 +122,27 @@
             if (ldf.SubLayer.LayerType == LayerType.Vector)
             {
                 var vl = ((IVectorLayerDefinition)ldf.SubLayer);
-                this.QualifiedClassName = vl.FeatureName;
-                this.GeometryPropertyName = vl.Geometry;
-                this.FeatureSourceID = vl.ResourceId;
-                this.Filter = vl.Filter;
+                _qualifiedClassName = vl.FeatureName;
+                _geometryPropertyName = vl.Geometry;
+                _featureSourceId = vl.ResourceId;
+                _filter = vl.Filter;
                 InitIdentityProperties(vl);
-                this.HasTooltips = !string.IsNullOrEmpty(vl.ToolTip);
+                _hasTooltips = !string.IsNullOrEmpty(vl.ToolTip);
             }
             else if (ldf.SubLayer.LayerType == LayerType.Raster)
             {
                 var rl = ((IRasterLayerDefinition)ldf.SubLayer);
-                this.QualifiedClassName = rl.FeatureName;
-                this.GeometryPropertyName = rl.Geometry;
-                this.FeatureSourceID = rl.ResourceId;
+                _qualifiedClassName = rl.FeatureName;
+                _geometryPropertyName = rl.Geometry;
+                _featureSourceId = rl.ResourceId;
             }
 
-            this.ExpandInLegend = false;
+            _expandInLegend = false;
             this.Name = ResourceIdentifier.GetName(ldf.ResourceID);
-            this.LegendLabel = this.Name;
-            this.Selectable = true;
-            this.ShowInLegend = true;
-            this.Visible = true;
+            _legendLabel = this.Name;
+            _selectable = true;
+            _showInLegend = true;
+            _visible = true;
 
             _disableChangeTracking = false;
         }
@@ -164,7 +164,7 @@
             _disableChangeTracking = true;
 
             this.Group = source.Group;
-            this.Visible = source.Visible;
+            _visible = source.Visible;
 
             _disableChangeTracking = false;
         }
@@ -179,14 +179,14 @@
             _disableChangeTracking = true;
 
             this.LayerDefinitionID = source.ResourceId;
-            this.ExpandInLegend = source.ExpandInLegend;
+            _expandInLegend = source.ExpandInLegend;
             this.Name = source.Name;
-            this.Selectable = source.Selectable;
-            this.ShowInLegend = source.ShowInLegend;
-            this.LegendLabel = source.LegendLabel;
+            _selectable = source.Selectable;
+            _showInLegend = source.ShowInLegend;
+            _legendLabel = source.LegendLabel;
 
-            this.NeedsRefresh = false;
-            this.DisplayOrder = 0;
+            _needsRefresh = false;
+            _displayOrder = 0;
 
             switch (ldf.SubLayer.LayerType)
             {
@@ -197,9 +197,9 @@
                 case LayerType.Raster:
                     {
                         IRasterLayerDefinition rdf = (IRasterLayerDefinition)ldf.SubLayer;
-                        this.FeatureSourceID = rdf.ResourceId;
-                        this.GeometryPropertyName = rdf.Geometry;
-                        this.QualifiedClassName = rdf.FeatureName;
+                        _featureSourceId = rdf.ResourceId;
+                        _geometryPropertyName = rdf.Geometry;
+                        _qualifiedClassName = rdf.FeatureName;
 
                         if (rdf.GridScaleRangeCount > 0)
                         {
@@ -217,10 +217,10 @@
                 case LayerType.Vector:
                     {
                         IVectorLayerDefinition vld = (IVectorLayerDefinition)ldf.SubLayer;
-                        this.FeatureSourceID = vld.ResourceId;
-                        this.GeometryPropertyName = vld.Geometry;
-                        this.QualifiedClassName = vld.FeatureName;
-                        this.Filter = vld.Filter;
+                        _featureSourceId = vld.ResourceId;
+                        _geometryPropertyName = vld.Geometry;
+                        _qualifiedClassName = vld.FeatureName;
+                        _filter = vld.Filter;
 
                         if (vld.HasVectorScaleRanges())
                         {
@@ -233,7 +233,7 @@
                                 _scaleRanges[i * 2 + 1] = vsr.MaxScale.HasValue ? vsr.MaxScale.Value : InfinityScale;
                             }
                         }
-                        this.HasTooltips = !string.IsNullOrEmpty(vld.ToolTip);
+                        _hasTooltips = !string.IsNullOrEmpty(vld.ToolTip);
                         //get identity property information
                         InitIdentityProperties(vld);
                     }
@@ -435,24 +435,28 @@
             }
         }
 
+        private string _featureSourceId;
+
         /// <summary>
         /// Gets or sets the feature source ID.
         /// </summary>
         /// <value>The feature source ID.</value>
         public string FeatureSourceID
         {
-            get;
-            internal set;
+            get { return _featureSourceId; }
+            internal set { _featureSourceId = value; }
         }
 
+        private string _qualifiedClassName;
+
         /// <summary>
         /// Gets the name of the qualified name of the feature class.
         /// </summary>
         /// <value>The name of the qualified name of the feature class.</value>
         public string QualifiedClassName
         {
-            get;
-            internal set;
+            get { return _qualifiedClassName; }
+            internal set { _qualifiedClassName = value; }
         }
 
         /// <summary>
@@ -465,61 +469,73 @@
             private set;
         }
 
+        private string _objectId;
+
         /// <summary>
         /// Gets the object id.
         /// </summary>
         /// <value>The object id.</value>
         public string ObjectId
         {
-            get;
-            internal set;
+            get { return _objectId; }
+            internal set { _objectId = value; }
         }
 
+        private string _geometryPropertyName;
+
         /// <summary>
         /// Gets the name of the geometry property.
         /// </summary>
         /// <value>The name of the geometry property.</value>
         public string GeometryPropertyName
         {
-            get;
-            private set;
+            get { return _geometryPropertyName; }
+            private set { _geometryPropertyName = value; }
         }
 
+        private string _filter;
+
         /// <summary>
         /// Gets the filter.
         /// </summary>
         /// <value>The filter.</value>
         public string Filter
         {
-            get;
-            internal set;
+            get { return _filter; }
+            internal set { _filter = value; }
         }
 
+        private int _type;
+
         /// <summary>
         /// Gets the type
         /// </summary>
         public int Type
         {
-            get;
-            internal set;
+            get { return _type; }
+            internal set { _type = value; }
         }
 
+        private double _displayOrder;
+
         /// <summary>
         /// Gets the display order
         /// </summary>
         public double DisplayOrder
         {
-            get;
-            internal set;
+            get { return _displayOrder; }
+            internal set { _displayOrder = value; }
         }
 
+        private bool _needsRefresh;
+
         /// <summary>
         /// Gets whether this layer needs to be refreshed
         /// </summary>
         public bool NeedsRefresh
         {
-            get;
-            internal set;
+            get { return _needsRefresh; }
+            internal set { _needsRefresh = value; }
         }
 
         /// <summary>
@@ -533,13 +549,15 @@
             this.NeedsRefresh = true;
         }
 
+        private bool _hasTooltips;
+
         /// <summary>
         /// Gets whether this layer has tooltips
         /// </summary>
         public bool HasTooltips
         {
-            get;
-            internal set;
+            get { return _hasTooltips; }
+            internal set { _hasTooltips = value; }
         }
 
         /// <summary>
@@ -708,17 +726,17 @@
             if (d.SiteVersion < SiteVersions.GetVersion(KnownSiteVersions.MapGuideOS1_2))
             {
                 this.Name = d.ReadString();
-                this.ObjectId = d.ReadString();
-                this.Type = d.ReadInt32();
+                _objectId = d.ReadString();
+                _type = d.ReadInt32();
 
-                this.Visible = d.ReadByte() > 0;
-                this.Selectable = d.ReadByte() > 0;
-                this.ShowInLegend = d.ReadByte() > 0;
-                this.ExpandInLegend = d.ReadByte() > 0;
+                _visible = d.ReadByte() > 0;
+                _selectable = d.ReadByte() > 0;
+                _showInLegend = d.ReadByte() > 0;
+                _expandInLegend = d.ReadByte() > 0;
 
-                this.LegendLabel = d.ReadString();
-                this.NeedsRefresh = d.ReadByte() > 0;
-                this.DisplayOrder = d.ReadDouble();
+                _legendLabel = d.ReadString();
+                _needsRefresh = d.ReadByte() > 0;
+                _displayOrder = d.ReadDouble();
 
                 var scaleRanges = new List<double>();
                 int scales = d.ReadInt32();
@@ -727,9 +745,9 @@
 
                 _scaleRanges = scaleRanges.ToArray();
                 
-                this.FeatureSourceID = d.ReadString();
-                this.QualifiedClassName = d.ReadString();
-                this.GeometryPropertyName = d.ReadString();
+                _featureSourceId = d.ReadString();
+                _qualifiedClassName = d.ReadString();
+                _geometryPropertyName = d.ReadString();
 
                 var ids = new List<PropertyInfo>();
                 int idCount = d.ReadInt32();
@@ -747,19 +765,19 @@
             {
                 //AAARGH!!! Now they bypass their own header system ....
                 this.Name = d.ReadInternalString();
-                this.ObjectId = d.ReadInternalString();
-                this.Type = BitConverter.ToInt32(d.ReadStreamRepeat(4), 0);
+                _objectId = d.ReadInternalString();
+                _type = BitConverter.ToInt32(d.ReadStreamRepeat(4), 0);
 
                 int flags = d.ReadStreamRepeat(1)[0];
-                this.Visible = (flags & 1) > 0;
-                this.Selectable = (flags & 2) > 0;
-                this.ShowInLegend = (flags & 4) > 0;
-                this.ExpandInLegend = (flags & 8) > 0;
-                this.NeedsRefresh = (flags & 16) > 0;
-                this.HasTooltips = (flags & 32) > 0;
+                _visible = (flags & 1) > 0;
+                _selectable = (flags & 2) > 0;
+                _showInLegend = (flags & 4) > 0;
+                _expandInLegend = (flags & 8) > 0;
+                _needsRefresh = (flags & 16) > 0;
+                _hasTooltips = (flags & 32) > 0;
 
-                this.LegendLabel = d.ReadInternalString();
-                this.DisplayOrder = BitConverter.ToDouble(d.ReadStreamRepeat(8), 0);
+                _legendLabel = d.ReadInternalString();
+                _displayOrder = BitConverter.ToDouble(d.ReadStreamRepeat(8), 0);
 
                 var scaleRanges = new List<double>();
                 int scales = BitConverter.ToInt32(d.ReadStreamRepeat(4), 0);
@@ -768,13 +786,13 @@
 
                 _scaleRanges = scaleRanges.ToArray();
                 
-                this.FeatureSourceID = d.ReadInternalString();
-                this.QualifiedClassName = d.ReadInternalString();
+                _featureSourceId = d.ReadInternalString();
+                _qualifiedClassName = d.ReadInternalString();
                 if (d.SiteVersion > SiteVersions.GetVersion(KnownSiteVersions.MapGuideOS2_1))
-                    this.Filter = d.ReadInternalString();
+                    _filter = d.ReadInternalString();
                 //this.SchemaName = d.ReadInternalString();
                 d.ReadInternalString();
-                this.GeometryPropertyName = d.ReadInternalString();
+                _geometryPropertyName = d.ReadInternalString();
 
                 var ids = new List<PropertyInfo>();
                 int idCount = BitConverter.ToInt32(d.ReadStreamRepeat(4), 0);



More information about the mapguide-commits mailing list