/// <summary>
        /// Prepares the result of the operation.
        /// </summary>
        /// <returns>The resulting object.</returns>
        protected override ISpectralGeometry PrepareResult()
        {
            _toarefGain = new Double[Source.Raster.NumberOfBands];

            switch (Source.Imaging.Device.MissionNumber)
            {
            case 7:
                Double sunZenith = 90 - Source.Imaging.SunElevation;
                Int32  dayOfYear = Source.Imaging.Time.DayOfYear;

                for (Int32 bandIndex = 0; bandIndex < Source.Raster.NumberOfBands; bandIndex++)
                {
                    if (Double.IsNaN(Source.Imaging.Bands[bandIndex].SolarIrradiance))
                    {
                        _toarefGain[bandIndex] = 0;
                    }
                    else
                    {
                        _toarefGain[bandIndex] = Convert.ToSingle(Constants.PI * (1 - 0.01673 * Math.Cos(0.9856 * (dayOfYear - 4) * Constants.PI / 180) * (1 - 0.01673 * Math.Cos(0.9856 * (dayOfYear - 4) * Math.PI / 180))) / (Source.Imaging.Bands[bandIndex].SolarIrradiance * Math.Cos(sunZenith * Constants.PI / 180)));
                    }
                }
                break;

            case 8:
                for (Int32 bandIndex = 0; bandIndex < Source.Raster.NumberOfBands; bandIndex++)
                {
                    _toarefGain[bandIndex] = 1 / (Math.Sin(Source.Imaging.SunElevation * Math.PI / 180));
                }
                break;
            }

            SetResultProperties(RasterFormat.Floating, 32, RasterPresentation.CreateGrayscalePresentation());

            return(base.PrepareResult());
        }
        /// <summary>
        /// Prepares the result of the operation.
        /// </summary>
        /// <returns>The resulting object.</returns>
        protected override ISpectralGeometry PrepareResult()
        {
            RasterPresentation presentation = null;

            if (_bandIndices.SequenceEqual(Enumerable.Range(0, Source.Raster.NumberOfBands)))
            {
                presentation = Source.Presentation;
            }
            else if (_bandIndices.Length == 3)
            {
                presentation = RasterPresentation.CreateFalseColorPresentation(0, 1, 2);
            }
            else
            {
                presentation = RasterPresentation.CreateGrayscalePresentation();
            }

            RasterImaging imaging = null;

            if (Source.Imaging != null)
            {
                imaging = RasterImaging.Filter(Source.Imaging, _bandIndices);
            }

            SetResultProperties(Source.Raster.Format, _bandIndices.Length, Source.Raster.NumberOfRows, Source.Raster.NumberOfColumns, Source.Raster.RadiometricResolution, Source.Raster.Mapper, presentation, imaging);

            return(base.PrepareResult());
        }
Example #3
0
        /// <summary>
        /// Sets the properties of the result.
        /// </summary>
        /// <param name="format">The raster format.</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>
        /// <param name="presentation">The raster presentation.</param>
        /// <param name="imaging">The raster imaging.</param>
        protected void SetResultProperties(RasterFormat format, Int32 numberOfBands, Int32 numberOfRows, Int32 numberOfColumns, Int32 radiometricResolution, RasterMapper mapper, RasterPresentation presentation, RasterImaging imaging)
        {
            if (_resultPropertiesSet)
            {
                return;
            }

            _resultFormat       = format;
            _resultDimensions   = new RasterDimensions(numberOfBands, numberOfRows, numberOfColumns, radiometricResolution);
            _resultMapper       = mapper;
            _resultPresentation = presentation;
            _resultImaging      = imaging;

            _resultPropertiesSet = true;
        }
Example #4
0
        /// <summary>
        /// Sets the properties of the result.
        /// </summary>
        /// <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>
        protected void SetResultProperties(Int32 numberOfBands, Int32 numberOfRows, Int32 numberOfColumns, Int32 radiometricResolution)
        {
            if (_resultPropertiesSet)
            {
                return;
            }

            _resultFormat       = Source.Raster.Format;
            _resultDimensions   = new RasterDimensions(numberOfBands, numberOfRows, numberOfColumns, radiometricResolution);
            _resultMapper       = Source.Raster.Mapper;
            _resultPresentation = Source.Presentation;
            _resultImaging      = Source.Imaging;

            _resultPropertiesSet = true;
        }
Example #5
0
        /// <summary>
        /// Sets the properties of the result.
        /// </summary>
        /// <param name="format">The raster format.</param>
        /// <param name="dimensions">The raster dimensions.</param>
        /// <param name="mapper">The mapper.</param>
        /// <param name="presentation">The raster presentation.</param>
        /// <param name="imaging">The raster imaging.</param>
        protected void SetResultProperties(RasterFormat format, RasterDimensions dimensions, RasterMapper mapper, RasterPresentation presentation, RasterImaging imaging)
        {
            if (_resultPropertiesSet)
            {
                return;
            }

            _resultFormat       = format;
            _resultDimensions   = dimensions ?? Source.Raster.Dimensions;
            _resultMapper       = mapper;
            _resultPresentation = presentation;
            _resultImaging      = imaging;

            _resultPropertiesSet = true;
        }
Example #6
0
        /// <summary>
        /// Sets the properties of the result.
        /// </summary>
        /// <param name="format">The raster format.</param>
        /// <param name="dimensions">The raster dimensions.</param>
        protected void SetResultProperties(RasterFormat format, RasterDimensions dimensions)
        {
            if (_resultPropertiesSet)
            {
                return;
            }

            _resultFormat       = format;
            _resultDimensions   = dimensions ?? Source.Raster.Dimensions;
            _resultMapper       = Source.Raster.Mapper;
            _resultPresentation = Source.Presentation;
            _resultImaging      = Source.Imaging;

            _resultPropertiesSet = true;
        }
Example #7
0
        /// <summary>
        /// Sets the properties of the result.
        /// </summary>
        /// <param name="geometry">The geometry.</param>
        /// <param name="format">The raster format.</param>
        /// <param name="numberOfBands">The number of bands.</param>
        /// <param name="radiometricResolution">The radiometric resolution.</param>
        /// <param name="presentation">The raster presentation.</param>
        protected void SetResultProperties(ISpectralGeometry geometry, RasterFormat format, Int32 numberOfBands, Int32 radiometricResolution, RasterPresentation presentation)
        {
            if (_resultPropertiesSet)
            {
                return;
            }

            _resultGeometry     = geometry;
            _resultFormat       = format;
            _resultDimensions   = new RasterDimensions(numberOfBands, Source.Raster.NumberOfRows, Source.Raster.NumberOfColumns, radiometricResolution);
            _resultMapper       = Source.Raster.Mapper;
            _resultPresentation = presentation;
            _resultImaging      = Source.Imaging;

            _resultPropertiesSet = true;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="SpectralPolygon" /> class.
        /// </summary>
        /// <param name="factory">The factory.</param>
        /// <param name="shell">The shell.</param>
        /// <param name="holes">The holes.</param>
        /// <param name="raster">The raster.</param>
        /// <param name="interpretation">The interpretation data.</param>
        /// <param name="imaging">The imaging data.</param>
        /// <param name="metadata">The metadata.</param>
        /// <exception cref="System.ArgumentNullException">
        /// The raster is null.
        /// or
        /// The shell is null.
        /// </exception>
        /// <exception cref="System.ArgumentException">The shell is empty.</exception>
        public SpectralPolygon(ISpectralGeometryFactory factory, IEnumerable <Coordinate> shell, IEnumerable <IEnumerable <Coordinate> > holes, IRaster raster, RasterPresentation presentation, RasterImaging imaging, IDictionary <String, Object> metadata)
        {
            if (raster == null)
            {
                throw new ArgumentNullException("raster", "The raster is null.");
            }

            _factory = factory ?? new SpectralGeometryFactory(new GeometryFactory(), new RasterFactory());

            Raster       = raster;
            Presentation = presentation;
            Imaging      = imaging;

            _polygon = _factory.GetFactory <IGeometryFactory>().CreatePolygon(shell, holes, metadata);

            _polygon.GeometryChanged += new EventHandler(Polygon_GeometryChanged);
        }
        /// <summary>
        /// Prepares the result of the operation.
        /// </summary>
        /// <returns>The resulting object.</returns>
        protected override ISpectralGeometry PrepareResult()
        {
            _toarefGain = new Double[Source.Raster.NumberOfBands];

            Double sunZenith = 90 - Source.Imaging.SunElevation, doySolarIrradianceSunZenithRatio;
            Int32  dayOfYear = Source.Imaging.Time.DayOfYear;

            for (Int32 bandIndex = 0; bandIndex < Source.Raster.NumberOfBands; bandIndex++)
            {
                doySolarIrradianceSunZenithRatio = Convert.ToSingle(Constants.PI * (1 - 0.01673 * Math.Cos(0.9856 * (dayOfYear - 4) * Constants.PI / 180) * (1 - 0.01673 * Math.Cos(0.9856 * (dayOfYear - 4) * Math.PI / 180))) / (Source.Imaging.Bands[bandIndex].SolarIrradiance * Math.Cos(sunZenith * Constants.PI / 180)));
                _toarefGain[bandIndex]           = doySolarIrradianceSunZenithRatio / Source.Imaging.Bands[bandIndex].PhysicalGain;
            }

            SetResultProperties(RasterFormat.Floating, 32, RasterPresentation.CreateGrayscalePresentation());

            return(base.PrepareResult());
        }
Example #10
0
        /// <summary>
        /// Prepares the result of the operation.
        /// </summary>
        /// <returns>The resulting object.</returns>
        protected override ISpectralGeometry PrepareResult()
        {
            _segmentNumbers = new Dictionary <Segment, UInt32>();

            UInt32 number = 0;

            foreach (Segment segment in _segmentCollection.GetSegments())
            {
                _segmentNumbers.Add(segment, number);
                number++;
            }

            Int32 radiometricResolution = _segmentCollection.Count > Int16.MaxValue ? 32 : (_segmentCollection.Count > Byte.MaxValue ? 16 : 8);

            SetResultProperties(RasterFormat.Integer, 1, radiometricResolution, RasterPresentation.CreateGrayscalePresentation());

            return(base.PrepareResult());
        }
Example #11
0
        /// <summary>
        /// Prepares the result of the operation.
        /// </summary>
        /// <returns>The resulting object.</returns>
        protected override ISpectralGeometry PrepareResult()
        {
            _meanValue = new Double[Source.Raster.NumberOfBands];

            for (Int32 bandIndex = 0; bandIndex < Source.Raster.NumberOfBands; bandIndex++)
            {
                Double result = 0;
                for (Int32 rowIndex = 0; rowIndex < Source.Raster.NumberOfRows; rowIndex++)
                {
                    for (Int32 columnIndex = 0; columnIndex < Source.Raster.NumberOfColumns; columnIndex++)
                    {
                        result += Source.Raster.GetFloatValue(rowIndex, columnIndex, bandIndex);
                    }
                }

                _meanValue[bandIndex] = result / (Source.Raster.NumberOfColumns * Source.Raster.NumberOfRows);
            }

            SetResultProperties(RasterFormat.Integer, 8, RasterPresentation.CreateGrayscalePresentation());

            return(base.PrepareResult());
        }
Example #12
0
        /// <summary>
        /// Prepares the result of the operation.
        /// </summary>
        /// <returns>The resulting object.</returns>
        protected override ISpectralGeometry PrepareResult()
        {
            Int32 maxSourceValue = 0;

            for (Int32 bandIndex = 0; bandIndex < Source.Raster.NumberOfBands; bandIndex++)
            {
                for (Int32 rowIndex = 0; rowIndex < Source.Raster.NumberOfRows; rowIndex++)
                {
                    for (Int32 columnIndex = 0; columnIndex < Source.Raster.NumberOfColumns; columnIndex++)
                    {
                        maxSourceValue = Math.Max(maxSourceValue, (Int32)Source.Raster.GetValue(rowIndex, columnIndex, bandIndex));
                    }
                }
            }

            // selection of colors with equal range from minimum to maximum
            _colors = Enumerable.Range(1, maxSourceValue + 1).Select(number => (Int32)(number * ((1 << 24) - 1.0) / (maxSourceValue + 1))).ToArray();

            // randomization
            Random random = new Random();

            for (Int32 colorIndex = 0; colorIndex < _colors.Length; colorIndex++)
            {
                Int32 replaceIndex = random.Next(0, _colors.Length);
                Int32 temp         = _colors[colorIndex];
                _colors[colorIndex]   = _colors[replaceIndex];
                _colors[replaceIndex] = temp;
            }

            SetResultProperties(RasterFormat.Integer, 3, maxSourceValue > Calculator.Pow(256, 3) ? 16 : 8, RasterPresentation.CreateTrueColorPresentation());

            return(base.PrepareResult());
        }
        /// <summary>
        /// Prepares the result of the operation.
        /// </summary>
        /// <returns>The resulting object.</returns>
        protected override ISpectralGeometry PrepareResult()
        {
            SetResultProperties(RasterFormat.Integer, 3, 8, RasterPresentation.CreateTrueColorPresentation(0, 1, 2));

            return(base.PrepareResult());
        }
        /// <summary>
        /// Prepares the result of the operation.
        /// </summary>
        /// <returns>The resulting object.</returns>
        protected override ISpectralGeometry PrepareResult()
        {
            SetResultProperties(_validationGeometry, RasterFormat.Integer, 1, 8, RasterPresentation.CreateGrayscalePresentation());

            return(base.PrepareResult());
        }
Example #15
0
 /// <summary>
 /// Sets the properties of the result.
 /// </summary>
 /// <param name="format">The raster format.</param>
 /// <param name="numberOfBands">The number of bands.</param>
 /// <param name="radiometricResolution">The radiometric resolution.</param>
 /// <param name="presentation">The raster presentation.</param>
 protected void SetResultProperties(RasterFormat format, Int32 numberOfBands, Int32 radiometricResolution, RasterPresentation presentation)
 {
     SetResultProperties(format, numberOfBands, Source.Raster.NumberOfRows, Source.Raster.NumberOfColumns, radiometricResolution, presentation);
 }
Example #16
0
        /// <summary>
        /// Prepares the result of the operation.
        /// </summary>
        /// <returns>The resulting object.</returns>
        protected override ISpectralGeometry PrepareResult()
        {
            SetResultProperties(RasterFormat.Floating, 1, 32, RasterPresentation.CreateGrayscalePresentation());

            return(base.PrepareResult());
        }
Example #17
0
        /// <summary>
        /// Prepares the result of the operation.
        /// </summary>
        /// <returns>The resulting object.</returns>
        protected override ISpectralGeometry PrepareResult()
        {
            SetResultProperties(RasterFormat.Floating, 3, 32, RasterPresentation.CreateFalseColorPresentation(0, 1, 2));

            return(base.PrepareResult());
        }