예제 #1
0
 public IEnumerable<MapElement> PrintPosts(GMap gMap)
 {
     var r = new Random();
     foreach (GSection section in gMap.Sections)
     {
         var sectionBrush = new SolidColorBrush(_sectionColors[r.Next(_sectionColors.Length)]);
         foreach (GPost post in section.Posts)
             yield return new KilometerPostMapElement(post) { SectionBrush = sectionBrush };
     }
 }
예제 #2
0
        public IEnumerable<MapElement> PrintObjects(GMap gMap, int trackNumber)
        {
            foreach (GSection section in gMap.Sections)
            {
                for (int i = 0; i < section.Posts.Count; i++)
                {
                    GPost post = section.Posts[i];
                    if (i + 1 < section.Posts.Count)
                    {
                        GPost nextPost = section.Posts[i + 1];
                        double dist = post.Point.DistanceTo(nextPost.Point);

                        GTrack track = post.Tracks.FirstOrDefault(t => t.Number == trackNumber);

                        if (track != null)
                        {
                            foreach (GObject gObject in track.Objects)
                            {
                                double objectRatio = (gObject.Ordinate - post.Ordinate) / dist;
                                EarthPoint objectPosition = EarthPoint.MiddlePoint(post.Point, nextPost.Point, objectRatio);
                                MapElement objectElement;
                                switch (gObject.Type)
                                {
                                    case GObjectType.TrafficLight:
                                        objectElement = new MapTrafficLightElement(objectPosition, gObject);
                                        break;
                                    case GObjectType.Platform:
                                    case GObjectType.Station:
                                        objectElement = new MapPlatformElement(objectPosition, gObject);
                                        break;
                                    default:
                                        objectElement = new MapUnknownObjectElement(objectPosition, gObject);
                                        break;
                                }
                                yield return objectElement;
                            }
                        }
                    }
                }
            }
        }