//--------------------------------------------------------------------- /// <summary> /// Initializes a new instance using an input raster with ecoregion /// pixels. /// </summary> public InputGrid(IInputRaster <Pixel> raster, IDataset ecoregions) : base(raster.Dimensions) { this.raster = raster; this.ecoregions = ecoregions; // Initialize pixel location so the next call to RowMajor.Next // will return upper-left location (1,1) this.pixelLocation = new Location(1, 0); }
//--------------------------------------------------------------------- public EcoregionCode ReadValue() { if (disposed) { throw new System.InvalidOperationException("Object has been disposed."); } Pixel pixel = raster.ReadPixel(); pixelLocation = RowMajor.Next(pixelLocation, raster.Dimensions.Columns); ushort mapCode = pixel.Band0; IEcoregion ecoregion = ecoregions.Find(mapCode); if (ecoregion != null) { return(new EcoregionCode(mapCode, ecoregion.Active)); } string mesg = string.Format("Error at map site {0}", pixelLocation); string innerMesg = string.Format("Unknown map code for ecoregion: {0}", mapCode); throw new MultiLineException(mesg, innerMesg); }
//--------------------------------------------------------------------- /// <summary> /// Gets a site on the landscape. /// </summary> /// <param name="location"> /// the site's location /// </param> /// <returns> /// a false site if the location is not on the landscape. /// </returns> public virtual Site GetSite(Location location) { return(new Site()); }
//--------------------------------------------------------------------- /// <summary> /// Is a location valid for a landscape? /// </summary> public virtual bool IsValid(Location location) { return(false); }
//--------------------------------------------------------------------- /// <summary> /// Gets an active site on the landscape. /// </summary> /// <param name="location"> /// the site's location /// </param> /// <returns> /// a false site if the location is not on the landscape. /// </returns> public virtual ActiveSite this[Location location] { get { return(new ActiveSite()); } }