Example #1
0
        public static RouteSegment CreateNew(float latitude, float longitude, OsmSharp.Routing.Profiles.Profile profile)
        {
            RouteSegment routeSegment = new RouteSegment();

            routeSegment.Latitude  = latitude;
            routeSegment.Longitude = longitude;
            string name = profile.Name;

            routeSegment.Profile = name;
            return(routeSegment);
        }
Example #2
0
        /// <summary>
        /// Clones this object.
        /// </summary>
        /// <returns></returns>
        public object Clone()
        {
            var clone = new RouteSegment();

            clone.Distance  = this.Distance;
            clone.Latitude  = this.Latitude;
            clone.Longitude = this.Longitude;
            if (this.Metrics != null)
            {
                clone.Metrics = new RouteMetric[this.Metrics.Length];
                for (int idx = 0; idx < this.Metrics.Length; idx++)
                {
                    clone.Metrics[idx] = this.Metrics[idx].Clone() as RouteMetric;
                }
            }
            if (this.Points != null)
            {
                clone.Points = new RoutePoint[this.Points.Length];
                for (int idx = 0; idx < this.Points.Length; idx++)
                {
                    clone.Points[idx] = this.Points[idx].Clone() as RoutePoint;
                }
            }
            if (this.SideStreets != null)
            {
                clone.SideStreets = new RouteSegmentBranch[this.SideStreets.Length];
                for (int idx = 0; idx < this.SideStreets.Length; idx++)
                {
                    clone.SideStreets[idx] = this.SideStreets[idx].Clone() as RouteSegmentBranch;
                }
            }
            if (this.Tags != null)
            {
                clone.Tags = new RouteTags[this.Tags.Length];
                for (int idx = 0; idx < this.Tags.Length; idx++)
                {
                    clone.Tags[idx] = this.Tags[idx].Clone() as RouteTags;
                }
            }
            clone.Time = this.Time;
            clone.Type = this.Type;
            clone.Name = this.Name;
            if (this.Names != null)
            {
                clone.Names = new RouteTags[this.Names.Length];
                for (int idx = 0; idx < this.Names.Length; idx++)
                {
                    clone.Names[idx] = this.Names[idx].Clone() as RouteTags;
                }
            }
            clone.Vehicle = this.Vehicle;
            return(clone);
        }
Example #3
0
 public static void SetStop(this RouteSegment segment, ICoordinate coordinate)
 {
     segment.Points = new RouteStop[1]
     {
         new RouteStop()
         {
             Latitude  = coordinate.Latitude,
             Longitude = coordinate.Longitude,
             Metrics   = (RouteMetric[])null,
             Tags      = (RouteTags[])null
         }
     };
 }
Example #4
0
 public static void SetStop(this RouteSegment segment, ICoordinate coordinate, TagsCollectionBase tags)
 {
     segment.Points = new RouteStop[1]
     {
         new RouteStop()
         {
             Latitude  = coordinate.Latitude,
             Longitude = coordinate.Longitude,
             Metrics   = (RouteMetric[])null,
             Tags      = tags.ConvertFrom()
         }
     };
 }
Example #5
0
        public static void SetDistanceAndTime(this RouteSegment segment, RouteSegment previous, Speed speed)
        {
            double num = GeoCoordinate.DistanceEstimateInMeter((ICoordinate) new GeoCoordinateSimple()
            {
                Latitude  = previous.Latitude,
                Longitude = previous.Longitude
            }, (ICoordinate) new GeoCoordinateSimple()
            {
                Latitude  = segment.Latitude,
                Longitude = segment.Longitude
            });

            segment.Distance = previous.Distance + num;
            segment.Time     = previous.Time + num / (double)speed.Value;
        }
Example #6
0
        public object Clone()
        {
            RouteSegment routeSegment = new RouteSegment();

            routeSegment.Distance  = this.Distance;
            routeSegment.Latitude  = this.Latitude;
            routeSegment.Longitude = this.Longitude;
            if (this.Metrics != null)
            {
                routeSegment.Metrics = new RouteMetric[this.Metrics.Length];
                for (int index = 0; index < this.Metrics.Length; ++index)
                {
                    routeSegment.Metrics[index] = this.Metrics[index].Clone() as RouteMetric;
                }
            }
            if (this.Points != null)
            {
                routeSegment.Points = new RouteStop[this.Points.Length];
                for (int index = 0; index < this.Points.Length; ++index)
                {
                    routeSegment.Points[index] = this.Points[index].Clone() as RouteStop;
                }
            }
            if (this.SideStreets != null)
            {
                routeSegment.SideStreets = new RouteSegmentBranch[this.SideStreets.Length];
                for (int index = 0; index < this.SideStreets.Length; ++index)
                {
                    routeSegment.SideStreets[index] = this.SideStreets[index].Clone() as RouteSegmentBranch;
                }
            }
            if (this.Tags != null)
            {
                routeSegment.Tags = new RouteTags[this.Tags.Length];
                for (int index = 0; index < this.Tags.Length; ++index)
                {
                    routeSegment.Tags[index] = this.Tags[index].Clone() as RouteTags;
                }
            }
            routeSegment.Profile = this.Profile;
            routeSegment.Time    = this.Time;
            return((object)routeSegment);
        }
Example #7
0
 public static void SetStop(this RouteSegment segment, ICoordinate[] coordinates, TagsCollectionBase[] tags)
 {
     if (coordinates.Length != tags.Length)
     {
         throw new ArgumentException("Coordinates and tags arrays must have the same dimensions.");
     }
     segment.Points = new RouteStop[coordinates.Length];
     for (int index = 0; index < coordinates.Length; ++index)
     {
         segment.Points[index] = new RouteStop()
         {
             Latitude  = coordinates[index].Latitude,
             Longitude = coordinates[index].Longitude,
             Metrics   = (RouteMetric[])null,
             Tags      = tags[index] == null ? (RouteTags[])null : tags[index].ConvertFrom()
         }
     }
     ;
 }
