MapCruncherConsole\Program.cs
// Copyright 2010 ESRI // // All rights reserved under the copyright laws of the United States // and applicable international laws, treaties, and conventions. // // You may freely redistribute and use this sample code, with or // without modification, provided you include the original copyright // notice and use restrictions. // // See the use restrictions. // using System; using System.Collections.Generic; using System.Linq; using System.Text; using ESRI.ArcGIS; namespace MapCruncher { class Program { // [STAThread] static void Main(string[] args) { if (args.Length != 4) { Console.WriteLine("Please enter 4 arguments"); Console.WriteLine("Argument 1: Path and Mxd to be cooked"); Console.WriteLine("Argument 2: Finest scale to be used"); Console.WriteLine(" ****Warning! Depending on the scale and map, processing may take a long time!"); Console.WriteLine("Argument 3: Target path for cache"); Console.WriteLine("Argument 4: Cache name"); return; } Console.WriteLine("\nThe following sample will create a cash from the specified map document."); Console.Write("\nIt will calculate an appropriate number of Levels of Detail (LOD) based on the map's scale range"); Console.Write("and extent. Then launch a number of threads based on the number of cores on the machine."); Console.Write("\n\nAs each thread finishes processing a LOD, it will notify which LOD was processed along with the thread id.\n\n"); // Bind to the Engine or Desktop Runtime. RuntimeManager.BindLicense(ProductCode.EngineOrDesktop); // Create the mapCruncher MapCruncherClass mapCruncher = new MapCruncherClass(); // Pass in the parameters for the MapCruncher mapCruncher.Init(args[0].ToString(), Convert.ToDouble(args[1]), args[2].ToString(), args[3].ToString()); // Wire up the MapCruncher's events mapCruncher.CookerProgress += new CookerThreadEventHandeler(CookerProgress); // Execute mapCruncher.Execute(); // Unwire the events mapCruncher.CookerProgress -= new CookerThreadEventHandeler(CookerProgress); Console.WriteLine("\nProcessing has finished... \nCache has been created"); } static void CookerProgress(object sender, MapCruncherEventArgs e) { Console.WriteLine("Processed LOD {0} on Thread ID {1}", e.LOD, e.ThreadId); } } }