[mapguide-commits] r5638 - in trunk/Tools/Maestro: Maestro.Base/Templates Maestro.Editors/LayerDefinition/Raster Maestro.Editors/LayerDefinition/Vector OSGeo.MapGuide.MaestroAPI/ObjectModels OSGeo.MapGuide.MaestroAPI/SchemaOverrides OSGeo.MapGuide.MaestroAPI.Http

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Fri Mar 18 19:38:17 EDT 2011


Author: jng
Date: 2011-03-18 16:38:17 -0700 (Fri, 18 Mar 2011)
New Revision: 5638

Modified:
   trunk/Tools/Maestro/Maestro.Base/Templates/RasterLayerDefinitionItemTemplate.cs
   trunk/Tools/Maestro/Maestro.Editors/LayerDefinition/Raster/RasterLayerSettingsSectionCtrl.cs
   trunk/Tools/Maestro/Maestro.Editors/LayerDefinition/Vector/VectorLayerSettingsSectionCtrl.cs
   trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI.Http/RequestBuilder.cs
   trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/ObjectModels/LayerFactory.cs
   trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/ObjectModels/LayerInterfaceExtensions.cs
   trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/SchemaOverrides/RasterWmsItem.cs
Log:
This submission includes the following changes:
 - #738: More work on the WMS feature source editor
 - Enable the raster layer definition item template
 - Fix an incorrect ISACTIVE flag for GETSPATIALCONTEXTS request
 - Fix NullReferenceException in Vector/Raster layer editors due to feature schema not being cached under certain conditions
 - Update raster layer definition creation code to produce a minimal object that passes XML validation
 - Update the GetSpatialExtent() extension method to return the first spatial context (turns that WMS can return multiple contexts even if the IsActive flag is true)


Modified: trunk/Tools/Maestro/Maestro.Base/Templates/RasterLayerDefinitionItemTemplate.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Base/Templates/RasterLayerDefinitionItemTemplate.cs	2011-03-17 16:23:41 UTC (rev 5637)
+++ trunk/Tools/Maestro/Maestro.Base/Templates/RasterLayerDefinitionItemTemplate.cs	2011-03-18 23:38:17 UTC (rev 5638)
@@ -24,6 +24,8 @@
 using Res = Maestro.Base.Properties.Resources;
 using OSGeo.MapGuide.MaestroAPI;
 using OSGeo.MapGuide.ObjectModels;
+using Maestro.Editors.Generic;
+using OSGeo.MapGuide.ObjectModels.LayerDefinition;
 
 namespace Maestro.Base.Templates
 {
@@ -43,13 +45,30 @@
         {
             get
             {
-                return new Version(99, 0);
+                return new Version(2, 0);
             }
         }
 
         public override IResource CreateItem(IServerConnection conn)
         {
-            return ObjectFactory.CreateDefaultLayer(conn, OSGeo.MapGuide.ObjectModels.LayerDefinition.LayerType.Raster, new Version(1, 0, 0));
+            using (var picker = new ResourcePicker(conn.ResourceService, ResourceTypes.FeatureSource, ResourcePickerMode.OpenResource))
+            {
+                if (picker.ShowDialog() == System.Windows.Forms.DialogResult.OK)
+                {
+                    var lyr = ObjectFactory.CreateDefaultLayer(conn, OSGeo.MapGuide.ObjectModels.LayerDefinition.LayerType.Raster, new Version(1, 0, 0));
+                    var rl = (IRasterLayerDefinition)lyr.SubLayer;
+                    rl.ResourceId = picker.ResourceID;
+                    //Stub these for now, validation will ensure this never makes it
+                    //into the session repository until all validation errors pass
+                    rl.FeatureName = string.Empty;
+                    rl.Geometry = string.Empty;
+                    return lyr;
+                }
+                else
+                {
+                    return null;
+                }
+            }
         }
     }
 }

Modified: trunk/Tools/Maestro/Maestro.Editors/LayerDefinition/Raster/RasterLayerSettingsSectionCtrl.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Editors/LayerDefinition/Raster/RasterLayerSettingsSectionCtrl.cs	2011-03-17 16:23:41 UTC (rev 5637)
+++ trunk/Tools/Maestro/Maestro.Editors/LayerDefinition/Raster/RasterLayerSettingsSectionCtrl.cs	2011-03-18 23:38:17 UTC (rev 5638)
@@ -58,21 +58,35 @@
             Debug.Assert(_rl != null);
 
             TextBoxBinder.BindText(txtFeatureSource, _rl, "ResourceId");
-
             TextBoxBinder.BindText(txtFeatureClass, _rl, "FeatureName");
             TextBoxBinder.BindText(txtGeometry, _rl, "Geometry");
+            _rl.PropertyChanged += OnRasterLayerPropertyChanged;
         }
 
