public static OsmStreetSystem Build(OsmLoader data)
        {
            OsmStreetSystem newSystem = new OsmStreetSystem();

            var ways = data.Ways.Values.Where(w => Defaults.HighwayWhitelist.Contains(w.GetTag("highway", "-")));

            foreach (var way in ways)
            {
                bool oneWay = (way.GetTag("oneway", "no") == "yes") ||
                              (way.GetTag("junction", "-") == "roundabout");

                Waypoint lastPoint = newSystem.GetWaypointForNode(way.Nodes[0]);

                var conInfo = MakeConnectionInfo(way);

                for (int i = 1; i < way.Nodes.Count; i++)
                {
                    var current = newSystem.GetWaypointForNode(way.Nodes[i]);

                    lastPoint.ConnectTo(current, conInfo);

                    if (!oneWay)
                    {
                        current.ConnectTo(lastPoint, conInfo);
                    }

                    lastPoint = current;
                }
            }

            return(newSystem);
        }
        private static void ParseWay(XmlReader rd, Dictionary <long, Waypoint> wps, OsmStreetSystem strt)
        {
            if (rd.IsEmptyElement)
            {
                return;
            }

            var wpIds = new ArrayList(2000);
            Dictionary <string, string> tags = new Dictionary <string, string>();

            while (rd.Read() && rd.NodeType != XmlNodeType.EndElement)
            {
                if (rd.NodeType == XmlNodeType.Element)
                {
                    switch (rd.Name)
                    {
                    case "nd":
                        wpIds.Add(long.Parse(rd.GetAttribute("ref")));
                        break;

                    case "tag":
                        tags.Add(
                            rd.GetAttribute("k"),
                            rd.GetAttribute("v")
                            );
                        break;
                    }
                }
            }

            if (!Defaults.HighwayWhitelist.Contains(tags.Get("highway", "-")))
            {
                return;
            }

            bool oneWay = (tags.Get("oneway", "no") == "yes") ||
                          (tags.Get("junction", "-") == "roundabout");

            var info = MakeConnectionInfo(tags);

            Waypoint last = wps[(long)wpIds[0]];

            if (!strt.Waypoints.ContainsKey(last.Id))
            {
                strt.Waypoints.Add(last.Id, last);
            }

            for (int i = 1; i < wpIds.Count; i++)
            {
                Waypoint current = wps[(long)wpIds[i]];
                if (!strt.Waypoints.ContainsKey(current.Id))
                {
                    strt.Waypoints.Add(current.Id, current);
                }

                last.ConnectTo(current, info);

                if (!oneWay)
                {
                    current.ConnectTo(last, info);
                }

                last = current;
            }
        }