Skip to content

Improvements to JSON format of web module #437

Open

Description

@karussell

Ideas for a new "version 2" of the /route endpoint:

request:

  • use JSON request instead URL parameter
  • keep the name /route but just support POST? /flexible would make no sense as we want to use the advantages of a POST request also for CH that is currently not flexible.
  • remove insecure JSONP
  • The input point should be better named e.g. waypoint then one can easily use waypoints for the output JSON name, see JSON output should contain snapped points for start, destination and via points #727
  • use waypoints_order instead of points_order
  • include heading for all instructions?
  • way_point_max_distance clashes with max_waypoint_distance see Added Max Point Distance for Non-Ch Requests #872
  • vehicle vs. profile (e.g. foot is no vehicle)
  • should we make ch.disable=true the new default? Or even use LM as the new default? Not now.
  • make input and output points more consistent all using [lon,lat,elevation] and output using GeoJSON? Same applies to the polyline encoding: the encoded string for points and snapped_waypoints has the order lat,lon,elevation to make it compatible with other clients but we should use lon,lat,elevation

response:

  • different APIs of the Directions API should use same time unit: seconds (currently routing API has ms)
  • different layout for via-points? 'legs', what about changing the vehicle -> multi modal?
  • turn_angle is in radian
  • Also see Add speed, time and more informations to instructions #439 as some properties could be per edge not per instruction
  • change default for GPX: export only track?
  • use different wording for points e.g. use geometry?
  • use different wording for paths e.g. routes?
  • info endpoint should be improved, either via profile_x:{} (and remove features) or a different layout
  • remove 'took' from output, see Remove took from json, use header instead #457
  • make i18n response more consistent or remove the need for a separate endpoint
  • do not use the same JSON entry points for encoded polyline and GeoJSON as we get problems with OpenAPI spec (alternatives not possible) when the user would try to do the decoding on his side with an autogenerated client

Activity

  1. michaz commented on May 12, 2017

    @michaz
    Member

    use JSON request instead URL parameter

    Are there any examples where this is considered a good idea? I thought the whole point about REST was that a resource is identified by its URL alone, and a shortest path is the perfect example of a resource.

    navitia.io seems to agree.

  2. karussell commented on May 12, 2017

    @karussell
    MemberAuthor

    Are there any examples where this is considered a good idea?

    ElasticSearch, our Route Optimization API, mapzen, ...

    I thought the whole point about REST was that a resource is identified by its URL alone, and a shortest path is the perfect example of a resource.

    Why? There are lots of possible parameters. E.g. it is time, vehicle size etc dependent. I do not see it as a resource. I see it more as a 'calculation job'...

  3. michaz commented on May 13, 2017

    @michaz
    Member

    Why?

    Because it doesn't change the world, because it returns the same result until it (the road network) is explicitly changed by something, because it can be cached.

    Google search is GET

    https://developers.google.com/custom-search/json-api/v1/using_rest

    I realize that POST can always be used as a universal remote procedure call, but from what little I know about the "principled" web stuff, my impression is that this is a typical GET.

    (at least the things which are fast enough that they return the result instantly, and don't need a "calculation job" as an extra resource to think about)

    But perhaps it isn't so important.

    And, of course, as soon as you start thinking about subscriptions to routes (so that you are pushed when road conditions change), then it's definitely a calculation job, true.

  4. michaz commented on May 13, 2017

    @michaz
    Member

    remove insecure JSONP?

    +1 (At least from the software. From the service, I don't mind.)

    Not only because security, but also because we are not a web framework.

    I think in a few years we will say "Oh, you want our API a bit different? Go use a web tool to click together a proxy/gateway which changes it like you want it."

  5. karussell commented on May 13, 2017

    @karussell
    MemberAuthor

    because it returns the same result until it (the road network) is explicitly changed by something, because it can be cached

    I would argue against this (as real time road changes will invalidate this and it is unclear which routes to invalidate), but I think this is indeed discussible :)

    Let me give you one "beauty" argument as why we shouldn't care much about principled web stuff here:

    we'll be able to configure a CH vehicle profiles with a JSON file. Also the default vehicle profiles for non-CH should be configurable by JSON and now, we are forced due to beauty reasons ;), to use the same JSON to request our API to dynamically change the vehicle profile per request.

    And, of course, as soon as you start thinking about subscriptions to routes

    Yes, but then you could also argue about a resource that you subscribe to. BTW: navitia api is reeaally old ;)

  6. michaz commented on May 13, 2017

    @michaz
    Member

    we'll be able to configure a CH vehicle profiles with a JSON file. Also the default vehicle profiles for non-CH should be configurable by JSON and now, we are forced due to beauty reasons ;), to use the same JSON to request our API to dynamically change the vehicle profile per request.

    I'm not sure I understood whether you think this is good or bad.

    So you want to use the same JSON description of a vehicle profile, no matter if you are

    • creating a pre-computed profile
    • giving request parameters to the flexible router

    Correct?

    Yeah, that sounds like a good thing.

  7. michaz commented on May 13, 2017

    @michaz
    Member

    Or did you mean that we do not want this, because it would be overdoing it? But then I don't see the connection to POST with JSON, because then we can use JSON for configuring the pre-computation and URL parameters for the request and nobody cares.

  8. karussell commented on May 13, 2017

    @karussell
    MemberAuthor

    So you want to use the same JSON description of a vehicle profile, no matter if you are

    Yes, I meant this and I think this as a good thing :) There is also a third use case where you change defaults e.g. of car to toll=no or ferry=no etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions