private void Disposed(IGeoDataDriver ldfDrv, IRasterDataProvider ldfPrd, IRasterBand ldfBand, IMvgDriver mvgDrv, IMvgDataProvider mvgPrd, IRasterBand mvgBand) { if (mvgBand != null) { mvgBand.Dispose(); } if (mvgPrd != null) { mvgPrd.Dispose(); } if (mvgDrv != null) { mvgDrv.Dispose(); } if (ldfBand != null) { ldfBand.Dispose(); } if (ldfPrd != null) { ldfPrd.Dispose(); } if (ldfDrv != null) { ldfDrv.Dispose(); } }
public GRIB1DataProvider(string fileName, byte[] header1024, IGeoDataDriver driver, enumDataProviderAccess access) : base(fileName, driver) { ReadToDataProvider(); _bandCount = 1; LoadBands(); }
public void Compute(IRasterDataProvider dataProvider, string expression, string outDriver, string outFile, Action <int, string> progressTracker) { if (dataProvider == null || string.IsNullOrWhiteSpace(expression) || string.IsNullOrWhiteSpace(outDriver) || string.IsNullOrWhiteSpace(outFile)) { throw new ArgumentNullException(); } IGeoDataDriver driver = GeoDataDriver.GetDriverByName(outDriver); if (driver == null) { throw new Exception("driver '" + outDriver + "' is not existed."); } IRasterDataProvider dstProvider = CreateDstDataProvider(driver as IRasterDataDriver, outFile, dataProvider); if (dataProvider == null) { throw new Exception("use '" + outDriver + "'create RasterDataProvider is failed."); } try { Compute(dataProvider, expression, dstProvider.GetRasterBand(1), progressTracker); } finally { dstProvider.Dispose(); driver.Dispose(); } }
//适用于打开文件的情况 public MvgDataProvider(string fileName, IGeoDataDriver dataDriver, bool isReadOnly) : base(fileName, dataDriver) { _driver = dataDriver; _fileName = fileName; string hdrfile = HdrFile.GetHdrFileName(_fileName); if (File.Exists(hdrfile)) { _filelist = new string[] { _fileName, hdrfile } } ; else { _filelist = new string[] { _fileName } }; _header = new MvgHeader(fileName); FillProviderAttributes(); _fsStream = new FileStream(_fileName, FileMode.Open, isReadOnly ? FileAccess.Read : FileAccess.ReadWrite); if (!isReadOnly) { _binaryWriter = new BinaryWriter(_fsStream); } _binaryReader = new BinaryReader(_fsStream); LoadBands(); }
public NA141BDataProvider(string fileName, byte[] header1024, IGeoDataDriver driver, enumDataProviderAccess access) : base(fileName, header1024, driver, access) { InitDataIdentify(); _fsStream = new FileStream(fileName, FileMode.Open, access == enumDataProviderAccess.ReadOnly ? FileAccess.Read : FileAccess.ReadWrite); _binrayReader = new BinaryReader(_fsStream); }
void item_Click(object sender, EventArgs e) { RadMenuItem item = sender as RadMenuItem; if (item == null) { return; } IGeoDataDriver driver = item.Tag as IGeoDataDriver; if (driver == null) { return; } using (OpenFileDialog diag = new OpenFileDialog()) { diag.Title = "文件打开为" + driver.FullName; if (diag.ShowDialog() == DialogResult.OK) { try { IGeoDataProvider provider = driver.Open(diag.FileName, enumDataProviderAccess.ReadOnly); if (provider == null) { return; } OpenDataProvider(provider); } catch (Exception ex) { MsgBox.ShowInfo("无法识别为该驱动的文件" + driver.FullName); } } } }
public GRIB2DataProvider(string fileName, byte[] header1024, IGeoDataDriver driver, enumDataProviderAccess access) : base(fileName, driver) { _records = new List <GRIB2Record>(); _parameterList = new List <string>(); ReadToDataProvider(); }
public FY3AASOandASLProvider(string fileName, byte[] header1024, IGeoDataDriver driver, params object[] args) : base(fileName, driver) { _fileName = fileName; _args = args; using (Dataset dataset = Gdal.Open(fileName, Access.GA_ReadOnly)) { GDALHelper.GetDatasetAttributes(dataset, _attributes); } Dictionary <string, string> allGdalSubDatasets = this.Attributes.GetAttributeDomain("SUBDATASETS"); _allGdalSubDatasets = RecordAllSubDatasetNames(allGdalSubDatasets); _coordEnvelope = TrySetGeoInfo(); _selectedsets = TryGetSelectedSets(); TryCreateBandProvider(); _bandCount = _rasterBands.Count; _dataType = _rasterBands[0].DataType; _width = _rasterBands[0].Width; _height = _rasterBands[0].Height; _spatialRef = SpatialReference.GetDefault(); _coordType = _spatialRef.ProjectionCoordSystem != null ? enumCoordType.PrjCoord : enumCoordType.GeoCoord; _resolutionX = (float)(_coordEnvelope.Width / (_width)); _resolutionY = (float)(_coordEnvelope.Height / (_height)); if (_dataIdentify != null) { _dataIdentify.OrbitDateTime = IceConDataProvider.TryGetFileDate(Path.GetFileName(fileName)); } }
public SeaWaveDataProvider(string fileName, IGeoDataDriver driver) : base(fileName, driver) { _filelist = new string[] { fileName }; _fileName = fileName; ReadData(); }
/// <summary> /// /// </summary> /// <param name="fileName"></param> /// <param name="header1024"></param> /// <param name="driver"></param> /// <param name="args"> /// 可扩展的参数信息,每对参数都采用key=value的形式。 /// 1、数据集,采用逗号分隔的形式加入默认所选择的波段。 /// 例如:datasets=VIRR_1Km_LST[,...] /// 2、投影方式,采用proj4字符串的形式 /// 例如:proj4= /// 3、其他待扩展的参数信息 /// 坐标信息:geoinfo=1,2,3,4,5,6//其中1,2,3,4,5,6分辨代表:minX,maxX,minY,maxY,resolutionX,resolutionY; /// 经纬度数据集:geodatasets=Longitude,Latitude//该数据对轨道数据有效。 /// </param> public HdfRasterDataProvider(string fileName, byte[] header1024, IGeoDataDriver driver, params object[] args) : base(fileName, driver) //: base(fileName, driver) { _args = args; TryParseArgs(); using (Dataset _dataset = Gdal.Open(fileName, Access.GA_ReadOnly)) { GDALHelper.GetDatasetAttributes(_dataset, _attributes); //数据集仅有一个数据集,一个通道 if (_dataset.RasterCount == 1) { //GDAL对于只有一个数据集的HDF数据,SUBDATASETS属性值是空的,这里尝试手动设置下 TrySetGDALSUBDATASETS(_datasets); } } //...可以在此添加投影等信息 TryCreateBandProvider(fileName, header1024, _datasets, _attributes.GetAttributeDomain("SUBDATASETS")); //_bandCount = _dataset.RasterCount; _bandCount = _rasterBands.Count; TryGetDatTypeOfProvider(); TryGetSizeOfProvider(); TryCreateSpatialRef(); TryCreateCoordTransform(); TrySetEnvelopeAndResolutions(); }
public unsafe void ReadMvgFile_noOffset_Bigger() { IGeoDataDriver drv = GeoDataDriver.GetDriverByName("MVG"); IRasterDataProvider prd = drv.Open(_fname, enumDataProviderAccess.ReadOnly) as IRasterDataProvider; Assert.NotNull(prd); IRasterBand band = prd.GetRasterBand(1); Assert.NotNull(band); Int16[] data = new Int16[prd.Width * 2 * prd.Height]; Console.WriteLine("prd.Width = " + prd.Width); Console.WriteLine("prd.Height = " + prd.Height); Console.WriteLine("band.Width = " + band.Width); Console.WriteLine("band.Height= " + band.Height); fixed(Int16 *ptr = data) { IntPtr buffer = new IntPtr(ptr); band.Read(0, 0, prd.Width, prd.Height, buffer, enumDataType.Int16, prd.Width * 2, prd.Height); } string dstFname = @"e:\mvg";//@"C:\工作\3.13\read"; WriteBandToFile(data, dstFname + "_bigger" + "_read" + ".dat"); prd.Dispose(); drv.Dispose(); }
public unsafe void ReadMvgFileNormal() { // _fname = @"C:\工作\3.13\SNW_DBLV_FY3A_VIRR_1000M_NULL_P001_200911131356.mvg"; IGeoDataDriver drv = GeoDataDriver.GetDriverByName("MVG"); IRasterDataProvider prd = drv.Open(_fname, enumDataProviderAccess.ReadOnly) as IRasterDataProvider; Assert.NotNull(prd); IRasterBand band = prd.GetRasterBand(1); Assert.NotNull(band); Int16[] data = new Int16[prd.Width * prd.Height]; Console.WriteLine("prd.Width = " + prd.Width); Console.WriteLine("prd.Height = " + prd.Height); Console.WriteLine("band.Width = " + band.Width); Console.WriteLine("band.Height= " + band.Height); fixed(Int16 *ptr = data) { IntPtr buffer = new IntPtr(ptr); band.Read(0, 0, prd.Width, prd.Height, buffer, enumDataType.Int16, prd.Width, prd.Height); } string dstFname = @"e:\mvg";//@"C:\工作\3.13\read"; WriteBandToFile(data, dstFname + "_normal" + "_read" + ".dat"); prd.Dispose(); drv.Dispose(); }
public void CreateEmptyLdfFile() { Assert.That(_newFileName != null); IGeoDataDriver driver = GeoDataDriver.GetDriverByName("LDF"); Assert.NotNull(driver); ILdfDriver drv = driver as ILdfDriver; Assert.NotNull(drv); int width = 2048; int height = 3390; int bandCount = 10; enumDataType dataType = enumDataType.UInt16; enumInterleave interleave = enumInterleave.BSQ; string version = "LDF"; //string proj4 = "+proj=merc +lon_0=0 +k=1 +x_0=0 +y_0=0 +a=6378137 +b=6378137"; string mapInfo = "{1,1}:{110,35}:{0.01,0.01}"; bool withHdr = true; ILdfDataProvider prd = drv.Create(_newFileName, width, height, bandCount, dataType, "INTERLEAVE=" + interleave.ToString(), "VERSION=" + version, //"SPATIALREF=" + proj4, "MAPINFO=" + mapInfo, "WITHHDR=" + withHdr.ToString()) as ILdfDataProvider; Assert.NotNull(prd); Assert.That(prd.Width == width && prd.Height == height); Assert.That(prd.BandCount == bandCount); Assert.That(prd.DataType == dataType); ILdfHeader header = prd.Header; Assert.NotNull(header); HdrFile hdr = header.ToHdrFile(); PrintHdrInfo(hdr); Ldf1Header ldfheader = header as Ldf1Header; Assert.NotNull(ldfheader); Assert.That(ldfheader._width == width && ldfheader._height == height); Assert.That(ldfheader.DataType == dataType); Assert.NotNull(prd.SpatialRef); for (int i = 0; i < bandCount; i++) { IRasterBand band = prd.GetRasterBand(i + 1); Assert.NotNull(band); Assert.That(band.Width == width && band.Height == height); Assert.That(band.DataType == dataType); } prd.Dispose(); drv.Dispose(); Assert.True(File.Exists(_newFileName)); FileInfo fInfo = new FileInfo(_newFileName); Assert.True(width * height * bandCount * 2 + header.HeaderSize == fInfo.Length); ISpatialReference spatialRef = prd.SpatialRef; Assert.NotNull(spatialRef); Console.Out.WriteLine(spatialRef.ToString()); }
public GPCRasterDataProvider(string fileName, byte[] header1024, IGeoDataDriver driver, params object[] args) : base(fileName, driver) { _fileName = fileName; ReadGPCRow(); LoadBand(); EQ2SQLUT(_gcpRows, out _cellIndexs, out _rowIndexs); InitAttributes(); }
public MODAS_GRIBDataProvider(string fileName, IGeoDataDriver driver, string deepValue, string featureName) : base(fileName, driver) { SetDefinition(); //如果指定了深度,则按照栅格数据集读取 if (!string.IsNullOrWhiteSpace(deepValue)) { TryReadToRasterDataProvider(deepValue, featureName, fileName); } }
public D1A5DataProvider(string fileName, byte[] header1024, IGeoDataDriver driver, enumDataProviderAccess access) : base(fileName, header1024, driver, access) { _dataIdentify.Satellite = GetSatellite(); //_dataIdentify.Sensor = GetSensor(); _dataIdentify.IsOrbit = true; if (_header != null) { _dataIdentify.IsAscOrbitDirection = (_header.AscDescendTag == 1); } }
private void TryGetInfosFromRasterProvider(string fname) { string extension = Path.GetExtension(fname).ToUpper(); foreach (string ext in EXTENSIONS) { if (extension == ext) { return; } } if (!File.Exists(fname)) { return; } IRasterDataProvider prd = null; IGeoDataDriver id = null; try { prd = RasterDataDriver.Open(fname) as IRasterDataProvider; if (prd != null) { _projectName = GetProjectionIdentify(prd.SpatialRef.GeographicsCoordSystem.Name); DataIdentify df = prd.DataIdentify; if (string.IsNullOrEmpty(Satellite) || Satellite.ToUpper() == "NUL") { Satellite = df.Satellite; } if (string.IsNullOrEmpty(Sensor) || Sensor.ToUpper() == "NUL") { Sensor = df.Sensor; } if (OrbitDateTime == DateTime.MinValue) { OrbitDateTime = df.OrbitDateTime; } if (string.IsNullOrWhiteSpace(Resolution) || Resolution == "NULL") { Resolution = TryGetResolution(prd.ResolutionX); } } } catch { } finally { if (prd != null) { prd.Dispose(); } } }
private IGeoDataDriver GetDriver(string driverName) { //IRasterDataProvider prd = null; //prd = driver.Open(filename, enumDataProviderAccess.ReadOnly) as IRasterDataProvider; try { IGeoDataDriver driver = GeoDataDriver.GetDriverByName(driverName); return(driver); } finally { } }
public void OpenFile() { IGeoDataDriver drv = GeoDataDriver.GetDriverByName("MVG"); IRasterDataProvider prd = drv.Open(_fileName, enumDataProviderAccess.ReadOnly) as IRasterDataProvider; Assert.IsNotNull(prd); MvgHeader header = (prd as IMvgDataProvider).Header as MvgHeader; Assert.IsNotNull(header); Console.WriteLine("header.Width=" + header.Width); Console.WriteLine("header.Height=" + header.Height); HdrFile hdr = header.ToHdrFile(); PrintHdrInfo(hdr); }
public IGeoDataDriver[] TryLoadDrivers() { string[] driverNames = new string[] { "NOAA_1BD", "LDF", "GDAL", "MVG", "MEM" }; List <IGeoDataDriver> drivers = new List <IGeoDataDriver>(); foreach (string name in driverNames) { IGeoDataDriver driver = GetDriver(name); if (driver != null) { drivers.Add(driver); } } return(drivers.ToArray()); }
/// <summary> /// /// </summary> /// <param name="fileName"></param> /// <param name="header1024"></param> /// <param name="driver"></param> /// <param name="access"></param> /// <param name="args"> /// selectedband=1,2,3 /// /// </param> public SICRasterDataProvider(string fileName, byte[] header1024, IGeoDataDriver driver, enumDataProviderAccess access, params object[] args) : base(fileName, driver) { _access = (access == enumDataProviderAccess.ReadOnly ? Access.GA_ReadOnly : Access.GA_Update); TryParseArgs(args); //通过GDAL获取GDAL识别的通道 using (Dataset _dataset = Gdal.Open(fileName, Access.GA_ReadOnly)) { GDALHelper.GetDatasetAttributes(_dataset, _attributes); } Dictionary <string, string> allGdalSubDatasets = _attributes.GetAttributeDomain("SUBDATASETS"); _allGdalSubDatasets = RecordAllSubDatasetNames(allGdalSubDatasets); //...根据参数取得当前需要的数据集 //如果是北极 string[] currentDsNames = new string[] { _allGdalSubDatasets[0], _allGdalSubDatasets[1], _allGdalSubDatasets[2] }; //如果是南极 currentDsNames = new string[] { _allGdalSubDatasets[3], _allGdalSubDatasets[4], _allGdalSubDatasets[5] }; //设置_rasterBands List <IRasterBand> rasterBands = new List <IRasterBand>(); foreach (string dsName in currentDsNames) { //这里测试时候看dsName是否是全路径,如果不是需要用全路径 string dsFullPath = dsName; Dataset ds = Gdal.Open(dsFullPath, _access); IRasterBand[] gdalDatasets = ReadBandsFromDataset(ds, this); rasterBands.AddRange(gdalDatasets); } _rasterBands = rasterBands; _bandCount = 3; _dataType = rasterBands[0].DataType; _width = rasterBands[0].Width; _height = rasterBands[0].Height; _resolutionX = 12500f; _resolutionY = 12500f; //设置坐标 _coordType = enumCoordType.PrjCoord; //如果是北极 _coordEnvelope = new Core.DF.CoordEnvelope(-3850000, 3750000, -5350000, 5850000); _spatialRef = SpatialReference.FromProj4(NORTH_PROJ4); //如果是南极 _coordEnvelope = new Core.DF.CoordEnvelope(-3950000, 3950000, -3950000, 4350000); _spatialRef = SpatialReference.FromProj4(SOUTH_PROJ4); }
public unsafe void WriteMvgFileNormal() { // _fname = @"C:\工作\3.13\SNW_DBLV_FY3A_VIRR_1000M_NULL_P001_200911131356.mvg"; IGeoDataDriver drv = GeoDataDriver.GetDriverByName("MVG"); IRasterDataProvider prd = drv.Open(_fname, enumDataProviderAccess.ReadOnly) as IRasterDataProvider; Assert.NotNull(prd); IRasterBand band = prd.GetRasterBand(1); Assert.NotNull(band); Int16[] buffer = new Int16[prd.Width * prd.Height]; Console.WriteLine("prd.Width = " + prd.Width); Console.WriteLine("prd.Height = " + prd.Height); Console.WriteLine("band.Width = " + band.Width); Console.WriteLine("band.Height= " + band.Height); fixed(Int16 *ptr = buffer) { IntPtr bufferPtr = new IntPtr(ptr); band.Read(0, 0, prd.Width, prd.Height, bufferPtr, enumDataType.Int16, prd.Width, prd.Height); } string dstFname = @"e:\mvg_writer.bin"; string mapInfo = "{1,1}:{110,35}:{0.01,0.01}"; Int16 valueCount = 2; bool withHdr = true; string values = "{ 0, 1 }"; string valueNames = "{120,99}"; IMvgDataProvider prdWriter = (drv as IRasterDataDriver).Create(dstFname, prd.Width, prd.Height, 1, enumDataType.Int16, "VALUECOUNT=" + valueCount, "VALUES=" + values, "VALUENAMES=" + valueNames, "MAPINFO=" + mapInfo, "WITHHDR=" + withHdr.ToString()) as IMvgDataProvider; IRasterBand bandWriter = prdWriter.GetRasterBand(1); fixed(Int16 *ptr = buffer) { IntPtr bufferPtr = new IntPtr(ptr); bandWriter.Write(0, 0, prd.Width, prd.Height, bufferPtr, enumDataType.Int16, prd.Width, prd.Height); } prd.Dispose(); drv.Dispose(); prdWriter.Dispose(); }
/// <summary> /// /// </summary> /// <param name="fileName">传入数据文件名</param> /// <param name="header1024"></param> /// <param name="driver"></param> /// <param name="args">扩展参数</param> /// 可扩展的参数信息,每对参数都采用key=value的形式 /// 1、子数据集用它在数据文件里的序号代替 /// 2、投影方式采用proj4字符串的形式 /// 3、数据投影信息,如数据地理范围、空间分辨率等 public Hdf4RasterDataProvider(string fileName, byte[] header1024, IGeoDataDriver driver, params object[] args) : base(fileName, header1024, driver, enumDataProviderAccess.ReadOnly) { _args = args; TryParseArgs(); TryCreateBands(fileName, header1024, _datasets); _bandCount = _rasterBands.Count; TryGetDatTypeOfProvider(); TryGetSizeOfProvider(); TryCreateSpatialRef(); TryCreateCoordTransform(); TrySetEnvelopeAndResolutions(); }
private void btPGS_Click(object sender, EventArgs e) { string fileanme; OpenFileDialog dilaog = new OpenFileDialog(); if (dilaog.ShowDialog() == DialogResult.OK) { fileanme = dilaog.FileName; } else { return; } IGeoDataDriver geoDriver = GeoDataDriver.GetDriverByName("GDAL"); if (geoDriver == null) { return; } }
public void MvgToLdfFile() { _fname = @"E:\气象局项目\MAS二期\mvg文件\FOG_DBLV_FY3A_VIRR_1000M_DXX_P001_200911131354.mvg"; IGeoDataDriver drv = GeoDataDriver.GetDriverByName("MVG"); IRasterDataProvider prd = drv.Open(_fname, enumDataProviderAccess.ReadOnly) as IRasterDataProvider; Assert.NotNull(prd); IMvgDataProvider mvgPrd = prd as IMvgDataProvider; MvgHeader mvgHeader = mvgPrd.Header; Assert.NotNull(mvgHeader); Console.WriteLine("mvgHeader.HeaderSize = " + mvgHeader.HeaderSize); Console.WriteLine("mvgHeader.Width = " + mvgHeader.Width); Console.WriteLine("mvgHeader.Height = " + mvgHeader.Height); mvgPrd.ToLdfFile(); mvgPrd.Dispose(); prd.Dispose(); drv.Dispose(); }
public unsafe void ReadMvgFile_smaller() { // _fname = @"C:\工作\3.13\SNW_DBLV_FY3A_VIRR_1000M_NULL_P001_200911131356.mvg"; IGeoDataDriver drv = GeoDataDriver.GetDriverByName("MVG"); IRasterDataProvider prd = drv.Open(_fname, enumDataProviderAccess.ReadOnly) as IRasterDataProvider; Assert.NotNull(prd); Int16[] data = new Int16[prd.Width / 2 * prd.Height]; Console.WriteLine("prd.Width = " + prd.Width); Console.WriteLine("prd.Height = " + prd.Height); int[] bandMap = { 1 }; fixed(Int16 *ptr = data) { IntPtr buffer = new IntPtr(ptr); prd.Read(0, 0, prd.Width, prd.Height, buffer, enumDataType.Int16, prd.Width / 2, prd.Height, 1, bandMap, enumInterleave.BSQ); } string dstFname = @"e:\mvg";//@"C:\工作\3.13\read"; WriteBandToFile(data, dstFname + "_smaller" + "_prdRead" + ".dat"); }
public FY3HDFL2ProductProvider(string fileName, byte[] header1024, IGeoDataDriver driver, params object[] args) : base(fileName, driver) { L2ProductDefind[] l2Pros = L2ProductDefindParser.GetL2ProductDefs(Path.GetFileName(_fileName)); if (l2Pros == null) { return; } _fileName = fileName; _args = args; L2ProductDefind verifyL2Pro = l2Pros.Length == 1 ? l2Pros[0] : VerifyL2ProDef(l2Pros); if (verifyL2Pro == null) { return; } using (Dataset dataset = Gdal.Open(fileName, Access.GA_ReadOnly)) { GDALHelper.GetDatasetAttributes(dataset, _attributes); } Dictionary <string, string> allGdalSubDatasets = this.Attributes.GetAttributeDomain("SUBDATASETS"); _allGdalSubDatasets = RecordAllSubDatasetNames(allGdalSubDatasets); _coordEnvelope = TrySetGeoInfo(verifyL2Pro); _selectedsets = TryGetSelectedSets(verifyL2Pro); TryCreateBandProvider(); _bandCount = _rasterBands.Count; _dataType = _rasterBands[0].DataType; _width = _rasterBands[0].Width; _height = _rasterBands[0].Height; _coordType = _spatialRef.ProjectionCoordSystem != null ? enumCoordType.PrjCoord : enumCoordType.GeoCoord; _resolutionX = (float)(_coordEnvelope.Width / (_width)); _resolutionY = (float)(_coordEnvelope.Height / (_height)); if (_dataIdentify != null && _dataIdentify.OrbitDateTime == DateTime.MinValue) { _dataIdentify.OrbitDateTime = IceConDataProvider.TryGetFileDate(Path.GetFileName(fileName)); } }
public FYSnowPrdDataProvider(string fileName, byte[] header1024, IGeoDataDriver driver, params object[] args) : base(fileName, driver) { _args = args; TryParseArgs(); using (Dataset dataset = Gdal.Open(fileName, Access.GA_ReadOnly)) { GDALHelper.GetDatasetAttributes(dataset, _attributes); } TryCreateBandProvider(); _bandCount = _rasterBands.Count; TryGetDatTypeOfProvider(); TryGetSizeOfProvider(); //TryCreateSpatialRef(); _coordType = enumCoordType.PrjCoord; _resolutionX = (float)(_coordEnvelope.Width / (_width)); _resolutionY = (float)(_coordEnvelope.Height / (_height)); if (_dataIdentify != null) { _dataIdentify.Sensor = "MWRI"; _dataIdentify.OrbitDateTime = IceConDataProvider.TryGetFileDate(Path.GetFileName(fileName)); } }
public GDALRasterDataProvider(string fileName, byte[] header1024, IGeoDataDriver driver, enumDataProviderAccess access) : base(fileName, driver) { _driver = driver; CallGDALBefore(); Access gdalAccess = access == enumDataProviderAccess.ReadOnly ? Access.GA_ReadOnly : Access.GA_Update; _dataset = Gdal.Open(fileName, gdalAccess); GDALHelper.GetDatasetAttributes(_dataset, _attributes); if (header1024 == null) { header1024 = GetHeader1024Bytes(fileName); } TryGetBandProviderAndGetDefaultBands(gdalAccess, header1024, _attributes.GetAttributeDomain(GDAL_SUBDATASETS_NAME)); _width = 0; //GDAL: _dataset.RasterXSize 默认为512 _height = 0; //GDAL: _dataset.RasterYSize 默认为512 _filelist = _dataset.GetFileList(); _fileName = _fileName; //读取波段列表 _bandCount = _dataset.RasterCount; for (int i = 1; i <= _bandCount; i++) { _rasterBands.Add(new GDALRasterBand(this, _dataset.GetRasterBand(i), new GDALDataset(_dataset))); } _bandCount = _rasterBands.Count; for (int i = 1; i <= _bandCount; i++) { _rasterBands[i - 1].BandNo = i; } TryGetDatTypeOfProvider(); TryGetSizeOfProvider(); TryCreateSpatialRef(); TryCreateCoordTransform(); TrySetEnvelopeAndResolutions(); // //TryGetDataIdentity(); }
public CloudsatDataProvider(string fileName, byte[] header1024, IGeoDataDriver driver, params object[] args) : base(fileName, driver) { Stopwatch sw = new Stopwatch(); sw.Start(); _filename = fileName; TryParseFileName(fileName, out _fileNameDateTime, out _fileNameProductName); _fileMateData = _attributes.CreateAttributeDomain("FileAttributes"); _fileMateData.Add("DateTime", _fileNameDateTime.ToString("yyyyMMddHHmmss")); _fileMateData.Add("ProductName", _fileNameProductName); BuilderRastersAndTables(); _dataType = enumDataType.Int16; _bandCount = _rasterBands.Count; _width = _rasterBands[0].Width; _height = _rasterBands[0].Height; _coordEnvelope = new CoordEnvelope(new CoordPoint(0, 0), _width, _height); _coordTransform = CoordTransoformFactory.GetCoordTransform(_spatialRef, null, _width, _height); TrySetEnvelopeAndResolutions(); sw.Stop(); long em = sw.ElapsedMilliseconds; Console.WriteLine(em + "毫秒"); }