← All procedures

geo.route

Give the time and the distance of a drive between two points (OSRM)

CLI
Package
@procedures/geo · README
Path
["geo","route"]
CLI
mark geo route --from <object> --to <object>
As data
{"$proc":["geo","route"],"input":{}}

Use it

In TypeScript

import { Client, LocalTransport, PROCEDURE_REGISTRY } from "@procedures/client";
import "@procedures/geo/register"; // registers its procedures

const client = new Client(new LocalTransport({ registry: PROCEDURE_REGISTRY }));
const result = await client.exec(["geo","route"], { from: {}, to: {} });
console.log(JSON.stringify(result));

From the command line

$ mark geo route --from <object> --to <object>

As data, in a program

{ "$proc": ["geo", "route"], "input": { "from": {}, "to": {} } }

Input

FieldTypeRequiredDefaultDescription
fromobjectyesThe start
toobjectyesThe destination
baseUrlstringnoAnother OSRM server (default: the public demonstration server)
line"full" | "simplified"noAlso give the points of the route: each point of the road (full) or fewer points (simplified)
timeoutMsintegerno20000The time limit, in milliseconds (default: 20000)

Output

FieldTypeRequiredDefaultDescription
kmnumberyes
minutesnumberyes
lineobject[]no
JSON Schemas
{
  "input": {
    "type": "object",
    "properties": {
      "from": {
        "type": "object",
        "properties": {
          "lat": {
            "type": "number",
            "minimum": -90,
            "maximum": 90
          },
          "lon": {
            "type": "number",
            "minimum": -180,
            "maximum": 180
          }
        },
        "required": [
          "lat",
          "lon"
        ],
        "description": "The start"
      },
      "to": {
        "type": "object",
        "properties": {
          "lat": {
            "type": "number",
            "minimum": -90,
            "maximum": 90
          },
          "lon": {
            "type": "number",
            "minimum": -180,
            "maximum": 180
          }
        },
        "required": [
          "lat",
          "lon"
        ],
        "description": "The destination"
      },
      "baseUrl": {
        "description": "Another OSRM server (default: the public demonstration server)",
        "type": "string",
        "format": "uri"
      },
      "line": {
        "description": "Also give the points of the route: each point of the road (full) or fewer points (simplified)",
        "type": "string",
        "enum": [
          "full",
          "simplified"
        ]
      },
      "timeoutMs": {
        "default": 20000,
        "description": "The time limit, in milliseconds (default: 20000)",
        "type": "integer",
        "exclusiveMinimum": 0,
        "maximum": 120000
      }
    },
    "required": [
      "from",
      "to"
    ]
  },
  "output": {
    "type": "object",
    "properties": {
      "km": {
        "type": "number"
      },
      "minutes": {
        "type": "number"
      },
      "line": {
        "type": "array",
        "items": {
          "type": "object",
          "properties": {
            "lat": {
              "type": "number"
            },
            "lon": {
              "type": "number"
            }
          },
          "required": [
            "lat",
            "lon"
          ],
          "additionalProperties": false
        }
      }
    },
    "required": [
      "km",
      "minutes"
    ],
    "additionalProperties": false
  }
}