示例#1
0
 private void SetAttribute(IGRIB2GridDefinitionSection gds)
 {
     if (gds != null)
     {
         _coordEnvelope = new Core.DF.CoordEnvelope(gds.LonFirstPoint, gds.LonEndPoint, gds.LatEndPoint, gds.LatFirstPoint);
         _width         = gds.Nx;
         _height        = gds.Ny;
         _definition    = new GRIB_Definition((float)gds.LonFirstPoint, (float)gds.LatFirstPoint, (float)gds.LonEndPoint, (float)gds.LatEndPoint,
                                              (float)gds.Dx, (float)gds.Dy, gds.Nx, gds.Ny, "30", -9999);
         int gridtype = gds.GridTemplateNo;
         using (SpatialReferenceBuilder builder = new SpatialReferenceBuilder())
         {
             _spatialRef = builder.GetSpatialRef(gridtype, gds.LatFirstPoint, gds.LatEndPoint, 0);
         }
         _resolutionX   = _definition.LonResolution;
         _resolutionY   = _definition.LatResolution;
         _coordEnvelope = _definition.GetCoordEnvelope();
     }
     if (_records == null)
     {
         _bandCount = 0;
     }
     else
     {
         _bandCount = _records.Count;
     }
     _dataType = enumDataType.Float;
 }
        private string AdjustDBLVFile(Core.DF.CoordEnvelope coordEnvelope, IRasterDataProvider rasterDataPrd)
        {
            List <string> fileList = new List <string>();
            bool          isDat    = false;
            string        dir      = Path.GetDirectoryName(rasterDataPrd.fileName);

            if (Path.GetExtension(rasterDataPrd.fileName).ToUpper() == ".DAT")
            {
                fileList.AddRange(Directory.GetFiles(dir, "*.ldf"));
                isDat = true;
            }
            else
            {
                fileList.AddRange(Directory.GetFiles(dir, "*.dat"));
                fileList.AddRange(Directory.GetFiles(dir, "*.mvg"));
            }
            if (fileList.Count < 1)
            {
                return(null);
            }
            string         dblvFileName = null;
            RasterIdentify ri           = new RasterIdentify(rasterDataPrd.fileName);

            foreach (string item in fileList)
            {
                RasterIdentify riItem = new RasterIdentify(item);
                if (riItem.OrbitDateTime == ri.OrbitDateTime)
                {
                    if (!isDat)
                    {
                        if (riItem.SubProductIdentify == "DBLV")
                        {
                            dblvFileName = item;
                            break;
                        }
                    }
                    else
                    {
                        dblvFileName = item;
                        break;
                    }
                }
            }
            if (dblvFileName == null)
            {
                return(null);
            }
            //找到对应判识结果文件,进行校正
            GeoAdjustHelper     adjustTool  = new GeoAdjustHelper();
            IRasterDataProvider dblvDataPrd = GeoDataDriver.Open(dblvFileName) as IRasterDataProvider;

            return(adjustTool.SaveGeoAdjustByChangeCoordEnvelope(coordEnvelope, dblvDataPrd));
        }
示例#3
0
 private void FillProviderAttributes()
 {
     _bandCount = 1;
     _dataType  = enumDataType.Int16;
     if (_header != null)
     {
         _width         = _header.Width;
         _height        = _header.Height;
         _resolutionX   = _header.LongitudeResolution;
         _resolutionY   = _header.LatitudeResolution;
         _spatialRef    = _header.SpatialRef;
         _coordEnvelope = new Core.DF.CoordEnvelope(_header.MinLon, _header.MaxLon, _header.MinLat, _header.MaxLat);
         TryCreateCoordTransform();
     }
 }
        /// <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);
        }