[mapguide-commits] r5739 - in trunk/Tools/Maestro: Maestro OSGeo.MapGuide.MaestroAPI/Mapping

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Wed May 4 09:36:44 EDT 2011


Author: jng
Date: 2011-05-04 06:36:44 -0700 (Wed, 04 May 2011)
New Revision: 5739

Modified:
   trunk/Tools/Maestro/Maestro/changelog.txt
   trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Mapping/RuntimeMap.cs
Log:
Update changelog.txt and add a helper API to RuntimeMap to initialize display parameters


Modified: trunk/Tools/Maestro/Maestro/changelog.txt
===================================================================
--- trunk/Tools/Maestro/Maestro/changelog.txt	2011-05-04 13:33:15 UTC (rev 5738)
+++ trunk/Tools/Maestro/Maestro/changelog.txt	2011-05-04 13:36:44 UTC (rev 5739)
@@ -1,6 +1,8 @@
 3.1
 ---
 
+ - This is the first release with a public SDK and samples demonstrating using the Maestro API.
+ - Fix: Map Definition resource id field in a WebLayout 1.1.0 editor does not update when changed.
  - Added a tip of the day dialog that is shown on startup (this can be turned off)
 
 3.0 Final

Modified: trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Mapping/RuntimeMap.cs
===================================================================
--- trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Mapping/RuntimeMap.cs	2011-05-04 13:33:15 UTC (rev 5738)
+++ trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Mapping/RuntimeMap.cs	2011-05-04 13:36:44 UTC (rev 5739)
@@ -184,6 +184,44 @@
         }
 
         /// <summary>
+        /// Sets the width, height and initial view scale
+        /// </summary>
+        /// <param name="width"></param>
+        /// <param name="height"></param>
+        public void InitialiseDisplayParameters(int width, int height)
+        {
+            this.DisplayWidth = width;
+            this.DisplayHeight = height;
+
+            var ext = this.MapExtent;
+            
+            var orgX1 = ext.MinX;
+            var orgY2 = ext.MinY;
+            var orgX2 = ext.MaxX;
+            var orgY1 = ext.MaxY;
+
+            if ((orgX1 - orgX2) == 0 || (orgY1 - orgY2) == 0)
+            {
+                orgX1 = -.1;
+                orgX2 = .1;
+                orgY1 = -.1;
+                orgY2 = .1;
+            }
+
+            var scale = CalculateScale(Math.Abs(orgX2 - orgX1), Math.Abs(orgY2 - orgY1), this.DisplayWidth, this.DisplayHeight);
+            this.ViewScale = scale;
+        }
+
+        private double CalculateScale(double mcsW, double mcsH, int devW, int devH)
+        {
+            var mpp = 0.0254 / this.DisplayDpi;
+            if (devH * mcsW < devW * mcsH)
+                return mcsW * this.MetersPerUnit / (devW * mpp);
+            else
+                return mcsH * this.MetersPerUnit / (devH * mpp);
+        }
+
+        /// <summary>
         /// Initializes a new instance of the <see cref="RuntimeMap"/> class.
         /// </summary>
         /// <param name="mdf">The map definition to create this map from.</param>



More information about the mapguide-commits mailing list