[mapguide-commits] r7649 - in trunk/Tools/Maestro: MgCooker OSGeo.MapGuide.MaestroAPI/Tile
svn_mapguide at osgeo.org
svn_mapguide at osgeo.org
Thu Jun 27 20:03:42 PDT 2013
Author: jng
Date: 2013-06-27 20:03:42 -0700 (Thu, 27 Jun 2013)
New Revision: 7649
Modified:
trunk/Tools/Maestro/MgCooker/Program.cs
trunk/Tools/Maestro/MgCooker/SetupRun.cs
trunk/Tools/Maestro/MgCooker/Strings.Designer.cs
trunk/Tools/Maestro/MgCooker/Strings.resx
trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Tile/BatchSettings.cs
Log:
MgCooker fixes:
- #2291: Fix batch/commandline parameter inconsistency (patch by dcreado)
- #2289: Fix override bounds not being respected in command-line mode. (patch by dcreado)
- Fix bad spacing and executable name in batch file generation
- Fix bad console progress format string
Modified: trunk/Tools/Maestro/MgCooker/Program.cs
===================================================================
--- trunk/Tools/Maestro/MgCooker/Program.cs 2013-06-27 07:33:17 UTC (rev 7648)
+++ trunk/Tools/Maestro/MgCooker/Program.cs 2013-06-28 03:03:42 UTC (rev 7649)
@@ -67,6 +67,8 @@
//scaleindex=0,1,2,3,4,5
//basegroups="x","y"
//extentoverride=minx,miny,maxx,maxy
+
+ Boolean batchMode = false;
string mapagent = "http://localhost/mapguide";
string username = "Anonymous";
@@ -137,13 +139,20 @@
}
+ if (largs.IndexOf("batch") >= 0 || largs.IndexOf("/batch") >= 0 || largs.IndexOf("commandline") >= 0 || largs.IndexOf("/commandline") >= 0)
+ {
+ batchMode = true;
+ }
+
try
{
Console.Clear();
+ m_logableProgress = true;
}
catch
{
hasConsole = false;
+ m_logableProgress = false;
}
@@ -154,7 +163,7 @@
SetupRun sr = null;
if (!opts.ContainsKey("username") || (!opts.ContainsKey("mapagent")))
{
- if (largs.IndexOf("/commandline") < 0 && largs.IndexOf("commandline") < 0)
+ if (!batchMode)
{
if (opts.ContainsKey("provider") && opts.ContainsKey("connection-params"))
{
@@ -212,9 +221,9 @@
}
}
-
- if (largs.IndexOf("batch") < 0 && largs.IndexOf("/batch") < 0)
+
+ if (!batchMode)
{
if (sr == null)
sr = new SetupRun(connection, maps, opts);
@@ -273,21 +282,29 @@
bx.SetGroups(groups.ToArray());
}
- if (!string.IsNullOrEmpty(scaleindex))
+ if (overrideExtents != null)
{
List<int> scales = new List<int>();
int tmp;
foreach (string s in scaleindex.Split(','))
if (int.TryParse(s, out tmp))
scales.Add(tmp);
+ foreach (MapTilingConfiguration bm in bx.Maps)
+ bm.SetScalesAndExtend(scales.ToArray(), overrideExtents);
+ }
+ else if (!string.IsNullOrEmpty(scaleindex))
+ {
+ List<int> scales = new List<int>();
+ int tmp;
+ foreach (string s in scaleindex.Split(','))
+ if (int.TryParse(s, out tmp))
+ scales.Add(tmp);
bx.SetScales(scales.ToArray());
}
- if (overrideExtents != null)
- foreach (MapTilingConfiguration bm in bx.Maps)
- bm.MaxExtent = overrideExtents;
+
- if (largs.IndexOf("/commandline") < 0 && largs.IndexOf("commandline") < 0)
+ if (!batchMode)
{
Progress pg = new Progress(bx);
pg.ShowDialog();
Modified: trunk/Tools/Maestro/MgCooker/SetupRun.cs
===================================================================
--- trunk/Tools/Maestro/MgCooker/SetupRun.cs 2013-06-27 07:33:17 UTC (rev 7648)
+++ trunk/Tools/Maestro/MgCooker/SetupRun.cs 2013-06-28 03:03:42 UTC (rev 7649)
@@ -30,6 +30,7 @@
using OSGeo.MapGuide.MaestroAPI.Exceptions;
using System.Collections.Specialized;
using OSGeo.MapGuide.MaestroAPI.Tile;
+using OSGeo.MapGuide.ObjectModels;
namespace MgCooker
{
@@ -64,6 +65,7 @@
grpDifferentConnection.Enabled = chkUseDifferentConnection.Enabled = !m_connection.ProviderName.ToUpper().Equals("MAESTRO.LOCAL"); //NOXLATE
m_commandlineargs = args;
m_coordinateOverrides = new Dictionary<string, IEnvelope>();
+ IEnvelope overrideExtents = null;
//HttpServerConnection hc = connection as HttpServerConnection;
try
@@ -76,11 +78,6 @@
if (m_commandlineargs.ContainsKey("mapdefinitions")) //NOXLATE
m_commandlineargs.Remove("mapdefinitions"); //NOXLATE
- if (m_commandlineargs.ContainsKey("scaleindex")) //NOXLATE
- m_commandlineargs.Remove("scaleindex"); //NOXLATE
- if (m_commandlineargs.ContainsKey("basegroups")) //NOXLATE
- m_commandlineargs.Remove("basegroups"); //NOXLATE
-
if (m_commandlineargs.ContainsKey("mapagent")) //NOXLATE
MapAgent.Text = m_commandlineargs["mapagent"]; //NOXLATE
if (m_commandlineargs.ContainsKey("username")) //NOXLATE
@@ -111,6 +108,28 @@
}
}
+ if (m_commandlineargs.ContainsKey("extentoverride")) //NOXLATE
+ {
+ string[] parts = m_commandlineargs["extentoverride"].Split(',');
+ if (parts.Length == 4)
+ {
+ double minx;
+ double miny;
+ double maxx;
+ double maxy;
+ if (
+ double.TryParse(parts[0], System.Globalization.NumberStyles.Float, System.Globalization.CultureInfo.InvariantCulture, out minx) &&
+ double.TryParse(parts[1], System.Globalization.NumberStyles.Float, System.Globalization.CultureInfo.InvariantCulture, out miny) &&
+ double.TryParse(parts[2], System.Globalization.NumberStyles.Float, System.Globalization.CultureInfo.InvariantCulture, out maxx) &&
+ double.TryParse(parts[3], System.Globalization.NumberStyles.Float, System.Globalization.CultureInfo.InvariantCulture, out maxy)
+ )
+ {
+ overrideExtents = ObjectFactory.CreateEnvelope(minx, miny, maxx, maxy);
+ }
+ }
+
+ }
+
if (m_commandlineargs.ContainsKey("metersperunit")) //NOXLATE
{
double d;
@@ -133,6 +152,24 @@
maps = tmp.ToArray();
}
+
+ var basegroupsSelected = new List<string>();
+ if (m_commandlineargs.ContainsKey("basegroups"))//NOXLATE
+ {
+ basegroupsSelected = new List<string>(m_commandlineargs["basegroups"].Split(','));//NOXLATE
+ m_commandlineargs.Remove("basegroups"); //NOXLATE
+ }
+
+ var scalesSelected = new List<int>();
+ if (m_commandlineargs.ContainsKey("scaleindex")) //NOXLATE
+ {
+ foreach (string scaleIndex in m_commandlineargs["scaleindex"].Split(','))//NOXLATE
+ {
+ scalesSelected.Add(int.Parse(scaleIndex));
+ }
+ m_commandlineargs.Remove("scaleindex"); //NOXLATE
+ }
+
MapTree.Nodes.Clear();
foreach (string m in maps)
{
@@ -146,27 +183,43 @@
baseMap.HasGroups())
{
TreeNode mn = MapTree.Nodes.Add(m);
- //mn.Checked = true;
+
mn.ImageIndex = mn.SelectedImageIndex = 0;
mn.Tag = mdef;
foreach (var g in baseMap.BaseMapLayerGroup)
{
TreeNode gn = mn.Nodes.Add(g.Name);
gn.Tag = g;
- //gn.Checked = true;
+ if (basegroupsSelected.Contains(g.Name))
+ {
+ mn.Checked = true;
+ gn.Checked = true;
+ if (overrideExtents != null && !m_coordinateOverrides.ContainsKey(m))
+ {
+ m_coordinateOverrides.Add(m, overrideExtents);
+ }
+ }
+
gn.ImageIndex = gn.SelectedImageIndex = 1;
+ int counter = 0;
foreach (double d in baseMap.FiniteDisplayScale)
{
TreeNode sn = gn.Nodes.Add(d.ToString(System.Globalization.CultureInfo.CurrentUICulture));
- //sn.Checked = true;
+ if (gn.Checked && scalesSelected.Contains(counter))
+ {
+ sn.Checked = true;
+
+ }
sn.ImageIndex = sn.SelectedImageIndex = 3;
+ counter++;
}
}
mn.Expand();
}
}
+ MapTree_AfterSelect(null, null);
}
private void panel1_Paint(object sender, PaintEventArgs e)
@@ -256,9 +309,8 @@
{
MapTilingConfiguration bm = new MapTilingConfiguration(bx, c.MapDefinition);
bm.SetGroups(new string[] { c.Group });
- bm.SetScales(c.ScaleIndexes);
- if (c.ExtentOverride != null)
- bm.MaxExtent = c.ExtentOverride;
+ bm.SetScalesAndExtend(c.ScaleIndexes,c.ExtentOverride);
+
bx.Maps.Add(bm);
}
@@ -323,34 +375,36 @@
if (saveFileDialog1.ShowDialog(this) == DialogResult.OK)
{
- StringBuilder args = new StringBuilder();
- args.Append("--mapagent=\"" + MapAgent.Text + "\" "); //NOXLATE
- args.Append("--username=\"" + Username.Text + "\" "); //NOXLATE
- args.Append("--password=\"" + Password.Text + "\" "); //NOXLATE
+ //Common args for all map defintions to be tiled
+ List<string> args = new List<string>();
+ args.Add("--mapagent=\"" + MapAgent.Text + "\""); //NOXLATE
+ args.Add("--username=\"" + Username.Text + "\""); //NOXLATE
+ args.Add("--password=\"" + Password.Text + "\""); //NOXLATE
if (LimitTileset.Checked)
{
if (MaxRowLimit.Value > 0)
- args.Append("--limitrows=\"" + ((int)MaxRowLimit.Value).ToString() + "\" "); //NOXLATE
+ args.Add("--limitrows=\"" + ((int)MaxRowLimit.Value).ToString() + "\""); //NOXLATE
if (MaxColLimit.Value > 0)
- args.Append("--limitcols=\"" + ((int)MaxColLimit.Value).ToString() + "\" "); //NOXLATE
+ args.Add("--limitcols=\"" + ((int)MaxColLimit.Value).ToString() + "\""); //NOXLATE
}
if (UseNativeAPI.Checked)
- args.Append("--native-connection "); //NOXLATE
+ args.Add("--native-connection"); //NOXLATE
if (UseOfficialMethod.Checked)
- args.Append("--metersperunit=" + ((double)MetersPerUnit.Value).ToString(System.Globalization.CultureInfo.InvariantCulture) + " "); //NOXLATE
+ args.Add("--metersperunit=" + ((double)MetersPerUnit.Value).ToString(System.Globalization.CultureInfo.InvariantCulture)); //NOXLATE
- args.Append("--threadcount=" + ((int)ThreadCount.Value).ToString() + " "); //NOXLATE
+ args.Add("--threadcount=" + ((int)ThreadCount.Value).ToString()); //NOXLATE
if (RandomTileOrder.Checked)
- args.Append("--random-tile-order "); //NOXLATE
+ args.Add("--random-tile-order"); //NOXLATE
string executable = System.IO.Path.GetFileName(System.Reflection.Assembly.GetExecutingAssembly().Location);
+ string cmdExecutable = "MgCookerCmd.exe"; //NOXLATE
//Windows has problems with console output from GUI applications...
- if (System.Environment.OSVersion.Platform != PlatformID.Unix && executable == "MgCooker.exe" && System.IO.File.Exists(System.IO.Path.Combine(Application.StartupPath, "MgCookerCommandline.exe"))) //NOXLATE
- executable = System.IO.Path.Combine(Application.StartupPath, "MgCookerCommandline.exe"); //NOXLATE
+ if (System.Environment.OSVersion.Platform != PlatformID.Unix && executable == "MgCooker.exe" && System.IO.File.Exists(System.IO.Path.Combine(Application.StartupPath, cmdExecutable))) //NOXLATE
+ executable = System.IO.Path.Combine(Application.StartupPath, cmdExecutable); //NOXLATE
else
executable = System.IO.Path.Combine(Application.StartupPath, executable);
@@ -382,42 +436,59 @@
foreach (Config c in ReadTree())
{
+ //Map-specific args
+ List<string> argsMap = new List<string>();
if (System.Environment.OSVersion.Platform != PlatformID.MacOSX ||
System.Environment.OSVersion.Platform != PlatformID.Unix)
{
- sw.Write(exeName);
+ argsMap.Add(exeName);
}
else
{
- sw.Write(executable);
+ argsMap.Add(executable);
}
- sw.Write(" batch"); //NOXLATE
- sw.Write(" --mapdefinitions=\""); //NOXLATE
- sw.Write(c.MapDefinition);
- sw.Write("\" --basegroups=\""); //NOXLATE
- sw.Write(c.Group);
- sw.Write("\" --scaleindex="); //NOXLATE
+
+ argsMap.Add("batch"); //NOXLATE
+ argsMap.Add("--mapdefinitions=\"" + c.MapDefinition + "\"");
+ argsMap.Add("--basegroups=\"" + c.Group + "\"");
+ StringBuilder si = new StringBuilder("--scaleindex="); //NOXLATE
for (int i = 0; i < c.ScaleIndexes.Length; i++)
{
if (i != 0)
- sw.Write(","); //NOXLATE
- sw.Write(c.ScaleIndexes[i].ToString());
+ si.Append(","); //NOXLATE
+ si.Append(c.ScaleIndexes[i].ToString());
}
- // dont forget the space after the list of scaleindexes ticket #1316
- sw.Write(" "); //NOXLATE
+ argsMap.Add(si.ToString());
+
if (c.ExtentOverride != null)
{
- sw.Write(" --extentoverride="); //NOXLATE
- sw.Write(c.ExtentOverride.MinX.ToString(System.Globalization.CultureInfo.InvariantCulture));
- sw.Write(","); //NOXLATE
- sw.Write(c.ExtentOverride.MinY.ToString(System.Globalization.CultureInfo.InvariantCulture));
- sw.Write(","); //NOXLATE
- sw.Write(c.ExtentOverride.MaxX.ToString(System.Globalization.CultureInfo.InvariantCulture));
- sw.Write(","); //NOXLATE
- sw.Write(c.ExtentOverride.MaxY.ToString(System.Globalization.CultureInfo.InvariantCulture));
+ StringBuilder ov = new StringBuilder("--extentoverride="); //NOXLATE
+ ov.Append(c.ExtentOverride.MinX.ToString(System.Globalization.CultureInfo.InvariantCulture));
+ ov.Append(","); //NOXLATE
+ ov.Append(c.ExtentOverride.MinY.ToString(System.Globalization.CultureInfo.InvariantCulture));
+ ov.Append(","); //NOXLATE
+ ov.Append(c.ExtentOverride.MaxX.ToString(System.Globalization.CultureInfo.InvariantCulture));
+ ov.Append(","); //NOXLATE
+ ov.Append(c.ExtentOverride.MaxY.ToString(System.Globalization.CultureInfo.InvariantCulture));
+ argsMap.Add(ov.ToString());
}
- sw.Write(args.ToString());
+ string[] argsFinal = new string[args.Count + argsMap.Count];
+ int a = 0;
+ //Map-specific args first (as this contains the executable name)
+ foreach (string arg in argsMap)
+ {
+ argsFinal[a] = arg;
+ a++;
+ }
+ //Then the common args
+ foreach (string arg in args)
+ {
+ argsFinal[a] = arg;
+ a++;
+ }
+
+ sw.Write(string.Join(" ", argsFinal));
sw.WriteLine();
}
@@ -491,7 +562,7 @@
if (m_isUpdating)
return;
- if (MapTree.SelectedNode == null || !UseOfficialMethod.Checked)
+ if (MapTree.SelectedNode == null)
{
BoundsOverride.Enabled = false;
BoundsOverride.Tag = null;
Modified: trunk/Tools/Maestro/MgCooker/Strings.Designer.cs
===================================================================
--- trunk/Tools/Maestro/MgCooker/Strings.Designer.cs 2013-06-27 07:33:17 UTC (rev 7648)
+++ trunk/Tools/Maestro/MgCooker/Strings.Designer.cs 2013-06-28 03:03:42 UTC (rev 7649)
@@ -1,7 +1,7 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
-// Runtime Version:4.0.30319.17929
+// Runtime Version:4.0.30319.18047
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
@@ -143,7 +143,7 @@
}
/// <summary>
- /// Looks up a localized string similar to {0}: Rendering group {1} ({3} of {4}).
+ /// Looks up a localized string similar to {0}: Rendering group {1} ({2} of {3}).
/// </summary>
internal static string ConsoleOperationBeginGroup {
get {
Modified: trunk/Tools/Maestro/MgCooker/Strings.resx
===================================================================
--- trunk/Tools/Maestro/MgCooker/Strings.resx 2013-06-27 07:33:17 UTC (rev 7648)
+++ trunk/Tools/Maestro/MgCooker/Strings.resx 2013-06-28 03:03:42 UTC (rev 7649)
@@ -155,7 +155,7 @@
<comment>Text displayed in the console to report progress</comment>
</data>
<data name="ConsoleOperationBeginGroup" xml:space="preserve">
- <value>{0}: Rendering group {1} ({3} of {4})</value>
+ <value>{0}: Rendering group {1} ({2} of {3})</value>
<comment>Text displayed in the console to report progress</comment>
</data>
<data name="ConsoleOperationBeginMap" xml:space="preserve">
Modified: trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Tile/BatchSettings.cs
===================================================================
--- trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Tile/BatchSettings.cs 2013-06-27 07:33:17 UTC (rev 7648)
+++ trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Tile/BatchSettings.cs 2013-06-28 03:03:42 UTC (rev 7649)
@@ -423,27 +423,9 @@
/// </summary>
public string[] Groups { get { return m_groups; } }
- /// <summary>
- /// The number of tiles to offset the row counter with
- /// </summary>
- private int m_rowTileOffset = 0;
+
/// <summary>
- /// The number of tiles to offset the col counter with
- /// </summary>
- private int m_colTileOffset = 0;
-
- /// <summary>
- /// The tile offset for row indexes for tiles
- /// </summary>
- public int RowTileOffset { get { return m_rowTileOffset; } }
-
- /// <summary>
- /// The tile offset for col indexes for tiles
- /// </summary>
- public int ColTileOffset { get { return m_colTileOffset; } }
-
- /// <summary>
/// The map's scales may have been modified, this array is a map of the new values
/// </summary>
public int[] ScaleIndexMap { get { return m_scaleindexmap; } }
@@ -501,7 +483,7 @@
m_dimensions = new long[this.Resolutions][];
for (int i = this.Resolutions - 1; i >= 0; i--)
{
- long rows, cols;
+ long rows, cols, rowTileOffset = 0 , colTileOffset = 0;
double scale = m_mapdefinition.BaseMap.GetScaleAt(i);
if (m_parent.Config.UseOfficialMethod)
@@ -535,9 +517,17 @@
{
//The extent is overridden, so we need to adjust the start offsets
double offsetX = MaxExtent.MinX - m_mapdefinition.Extents.MinX;
- double offsetY = MaxExtent.MinY - m_mapdefinition.Extents.MinY;
- m_rowTileOffset = (int)Math.Ceiling(offsetY / tileHeight);
- m_colTileOffset = (int)Math.Ceiling(offsetX / tileWidth);
+ double offsetY = m_mapdefinition.Extents.MaxY - MaxExtent.MaxY ;
+ rowTileOffset = (int)Math.Floor(offsetY / tileHeight);
+ colTileOffset = (int)Math.Floor(offsetX / tileWidth);
+
+ double offsetMaxX = MaxExtent.MaxX - m_mapdefinition.Extents.MinX;
+ double offsetMinY = m_mapdefinition.Extents.MaxY - MaxExtent.MinY;
+ int rowMinTileOffset = (int)Math.Floor(offsetMinY / tileHeight);
+ int colMaxTileOffset = (int)Math.Floor(offsetMaxX / tileWidth);
+
+ cols += (colMaxTileOffset - colTileOffset);
+ rows += (rowMinTileOffset - rowTileOffset);
}
}
else
@@ -561,7 +551,7 @@
}
- m_dimensions[i] = new long[] {rows, cols};
+ m_dimensions[i] = new long[] { rows, cols, rowTileOffset , colTileOffset};
}
}
@@ -579,7 +569,20 @@
m_groups = g.ToArray();
}
+
/// <summary>
+ /// Sets the list of scale indexes and sets the maximum extent to the given envelope
+ /// </summary>
+ /// <param name="scales"></param>
+ /// <param name="envelope"></param>
+ public void SetScalesAndExtend(int[] scales, IEnvelope envelope)
+ {
+ this.m_maxExtent = envelope;
+ SetScales(scales);
+ }
+
+
+ /// <summary>
/// Sets the list of scale indexes
/// </summary>
/// <param name="scaleindexes"></param>
@@ -662,10 +665,12 @@
{
int rows = (int)m_dimensions[scaleindex][0];
int cols = (int)m_dimensions[scaleindex][1];
+ int rowTileOffset = (int)m_dimensions[scaleindex][2];
+ int colTileOffset = (int)m_dimensions[scaleindex][3];
//If the MaxExtents are different from the actual bounds, we need a start offset offset
- RenderThreads settings = new RenderThreads(this, m_parent, m_scaleindexmap[scaleindex], group, m_mapdefinition.ResourceID, rows, cols, m_rowTileOffset, m_colTileOffset, m_parent.Config.RandomizeTileSequence);
+ RenderThreads settings = new RenderThreads(this, m_parent, m_scaleindexmap[scaleindex], group, m_mapdefinition.ResourceID, rows, cols, rowTileOffset, colTileOffset, m_parent.Config.RandomizeTileSequence);
settings.RunAndWait();
@@ -747,6 +752,8 @@
/// Gets a reference to the parent tiling run collection
/// </summary>
public TilingRunCollection Parent { get { return m_parent; } }
+
+
}
/// <summary>
More information about the mapguide-commits
mailing list