← All procedures

geo.distanceBetweenGeometriesKm

This function gives the great-circle distance in kilometres between the nearest points of two GeoJSON geometries. The rules are in the description of this module. The model is a sphere.

CLI
Package
@procedures/geo · README
Path
["geo","distanceBetweenGeometriesKm"]
CLI
mark geo distanceBetweenGeometriesKm --a <any> --b <any>
As data
{"$proc":["geo","distanceBetweenGeometriesKm"],"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","distanceBetweenGeometriesKm"], { a: "<a>", b: "<b>" });
console.log(JSON.stringify(result));

From the command line

$ mark geo distanceBetweenGeometriesKm --a <any> --b <any>

As data, in a program

{
  "$proc": ["geo", "distanceBetweenGeometriesKm"],
  "input": { "a": "<a>", "b": "<b>" }
}

Input

FieldTypeRequiredDefaultDescription
aanyyes
banyyes
radiusKmnumbernoThe 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": {
        "$ref": "#/definitions/__schema0"
      },
      "b": {
        "$ref": "#/definitions/__schema0"
      },
      "radiusKm": {
        "type": "number",
        "description": "The radius of the sphere, more than 0. The default is `EARTH_MEAN_RADIUS_KM`."
      }
    },
    "required": [
      "a",
      "b"
    ],
    "additionalProperties": false,
    "definitions": {
      "__schema0": {
        "anyOf": [
          {
            "type": "object",
            "properties": {
              "type": {
                "type": "string",
                "const": "GeometryCollection"
              },
              "geometries": {
                "type": "array",
                "items": {
                  "allOf": [
                    {
                      "$ref": "#/definitions/__schema0"
                    }
                  ]
                }
              },
              "bbox": {
                "anyOf": [
                  {
                    "type": "array",
                    "items": [
                      {
                        "type": "number"
                      },
                      {
                        "type": "number"
                      },
                      {
                        "type": "number"
                      },
                      {
                        "type": "number"
                      }
                    ],
                    "additionalItems": {},
                    "minItems": 4,
                    "maxItems": 4
                  },
                  {
                    "type": "array",
                    "items": [
                      {
                        "type": "number"
                      },
                      {
                        "type": "number"
                      },
                      {
                        "type": "number"
                      },
                      {
                        "type": "number"
                      },
                      {
                        "type": "number"
                      },
                      {
                        "type": "number"
                      }
                    ],
                    "additionalItems": {},
                    "minItems": 6,
                    "maxItems": 6
                  }
                ],
                "description": "The bounding box of the object (RFC 7946, section 5)."
              }
            },
            "required": [
              "type",
              "geometries"
            ],
            "additionalProperties": {}
          },
          {
            "type": "object",
            "properties": {
              "type": {
                "type": "string",
                "const": "MultiLineString"
              },
              "coordinates": {
                "type": "array",
                "items": {
                  "type": "array",
                  "items": {
                    "type": "array",
                    "items": [
                      {
                        "type": "number"
                      },
                      {
                        "type": "number"
                      },
                      {
                        "type": "number"
                      }
                    ],
                    "additionalItems": {},
                    "minItems": 2
                  }
                }
              },
              "bbox": {
                "anyOf": [
                  {
                    "type": "array",
                    "items": [
                      {
                        "type": "number"
                      },
                      {
                        "type": "number"
                      },
                      {
                        "type": "number"
                      },
                      {
                        "type": "number"
                      }
                    ],
                    "additionalItems": {},
                    "minItems": 4,
                    "maxItems": 4
                  },
                  {
                    "type": "array",
                    "items": [
                      {
                        "type": "number"
                      },
                      {
                        "type": "number"
                      },
                      {
                        "type": "number"
                      },
                      {
                        "type": "number"
                      },
                      {
                        "type": "number"
                      },
                      {
                        "type": "number"
                      }
                    ],
                    "additionalItems": {},
                    "minItems": 6,
                    "maxItems": 6
                  }
                ],
                "description": "The bounding box of the object (RFC 7946, section 5)."
              }
            },
            "required": [
              "type",
              "coordinates"
            ],
            "additionalProperties": {}
          },
          {
            "type": "object",
            "properties": {
              "type": {
                "type": "string",
                "const": "MultiPoint"
              },
              "coordinates": {
                "type": "array",
                "items": {
                  "type": "array",
                  "items": [
                    {
                      "type": "number"
                    },
                    {
                      "type": "number"
                    },
                    {
                      "type": "number"
                    }
                  ],
                  "additionalItems": {},
                  "minItems": 2
                }
              },
              "bbox": {
                "anyOf": [
                  {
                    "type": "array",
                    "items": [
                      {
                        "type": "number"
                      },
                      {
                        "type": "number"
                      },
                      {
                        "type": "number"
                      },
                      {
                        "type": "number"
                      }
                    ],
                    "additionalItems": {},
                    "minItems": 4,
                    "maxItems": 4
                  },
                  {
                    "type": "array",
                    "items": [
                      {
                        "type": "number"
                      },
                      {
                        "type": "number"
                      },
                      {
                        "type": "number"
                      },
                      {
                        "type": "number"
                      },
                      {
                        "type": "number"
                      },
                      {
                        "type": "number"
                      }
                    ],
                    "additionalItems": {},
                    "minItems": 6,
                    "maxItems": 6
                  }
                ],
                "description": "The bounding box of the object (RFC 7946, section 5)."
              }
            },
            "required": [
              "type",
              "coordinates"
            ],
            "additionalProperties": {}
          },
          {
            "type": "object",
            "properties": {
              "type": {
                "type": "string",
                "const": "Polygon"
              },
              "coordinates": {
                "type": "array",
                "items": {
                  "type": "array",
                  "items": {
                    "type": "array",
                    "items": [
                      {
                        "type": "number"
                      },
                      {
                        "type": "number"
                      },
                      {
                        "type": "number"
                      }
                    ],
                    "additionalItems": {},
                    "minItems": 2
                  }
                }
              },
              "bbox": {
                "anyOf": [
                  {
                    "type": "array",
                    "items": [
                      {
                        "type": "number"
                      },
                      {
                        "type": "number"
                      },
                      {
                        "type": "number"
                      },
                      {
                        "type": "number"
                      }
                    ],
                    "additionalItems": {},
                    "minItems": 4,
                    "maxItems": 4
                  },
                  {
                    "type": "array",
                    "items": [
                      {
                        "type": "number"
                      },
                      {
                        "type": "number"
                      },
                      {
                        "type": "number"
                      },
                      {
                        "type": "number"
                      },
                      {
                        "type": "number"
                      },
                      {
                        "type": "number"
                      }
                    ],
                    "additionalItems": {},
                    "minItems": 6,
                    "maxItems": 6
                  }
                ],
                "description": "The bounding box of the object (RFC 7946, section 5)."
              }
            },
            "required": [
              "type",
              "coordinates"
            ],
            "additionalProperties": {}
          },
          {
            "type": "object",
            "properties": {
              "type": {
                "type": "string",
                "const": "LineString"
              },
              "coordinates": {
                "type": "array",
                "items": {
                  "type": "array",
                  "items": [
                    {
                      "type": "number"
                    },
                    {
                      "type": "number"
                    },
                    {
                      "type": "number"
                    }
                  ],
                  "additionalItems": {},
                  "minItems": 2
                }
              },
              "bbox": {
                "anyOf": [
                  {
                    "type": "array",
                    "items": [
                      {
                        "type": "number"
                      },
                      {
                        "type": "number"
                      },
                      {
                        "type": "number"
                      },
                      {
                        "type": "number"
                      }
                    ],
                    "additionalItems": {},
                    "minItems": 4,
                    "maxItems": 4
                  },
                  {
                    "type": "array",
                    "items": [
                      {
                        "type": "number"
                      },
                      {
                        "type": "number"
                      },
                      {
                        "type": "number"
                      },
                      {
                        "type": "number"
                      },
                      {
                        "type": "number"
                      },
                      {
                        "type": "number"
                      }
                    ],
                    "additionalItems": {},
                    "minItems": 6,
                    "maxItems": 6
                  }
                ],
                "description": "The bounding box of the object (RFC 7946, section 5)."
              }
            },
            "required": [
              "type",
              "coordinates"
            ],
            "additionalProperties": {}
          },
          {
            "type": "object",
            "properties": {
              "type": {
                "type": "string",
                "const": "Point"
              },
              "coordinates": {
                "type": "array",
                "items": [
                  {
                    "type": "number"
                  },
                  {
                    "type": "number"
                  },
                  {
                    "type": "number"
                  }
                ],
                "additionalItems": {},
                "minItems": 2
              },
              "bbox": {
                "anyOf": [
                  {
                    "type": "array",
                    "items": [
                      {
                        "type": "number"
                      },
                      {
                        "type": "number"
                      },
                      {
                        "type": "number"
                      },
                      {
                        "type": "number"
                      }
                    ],
                    "additionalItems": {},
                    "minItems": 4,
                    "maxItems": 4
                  },
                  {
                    "type": "array",
                    "items": [
                      {
                        "type": "number"
                      },
                      {
                        "type": "number"
                      },
                      {
                        "type": "number"
                      },
                      {
                        "type": "number"
                      },
                      {
                        "type": "number"
                      },
                      {
                        "type": "number"
                      }
                    ],
                    "additionalItems": {},
                    "minItems": 6,
                    "maxItems": 6
                  }
                ],
                "description": "The bounding box of the object (RFC 7946, section 5)."
              }
            },
            "required": [
              "type",
              "coordinates"
            ],
            "additionalProperties": {}
          },
          {
            "type": "object",
            "properties": {
              "type": {
                "type": "string",
                "const": "MultiPolygon"
              },
              "coordinates": {
                "type": "array",
                "items": {
                  "type": "array",
                  "items": {
                    "type": "array",
                    "items": {
                      "type": "array",
                      "items": [
                        {
                          "type": "number"
                        },
                        {
                          "type": "number"
                        },
                        {
                          "type": "number"
                        }
                      ],
                      "additionalItems": {},
                      "minItems": 2
                    }
                  }
                }
              },
              "bbox": {
                "anyOf": [
                  {
                    "type": "array",
                    "items": [
                      {
                        "type": "number"
                      },
                      {
                        "type": "number"
                      },
                      {
                        "type": "number"
                      },
                      {
                        "type": "number"
                      }
                    ],
                    "additionalItems": {},
                    "minItems": 4,
                    "maxItems": 4
                  },
                  {
                    "type": "array",
                    "items": [
                      {
                        "type": "number"
                      },
                      {
                        "type": "number"
                      },
                      {
                        "type": "number"
                      },
                      {
                        "type": "number"
                      },
                      {
                        "type": "number"
                      },
                      {
                        "type": "number"
                      }
                    ],
                    "additionalItems": {},
                    "minItems": 6,
                    "maxItems": 6
                  }
                ],
                "description": "The bounding box of the object (RFC 7946, section 5)."
              }
            },
            "required": [
              "type",
              "coordinates"
            ],
            "additionalProperties": {}
          }
        ]
      }
    }
  },
  "output": {
    "type": "number"
  }
}