Example #8
0
        public static Route Concatenate(this Route route1, Route route2, bool clone)
        {
            if (route1 == null)
            {
                return(route2);
            }
            if (route2 == null)
            {
                return(route1);
            }
            if (route1.Segments.Count == 0)
            {
                return(route2);
            }
            if (route2.Segments.Count == 0)
            {
                return(route1);
            }
            RouteSegment segment1 = route1.Segments[route1.Segments.Count - 1];
            double       time     = segment1.Time;
            double       distance = segment1.Distance;
            RouteSegment segment2 = route2.Segments[0];

            if ((double)System.Math.Abs(segment1.Latitude - segment2.Latitude) >= 0.001 || (double)System.Math.Abs(segment1.Longitude - segment2.Longitude) >= 0.001)
            {
                throw new ArgumentOutOfRangeException("Contatenation of routes can only be done when the end point of the first route equals the start of the second.");
            }
            Route route = new Route();
            List <RouteSegment> routeSegmentList = new List <RouteSegment>();

            for (int index = 0; index < route1.Segments.Count - 1; ++index)
            {
                if (clone)
                {
                    routeSegmentList.Add(route1.Segments[index].Clone() as RouteSegment);
                }
                else
                {
                    routeSegmentList.Add(route1.Segments[index]);
                }
            }
            RouteSegment routeSegment = route1.Segments[route1.Segments.Count - 1].Clone() as RouteSegment;

            if (route2.Segments[0].Points != null && route2.Segments[0].Points.Length != 0)
            {
                List <RouteStop> routeStopList = new List <RouteStop>();
                if (routeSegment.Points != null)
                {
                    routeStopList.AddRange((IEnumerable <RouteStop>)routeSegment.Points);
                }
                for (int index1 = 0; index1 < route2.Segments[0].Points.Length; ++index1)
                {
                    bool flag = false;
                    for (int index2 = 0; index2 < routeStopList.Count; ++index2)
                    {
                        if (routeStopList[index2].RepresentsSame(route2.Segments[0].Points[index1]))
                        {
                            flag = true;
                            break;
                        }
                    }
                    if (!flag)
                    {
                        routeStopList.Add(route2.Segments[0].Points[index1]);
                    }
                }
                routeSegment.Points = routeStopList.ToArray();
            }
            routeSegmentList.Add(routeSegment);
            for (int index = 1; index < route2.Segments.Count; ++index)
            {
                if (clone)
                {
                    routeSegmentList.Add(route2.Segments[index].Clone() as RouteSegment);
                }
                else
                {
                    routeSegmentList.Add(route2.Segments[index]);
                }
                routeSegmentList[routeSegmentList.Count - 1].Distance = routeSegmentList[routeSegmentList.Count - 1].Distance + distance;
                routeSegmentList[routeSegmentList.Count - 1].Time     = routeSegmentList[routeSegmentList.Count - 1].Time + time;
            }
            route.Segments = routeSegmentList;
            List <RouteTags> routeTagsList = new List <RouteTags>((route1.Tags == null ? 0 : route1.Tags.Count) + (route2.Tags == null ? 0 : route2.Tags.Count));

            if (route1.Tags != null)
            {
                routeTagsList.AddRange((IEnumerable <RouteTags>)route1.Tags);
            }
            if (route2.Tags != null)
            {
                routeTagsList.AddRange((IEnumerable <RouteTags>)route2.Tags);
            }
            route.Tags = routeTagsList;
            if (route.Segments != null && route.Segments.Count > 0)
            {
                route.TotalDistance = route.Segments[route.Segments.Count - 1].Distance;
                route.TotalTime     = route.Segments[route.Segments.Count - 1].Time;
            }
            return(route);
        }
Example #9
0
 /// <summary>
 /// Clones this object.
 /// </summary>
 /// <returns></returns>
 public object Clone()
 {
     var clone = new RouteSegment();
     clone.Distance = this.Distance;
     clone.Latitude = this.Latitude;
     clone.Longitude = this.Longitude;
     if (this.Metrics != null)
     {
         clone.Metrics = new RouteMetric[this.Metrics.Length];
         for (int idx = 0; idx < this.Metrics.Length; idx++)
         {
             clone.Metrics[idx] = this.Metrics[idx].Clone() as RouteMetric;
         }
     }
     if (this.Points != null)
     {
         clone.Points = new RoutePoint[this.Points.Length];
         for (int idx = 0; idx < this.Points.Length; idx++)
         {
             clone.Points[idx] = this.Points[idx].Clone() as RoutePoint;
         }
     }
     if (this.SideStreets != null)
     {
         clone.SideStreets = new RouteSegmentBranch[this.SideStreets.Length];
         for (int idx = 0; idx < this.SideStreets.Length; idx++)
         {
             clone.SideStreets[idx] = this.SideStreets[idx].Clone() as RouteSegmentBranch;
         }
     }
     if (this.Tags != null)
     {
         clone.Tags = new RouteTags[this.Tags.Length];
         for (int idx = 0; idx < this.Tags.Length; idx++)
         {
             clone.Tags[idx] = this.Tags[idx].Clone() as RouteTags;
         }
     }
     clone.Time = this.Time;
     clone.Type = this.Type;
     clone.Name = this.Name;
     if (this.Names != null)
     {
         clone.Names = new RouteTags[this.Names.Length];
         for (int idx = 0; idx < this.Names.Length; idx++)
         {
             clone.Names[idx] = this.Names[idx].Clone() as RouteTags;
         }
     }
     clone.Vehicle = this.Vehicle;
     return clone;
 }
Example #10
0
        public void RoutePositionAfterRegressionTest1()
        {
            var delta = .00001;

            // a route of approx 30 m along the following coordinates:
            // 50.98624687752063, 2.902620979360633
            // 50.98624687752063, 2.9027639004471673 (10m)
            // 50.986156907620895, 2.9027639004471673  (20m)
            // 50.9861564788317, 2.902620884621392 (30m)

            var route1 = new Route();
            route1.Vehicle = Vehicle.Car.UniqueName;
            var route1entry1 = new RouteSegment();
            route1entry1.Distance = -1;
            route1entry1.Latitude = 50.98624687752063f;
            route1entry1.Longitude = 2.902620979360633f;
            route1entry1.Metrics = null;
            route1entry1.Points = new RoutePoint[1];
            route1entry1.Points[0] = new RoutePoint();
            route1entry1.Points[0].Name = "TestPoint1";
            route1entry1.Points[0].Tags = new RouteTags[1];
            route1entry1.Points[0].Tags[0] = new RouteTags();
            route1entry1.Points[0].Tags[0].Value = "TestValue1";
            route1entry1.Points[0].Tags[0].Key = "TestKey1";
            route1entry1.SideStreets = new RouteSegmentBranch[] {
                    new RouteSegmentBranch() { 
                        Latitude = 51, 
                        Longitude = 3.999f,
                        Tags = new RouteTags[] {
                            new RouteTags() { Key = "name", Value = "Street B" },
                            new RouteTags() { Key = "highway", Value = "residential" }
                        },
                        Name = "Street B"
                    }
                };
            route1entry1.Tags = new RouteTags[1];
            route1entry1.Tags[0] = new RouteTags();
            route1entry1.Tags[0].Key = "highway";
            route1entry1.Tags[0].Value = "residential";
            route1entry1.Time = 10;
            route1entry1.Type = RouteSegmentType.Start;
            route1entry1.Name = string.Empty;
            route1entry1.Names = null;

            RouteSegment route1entry2 = new RouteSegment();
            route1entry2.Distance = -1;
            route1entry2.Latitude = 50.98624687752063f;
            route1entry2.Longitude = 2.9027639004471673f;
            route1entry2.Metrics = null;
            route1entry2.Points = new RoutePoint[1];
            route1entry2.Points[0] = new RoutePoint();
            route1entry2.Points[0].Name = "TestPoint2";
            route1entry2.Points[0].Tags = new RouteTags[1];
            route1entry2.Points[0].Tags[0] = new RouteTags();
            route1entry2.Points[0].Tags[0].Value = "TestValue2";
            route1entry1.Points[0].Tags[0].Key = "TestKey2";
            route1entry2.SideStreets = new RouteSegmentBranch[] {
                    new RouteSegmentBranch() { 
                        Latitude = 51, 
                        Longitude = 3.999f,
                        Tags = new RouteTags[] {
                            new RouteTags() { Key = "name", Value = "Street B" },
                            new RouteTags() { Key = "highway", Value = "residential" }
                        },
                        Name = "Street B"
                    }
                };
            route1entry2.Tags = new RouteTags[1];
            route1entry2.Tags[0] = new RouteTags();
            route1entry2.Tags[0].Key = "highway";
            route1entry2.Tags[0].Value = "residential";
            route1entry2.Time = 10;
            route1entry2.Type = RouteSegmentType.Start;
            route1entry2.Name = string.Empty;
            route1entry2.Names = null;

            RouteSegment route1entry3 = new RouteSegment();
            route1entry3.Distance = -1;
            route1entry3.Latitude = 50.986156907620895f;
            route1entry3.Longitude = 2.9027639004471673f;
            route1entry3.Metrics = null;
            route1entry3.Points = new RoutePoint[1];
            route1entry3.Points[0] = new RoutePoint();
            route1entry3.Points[0].Name = "TestPoint3";
            route1entry3.Points[0].Tags = new RouteTags[1];
            route1entry3.Points[0].Tags[0] = new RouteTags();
            route1entry3.Points[0].Tags[0].Value = "TestValue3";
            route1entry1.Points[0].Tags[0].Key = "TestKey3";
            route1entry3.SideStreets = new RouteSegmentBranch[] {
                    new RouteSegmentBranch() { 
                        Latitude = 51, 
                        Longitude = 3.999f,
                        Tags = new RouteTags[] {
                            new RouteTags() { Key = "name", Value = "Street B" },
                            new RouteTags() { Key = "highway", Value = "residential" }
                        },
                        Name = "Street B"
                    }
                };
            route1entry3.Tags = new RouteTags[1];
            route1entry3.Tags[0] = new RouteTags();
            route1entry3.Tags[0].Key = "highway";
            route1entry3.Tags[0].Value = "residential";
            route1entry3.Time = 10;
            route1entry3.Type = RouteSegmentType.Start;
            route1entry3.Name = string.Empty;
            route1entry3.Names = null;

            RouteSegment route1entry4 = new RouteSegment();
            route1entry4.Distance = -1;
            route1entry4.Latitude = 50.9861564788317f;
            route1entry4.Longitude = 2.902620884621392f;
            route1entry4.Metrics = null;
            route1entry4.Points = new RoutePoint[1];
            route1entry4.Points[0] = new RoutePoint();
            route1entry4.Points[0].Name = "TestPoint4";
            route1entry4.Points[0].Tags = new RouteTags[1];
            route1entry4.Points[0].Tags[0] = new RouteTags();
            route1entry4.Points[0].Tags[0].Value = "TestValue4";
            route1entry1.Points[0].Tags[0].Key = "TestKey4";
            route1entry4.SideStreets = new RouteSegmentBranch[] {
                    new RouteSegmentBranch() { 
                        Latitude = 51, 
                        Longitude = 3.999f,
                        Tags = new RouteTags[] {
                            new RouteTags() { Key = "name", Value = "Street B" },
                            new RouteTags() { Key = "highway", Value = "residential" }
                        },
                        Name = "Street B"
                    }
                };
            route1entry4.Tags = new RouteTags[1];
            route1entry4.Tags[0] = new RouteTags();
            route1entry4.Tags[0].Key = "highway";
            route1entry4.Tags[0].Value = "residential";
            route1entry4.Time = 10;
            route1entry4.Type = RouteSegmentType.Start;
            route1entry4.Name = string.Empty;
            route1entry4.Names = null;

            route1.Segments = new RouteSegment[4];
            route1.Segments[0] = route1entry1;
            route1.Segments[1] = route1entry2;
            route1.Segments[2] = route1entry3;
            route1.Segments[3] = route1entry4;

            // create the route tracker.
            var routeTracker = new RouteTracker(route1, new OsmRoutingInterpreter());

            var distance = 5.0;
            var location = route1.PositionAfter(distance);
            routeTracker.Track(location);
            Assert.AreEqual(distance, routeTracker.DistanceFromStart.Value, delta);
            Assert.AreEqual(location.Latitude, routeTracker.PositionRoute.Latitude, delta);
            Assert.AreEqual(location.Longitude, routeTracker.PositionRoute.Longitude, delta);
            Assert.AreEqual(new GeoCoordinate(route1.Segments[1].Latitude, route1.Segments[1].Longitude).DistanceReal(location).Value, routeTracker.DistanceNextInstruction.Value, delta);
            var locationAfter = routeTracker.PositionAfter(10.0);

            distance = 15.0;
            location = route1.PositionAfter(distance);
            Assert.AreEqual(location.Latitude, locationAfter.Latitude, delta);
            Assert.AreEqual(location.Longitude, locationAfter.Longitude, delta);
            routeTracker.Track(location);
            Assert.AreEqual(distance, routeTracker.DistanceFromStart.Value, delta);
            Assert.AreEqual(location.Latitude, routeTracker.PositionRoute.Latitude, delta);
            Assert.AreEqual(location.Longitude, routeTracker.PositionRoute.Longitude, delta);
            Assert.AreEqual(new GeoCoordinate(route1.Segments[2].Latitude, route1.Segments[2].Longitude).DistanceReal(location).Value, routeTracker.DistanceNextInstruction.Value, delta);

            location = new GeoCoordinate(route1.Segments[3].Latitude, route1.Segments[3].Longitude);
            Meter distanceFromStart;
            route1.ProjectOn(location, out distanceFromStart);
            distance = distanceFromStart.Value;
            routeTracker.Track(location);
            Assert.AreEqual(distance, routeTracker.DistanceFromStart.Value, delta);
            Assert.AreEqual(location.Latitude, routeTracker.PositionRoute.Latitude, delta);
            Assert.AreEqual(location.Longitude, routeTracker.PositionRoute.Longitude, delta);
            Assert.AreEqual(0, routeTracker.DistanceNextInstruction.Value, delta);
        }
