Esempio n. 1
0
        /// <summary>
        /// Since the way was extended - adjust that intersection to show that the tip of the 'extendedWay' is actually the
        /// new concatenated way.
        /// </summary>
        /// <param name="newIntersectNode"></param>
        /// <param name="extendingWay"></param>
        /// <param name="way"></param>
        private void ChangeIntersectingWay(OSMNode newIntersectNode, OSMWay extendingWay, OSMWay way)
        {
            var wayList = endNodeWayList[newIntersectNode.ID];

            wayList.Remove(extendingWay);
            wayList.Add(way);
        }
Esempio n. 2
0
        //   <node id="29568287" version="1" timestamp="2007-05-24T23:55:56Z" uid="7591" user="******" changeset="65544" lat="34.7661891" lon="-82.3672466">
        //      <tag k="created_by" v="YahooApplet 1.1"/>
        //   </node>
        private void HandleNodeRead(XmlReader reader)
        {
            var osmNode = new OSMNode();

            osmNode.ID  = Convert.ToInt64(reader.GetAttribute("id"));
            osmNode.Lat = Convert.ToDouble(reader.GetAttribute("lat"));
            osmNode.Lon = Convert.ToDouble(reader.GetAttribute("lon"));

            osmNodes.Add(osmNode.ID, osmNode);

            var     doc  = new System.Xml.XmlDocument();
            XmlNode node = doc.ReadNode(reader);

            foreach (XmlAttribute attr in node.Attributes)
            {
                osmNode.InnerAttributes.Add(attr.Name, attr.Value);
            }

            if (node.HasChildNodes)
            {
                var tags = node.SelectNodes("tag");
                foreach (XmlNode tag in tags)
                {
                    var key = tag.Attributes["k"].Value;
                    var val = tag.Attributes["v"].Value;
                    osmNode.Tags.Add(key, val);
                }
            }
        }
Esempio n. 3
0
 public static bool BBoxContains(BBox bbox, OSMNode osmNode)
 {
     if ((osmNode.Lat >= bbox.MinLat) &&
         (osmNode.Lon >= bbox.MinLon) &&
         (osmNode.Lat < bbox.MaxLat) &&
         (osmNode.Lon < bbox.MaxLon))
     {
         return(true);
     }
     return(false);
 }
Esempio n. 4
0
        /// <summary>
        /// set or expand box if node not already contained
        /// </summary>
        /// <param name="bbox1"></param>
        /// <param name="node"></param>
        /// <returns></returns>
        public static BBox BboxUnion(BBox bbox1, OSMNode node)
        {
            var bbox = new BBox();

            bbox.MinLat = bbox1.MinLat < node.Lat ? bbox1.MinLat : node.Lat;
            bbox.MinLon = bbox1.MinLon < node.Lon ? bbox1.MinLon : node.Lon;

            bbox.MaxLat = bbox1.MaxLat > node.Lat ? bbox1.MaxLat : node.Lat;
            bbox.MaxLon = bbox1.MaxLon > node.Lon ? bbox1.MaxLon : node.Lon;

            return(bbox);
        }
Esempio n. 5
0
        private void AddEndNode(OSMNode osmNode, OSMWay way)
        {
            var id = osmNode.ID;

            if (!endNodeWayList.ContainsKey(id))
            {
                var newWayList = new List <OSMWay>();
                endNodeWayList.Add(id, newWayList);
            }

            var wayList = endNodeWayList[id];

            if (!wayList.Contains(way))
            {
                wayList.Add(way);
            }
        }
Esempio n. 6
0
        /// <summary>
        /// Extend way by concatenating 'extendingWay' onto 'way' at the intersection node
        /// </summary>
        /// <param name="way"></param>
        /// <param name="intersectionNode"></param>
        /// <param name="extendingWay"></param>
        private void ExtendWay(OSMWay way, OSMNode intersectionNode, OSMWay extendingWay)
        {
            int     direction        = 1;
            int     start            = 0;
            OSMNode newIntersectNode = null;

            if (extendingWay.NodeList[0] == intersectionNode)
            {
                // Sequence Logic already set above

                newIntersectNode = extendingWay.NodeList[extendingWay.NodeList.Count - 1]; // Last node
            }
            else if (extendingWay.NodeList[extendingWay.NodeList.Count - 1] == intersectionNode)
            {
                // Attach from end of this way
                direction        = -1;
                start            = extendingWay.NodeList.Count - 1;
                newIntersectNode = extendingWay.NodeList[0]; // First node
            }


            if (way.NodeList[0] == intersectionNode)
            {
                // Attach before first node
                PrependTo(way, extendingWay, direction, start);
            }
            else if (way.NodeList[way.NodeList.Count - 1] == intersectionNode)
            {
                // Attach after last node
                AppendTo(way, extendingWay, direction, start);
            }
            else
            {
                // 3-way intersection at same node?
                Console.WriteLine("Logic error during glom.");
            }

            if (newIntersectNode.ID != intersectionNode.ID)
            {
                ChangeIntersectingWay(newIntersectNode, extendingWay, way);
            }

            DropDuplicateNodes(way);
        }