[mapguide-commits] r5653 - in trunk/Tools/Maestro:
Maestro.Editors/Fusion OSGeo.MapGuide.MaestroAPI/ObjectModels
OSGeo.MapGuide.MaestroAPI/Properties
OSGeo.MapGuide.MaestroAPI/Resource/Validation
svn_mapguide at osgeo.org
svn_mapguide at osgeo.org
Tue Mar 22 07:03:00 EDT 2011
Author: jng
Date: 2011-03-22 04:03:00 -0700 (Tue, 22 Mar 2011)
New Revision: 5653
Modified:
trunk/Tools/Maestro/Maestro.Editors/Fusion/MapCtrl.cs
trunk/Tools/Maestro/Maestro.Editors/Fusion/MapSettingsCtrl.cs
trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/ObjectModels/ApplicationDefinition.cs
trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Properties/Resources.Designer.cs
trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Properties/Resources.resx
trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Resource/Validation/ApplicationDefinitionValidator.cs
Log:
#1635: Some fixes
- Fix error when ticking available commercial layers and dirty state not being raised
- Fix certain map group UI elements not being initialized
- Add a validation rule to warn about incompatible coordinate systems when a commercial layer is included
Modified: trunk/Tools/Maestro/Maestro.Editors/Fusion/MapCtrl.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Editors/Fusion/MapCtrl.cs 2011-03-22 09:54:32 UTC (rev 5652)
+++ trunk/Tools/Maestro/Maestro.Editors/Fusion/MapCtrl.cs 2011-03-22 11:03:00 UTC (rev 5653)
@@ -36,7 +36,7 @@
namespace Maestro.Editors.Fusion
{
[ToolboxItem(false)]
- internal partial class MapCtrl : UserControl
+ internal partial class MapCtrl : UserControl, INotifyResourceChanged
{
const string G_NORMAL_MAP = "G_NORMAL_MAP";
const string G_SATELLITE_MAP = "G_SATELLITE_MAP";
@@ -57,12 +57,13 @@
private MapCtrl()
{
InitializeComponent();
+ cmbSelectionColor.ResetColors();
+ this.Disposed += new EventHandler(OnDisposed);
}
private IMap _map;
private IMapGroup _group;
private IMapView _initialView;
- private IResourceService _resSvc;
private Dictionary<string, CmsMap> _cmsMaps;
@@ -146,9 +147,12 @@
private bool _noEvents = true;
private IApplicationDefinition _appDef;
+ private IEditorService _edsvc;
- public MapCtrl(IApplicationDefinition appDef, IMapGroup group, IResourceService resSvc) : this()
+ public MapCtrl(IApplicationDefinition appDef, IMapGroup group, IEditorService edService) : this()
{
+ _edsvc = edService;
+ _edsvc.RegisterCustomNotifier(this);
_appDef = appDef;
_group = group;
@@ -157,12 +161,60 @@
if (map.Type.Equals("MapGuide"))
{
_map = map;
- break;
}
+ else
+ {
+ var cmsOpts = map.CmsMapOptions;
+ if (cmsOpts != null)
+ {
+ switch (cmsOpts.Type)
+ {
+ case G_HYBRID_MAP:
+ chkGoogHybrid.Checked = true;
+ break;
+ case G_NORMAL_MAP:
+ chkGoogStreets.Checked = true;
+ break;
+ case G_SATELLITE_MAP:
+ chkGoogSatellite.Checked = true;
+ break;
+ case BING_AERIAL:
+ chkBingSatellite.Checked = true;
+ break;
+ case BING_HYBRID:
+ chkBingHybrid.Checked = true;
+ break;
+ case BING_ROAD:
+ chkBingStreets.Checked = true;
+ break;
+ case YAHOO_MAP_HYB:
+ chkYahooHybrid.Checked = true;
+ break;
+ case YAHOO_MAP_REG:
+ chkYahooStreets.Checked = true;
+ break;
+ case YAHOO_MAP_SAT:
+ chkYahooSatellite.Checked = true;
+ break;
+ }
+ }
+ }
}
+ string googUrl = _appDef.GetValue("GoogleScript");
+ string yahooUrl = _appDef.GetValue("YahooScript");
+
+ if (!string.IsNullOrEmpty(googUrl))
+ {
+ txtGoogApiKey.Text = googUrl.Substring(GOOGLE_URL.Length);
+ }
+ if (!string.IsNullOrEmpty(yahooUrl))
+ {
+ txtYahooApiKey.Text = yahooUrl.Substring(YAHOO_URL.Length);
+ }
+ EvaluateCmsStates();
+
_initialView = _group.InitialView;
- _resSvc = resSvc;
_cmsMaps = new Dictionary<string, CmsMap>();
chkOverride.Checked = (_initialView != null);
@@ -180,25 +232,38 @@
{
double d;
if (double.TryParse(txtViewX.Text, out d))
+ {
_initialView.CenterX = d;
+ OnResourceChanged();
+ }
};
txtViewY.TextChanged += (s, e) =>
{
double d;
if (double.TryParse(txtViewY.Text, out d))
+ {
_initialView.CenterY = d;
+ OnResourceChanged();
+ }
};
txtViewScale.TextChanged += (s, e) =>
{
double d;
if (double.TryParse(txtViewScale.Text, out d))
+ {
_initialView.Scale = d;
+ OnResourceChanged();
+ }
};
TextBoxBinder.BindText(txtMapId, group, "id");
txtMapDefinition.Text = _map.GetMapDefinition();
- txtMapDefinition.TextChanged += (s, e) => { _map.SetMapDefinition(txtMapDefinition.Text); };
+ txtMapDefinition.TextChanged += (s, e) =>
+ {
+ _map.SetMapDefinition(txtMapDefinition.Text);
+ OnResourceChanged();
+ };
CheckBoxBinder.BindChecked(chkSingleTiled, _map, "SingleTile");
@@ -218,18 +283,36 @@
cmbSelectionColor.SelectedIndexChanged += (s, e) =>
{
_map.SetValue("SelectionColor", "0x" + Utility.SerializeHTMLColor(cmbSelectionColor.CurrentColor, true));
+ OnResourceChanged();
};
- chkSelectionAsOverlay.CheckedChanged += (s, e) => { _map.SetValue("SelectionAsOverlay", chkSelectionAsOverlay.Checked.ToString().ToLower()); };
+ chkSelectionAsOverlay.CheckedChanged += (s, e) =>
+ {
+ _map.SetValue("SelectionAsOverlay", chkSelectionAsOverlay.Checked.ToString().ToLower());
+ OnResourceChanged();
+ };
_noEvents = false;
}
+ void OnDisposed(object sender, EventArgs e)
+ {
+ var handler = this.ResourceChanged;
+ if (handler != null)
+ {
+ foreach (var h in handler.GetInvocationList())
+ {
+ this.ResourceChanged -= (EventHandler)h;
+ }
+ this.ResourceChanged = null;
+ }
+ }
+
private void InitCmsMaps(IMapGroup group)
{
foreach (var map in group.Map)
{
var opts = map.CmsMapOptions;
- if (opts != null && _cmsMaps.ContainsKey(opts.Type))
+ if (opts != null && !_cmsMaps.ContainsKey(opts.Type))
{
_cmsMaps[opts.Type] = new CmsMap(map) { IsEnabled = true };
}
@@ -266,15 +349,18 @@
_group.InitialView = _initialView;
else
_group.InitialView = null;
+
+ OnResourceChanged();
}
private void btnBrowseMdf_Click(object sender, EventArgs e)
{
- using (var picker = new ResourcePicker(_resSvc, ResourceTypes.MapDefinition, ResourcePickerMode.OpenResource))
+ using (var picker = new ResourcePicker(_edsvc.ResourceService, ResourceTypes.MapDefinition, ResourcePickerMode.OpenResource))
{
if (picker.ShowDialog() == DialogResult.OK)
{
txtMapDefinition.Text = picker.ResourceID;
+ OnResourceChanged();
}
}
}
@@ -315,6 +401,8 @@
_map.OverlayOptions = _map.CreateOverlayOptions(false, true, "EPSG:900913");
else
_map.OverlayOptions = null;
+
+ OnResourceChanged();
}
private bool IsUsingCmsLayers()
@@ -330,6 +418,9 @@
private void chkBingStreets_CheckedChanged(object sender, EventArgs e)
{
+ if (_noEvents)
+ return;
+
if (chkBingStreets.Checked)
_appDef.SetValue("VirtualEarthScript", BING_URL);
SetCmsAvailability(BING_ROAD, chkBingStreets.Checked);
@@ -337,6 +428,9 @@
private void chkBingSatellite_CheckedChanged(object sender, EventArgs e)
{
+ if (_noEvents)
+ return;
+
if (chkBingSatellite.Checked)
_appDef.SetValue("VirtualEarthScript", BING_URL);
SetCmsAvailability(BING_AERIAL, chkBingSatellite.Checked);
@@ -344,6 +438,9 @@
private void chkBingHybrid_CheckedChanged(object sender, EventArgs e)
{
+ if (_noEvents)
+ return;
+
if (chkBingHybrid.Checked)
_appDef.SetValue("VirtualEarthScript", BING_URL);
SetCmsAvailability(BING_HYBRID, chkBingHybrid.Checked);
@@ -351,36 +448,54 @@
private void chkGoogStreets_CheckedChanged(object sender, EventArgs e)
{
+ if (_noEvents)
+ return;
+
SetCmsAvailability(G_NORMAL_MAP, chkGoogStreets.Checked);
EvaluateCmsStates();
}
private void chkGoogSatellite_CheckedChanged(object sender, EventArgs e)
{
+ if (_noEvents)
+ return;
+
SetCmsAvailability(G_SATELLITE_MAP, chkGoogSatellite.Checked);
EvaluateCmsStates();
}
private void chkGoogHybrid_CheckedChanged(object sender, EventArgs e)
{
+ if (_noEvents)
+ return;
+
SetCmsAvailability(G_HYBRID_MAP, chkGoogHybrid.Checked);
EvaluateCmsStates();
}
private void chkYahooStreets_CheckedChanged(object sender, EventArgs e)
{
+ if (_noEvents)
+ return;
+
SetCmsAvailability(YAHOO_MAP_REG, chkYahooStreets.Checked);
EvaluateCmsStates();
}
private void chkYahooSatellite_CheckedChanged(object sender, EventArgs e)
{
+ if (_noEvents)
+ return;
+
SetCmsAvailability(YAHOO_MAP_SAT, chkYahooSatellite.Checked);
EvaluateCmsStates();
}
private void chkYahooHybrid_CheckedChanged(object sender, EventArgs e)
{
+ if (_noEvents)
+ return;
+
SetCmsAvailability(YAHOO_MAP_HYB, chkYahooHybrid.Checked);
EvaluateCmsStates();
}
@@ -407,16 +522,31 @@
private void txtGoogApiKey_TextChanged(object sender, EventArgs e)
{
+ if (_noEvents)
+ return;
+
_appDef.SetValue("GoogleScript", GOOGLE_URL + txtGoogApiKey.Text);
}
private void txtYahooApiKey_TextChanged(object sender, EventArgs e)
{
+ if (_noEvents)
+ return;
+
_appDef.SetValue("YahooScript", YAHOO_URL + txtGoogApiKey.Text);
}
const string GOOGLE_URL = "http://maps.google.com/maps?file=api&v=2&key=";
const string YAHOO_URL = "http://api.maps.yahoo.com/ajaxymap?v=3.0&appid=";
const string BING_URL = "http://dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=6.2";
+
+ private void OnResourceChanged()
+ {
+ var handler = this.ResourceChanged;
+ if (handler != null)
+ handler(this, EventArgs.Empty);
+ }
+
+ public event EventHandler ResourceChanged;
}
}
Modified: trunk/Tools/Maestro/Maestro.Editors/Fusion/MapSettingsCtrl.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Editors/Fusion/MapSettingsCtrl.cs 2011-03-22 09:54:32 UTC (rev 5652)
+++ trunk/Tools/Maestro/Maestro.Editors/Fusion/MapSettingsCtrl.cs 2011-03-22 11:03:00 UTC (rev 5653)
@@ -107,7 +107,7 @@
if (grp != null)
{
propertiesPanel.Controls.Clear();
- var mapCtrl = new MapCtrl(_flexLayout, grp, _edsvc.ResourceService);
+ var mapCtrl = new MapCtrl(_flexLayout, grp, _edsvc);
mapCtrl.Dock = DockStyle.Fill;
propertiesPanel.Controls.Add(mapCtrl);
}
Modified: trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/ObjectModels/ApplicationDefinition.cs
===================================================================
--- trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/ObjectModels/ApplicationDefinition.cs 2011-03-22 09:54:32 UTC (rev 5652)
+++ trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/ObjectModels/ApplicationDefinition.cs 2011-03-22 11:03:00 UTC (rev 5653)
@@ -975,7 +975,7 @@
set
{
if (!this.Type.Equals("MapGuide"))
- throw new InvalidOperationException("Overlay options are only applicable to MapGuide maps");
+ throw new InvalidOperationException("Overlay options are only applicable to MapGuide maps"); //LOCALIZEME
if (value == null)
{
@@ -1024,9 +1024,9 @@
el.RemoveAll();
- var n = AppDefDocument.Instance.CreateElement("isBaseLayer");
- var t = AppDefDocument.Instance.CreateElement("useOverlay");
- var p = AppDefDocument.Instance.CreateElement("projection");
+ var n = el.OwnerDocument.CreateElement("isBaseLayer");
+ var t = el.OwnerDocument.CreateElement("useOverlay");
+ var p = el.OwnerDocument.CreateElement("projection");
n.InnerText = value.IsBaseLayer.ToString().ToLower();
t.InnerText = value.UseOverlay.ToString().ToLower();
Modified: trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Properties/Resources.Designer.cs
===================================================================
--- trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Properties/Resources.Designer.cs 2011-03-22 09:54:32 UTC (rev 5652)
+++ trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Properties/Resources.Designer.cs 2011-03-22 11:03:00 UTC (rev 5653)
@@ -115,6 +115,15 @@
}
/// <summary>
+ /// Looks up a localized string similar to The Map Definition {0} has a coordinate system that is not EPSG:3857. This map is in a group containing one or more commerical base layers. The specified Map Definition may not correctly display or line up with the commerical base layers..
+ /// </summary>
+ internal static string ADF_MapWithIncompatibleCommericalCs {
+ get {
+ return ResourceManager.GetString("ADF_MapWithIncompatibleCommericalCs", resourceCulture);
+ }
+ }
+
+ /// <summary>
/// Looks up a localized string similar to Fusion application specifies a start view that is outside the map's initial extents.
/// </summary>
internal static string ADF_ViewOutsideMapExtents {
Modified: trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Properties/Resources.resx
===================================================================
--- trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Properties/Resources.resx 2011-03-22 09:54:32 UTC (rev 5652)
+++ trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Properties/Resources.resx 2011-03-22 11:03:00 UTC (rev 5653)
@@ -488,4 +488,7 @@
<data name="MDF_NoFiniteDisplayScalesSpecified" xml:space="preserve">
<value>The Map Definition contains tiled layers but has no finite display scales defined</value>
</data>
+ <data name="ADF_MapWithIncompatibleCommericalCs" xml:space="preserve">
+ <value>The Map Definition {0} has a coordinate system that is not EPSG:3857. This map is in a group containing one or more commerical base layers. The specified Map Definition may not correctly display or line up with the commerical base layers.</value>
+ </data>
</root>
\ No newline at end of file
Modified: trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Resource/Validation/ApplicationDefinitionValidator.cs
===================================================================
--- trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Resource/Validation/ApplicationDefinitionValidator.cs 2011-03-22 09:54:32 UTC (rev 5652)
+++ trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Resource/Validation/ApplicationDefinitionValidator.cs 2011-03-22 11:03:00 UTC (rev 5653)
@@ -67,26 +67,38 @@
{
foreach (IMapGroup mapGroup in fusionApp.MapSet.MapGroups)
{
+ bool checkCmsProjection = false;
+ List<IMapDefinition> mapDefsInGroup = new List<IMapDefinition>();
foreach (IMap map in mapGroup.Map)
{
+ if (IsCommercialOverlay(map))
+ {
+ checkCmsProjection = true;
+ }
try
{
- if (map.Extension == null || string.IsNullOrEmpty(map.GetMapDefinition()))
+ if (map.Type.ToLower() == "mapguide")
{
- issues.Add(new ValidationIssue(fusionApp, ValidationStatus.Error, string.Format(Properties.Resources.ADF_MapInvalidError, mapGroup.id)));
- }
- else
- {
- IMapDefinition mdef = (IMapDefinition)context.GetResource(map.GetMapDefinition());
+ var mdfId = map.GetMapDefinition();
+ if (string.IsNullOrEmpty(mdfId) || !resource.CurrentConnection.ResourceService.ResourceExists(mdfId))
+ {
+ issues.Add(new ValidationIssue(fusionApp, ValidationStatus.Error, string.Format(Properties.Resources.ADF_MapInvalidError, mapGroup.id)));
+ }
+ else
+ {
+ IMapDefinition mdef = (IMapDefinition)context.GetResource(mdfId);
+ mapDefsInGroup.Add(mdef);
- issues.AddRange(ResourceValidatorSet.Validate(context, mdef, true));
+ if (recurse)
+ issues.AddRange(ResourceValidatorSet.Validate(context, mdef, true));
- IEnvelope mapEnv = ObjectFactory.CreateEnvelope(mdef.Extents.MinX, mdef.Extents.MaxX, mdef.Extents.MinY, mdef.Extents.MaxY);
+ IEnvelope mapEnv = ObjectFactory.CreateEnvelope(mdef.Extents.MinX, mdef.Extents.MaxX, mdef.Extents.MinY, mdef.Extents.MaxY);
- if (mapGroup.InitialView != null)
- {
- if (!mapEnv.Contains(mapGroup.InitialView.CenterX, mapGroup.InitialView.CenterY))
- issues.Add(new ValidationIssue(mdef, ValidationStatus.Warning, string.Format(Properties.Resources.ADF_ViewOutsideMapExtents)));
+ if (mapGroup.InitialView != null)
+ {
+ if (!mapEnv.Contains(mapGroup.InitialView.CenterX, mapGroup.InitialView.CenterY))
+ issues.Add(new ValidationIssue(mdef, ValidationStatus.Warning, string.Format(Properties.Resources.ADF_ViewOutsideMapExtents)));
+ }
}
}
}
@@ -96,6 +108,19 @@
issues.Add(new ValidationIssue(fusionApp, ValidationStatus.Error, string.Format(Properties.Resources.ADF_MapValidationError, mapGroup.id, msg)));
}
}
+
+ if (checkCmsProjection)
+ {
+ foreach (var mdf in mapDefsInGroup)
+ {
+ var wkt = mdf.CoordinateSystem;
+ var csCode = resource.CurrentConnection.CoordinateSystemCatalog.ConvertWktToCoordinateSystemCode(wkt);
+ if (csCode.ToUpper() != "WGS84.PSEUDOMERCATOR")
+ {
+ issues.Add(new ValidationIssue(resource, ValidationStatus.Warning, string.Format(Properties.Resources.ADF_MapWithIncompatibleCommericalCs, mdf.ResourceID)));
+ }
+ }
+ }
}
}
}
@@ -105,6 +130,12 @@
return issues.ToArray();
}
+ private static bool IsCommercialOverlay(IMap map)
+ {
+ string type = map.Type.ToLower();
+ return type == "google" || type == "virtualearth" || type == "yahoo";
+ }
+
/// <summary>
/// Gets the resource type and version this validator supports
/// </summary>
More information about the mapguide-commits
mailing list