示例#1
0
        public void TestRegressionDecode1()
        {
            string data          = "CwMVUCRPVxJYt9IEFkYScQYP";
            string geoJsonActual = "{\"type\":\"LineString\",\"coordinates\":[[4.3359875679016113,51.060848236083984],[4.335850715637207,51.060760498046875],[4.334843635559082,51.060855865478516],[4.3344945907592773,51.060886383056641],[4.33406925201416,51.0609130859375],[4.3313779830932617,51.061012268066406],[4.3303995132446289,51.061042785644531],[4.3293352127075195,51.061134338378906],[4.3285455703735352,51.061248779296875],[4.3269405364990234,51.061508178710938],[4.3250093460083008,51.061790466308594],[4.3239278793334961,51.061965942382812],[4.3231124877929688,51.062137603759766],[4.3220844268798828,51.062397003173828],[4.320711612701416,51.062847137451172],[4.3192791938781738,51.0634880065918],[4.31713342666626,51.064666748046875],[4.3153839111328125,51.065628051757812],[4.3107118606567383,51.068279266357422],[4.3084430694580078,51.069671630859375],[4.3065905570983887,51.071128845214844],[4.3063244819641113,51.071361541748047],[4.3056955337524414,51.071971893310547],[4.3053798675537109,51.072280883789062],[4.3051509857177734,51.072505950927734],[4.3041725158691406,51.073539733886719],[4.303675651550293,51.074043273925781],[4.3029775619506836,51.074745178222656],[4.3026752471923828,51.075027465820312],[4.3023591041564941,51.075298309326172],[4.3021035194396973,51.075511932373047],[4.3017449378967285,51.075771331787109],[4.3013901710510254,51.076007843017578],[4.3010897636413574,51.076210021972656],[4.3007535934448242,51.076408386230469],[4.3003439903259277,51.076633453369141],[4.3000245094299316,51.076801300048828],[4.298856258392334,51.0773811340332],[4.2980813980102539,51.077774047851562],[4.2970776557922363,51.078281402587891],[4.2965779304504395,51.078525543212891],[4.2960972785949707,51.078773498535156],[4.29279899597168,51.080398559570312],[4.2900562286376953,51.081764221191406],[4.2892160415649414,51.082183837890625],[4.2884082794189453,51.082588195800781],[4.2840476036071777,51.084754943847656],[4.2799005508422852,51.086818695068359],[4.2771029472351074,51.088191986083984],[4.2763633728027344,51.088531494140625],[4.2758951187133789,51.0887336730957],[4.2754759788513184,51.088924407958984],[4.2742376327514648,51.089462280273438],[4.27300500869751,51.089988708496094],[4.2701148986816406,51.091232299804688],[4.26772928237915,51.092247009277344],[4.2594938278198242,51.095787048339844],[4.2562212944030762,51.097202301025391],[4.252922534942627,51.098606109619141],[4.2521233558654785,51.098960876464844],[4.2499408721923828,51.099910736083984],[4.2495770454406738,51.100074768066406],[4.2486934661865234,51.1004524230957],[4.2477850914001465,51.1008415222168],[4.2434616088867188,51.102691650390625],[4.2430300712585449,51.102874755859375],[4.2373924255371094,51.105289459228516],[4.2359986305236816,51.105884552001953],[4.220517635345459,51.112506866455078],[4.2201657295227051,51.1126708984375],[4.2197279930114746,51.112892150878906],[4.2194104194641113,51.113067626953125],[4.2191100120544434,51.113273620605469],[4.2186551094055176,51.113624572753906],[4.2183289527893066,51.113929748535156],[4.2177948951721191,51.114604949951172],[4.2175607681274414,51.115093231201172],[4.2174534797668457,51.115676879882812],[4.2174396514892578,51.115940093994141],[4.2174715995788574,51.116191864013672],[4.2175202369689941,51.116523742675781],[4.217595100402832,51.116874694824219],[4.2177186012268066,51.117149353027344],[4.217808723449707,51.1172981262207],[4.2179837226867676,51.117595672607422],[4.2181568145751953,51.11785888671875]]}";

            // create a referenced decoder.
            var referencedDecoder = new ReferencedOsmDecoder(RealGraphOsm.GetRoutingGraph("puurs"), new BinaryDecoder());

            // decodes a location.
            var maxSettlesOriginal = BasicRouter.MaxSettles;

            BasicRouter.MaxSettles = 65536;
            var location = referencedDecoder.Decode(data);

            Assert.IsNotNull(location);
            var lineLocation         = location as ReferencedLine;
            var lineLocationGeometry = lineLocation.ToGeometry();

            BasicRouter.MaxSettles = maxSettlesOriginal;

            // write GeoJSON.
            var geoJsonWriter = new GeoJsonWriter();
            var geoJson       = geoJsonWriter.Write(lineLocationGeometry);

            Assert.IsNotNull(geoJson);
            AssertGeo.AreEqual(geoJsonActual, geoJson, 1);
        }
