package
0.1.18
Repository: https://github.com/nextmv-io/go-routingkit.git
Documentation: pkg.go.dev

# README

go-routingkit standalone

routingkit allows the usage of go-routingkit as a standalone executable.

Example

  1. Download an .osm.pbf file for Maryland from Geofabrik:

    wget -P "data/" "http://download.geofabrik.de/north-america/us/maryland-latest.osm.pbf"
    
  2. Execute the sample request from data/maryland-points.json

    go run . \
        -map "data/maryland-latest.osm.pbf" \
        -input "data/maryland-points.json" \
        -measure "distance"
    

Note that contraction hierarchies are built and saved to the .ch file, if the file is not yet present. This process takes a while. Subsequent calls (with a .ch file present) will be faster.

Usage

Usage of standalone go-routingkit is described below.

Build

Build a binary by simply invoking

go build

Install

Install binary to PATH. Requires $(go env GOPATH)/bin to be included in PATH. After successful installation routingkit can be invoked as a command.

go install github.com/nextmv-io/go-routingkit/cmd/routingkit@latest

Arguments

Usage of routingkit:
  -height float
     truck height (default 1.7976931348623157e+308)
  -input string
     path to input file. default is stdin.
  -length float
     truck length (default 1.7976931348623157e+308)
  -map string
     path to map file (default "data/map.osm.pbf")
  -measure string
     distance|traveltime (default "distance")
  -mode string
     tuples|matrix (default "tuples")
  -output string
     path to output file. default is stdout.
  -profile string
     car|truck|bike|pedestrian (default "car")
  -speed int
     truck speed in m/s (default=27) (default 27)
  -weight float
     truck weight (default 1.7976931348623157e+308)
  -width float
     truck width (default 1.7976931348623157e+308)

Tuples mode

Find a sample --input below. Each request is given as a tuple of two locations defining the from and to part of the trip. The position of the location is given as longitude (lon) and latitude (lat).

{
    "tuples": [
        {
            "from": { "lon": -76.733, "lat": 38.887 },
            "to": { "lon": -77.095, "lat": 38.981 }
        },
        {
            "from": { "lon": -76.888, "lat": 38.951 },
            "to": { "lon": -76.868, "lat": 38.938 }
        },
        {
            "from": { "lon": -76.698, "lat": 39.065 },
            "to": { "lon": -77.029, "lat": 39.022 }
        },
        {
            "from": { "lon": -76.888, "lat": 39.207 },
            "to": { "lon": -76.485, "lat": 39.364 }
        }
    ]
}

Here is an excerpt of a sample output. There is one 'trip' per tuple in the input given as an array in input order. Each trip contains the cost (distance or drive-time) and the waypoints, which define the shape of the route. All positions are again given as longitude (lon) & latitude (lat).

{
    "trips": [
        {
            "waypoints": [
                { "lon": -76.7316, "lat": 38.887352 },
                { "lon": -76.731415, "lat": 38.88516 },
                { "lon": -76.73108, "lat": 38.88498 },
                // ...
                { "lon": -77.09511, "lat": 38.98097 }
            ],
            "cost": 42480
        },
        {
            "waypoints": [
                { "lon": -76.888374, "lat": 38.95079 },
                { "lon": -76.88743, "lat": 38.950684 },
                { "lon": -76.88705, "lat": 38.950535 },
                // ...
                { "lon": -76.867935, "lat": 38.937477 }
            ],
            "cost": 5200
        },
        {
            "waypoints": [
                { "lon": -76.69816, "lat": 39.064713 },
                { "lon": -76.697945, "lat": 39.065346 },
                { "lon": -76.69793, "lat": 39.065422 },
                // ...
                { "lon": -77.028854, "lat": 39.022038 }
            ],
            "cost": 38806
        },
        {
            "waypoints": [
                { "lon": -76.88802, "lat": 39.206516 },
                { "lon": -76.88725, "lat": 39.20655 },
                { "lon": -76.88608, "lat": 39.2066 },
                // ...
                { "lon": -76.48349, "lat": 39.363342 }
            ],
            "cost": 45401
        }
    ]
}

Matrix mode

In matrix mode, the input is given as a list of locations. The output is a matrix of costs between all locations. An example --input is given below.

{
    "points": [
        { "lon": -76.733, "lat": 38.887 },
        { "lon": -77.095, "lat": 38.981 },
        { "lon": -76.888, "lat": 38.951 }
    ]
}

When we execute the command like this, we get the following output.

routingkit --input input.json --mode matrix --map maryland-latest.osm.pbf
{
    "matrix": [
        [0, 40761, 20788],
        [40934, 0, 21124],
        [20635, 21264, 0]
    ]
}

# Interfaces

No description provided by the author