[mapguide-commits] r9125 - in trunk/Tools/Maestro: OSGeo.MapGuide.MaestroAPI/Tile OSGeo.MapGuide.MaestroAPI.Tests

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Wed Jan 25 06:41:18 PST 2017


Author: jng
Date: 2017-01-25 06:41:18 -0800 (Wed, 25 Jan 2017)
New Revision: 9125

Modified:
   trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI.Tests/TileTests.cs
   trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Tile/BatchSettings.cs
Log:
Fix the row/col offset calculations when override extents are involved

Fixes #2745

Modified: trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Tile/BatchSettings.cs
===================================================================
--- trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Tile/BatchSettings.cs	2017-01-25 14:01:47 UTC (rev 9124)
+++ trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Tile/BatchSettings.cs	2017-01-25 14:41:18 UTC (rev 9125)
@@ -687,28 +687,28 @@
                 // Also have in mind that you can also request tiles beyond the map extent (for example tile (-1, -1), however, there is probably no point to cache them unless you have valid data outside your initial map extents.
 
                 //The tile extent in meters
-                double tileWidth = ((INCH_TO_METER / m_parent.Config.DPI * m_parent.Config.TileWidth) * (scale));
-                double tileHeight = ((INCH_TO_METER / m_parent.Config.DPI * m_parent.Config.TileHeight) * (scale));
+                double tileMapWidth = ((INCH_TO_METER / m_parent.Config.DPI * m_parent.Config.TileWidth) * (scale));
+                double tileMapHeight = ((INCH_TO_METER / m_parent.Config.DPI * m_parent.Config.TileHeight) * (scale));
 
                 //Using this algorithm, yields a negative number of columns/rows, if the max scale is larger than the max extent of the map.
-                rows = Math.Max(1, (int)Math.Ceiling((height_in_meters / tileHeight)));
-                cols = Math.Max(1, (int)Math.Ceiling((width_in_meters / tileWidth)));
+                rows = Math.Max(1, (int)Math.Ceiling((height_in_meters / tileMapHeight)));
+                cols = Math.Max(1, (int)Math.Ceiling((width_in_meters / tileMapWidth)));
                 
                 if (m_maxExtent != null)
                 {
                     //The extent is overridden, so we need to adjust the start offsets
                     //and re-compute row/col span against the overridden extents
-                    double offsetX = m_maxExtent.MinX - m_tileSetExtents.MinX;
-                    double offsetY = m_tileSetExtents.MaxY - m_maxExtent.MaxY;
-                    rowTileOffset = (int)Math.Floor(offsetY / tileHeight);
-                    colTileOffset = (int)Math.Floor(offsetX / tileWidth);
+                    double offsetMapX = Math.Abs(m_parent.Config.MetersPerUnit * (m_maxExtent.MinX - m_tileSetExtents.MinX));
+                    double offsetMapY = Math.Abs(m_parent.Config.MetersPerUnit * (m_tileSetExtents.MaxY - m_maxExtent.MaxY));
+                    rowTileOffset = (int)Math.Floor(offsetMapY / tileMapHeight);
+                    colTileOffset = (int)Math.Floor(offsetMapX / tileMapWidth);
 
                     //Re-compute rows/cols against override extent
                     width_in_meters = Math.Abs(m_parent.Config.MetersPerUnit * (m_maxExtent.MaxX - m_maxExtent.MinX));
                     height_in_meters = Math.Abs(m_parent.Config.MetersPerUnit * (m_maxExtent.MaxY - m_maxExtent.MinY));
 
-                    rows = Math.Max(1, (int)Math.Ceiling((height_in_meters / tileHeight)));
-                    cols = Math.Max(1, (int)Math.Ceiling((width_in_meters / tileWidth)));
+                    rows = Math.Max(1, (int)Math.Ceiling((height_in_meters / tileMapHeight)));
+                    cols = Math.Max(1, (int)Math.Ceiling((width_in_meters / tileMapWidth)));
                 }
                 m_dimensions[i] = new long[] { rows, cols, rowTileOffset, colTileOffset };
             }

Modified: trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI.Tests/TileTests.cs
===================================================================
--- trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI.Tests/TileTests.cs	2017-01-25 14:01:47 UTC (rev 9124)
+++ trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI.Tests/TileTests.cs	2017-01-25 14:41:18 UTC (rev 9125)
@@ -98,7 +98,7 @@
 
             Assert.AreEqual(127472, tileConf.TotalTiles);
 
-            customExtents = ObjectFactory.CreateEnvelope(-87.73, 43.71, -87.71, 43.75);
+            customExtents = ObjectFactory.CreateEnvelope(-87.7278601614039, 43.7443959276596, -87.7135994943579, 43.7592852552018);
             tileConf.SetScalesAndExtend(Enumerable.Range(0, 10).ToArray(), customExtents);
 
             //I don't know the exact number here, but it should be less than the original and



More information about the mapguide-commits mailing list