Source: https://gometry.monicz.dev/mental-model/

# The mental model

Every geometry carries a complete [`Space`](https://gometry.monicz.dev/api/crs/#gometry.Space "Space"): its coordinate
reference system, optional coordinate epoch, and curve model (`planar`, `chart`,
or `spherical`). The curve model defines the path between stored vertices; the
measurement metric decides how that path is measured. Changing the metric never
changes the curve.

## Declare, transform, refine

Three rules govern every pipeline:

1. **Declare** with [`with_space`](https://gometry.monicz.dev/api/geometry/#gometry.Geometry.with_space "with_space") — attaches or
   replaces the complete `Space` without moving numeric coordinates.
2. **Transform** with [`to_space`](https://gometry.monicz.dev/api/geometry/#gometry.Geometry.to_space "to_space") — converts the
   represented shape into another target `Space` (reprojecting through PROJ
   and/or converting curve models).
3. **Refine** spatial candidates — a [`SpatialIndex.candidates`](https://gometry.monicz.dev/api/spatial-index/#gometry.SpatialIndex.candidates "candidates")
   bbox lookup or a grid cover narrows the search; it is not an exact geometry
   answer. Keep the source geometry and refine candidates with an exact
   predicate ([`SpatialIndex.query`](https://gometry.monicz.dev/api/spatial-index/#gometry.SpatialIndex.query "query"),
   [`gm.covers`](https://gometry.monicz.dev/api/predicates/#gometry.covers "covers"), [`gm.intersects`](https://gometry.monicz.dev/api/predicates/#gometry.intersects "intersects")).

See [CRS, units & measurement](https://gometry.monicz.dev/guide/crs/),
[Candidates vs query](https://gometry.monicz.dev/guide/indexing/#candidates-vs-query), and
[Exact membership with the source geometry](https://gometry.monicz.dev/guide/grids/#exact-membership-with-the-source-geometry).

## Curve models, metrics, and candidates

gometry separates curve interpretation, measurement, and discrete grid keys
instead of conflating them:

- **Curve model (`Space.model`)** — chooses what each edge represents:
- `'planar'` — straight segments (and ISO SQL/MM [curves & surfaces](https://gometry.monicz.dev/guide/curves/)) in literal X/Y coordinates; matches PostGIS `geometry`.
- `'chart'` — straight longitude/latitude segments in a geographic CRS with periodic longitude, antimeridian seam, and polar-ring handling. See [Geographic topology & antimeridian](https://gometry.monicz.dev/guide/geographic/).
- `'spherical'` — minor great-circle arcs evaluated on the sphere without a longitude seam (backed by S2); matches PostGIS `geography`.
- **Measurement metric** — on a geographic CRS, the default measuring surface is
  the CRS ellipsoid: length and distance are in meters, area in square meters.
  An explicit [`Sphere`](https://gometry.monicz.dev/api/crs/#gometry.Sphere "Sphere") selects a sphere instead.
  Projected CRSs use native linear units (with optional `unit='meters'`), unreferenced geometries use raw coordinate units,
  and `metric='cartesian'` measures planar coordinates directly. See
  [CRS, units & measurement](https://gometry.monicz.dev/guide/crs/).
- **Discrete grid keys** — [H3](https://h3geo.org/),
  [S2](https://s2geometry.io/), geohash, and XYZ tiles assign typed
  [`CellArray`](https://gometry.monicz.dev/api/grids/#gometry.CellArray "CellArray") keys for grouping, joins, and prefiltering.
  Cell covers return candidates that should be refined with exact predicates
  against the source geometry. See [Grids & geocodes](https://gometry.monicz.dev/guide/grids/).

1. Ellipsoidal measurement (245 km², 17.8 km)

Ellipsoidal measurement evaluates area on the source chart region and geodesic distance between two anchor points.

- source region
- measured / exact result
- geodesic endpoints

2. Chart topology (intersection)

Chart topology intersects the source region and query window to produce the overlapping polygon.

- source region
- query window
- measured / exact result

3. Discrete grid keys (418 H3 cells)

Discrete grid keys cover the source region with candidate H3 cells that extend past its edges and require predicate refinement.

- grid candidates
- source region

One geographic region viewed through gometry’s spatial layers: ellipsoidal measurement, topology, and discrete grid keys.

For naming rules, Python protocols, equality, and error types, see
[API conventions](https://gometry.monicz.dev/api/conventions/).
