public override void Project(RSS.Core.DF.IRasterDataProvider srcRaster, FilePrjSettings prjSettings, Project.ISpatialReference dstSpatialRef, Action <int, string> progressCallback)
 {
     try
     {
         ReadyArgs(srcRaster, prjSettings, dstSpatialRef, progressCallback);
         IRasterDataProvider outwriter = null;
         try
         {
             Size     outSize = _prjSettings.OutSize;
             string[] options = new string[] {
                 "INTERLEAVE=BSQ",
                 "VERSION=LDF",
                 "WITHHDR=TRUE",
                 "SPATIALREF=" + _dstSpatialRef.ToProj4String(),
                 "MAPINFO={" + 1 + "," + 1 + "}:{" + _prjSettings.OutEnvelope.MinX + "," + _prjSettings.OutEnvelope.MaxY + "}:{" + _outResolutionX + "," + _outResolutionY + "}"
             };
             outwriter = CreateOutFile(_outfilename, _dstBandCount, outSize, srcRaster.DataType, options);
             //ReadyAngleFiles(_angleDataProvider, _outfilename, _prjSettings, outSize, options);
             ProjectRaster(srcRaster, outwriter, 0, progressCallback);
         }
         catch (IOException ex)
         {
             if (ex.Message == "磁盘空间不足。\r\n" && File.Exists(_outfilename))
             {
                 File.Delete(_outfilename);
             }
             throw ex;
         }
         finally
         {
             if (outwriter != null)
             {
                 outwriter.Dispose();
                 outwriter = null;
             }
         }
     }
     catch
     {
         EndSession();
         TryDeleteCurCatch();
         throw;
     }
     finally
     {
         if (_curSession == null)
         {
             EndSession();
             if (prjSettings.IsClearPrjCache)
             {
                 TryDeleteCurCatch();
             }
         }
     }
 }
Example #2
0
 public override void ComputeDstEnvelope(RSS.Core.DF.IRasterDataProvider srcRaster, Project.ISpatialReference dstSpatialRef, out RasterProject.PrjEnvelope maxPrjEnvelope, Action <int, string> progressCallback)
 {
     if (dstSpatialRef == null || dstSpatialRef.ProjectionCoordSystem == null)
     {
         maxPrjEnvelope = new PrjEnvelope(60, 150, -70, 70);
     }
     else
     {
         maxPrjEnvelope = null;
     }
 }
Example #3
0
        public void Resample(RSS.Core.DF.IRasterDataProvider srcRaster, FileResampleSetting resSettings, Action <int, string> progressCallback)
        {
            if (srcRaster == null)
            {
                throw new ArgumentNullException("srcRaster", "待重采样数据为空");
            }
            if (resSettings == null)
            {
                throw new ArgumentNullException("prjSettings", "重采样参数为空");
            }
            ReadExtArgs(resSettings);
            string outfilename            = resSettings.OutPathAndFileName;
            IRasterDataProvider outwriter = null;

            try
            {
                Size     outSize = _resSettings.OutSize;
                string[] options = new string[] {
                    "INTERLEAVE=BSQ",
                    "VERSION=LDF",
                    "WITHHDR=TRUE",
                    "SPATIALREF=" + _dstSpatialRef.ToProj4String(),
                    "MAPINFO={" + 1 + "," + 1 + "}:{" + _resSettings.OutEnvelope.MinX + "," + _resSettings.OutEnvelope.MaxY + "}:{" + _resSettings.OutResolutionX + "," + _resSettings.OutResolutionY + "}"
                };
                outwriter = CreateOutFile(outfilename, srcRaster.BandCount, outSize, srcRaster.DataType, options);
                if (File.Exists(outfilename))
                {
                    ResampleRaster(srcRaster, outwriter, progressCallback);
                }
                else
                {
                    throw new FileLoadException("目标文件" + outfilename + "不存在!");
                }
            }
            catch (IOException ex)
            {
                if (ex.Message == "磁盘空间不足。\r\n" && File.Exists(outfilename))
                {
                    File.Delete(outfilename);
                }
                throw ex;
            }
            finally
            {
                if (outwriter != null)
                {
                    outwriter.Dispose();
                    outwriter = null;
                }
            }
        }
Example #4
0
 public override void ComputeDstEnvelope(RSS.Core.DF.IRasterDataProvider srcRaster, Project.ISpatialReference dstSpatialRef, out RasterProject.PrjEnvelope maxPrjEnvelope, Action <int, string> progressCallback)
 {
     //throw new NotImplementedException();
     if (srcRaster != null)
     {
         Size     srcSize = new Size(srcRaster.Width, srcRaster.Height);
         double[] xs, ys;
         ReadyLocations(srcRaster, dstSpatialRef, srcSize, out xs, out ys, out maxPrjEnvelope, progressCallback);
     }
     else
     {
         maxPrjEnvelope = PrjEnvelope.Empty;
     }
 }
