示例#1
0
        /// <summary>
        /// Creates a new referenced decoder.
        /// </summary>
        public ReferencedDecoderBase(BasicRouterDataSource <LiveEdge> graph, Vehicle vehicle, Decoder locationDecoder)
            : base(locationDecoder)
        {
            _graph   = graph;
            _vehicle = vehicle;

            _referencedCircleDecoder         = this.GetReferencedCircleDecoder();
            _referencedGeoCoordinateDecoder  = this.GetReferencedGeoCoordinateDecoder();
            _referencedGridDecoder           = this.GetReferencedGridDecoder();
            _referencedLineDecoder           = this.GetReferencedLineDecoder();
            _referencedPointAlongLineDecoder = this.GetReferencedPointAlongLineDecoder();
            _referencedPolygonDecoder        = this.GetReferencedPolygonDecoder();
            _referencedRectangleDecoder      = this.GetReferencedRectangleDecoder();
        }
示例#2
0
        /// <summary>
        /// Creates a new referenced decoder.
        /// </summary>
        public ReferencedDecoderBase(BasicRouterDataSource <LiveEdge> graph, Vehicle vehicle, Decoder locationDecoder, Meter maxVertexDistance,
                                     float candidateSearchBoxSize)
            : base(locationDecoder)
        {
            _graph                  = graph;
            _maxVertexDistance      = maxVertexDistance;
            _vehicle                = vehicle;
            _candidateSearchBoxSize = candidateSearchBoxSize;

            _referencedCircleDecoder         = this.GetReferencedCircleDecoder();
            _referencedGeoCoordinateDecoder  = this.GetReferencedGeoCoordinateDecoder();
            _referencedGridDecoder           = this.GetReferencedGridDecoder();
            _referencedLineDecoder           = this.GetReferencedLineDecoder();
            _referencedPointAlongLineDecoder = this.GetReferencedPointAlongLineDecoder();
            _referencedPolygonDecoder        = this.GetReferencedPolygonDecoder();
            _referencedRectangleDecoder      = this.GetReferencedRectangleDecoder();
        }
示例#3
0
        /// <summary>
        /// Converts this referenced location to a geometry.
        /// </summary>
        /// <returns></returns>
        public FeatureCollection ToFeatures(BasicRouterDataSource <LiveEdge> graph)
        {
            var featureCollection = new FeatureCollection();
            var geometryFactory   = new GeometryFactory();

            // build coordinates list.
            var   coordinates = new List <Coordinate>();
            float latitude, longitude;

            graph.GetVertex(this.Vertex, out latitude, out longitude);
            coordinates.Add(new Coordinate(longitude, latitude));

            var edgeShape = graph.GetEdgeShape(this.Vertex, this.TargetVertex);

            if (edgeShape != null)
            {
                for (int coordIdx = 0; coordIdx < edgeShape.Length; coordIdx++)
                {
                    coordinates.Add(new Coordinate()
                    {
                        X = edgeShape[coordIdx].Longitude,
                        Y = edgeShape[coordIdx].Latitude
                    });
                }
            }

            var tags  = graph.TagsIndex.Get(this.Edge.Tags);
            var table = tags.ToAttributes();

            graph.GetVertex(this.TargetVertex, out latitude, out longitude);
            coordinates.Add(new Coordinate(longitude, latitude));

            featureCollection.Add(new Feature(geometryFactory.CreateLineString(coordinates.ToArray()), table));

            return(featureCollection);
        }
示例#4
0
 /// <summary>
 /// Creates a new referenced live edge decoder.
 /// </summary>
 public ReferencedDecoderBaseLiveEdge(BasicRouterDataSource <LiveEdge> graph, Vehicle vehicle, Decoder locationDecoder, Meter maxVertexDistance,
                                      float candidateSearchBoxSize)
     : base(graph, vehicle, locationDecoder, maxVertexDistance, candidateSearchBoxSize)
 {
 }
示例#5
0
 /// <summary>
 /// Creates a new referenced live edge decoder.
 /// </summary>
 public ReferencedDecoderBaseLiveEdge(BasicRouterDataSource <LiveEdge> graph, Vehicle vehicle, Decoder locationDecoder)
     : base(graph, vehicle, locationDecoder)
 {
 }
示例#6
0
 /// <summary>
 /// Creates a new referenced encoder.
 /// </summary>
 /// <param name="graph"></param>
 /// <param name="locationEncoder"></param>
 public ReferencedEncoderBase(BasicRouterDataSource <LiveEdge> graph, Encoder locationEncoder)
     : base(locationEncoder)
 {
     _graph = graph;
 }
示例#7
0
 /// <summary>
 /// Creates a new referenced live edge decoder.
 /// </summary>
 /// <param name="graph"></param>
 /// <param name="locationDecoder"></param>
 public ReferencedNWBDecoder(BasicRouterDataSource <LiveEdge> graph, Decoder locationDecoder)
     : base(graph, new global::OsmSharp.Routing.Shape.Vehicles.Car(NWBMapping.RIJRICHTNG, "H", "T", string.Empty), locationDecoder)
 {
 }
示例#8
0
 /// <summary>
 /// Creates a new referenced NWB decoder.
 /// </summary>
 /// <param name="graph">The graph containing the NWB network.</param>
 /// <param name="rawLocationDecoder">The raw location decoder.</param>
 /// <returns></returns>
 public static ReferencedNWBDecoder Create(BasicRouterDataSource <LiveEdge> graph, Decoder rawLocationDecoder)
 {
     return(new ReferencedNWBDecoder(graph, rawLocationDecoder));
 }
示例#9
0
 /// <summary>
 /// Creates a new referenced NWB decoder.
 /// </summary>
 /// <param name="graph">The graph containing the NWB network.</param>
 /// <returns></returns>
 public static ReferencedNWBDecoder CreateBinary(BasicRouterDataSource <LiveEdge> graph)
 {
     return(ReferencedNWBDecoder.Create(graph, new OpenLR.Binary.BinaryDecoder()));
 }
        public void EncodedReferencedPointAlongLineLocation()
        {
            // build a graph to encode from.
            var  tags            = new TagsTableCollectionIndex();
            var  graphDataSource = new DynamicGraphRouterDataSource <LiveEdge>(tags);
            uint vertex1         = graphDataSource.AddVertex(49.60597f, 6.12829f);
            uint vertex2         = graphDataSource.AddVertex(49.60521f, 6.12779f);

            graphDataSource.AddEdge(vertex1, vertex2, new LiveEdge()
            {
                Distance = 10,
                Forward  = true,
                Tags     = tags.Add(new TagsCollection(
                                        Tag.Create("BAANSUBSRT", "VBD"),
                                        Tag.Create("WEGBEHSRT", "R"),
                                        Tag.Create("WEGNUMMER", string.Empty),
                                        Tag.Create("RIJRICHTNG", "N")))
            }, null);
            graphDataSource.AddEdge(vertex2, vertex1, new LiveEdge()
            {
                Distance = 10,
                Forward  = false,
                Tags     = tags.Add(new TagsCollection(
                                        Tag.Create("BAANSUBSRT", "VBD"),
                                        Tag.Create("WEGBEHSRT", "R"),
                                        Tag.Create("WEGNUMMER", string.Empty),
                                        Tag.Create("RIJRICHTNG", "N"),
                                        Tag.Create("HECTOLTTR", string.Empty)))
            }, null);

            // create a referenced location and encode it.
            var graph = new BasicRouterDataSource <LiveEdge>(graphDataSource);
            var referencedPointAlongLineLocation = new ReferencedPointAlongLine();

            referencedPointAlongLineLocation.Route          = new ReferencedLine(graph);
            referencedPointAlongLineLocation.Route.Edges    = new LiveEdge[1];
            referencedPointAlongLineLocation.Route.Edges[0] = new LiveEdge()
            {
                Distance = 10,
                Forward  = true,
                Tags     = tags.Add(new TagsCollection(
                                        Tag.Create("BAANSUBSRT", "VBD"),
                                        Tag.Create("WEGBEHSRT", "R"),
                                        Tag.Create("WEGNUMMER", string.Empty),
                                        Tag.Create("RIJRICHTNG", "N"),
                                        Tag.Create("HECTOLTTR", string.Empty)))
            };
            referencedPointAlongLineLocation.Route.EdgeShapes    = new GeoCoordinateSimple[1][];
            referencedPointAlongLineLocation.Route.EdgeShapes[0] = new GeoCoordinateSimple[0];
            referencedPointAlongLineLocation.Route.Vertices      = new long[2];
            referencedPointAlongLineLocation.Route.Vertices[0]   = vertex1;
            referencedPointAlongLineLocation.Route.Vertices[1]   = vertex2;
            referencedPointAlongLineLocation.Latitude            = (49.60597f + 49.60521f) / 2f;
            referencedPointAlongLineLocation.Longitude           = (6.12829f + 6.12779f) / 2f;

            // encode location.
            var encoder           = new PointAlongLineEncoder();
            var mainEncoder       = new ReferencedNWBEncoder(graph, null);
            var referencedEncoder = new ReferencedPointAlongLineEncoder(mainEncoder, encoder);
            var location          = referencedEncoder.EncodeReferenced(referencedPointAlongLineLocation);

            // test result.
            Assert.IsNotNull(location);
            Assert.AreEqual(SideOfRoad.OnOrAbove, location.SideOfRoad);
            Assert.AreEqual(Orientation.NoOrientation, location.Orientation);
            Assert.AreEqual(50, location.PositiveOffsetPercentage.Value, 0.5f);

            Assert.AreEqual(49.60597f, location.First.Coordinate.Latitude);
            Assert.AreEqual(6.12829f, location.First.Coordinate.Longitude);
            Assert.AreEqual(91, location.First.DistanceToNext);
            Assert.AreEqual(FormOfWay.SlipRoad, location.First.FormOfWay);
            Assert.AreEqual(FunctionalRoadClass.Frc0, location.First.FuntionalRoadClass);
            Assert.AreEqual(FunctionalRoadClass.Frc0, location.First.LowestFunctionalRoadClassToNext);

            Assert.AreEqual(49.60521f, location.Last.Coordinate.Latitude);
            Assert.AreEqual(6.12779f, location.Last.Coordinate.Longitude);

            // TODO: encode location with a point on or at the first and last points.
        }
示例#11
0
        public void DecodeReferencedLineLocation()
        {
            // build the location to decode.
            var location = new LineLocation();

            location.First            = new LocationReferencePoint();
            location.First.Coordinate = new Coordinate()
            {
                Latitude = 49.60851, Longitude = 6.12683
            };
            location.First.DistanceToNext     = 517;
            location.First.FuntionalRoadClass = FunctionalRoadClass.Frc3;
            location.First.FormOfWay          = FormOfWay.MultipleCarriageWay;
            location.First.LowestFunctionalRoadClassToNext = FunctionalRoadClass.Frc3;
            location.First.Bearing              = 0;
            location.Intermediate               = new LocationReferencePoint[1];
            location.Intermediate[0]            = new LocationReferencePoint();
            location.Intermediate[0].Coordinate = new Coordinate()
            {
                Latitude = 49.60398, Longitude = 6.12838
            };
            location.Intermediate[0].DistanceToNext     = 104;
            location.Intermediate[0].FuntionalRoadClass = FunctionalRoadClass.Frc3;
            location.Intermediate[0].FormOfWay          = FormOfWay.SingleCarriageWay;
            location.Intermediate[0].LowestFunctionalRoadClassToNext = FunctionalRoadClass.Frc5;
            location.Intermediate[0].Bearing = 0;
            location.Last            = new LocationReferencePoint();
            location.Last            = new LocationReferencePoint();
            location.Last.Coordinate = new Coordinate()
            {
                Latitude = 49.60305, Longitude = 6.12817
            };
            location.Last.DistanceToNext     = 0;
            location.Last.FuntionalRoadClass = FunctionalRoadClass.Frc5;
            location.Last.FormOfWay          = FormOfWay.SingleCarriageWay;
            location.Last.Bearing            = 0;

            // build a graph to decode onto.
            var  tags            = new TagsTableCollectionIndex();
            var  graphDataSource = new DynamicGraphRouterDataSource <LiveEdge>(tags);
            uint vertex1         = graphDataSource.AddVertex(49.60851f, 6.12683f);
            uint vertex2         = graphDataSource.AddVertex(49.60398f, 6.12838f);
            uint vertex3         = graphDataSource.AddVertex(49.60305f, 6.12817f);

            graphDataSource.AddEdge(vertex1, vertex2, new LiveEdge()
            {
                Distance = 517,
                Forward  = true,
                Tags     = tags.Add(new TagsCollection(Tag.Create("highway", "tertiary")))
            }, null);
            graphDataSource.AddEdge(vertex2, vertex1, new LiveEdge()
            {
                Distance = 517,
                Forward  = true,
                Tags     = tags.Add(new TagsCollection(Tag.Create("highway", "tertiary")))
            }, null);
            graphDataSource.AddEdge(vertex2, vertex3, new LiveEdge()
            {
                Distance = 104,
                Forward  = true,
                Tags     = tags.Add(new TagsCollection(Tag.Create("highway", "tertiary")))
            }, null);
            graphDataSource.AddEdge(vertex3, vertex2, new LiveEdge()
            {
                Distance = 104,
                Forward  = true,
                Tags     = tags.Add(new TagsCollection(Tag.Create("highway", "tertiary")))
            }, null);

            // decode the location
            var graph              = new BasicRouterDataSource <LiveEdge>(graphDataSource);
            var decoder            = new LineLocationDecoder();
            var router             = new BasicRouter();
            var mainDecoder        = new ReferencedOsmDecoder(graph, new BinaryDecoder());
            var referencedDecoder  = new ReferencedLineDecoder(mainDecoder, decoder);
            var referencedLocation = referencedDecoder.Decode(location);

            // confirm result.
            Assert.IsNotNull(referencedLocation);
            Assert.IsNotNull(referencedLocation.Vertices);
            Assert.AreEqual(3, referencedLocation.Vertices.Length);
            Assert.IsNotNull(referencedLocation.Edges);
            Assert.AreEqual(2, referencedLocation.Edges.Length);
        }
示例#12
0
 /// <summary>
 /// Creates a new referenced line.
 /// </summary>
 /// <param name="graph"></param>
 public ReferencedLine(BasicRouterDataSource <LiveEdge> graph)
 {
     _graph = graph;
 }
示例#13
0
 /// <summary>
 /// Creates a new referenced live edge decoder.
 /// </summary>
 public ReferencedMultiNetDecoder(BasicRouterDataSource <LiveEdge> graph, Decoder locationDecoder, Meter maxVertexDistance,
                                  float candidateSearchBoxSize)
     : base(graph, new global::OsmSharp.Routing.Shape.Vehicles.Car("ONEWAY", "FT", "TF", string.Empty), locationDecoder, maxVertexDistance,
            candidateSearchBoxSize)
 {
 }
示例#14
0
 /// <summary>
 /// Creates a new referenced live edge decoder.
 /// </summary>
 /// <param name="graph"></param>
 /// <param name="locationDecoder"></param>
 public ReferencedMultiNetDecoder(BasicRouterDataSource <LiveEdge> graph, Decoder locationDecoder)
     : base(graph, new global::OsmSharp.Routing.Shape.Vehicles.Car("ONEWAY", "FT", "TF", string.Empty), locationDecoder)
 {
 }
示例#15
0
 /// <summary>
 /// Creates a new referenced MultiNet encoder.
 /// </summary>
 /// <param name="graph">The graph containing the MultiNet network.</param>
 /// <param name="rawLocationEncoder">The raw location encoder.</param>
 /// <returns></returns>
 public static ReferencedMultiNetEncoder Create(BasicRouterDataSource <LiveEdge> graph, Encoder rawLocationEncoder)
 {
     return(new ReferencedMultiNetEncoder(graph, rawLocationEncoder));
 }
示例#16
0
 /// <summary>
 /// Creates a new referenced live edge decoder.
 /// </summary>
 /// <param name="graph"></param>
 /// <param name="locationEncoder"></param>
 public ReferencedOsmEncoder(BasicRouterDataSource <LiveEdge> graph, Encoder locationEncoder)
     : base(graph, locationEncoder)
 {
 }
示例#17
0
 /// <summary>
 /// Creates a new referenced Osm decoder.
 /// </summary>
 /// <param name="graph">The graph containing the Osm network.</param>
 /// <param name="maxVertexDistance">The maximum vertex distance.</param>
 /// <returns></returns>
 public static ReferencedOsmDecoder CreateBinary(BasicRouterDataSource <LiveEdge> graph, Meter maxVertexDistance)
 {
     return(ReferencedOsmDecoder.Create(graph, new OpenLR.Binary.BinaryDecoder(), maxVertexDistance));
 }
示例#18
0
        public void DecodeReferencedPointAlongLineLocation()
        {
            double delta = 0.0001;

            // build the location to decode.
            var location = new PointAlongLineLocation();

            location.First            = new LocationReferencePoint();
            location.First.Coordinate = new Coordinate()
            {
                Latitude = 49.60597, Longitude = 6.12829
            };
            location.First.DistanceToNext     = 92;
            location.First.FuntionalRoadClass = FunctionalRoadClass.Frc2;
            location.First.FormOfWay          = FormOfWay.MultipleCarriageWay;
            location.First.LowestFunctionalRoadClassToNext = FunctionalRoadClass.Frc2;
            location.First.Bearing   = 203;
            location.Last            = new LocationReferencePoint();
            location.Last.Coordinate = new Coordinate()
            {
                Latitude = 49.60521, Longitude = 6.12779
            };
            location.Last.DistanceToNext      = 10;
            location.Last.FuntionalRoadClass  = FunctionalRoadClass.Frc2;
            location.Last.FormOfWay           = FormOfWay.MultipleCarriageWay;
            location.Last.Bearing             = 23;
            location.PositiveOffsetPercentage = (float)((28.0 / 92.0) * 100.0);
            location.Orientation = Orientation.FirstToSecond;
            location.SideOfRoad  = SideOfRoad.Left;

            // build a graph to decode onto.
            var tags            = new TagsTableCollectionIndex();
            var graphDataSource = new DynamicGraphRouterDataSource <LiveEdge>(tags);
            var vertex1         = graphDataSource.AddVertex(49.60597f, 6.12829f);
            var vertex2         = graphDataSource.AddVertex(49.60521f, 6.12779f);

            graphDataSource.AddEdge(vertex1, vertex2, new LiveEdge()
            {
                Distance = 10,
                Forward  = true,
                Tags     = tags.Add(new TagsCollection(Tag.Create("highway", "tertiary")))
            }, null);
            graphDataSource.AddEdge(vertex2, vertex1, new LiveEdge()
            {
                Distance = 10,
                Forward  = true,
                Tags     = tags.Add(new TagsCollection(Tag.Create("highway", "tertiary")))
            }, null);

            // decode the location
            var graph              = new BasicRouterDataSource <LiveEdge>(graphDataSource);
            var decoder            = new PointAlongLineDecoder();
            var router             = new BasicRouter();
            var mainDecoder        = new ReferencedOsmDecoder(graph, new BinaryDecoder());
            var referencedDecoder  = new ReferencedPointAlongLineDecoder(mainDecoder, decoder);
            var referencedLocation = referencedDecoder.Decode(location);

            // confirm result.
            Assert.IsNotNull(referencedLocation);
            Assert.IsNotNull(referencedLocation.Route);
            Assert.IsNotNull(referencedLocation.Route.Edges);
            Assert.AreEqual(vertex1, referencedLocation.Route.Vertices[0]);
            Assert.AreEqual(vertex2, referencedLocation.Route.Vertices[1]);
            var longitudeReference = (location.Last.Coordinate.Longitude - location.First.Coordinate.Longitude) * (location.PositiveOffsetPercentage.Value / 100.0) + location.First.Coordinate.Longitude;
            var latitudeReference  = (location.Last.Coordinate.Latitude - location.First.Coordinate.Latitude) * (location.PositiveOffsetPercentage.Value / 100.0) + location.First.Coordinate.Latitude;

            Assert.AreEqual(longitudeReference, referencedLocation.Longitude, delta);
            Assert.AreEqual(latitudeReference, referencedLocation.Latitude, delta);
            Assert.AreEqual(Orientation.FirstToSecond, referencedLocation.Orientation);
        }