Example #11
0
 public static void Set(this RouteSegment segment, RouteSegment previous, Profile profile, TagsCollectionBase tags, Speed speed)
 {
     segment.SetDistanceAndTime(previous, speed);
     segment.Tags    = tags.ConvertFrom();
     segment.Profile = profile.Name;
 }
Example #12
0
        public void RouteConcatenateVehiclesTest()
        {
            var route1 = new Route();
            route1.Vehicle = Vehicle.Car.UniqueName;
            var route1segment1 = new RouteSegment();
            route1segment1.Distance = 10;
            route1segment1.Latitude = -1;
            route1segment1.Longitude = -1;
            route1segment1.Metrics = null;
            route1segment1.Points = new RoutePoint[1];
            route1segment1.Points[0] = new RoutePoint();
            route1segment1.Points[0].Name = "TestPoint1";
            route1segment1.Points[0].Tags = new RouteTags[1];
            route1segment1.Points[0].Tags[0] = new RouteTags();
            route1segment1.Points[0].Tags[0].Value = "TestValue1";
            route1segment1.Points[0].Tags[0].Key = "TestKey1";
            route1segment1.SideStreets = null;
            route1segment1.Tags = new RouteTags[1];
            route1segment1.Tags[0] = new RouteTags();
            route1segment1.Tags[0].Key = "highway";
            route1segment1.Tags[0].Value = "residential";
            route1segment1.Time = 10;
            route1segment1.Type = RouteSegmentType.Start;
            route1segment1.Name = string.Empty;
            route1segment1.Names = null;
            route1segment1.Vehicle = Vehicle.Car.UniqueName;

            var route1segment2 = new RouteSegment();
            route1segment2.Distance = 10;
            route1segment2.Latitude = -1;
            route1segment2.Longitude = -1;
            route1segment2.Metrics = null;
            route1segment2.Points = new RoutePoint[1];
            route1segment2.Points[0] = new RoutePoint();
            route1segment2.Points[0].Name = "TestPoint2";
            route1segment2.Points[0].Tags = new RouteTags[1];
            route1segment2.Points[0].Tags[0] = new RouteTags();
            route1segment2.Points[0].Tags[0].Value = "TestValue2";
            route1segment1.Points[0].Tags[0].Key = "TestKey2";
            route1segment2.SideStreets = null;
            route1segment2.Tags = new RouteTags[1];
            route1segment2.Tags[0] = new RouteTags();
            route1segment2.Tags[0].Key = "highway";
            route1segment2.Tags[0].Value = "residential";
            route1segment2.Time = 10;
            route1segment2.Type = RouteSegmentType.Start;
            route1segment2.Name = string.Empty;
            route1segment2.Names = null;
            route1segment2.Vehicle = Vehicle.Car.UniqueName;

            route1.Segments = new RouteSegment[2];
            route1.Segments[0] = route1segment1;
            route1.Segments[1] = route1segment2;

            var route2 = new Route();
            route2.Vehicle = Vehicle.Pedestrian.UniqueName;
            var route2segment1 = new RouteSegment();
            route2segment1.Distance = 10;
            route2segment1.Latitude = -1;
            route2segment1.Longitude = -1;
            route2segment1.Metrics = null;
            route2segment1.Points = new RoutePoint[1];
            route2segment1.Points[0] = new RoutePoint();
            route2segment1.Points[0].Name = "TestPoint3";
            route2segment1.Points[0].Tags = new RouteTags[1];
            route2segment1.Points[0].Tags[0] = new RouteTags();
            route2segment1.Points[0].Tags[0].Value = "TestValue3";
            route2segment1.Points[0].Tags[0].Key = "TestKey3";
            route2segment1.SideStreets = null;
            route2segment1.Tags = new RouteTags[1];
            route2segment1.Tags[0] = new RouteTags();
            route2segment1.Tags[0].Key = "highway";
            route2segment1.Tags[0].Value = "residential";
            route2segment1.Time = 10;
            route2segment1.Type = RouteSegmentType.Start;
            route2segment1.Name = string.Empty;
            route2segment1.Names = null;
            route2segment1.Vehicle = Vehicle.Pedestrian.UniqueName;

            var route2segment2 = new RouteSegment();
            route2segment2.Distance = 10;
            route2segment2.Latitude = -1;
            route2segment2.Longitude = -1;
            route2segment2.Metrics = null;
            route2segment2.Points = new RoutePoint[1];
            route2segment2.Points[0] = new RoutePoint();
            route2segment2.Points[0].Name = "TestPoint4";
            route2segment2.Points[0].Tags = new RouteTags[1];
            route2segment2.Points[0].Tags[0] = new RouteTags();
            route2segment2.Points[0].Tags[0].Value = "TestValue4";
            route2segment1.Points[0].Tags[0].Key = "TestKey4";
            route2segment2.SideStreets = null;
            route2segment2.Tags = new RouteTags[1];
            route2segment2.Tags[0] = new RouteTags();
            route2segment2.Tags[0].Key = "highway";
            route2segment2.Tags[0].Value = "residential";
            route2segment2.Time = 10;
            route2segment2.Type = RouteSegmentType.Start;
            route2segment2.Name = string.Empty;
            route2segment2.Names = null;
            route2segment2.Vehicle = Vehicle.Pedestrian.UniqueName;

            route2.Segments = new RouteSegment[2];
            route2.Segments[0] = route2segment1;
            route2.Segments[1] = route2segment2;

            var concatenated = Route.Concatenate(route1, route2);

            // test the result.
            Assert.IsNotNull(concatenated);
            Assert.IsNotNull(concatenated.Segments);
            Assert.AreEqual(null, concatenated.Vehicle);
            Assert.AreEqual(3, concatenated.Segments.Length);
            Assert.AreEqual(Vehicle.Car.UniqueName, concatenated.Segments[0].Vehicle);
            Assert.AreEqual(Vehicle.Car.UniqueName, concatenated.Segments[1].Vehicle);
            Assert.AreEqual(Vehicle.Pedestrian.UniqueName, concatenated.Segments[2].Vehicle);
        }
        /// <summary>
        /// Builds a dummy route (as the crow flies) for segments of a route not found.
        /// </summary>
        /// <returns></returns>
        public virtual Route BuildDummyRoute(Vehicle vehicle, GeoCoordinate coordinate1, GeoCoordinate coordinate2)
        {
            var route = new Route();
            route.Vehicle = vehicle.UniqueName;

            var segments = new RouteSegment[2];
            segments[0] = new RouteSegment();
            segments[0].Distance = 0;
            segments[0].Time = 0;
            segments[0].Type = RouteSegmentType.Start;
            segments[0].Vehicle = vehicle.UniqueName;
            segments[0].Latitude = (float)coordinate1.Latitude;
            segments[0].Longitude = (float)coordinate1.Longitude;

            var distance = coordinate1.DistanceReal(coordinate2).Value;
            var timeEstimage = distance / (vehicle.MaxSpeed().Value) * 3.6;
            var tags = new TagsCollection();
            tags.Add("route", "not_found");
            segments[1] = new RouteSegment();
            segments[1].Distance = distance;
            segments[1].Time = timeEstimage;
            segments[1].Type = RouteSegmentType.Stop;
            segments[1].Vehicle = vehicle.UniqueName;
            segments[1].Latitude = (float)coordinate2.Latitude;
            segments[1].Longitude = (float)coordinate2.Longitude;
            segments[1].Tags = RouteTagsExtensions.ConvertFrom(tags);

            route.Segments = segments;

            return route;
        }
