Пример #1
0
        /// <summary>
        ///     Performs latitude calculations as part of lat/long to scanning angle. These are cached in order to avoid
        ///     repeating latitude calculations for every pixel.
        /// </summary>
        private LatitudeCalculations CalculateGeostationaryLatitude(int y)
        {
            var target  = _target;
            var yOffset = _yOffset;

            return(LatitudeCalculationCache.GetOrAdd(y, angle =>
            {
                // Convert pixel row to latitude
                var projectionY = ProjectionAngleConverter.FromY(y, target.Height + yOffset * 2);

                // Perform and cache intermediary geostationary latitude calculations
                return GeostationaryProjection.LatitudeCalculations(projectionY);
            }));
        }
Пример #2
0
        public void Invoke(int y)
        {
            var span = _target.GetPixelRowSpan(y);

            // Calculate or retrieve the latitude calculation component of geostationary projection
            var latitudeCalculations = CalculateGeostationaryLatitude(y + _yOffset);

            // Convert image x,y to Mercator projection angle
            var targetWidth = _registration.Width * 2;
            var projectionY = ProjectionAngleConverter.FromY(y + _yOffset, _registration.Height);

            for (var x = 0; x < span.Length; x++)
            {
                var projectionX = ProjectionAngleConverter.FromX(x + _xOffset, targetWidth);

                // Convert latitude/longitude to geostationary scanning angle
                GeostationaryProjection.ToScanningAngle(latitudeCalculations, projectionX, _registration.Definition, out var scanningX, out var scanningY);

                // Map pixel from satellite image back to target image
                span[x] = GetTargetColour(scanningX, scanningY, projectionY, projectionX);
            }
        }
Пример #3
0
 public void FromY()
 {
     Angle.FromRadians(ProjectionAngleConverter.FromY(0, 200)).Degrees.Should().BeApproximately(90, Precision);
     Angle.FromRadians(ProjectionAngleConverter.FromY(200, 200)).Degrees.Should().BeApproximately(-90, Precision);
     Angle.FromRadians(ProjectionAngleConverter.FromY(100, 200)).Degrees.Should().BeApproximately(0, Precision);
 }