private static void LoadClimateTable(L3dtFile retValue, XmlDocument projectFile) { XmlNodeList nodes = projectFile.SelectNodes("/varlist[@name='ProjectData']/varlist[@name='Climates']/varlist"); if (nodes != null) { byte climateId = 0; foreach (XmlNode xmlNode in nodes) { Stream climateFileStream = (Stream)File.Open(xmlNode.InnerText, FileMode.Open); XmlDocument xmlDocument = new XmlDocument(); xmlDocument.Load(climateFileStream); climateFileStream.Close(); byte landTypeId = 1; foreach (XmlElement xmlElement in xmlDocument.SelectNodes("/varlist/varlist[@name='LandTypeList']/varlist")) { string key = climateId + "-" + landTypeId; if (retValue.ClimateTable[key] == null) { retValue.ClimateTable.Add(key, xmlElement.Attributes["name"].Value); } landTypeId++; } climateId++; } } }
private void LoadAmfAttributeMap(string fileName, L3dtFile retValue, XmlDocument projectFile) { XmlNode node = projectFile.SelectSingleNode("/varlist[@name='ProjectData']/varlist[@name='Maps']/varlist[@name='AM']/string[@name='Filename']"); if (node != null) { string amfFileName = fileName.Substring(0, fileName.LastIndexOf('\\') + 1) + node.InnerText; if (amfFileName.EndsWith(".amf") || amfFileName.EndsWith(".amf.gz")) { retValue.AmfFile = amfFileName.EndsWith(".amf.gz") ? amfManager.loadFile(amfFileName, FileFormat.COMPRESSED) : amfManager.loadFile(amfFileName, FileFormat.UNCOMPRESSED); } } }
public L3dtFile loadL3dtFile(string fileName) { L3dtFile retValue = new L3dtFile(); using (StreamReader stream = new StreamReader(fileName)) { XmlDocument projectFile = new XmlDocument(); projectFile.Load(stream); LoadDmfMap(fileName, retValue, projectFile); LoadHeightMap(fileName, retValue, projectFile); LoadWmfWaterMap(fileName, retValue, projectFile); LoadAmfAttributeMap(fileName, retValue, projectFile); LoadClimateTable(retValue, projectFile); } return retValue; }
private void LoadHeightMap(string fileName, L3dtFile retValue, XmlDocument projectFile) { XmlNode node = projectFile.SelectSingleNode("/varlist[@name='ProjectData']/varlist[@name='Maps']/varlist[@name='HF']/string[@name='Filename']"); if (node != null) { string heightMapFileName = fileName.Substring(0, fileName.LastIndexOf('\\') + 1) + node.InnerText; if (heightMapFileName.EndsWith("hfz") || heightMapFileName.EndsWith("hf2.gz") || heightMapFileName.EndsWith("hf2")) { retValue.heightMapType = L3dtFile.HeightMapType.HFZ; retValue.HfzFile = hfzManager.loadFile(heightMapFileName, heightMapFileName.EndsWith("hf2.gz") || heightMapFileName.EndsWith("hfz") ? FileFormat.COMPRESSED : FileFormat.UNCOMPRESSED); } else if (heightMapFileName.EndsWith("hff")) { retValue.heightMapType = L3dtFile.HeightMapType.HFF; retValue.HffFile = hffManager.loadFile(heightMapFileName); } } }
private void LoadDmfMap(string fileName, L3dtFile retValue, XmlDocument projectFile) { XmlNode node = projectFile.SelectSingleNode("/varlist[@name='ProjectData']/varlist[@name='Maps']/varlist[@name='DM']/string[@name='Filename']"); if (node != null) { string dmfFileName = fileName.Substring(0, fileName.LastIndexOf('\\') + 1) + node.InnerText; retValue.DmfFile = dmfManager.loadFile(dmfFileName); } }