public override void Reset() { if (_datasetNames != null) { _datasetNames.Clear(); _datasetNames = null; } _provider = null; _matchedBandProviderDef = null; }
public BandProviderDef[] GetBandProviderDefs() { XDocument doc = XDocument.Load(_cnfgFile); XElement root = doc.Root; var elePrds = root.Elements(XName.Get("BandProvider")); if (elePrds == null || elePrds.Count() == 0) { return(null); } List <BandProviderDef> prds = new List <BandProviderDef>(); foreach (XElement ele in elePrds) { BandProviderDef prd = BandProviderDef.FromXElement(ele); if (prd != null) { prds.Add(prd); } } return(prds.Count > 0 ? prds.ToArray() : null); }
private void TryGetBandProviderDefinition(string fname, Dictionary <string, string> subdatasets) { List <string> datasetNames = null; if (subdatasets != null) { datasetNames = GetDatasetNames(subdatasets); } BandProviderDef[] bandProviderDefs = null; //Console.WriteLine(this.GetType().Assembly.Location); string configfile = Path.Combine(Path.GetDirectoryName(this.GetType().Assembly.Location), "GeoDo.RSS.DF.GDAL.H4BandPrd.xml"); using (H4BandProviderXmlParser xml = new H4BandProviderXmlParser(configfile)) { bandProviderDefs = xml.GetBandProviderDefs(); } if (bandProviderDefs == null) { return; } string dayornight = ""; using (Hdf4Operator hdf = new Hdf4Operator(fname)) { foreach (BandProviderDef prddef in bandProviderDefs) { bool isMatched = true; if (datasetNames != null) { foreach (DefaultBandDatasetDef bandDef in prddef.DefaultBandDatasetDefs) { if (!datasetNames.Contains(bandDef.Name)) { isMatched = false; break; } } if (!isMatched) { continue; } } foreach (IdentifyAttDef id in prddef.IdentifyAttDefs) { string attvalue = hdf.GetAttributeValue(id.Name); if (attvalue != id.Value) { isMatched = false; break; } } //增加对网站下载MODIS数据的支持,数据未在属性中定义卫星、传感器信息 if (!isMatched) { DataIdentify di = DataIdentifyMatcher.Match(fname); if (di != null && !string.IsNullOrEmpty(di.Satellite)) { foreach (IdentifyAttDef id in prddef.IdentifyAttDefs) { if (di.Satellite.ToUpper() == id.Value.ToUpper()) { isMatched = true; break; } } } } if (isMatched) { _matchedBandProviderDef = prddef; break; } } dayornight = TryGetDayOrnight(hdf); } if (_matchedBandProviderDef != null) { _dataIdentify = new DataIdentify(_matchedBandProviderDef.Satellite, _matchedBandProviderDef.Sensor); _dataIdentify.IsOrbit = true; TrySetIdentifyByName(fname); TryGetOrbitDirection(dayornight, _matchedBandProviderDef.Satellite); } }