~mil/mobroute

13eb3b5f97e24ec631cab9f5cd3ab3b89cc82731 — Miles Alan 2 months ago 6b2b13a
Fill out documentation for doc cli guide with autogen cli doc
1 files changed, 66 insertions(+), 21 deletions(-)

M doc/userguide_cli.md
M doc/userguide_cli.md => doc/userguide_cli.md +66 -21
@@ 10,9 10,9 @@ Go codebase and then running routing requests locally.

- *1:* [Primer Documentation](#strongprimer-documentationstrong)
- *2:* [Mobroute CLI: Install & Running Custom Routing Requests](#strongmobroute-cli-install-amp-running-custom-routing-requestsstrong)
- *3:* [Mobroute CLI: Subcommands Documentation](#strongmobroute-cli-subcommands-documentationstrong)
- *4:* [Further Resources & Documentation](#strongfurther-resources-amp-documentationstrong)

- *3:* [Mobroute CLI: Route subcommand](#strongmobroute-cli-subcommands-documentationstrong)
- *4:* [Mobroute CLI: Mobsql subcommand](#strongmobroute-cli-subcommands-documentationstrong)
- *5:* [Further Resources & Documentation](#strongfurther-resources-amp-documentationstrong)

## **Primer Documentation**



@@ 28,6 28,9 @@ Go codebase and then running routing requests locally.
  - `git clone http://git.sr.ht/~mil/mobroute`
- (3) Build the Mobroute binary:
  - `./build.sh`



- (4) Run your routing request by passing the request as JSON:
  - ```sh
./mobroute route -rp '{


@@ 51,41 54,83 @@ Go codebase and then running routing requests locally.
    - The route is converted to GeoJSON and displayed as a URL link to a [web geojson rendering service](http://geojson.lrdu.org))
    - See [an example of a route map format rendering here](http://geojson.lrdu.org/#%5B%7B%22type%22%3A%22Feature%22%2C%22properties%22%3A%7B%22icon%22%3A%22walk%22%2C%22name%22%3A%22Walk+from+origin+%2840.7094%2C+-74.0054%29%3A+21%3A22%3A20+%E2%86%92+21%3A26+%283m+40s%29%22%7D%2C%22geometry%22%3A%7B%22type%22%3A%22Point%22%2C%22coordinates%22%3A%5B-74.0054%2C40.7094%5D%7D%7D%2C%7B%22type%22%3A%22Feature%22%2C%22properties%22%3A%7B%22icon%22%3A%22board%22%2C%22name%22%3A%22Board+trip+%28A+toward+Ozone+Park-Lefferts+Blvd%29%3A+21%3A26+%E2%86%92+21%3A32%3A30+%286m+30s%29%22%7D%2C%22geometry%22%3A%7B%22type%22%3A%22Point%22%2C%22coordinates%22%3A%5B-74.0077%2C40.7102%5D%7D%7D%2C%7B%22type%22%3A%22Feature%22%2C%22properties%22%3A%7B%22icon%22%3A%22stop%22%2C%22name%22%3A%22Trip+stop+%28High+St%29+at+21%3A29%22%7D%2C%22geometry%22%3A%7B%22type%22%3A%22Point%22%2C%22coordinates%22%3A%5B-73.9905%2C40.6993%5D%7D%7D%2C%7B%22type%22%3A%22Feature%22%2C%22properties%22%3A%7B%22icon%22%3A%22stop%22%2C%22name%22%3A%22Trip+stop+%28Jay+St-MetroTech%29+at+21%3A31%22%7D%2C%22geometry%22%3A%7B%22type%22%3A%22Point%22%2C%22coordinates%22%3A%5B-73.9873%2C40.6923%5D%7D%7D%2C%7B%22type%22%3A%22Feature%22%2C%22properties%22%3A%7B%22icon%22%3A%22stop%22%2C%22name%22%3A%22Trip+stop+%28Hoyt-Schermerhorn+Sts%29+at+21%3A32%3A30%22%7D%2C%22geometry%22%3A%7B%22type%22%3A%22Point%22%2C%22coordinates%22%3A%5B-73.985%2C40.6885%5D%7D%7D%2C%7B%22type%22%3A%22Feature%22%2C%22properties%22%3A%7B%22icon%22%3A%22board%22%2C%22name%22%3A%22Transfer%22%7D%2C%22geometry%22%3A%7B%22type%22%3A%22Point%22%2C%22coordinates%22%3A%5B-73.985%2C40.6885%5D%7D%7D%2C%7B%22type%22%3A%22Feature%22%2C%22properties%22%3A%7B%22icon%22%3A%22board%22%2C%22name%22%3A%22Board+trip+%28G+toward+Court+Sq%29%3A+21%3A37+%E2%86%92+21%3A51%3A30+%2814m+30s%29%22%7D%2C%22geometry%22%3A%7B%22type%22%3A%22Point%22%2C%22coordinates%22%3A%5B-73.985%2C40.6885%5D%7D%7D%2C%7B%22type%22%3A%22Feature%22%2C%22properties%22%3A%7B%22icon%22%3A%22stop%22%2C%22name%22%3A%22Trip+stop+%28Fulton+St%29+at+21%3A38%3A30%22%7D%2C%22geometry%22%3A%7B%22type%22%3A%22Point%22%2C%22coordinates%22%3A%5B-73.9754%2C40.6871%5D%7D%7D%2C%7B%22type%22%3A%22Feature%22%2C%22properties%22%3A%7B%22icon%22%3A%22stop%22%2C%22name%22%3A%22Trip+stop+%28Clinton-Washington+Avs%29+at+21%3A40%22%7D%2C%22geometry%22%3A%7B%22type%22%3A%22Point%22%2C%22coordinates%22%3A%5B-73.9668%2C40.6881%5D%7D%7D%2C%7B%22type%22%3A%22Feature%22%2C%22properties%22%3A%7B%22icon%22%3A%22stop%22%2C%22name%22%3A%22Trip+stop+%28Classon+Av%29+at+21%3A41%3A30%22%7D%2C%22geometry%22%3A%7B%22type%22%3A%22Point%22%2C%22coordinates%22%3A%5B-73.9601%2C40.6889%5D%7D%7D%2C%7B%22type%22%3A%22Feature%22%2C%22properties%22%3A%7B%22icon%22%3A%22stop%22%2C%22name%22%3A%22Trip+stop+%28Bedford-Nostrand+Avs%29+at+21%3A42%3A30%22%7D%2C%22geometry%22%3A%7B%22type%22%3A%22Point%22%2C%22coordinates%22%3A%5B-73.9535%2C40.6896%5D%7D%7D%2C%7B%22type%22%3A%22Feature%22%2C%22properties%22%3A%7B%22icon%22%3A%22stop%22%2C%22name%22%3A%22Trip+stop+%28Myrtle-Willoughby+Avs%29+at+21%3A44%22%7D%2C%22geometry%22%3A%7B%22type%22%3A%22Point%22%2C%22coordinates%22%3A%5B-73.949%2C40.6946%5D%7D%7D%2C%7B%22type%22%3A%22Feature%22%2C%22properties%22%3A%7B%22icon%22%3A%22stop%22%2C%22name%22%3A%22Trip+stop+%28Flushing+Av%29+at+21%3A45%3A30%22%7D%2C%22geometry%22%3A%7B%22type%22%3A%22Point%22%2C%22coordinates%22%3A%5B-73.9502%2C40.7004%5D%7D%7D%2C%7B%22type%22%3A%22Feature%22%2C%22properties%22%3A%7B%22icon%22%3A%22stop%22%2C%22name%22%3A%22Trip+stop+%28Broadway%29+at+21%3A46%3A30%22%7D%2C%22geometry%22%3A%7B%22type%22%3A%22Point%22%2C%22coordinates%22%3A%5B-73.9503%2C40.7061%5D%7D%7D%2C%7B%22type%22%3A%22Feature%22%2C%22properties%22%3A%7B%22icon%22%3A%22stop%22%2C%22name%22%3A%22Trip+stop+%28Metropolitan+Av%29+at+21%3A48%22%7D%2C%22geometry%22%3A%7B%22type%22%3A%22Point%22%2C%22coordinates%22%3A%5B-73.9514%2C40.7128%5D%7D%7D%2C%7B%22type%22%3A%22Feature%22%2C%22properties%22%3A%7B%22icon%22%3A%22stop%22%2C%22name%22%3A%22Trip+stop+%28Nassau+Av%29+at+21%3A50%3A30%22%7D%2C%22geometry%22%3A%7B%22type%22%3A%22Point%22%2C%22coordinates%22%3A%5B-73.9513%2C40.7246%5D%7D%7D%2C%7B%22type%22%3A%22Feature%22%2C%22properties%22%3A%7B%22icon%22%3A%22stop%22%2C%22name%22%3A%22Trip+stop+%28Greenpoint+Av%29+at+21%3A51%3A30%22%7D%2C%22geometry%22%3A%7B%22type%22%3A%22Point%22%2C%22coordinates%22%3A%5B-73.9544%2C40.7314%5D%7D%7D%2C%7B%22type%22%3A%22Feature%22%2C%22properties%22%3A%7B%22icon%22%3A%22walk%22%2C%22name%22%3A%22Walk+to+destination+%2840.7288%2C+-73.9522%29%3A+21%3A51%3A30+%E2%86%92+21%3A57%3A24+%285m+54s%29%22%7D%2C%22geometry%22%3A%7B%22type%22%3A%22Point%22%2C%22coordinates%22%3A%5B-73.9522%2C40.7288%5D%7D%7D%2C%7B%22type%22%3A%22Feature%22%2C%22properties%22%3A%7B%22name%22%3A%22Route%22%7D%2C%22geometry%22%3A%7B%22type%22%3A%22LineString%22%2C%22coordinates%22%3A%5B%5B-74.0054%2C40.7094%5D%2C%5B-74.0077%2C40.7102%5D%2C%5B-74.0077%2C40.7102%5D%2C%5B-74.0077%2C40.7102%5D%2C%5B-73.9905%2C40.6993%5D%2C%5B-73.9873%2C40.6923%5D%2C%5B-73.985%2C40.6885%5D%2C%5B-73.985%2C40.6885%5D%2C%5B-73.985%2C40.6885%5D%2C%5B-73.985%2C40.6885%5D%2C%5B-73.985%2C40.6885%5D%2C%5B-73.985%2C40.6885%5D%2C%5B-73.9754%2C40.6871%5D%2C%5B-73.9668%2C40.6881%5D%2C%5B-73.9601%2C40.6889%5D%2C%5B-73.9535%2C40.6896%5D%2C%5B-73.949%2C40.6946%5D%2C%5B-73.9502%2C40.7004%5D%2C%5B-73.9503%2C40.7061%5D%2C%5B-73.9514%2C40.7128%5D%2C%5B-73.9513%2C40.7246%5D%2C%5B-73.9544%2C40.7314%5D%2C%5B-73.9544%2C40.7314%5D%2C%5B-73.9544%2C40.7314%5D%2C%5B-73.9522%2C40.7288%5D%5D%7D%7D%5D)

## **Mobroute CLI: Subcommands Documentation**

You can retrieve documentation about each mobroute subcommand via using
`-h`. For example `mobroute route -h` yields:
## **Mobroute CLI: Route subcommand**

```sh
Usage of route:
Usage of ./mobroute route:
  -d string
        Verbose debug categories: (i) Information (w) Warn (d) Debug (default "i")
  -dprof string
        Write debug pprof CPU profile to file
  -format string
        Output format, currently only json supported (default "json")
  -h    Show this usage message
  -rp string
        JSON Parameters for route subcommand

        Valid properties:
          - feed_ids: Array of feed IDs (MDBID) to use for routing requests (default: {mdbid: [516]})
          - from: Object with two float properties, lat & lon (default: {lat: 40.70940, lon: -74.00537})
          - to: Object with two float properties, lat & lon (default: {lat: 40.72879, lon: -73.95215})
          - time: Datetime to depart from trip, if unset defaults to current time / now (default: null)
        JSON Parameters for oneshot route subcommand, should be in format of: {"route_params": {"feed_ids": [516],...}}

        Required route parameters:
          - feed_ids: Array of integer feed IDs (MDBID) to use for routing requests
          - from: Array of two floats; [lat, lon]
          - to: Array of two floats; [lat, lon]
          - time: Datetime at which route should depart in RFC3339 format
          - transfer_categories: Array of transfers categories to load - "f" for feed, "i" for implicit, "g" for generated, e.g. ["f", "i"]
          - output_formats: Array of formats for the output may include - ["legs", "geojson", "diagnostics", "mapurl", "request"]

        Optional route parameters:
          - max_walk_seconds: Maximum seconds walking distance on start/end of trip to get to/from origin/destination stops (default: 1200)
          - max_trip_seconds: Maximum seconds the entire route/trip can take (default: 14400)
          - min_transfer_seconds: Minimum seconds each transfer in the route can take (default: 180)
          - max_transfer_seconds: Maximum seconds each transfer in the route can take (default: 2400)
          - max_n_transfers: Maximum number of transfers a route can contain (default: 20)
          - walkspeed_km_hr: Ratio of kilometers per hour the user walk (default: 4.5)
          - transfer_categories: Array of transfers categories to load - "f" for feed, "i" for implicit, "g" for generated (default: ["f", "i"])
          - cache_dir: Directory to store sqlite db, defaults to ~/.cache/mobroute if null (default: null)
          - output_formats: Array of formats for the output may include - "legs", "geojson", "diagnostics", "mapurl", "request" (default: ["legs"])
                 (default "\n\t\t  {\"route_params\": {\"feed_ids\": [516], \"from\": [40.70940, -74.00537], \"to\": [40.72879, -73.95215], \"transfer_categori
es\": [\"f\", \"i\"], \"output_formats\": [\"legs\", \"diagnostics\", \"geojson\"]}}\n\t\t")


Examples:
  NYC Routing Example:
    mobroute route -rp '{"route_params":{"feed_ids":[516],"from":[40.70940,-74.00537],"to":[40.72879,-73.95215],"transfer_categories":["f","i"],"output_formats
":["legs","diagnostics","mapurl","request"]}}'
  Brussels Routing Example:
    mobroute route -rp '{"route_params":{"feed_ids":[1088],"from":[50.85728,4.351426],"to":[50.83214,4.350534],"transfer_categories":["f","i"],"output_formats"
:["legs","diagnostics","mapurl","request"]}}'
  Krakow Routing Example:
    mobroute route -rp '{"route_params":{"feed_ids":[1270],"from":[50.012338,19.88192],"to":[50.08785,20.02387],"transfer_categories":["f","i"],"output_formats
":["legs","diagnostics","mapurl","request"]}}'
```


## **Mobroute CLI: Mobsql subcommand**

```sh
Usage of ./mobroute mobsql:
  -d string
        Verbose debug categories: (i) Information (w) Warn (d) Debug (default "i")
  -dprof string
        Write debug pprof CPU profile to file
  -h    Show this usage message
  -mp string
        JSON Parameters for oneshot mobsql subcommand, should be in format of: {"mobsql_params": {"feed_ids": [767], "op": "status"}}.

        Required mobsql parameters:
          - feed_ids: Array of integer feed IDs (MDBID) to use for mobsql requests
          - op: Operation to perform, one of - ["status", "load", "compute", "purge_gtfs", "purge_computed", "purge_all"]


Examples:
  Load a GTFS Feed:
    mobroute mobsql -mp '{"mobsql_params": {"op": "load", "feed_ids": [767]}}'
  Compute Routing-Optimized GTFS Derived Tables:
    mobroute mobsql -mp '{"mobsql_params": {"op": " compute", "feed_ids": [767]}}'
  Purge GTFS Feed Data:
    mobroute mobsql -mp '{"mobsql_params": {"op": " purge_gtfs", "feed_ids": [767]}}'
  Purge Computed Tables:
    mobroute mobsql -mp '{"mobsql_params": {"op": " purge_computed", "feed_ids": [767]}}'
  Purge All Tables:
    mobroute mobsql -mp '{"mobsql_params": {"op": " purge_all", "feed_ids": [767]}}'
  Determine GTFS Feed Status:
    mobroute mobsql -mp '{"mobsql_params": {"op": "status", "feed_ids": [767]}}'
```



## **Further Resources & Documentation**

- [Automated Test Results / Metros](https://ci.lrdu.org/tests_results/): If you're curious about metros that have been well-tested and MDBIDs which you can experiment with for routing, this page has a number of working routing requests (lat/lon pairs and MDBIDs)