//--------------------------------------------------------------------- //Modified to add inputMapPath, allowing users to specify raster paths to change at timestep public void ProcessInputMap(ProcessLandUseAt processLandUseAt) { string inputMapPath = MapNames.ReplaceTemplateVars(inputMapTemplate, Model.Core.CurrentTime); Model.Core.UI.WriteLine(" Reading map \"{0}\"...", inputMapPath); IInputRaster <MapPixel> inputMap; Dictionary <string, int> counts = new Dictionary <string, int>(); using (inputMap = Model.Core.OpenRaster <MapPixel>(inputMapPath)) { MapPixel pixel = inputMap.BufferPixel; foreach (Site site in Model.Core.Landscape.AllSites) { inputMap.ReadBufferPixel(); if (site.IsActive) { LandUse landUse = LandUseRegistry.LookUp(pixel.LandUseCode.Value); if (landUse == null) { string message = string.Format("Error: Unknown map code ({0}) at pixel {1}", pixel.LandUseCode.Value, site.Location); throw new System.ApplicationException(message); } string key = processLandUseAt(site, landUse); if (key != null) { int count; if (counts.TryGetValue(key, out count)) { count = count + 1; } else { count = 1; } counts[key] = count; } } } } foreach (string key in counts.Keys) { Model.Core.UI.WriteLine(" {0} ({1:#,##0})", key, counts[key]); } }
//--------------------------------------------------------------------- public void ProcessInputMap(ProcessLandUseAt processLandUseAt) { string inputMapPath = MapNames.ReplaceTemplateVars(inputMapTemplate, Model.Core.CurrentTime); Model.Core.UI.WriteLine(" Reading map \"{0}\"...", inputMapPath); IInputRaster<MapPixel> inputMap; Dictionary<string, int> counts = new Dictionary<string, int>(); using (inputMap = Model.Core.OpenRaster<MapPixel>(inputMapPath)) { MapPixel pixel = inputMap.BufferPixel; foreach (Site site in Model.Core.Landscape.AllSites) { inputMap.ReadBufferPixel(); if (site.IsActive) { LandUse landUse = LandUseRegistry.LookUp(pixel.LandUseCode.Value); if (landUse == null) { string message = string.Format("Error: Unknown map code ({0}) at pixel {1}", pixel.LandUseCode.Value, site.Location); throw new System.ApplicationException(message); } string key = processLandUseAt(site, landUse); if (key != null) { int count; if (counts.TryGetValue(key, out count)) count = count + 1; else count = 1; counts[key] = count; } } } } foreach (string key in counts.Keys) Model.Core.UI.WriteLine(" {0} ({1:#,##0})", key, counts[key]); }