Example #14
0
        /// <summary>
        /// Concatenates two routes.
        /// </summary>
        /// <param name="route1"></param>
        /// <param name="route2"></param>
        /// <param name="clone"></param>
        /// <returns></returns>
        public static Route Concatenate(Route route1, Route route2, bool clone)
        {
            if (route1 == null)
            {
                return(route2);
            }
            if (route2 == null)
            {
                return(route1);
            }
            if (route1.Segments.Length == 0)
            {
                return(route2);
            }
            if (route2.Segments.Length == 0)
            {
                return(route1);
            }
            if (route1.Vehicle != route2.Vehicle)
            {
                throw new ArgumentException("Route vechicles do not match!");
            }

            // get the end/start point.
            RouteSegment end   = route1.Segments[route1.Segments.Length - 1];
            RouteSegment start = route2.Segments[0];

            // only do all this if the routes are 'concatenable'.
            if (end.Latitude == start.Latitude &&
                end.Longitude == start.Longitude)
            {
                // construct the new route.
                Route route = new Route();

                // concatenate points.
                List <RouteSegment> entries = new List <RouteSegment>();
                // add points for the first route except the last point.
                for (int idx = 0; idx < route1.Segments.Length - 1; idx++)
                {
                    if (clone)
                    {
                        entries.Add(route1.Segments[idx].Clone() as RouteSegment);
                    }
                    else
                    {
                        entries.Add(route1.Segments[idx]);
                    }
                }

                // merge last and first entry.
                RouteSegment mergedEntry =
                    route1.Segments[route1.Segments.Length - 1].Clone() as RouteSegment;
                mergedEntry.Type = RouteSegmentType.Along;
                if (route2.Segments[0].Points != null && route2.Segments[0].Points.Length > 0)
                { // merge in important points from the second route too but do not keep duplicates.
                    var points = new List <RoutePoint>();
                    if (mergedEntry.Points != null)
                    { // keep originals.
                        points.AddRange(mergedEntry.Points);
                    }
                    for (int otherIdx = 0; otherIdx < route2.Segments[0].Points.Length; otherIdx++)
                    { // remove duplicates.
                        bool found = false;
                        for (int idx = 0; idx < points.Count; idx++)
                        {
                            if (points[idx].RepresentsSame(
                                    route2.Segments[0].Points[otherIdx]))
                            { // the points represent the same info!
                                found = true;
                                break;
                            }
                        }
                        if (!found)
                        { // the point was not in there yet!
                            points.Add(route2.Segments[0].Points[otherIdx]);
                        }
                    }
                    mergedEntry.Points = points.ToArray();
                }
                entries.Add(mergedEntry);

                // add points of the next route.
                for (int idx = 1; idx < route2.Segments.Length; idx++)
                {
                    if (clone)
                    {
                        entries.Add(route2.Segments[idx].Clone() as RouteSegment);
                    }
                    else
                    {
                        entries.Add(route2.Segments[idx]);
                    }
                }
                route.Segments = entries.ToArray();

                // concatenate tags.
                List <RouteTags> tags = new List <RouteTags>();
                if (route1.Tags != null)
                {
                    tags.AddRange(route1.Tags);
                }
                if (route2.Tags != null)
                {
                    tags.AddRange(route2.Tags);
                }
                route.Tags = tags.ToArray();

                //// calculate metrics.
                //Routing.Core.Metrics.Time.TimeCalculator calculator = new OsmSharp.Routing.Metrics.Time.TimeCalculator();
                //Dictionary<string, double> metrics = calculator.Calculate(route);
                //route.TotalDistance = metrics[Routing.Core.Metrics.Time.TimeCalculator.DISTANCE_KEY];
                //route.TotalTime = metrics[Routing.Core.Metrics.Time.TimeCalculator.TIME_KEY];

                // set the vehicle.
                route.Vehicle = route1.Vehicle;
                return(route);
            }
            else
            {
                throw new ArgumentOutOfRangeException("Contatenation routes can only be done when the end point of the first route equals the start of the second.");
            }
        }
Example #15
0
        public void RoutePositionAfterRegressionTest1()
        {
            var delta = .00001;

            // a route of approx 30 m along the following coordinates:
            // 50.98624687752063, 2.902620979360633
            // 50.98624687752063, 2.9027639004471673 (10m)
            // 50.986156907620895, 2.9027639004471673  (20m)
            // 50.9861564788317, 2.902620884621392 (30m)

            Route route1 = new Route();
            route1.Vehicle = Vehicle.Car.UniqueName;
            RouteSegment route1entry1 = new RouteSegment();
            route1entry1.Distance = -1;
            route1entry1.Latitude = 50.98624687752063f;
            route1entry1.Longitude = 2.902620979360633f;
            route1entry1.Metrics = null;
            route1entry1.Points = new RoutePoint[1];
            route1entry1.Points[0] = new RoutePoint();
            route1entry1.Points[0].Name = "TestPoint1";
            route1entry1.Points[0].Tags = new RouteTags[1];
            route1entry1.Points[0].Tags[0] = new RouteTags();
            route1entry1.Points[0].Tags[0].Value = "TestValue1";
            route1entry1.Points[0].Tags[0].Key = "TestKey1";
            route1entry1.SideStreets = null;
            route1entry1.Tags = new RouteTags[1];
            route1entry1.Tags[0] = new RouteTags();
            route1entry1.Tags[0].Key = "highway";
            route1entry1.Tags[0].Value = "residential";
            route1entry1.Time = 10;
            route1entry1.Type = RouteSegmentType.Start;
            route1entry1.Name = string.Empty;
            route1entry1.Names = null;

            RouteSegment route1entry2 = new RouteSegment();
            route1entry2.Distance = -1;
            route1entry2.Latitude = 50.98624687752063f;
            route1entry2.Longitude = 2.9027639004471673f;
            route1entry2.Metrics = null;
            route1entry2.Points = new RoutePoint[1];
            route1entry2.Points[0] = new RoutePoint();
            route1entry2.Points[0].Name = "TestPoint2";
            route1entry2.Points[0].Tags = new RouteTags[1];
            route1entry2.Points[0].Tags[0] = new RouteTags();
            route1entry2.Points[0].Tags[0].Value = "TestValue2";
            route1entry1.Points[0].Tags[0].Key = "TestKey2";
            route1entry2.SideStreets = null;
            route1entry2.Tags = new RouteTags[1];
            route1entry2.Tags[0] = new RouteTags();
            route1entry2.Tags[0].Key = "highway";
            route1entry2.Tags[0].Value = "residential";
            route1entry2.Time = 10;
            route1entry2.Type = RouteSegmentType.Start;
            route1entry2.Name = string.Empty;
            route1entry2.Names = null;

            RouteSegment route1entry3 = new RouteSegment();
            route1entry3.Distance = -1;
            route1entry3.Latitude = 50.986156907620895f;
            route1entry3.Longitude = 2.9027639004471673f;
            route1entry3.Metrics = null;
            route1entry3.Points = new RoutePoint[1];
            route1entry3.Points[0] = new RoutePoint();
            route1entry3.Points[0].Name = "TestPoint3";
            route1entry3.Points[0].Tags = new RouteTags[1];
            route1entry3.Points[0].Tags[0] = new RouteTags();
            route1entry3.Points[0].Tags[0].Value = "TestValue3";
            route1entry1.Points[0].Tags[0].Key = "TestKey3";
            route1entry3.SideStreets = null;
            route1entry3.Tags = new RouteTags[1];
            route1entry3.Tags[0] = new RouteTags();
            route1entry3.Tags[0].Key = "highway";
            route1entry3.Tags[0].Value = "residential";
            route1entry3.Time = 10;
            route1entry3.Type = RouteSegmentType.Start;
            route1entry3.Name = string.Empty;
            route1entry3.Names = null;

            RouteSegment route1entry4 = new RouteSegment();
            route1entry4.Distance = -1;
            route1entry4.Latitude = 50.9861564788317f;
            route1entry4.Longitude = 2.902620884621392f;
            route1entry4.Metrics = null;
            route1entry4.Points = new RoutePoint[1];
            route1entry4.Points[0] = new RoutePoint();
            route1entry4.Points[0].Name = "TestPoint4";
            route1entry4.Points[0].Tags = new RouteTags[1];
            route1entry4.Points[0].Tags[0] = new RouteTags();
            route1entry4.Points[0].Tags[0].Value = "TestValue4";
            route1entry1.Points[0].Tags[0].Key = "TestKey4";
            route1entry4.SideStreets = null;
            route1entry4.Tags = new RouteTags[1];
            route1entry4.Tags[0] = new RouteTags();
            route1entry4.Tags[0].Key = "highway";
            route1entry4.Tags[0].Value = "residential";
            route1entry4.Time = 10;
            route1entry4.Type = RouteSegmentType.Start;
            route1entry4.Name = string.Empty;
            route1entry4.Names = null;

            route1.Segments = new RouteSegment[4];
            route1.Segments[0] = route1entry1;
            route1.Segments[1] = route1entry2;
            route1.Segments[2] = route1entry3;
            route1.Segments[3] = route1entry4;

            // first test position after.
            var positionAfter = route1.PositionAfter(5);
            Assert.IsNotNull(positionAfter);
            Assert.AreEqual(5.0, positionAfter.DistanceReal(new GeoCoordinate(route1.Segments[0].Latitude, route1.Segments[0].Longitude)).Value, .0001);
            positionAfter = route1.PositionAfter(15);
            Assert.IsNotNull(positionAfter);
            Assert.AreEqual(15.0,
                new GeoCoordinate(route1.Segments[0].Latitude, route1.Segments[0].Longitude).DistanceReal(new GeoCoordinate(route1.Segments[1].Latitude, route1.Segments[1].Longitude)).Value +
                positionAfter.DistanceReal(new GeoCoordinate(route1.Segments[1].Latitude, route1.Segments[1].Longitude)).Value, .0001);
            positionAfter = route1.PositionAfter(25);
            Assert.IsNotNull(positionAfter);
            Assert.AreEqual(25.0,
                new GeoCoordinate(route1.Segments[0].Latitude, route1.Segments[0].Longitude).DistanceReal(new GeoCoordinate(route1.Segments[1].Latitude, route1.Segments[1].Longitude)).Value +
                new GeoCoordinate(route1.Segments[1].Latitude, route1.Segments[1].Longitude).DistanceReal(new GeoCoordinate(route1.Segments[2].Latitude, route1.Segments[2].Longitude)).Value +
                positionAfter.DistanceReal(new GeoCoordinate(route1.Segments[2].Latitude, route1.Segments[2].Longitude)).Value, .0001);

            // use position after to test project on.
            int entryIdx;
            GeoCoordinate projected;
            Meter distanceFromStart;
            Second timeFromStart;

            var distance = 5.0;
            var location = route1.PositionAfter(distance);
            Assert.IsTrue(route1.ProjectOn(location, out projected, out entryIdx, out distanceFromStart, out timeFromStart));
            Assert.AreEqual(distance, distanceFromStart.Value, delta);
            Assert.AreEqual(location.Latitude, projected.Latitude, delta);
            Assert.AreEqual(location.Longitude, projected.Longitude, delta);
            Assert.AreEqual(0, entryIdx);

            location = route1.PositionAfter(distanceFromStart);
            Assert.AreEqual(location.Latitude, projected.Latitude, delta);
            Assert.AreEqual(location.Longitude, projected.Longitude, delta);

            distance = 15.0;
            location = route1.PositionAfter(distance);
            Assert.IsTrue(route1.ProjectOn(location, out projected, out entryIdx, out distanceFromStart, out timeFromStart));
            Assert.AreEqual(distance, distanceFromStart.Value, delta);
            Assert.AreEqual(location.Latitude, projected.Latitude, delta);
            Assert.AreEqual(location.Longitude, projected.Longitude, delta);
            Assert.AreEqual(1, entryIdx);

            location = route1.PositionAfter(distanceFromStart);
            Assert.AreEqual(location.Latitude, projected.Latitude, delta);
            Assert.AreEqual(location.Longitude, projected.Longitude, delta);

            distance = 25;
            location = route1.PositionAfter(distance);
            Assert.IsTrue(route1.ProjectOn(location, out projected, out entryIdx, out distanceFromStart, out timeFromStart));
            Assert.AreEqual(distance, distanceFromStart.Value, delta);
            Assert.AreEqual(location.Latitude, projected.Latitude, delta);
            Assert.AreEqual(location.Longitude, projected.Longitude, delta);
            Assert.AreEqual(2, entryIdx);

            location = route1.PositionAfter(distanceFromStart);
            Assert.AreEqual(location.Latitude, projected.Latitude, delta);
            Assert.AreEqual(location.Longitude, projected.Longitude, delta);
        }
