public override void EndSession() { base.EndSession(); _xs = null; _ys = null; _vir_Cal_Coeff = null; if (_solarZenithCacheRaster != null) { _solarZenithCacheRaster.Dispose(); _solarZenithCacheRaster = null; } if (_longitudeBand != null) { (_longitudeBand as IDisposable).Dispose(); _longitudeBand = null; } if (_latitudeBand != null) { (_latitudeBand as IDisposable).Dispose(); _latitudeBand = null; } if (_latitudeRaster != null) { _latitudeRaster.Dispose(); _latitudeRaster = null; } if (_longitudeRaster != null) { _longitudeRaster.Dispose(); _longitudeRaster = null; } }
public override void Project(AbstractWarpDataset srcRaster, FilePrjSettings prjSettings, SpatialReference dstSpatialRef, Action <int, string> progressCallback) { try { ReadyArgs(srcRaster, prjSettings, dstSpatialRef, progressCallback); AbstractWarpDataset outwriter = null; try { Size outSize = _prjSettings.OutSize; string[] options = new string[] { "INTERLEAVE=BSQ", "VERSION=LDF", "WITHHDR=TRUE", "SPATIALREF=" + _dstSpatialRef.ExportToProj4(), "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); ProjectRaster(srcRaster, outwriter, 0, 9999, 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(); } } } }
public override void EndSession() { mBandGeoDataset?.Dispose(); iBandGeoDataset?.Dispose(); bandDatasetList.All(t => { t.Value?.Dispose(); return(true); }); base.EndSession(); }
public override void Project(AbstractWarpDataset srcRaster, FilePrjSettings prjSettings, SpatialReference dstSpatial, Action <int, string> progressCallback) { try { InitInputDataset(srcRaster, prjSettings); ReadyArgs(srcRaster, prjSettings, dstSpatial, progressCallback); AbstractWarpDataset outwriter = null; try { outwriter = CreateOutFile(_outfilename, _dstBandCount, _dstSize, null); WriteMetaData(srcRaster, outwriter, _prjSettings); ReadyAngleFiles(_geoDataProvider, _outfilename, _prjSettings, _dstSize, null); ReadyExtBands(_geoDataProvider, _outfilename, _prjSettings, _dstSize, null); ProjectToLDF(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 (Exception ex) { EndSession(); TryDeleteCurCatch(); throw; } finally { if (_curSession != null) { EndSession(); if (prjSettings.IsClearPrjCache) { TryDeleteCurCatch(); } } } //base.Project(srcRaster, prjSettings, dstSpatial, progressCallback); }
public override AbstractWarpDataset Project(AbstractWarpDataset srcRaster, FilePrjSettings prjSettings, AbstractWarpDataset dstRaster, int beginBandIndex, Action <int, string> progressCallback) { try { var dstSpatialRef = dstRaster.SpatialRef; ReadyArgs(srcRaster, prjSettings, dstSpatialRef, progressCallback); string[] angleOptions = LdfOptions(prjSettings, dstSpatialRef, _outResolutionX, _outResolutionY, srcRaster.DataIdentify); ReadyAngleFiles(srcRaster, _outfilename, prjSettings, _dstSize, angleOptions); ProjectToLDF(srcRaster, dstRaster, beginBandIndex, progressCallback); return(dstRaster); } catch (IOException ex) { if (ex.Message == "磁盘空间不足。\r\n" && File.Exists(_outfilename)) { File.Delete(_outfilename); } TryDeleteCurCatch(); throw ex; } catch { EndSession(); TryDeleteCurCatch(); throw; } finally { if (dstRaster != null) { dstRaster.Dispose(); dstRaster = null; } EndSession(); if (prjSettings.IsClearPrjCache) { TryDeleteCurCatch(); } } }
public override void Project(AbstractWarpDataset srcRaster, FilePrjSettings prjSettings, SpatialReference dstSpatialRef, Action <int, string> progressCallback) { try { ReadyArgs(srcRaster, prjSettings, dstSpatialRef, progressCallback); AbstractWarpDataset outwriter = null; try { //string[] options = new string[]{ // "INTERLEAVE=BSQ", // "VERSION=LDF", // "WITHHDR=TRUE", // "SPATIALREF=" + _dstSpatialRef.ExportToProj4(), // "MAPINFO={" + 1 + "," + 1 + "}:{" + _prjSettings.OutEnvelope.MinX + "," + _prjSettings.OutEnvelope.MaxY + "}:{" + _outResolutionX + "," + _outResolutionY + "}" // ,"BANDNAMES="+ BandNameString(_prjSettings.OutBandNos) //}; List <string> options = new List <string>(); options.Add("INTERLEAVE=BSQ"); options.Add("VERSION=LDF"); options.Add("WITHHDR=TRUE"); options.Add("SPATIALREF=" + _dstSpatialRef.ExportToProj4()); options.Add("MAPINFO={" + 1 + "," + 1 + "}:{" + _prjSettings.OutEnvelope.MinX + "," + _prjSettings.OutEnvelope.MaxY + "}:{" + _outResolutionX + "," + _outResolutionY + "}"); options.Add("SENSOR=MERSI"); if (srcRaster.DataIdentify != null) { string satellite = srcRaster.DataIdentify.Satellite; DateTime dt = srcRaster.DataIdentify.OrbitDateTime; bool asc = srcRaster.DataIdentify.IsAscOrbitDirection; if (!string.IsNullOrWhiteSpace(satellite)) { options.Add("SATELLITE=" + satellite); } if (dt != DateTime.MinValue && dt != DateTime.MaxValue) { options.Add("DATETIME=" + dt.ToString("yyyy/MM/dd HH:mm")); } options.Add("ORBITDIRECTION=" + (asc ? "ASC" : "DESC")); } List <string> op1 = new List <string>(options); op1.Add("BANDNAMES=" + BandNameString(_prjSettings.OutBandNos)); outwriter = CreateOutFile(_outfilename, _dstBandCount, _dstSize, op1.ToArray()); WriteMetaData(srcRaster, outwriter, _prjSettings); ReadyAngleFiles(_angleDataProvider, _outfilename, _prjSettings, _dstSize, options.ToArray()); ProjectToLDF(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(); } } } }
public override AbstractWarpDataset Project(AbstractWarpDataset srcRaster, FilePrjSettings prjSettings, AbstractWarpDataset dstRaster, int beginBandIndex, Action <int, string> progressCallback) { if (dstRaster == null) { return(null); } try { ReadyArgs(srcRaster, prjSettings, (dstRaster.SpatialRef), progressCallback); _prjSettings.OutPathAndFileName = dstRaster.fileName; _outfilename = dstRaster.fileName; _outResolutionX = dstRaster.ResolutionX; _outResolutionY = dstRaster.ResolutionY; _dstEnvelope = _prjSettings.OutEnvelope = new PrjEnvelope( dstRaster.GetEnvelope().MinX, dstRaster.GetEnvelope().MaxX, dstRaster.GetEnvelope().MinY, dstRaster.GetEnvelope().MaxY, _dstSpatialRef); try { Size outSize = new Size(dstRaster.Width, dstRaster.Height); //角度输出,其中的BANDNAME需要在ReadyAngleFiles()方法中获取 string[] angleOptions = new string[] { "INTERLEAVE=BSQ", "VERSION=LDF", "WITHHDR=TRUE", "SPATIALREF=" + _dstSpatialRef.ExportToProj4(), "MAPINFO={" + 1 + "," + 1 + "}:{" + _prjSettings.OutEnvelope.MinX + "," + _prjSettings.OutEnvelope.MaxY + "}:{" + _outResolutionX + "," + _outResolutionY + "}" }; ReadyAngleFiles(_angleDataProvider, _outfilename, _prjSettings, outSize, angleOptions); UpdateNodataValue(dstRaster); ProjectToLDF(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(); } } } }
/// <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 AbstractWarpDataset Project(AbstractWarpDataset srcRaster, FilePrjSettings prjSettings, AbstractWarpDataset dstRaster, int beginBandIndex, Action <int, string> progressCallback) { if (dstRaster == null) { return(null); } try { _dstSpatialRef = dstRaster.SpatialRef; var coordEnv = dstRaster.GetEnvelope(); prjSettings.OutEnvelope = new PrjEnvelope() { Srs = _dstSpatialRef, MinX = coordEnv.MinX, MinY = coordEnv.MinY, MaxX = coordEnv.MaxX, MaxY = coordEnv.MaxY }; ReadyArgs(srcRaster, prjSettings, _dstSpatialRef, 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.ExportToProj4(), "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(); } } } }