public LogicalRasterDataProvider(string fileName, string[] fnames, object tag) { if (fnames == null || fnames.Length == 0) { throw new ArgumentNullException("fnames"); } _tag = tag; _fileNames = new string[fnames.Length + 1]; _fileNames[0] = fileName; int i = 1; bool isFirst = true; foreach (string fname in fnames) { _fileNames[i++] = fname; IRasterDataProvider prd = GeoDataDriver.Open(fname) as IRasterDataProvider; if (prd == null) { continue; } if (isFirst) { _dataType = prd.DataType; _width = prd.Width; _height = prd.Height; _coordEnvelope = prd.CoordEnvelope; _coordType = prd.CoordType; _spatialRef = prd.SpatialRef; _coordTransform = prd.CoordTransform; isFirst = false; } else { if (_dataType != prd.DataType || _coordType != prd.CoordType || !CoordEnvelopeEquals(_coordEnvelope, prd.CoordEnvelope) || _coordType != prd.CoordType || _width != prd.Width || _height != prd.Height || !_spatialRef.IsSame(prd.SpatialRef) ) { continue; } } for (int b = 0; b < prd.BandCount; b++) { IRasterBand band = prd.GetRasterBand(b + 1); band.Description = prd.fileName; _rasterBands.Add(band); band.BandNo = _rasterBands.Count; } _needDisposeObjects.Add(prd); } }
public IRasterDataProvider ConvertDataType <TSrc, TDst>(string srcFileName, enumDataType dstDataType, string dstFileName, Func <TSrc, TDst> converter) { IRasterDataProvider srcDataProvider = GeoDataDriver.Open(srcFileName) as IRasterDataProvider; if (srcDataProvider == null) { new Exception("创建源数据提供者时发生错误!"); } try { return(ConvertDataType <TSrc, TDst>(srcDataProvider, dstDataType, dstFileName, converter)); } finally { srcDataProvider.Dispose(); } }
private IRasterDataProvider CreateDstDataProvider(enumDataType dstDataType, IRasterDataProvider srcDataProvider, string dstFileName) { IRasterDataDriver driver = GeoDataDriver.GetDriverByName("LDF") as IRasterDataDriver; if (driver == null) { throw new Exception("获取LDF栅格数据驱动时发生未知错误!"); } if (!dstFileName.ToLower().EndsWith(".ldf")) { dstFileName += ".ldf"; } return(driver.Create(dstFileName, srcDataProvider.Width, srcDataProvider.Height, srcDataProvider.BandCount, dstDataType, "SPATIALREF=" + GetSpatialRefString(srcDataProvider), GetMapInfoString(srcDataProvider.CoordEnvelope, srcDataProvider.Width, srcDataProvider.Height))); }