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 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 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 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(); }
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(); }