示例#1
0
 public RawError(ErrorType type, RouteRel route, string desc)
 {
     OsmType = OsmGeoType.Relation;
     Id      = route.Id;
     Desc    = desc;
     Type    = type;
 }
示例#2
0
 public RawError(ErrorType type, RouteRel route)
     : this(type, route, "[route]")
 {
 }
示例#3
0
 public int CompareTo(RouteRel route)
 {
     return(Id.CompareTo(route.Id));
 }
示例#4
0
 protected static bool EqualsHelper(RouteRel r1, RouteRel r2)
 {
     return(r1.Id == r2.Id || r1.Ref == r2.Ref);
 }
示例#5
0
        private void ParseRel(Relation element)
        {
            if (!firstRel)
            {
                errors.AddRange(milestones
                                .Where(x => x.WayRoute == null)
                                .Select(x => new RawError(ErrorType.NotOnRoad, x)));

                milestones.RemoveAll(x => x.WayRoute == null);
                mems = milestones.Select(x => x.WayRoute.Id).Distinct().ToList();
                mems.Sort();
                firstRel = true;
                Console.WriteLine("Rel");
            }

            if (!(element.Tags.Contains("type", "route") &&
                  element.Tags.Contains("route", "road")))
            {
                return;
            }

            if (element.Tags.Contains("network", "e-road") ||
                element.Tags.Contains("network", "AsianHighway"))
            {
                return;
            }

            var wayMems = element.Members
                          .Where(x => x.Type == OsmGeoType.Way)
                          .Select(x => (long)x.Id)
                          .ToList();
            //.Intersect( mems );

            var intersect = Intersect(mems, wayMems);

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

            string tagref = "";

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

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

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

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

            routes.Add(route);

            // привязывание отношения к точке
            foreach (var id in intersect)
            {
                var mils = milestones.FindAll(x => x.WayRoute.Id == id);
                foreach (var mil in mils)
                {
                    mil.RelRoutes.Add(route);
                    if (!string.IsNullOrEmpty(mil.WayRoute.Ref))
                    {
                        if (mil.WayRoute.Ref == route.Ref)
                        {
                            mil.WayRoute.Dublicate = true;
                        }
                        else if (mil.WayRoute.Ref.Contains(";"))
                        {
                            foreach (var wayref in mil.WayRoute.Ref.Split(';'))
                            {
                                if (wayref.Trim() == route.Ref)
                                {
                                    mil.WayRoute.Dublicate = true;
                                }
                            }
                        }
                    }
                }
            }
        }