public OSMXml parseOSM(string filename) { OSMXml osmxml = new OSMXml(); osmxml.nodeList = new List <Node>(); osmxml.wayList = new List <Way>(); osmxml.relationList = new List <Relation>(); osmxml.buildingRelations = new List <BuildingRelation>(); osmxml.defaultobject3DList = new List <Node>(); nodeList = new List <Node>(); wayList = new List <Way>(); StreamReader osmfile = new StreamReader(filename); if (osmfile == null) { Debug.Log("<color=red>Fatal error:</color>" + filename + " not set"); return(new OSMXml()); } XmlDocument xmlfile = new XmlDocument(); xmlfile.Load(osmfile); foreach (XmlNode node in xmlfile.DocumentElement.ChildNodes) { if (node.Name == "node") { Node nd = readNode(node); osmxml.nodeList.Add(nd); nodeList.Add(nd); if (nd.type != ItemEnumerator.nodeType.None) { osmxml.defaultobject3DList.Add(nd); } } else if (node.Name == "way") { Way nd = readWay(node); osmxml.wayList.Add(nd); wayList.Add(nd); } else if (node.Name == "relation") { Relation r = readRelation(node); osmxml.relationList.Add(r); if (isBuildingRelation(r)) { osmxml.buildingRelations.Add(generateBuildingRelation(r)); } } else if (node.Name == "bounds") { osmxml.bbox = readBounds(node); } } return(osmxml); }
public OSMXml parseOSM(string filename) { OSMXml osmxml = new OSMXml(); osmxml.nodeList = new List<Node>(); osmxml.wayList = new List<Way>(); osmxml.relationList = new List<Relation>(); osmxml.buildingRelations = new List<BuildingRelation>(); osmxml.defaultobject3DList = new List<Node>(); nodeList = new List<Node>(); wayList = new List<Way>(); StreamReader osmfile = new StreamReader(filename); if (osmfile == null) { Debug.Log("<color=red>Fatal error:</color>" + filename + " not set"); return new OSMXml(); } XmlDocument xmlfile = new XmlDocument(); xmlfile.Load(osmfile); foreach (XmlNode node in xmlfile.DocumentElement.ChildNodes) { if (node.Name == "node") { Node nd = readNode(node); osmxml.nodeList.Add(nd); nodeList.Add(nd); if (nd.type != ItemEnumerator.nodeType.None) osmxml.defaultobject3DList.Add(nd); } else if (node.Name == "way") { Way nd = readWay(node); osmxml.wayList.Add(nd); wayList.Add(nd); } else if (node.Name == "relation") { Relation r = readRelation(node); osmxml.relationList.Add(r); if (isBuildingRelation(r)) osmxml.buildingRelations.Add(generateBuildingRelation(r)); } else if (node.Name == "bounds") osmxml.bbox = readBounds(node); } return osmxml; }