public LTSAnalyzer(Options options) { _nodes = new Dictionary <string, Node>(); _ways = new Dictionary <string, Way>(); _relations = new Dictionary <string, Relation>(); _options = options; _stressModel = new StressModel(); _usedNodes = new HashSet <string>(); }
/// <summary> /// Processes a way element at the current read position in the reader. /// Exits with the reader positioned at the next sibling element. /// </summary> /// <param name="i_reader">An XmlReader object with the read position on a way element.</param> private void ProcessWays1(XmlReader reader) { if (reader.IsStartElement("way")) { Way way = new Way(); string id = reader.GetAttribute("id"); if (reader.IsEmptyElement) { // Next node. reader.Read(); } else { while (reader.Read()) { if (reader.Name == "tag") { way.AddTag(reader); } else if (reader.Name == "nd") { string nodeRef = reader.GetAttribute("ref"); way.Nodes.Add(nodeRef); } else { if (reader.NodeType == XmlNodeType.EndElement) { reader.Read(); break; } else { throw new Exception("Unexpected element: " + reader.ReadOuterXml()); } } } } // This is a preliminary test to make sure we only add ways that are potentially valid // routes. This could be expanded to further filter the ways but this will typically // be done in the analysis phase. if (_options.IncludeBannedHighways || StressModel.BikingPermitted(id, way)) { if (way.HasTag("highway")) { _ways.Add(id, way); foreach (string nodeRef in way.Nodes) { if (!_usedNodes.Contains(nodeRef)) { _usedNodes.Add(nodeRef); } } } } } else { throw new Exception("Unexpected node: " + reader.Name); } }