# What every geospatial operation follows

Every `geo.` operation works the same way in the respects below, so you
can rely on them without checking each operation.

## Latitude and longitude by name

A point names its latitude and its longitude, so you never have to
remember which comes first. An order appears only where a format fixes
one: in `geo.from_geojson`, `geo.from_lng_lat`, `geo.from_lat_lng` and
the WKT operations under [Interop](geospatial-interop.md).

## Edges are great circles

An edge between two points is a great circle: the shortest path between
them on the globe, as PostGIS's `geography` draws it. It isn't a straight
line on a flat map of longitude and latitude, which is how RFC 7946, the
GeoJSON standard, describes an edge (its §3.1.1). Code and queries both
use great circles, so a query and `geo.contains` mean the same shape.

At city scale the difference is small: an east-west edge 5 km long at
51.5° N bows 0.6 m north at its middle, and one 50 km long bows 61 m
(verified). Over long edges it matters: in a box 20° wide with corners at
50° N and 60° N, a point at 60.1° N is inside and one at 50.1° N is
outside, because both edges bow towards the pole (verified). If a zone is
drawn on a web map with long straight edges, add points along them.
City-sized delivery patches are unaffected.

## Measures are on the ellipsoid

Distance, length, bearing and area are measured on the WGS84 ellipsoid,
the slightly flattened shape of the Earth that GPS uses. Jadpo uses
Karney's geodesic algorithms, which GeographicLib implements and which
PostGIS's `geography` uses by default for `ST_Distance`, `ST_DWithin`,
`ST_Length` and `ST_Area`, so code and database measure alike. Every
operation ignores altitude.

## Inside includes the edge

A point on a patch's boundary is in the patch. This holds for every
operation that asks whether one thing is inside another.

## The same answer everywhere

Every operation is pure, and is worked out by Jadpo's own whole-number
code, fixed point in 256 bits. So the interpreter, native builds and
wasm32 builds give the same digits.
[Precision and determinism](precision-and-determinism.md) says where floats
still appear.

## What each operation takes

An operation that takes a geometry takes any of the six geometries or a
`Geometry`, as `list.` operations take any list. The operation kind
`Shapes` lists the types such a parameter takes. The four measures are
narrower:

- `distance` and `bearing` take `Point`s only;
- `length` takes a `LineString` or a `MultiLineString`;
- `area` takes a `Polygon` or a `MultiPolygon`.

Anything else, a `Geometry` included, is `type.mismatch`, and the message
names this page. To measure a `Geometry`, `match` it first, so your code
decides what, say, a point's area is.
