Ejemplo n.º 1
0
        private static L2ProductDefind CrateL2ProductDef(XElement element)
        {
            L2ProductDefind result = new L2ProductDefind();

            result.Name     = element.Attribute("name").Value;
            result.Desc     = element.Attribute("desc").Value;
            result.Identify = element.Attribute("identify").Value;
            result.Product  = element.Attribute("product").Value;
            XElement geoInfoElement = element.Element("GeoInfo");

            if (geoInfoElement != null)
            {
                GeoInfos geoInfo = new GeoInfos(geoInfoElement.Attribute("poj4").Value);
                GetGeoAtrrs(geoInfo, geoInfoElement);
                GetGeoDef(geoInfo, geoInfoElement);
                result.GeoInfo = geoInfo;
            }
            XElement proInfoElement = element.Element("ProInfo");

            if (proInfoElement != null)
            {
                ProInfos proInfo = new ProInfos();
                GetProDataSets(proInfo, proInfoElement);
                result.ProInfo = proInfo;
            }
            return(result);
        }
Ejemplo n.º 2
0
 private CoordEnvelope TrySetGeoInfo(L2ProductDefind l2Pro)
 {
     _spatialRef = SpatialReference.FromProj4(l2Pro.GeoInfo.Proj4Str);
     if (l2Pro.GeoInfo.GeoAtrrs == null && l2Pro.GeoInfo.GeoDef != null)
     {
         return(new CoordEnvelope(l2Pro.GeoInfo.GeoDef.LeftTopLon, l2Pro.GeoInfo.GeoDef.RightBottomLon, l2Pro.GeoInfo.GeoDef.RightBottomLat, l2Pro.GeoInfo.GeoDef.LeftTopLat));
     }
     else if (l2Pro.GeoInfo.GeoAtrrs != null)
     {
         return(GetCoordEnvelope(l2Pro.GeoInfo.GeoAtrrs));
     }
     return(null);
 }
Ejemplo n.º 3
0
        private L2ProductDefind GetL2ProDefFromDic()
        {
            L2ProductDefind result   = null;
            int             maxCount = 0;

            foreach (L2ProductDefind item in _selectedSetsDic.Keys)
            {
                if (_selectedSetsDic[item].Count > maxCount)
                {
                    result   = item;
                    maxCount = _selectedSetsDic[item].Count;
                }
            }
            return(maxCount == 0 ? null : result);
        }
Ejemplo n.º 4
0
 private string[] GetTempSetsFromArgs(L2ProductDefind l2Pro)
 {
     if (_args == null || _args.Length == 0)
     {
         if (l2Pro.ProInfo != null)
         {
             if (!string.IsNullOrEmpty(l2Pro.ProInfo.ProDatasets))
             {
                 return(l2Pro.ProInfo.ProDatasets.Split(new char[] { ',', ',' }, StringSplitOptions.RemoveEmptyEntries));
             }
         }
     }
     else
     {
         if (_selectedSetsDic != null && _selectedSetsDic.Count != 0)
         {
             return(_selectedSetsDic[l2Pro].ToArray());
         }
         string argStr;
         for (int i = 0; i < _args.Length; i++)
         {
             if (_args[i] == null)
             {
                 continue;
             }
             argStr = _args[i].ToString();
             if (!string.IsNullOrEmpty(argStr) && argStr.Contains(_prodatasetArg))
             {
                 return(argStr.Replace(_prodatasetArg, "").Replace(" ", "_").Split(new char[] { ',', ',' }, StringSplitOptions.RemoveEmptyEntries));
             }
             if (!string.IsNullOrEmpty(argStr) && argStr.Contains(_prodscArg) && l2Pro.ProInfo != null)
             {
                 if (!string.IsNullOrEmpty(l2Pro.ProInfo.ProDatasets))
                 {
                     return(l2Pro.ProInfo.ProDatasets.Split(new char[] { ',', ',' }, StringSplitOptions.RemoveEmptyEntries));
                 }
             }
         }
     }
     return(null);
 }
Ejemplo n.º 5
0
        private string[] TryGetSelectedSets(L2ProductDefind l2Pro)
        {
            List <string> allsets = new List <string>();

            string[] allsetTemp = GetTempSetsFromArgs(l2Pro);
            if (allsetTemp != null)
            {
                for (int i = 0; i < allsetTemp.Length; i++)
                {
                    for (int j = 0; j < _allGdalSubDatasets.Length; j++)
                    {
                        if (GetDatasetShortName(_allGdalSubDatasets[j]).ToUpper().Trim() == allsetTemp[i].ToUpper().Trim())
                        {
                            allsets.Add(allsetTemp[i]);
                            break;
                        }
                    }
                }
            }
            return(allsets.Count == 0 ? TryGetSelectedSets() : allsets.ToArray());
        }
Ejemplo n.º 6
0
        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));
            }
        }