Example #16
0
        public void RouteToGeoJson()
        {
            // build a test route.
            var route = new Route();
            route.Vehicle = Vehicle.Car.UniqueName;
            var route1entry1 = new RouteSegment();
            route1entry1.Distance = 0;
            route1entry1.Latitude = 1;
            route1entry1.Longitude = 1;
            route1entry1.Metrics = null;
            route1entry1.Points = new RoutePoint[1];
            route1entry1.Points[0] = new RoutePoint();
            route1entry1.Points[0].Name = "TestPoint1";
            route1entry1.Points[0].Tags = new RouteTags[1];
            route1entry1.Points[0].Tags[0] = new RouteTags();
            route1entry1.Points[0].Tags[0].Value = "TestValue1";
            route1entry1.Points[0].Tags[0].Key = "TestKey1";
            route1entry1.SideStreets = null;
            route1entry1.Tags = new RouteTags[1];
            route1entry1.Tags[0] = new RouteTags();
            route1entry1.Tags[0].Key = "highway";
            route1entry1.Tags[0].Value = "residential";
            route1entry1.Time = 0;
            route1entry1.Type = RouteSegmentType.Start;
            route1entry1.Name = string.Empty;
            route1entry1.Names = null;

            var route1entry2 = new RouteSegment();
            route1entry2.Distance = 10;
            route1entry2.Latitude = 2;
            route1entry2.Longitude = 2;
            route1entry2.Metrics = null;
            route1entry2.Points = new RoutePoint[1];
            route1entry2.Points[0] = new RoutePoint();
            route1entry2.Points[0].Name = "TestPoint2";
            route1entry2.Points[0].Tags = new RouteTags[1];
            route1entry2.Points[0].Tags[0] = new RouteTags();
            route1entry2.Points[0].Tags[0].Value = "TestValue2";
            route1entry2.Points[0].Tags[0].Key = "TestKey2";
            route1entry2.SideStreets = null;
            route1entry2.Tags = new RouteTags[1];
            route1entry2.Tags[0] = new RouteTags();
            route1entry2.Tags[0].Key = "highway";
            route1entry2.Tags[0].Value = "residential";
            route1entry2.Time = 20;
            route1entry2.Type = RouteSegmentType.Start;
            route1entry2.Name = string.Empty;
            route1entry2.Names = null;

            route.Segments = new RouteSegment[2];
            route.Segments[0] = route1entry1;
            route.Segments[1] = route1entry2;

            // execute the conversion.
            var geojson = route.ToGeoJson();
            geojson = geojson.RemoveWhitespace();

            Assert.AreEqual("{\"type\":\"FeatureCollection\",\"features\":[{\"type\":\"Feature\",\"properties\":{\"TestKey1\":\"TestValue1\"},\"geometry\":{\"type\":\"Point\",\"coordinates\":[0.0,0.0]}},{\"type\":\"Feature\",\"properties\":{\"highway\":\"residential\",\"time\":20.0,\"distance\":10.0},\"geometry\":{\"type\":\"LineString\",\"coordinates\":[[1.0,1.0],[2.0,2.0]]}},{\"type\":\"Feature\",\"properties\":{\"TestKey2\":\"TestValue2\"},\"geometry\":{\"type\":\"Point\",\"coordinates\":[0.0,0.0]}}]}",
                geojson);
        }
