geo.distanceKm
This function gives the great-circle distance between two points in kilometres. The model is a sphere. On the ellipsoid of WGS84, the true distance can be different by up to approximately 0.6 %.
CLI- Package
- @procedures/geo · README
- Path
["geo","distanceKm"]- CLI
mark geo distanceKm --a <object> --b <object>- As data
{"$proc":["geo","distanceKm"],"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","distanceKm"], { a: {}, b: {} });
console.log(JSON.stringify(result));From the command line
$ mark geo distanceKm --a <object> --b <object>
As data, in a program
{ "$proc": ["geo", "distanceKm"], "input": { "a": {}, "b": {} } }Input
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
a | object | yes | ||
b | object | yes | ||
radiusKm | number | no | The radius of the sphere, more than 0. The default is `EARTH_MEAN_RADIUS_KM`. |
Output
The schema does not list fields (number).
JSON Schemas
{
"input": {
"type": "object",
"properties": {
"a": {
"type": "object",
"properties": {
"lat": {
"type": "number",
"description": "The latitude in degrees, from -90 to 90."
},
"lon": {
"type": "number",
"description": "The longitude in degrees. A normalized longitude is from -180 to less than 180."
}
},
"required": [
"lat",
"lon"
],
"additionalProperties": {}
},
"b": {
"type": "object",
"properties": {
"lat": {
"type": "number",
"description": "The latitude in degrees, from -90 to 90."
},
"lon": {
"type": "number",
"description": "The longitude in degrees. A normalized longitude is from -180 to less than 180."
}
},
"required": [
"lat",
"lon"
],
"additionalProperties": {}
},
"radiusKm": {
"type": "number",
"description": "The radius of the sphere, more than 0. The default is `EARTH_MEAN_RADIUS_KM`."
}
},
"required": [
"a",
"b"
],
"additionalProperties": false
},
"output": {
"type": "number"
}
}