> ## Documentation Index
> Fetch the complete documentation index at: https://docs.bijection.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Geofences and position observations

`geo({...})` from `@bijectionhq/library-geo` returns a subtree. Place it in the app
tree and its tables and functions take their paths there:

```ts theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
import { app, label, role } from "@bijectionhq/bijection";
import { geo } from "@bijectionhq/library-geo";

export const vehicles = label();
export const devices = role({ clear: [vehicles] });
export const dispatch = role({ clear: [vehicles] });
export const ops = role({ clear: [vehicles] });

export const fleet = geo({
  roles: { report: [devices], read: [dispatch], manage: [ops] },
  labels: { positions: vehicles, fences: vehicles },
  series: { latency: { seconds: 5 }, interval: { seconds: 10 } },
});

export default app({ vehicles, devices, dispatch, ops, fleet });
```

The instance's tables are `fleet.positions`, `fleet.subjects`,
`fleet.fences`, `fleet.memberships` and `fleet.transitions`. Its exposed
functions:

| Function | `allow` | What |
| - | - | - |
| `admit` | report | Admit a batch of up to 500 observations over 64 subjects |
| `latest`, `track`, `positionAt` | read | The newest position, a page of observations, an estimate at an instant |
| `publish`, `retire` | manage | Publish an area with its `maxGap` (a duration) and `maxAccuracy`; retire it |
| `fence` | read | One fence |
| `membership`, `inside` | read | A subject's side and how far it is final; a page of the subjects inside a fence |
| `journal`, `history` | read | A page of transitions by fence or by subject; the order-free history |

Paged functions take `{ size, cursor }` and answer `{ facts, next }`, so
`usePages` holds them. An observation is
`{ subject, id, at, position: { point, accuracy_m } }`. Admission deduplicates
by `id`: the same content again is a duplicate, and other content under the
same `id` refuses `ObservationConflict`. `publish` refuses `FenceGapUnsafe`
when the series' timing cannot decide the fence within its `maxGap`.

`fleet.admitBatch(ctx, observations)` admits from your own mutation, under
exactly the positions' label (an HTTP ingest, a connector).
`onTransition: mutation` runs your mutation once per final transition, as a
task whose `once` is the transition. See the
[Geo library](https://github.com/bijectionhq/bijection/tree/main/npm-packages/libraries/geo)
for the fence fold and its finality rules.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.