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

Expose user-defined class information #4203

Closed
TheMarex opened this issue Jun 27, 2017 · 4 comments
Closed

Expose user-defined class information #4203

TheMarex opened this issue Jun 27, 2017 · 4 comments
Milestone

Comments

@TheMarex
Copy link
Member

Breaking this out from #4006 we need a way to set a user-defined class per edge and use this in the server. This will enable features like displaying when a route is using a toll road, or a private road.

API Changes

Lua profile

Instead of hard-coding specific classes for #4006 we want to keep this more general. This requires us to have an interface in the profiles to mark ways with true/false if they fall into that class.

function way_function(way, result)
   result.classes['highway'] = way:get_value_by_key('highway') == 'motorway'
   result.classes['ferry'] =  way:get_value_by_key('route') == 'ferry'
end

HTTP/node

We can expose this as a new property classes in the RouteStep object, that is only there if there is class information for that step.

  • classes: An array of strings signifying the classes of the road as specified in the profile.

Example:

{
   "geometry" : "{lu_IypwpAVrAvAdI",
   "mode" : "driving",
   "classes": ["toll", "highway"],
   "duration" : 15.6,
   "weight" : 15.6,
   "intersections" : [
      {  "bearings" : [ 10, 92, 184, 270 ],
         "lanes" : [
            { "indications" : [ "left", "straight" ],
               "valid" : "false" },
            { "valid" : "true",
               "indications" : [ "right" ] }
         ],
         "out" : 2,
         "in" : 3,
         "entry" : [ "true", "true", "true", "false" ],
         "location" : [ 13.39677, 52.54366 ]
      },
      {  "out" : 1,
         "lanes" : [
            { "indications" : [ "straight" ],
               "valid" : "true" },
            { "indications" : [ "right" ],
               "valid" : "false" }
         ],
         "bearings" : [ 60, 240, 330 ],
         "in" : 0,
         "entry" : [ "false", "true", "true" ],
         "location" : [ 13.394718, 52.543096 ]
      }
   ],
   "name" : "Lortzingstraße",
   "distance" : 152.3,
   "maneuver" : {
      "modifier" : "right",
      "type" : "turn"
   }
}
@danpat
Copy link
Member

danpat commented Jun 27, 2017

We should probably add something to annotations as well, in case someone wants the full route details:

annotations : { "classes" : [ ["highway","ferry"], ["highway"],["highway"],["highway"],["ferry"],["ferry"],["highway","ferry"] ] }

This annotation, similar to speeds, would be per-segment along the route. I've described each segment using an array of strings, to support the case where a single segment belongs to multiple classes.

This would allow for correct rendering of various route sections if desired.

@emiltin
Copy link
Contributor

emiltin commented Jul 6, 2017

how will this work together with the mode, they are still separate flags?
for example, if the mode is ferry, i could potentially indicate 8 different types of ferry routes with the classes?

@TheMarex
Copy link
Member Author

TheMarex commented Jul 6, 2017

@emiltin yep separate flags.

@TheMarex
Copy link
Member Author

TheMarex commented Jul 6, 2017

This was added with #4204.

@TheMarex TheMarex closed this as completed Jul 6, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants