//--------------------------------------------------------------------- public IInputRaster <TPixel> OpenRaster <TPixel>(string path) where TPixel : Pixel, new() { if (typeof(TPixel) != typeof(EcoregionPixel)) { throw new ApplicationException("Only valid pixel type is Landis.Ecoregions.EcoregionPixel"); } object data; if (!dataArrays.TryGetValue(path, out data)) { throw new ApplicationException("Unknown path: " + path); } IInputRaster <EcoregionPixel> raster; if (data is byte[, ]) { raster = new InputRaster <byte>(path, (byte[, ])data, Convert.ToUInt16); } else { raster = new InputRaster <ushort>(path, (ushort[, ])data, Convert.ToUInt16); } return((IInputRaster <TPixel>)raster); }
//--------------------------------------------------------------------- public IInputRaster<TPixel> OpenRaster<TPixel>(string path) where TPixel : IPixel, new() { if (typeof(TPixel) != typeof(Pixel)) throw new ApplicationException("Only valid pixel type is Landis.Ecoregions.Pixel"); object data; if (! dataArrays.TryGetValue(path, out data)) throw new ApplicationException("Unknown path: " + path); ///byte[,] data = new byte[,]{ { 1, 2, 3}, {4, 5, 6} }; IInputRaster<Pixel> raster; if (data is byte[,]) raster = new InputRaster<byte>(path, (byte[,]) data, Convert.ToUInt16); else raster = new InputRaster<ushort>(path, (ushort[,]) data, Convert.ToUInt16); return (IInputRaster<TPixel>) raster; }