Example #5
0
        public void SetArgs(RSS.Core.DF.IRasterDataProvider rasterDataProvider)
        {
            if (rasterDataProvider == null)
            {
                return;
            }
            DataIdentify dataIdentify = rasterDataProvider.DataIdentify;

            if (dataIdentify.IsOrbit)
            {
                AddBandsWithOrbit(rasterDataProvider);
            }
            else
            {
                AddBandsWithProjected(rasterDataProvider);
            }
        }
Example #6
0
        public static void TryCorrectCenterWaveNum(RSS.Core.DF.IRasterDataProvider dataProvider, int midIfrBandNo, int farIfrBandNo, ref float midIfrCenterWaveNum, ref float farIfrCenterWaveNum, IContextMessage contextMessage)
        {
            DataIdentify id = dataProvider.DataIdentify;

            if (id != null && !string.IsNullOrEmpty(id.Satellite) && !string.IsNullOrEmpty(id.Sensor))
            {
                BandnameRefTable tb = BandRefTableHelper.GetBandRefTable(id.Satellite, id.Sensor);
                if (tb != null)
                {
                    float        wn   = 0;
                    BandnameItem item = tb.GetBandItem(midIfrBandNo);
                    if (item != null)
                    {
                        wn = item.CenterWaveNumber;
                        if (wn > float.Epsilon)
                        {
                            midIfrCenterWaveNum = wn;
                        }
                    }
                    item = tb.GetBandItem(farIfrBandNo);
                    if (item != null)
                    {
                        wn = item.CenterWaveNumber;
                        if (wn > float.Epsilon)
                        {
                            farIfrCenterWaveNum = wn;
                        }
                    }
                }
            }
            //
            if (farIfrCenterWaveNum < float.Epsilon)
            {
                farIfrCenterWaveNum = 912;
                PrintInfo(contextMessage, "     通过卫星、传感器获远红外中心波数失败,使用缺省值:912。");
            }
            if (midIfrCenterWaveNum < float.Epsilon)
            {
                midIfrCenterWaveNum = 2640;
                PrintInfo(contextMessage, "     通过卫星、传感器获中红外中心波数失败,使用缺省值:2640。");
            }
        }
Example #7
0
        protected override void ReadLocations(RSS.Core.DF.IRasterDataProvider srcRaster, out double[] xs, out double[] ys, out System.Drawing.Size locationSize)
        {
            IRasterBand longitudeBand = null;
            IRasterBand latitudeBand  = null;

            try
            {
                ReadLocations(srcRaster, out longitudeBand, out latitudeBand);
                ReadBandData(longitudeBand, out xs, out locationSize);
                ReadBandData(latitudeBand, out ys, out locationSize);
                TryApplyGeoInterceptSlope(xs, ys);
            }
            finally
            {
                if (longitudeBand != null)
                {
                    longitudeBand.Dispose();
                }
                if (latitudeBand != null)
                {
                    latitudeBand.Dispose();
                }
            }
        }
 protected override void DoRadiation(RSS.Core.DF.IRasterDataProvider srcImgRaster, int i, ushort[] srcBandData, float[] solarZenithData, System.Drawing.Size srcBlockImgSize, System.Drawing.Size angleSize)
 {
 }
 public override void ComputeDstEnvelope(RSS.Core.DF.IRasterDataProvider srcRaster, Project.ISpatialReference dstSpatialRef, out RasterProject.PrjEnvelope maxPrjEnvelope, Action <int, string> progressCallback)
 {
     throw new NotImplementedException();
 }
Example #10
0
 /// <summary>
 /// 投影
 /// </summary>
 /// <param name="srcRaster"></param>
 /// <param name="prjSettings"></param>
 /// <param name="dstRaster"></param>
 /// <param name="beginBandIndex"></param>
 /// <param name="progressCallback"></param>
 /// <returns></returns>
 public override IRasterDataProvider Project(IRasterDataProvider srcRaster, FilePrjSettings prjSettings, RSS.Core.DF.IRasterDataProvider dstRaster, int beginBandIndex, Action <int, string> progressCallback)
 {
     if (dstRaster == null)
     {
         return(null);
     }
     try
     {
         _dstSpatialRef = dstRaster.SpatialRef;
         CoordEnvelope coordEnv = dstRaster.CoordEnvelope;
         prjSettings.OutEnvelope = PrjEnvelope.CreateByLeftTop(coordEnv.MinX, coordEnv.MaxY, coordEnv.Width, coordEnv.Height);
         ReadyArgs(srcRaster, prjSettings, dstRaster.SpatialRef, progressCallback);
         string outfilename = _prjSettings.OutPathAndFileName;
         try
         {
             Size     outSize = new Size(dstRaster.Width, dstRaster.Height);
             string[] options = new string[] {
                 "INTERLEAVE=BSQ",
                 "VERSION=LDF",
                 "WITHHDR=TRUE",
                 "SPATIALREF=" + _dstSpatialRef.ToProj4String(),
                 "MAPINFO={" + 1 + "," + 1 + "}:{" + _prjSettings.OutEnvelope.MinX + "," + _prjSettings.OutEnvelope.MaxY + "}:{" + dstRaster.ResolutionX + "," + dstRaster.ResolutionY + "}"
                 , "BANDNAMES=" + BandNameString(_prjSettings.OutBandNos)
             };
             //ReadyAngleFiles(_angleDataProvider, outfilename, _prjSettings, outSize, options);
             ProjectRaster(srcRaster, dstRaster, beginBandIndex, progressCallback);
             return(dstRaster);
         }
         catch (IOException ex)
         {
             if (ex.Message == "磁盘空间不足。\r\n" && File.Exists(outfilename))
             {
                 File.Delete(outfilename);
             }
             throw ex;
         }
         finally
         {
             if (dstRaster != null)
             {
                 dstRaster.Dispose();
                 dstRaster = null;
             }
         }
     }
     catch
     {
         EndSession();
         TryDeleteCurCatch();
         throw;
     }
     finally
     {
         if (_curSession == null)
         {
             EndSession();
             if (prjSettings.IsClearPrjCache)
             {
                 TryDeleteCurCatch();
             }
         }
     }
 }
