[mapguide-commits] r8574 - in trunk/Tools/Maestro: MgCooker OSGeo.MapGuide.MaestroAPI OSGeo.MapGuide.MaestroAPI/Tile
svn_mapguide at osgeo.org
svn_mapguide at osgeo.org
Sat Mar 14 10:07:19 PDT 2015
Author: jng
Date: 2015-03-14 10:07:19 -0700 (Sat, 14 Mar 2015)
New Revision: 8574
Modified:
trunk/Tools/Maestro/MgCooker/Program.cs
trunk/Tools/Maestro/MgCooker/SetupRun.cs
trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Strings.Designer.cs
trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Strings.resx
trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Tile/BatchSettings.cs
Log:
#2515: Add TileSetDefinition support to MgCooker and backend classes
Modified: trunk/Tools/Maestro/MgCooker/Program.cs
===================================================================
--- trunk/Tools/Maestro/MgCooker/Program.cs 2015-03-14 15:06:41 UTC (rev 8573)
+++ trunk/Tools/Maestro/MgCooker/Program.cs 2015-03-14 17:07:19 UTC (rev 8574)
@@ -305,8 +305,8 @@
Console.Clear();
Console.WriteLine(string.Format(Strings.ConsoleUpdateTime.Replace("\\t", "\t"), DateTime.Now));
Console.WriteLine(string.Format(Strings.ConsoleCurrentMap.Replace("\\t", "\t"), map.ResourceId, mapCount, map.Parent.Maps.Count));
- Console.WriteLine(string.Format(Strings.ConsoleCurrentGroup.Replace("\\t", "\t"), group, groupCount, map.MapDefinition.BaseMap.GroupCount));
- Console.WriteLine(string.Format(Strings.ConsoleCurrentScale.Replace("\\t", "\t"), map.MapDefinition.BaseMap.GetScaleAt(Array.IndexOf<int>(map.ScaleIndexMap, scaleindex)), Array.IndexOf<int>(map.ScaleIndexMap, scaleindex) + 1, map.MapDefinition.BaseMap.ScaleCount));
+ Console.WriteLine(string.Format(Strings.ConsoleCurrentGroup.Replace("\\t", "\t"), group, groupCount, map.TileSet.GroupCount));
+ Console.WriteLine(string.Format(Strings.ConsoleCurrentScale.Replace("\\t", "\t"), map.TileSet.GetScaleAt(Array.IndexOf<int>(map.ScaleIndexMap, scaleindex)), Array.IndexOf<int>(map.ScaleIndexMap, scaleindex) + 1, map.TileSet.ScaleCount));
Console.WriteLine(string.Format(Strings.ConsoleCurrentTile.Replace("\\t", "\t"), tileCount, totalTiles));
Console.WriteLine();
Console.WriteLine(string.Format(Strings.ConsoleGroupDuration.Replace("\\t", "\t"), DateTime.Now - beginGroup));
@@ -379,14 +379,14 @@
{
TimeSpan duration = DateTime.Now - beginScale;
if (m_loggableProgress)
- Console.WriteLine(string.Format(Strings.ConsoleOperationFinishScale, DateTime.Now, map.MapDefinition.BaseMap.GetScaleAt(scaleindex), duration));
+ Console.WriteLine(string.Format(Strings.ConsoleOperationFinishScale, DateTime.Now, map.TileSet.GetScaleAt(scaleindex), duration));
}
private static void bx_BeginRenderingScale(CallbackStates state, MapTilingConfiguration map, string group, int scaleindex, int row, int column, ref bool cancel)
{
beginScale = DateTime.Now;
if (m_loggableProgress)
- Console.WriteLine(string.Format(Strings.ConsoleOperationBeginScale, beginMap, map.MapDefinition.BaseMap.GetScaleAt(scaleindex), scaleindex, map.Resolutions));
+ Console.WriteLine(string.Format(Strings.ConsoleOperationBeginScale, beginMap, map.TileSet.GetScaleAt(scaleindex), scaleindex, map.Resolutions));
}
private static void bx_FinishRenderingMap(CallbackStates state, MapTilingConfiguration map, string group, int scaleindex, int row, int column, ref bool cancel)
Modified: trunk/Tools/Maestro/MgCooker/SetupRun.cs
===================================================================
--- trunk/Tools/Maestro/MgCooker/SetupRun.cs 2015-03-14 15:06:41 UTC (rev 8573)
+++ trunk/Tools/Maestro/MgCooker/SetupRun.cs 2015-03-14 17:07:19 UTC (rev 8574)
@@ -147,6 +147,8 @@
List<string> tmp = new List<string>();
foreach (ResourceListResourceDocument doc in m_connection.ResourceService.GetRepositoryResources(StringConstants.RootIdentifier, ResourceTypes.MapDefinition.ToString()).Items)
tmp.Add(doc.ResourceId);
+ foreach (ResourceListResourceDocument doc in m_connection.ResourceService.GetRepositoryResources(StringConstants.RootIdentifier, ResourceTypes.TileSetDefinition.ToString()).Items)
+ tmp.Add(doc.ResourceId);
maps = tmp.ToArray();
}
@@ -170,20 +172,33 @@
MapTree.Nodes.Clear();
foreach (string m in maps)
{
- IMapDefinition mdef = m_connection.ResourceService.GetResource(m) as IMapDefinition;
- if (mdef == null) //Skip unknown Map Definition version (which would be returned as UntypedResource objects)
+ ITileSetAbstract tileSet = null;
+ IResource res = m_connection.ResourceService.GetResource(m);
+ IMapDefinition mdef = res as IMapDefinition;
+ ITileSetDefinition tsd = res as ITileSetDefinition;
+ if (mdef != null)
+ {
+ tileSet = mdef.BaseMap;
+ }
+ else if (tsd != null && tsd.SupportsCustomFiniteDisplayScales)
+ {
+ tileSet = tsd;
+ }
+
+ if (tileSet == null)
continue;
- IBaseMapDefinition baseMap = mdef.BaseMap;
- if (baseMap != null &&
- baseMap.ScaleCount > 0 &&
- baseMap.HasGroups())
+ bool bValidTileSet = (tileSet != null &&
+ tileSet.ScaleCount > 0 &&
+ tileSet.HasGroups());
+
+ if (bValidTileSet)
{
TreeNode mn = MapTree.Nodes.Add(m);
mn.ImageIndex = mn.SelectedImageIndex = 0;
mn.Tag = mdef;
- foreach (var g in baseMap.BaseMapLayerGroups)
+ foreach (var g in tileSet.BaseMapLayerGroups)
{
TreeNode gn = mn.Nodes.Add(g.Name);
gn.Tag = g;
@@ -200,7 +215,7 @@
gn.ImageIndex = gn.SelectedImageIndex = 1;
int counter = 0;
- foreach (double d in baseMap.FiniteDisplayScale)
+ foreach (double d in tileSet.FiniteDisplayScale)
{
TreeNode sn = gn.Nodes.Add(d.ToString(System.Globalization.CultureInfo.CurrentUICulture));
if (gn.Checked && scalesSelected.Contains(counter))
@@ -274,16 +289,19 @@
if (mn.Checked)
{
foreach (TreeNode gn in mn.Nodes)
+ {
if (gn.Checked)
{
List<int> ix = new List<int>();
foreach (TreeNode sn in gn.Nodes)
+ {
if (sn.Checked)
ix.Add(sn.Index);
-
+ }
if (ix.Count > 0)
lst.Add(new Config(mn.Text, gn.Text, ix.ToArray(), (m_coordinateOverrides.ContainsKey(mn.Text) ? m_coordinateOverrides[mn.Text] : null)));
}
+ }
}
}
@@ -597,7 +615,7 @@
{
var currentPath = Path.GetDirectoryName(new Uri(Assembly.GetExecutingAssembly().CodeBase).LocalPath);
var mpuCalc = Path.Combine(currentPath, "AddIns/Local/MpuCalc.exe");
- if (!File.Exists(mpuCalc))
+ if (!File.Exists(mpuCalc) && mapDef.EndsWith(ResourceTypes.MapDefinition.ToString()))
{
int[] cmdTypes = m_connection.Capabilities.SupportedCommands;
if (Array.IndexOf(cmdTypes, (int)OSGeo.MapGuide.MaestroAPI.Commands.CommandType.CreateRuntimeMap) < 0)
@@ -625,27 +643,40 @@
}
else
{
- IMapDefinition mdf = (IMapDefinition)m_connection.ResourceService.GetResource(mapDef);
- var proc = new Process
+ IResource res = m_connection.ResourceService.GetResource(mapDef);
+ ITileSetDefinition tsd = res as ITileSetDefinition;
+ IMapDefinition mdf = res as IMapDefinition;
+
+ string coordSys = null;
+ if (mdf != null)
+ coordSys = mdf.CoordinateSystem;
+ else if (tsd != null)
+ coordSys = tsd.GetDefaultCoordinateSystem();
+
+ string output = string.Empty;
+ if (coordSys != null)
{
- StartInfo = new ProcessStartInfo
+ var proc = new Process
{
- FileName = mpuCalc,
- Arguments = mdf.CoordinateSystem,
- UseShellExecute = false,
- RedirectStandardOutput = true,
- CreateNoWindow = true
+ StartInfo = new ProcessStartInfo
+ {
+ FileName = mpuCalc,
+ Arguments = coordSys,
+ UseShellExecute = false,
+ RedirectStandardOutput = true,
+ CreateNoWindow = true
+ }
+ };
+ proc.Start();
+ StringBuilder sb = new StringBuilder();
+ while (!proc.StandardOutput.EndOfStream)
+ {
+ string line = proc.StandardOutput.ReadLine();
+ // do something with line
+ sb.AppendLine(line);
}
- };
- proc.Start();
- StringBuilder sb = new StringBuilder();
- while (!proc.StandardOutput.EndOfStream)
- {
- string line = proc.StandardOutput.ReadLine();
- // do something with line
- sb.AppendLine(line);
+ output = sb.ToString();
}
- string output = sb.ToString();
double mpu;
if (double.TryParse(output, out mpu))
return new MpuCalcResult() { Method = MpuMethod.MpuCalcExe, Result = Convert.ToDecimal(mpu) };
Modified: trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Strings.Designer.cs
===================================================================
--- trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Strings.Designer.cs 2015-03-14 15:06:41 UTC (rev 8573)
+++ trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Strings.Designer.cs 2015-03-14 17:07:19 UTC (rev 8574)
@@ -2293,6 +2293,15 @@
}
/// <summary>
+ /// Looks up a localized string similar to The given Map Definition or Tile Set Definition cannot be seeded.
+ /// </summary>
+ public static string UnseedableTileSet {
+ get {
+ return ResourceManager.GetString("UnseedableTileSet", resourceCulture);
+ }
+ }
+
+ /// <summary>
/// Looks up a localized string similar to Unsupported Load Procedure Type.
/// </summary>
public static string UnsupportedLoadProcedureType {
Modified: trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Strings.resx
===================================================================
--- trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Strings.resx 2015-03-14 15:06:41 UTC (rev 8573)
+++ trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Strings.resx 2015-03-14 17:07:19 UTC (rev 8574)
@@ -891,4 +891,7 @@
<data name="ErrorWriteClassXmlNeedToBeAttachedToParent" xml:space="preserve">
<value>Cannot write XML for a Class Definition that is not attached to a parent schema</value>
</data>
+ <data name="UnseedableTileSet" xml:space="preserve">
+ <value>The given Map Definition or Tile Set Definition cannot be seeded</value>
+ </data>
</root>
\ No newline at end of file
Modified: trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Tile/BatchSettings.cs
===================================================================
--- trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Tile/BatchSettings.cs 2015-03-14 15:06:41 UTC (rev 8573)
+++ trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Tile/BatchSettings.cs 2015-03-14 17:07:19 UTC (rev 8574)
@@ -412,9 +412,19 @@
private TilingRunCollection m_parent;
/// <summary>
+ /// The resource ID of the tile set or map definition
+ /// </summary>
+ private string m_tileSetResourceID;
+
+ /// <summary>
+ /// The tile set extents
+ /// </summary>
+ private IEnvelope m_tileSetExtents;
+
+ /// <summary>
/// The map read from MapGuide
/// </summary>
- private IMapDefinition m_mapdefinition;
+ private ITileSetAbstract m_tileset;
/// <summary>
/// The max extent of the map
@@ -464,9 +474,28 @@
public MapTilingConfiguration(TilingRunCollection parent, string map)
{
m_parent = parent;
- m_mapdefinition = (IMapDefinition)parent.Connection.ResourceService.GetResource(map);
- var baseMap = m_mapdefinition.BaseMap;
+ IResource res = parent.Connection.ResourceService.GetResource(map);
+ IMapDefinition mdf = res as IMapDefinition;
+ ITileSetDefinition tsd = res as ITileSetDefinition;
+ if (mdf != null)
+ {
+ m_tileSetResourceID = mdf.ResourceID;
+ m_tileSetExtents = mdf.Extents.Clone();
+ m_tileset = mdf.BaseMap;
+ }
+ else if (tsd != null && tsd.SupportsCustomFiniteDisplayScales)
+ {
+ m_tileSetResourceID = tsd.ResourceID;
+ m_tileSetExtents = tsd.Extents.Clone();
+ m_tileset = tsd;
+ }
+
+ if (m_tileset == null)
+ throw new InvalidOperationException(OSGeo.MapGuide.MaestroAPI.Strings.UnseedableTileSet);
+
+ var baseMap = m_tileset;
+
if (baseMap != null &&
baseMap.ScaleCount > 0)
{
@@ -481,7 +510,7 @@
internal void CalculateDimensions()
{
- int[] tmp = new int[this.MapDefinition.BaseMap.ScaleCount];
+ int[] tmp = new int[this.TileSet.ScaleCount];
for (int i = 0; i < tmp.Length; i++)
tmp[i] = i;
@@ -490,14 +519,14 @@
internal void CalculateDimensionsInternal()
{
- if (m_mapdefinition.BaseMap.ScaleCount == 0)
+ if (m_tileset.ScaleCount == 0)
{
m_scaleindexmap = new int[0];
m_dimensions = new long[0][];
return;
}
- IEnvelope extents = this.MaxExtent ?? m_mapdefinition.Extents;
+ IEnvelope extents = this.MaxExtent ?? m_tileSetExtents;
double maxscale = m_maxscale;
m_dimensions = new long[this.Resolutions][];
@@ -510,7 +539,7 @@
for (int i = this.Resolutions - 1; i >= 0; i--)
{
long rows, cols, rowTileOffset = 0, colTileOffset = 0;
- double scale = m_mapdefinition.BaseMap.GetScaleAt(i);
+ double scale = m_tileset.GetScaleAt(i);
// This is the official method, and the only one MgCooker will ever use
@@ -542,13 +571,13 @@
if (m_maxExtent != null)
{
//The extent is overridden, so we need to adjust the start offsets
- double offsetX = MaxExtent.MinX - m_mapdefinition.Extents.MinX;
- double offsetY = m_mapdefinition.Extents.MaxY - MaxExtent.MaxY;
+ double offsetX = MaxExtent.MinX - m_tileSetExtents.MinX;
+ double offsetY = m_tileSetExtents.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;
+ double offsetMaxX = MaxExtent.MaxX - m_tileSetExtents.MinX;
+ double offsetMinY = m_tileSetExtents.MaxY - MaxExtent.MinY;
int rowMinTileOffset = (int)Math.Floor(offsetMinY / tileHeight);
int colMaxTileOffset = (int)Math.Floor(offsetMaxX / tileWidth);
@@ -602,9 +631,9 @@
List<int> keys = new List<int>(s.Keys);
keys.Reverse();
- for (int i = m_mapdefinition.BaseMap.ScaleCount - 1; i >= 0; i--)
+ for (int i = m_tileset.ScaleCount - 1; i >= 0; i--)
if (!keys.Contains(i))
- m_mapdefinition.BaseMap.RemoveScaleAt(i);
+ m_tileset.RemoveScaleAt(i);
CalculateDimensionsInternal();
@@ -649,10 +678,10 @@
{
get
{
- if (m_mapdefinition.BaseMap == null || m_mapdefinition.BaseMap.ScaleCount == 0)
+ if (m_tileset == null || m_tileset.ScaleCount == 0)
return 0;
else
- return m_mapdefinition.BaseMap.ScaleCount;
+ return m_tileset.ScaleCount;
}
}
@@ -674,7 +703,7 @@
//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, rowTileOffset, colTileOffset, m_parent.Config.RandomizeTileSequence);
+ RenderThreads settings = new RenderThreads(this, m_parent, m_scaleindexmap[scaleindex], group, m_tileSetResourceID, rows, cols, rowTileOffset, colTileOffset, m_parent.Config.RandomizeTileSequence);
settings.RunAndWait();
@@ -741,12 +770,12 @@
/// <summary>
/// Gets the resourceId for the map
/// </summary>
- public string ResourceId { get { return m_mapdefinition.ResourceID; } }
+ public string ResourceId { get { return m_tileSetResourceID; } }
/// <summary>
/// Gets the MapDefintion
/// </summary>
- public IMapDefinition MapDefinition { get { return m_mapdefinition; } }
+ public ITileSetAbstract TileSet { get { return m_tileset; } }
/// <summary>
/// Gets a reference to the parent tiling run collection
More information about the mapguide-commits
mailing list