//--------------------------------------------------------------------- /// <summary> /// Initializes a new instance. /// </summary> /// <param name="path"> /// Path to the raster file that represents the map. /// </param> /// <param name="ecoregions"> /// The dataset of ecoregions that are in the map. /// </param> /// <param name="rasterFactory"> /// The raster factory to use to read the map. /// </param> public Map(string path, IEcoregionDataset ecoregions, IRasterFactory rasterFactory) { this.path = path; this.ecoregions = ecoregions; this.rasterFactory = rasterFactory; try { IInputRaster<EcoregionPixel> map = rasterFactory.OpenRaster<EcoregionPixel>(path); using (map) { //this.metadata = map.Metadata; } } catch (Exception exc) { Console.WriteLine("#### Internal error occurred within the program:"); Console.WriteLine(" {0}", exc.Message); for (Exception innerException = exc.InnerException; innerException != null; innerException = innerException.InnerException) { Console.WriteLine(" {0}", innerException.Message); } } }
//--------------------------------------------------------------------- /// <summary> /// Initializes a new instance. /// </summary> /// <param name="path"> /// Path to the raster file that represents the map. /// </param> /// <param name="ecoregions"> /// The dataset of ecoregions that are in the map. /// </param> /// <param name="rasterFactory"> /// The raster factory to use to read the map. /// </param> public Map(string path, IEcoregionDataset ecoregions, IRasterFactory rasterFactory) { this.path = path; this.ecoregions = ecoregions; this.rasterFactory = rasterFactory; try { IInputRaster <EcoregionPixel> map = rasterFactory.OpenRaster <EcoregionPixel>(path); using (map) { //this.metadata = map.Metadata; } } catch (Exception exc) { Console.WriteLine("#### Internal error occurred within the program:"); Console.WriteLine(" {0}", exc.Message); for (Exception innerException = exc.InnerException; innerException != null; innerException = innerException.InnerException) { Console.WriteLine(" {0}", innerException.Message); } } }
/// <summary> /// Initializes a new instance of the <see cref="MaskedRaster" /> class. /// </summary> /// <param name="factory">The raster factory.</param> /// <param name="source">The source raster.</param> /// <param name="rowIndex">The starting row index of a mask.</param> /// <param name="columnIndex">The starting column index of a mask.</param> /// <param name="numberOfRows">The number of rows in the mask.</param> /// <param name="numberOfColumns">The number of columns in the mask.</param> /// <exception cref="System.ArgumentNullException">The source is null.</exception> /// <exception cref="System.ArgumentOutOfRangeException"> /// The starting row index is less than 0. /// or /// The starting row index is equal to or greater than the number of rows in the source. /// or /// The starting column index is less than 0. /// or /// the starting column index is equal to or greater than the number of columns in the source. /// or /// The starting row index and the number of rows is greater than the number of rows in the source. /// or /// The starting columns index and the number of columns is greater than the number of columns in the source. /// </exception> public MaskedRaster(IRasterFactory factory, IRaster source, Int32 rowIndex, Int32 columnIndex, Int32 numberOfRows, Int32 numberOfColumns) : base(factory, GetNumberOfBands(source), numberOfRows, numberOfColumns, GetRadiometricResolution(source), ComputeMapper(source, rowIndex, columnIndex)) { if (rowIndex < 0) { throw new ArgumentOutOfRangeException(nameof(rowIndex), "The starting row index is less than 0."); } if (rowIndex >= source.NumberOfRows) { throw new ArgumentOutOfRangeException(nameof(rowIndex), "The starting row index is equal to or greater than the number of rows in the source."); } if (columnIndex < 0) { throw new ArgumentOutOfRangeException(nameof(columnIndex), "The starting column index is less than 0."); } if (columnIndex >= source.NumberOfColumns) { throw new ArgumentOutOfRangeException(nameof(columnIndex), "the starting column index is equal to or greater than the number of columns in the source."); } if (rowIndex + numberOfRows > source.NumberOfRows) { throw new ArgumentOutOfRangeException(nameof(numberOfRows), "The starting row index and the number of rows is greater than the number of rows in the source."); } if (columnIndex + numberOfColumns > source.NumberOfColumns) { throw new ArgumentOutOfRangeException(nameof(numberOfColumns), "The starting columns index and the number of columns is greater than the number of columns in the source."); } _source = source; _rowIndex = rowIndex; _columnIndex = columnIndex; _histogramValues = Enumerable.Repeat <IReadOnlyList <Int32> >(null, _source.NumberOfBands).ToArray(); }
/// <summary> /// Initializes a new instance of the <see cref="RasterFloat32" /> class. /// </summary> /// <param name="factory">The factory.</param> /// <param name="spectralValues">The array of spectral values.</param> /// <param name="dimensions">The dimensions of the raster.</param> /// <param name="mapper">The mapper.</param> private RasterFloat32(IRasterFactory factory, Single[][] spectralValues, RasterDimensions dimensions, RasterMapper mapper) : base(factory, dimensions, mapper) { // copy values for all bands for (Int32 bandIndex = 0; bandIndex < spectralValues.Length; bandIndex++) { _values[bandIndex] = new Single[spectralValues[bandIndex].Length]; Array.Copy(spectralValues[bandIndex], _values[bandIndex], spectralValues[bandIndex].Length); } }
/// <summary> /// Initializes a new instance of the <see cref="RasterFloat32" /> class. /// </summary> /// <param name="factory">The factory.</param> /// <param name="numberOfBands">The number of bands.</param> /// <param name="numberOfRows">The number of rows.</param> /// <param name="numberOfColumns">The number of columns.</param> /// <param name="radiometricResolution">The radiometric resolution.</param> /// <param name="mapper">The mapper.</param> /// <exception cref="System.ArgumentOutOfRangeException"> /// The number of bands is less than 1. /// or /// The number of rows is less than 0. /// or /// The number of columns is less than 0. /// or /// The radiometric resolution is less than 1. /// or /// The radiometric resolution is greater than 64. /// </exception> public RasterFloat32(IRasterFactory factory, Int32 numberOfBands, Int32 numberOfRows, Int32 numberOfColumns, Int32 radiometricResolution, RasterMapper mapper) : base(factory, numberOfBands, numberOfRows, numberOfColumns, radiometricResolution, mapper) { // generate empty values for all bands _values = Enumerable.Repeat <Single[]>(null, numberOfBands).ToArray(); for (Int32 bandIndex = 0; bandIndex < _values.Length; bandIndex++) { _values[bandIndex] = new Single[NumberOfRows * NumberOfColumns]; } }
//--------------------------------------------------------------------- /// <summary> /// Initializes a new instance. /// </summary> /// <param name="path"> /// Path to the raster file that represents the map. /// </param> /// <param name="ecoregions"> /// The dataset of ecoregions that are in the map. /// </param> /// <param name="rasterFactory"> /// The raster factory to use to read the map. /// </param> public Map(string path, IDataset ecoregions, IRasterFactory rasterFactory) { this.path = path; this.ecoregions = ecoregions; this.rasterFactory = rasterFactory; IInputRaster<Pixel> map = rasterFactory.OpenRaster<Pixel>(path); using (map) { this.metadata = map.Metadata; } }
/// <summary> /// Initializes a new instance of the <see cref="Raster16" /> class. /// </summary> /// <param name="factory">The factory.</param> /// <param name="spectralValues">The array of spectral values.</param> /// <param name="dimensions">The dimensions of the raster.</param> /// <param name="mapper">The mapper.</param> private Raster16(IRasterFactory factory, UInt16[][] spectralValues, RasterDimensions dimensions, RasterMapper mapper) : base(factory, dimensions, mapper) { // copy values for all bands for (Int32 bandIndex = 0; bandIndex < spectralValues.Length; bandIndex++) { _values[bandIndex] = new UInt16[spectralValues[bandIndex].Length]; Array.Copy(spectralValues[bandIndex], _values[bandIndex], spectralValues[bandIndex].Length); } _histogramValues = Enumerable.Repeat <Int32[]>(null, spectralValues.Length).ToArray(); }
//--------------------------------------------------------------------- /// <summary> /// Initializes a new instance. /// </summary> /// <param name="path"> /// Path to the raster file that represents the map. /// </param> /// <param name="ecoregions"> /// The dataset of ecoregions that are in the map. /// </param> /// <param name="rasterFactory"> /// The raster factory to use to read the map. /// </param> public Map(string path, IDataset ecoregions, IRasterFactory rasterFactory) { this.path = path; this.ecoregions = ecoregions; this.rasterFactory = rasterFactory; IInputRaster <Pixel> map = rasterFactory.OpenRaster <Pixel>(path); using (map) { this.metadata = map.Metadata; } }
/// <summary> /// Prepares the result of the operation. /// </summary> protected override ISpectralGeometry PrepareResult() { IRasterFactory factory = Source.Factory.GetFactory <ISpectralGeometryFactory>() .GetFactory <IRasterFactory>(); Int32 radiometricResolution = _numberOfCategories > 65535 ? 32 : (_numberOfCategories > 255 ? 16 : 8); IRaster raster = factory.CreateRaster(_categoryIndices.Count, Source.Raster.NumberOfRows, Source.Raster.NumberOfColumns, radiometricResolution, Source.Raster.Mapper); return(Source.Factory.CreateSpectralGeometry(Source, raster, Source.Presentation, Source.Imaging)); }
/// <summary> /// Initializes a new instance of the <see cref="ProxyRaster" /> class. /// </summary> /// <param name="factory">The raster factory.</param> /// <param name="service">The raster service.</param> /// <param name="mapper">The raster mapper.</param> /// <exception cref="System.ArgumentNullException">The service is null.</exception> public ProxyRaster(IRasterFactory factory, IRasterService service, RasterMapper mapper) : base(factory, service?.Dimensions, mapper) { if (service == null) { throw new ArgumentNullException("service", "The service is null."); } _service = service; _isSequentialService = _service.DataOrder == RasterDataOrder.RowColumnBand; _histogramValues = Enumerable.Repeat <Int32[]>(null, NumberOfRows).ToArray(); }