Пример #1
0
        public bool EmptyRoutes()
        {
            if (!WayRoute.Empty())
            {
                return(false);
            }

            foreach (var route in RelRoutes)
            {
                if (!route.Empty())
                {
                    return(false);
                }
            }

            return(true);
        }
Пример #2
0
        private void ParseWay(Way element)
        {
            if (!firstWay)
            {
                nids     = milestones.Select(x => x.Id).ToList();
                firstWay = true;
            }

            string taghighway;

            if (!element.Tags.TryGetValue("highway", out taghighway))
            {
                return;
            }

            Highway tagHighwayEnum;

            if (!Highway.TryParse(taghighway, out tagHighwayEnum))
            {
                if (!taghighway.Contains("_"))
                {
                    return;
                }

                var split = taghighway.Split('_');
                if (!(split.Length == 2 &&
                      split[1] == "link" &&
                      Highway.TryParse(split[0], out tagHighwayEnum)))
                {
                    return;
                }
            }


            var intersect = Intersect(nids, element.Nodes.ToList());

            if (intersect.Count == 0)
            {
                return;
            }

            WayRoute route;

            string tagref;

            element.Tags.TryGetValue("ref", out tagref);

            string tagname;

            element.Tags.TryGetValue("name", out tagname);

            string tagdescription;

            element.Tags.TryGetValue("description", out tagdescription);

            if (tagname != "" && tagname == tagdescription)
            {
                errors.Add(new RawError
                {
                    Type    = ErrorType.SameNameAndDescription,
                    OsmType = OsmGeoType.Way,
                    Id      = (long)element.Id,
                    Desc    = tagname
                });
            }

            route = new WayRoute
            {
                Id          = (long)element.Id,
                Ref         = tagref,
                Name        = tagname,
                Description = tagdescription,
                Highway     = tagHighwayEnum
            };

            // привязование линии к точке
            foreach (var id in intersect)
            {
                var index = milestones.BinarySearch(new Milestone {
                    Id = id
                });
                var milestone = milestones[index];
                if (milestone.WayRoute == null)
                {
                    milestone.WayRoute = route;
                }
                else if (milestone.WayRoute.Highway < route.Highway)
                {
                    milestone.WayRoute = route;
                }
            }
        }