Esempio n. 1
0
        private void InitLocalFields()
        {
            double val    = 0;
            int    hasVal = 0;

            _dataType = GDALHelper.GDALDataType2DataType(_band.DataType);
            _band.GetScale(out val, out hasVal);
            if (hasVal != 0)
            {
                _dataScale = val;
            }
            _band.GetOffset(out val, out hasVal);
            if (hasVal != 0)
            {
                _dataOffset = val;
            }
            GDALHelper.GetBandAttributes(_band, _attributes);
            _description = _band.GetDescription();
            //_measureBits = ?
            _width  = _band.XSize;
            _height = _band.YSize;
            _band.GetNoDataValue(out val, out hasVal);
            if (hasVal != 0)
            {
                _noDataValue = val;
            }
            _spatialRef     = _rasterDataProvider.SpatialRef;
            _coordTransofrm = _rasterDataProvider.CoordTransform;
        }
Esempio n. 2
0
        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();
        }
Esempio n. 3
0
 protected override void DirectWrite(int xOffset, int yOffset, int xSize, int ySize, IntPtr buffer, enumDataType dataType, int xBufferSize, int yBufferSize)
 {
     _band.WriteRaster(xOffset, yOffset, xSize, ySize, buffer, xBufferSize, yBufferSize, GDALHelper.DataType2GDALDataType(dataType), 0, 0);
 }