itinero / OpenLR

A C# Implementation of the OpenLR specification using Itinero.
https://www.itinero.tech
Other
18 stars 12 forks source link

Encoding or Decoding fails when Longitude is -ve #76

Closed idbates closed 7 years ago

idbates commented 7 years ago

The following is a modified version of Samples.OSM Program.cs - it uses a OSM pbf file of the Derbyshire in the UK. When the binary OpenLR is decoded the decode codec returns Longitude location -178. Code decode worked for sample in Cambridgeshire UK with a positive Longitude. Link to OSM data used to create issue https://1drv.ms/u/s!AkOVlf_yN86BidVJDq2vnRX5H9UEUg

        // build routerdb from raw OSM data.
        // check this for more info on RouterDb's: https://github.com/itinero/routing/wiki/RouterDb
        var routerDb = new RouterDb();
        using (var sourceStream = File.OpenRead(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "derbyshire.osm.pbf")))
        {
            routerDb.LoadOsmData(sourceStream, Vehicle.Car);
        }

        // create coder.
        var coder = new Coder(routerDb, new OsmCoderProfile());

        // build a line location from a shortest path.
        // REMARK: this functionality is NOT part of the OpenLR-spec, just a convenient way to build a line location.

        var line = coder.BuildLine(new Itinero.LocalGeo.Coordinate(52.932129f, -1.521154f),
            new Itinero.LocalGeo.Coordinate(52.929387f, -1.505844f));
        var lineGeoJson = line.ToFeatures(coder.Router.Db).ToGeoJson();

        // encode this location.
        var encoded = coder.Encode(line);
        Console.WriteLine(encoded);

        // decode this location.
        var decodedLine = coder.Decode(encoded) as ReferencedLine;
        var decodedLineGeoJson = decodedLine.ToFeatures(coder.Router.Db).ToGeoJson();

        Console.ReadLine();

image

image

xivk commented 7 years ago

Ouwch, thanks for reporting...

idbates commented 7 years ago

Hi Ben,

Thanks for acknowledging the issue. Any idea when you might get around to fixing this? We were looking at using Itinero/OpenLR to decode OpenLR from a TomTom traffic feed. There aren’t really many alternatives around in .NET unless we either write our own or port TomTom OpenLR.org code from Java.

Thanks, Ian Bates, MEng MIET MCTS Principal Software Developer, Transportation D +44 (0)191 224 6523 ian.bates@aecom.commailto:ian.bates@aecom.com AECOM First Floor, One Trinity Gardens Quayside, Newcastle upon Tyne, NE1 2HF T +44 (0)191 224 6500 F +44 (0)191 224 6599 www.aecom.comhttp://www.aecom.com/

AECOM and URS have joined together as one company. Learn morehttp://www.aecom.com/

From: Ben Abelshausen [mailto:notifications@github.com] Sent: 09 March 2017 17:21 To: itinero/OpenLR Cc: Bates, Ian; Author Subject: Re: [itinero/OpenLR] Encoding or Decoding fails when Longitude is -ve (#76)

Ouwch, thanks for reporting...

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/itinero/OpenLR/issues/76#issuecomment-285418525, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AG5KOMPvsf33lOM_iQiRRUIY4lHOOiFPks5rkDUQgaJpZM4MXXwB.

xivk commented 7 years ago

Verified and tests, this decodes now fine to:

http://geojson.io/#id=gist:anonymous/c66ff1deb844ec84d8a39de3da89c5cb&map=16/52.9307/-1.5135

idbates commented 7 years ago

Thanks!

Ian Bates, MEng MIET MCTS Principal Software Developer, Transportation D +44 (0)191 224 6523 ian.bates@aecom.commailto:ian.bates@aecom.com AECOM First Floor, One Trinity Gardens Quayside, Newcastle upon Tyne, NE1 2HF T +44 (0)191 224 6500 F +44 (0)191 224 6599 www.aecom.comhttp://www.aecom.com/

AECOM and URS have joined together as one company. Learn morehttp://www.aecom.com/

From: Ben Abelshausen [mailto:notifications@github.com] Sent: 17 March 2017 11:15 To: itinero/OpenLR Cc: Bates, Ian; Author Subject: Re: [itinero/OpenLR] Encoding or Decoding fails when Longitude is -ve (#76)

Verified and tests, this decodes now fine to:

http://geojson.io/#id=gist:anonymous/c66ff1deb844ec84d8a39de3da89c5cb&map=16/52.9307/-1.5135

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/itinero/OpenLR/issues/76#issuecomment-287328596, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AG5KODri_gUWcX14STYBOg2v3D9Qvgmgks5rmms5gaJpZM4MXXwB.