示例#19
0
 /// <summary>
 /// Creates a new referenced Osm decoder.
 /// </summary>
 /// <param name="graph">The graph containing the Osm network.</param>
 /// <param name="rawLocationDecoder">The raw location decoder.</param>
 /// <param name="maxVertexDistance">The maximum vertex distance.</param>
 /// <returns></returns>
 public static ReferencedOsmDecoder Create(BasicRouterDataSource <LiveEdge> graph, Decoder rawLocationDecoder, Meter maxVertexDistance)
 {
     return(new ReferencedOsmDecoder(graph, rawLocationDecoder, maxVertexDistance));
 }
示例#20
0
 /// <summary>
 /// Creates a new referenced NWB decoder.
 /// </summary>
 /// <returns></returns>
 public static ReferencedNWBDecoder CreateBinary(BasicRouterDataSource <LiveEdge> graph, Meter maxVertexDistance,
                                                 float candidateSearchBoxSize)
 {
     return(ReferencedNWBDecoder.Create(graph, new OpenLR.Binary.BinaryDecoder(), maxVertexDistance, candidateSearchBoxSize));
 }
示例#21
0
 /// <summary>
 /// Creates a new referenced live edge decoder.
 /// </summary>
 /// <param name="graph"></param>
 /// <param name="locationDecoder"></param>
 public ReferencedOsmDecoder(BasicRouterDataSource <LiveEdge> graph, Decoder locationDecoder)
     : base(graph, Vehicle.Car, locationDecoder)
 {
 }
示例#22
0
 /// <summary>
 /// Creates a new referenced NWB decoder.
 /// </summary>
 /// <returns></returns>
 public static ReferencedNWBDecoder Create(BasicRouterDataSource <LiveEdge> graph, Decoder rawLocationDecoder, Meter maxVertexDistance, float candidateSearchBoxSize)
 {
     return(new ReferencedNWBDecoder(graph, rawLocationDecoder, maxVertexDistance, candidateSearchBoxSize));
 }
示例#23
0
 /// <summary>
 /// Creates a new referenced live edge decoder.
 /// </summary>
 /// <param name="graph"></param>
 /// <param name="locationDecoder"></param>
 /// <param name="maxVertexDistance"></param>
 public ReferencedOsmDecoder(BasicRouterDataSource <LiveEdge> graph, Decoder locationDecoder, Meter maxVertexDistance)
     : base(graph, Vehicle.Car, locationDecoder)
 {
     _maxVertexDistance = maxVertexDistance;
 }
