Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Routing distance between matched points #35

Closed
RobKoch opened this issue Oct 23, 2016 · 2 comments
Closed

Routing distance between matched points #35

RobKoch opened this issue Oct 23, 2016 · 2 comments
Labels

Comments

@RobKoch
Copy link

RobKoch commented Oct 23, 2016

First of all, this library is amazing! Thanks so much for providing us with such great work.

Is there any simple way to include the routing distance between two matched points in the debug output (e.g. by changing the source code)? To make my point clear, I'd like to give an example. For instance, the following JSON sample shows two matched points for two given GPS points. I'd like to include the routing distance between POINT (9.37383970739068 47.429504725440154) and POINT (9.373731696208619 47.429421380914064).

I'm thankful for any advice!

{
    "id": "bad25e18-4fb8-4874-9561-c8a3ac02081b",
    "point": {
      "road": 374570,
      "heading": "forward",
      "frac": 0.038874758720377
    },
    "time": 1457954691,
    "road_edge": 749140,
    "seqprob": -2.5891656830773,
    "geom": "LINESTRING (9.3738989 47.4295504, 9.3738989 47.4295504, 9.37383970739068 47.429504725440154)",
    "transition": {
      "route": {
        "source": {
          "road": 374570,
          "heading": "backward",
          "frac": 1
        },
        "target": {
          "road": 374570,
          "heading": "forward",
          "frac": 0.038874758720377
        },
        "roads": [
          {
            "road": 374570,
            "heading": "backward"
          },
          {
            "road": 374570,
            "heading": "forward"
          }
        ]
      }
    },
    "point_matched": "POINT (9.37383970739068 47.429504725440154)",
    "filtprob": 0.31211030877409,
    "frac": 0.038874758720377
  },
  {
    "id": "90b458bf-de66-4a6e-8675-7b38904a212a",
    "point": {
      "road": 374570,
      "heading": "forward",
      "frac": 0.10981129879372
    },
    "time": 1457954692,
    "road_edge": 749140,
    "seqprob": -4.2432779916644,
    "geom": "LINESTRING (9.37383970739068 47.429504725440154, 9.373731696208619 47.429421380914064)",
    "transition": {
      "route": {
        "source": {
          "road": 374570,
          "heading": "forward",
          "frac": 0.038874758720377
        },
        "target": {
          "road": 374570,
          "heading": "forward",
          "frac": 0.10981129879372
        },
        "roads": [
          {
            "road": 374570,
            "heading": "forward"
          }
        ]
      }
    },
    "point_matched": "POINT (9.373731696208619 47.429421380914064)",
    "filtprob": 0.40308485166153,
    "frac": 0.10981129879372
  }
@smattheis
Copy link

smattheis commented Oct 23, 2016

Thanks for the kind words. You have mutliple options:

  1. In the MatcherKState class (https://github.com/bmwcarit/barefoot/blob/master/src/main/java/com/bmwcarit/barefoot/matcher/MatcherKState.java), you could add something like jsoncandidate.put("length", candidate.transition().route().length());right after line 123 in the body of the if-statement.
  2. Since you add the JSON of the transition/route, you could also add json.put("length", length()); in the Route class (https://github.com/bmwcarit/barefoot/blob/master/src/main/java/com/bmwcarit/barefoot/roadmap/Route.java) after line 240.

Route#length() returns the length of the route in meters.

@RobKoch
Copy link
Author

RobKoch commented Oct 24, 2016

Splendid, that works quite well! Thanks for your quick reply.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants