コード例 #1
0
        private void ReadyArgs(AbstractWarpDataset srcRaster, FilePrjSettings prjSettings,
                               SpatialReference dstSpatialRef, Action <int, string> progressCallback)
        {
            if (srcRaster == null)
            {
                throw new ArgumentNullException("srcRaster");
            }
            if (prjSettings == null)
            {
                throw new ArgumentNullException("prjSettings");
            }
            _readyProgress = 0;
            _prjSettings   = prjSettings as FY3_VIRR_PrjSettings;
            _dstSpatialRef = dstSpatialRef;
            MemoryHelper.MemoryNeed(200, 1536); //剩余200MB,已使用1.2GB
            if (progressCallback != null)
            {
                progressCallback(_readyProgress++, "准备相关参数");
            }
            TryCreateDefaultArgs(srcRaster, _prjSettings, ref dstSpatialRef);
            //这里去除的是读取轨道数据时候的左右像元个数。
            _left  = 4;
            _right = 4;
            TrySetLeftRightInvalidPixel(_prjSettings.ExtArgs);
            DoSession(srcRaster, dstSpatialRef, _prjSettings, progressCallback);
            if (prjSettings.OutEnvelope == null || prjSettings.OutEnvelope == PrjEnvelope.Empty)
            {
                prjSettings.OutEnvelope = _maxPrjEnvelope;
                _orbitBlock             = new Block
                {
                    xBegin = 0, yBegin = 0, xEnd = srcRaster.Width - 1, yEnd = srcRaster.Height - 1
                };
            }
            else
            {
                GetEnvelope(_xs, _ys, srcRaster.Width, srcRaster.Height, _prjSettings.OutEnvelope, out _orbitBlock);
                if (_orbitBlock == null || _orbitBlock.Width <= 0 || _orbitBlock.Height <= 0)
                {
                    throw new Exception("数据不在目标区间内");
                }
                float invalidPresent = (_orbitBlock.Width * _orbitBlock.Height * 1.0F) /
                                       (srcRaster.Width * srcRaster.Height);
                if (invalidPresent < 0.0001f)
                {
                    throw new Exception("数据占轨道数据比例太小,有效率" + invalidPresent * 100 + "%");
                }
                if (invalidPresent > 0.60)
                {
                    _orbitBlock = new Block
                    {
                        xBegin = 0, yBegin = 0, xEnd = srcRaster.Width - 1, yEnd = srcRaster.Height - 1
                    }
                }
                ;
            }

            //if (dstSpatialRef.IsGeographic()==1 && (prjSettings.OutEnvelope.MaxY > 80 || prjSettings.OutEnvelope.MaxY < -80))
            //    throw new Exception(string.Format("高纬度数据,不适合投影为等经纬度数据[{0}]", _maxPrjEnvelope));
            _dstSpatialRef = dstSpatialRef;
            _dstEnvelope   = _prjSettings.OutEnvelope;
            if (!_dstEnvelope.IntersectsWith(_maxPrjEnvelope))
            {
                throw new Exception("数据不在目标区间内");
            }
            _outResolutionX = _prjSettings.OutResolutionX;
            _outResolutionY = _prjSettings.OutResolutionY;
            _outFormat      = _prjSettings.OutFormat;
            _outfilename    = _prjSettings.OutPathAndFileName;
            _dstProj4       = _dstSpatialRef.ExportToProj4();
            _dstBandCount   = _prjBands.Length;
            _dstSize        = _prjSettings.OutSize;
            _isRadRef       = _prjSettings.IsRadRef;
            _isSolarZenith  = _prjSettings.IsSolarZenith;
            _isSensorZenith = _prjSettings.IsSensorZenith;
            _isRad          = _prjSettings.IsRad;
        }
コード例 #2
0
        private void ReadyArgs(AbstractWarpDataset srcRaster, FilePrjSettings prjSettings, SpatialReference dstSpatialRef, Action <int, string> progressCallback)
        {
            if (srcRaster.DataIdentify != null)
            {
                string satellite = srcRaster.DataIdentify.Satellite;
                //if (satellite == "FY3A")//FY3A MERSI250米数据已经经过处理,不需要再执行去条带操作
                //{
                //    _sacnLineWidth = 0;
                //}
            }
            float resolutionScale = 1f;

            _readyProgress = 0;
            if (progressCallback != null)
            {
                progressCallback(_readyProgress++, "准备相关参数");
            }
            _prjSettings = ArgsCheck(srcRaster, prjSettings);
            CheckIs0250(srcRaster);
            _dstSpatialRef = dstSpatialRef;
            switch (_dataType)
            {
            case "1KM":
                //整轨投影时候去除左右锯齿,分块投影不需要
                _left  = 10;
                _right = 10;
                if (_prjSettings.OutEnvelope == null || _prjSettings.OutEnvelope == PrjEnvelope.Empty)    //整轨投影
                {
                    MemoryHelper.MemoryNeed(500, 1536);
                }
                else
                {
                    MemoryHelper.MemoryNeed(400, 1536);    //剩余900MB,已使用1.2GB
                }
                TryCreateDefaultArgs(srcRaster, _prjSettings, ref _dstSpatialRef);
                DoSession(srcRaster, srcRaster, _dstSpatialRef, _prjSettings, progressCallback);
                _angleDataProvider = srcRaster;
                break;

            case "QKM":
                resolutionScale = 4f;
                _left           = 20;
                _right          = 20;
                if (_prjSettings.OutEnvelope == null || _prjSettings.OutEnvelope == PrjEnvelope.Empty)
                {
                    MemoryHelper.MemoryNeed(800, 1280);         //整幅投影对内存做限制,系统剩余内存不低于1.5GB,应用程序已使用内存不超过600MB
                }
                else
                {
                    MemoryHelper.MemoryNeed(600, 1280);         //剩余900MB,已使用1.2GB
                }
                TryCreate0250DefaultArgs(srcRaster, _prjSettings, ref _dstSpatialRef);
                DoSession(srcRaster, _prjSettings.SecondaryOrbitRaster, _dstSpatialRef, _prjSettings, progressCallback);
                _angleDataProvider = _prjSettings.SecondaryOrbitRaster;
                break;

            default:
                break;
            }
            TrySetLeftRightInvalidPixel(_prjSettings.ExtArgs);
            if (_prjSettings.OutEnvelope == null || _prjSettings.OutEnvelope == PrjEnvelope.Empty)
            {
                _prjSettings.OutEnvelope = _maxPrjEnvelope;
                _orbitBlock = new Block {
                    xBegin = 0, yBegin = 0, xEnd = _srcLocationSize.Width - 1, yEnd = _srcLocationSize.Height - 1
                };
            }
            else
            {
                GetEnvelope(_xs, _ys, _srcLocationSize.Width, _srcLocationSize.Height, _prjSettings.OutEnvelope, out _orbitBlock);
                if (_orbitBlock == null || _orbitBlock.Width <= 0 || _orbitBlock.Height <= 0)
                {
                    throw new Exception("数据不在目标区间内");
                }
                float invalidPresent = (_orbitBlock.Width * _orbitBlock.Height * resolutionScale) / (_srcLocationSize.Width * _srcLocationSize.Height);
                if (invalidPresent < 0.0001f)
                {
                    throw new Exception("数据占轨道数据比例太小,有效率" + invalidPresent * 100 + "%");
                }
                if (invalidPresent > 0.60)
                {
                    _orbitBlock = new Block {
                        xBegin = 0, yBegin = 0, xEnd = _srcLocationSize.Width - 1, yEnd = _srcLocationSize.Height - 1
                    }
                }
                ;
            }
            //地理坐标投影,下面简单的对地理坐标投影的范围作了限制,不大严谨,仅适合目前的状况。
            //if (_dstSpatialRef.IsGeographic()==1 && (prjSettings.OutEnvelope.MaxY > 80 || prjSettings.OutEnvelope.MaxY < -80))
            //    throw new Exception(string.Format("高纬度数据,不适合投影为等经纬度数据[{0}]", _maxPrjEnvelope));
            //以下参数用于投影
            _dstEnvelope = _prjSettings.OutEnvelope;
            if (!_dstEnvelope.IntersectsWith(_maxPrjEnvelope))
            {
                throw new Exception("数据不在目标区间内");
            }
            _outResolutionX = _prjSettings.OutResolutionX;
            _outResolutionY = _prjSettings.OutResolutionY;
            _outFormat      = _prjSettings.OutFormat;
            _outfilename    = _prjSettings.OutPathAndFileName;
            _dstProj4       = _dstSpatialRef.ExportToProj4();
            _dstBandCount   = _prjBands.Length;
            _dstSize        = _prjSettings.OutSize;
            _isRadRef       = _prjSettings.IsRadRef;
            _isSolarZenith  = _prjSettings.IsSolarZenith;
            _isSensorZenith = _prjSettings.IsSensorZenith;
            _isRad          = _prjSettings.IsRad;
        }