Example #11
0
 public Mosaic(InputArg inArg, RSS.Core.DF.IRasterDataProvider infileRaster, Action <int, string> action)
 {
     this.inArg      = inArg;
     this.fileRaster = infileRaster;
     this.action     = action;
 }
Example #12
0
 protected override void DoRadiation(RSS.Core.DF.IRasterDataProvider srcImgRaster, int bandNo, ushort[] srcBandData, float[] solarZenithData, System.Drawing.Size srcBlockImgSize, System.Drawing.Size angleSize)
 {
     throw new NotImplementedException();
 }
Example #13
0
        public override void Project(RSS.Core.DF.IRasterDataProvider srcRaster, FilePrjSettings prjSettings, ISpatialReference dstSpatialRef, Action <int, string> progressCallback)
        {
            try
            {
                if (prjSettings == null)
                {
                    prjSettings = CreateDefaultPrjSettings();
                }
                ReadyArgs(srcRaster, prjSettings, dstSpatialRef, progressCallback);
                using (IRasterDataProvider dstRaster = CreateOutFile(prjSettings, dstSpatialRef, srcRaster.DataIdentify))
                {
                    if (dstRaster == null)
                    {
                        return;
                    }
                    string[] options = LdfOptions(prjSettings, dstRaster.SpatialRef, _outResolutionX, _outResolutionY, srcRaster.DataIdentify);
                    ReadyAngleFiles(srcRaster, _outfilename, prjSettings, _dstSize, options);
                    _dstDataBands = GetDstRasterBand(dstRaster, prjSettings, 0);
                    List <IRasterBand> srcbands = new List <IRasterBand>();
                    List <IRasterBand> dstbands = new List <IRasterBand>();
                    for (int i = 0; i < _rasterDataBands.Length; i++)
                    {
                        if (_rasterDataBands[i].BandNo != 5)
                        {
                            srcbands.Add(_rasterDataBands[i]);
                            dstbands.Add(_dstDataBands[i]);
                        }
                    }
                    if (dstSpatialRef == null || dstSpatialRef.ProjectionCoordSystem == null)
                    {
                        _srcImgResolution = 0.05f;
                    }
                    else
                    {
                        _srcImgResolution = 5000f;
                    }
                    //先处理5km的通道
                    //_orbitBlock = new Block { xOffset = 0, yBegin = 0, xEnd = srcbands[0].Width - 1, yEnd = srcbands[0].Height - 1 };
                    if (dstbands.Count != 0)
                    {
                        ProjectToLDF(srcbands.ToArray(), dstbands.ToArray(), 0, progressCallback);
                    }

                    //处理1km的通道
                    srcbands.Clear();
                    dstbands.Clear();
                    if (dstSpatialRef == null || dstSpatialRef.ProjectionCoordSystem == null)
                    {
                        _srcImgResolution = 0.01f;
                    }
                    else
                    {
                        _srcImgResolution = 1000f;
                    }
                    for (int i = 0; i < _rasterDataBands.Length; i++)
                    {
                        if (_rasterDataBands[i].BandNo == 5)
                        {
                            srcbands.Add(_rasterDataBands[i]);
                            dstbands.Add(_dstDataBands[i]);
                        }
                    }
                    if (srcbands.Count == 1)
                    {
                        //_orbitBlock = new Block { xOffset = 0, yBegin = 0, xEnd = srcbands[0].Width - 1, yEnd = srcbands[0].Height - 1 };
                        ProjectToLDF(srcbands.ToArray(), dstbands.ToArray(), 0, progressCallback);
                    }
                }
            }
            catch
            {
                EndSession();
                TryDeleteCurCatch();
                throw;
            }
            finally
            {
                EndSession();
                if (prjSettings.IsClearPrjCache)
                {
                    TryDeleteCurCatch();
                }
            }
        }