示例#24
0
 /// <summary>
 /// Creates a new referenced live edge decoder.
 /// </summary>
 public ReferencedNWBDecoder(BasicRouterDataSource <LiveEdge> graph, Decoder locationDecoder, Meter maxVertexDistance,
                             float candidateSearchBoxSize)
     : base(graph, new global::OsmSharp.Routing.Shape.Vehicles.Car(NWBMapping.RIJRICHTNG, "H", "T", string.Empty), locationDecoder,
            maxVertexDistance, candidateSearchBoxSize)
 {
 }
        public void EncodeReferencedPointAlongLineLocation()
        {
            // build a graph to encode from.
            var  tags            = new TagsTableCollectionIndex();
            var  graphDataSource = new DynamicGraphRouterDataSource <LiveEdge>(tags);
            uint vertex1         = graphDataSource.AddVertex(49.60597f, 6.12829f);
            uint vertex2         = graphDataSource.AddVertex(49.60521f, 6.12779f);

            graphDataSource.AddEdge(vertex1, vertex2, new LiveEdge()
            {
                Distance = 10,
                Forward  = true,
                Tags     = tags.Add(new TagsCollection(Tag.Create("highway", "tertiary")))
            }, null);
            graphDataSource.AddEdge(vertex2, vertex1, new LiveEdge()
            {
                Distance = 10,
                Forward  = false,
                Tags     = tags.Add(new TagsCollection(Tag.Create("highway", "tertiary")))
            }, null);

            // create a referenced location and encode it.
            var graph = new BasicRouterDataSource <LiveEdge>(graphDataSource);
            var referencedPointAlongLineLocation = new ReferencedPointAlongLine();

            referencedPointAlongLineLocation.Route          = new ReferencedLine(graph);
            referencedPointAlongLineLocation.Route.Edges    = new LiveEdge[1];
            referencedPointAlongLineLocation.Route.Edges[0] = new LiveEdge()
            {
                Distance = 10,
                Forward  = true,
                Tags     = tags.Add(new TagsCollection(Tag.Create("highway", "tertiary")))
            };
            referencedPointAlongLineLocation.Route.EdgeShapes    = new GeoCoordinateSimple[1][];
            referencedPointAlongLineLocation.Route.EdgeShapes[0] = new GeoCoordinateSimple[0];
            referencedPointAlongLineLocation.Route.Vertices      = new long[2];
            referencedPointAlongLineLocation.Route.Vertices[0]   = vertex1;
            referencedPointAlongLineLocation.Route.Vertices[1]   = vertex2;
            referencedPointAlongLineLocation.Latitude            = (49.60597f + 49.60521f) / 2f;
            referencedPointAlongLineLocation.Longitude           = (6.12829f + 6.12779f) / 2f;

            // encode location.
            var encoder           = new PointAlongLineEncoder();
            var router            = new Dykstra();
            var mainEncoder       = new ReferencedOsmEncoder(graph, null);
            var referencedEncoder = new ReferencedPointAlongLineEncoder(mainEncoder, encoder);
            var location          = referencedEncoder.EncodeReferenced(referencedPointAlongLineLocation);

            // test result.
            Assert.IsNotNull(location);
            Assert.AreEqual(SideOfRoad.OnOrAbove, location.SideOfRoad);
            Assert.AreEqual(Orientation.NoOrientation, location.Orientation);
            Assert.AreEqual(50, location.PositiveOffsetPercentage.Value, 0.5f);

            Assert.AreEqual(49.60597f, location.First.Coordinate.Latitude);
            Assert.AreEqual(6.12829f, location.First.Coordinate.Longitude);
            Assert.AreEqual(91, location.First.DistanceToNext);
            Assert.AreEqual(203, location.First.Bearing);
            Assert.AreEqual(FormOfWay.SingleCarriageWay, location.First.FormOfWay);
            Assert.AreEqual(FunctionalRoadClass.Frc3, location.First.FuntionalRoadClass);
            Assert.AreEqual(FunctionalRoadClass.Frc3, location.First.LowestFunctionalRoadClassToNext);

            Assert.AreEqual(49.60521f, location.Last.Coordinate.Latitude);
            Assert.AreEqual(6.12779f, location.Last.Coordinate.Longitude);
            Assert.AreEqual(23, location.Last.Bearing);

            // encode location with a point on the first point.
            referencedPointAlongLineLocation                = new ReferencedPointAlongLine();
            referencedPointAlongLineLocation.Route          = new ReferencedLine(graph);
            referencedPointAlongLineLocation.Route.Edges    = new LiveEdge[1];
            referencedPointAlongLineLocation.Route.Edges[0] = new LiveEdge()
            {
                Distance = 10,
                Forward  = true,
                Tags     = tags.Add(new TagsCollection(Tag.Create("highway", "tertiary")))
            };
            referencedPointAlongLineLocation.Route.EdgeShapes    = new GeoCoordinateSimple[1][];
            referencedPointAlongLineLocation.Route.EdgeShapes[0] = new GeoCoordinateSimple[0];
            referencedPointAlongLineLocation.Route.Vertices      = new long[2];
            referencedPointAlongLineLocation.Route.Vertices[0]   = vertex1;
            referencedPointAlongLineLocation.Route.Vertices[1]   = vertex2;
            referencedPointAlongLineLocation.Latitude            = 49.60597f;
            referencedPointAlongLineLocation.Longitude           = 6.12829f;

            // encode location.
            location = referencedEncoder.EncodeReferenced(referencedPointAlongLineLocation);

            // test result.
            Assert.IsNotNull(location);
            Assert.AreEqual(SideOfRoad.OnOrAbove, location.SideOfRoad);
            Assert.AreEqual(Orientation.NoOrientation, location.Orientation);
            Assert.AreEqual(0, location.PositiveOffsetPercentage);

            Assert.AreEqual(49.60597f, location.First.Coordinate.Latitude);
            Assert.AreEqual(6.12829f, location.First.Coordinate.Longitude);
            Assert.AreEqual(91, location.First.DistanceToNext);
            Assert.AreEqual(FormOfWay.SingleCarriageWay, location.First.FormOfWay);
            Assert.AreEqual(FunctionalRoadClass.Frc3, location.First.FuntionalRoadClass);
            Assert.AreEqual(FunctionalRoadClass.Frc3, location.First.LowestFunctionalRoadClassToNext);

            Assert.AreEqual(49.60521f, location.Last.Coordinate.Latitude);
            Assert.AreEqual(6.12779f, location.Last.Coordinate.Longitude);

            // encode location with a point on the last point.
            referencedPointAlongLineLocation                = new ReferencedPointAlongLine();
            referencedPointAlongLineLocation.Route          = new ReferencedLine(graph);
            referencedPointAlongLineLocation.Route.Edges    = new LiveEdge[1];
            referencedPointAlongLineLocation.Route.Edges[0] = new LiveEdge()
            {
                Distance = 10,
                Forward  = true,
                Tags     = tags.Add(new TagsCollection(Tag.Create("highway", "tertiary")))
            };
            referencedPointAlongLineLocation.Route.EdgeShapes    = new GeoCoordinateSimple[1][];
            referencedPointAlongLineLocation.Route.EdgeShapes[0] = new GeoCoordinateSimple[0];
            referencedPointAlongLineLocation.Route.Vertices      = new long[2];
            referencedPointAlongLineLocation.Route.Vertices[0]   = vertex1;
            referencedPointAlongLineLocation.Route.Vertices[1]   = vertex2;
            referencedPointAlongLineLocation.Latitude            = 49.60521f;
            referencedPointAlongLineLocation.Longitude           = 6.12779f;

            // encode location.
            location = referencedEncoder.EncodeReferenced(referencedPointAlongLineLocation);

            // test result.
            Assert.IsNotNull(location);
            Assert.AreEqual(SideOfRoad.OnOrAbove, location.SideOfRoad);
            Assert.AreEqual(Orientation.NoOrientation, location.Orientation);
            Assert.AreEqual(99, location.PositiveOffsetPercentage.Value);

            Assert.AreEqual(49.60597f, location.First.Coordinate.Latitude);
            Assert.AreEqual(6.12829f, location.First.Coordinate.Longitude);
            Assert.AreEqual(91, location.First.DistanceToNext);
            Assert.AreEqual(FormOfWay.SingleCarriageWay, location.First.FormOfWay);
            Assert.AreEqual(FunctionalRoadClass.Frc3, location.First.FuntionalRoadClass);
            Assert.AreEqual(FunctionalRoadClass.Frc3, location.First.LowestFunctionalRoadClassToNext);

            Assert.AreEqual(49.60521f, location.Last.Coordinate.Latitude);
            Assert.AreEqual(6.12779f, location.Last.Coordinate.Longitude);
        }