# getGeoDiff

{% hint style="info" %} <mark style="color:$info;">**ACCURACY MODES**</mark>

* <mark style="color:$info;">**High‑accuracy mode**</mark> <mark style="color:$info;"></mark><mark style="color:$info;">is based on the</mark> [<mark style="color:$info;">Vincenty formulae</mark>](https://en.wikipedia.org/wiki/Vincenty's_formulae) <mark style="color:$info;">(ellipsoidal Earth model, higher precision).</mark>
* <mark style="color:$info;">**Normal-accuracy mode**</mark> <mark style="color:$info;"></mark><mark style="color:$info;">is based on the</mark> [<mark style="color:$info;">Haversine formulae</mark>](https://en.wikipedia.org/wiki/Haversine_formula) <mark style="color:$info;">(spherical Earth model, faster, slightly less precise)</mark>
  {% endhint %}

## IMPORT

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

***

## FORMAT

### Input

```typescript
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

```typescript
type GeoDiff = {
    type: "geo";
    status: "added" | "deleted" | "error" | "equal" | "updated";
    diff: {
        coordinates: [number, number] | null;
        previousCoordinates: [number, number] | null;
        distance: number;
        unit: "centimeter" | "foot" | "inch" | "kilometer" | "meter" | "mile" | "mile-scandinavian" | "millimeter" | "yard";
        label: string,
        direction: "east" | "north" | "south" | "west" | "north-east" | "north-west" | "south-east" | "south-west" | "stationary";
    };
}
};
```

***

## USAGE

### Input

```diff
getGeoDiff(
- [2.3522, 48.8566],
+ [-0.1278, 51.5074]
);
```

{% hint style="info" %}
Coordinates follow GeoJSON order: \[longitude, latitude].
{% endhint %}

### Output

```diff
{
      type: "geo",
+     status: "updated",
      diff: {
+          coordinates: [-0.1278, 51.5074],
           previousCoordinates: [2.3522, 48.8566],
+          direction: "north-west",
+          distance: 343.56,
+          label: "343.56 kilometers",
+          unit: "kilometer"
        }
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://donedeal0.gitbook.io/superdiff/features/getgeodiff.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