コード例 #3
0
        private void ReadyArgs(AbstractWarpDataset srcRaster, FilePrjSettings prjSettings, SpatialReference dstSpatialRef, Action <int, string> progressCallback)
        {
            float resolutionScale = 1f;

            _readyProgress = 0;
            if (progressCallback != null)
            {
                progressCallback(_readyProgress++, "准备相关参数");
            }
            _prjSettings     = ArgsCheck(srcRaster, prjSettings);
            _geoDataProvider = _prjSettings.GeoFile;
            CheckIs0250(srcRaster);
            _dstSpatialRef = dstSpatialRef;
            switch (_dataType)
            {
            case "1KM":
                //整轨投影时候去除左右锯齿,分块投影不需要
                _left  = 10;
                _right = 10;
                if (_prjSettings.OutEnvelope == null || _prjSettings.OutEnvelope == PrjEnvelope.Empty)    //整轨投影时做限制
                {
                    MemoryHelper.MemoryNeed(500, 1536);
                }
                else
                {
                    MemoryHelper.MemoryNeed(400, 1536);          //剩余900MB,已使用1.2GB
                }
                //_angleDataProvider = srcRaster;
                TryCreateDefaultArgs(srcRaster, _prjSettings, ref _dstSpatialRef);
                TrySetLeftRightInvalidPixel(_prjSettings.ExtArgs);
                DoSession(srcRaster, _geoDataProvider, _dstSpatialRef, _prjSettings, progressCallback);
                break;

            case "QKM":
                resolutionScale = 4f;
                _left           = 20;
                _right          = 20;
                if (_prjSettings.OutEnvelope == null || _prjSettings.OutEnvelope == PrjEnvelope.Empty)
                {
                    MemoryHelper.MemoryNeed(800, 1280);         //整幅投影对内存做限制,系统剩余内存不低于A参数MB,应用程序已使用内存不超过B参数MB
                }
                else
                {
                    MemoryHelper.MemoryNeed(600, 1280);         //剩余900MB,最大已使用1.2GB
                }
                //_angleDataProvider = _prjSettings.SecondaryOrbitRaster;
                TryCreate0250DefaultArgs(srcRaster, _prjSettings, ref _dstSpatialRef);
                TrySetLeftRightInvalidPixel(_prjSettings.ExtArgs);
                DoSession(srcRaster, _geoDataProvider, _dstSpatialRef, _prjSettings, progressCallback);
                break;

            default:
                break;
            }
            if (_prjSettings.OutEnvelope == null || _prjSettings.OutEnvelope == PrjEnvelope.Empty)
            {
                _prjSettings.OutEnvelope = _maxPrjEnvelope;
                _orbitBlock = new Block {
                    xBegin = 0, yBegin = 0, xEnd = _srcLocationSize.Width - 1, yEnd = _srcLocationSize.Height - 1
                };
            }
            else
            {
                if (_xs != null && _ys != null)
                {
                    GetEnvelope(_xs, _ys, _srcLocationSize.Width, _srcLocationSize.Height, _prjSettings.OutEnvelope, out _orbitBlock);
                }
                else
                {
                    int      bC        = 8;
                    int      tmpWidth  = 0;
                    int      tmpHeight = 0;
                    double[] tmpxs     = null;
                    double[] tmpys     = null;
                    //8024,8000
                    tmpWidth  = _srcLocationSize.Width / bC;
                    tmpHeight = _srcLocationSize.Height / bC;
                    tmpxs     = ReadSampleDatas(_longitudeBand, 0, 0, tmpWidth, tmpHeight);
                    tmpys     = ReadSampleDatas(_latitudeBand, 0, 0, tmpWidth, tmpHeight);
                    _rasterProjector.Transform(wgs84, tmpxs, tmpys, _dstSpatialRef);
                    //计算偏移
                    GetEnvelope(tmpxs, tmpys, tmpWidth, tmpHeight, _prjSettings.OutEnvelope, out _orbitBlock);
                    _orbitBlock = _orbitBlock.Zoom(bC, bC);
                }
                if (_orbitBlock == null || _orbitBlock.Width <= 0 || _orbitBlock.Height <= 0)
                {
                    throw new Exception("数据不在目标区间内");
                }
                float invalidPresent = (_orbitBlock.Width * _orbitBlock.Height * resolutionScale) / (_srcLocationSize.Width * _srcLocationSize.Height);
                if (invalidPresent < 0.0001f)
                {
                    throw new Exception("数据占轨道数据比例太小,有效率" + invalidPresent * 100 + "%");
                }
                if (invalidPresent > 0.60)
                {
                    _orbitBlock = new Block {
                        xBegin = 0, yBegin = 0, xEnd = _srcLocationSize.Width - 1, yEnd = _srcLocationSize.Height - 1
                    }
                }
                ;
            }
            //以下参数用于投影
            _dstEnvelope = _prjSettings.OutEnvelope;
            if (!_dstEnvelope.IntersectsWith(_maxPrjEnvelope))
            {
                throw new Exception("数据不在目标区间内");
            }
            _outResolutionX = _prjSettings.OutResolutionX;
            _outResolutionY = _prjSettings.OutResolutionY;
            _outFormat      = _prjSettings.OutFormat;
            _outfilename    = _prjSettings.OutPathAndFileName;
            _dstProj4       = _dstSpatialRef.ExportToProj4();
            _dstBandCount   = _prjBands.Length;
            _dstSize        = _prjSettings.OutSize;
            _isRadRef       = _prjSettings.IsRadRef;
            _isSolarZenith  = _prjSettings.IsSolarZenith;
            _isSensorZenith = _prjSettings.IsSensorZenith;
            _isRad          = _prjSettings.IsRad;
        }