[mapguide-commits] r6243 - in trunk/Tools/Maestro: MaestroAPITests OSGeo.MapGuide.MaestroAPI/Services OSGeo.MapGuide.MaestroAPI.Http

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Tue Nov 22 08:55:27 EST 2011


Author: jng
Date: 2011-11-22 05:55:27 -0800 (Tue, 22 Nov 2011)
New Revision: 6243

Modified:
   trunk/Tools/Maestro/MaestroAPITests/RuntimeMapTests.cs
   trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI.Http/HttpServerConnection.cs
   trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Services/IMappingService.cs
Log:
#1860: The GetLegendImage() API is already implemented. It just wasn't accessible through any public interface. This submission exposes this method through the IMappingService interface. A unit test has been added to exercise this API.

Modified: trunk/Tools/Maestro/MaestroAPITests/RuntimeMapTests.cs
===================================================================
--- trunk/Tools/Maestro/MaestroAPITests/RuntimeMapTests.cs	2011-11-22 07:50:47 UTC (rev 6242)
+++ trunk/Tools/Maestro/MaestroAPITests/RuntimeMapTests.cs	2011-11-22 13:55:27 UTC (rev 6243)
@@ -460,6 +460,46 @@
 
         #endregion
 
+        public virtual void TestLegendIconRendering()
+        {
+            var resSvc = _conn.ResourceService;
+            var mapSvc = _conn.GetService((int)ServiceType.Mapping) as IMappingService;
+            Assert.NotNull(mapSvc);
+
+            var mdf = resSvc.GetResource("Library://UnitTests/Maps/Sheboygan.MapDefinition") as IMapDefinition;
+            Assert.NotNull(mdf);
+
+            //FIXME: We have a problem. Can we calculate this value without MgCoordinateSystem and just using the WKT?
+            //The answer to this will answer whether we can actually support the Rendering Service API over http 
+            //using pure client-side runtime maps 
+            //
+            //The hard-coded value here was the output of MgCoordinateSystem.ConvertCoordinateSystemUnitsToMeters(1.0)
+            //for this particular map.
+            double metersPerUnit = 111319.490793274;
+            var cs = CoordinateSystemBase.Create(mdf.CoordinateSystem);
+            metersPerUnit = cs.MetersPerUnitX;
+            Trace.TraceInformation("Using MPU of: {0}", metersPerUnit);
+
+            var mid = "Session:" + _conn.SessionID + "//TestLegendIconRendering.Map";
+            var map = mapSvc.CreateMap(mid, mdf, metersPerUnit);
+            map.ViewScale = 12000;
+            map.DisplayWidth = 1024;
+            map.DisplayHeight = 1024;
+            map.DisplayDpi = 96;
+
+            //Doesn't exist yet because save isn't called
+            Assert.IsTrue(!resSvc.ResourceExists(mid));
+            map.Save();
+
+            int counter = 0;
+            foreach (var layer in map.Layers)
+            {
+                var icon = mapSvc.GetLegendImage(map.ViewScale, layer.LayerDefinitionID, -1, -1);
+                icon.Save("TestLegendIconRendering_" + counter + ".png");
+                counter++;
+            }
+        }
+
         public virtual void TestRender12k()
         { 
             //Render a map of sheboygan at 12k
@@ -989,6 +1029,12 @@
         }
 
         [Test]
+        public override void TestLegendIconRendering()
+        {
+            base.TestLegendIconRendering();
+        }
+
+        [Test]
         public override void TestMapManipulation()
         {
             base.TestMapManipulation();
@@ -1055,6 +1101,12 @@
         }
 
         [Test]
+        public override void TestLegendIconRendering()
+        {
+            base.TestLegendIconRendering();
+        }
+
+        [Test]
         public override void TestMapManipulation()
         {
             base.TestMapManipulation();

Modified: trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Services/IMappingService.cs
===================================================================
--- trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Services/IMappingService.cs	2011-11-22 07:50:47 UTC (rev 6242)
+++ trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Services/IMappingService.cs	2011-11-22 13:55:27 UTC (rev 6243)
@@ -228,5 +228,15 @@
         /// <param name="format"></param>
         /// <returns></returns>
         System.IO.Stream RenderMapLegend(RuntimeMap map, int width, int height, Color backgroundColor, string format);
+
+        /// <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>
+        /// <returns>The minature bitmap</returns>
+        System.Drawing.Image GetLegendImage(double scale, string layerdefinition, int themeIndex, int type);
     }
 }

Modified: trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI.Http/HttpServerConnection.cs
===================================================================
--- trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI.Http/HttpServerConnection.cs	2011-11-22 07:50:47 UTC (rev 6242)
+++ trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI.Http/HttpServerConnection.cs	2011-11-22 13:55:27 UTC (rev 6243)
@@ -1298,7 +1298,6 @@
             return new System.Drawing.Bitmap(this.OpenRead(param));
         }
 
-
         /// <summary>
         /// Upload a MapGuide Package file to the server
         /// </summary>



More information about the mapguide-commits mailing list