Example #17
0
        public void RouteConcatenateTagsIdenticalTest()
        {
            Route route1 = new Route();
            RouteSegment route1entry1 = new RouteSegment();
            route1entry1.Distance = 10;
            route1entry1.Latitude = -1;
            route1entry1.Longitude = -1;
            route1entry1.Metrics = null;
            route1entry1.Points = new RoutePoint[1];
            route1entry1.Points[0] = new RoutePoint();
            route1entry1.Points[0].Name = "TestPoint1";
            route1entry1.Points[0].Tags = new RouteTags[1];
            route1entry1.Points[0].Tags[0] = new RouteTags();
            route1entry1.Points[0].Tags[0].Value = "TestValue1";
            route1entry1.Points[0].Tags[0].Key = "TestKey1";
            route1entry1.SideStreets = null;
            route1entry1.Tags = new RouteTags[1];
            route1entry1.Tags[0] = new RouteTags();
            route1entry1.Tags[0].Key = "highway";
            route1entry1.Tags[0].Value = "residential";
            route1entry1.Time = 10;
            route1entry1.Type = RouteSegmentType.Start;
            route1entry1.Name = string.Empty;
            route1entry1.Names = null;

            RouteSegment route1entry2 = new RouteSegment();
            route1entry2.Distance = 10;
            route1entry2.Latitude = -1;
            route1entry2.Longitude = -1;
            route1entry2.Metrics = null;
            route1entry2.Points = new RoutePoint[1];
            route1entry2.Points[0] = new RoutePoint();
            route1entry2.Points[0].Name = "TestPoint2";
            route1entry2.Points[0].Tags = new RouteTags[1];
            route1entry2.Points[0].Tags[0] = new RouteTags();
            route1entry2.Points[0].Tags[0].Value = "TestValue2";
            route1entry2.Points[0].Tags[0].Key = "TestKey2";
            route1entry2.SideStreets = null;
            route1entry2.Tags = new RouteTags[1];
            route1entry2.Tags[0] = new RouteTags();
            route1entry2.Tags[0].Key = "highway";
            route1entry2.Tags[0].Value = "residential";
            route1entry2.Time = 10;
            route1entry2.Type = RouteSegmentType.Start;
            route1entry2.Name = string.Empty;
            route1entry2.Names = null;

            route1.Segments = new RouteSegment[2];
            route1.Segments[0] = route1entry1;
            route1.Segments[1] = route1entry2;

            Route route2 = new Route();
            RouteSegment route2entry1 = new RouteSegment();
            route2entry1.Distance = 10;
            route2entry1.Latitude = -1;
            route2entry1.Longitude = -1;
            route2entry1.Metrics = null;
            route2entry1.Points = new RoutePoint[1];
            route2entry1.Points[0] = new RoutePoint();
            route2entry1.Points[0].Name = "TestPoint2";
            route2entry1.Points[0].Tags = new RouteTags[1];
            route2entry1.Points[0].Tags[0] = new RouteTags();
            route2entry1.Points[0].Tags[0].Value = "TestValue2";
            route2entry1.Points[0].Tags[0].Key = "TestKey2";
            route2entry1.SideStreets = null;
            route2entry1.Tags = new RouteTags[1];
            route2entry1.Tags[0] = new RouteTags();
            route2entry1.Tags[0].Key = "highway";
            route2entry1.Tags[0].Value = "residential";
            route2entry1.Time = 10;
            route2entry1.Type = RouteSegmentType.Start;
            route2entry1.Name = string.Empty;
            route2entry1.Names = null;

            RouteSegment route2entry2 = new RouteSegment();
            route2entry2.Distance = 10;
            route2entry2.Latitude = -1;
            route2entry2.Longitude = -1;
            route2entry2.Metrics = null;
            route2entry2.Points = new RoutePoint[1];
            route2entry2.Points[0] = new RoutePoint();
            route2entry2.Points[0].Name = "TestPoint4";
            route2entry2.Points[0].Tags = new RouteTags[1];
            route2entry2.Points[0].Tags[0] = new RouteTags();
            route2entry2.Points[0].Tags[0].Value = "TestValue4";
            route2entry2.Points[0].Tags[0].Key = "TestKey4";
            route2entry2.SideStreets = null;
            route2entry2.Tags = new RouteTags[1];
            route2entry2.Tags[0] = new RouteTags();
            route2entry2.Tags[0].Key = "highway";
            route2entry2.Tags[0].Value = "residential";
            route2entry2.Time = 10;
            route2entry2.Type = RouteSegmentType.Start;
            route2entry2.Name = string.Empty;
            route2entry2.Names = null;

            route2.Segments = new RouteSegment[2];
            route2.Segments[0] = route2entry1;
            route2.Segments[1] = route2entry2;

            Route concatenated = Route.Concatenate(route1, route2);

            // test the result.
            Assert.IsNotNull(concatenated);
            Assert.IsNotNull(concatenated.Segments);
            Assert.AreEqual(3, concatenated.Segments.Length);
            Assert.AreEqual("TestPoint1", concatenated.Segments[0].Points[0].Name);
            Assert.AreEqual("TestPoint2", concatenated.Segments[1].Points[0].Name);
            Assert.AreEqual(1, concatenated.Segments[1].Points.Length);
            Assert.AreEqual("TestPoint4", concatenated.Segments[2].Points[0].Name);
        }
Example #18
0
        public void RouteToFeatureCollection()
        {
            // build a test route.
            var route = new Route();
            route.Vehicle = Vehicle.Car.UniqueName;
            var route1entry1 = new RouteSegment();
            route1entry1.Distance = 10;
            route1entry1.Latitude = -1;
            route1entry1.Longitude = -1;
            route1entry1.Metrics = null;
            route1entry1.Points = new RoutePoint[1];
            route1entry1.Points[0] = new RoutePoint();
            route1entry1.Points[0].Name = "TestPoint1";
            route1entry1.Points[0].Tags = new RouteTags[1];
            route1entry1.Points[0].Tags[0] = new RouteTags();
            route1entry1.Points[0].Tags[0].Value = "TestValue1";
            route1entry1.Points[0].Tags[0].Key = "TestKey1";
            route1entry1.SideStreets = null;
            route1entry1.Tags = new RouteTags[1];
            route1entry1.Tags[0] = new RouteTags();
            route1entry1.Tags[0].Key = "highway";
            route1entry1.Tags[0].Value = "residential";
            route1entry1.Time = 10;
            route1entry1.Type = RouteSegmentType.Start;
            route1entry1.Name = string.Empty;
            route1entry1.Names = null;

            var route1entry2 = new RouteSegment();
            route1entry2.Distance = 10;
            route1entry2.Latitude = -1;
            route1entry2.Longitude = -1;
            route1entry2.Metrics = null;
            route1entry2.Points = new RoutePoint[1];
            route1entry2.Points[0] = new RoutePoint();
            route1entry2.Points[0].Name = "TestPoint2";
            route1entry2.Points[0].Tags = new RouteTags[1];
            route1entry2.Points[0].Tags[0] = new RouteTags();
            route1entry2.Points[0].Tags[0].Value = "TestValue2";
            route1entry2.Points[0].Tags[0].Key = "TestKey2";
            route1entry2.SideStreets = null;
            route1entry2.Tags = new RouteTags[1];
            route1entry2.Tags[0] = new RouteTags();
            route1entry2.Tags[0].Key = "highway";
            route1entry2.Tags[0].Value = "residential";
            route1entry2.Time = 10;
            route1entry2.Type = RouteSegmentType.Start;
            route1entry2.Name = string.Empty;
            route1entry2.Names = null;

            route.Segments = new RouteSegment[2];
            route.Segments[0] = route1entry1;
            route.Segments[1] = route1entry2;

            // execute the conversion.
            var features = route.ToFeatureCollection();

            // check result, two points, one linestring.
            Assert.IsNotNull(features);
            Assert.AreEqual(3, features.Count);
            var featuresList = new List<Feature>(features);
            Assert.IsInstanceOf<Point>(featuresList[0].Geometry);
            Assert.IsInstanceOf<LineString>(featuresList[1].Geometry);
            Assert.IsInstanceOf<Point>(featuresList[2].Geometry);
        }