示例#2
0
        public void TestDecode3()
        {
            // this is an encoded line-location, but assume we don't know this.
            string data          = "CwM8tSQZgQs7EvvvAr4LCQ==";
            string geoJsonActual = "{\"type\":\"LineString\",\"coordinates\":[[4.5523185729980469,50.7650146484375],[4.5522303581237793,50.765064239501953],[4.55216121673584,50.765102386474609],[4.5513834953308105,50.765544891357422],[4.5506992340087891,50.765937805175781],[4.549346923828125,50.7667121887207],[4.5487337112426758,50.767177581787109],[4.54760217666626,50.767967224121094],[4.5467185974121094,50.768653869628906],[4.5454902648925781,50.769634246826172],[4.5442113876342773,50.770816802978516],[4.543121337890625,50.771892547607422],[4.5426936149597168,50.772018432617188],[4.5425186157226562,50.772056579589844],[4.5423049926757812,50.772087097167969],[4.5419602394104,50.772125244140625],[4.5418844223022461,50.772132873535156]]}";

            // create a referenced decoder.
            var referencedDecoder = new ReferencedOsmDecoder(RealGraphOsm.GetRoutingGraph("overijse"), new BinaryDecoder());

            // decodes a location.
            var location             = referencedDecoder.Decode(data);
            var lineLocation         = location as ReferencedLine;
            var lineLocationGeometry = lineLocation.ToGeometry();

            // write GeoJSON.
            var geoJsonWriter = new GeoJsonWriter();
            var geoJson       = geoJsonWriter.Write(lineLocationGeometry);

            Assert.IsNotNull(geoJson);
            AssertGeo.AreEqual(geoJsonActual, geoJson, 1);
        }
示例#3
0
        public void TestDecode2()
        {
            // this is an encoded line-location, but assume we don't know this.
            string data          = "CwM+IiQYtws7DPzyAbILCg==";
            string geoJsonActual = "{\"type\":\"LineString\",\"coordinates\":[[4.5598363876342773,50.760837554931641],[4.5597963333129883,50.760860443115234],[4.5595493316650391,50.760982513427734],[4.55853796005249,50.761508941650391],[4.5582680702209473,50.761661529541016],[4.5523185729980469,50.7650146484375]]}";

            // create a referenced decoder.
            var referencedDecoder = new ReferencedOsmDecoder(RealGraphOsm.GetRoutingGraph("overijse"), new BinaryDecoder());

            // decodes a location.
            var location             = referencedDecoder.Decode(data);
            var lineLocation         = location as ReferencedLine;
            var lineLocationGeometry = lineLocation.ToGeometry();

            // write GeoJSON.
            var geoJsonWriter = new GeoJsonWriter();
            var geoJson       = geoJsonWriter.Write(lineLocationGeometry);

            Assert.IsNotNull(geoJson);
            AssertGeo.AreEqual(geoJsonActual, geoJson, 1);
        }
示例#4
0
        public void TestDecode1()
        {
            // this is an encoded line-location, but assume we don't know this.
            string data          = "CwNIUCQL5gs8Ef/FA6sLDw==";
            string geoJsonActual = "{\"type\":\"LineString\",\"coordinates\":[[4.6161060333251953,50.690467834472656],[4.615666389465332,50.690864562988281],[4.6154966354370117,50.696247100830078],[4.615412712097168,50.697616577148438],[4.6153979301452637,50.698280334472656],[4.6153759956359863,50.698684692382812],[4.6153225898742676,50.699268341064453],[4.6153054237365723,50.699459075927734],[4.6152987480163574,50.699722290039062]]}";

            // create a referenced decoder.
            var referencedDecoder = new ReferencedOsmDecoder(RealGraphOsm.GetRoutingGraph("wavre"), new BinaryDecoder());

            // decodes a location.
            var location             = referencedDecoder.Decode(data);
            var lineLocation         = location as ReferencedLine;
            var lineLocationGeometry = lineLocation.ToGeometry();

            // write GeoJSON.
            var geoJsonWriter = new GeoJsonWriter();
            var geoJson       = geoJsonWriter.Write(lineLocationGeometry);

            Assert.IsNotNull(geoJson);
            AssertGeo.AreEqual(geoJsonActual, geoJson, 1);
        }
示例#5
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);
        }
示例#6
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);
        }