getGeoDiff

Returns a structured diff between two geographical coordinates. Supports 9 distance units, locale‑aware output, and two accuracy modes.

circle-info

ACCURACY MODES

IMPORT

import { getGeoDiff } from "@donedeal0/superdiff";

FORMAT

Input

previousCoordinates: [number, number] | null | undefined;
  coordinates: [number, number] | null | undefined;
  options?: {
    unit?: "centimeter" | "foot" | "inch" | "kilometer" | "meter" | "mile" | "mile-scandinavian" | "millimeter" | "yard"; // "kilometer" by default
    accuracy?: "normal" | "high"; // "normal" by default
    maxDecimals?: number; // 2 by default,
    locale?: Intl.Locale | string; // "en-US" by default
  }
  • previousCoordinates: the original coordinates ([Longitude, Latitude]).

  • coordinates: the new coordinates ([Longitude, Latitude]).

  • options

    • unit: the unit used for the returned distance.

    • accuracy:

      • normal (default): fastest mode, with a small error margin, based on Haversine formula.

      • high: slower but highly precise distance. Based on Vincenty formula.

    • maxDecimals: maximal decimals for the distance. Defaults to 2.

    • locale: the locale of your distance. Enables a locale‑aware distance label.

Output


USAGE

Input

circle-info

Coordinates follow GeoJSON order: [longitude, latitude].

Output

Last updated