Esempio n. 1
0
 private void ReadExtArgs(FileResampleSetting prjSettings)
 {
     if (prjSettings.ExtArgs != null && prjSettings.ExtArgs.Length != 0)
     {
         foreach (object arg in prjSettings.ExtArgs)
         {
             if (arg is Dictionary <string, double> )
             {
                 Dictionary <string, double> exAtg = arg as Dictionary <string, double>;
                 if (exAtg.ContainsKey("xzoom"))
                 {
                     _xzoom = exAtg["xzoom"];
                 }
                 if (exAtg.ContainsKey("yzoom"))
                 {
                     _yzoom = exAtg["yzoom"];
                 }
                 if (exAtg.ContainsKey("FillValue"))
                 {
                     _fillValue = exAtg["FillValue"];
                 }
             }
         }
     }
     if (prjSettings.OutEnvelope != null)
     {
         _resSettings         = prjSettings;
         _resSettings.OutSize = GetSize(prjSettings.OutResolutionX, prjSettings.OutEnvelope);
     }
 }
Esempio n. 2
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;
                }
            }
        }