+        void OnRasterLayerPropertyChanged(object sender, PropertyChangedEventArgs e)
+        {
+            OnResourceChanged();
+        }
+
+        protected override void UnsubscribeEventHandlers()
+        {
+            if (_rl != null)
+            {
+                _rl.PropertyChanged -= OnRasterLayerPropertyChanged;
+            }
+            base.UnsubscribeEventHandlers();
+        }
+
         private FeatureSourceDescription _cachedDesc;
 
         protected override void OnLoad(EventArgs e)
         {
+            if (_cachedDesc == null)
+                _cachedDesc = _edsvc.FeatureService.DescribeFeatureSource(txtFeatureSource.Text);
+
             //Init cached schemas and selected class
             if (!string.IsNullOrEmpty(txtFeatureClass.Text))
             {
-                if (_cachedDesc == null)
-                    _cachedDesc = _edsvc.FeatureService.DescribeFeatureSource(txtFeatureSource.Text);
-
                 var cls = _cachedDesc.GetClass(txtFeatureClass.Text);
                 if (cls != null)
                 {

Modified: trunk/Tools/Maestro/Maestro.Editors/LayerDefinition/Vector/VectorLayerSettingsSectionCtrl.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Editors/LayerDefinition/Vector/VectorLayerSettingsSectionCtrl.cs	2011-03-17 16:23:41 UTC (rev 5637)
+++ trunk/Tools/Maestro/Maestro.Editors/LayerDefinition/Vector/VectorLayerSettingsSectionCtrl.cs	2011-03-18 23:38:17 UTC (rev 5638)
@@ -73,12 +73,12 @@
 
         protected override void OnLoad(EventArgs e)
         {
+            if (_cachedDesc == null)
+                _cachedDesc = _edsvc.FeatureService.DescribeFeatureSource(txtFeatureSource.Text);
+
             //Init cached schemas and selected class
             if (!string.IsNullOrEmpty(txtFeatureClass.Text))
-            {
-                if (_cachedDesc == null)
-                    _cachedDesc = _edsvc.FeatureService.DescribeFeatureSource(txtFeatureSource.Text);
-
+            {                
                 var cls = _cachedDesc.GetClass(txtFeatureClass.Text);
                 if (cls != null)
                 {

Modified: trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/ObjectModels/LayerFactory.cs
===================================================================
--- trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/ObjectModels/LayerFactory.cs	2011-03-17 16:23:41 UTC (rev 5637)
+++ trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/ObjectModels/LayerFactory.cs	2011-03-18 23:38:17 UTC (rev 5638)
@@ -102,7 +102,34 @@
 
         public void CreateRasterLayer()
         {
-            this.Item = new GridLayerDefinitionType();
+            var gl = new GridLayerDefinitionType()
+            {
+                GridScaleRange = new System.ComponentModel.BindingList<GridScaleRangeType>(),
+            };
+
+            gl.AddGridScaleRange(new GridScaleRangeType()
+            {
+                ColorStyle = new GridColorStyleType()
+                {
+                    ColorRule = new System.ComponentModel.BindingList<GridColorRuleType>() 
+                    { 
+                        new GridColorRuleType() { 
+                            LegendLabel = string.Empty,
+                            Color = new GridColorType() 
+                        },
+                        new GridColorRuleType() { 
+                            LegendLabel = string.Empty,
+                            Color = new GridColorType()
+                        }
+                    }
+                },
+                RebuildFactor = 1.0
+            });
+
+            gl.GetScaleRangeAt(0).ColorStyle.GetColorRuleAt(0).Color.SetValue("000000");
+            gl.GetScaleRangeAt(0).ColorStyle.GetColorRuleAt(1).Color.SetValue("FFFFFF");
+
+            this.Item = gl;
         }
 
         public void CreateDrawingLayer()

Modified: trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/ObjectModels/LayerInterfaceExtensions.cs
===================================================================
--- trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/ObjectModels/LayerInterfaceExtensions.cs	2011-03-17 16:23:41 UTC (rev 5637)
+++ trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/ObjectModels/LayerInterfaceExtensions.cs	2011-03-18 23:38:17 UTC (rev 5638)
@@ -249,7 +249,7 @@
                         catch //Default to extents of active spatial context
                         {
                             var scList = conn.FeatureService.GetSpatialContextInfo(layer.SubLayer.ResourceId, true);
-                            if (scList.SpatialContext.Count == 1)
+                            if (scList.SpatialContext.Count > 0)
                             {
                                 var sc = scList.SpatialContext[0];
                                 return ObjectFactory.CreateEnvelope(
@@ -272,7 +272,7 @@
                         catch //Default to extents of active spatial context
                         {
                             var scList = conn.FeatureService.GetSpatialContextInfo(layer.SubLayer.ResourceId, true);
-                            if (scList.SpatialContext.Count == 1)
+                            if (scList.SpatialContext.Count > 0)
                             {
                                 var sc = scList.SpatialContext[0];
                                 return ObjectFactory.CreateEnvelope(

Modified: trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/SchemaOverrides/RasterWmsItem.cs
===================================================================
--- trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/SchemaOverrides/RasterWmsItem.cs	2011-03-17 16:23:41 UTC (rev 5637)
+++ trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/SchemaOverrides/RasterWmsItem.cs	2011-03-18 23:38:17 UTC (rev 5638)
@@ -118,6 +118,7 @@
 
             var fc = node.ParentNode.Attributes["name"].Value;
             this.FeatureClass = fc.Substring(0, fc.Length - "Type".Length);
+            this.RasterPropertyName = node.Attributes["name"].Value;
 
             var format = node["Format"];
             var transparent = node["Transparent"];

Modified: trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI.Http/RequestBuilder.cs
===================================================================
--- trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI.Http/RequestBuilder.cs	2011-03-17 16:23:41 UTC (rev 5637)
+++ trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI.Http/RequestBuilder.cs	2011-03-18 23:38:17 UTC (rev 5638)
@@ -1047,7 +1047,7 @@
 			param.Add("SESSION", m_sessionID);
 			param.Add("FORMAT", "text/xml");
 			param.Add("RESOURCEID", resourceID);
-			param.Add("ACTIVEONLY", activeOnly ? "0" : "1");
+			param.Add("ACTIVEONLY", activeOnly ? "1" : "0");
             param.Add("CLIENTAGENT", m_userAgent);
 
 			if (m_locale != null)



More information about the mapguide-commits mailing list