[mapguide-commits] r6264 - in trunk/Tools/Maestro:
Maestro.Editors/MapDefinition MaestroAPITests
OSGeo.MapGuide.MaestroAPI OSGeo.MapGuide.MaestroAPI/Services
OSGeo.MapGuide.MaestroAPI.Http OSGeo.MapGuide.MaestroAPI.Native
svn_mapguide at osgeo.org
svn_mapguide at osgeo.org
Tue Nov 29 11:25:17 EST 2011
Author: jng
Date: 2011-11-29 08:25:17 -0800 (Tue, 29 Nov 2011)
New Revision: 6264
Modified:
trunk/Tools/Maestro/Maestro.Editors/MapDefinition/MapDefinitionEditorCtrl.cs
trunk/Tools/Maestro/MaestroAPITests/RuntimeMapTests.cs
trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI.Http/HttpServerConnection.cs
trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI.Http/RequestBuilder.cs
trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI.Native/LocalNativeConnection.cs
trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/MgServerConnectionBase.cs
trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Services/IMappingService.cs
Log:
Add a new overload of GetLegendImage which allows for custom image formats and sizes. Update the existing unit tests to exercise this new overload. Also add a missing bit from the previous submission.
Modified: trunk/Tools/Maestro/Maestro.Editors/MapDefinition/MapDefinitionEditorCtrl.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Editors/MapDefinition/MapDefinitionEditorCtrl.cs 2011-11-29 15:59:13 UTC (rev 6263)
+++ trunk/Tools/Maestro/Maestro.Editors/MapDefinition/MapDefinitionEditorCtrl.cs 2011-11-29 16:25:17 UTC (rev 6264)
@@ -55,6 +55,7 @@
{
_edSvc = service;
_map = _edSvc.GetEditedResource() as IMapDefinition;
+ _map.SetExtentsFromFirstAddedLayer = true;
mapSettingsCtrl.Bind(service);
mapLayersCtrl.Bind(service);
Modified: trunk/Tools/Maestro/MaestroAPITests/RuntimeMapTests.cs
===================================================================
--- trunk/Tools/Maestro/MaestroAPITests/RuntimeMapTests.cs 2011-11-29 15:59:13 UTC (rev 6263)
+++ trunk/Tools/Maestro/MaestroAPITests/RuntimeMapTests.cs 2011-11-29 16:25:17 UTC (rev 6264)
@@ -495,9 +495,30 @@
foreach (var layer in map.Layers)
{
var icon = mapSvc.GetLegendImage(map.ViewScale, layer.LayerDefinitionID, -1, -1);
- icon.Save("TestLegendIconRendering_" + counter + ".png");
+ icon.Save("TestLegendIconRendering_" + counter + "_16x16.png");
counter++;
}
+
+ foreach (var layer in map.Layers)
+ {
+ var icon = mapSvc.GetLegendImage(map.ViewScale, layer.LayerDefinitionID, -1, -1, 16, 16, "JPG");
+ icon.Save("TestLegendIconRendering_" + counter + "_16x16.jpg");
+ counter++;
+ }
+
+ foreach (var layer in map.Layers)
+ {
+ var icon = mapSvc.GetLegendImage(map.ViewScale, layer.LayerDefinitionID, -1, -1, 16, 16, "GIF");
+ icon.Save("TestLegendIconRendering_" + counter + "_16x16.gif");
+ counter++;
+ }
+
+ foreach (var layer in map.Layers)
+ {
+ var icon = mapSvc.GetLegendImage(map.ViewScale, layer.LayerDefinitionID, -1, -1, 160, 50, "PNG");
+ icon.Save("TestLegendIconRendering_" + counter + "_160x50.png");
+ counter++;
+ }
}
public virtual void TestRender12k()
Modified: trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/MgServerConnectionBase.cs
===================================================================
--- trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/MgServerConnectionBase.cs 2011-11-29 15:59:13 UTC (rev 6263)
+++ trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/MgServerConnectionBase.cs 2011-11-29 16:25:17 UTC (rev 6264)
@@ -176,10 +176,24 @@
/// <param name="themeIndex">If the layer is themed, this gives the theme index, otherwise set to 0</param>
/// <param name="type">The geometry type, 1 for point, 2 for line, 3 for area, 4 for composite</param>
/// <returns>The minature bitmap</returns>
- abstract public System.Drawing.Image GetLegendImage(double scale, string layerdefinition, int themeIndex, int type);
+ public virtual System.Drawing.Image GetLegendImage(double scale, string layerdefinition, int themeIndex, int type)
+ {
+ return GetLegendImage(scale, layerdefinition, themeIndex, type, 16, 16, "PNG");
+ }
+ /// <summary>
+ /// Gets the legend image.
+ /// </summary>
+ /// <param name="scale">The scale.</param>
+ /// <param name="layerdefinition">The layerdefinition.</param>
+ /// <param name="themeIndex">Index of the theme.</param>
+ /// <param name="type">The type.</param>
+ /// <param name="width">The width.</param>
+ /// <param name="height">The height.</param>
+ /// <param name="format">The format.</param>
+ /// <returns></returns>
+ abstract public System.Drawing.Image GetLegendImage(double scale, string layerdefinition, int themeIndex, int type, int width, int height, string format);
-
/// <summary>
/// Renders the runtime map.
/// </summary>
Modified: trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Services/IMappingService.cs
===================================================================
--- trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Services/IMappingService.cs 2011-11-29 15:59:13 UTC (rev 6263)
+++ trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Services/IMappingService.cs 2011-11-29 16:25:17 UTC (rev 6264)
@@ -240,6 +240,19 @@
System.Drawing.Image GetLegendImage(double scale, string layerdefinition, int themeIndex, int type);
/// <summary>
+ ///Renders a minature bitmap of the layers style
+ /// </summary>
+ /// <param name="scale">The scale for the bitmap to match</param>
+ /// <param name="layerdefinition">The layer definition resource id</param>
+ /// <param name="themeIndex">If the layer is themed, this gives the theme index, otherwise set to 0</param>
+ /// <param name="type">The geometry type, 1 for point, 2 for line, 3 for area, 4 for composite</param>
+ /// <param name="width">The width of the image to request.</param>
+ /// <param name="height">The height of the image to request.</param>
+ /// <param name="format">The image format (PNG, JPG or GIF).</param>
+ /// <returns></returns>
+ System.Drawing.Image GetLegendImage(double scale, string layerdefinition, int themeIndex, int type, int width, int height, string format);
+
+ /// <summary>
/// Selects features from a runtime map, returning a selection Xml.
/// </summary>
/// <param name="runtimeMapName">The map to query. NOT a resourceID, only the map name!</param>
Modified: trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI.Http/HttpServerConnection.cs
===================================================================
--- trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI.Http/HttpServerConnection.cs 2011-11-29 15:59:13 UTC (rev 6263)
+++ trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI.Http/HttpServerConnection.cs 2011-11-29 16:25:17 UTC (rev 6264)
@@ -1292,9 +1292,9 @@
/// <param name="themeIndex">If the layer is themed, this gives the theme index, otherwise set to 0</param>
/// <param name="type">The geometry type, 1 for point, 2 for line, 3 for area, 4 for composite</param>
/// <returns>The minature bitmap</returns>
- public override System.Drawing.Image GetLegendImage(double scale, string layerdefinition, int themeIndex, int type)
+ public override System.Drawing.Image GetLegendImage(double scale, string layerdefinition, int themeIndex, int type, int width, int height, string format)
{
- string param = m_reqBuilder.GetLegendImage(scale, layerdefinition, themeIndex, type);
+ string param = m_reqBuilder.GetLegendImage(scale, layerdefinition, themeIndex, type, width, height, format);
return new System.Drawing.Bitmap(this.OpenRead(param));
}
Modified: trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI.Http/RequestBuilder.cs
===================================================================
--- trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI.Http/RequestBuilder.cs 2011-11-29 15:59:13 UTC (rev 6263)
+++ trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI.Http/RequestBuilder.cs 2011-11-29 16:25:17 UTC (rev 6264)
@@ -1140,7 +1140,7 @@
return m_hosturi + "?" + EncodeParameters(param);
}
- public string GetLegendImage(double scale, string layerdef, int themeIndex, int type)
+ public string GetLegendImage(double scale, string layerdef, int themeIndex, int type, int width, int height, string format)
{
NameValueCollection param = new NameValueCollection();
param.Add("OPERATION", "GETLEGENDIMAGE");
@@ -1149,6 +1149,9 @@
param.Add("SCALE", scale.ToString(System.Globalization.CultureInfo.InvariantCulture));
param.Add("LAYERDEFINITION", layerdef);
param.Add("THEMECATEGORY", themeIndex.ToString());
+ param.Add("WIDTH", width.ToString());
+ param.Add("HEIGHT", height.ToString());
+ param.Add("FORMAT", format);
param.Add("TYPE", type.ToString());
param.Add("CLIENTAGENT", m_userAgent);
Modified: trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI.Native/LocalNativeConnection.cs
===================================================================
--- trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI.Native/LocalNativeConnection.cs 2011-11-29 15:59:13 UTC (rev 6263)
+++ trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI.Native/LocalNativeConnection.cs 2011-11-29 16:25:17 UTC (rev 6264)
@@ -871,13 +871,18 @@
/// <param name="layerdefinition">The layer the image should represent</param>
/// <param name="themeIndex">If the layer is themed, this gives the theme index, otherwise set to 0</param>
/// <param name="type">The geometry type, 1 for point, 2 for line, 3 for area, 4 for composite</param>
- /// <returns>The minature bitmap</returns>
- public override System.Drawing.Image GetLegendImage(double scale, string layerdefinition, int themeIndex, int type)
+ /// <param name="width">The width.</param>
+ /// <param name="height">The height.</param>
+ /// <param name="format">The format.</param>
+ /// <returns>
+ /// The minature bitmap
+ /// </returns>
+ public override System.Drawing.Image GetLegendImage(double scale, string layerdefinition, int themeIndex, int type, int width, int height, string format)
{
MgMappingService ms = this.Connection.CreateService(MgServiceType.MappingService) as MgMappingService;
MgResourceIdentifier ldef = new MgResourceIdentifier(layerdefinition);
- var bmp = new System.Drawing.Bitmap(Utility.MgStreamToNetStream(ms, ms.GetType().GetMethod("GenerateLegendImage"), new object[] { ldef, scale, 16, 16, "PNG", type, themeIndex }));
+ var bmp = new System.Drawing.Bitmap(Utility.MgStreamToNetStream(ms, ms.GetType().GetMethod("GenerateLegendImage"), new object[] { ldef, scale, width, height, format, type, themeIndex }));
LogMethodCall("MgMappingService::GetLegendImage", true, scale.ToString(), layerdefinition, themeIndex.ToString(), type.ToString());
return bmp;
}
More information about the mapguide-commits
mailing list