# `MapTile`

A web map tile on OpenStreetMap's XYZ scheme: a zoom from 0 to 30 and a column and row each below 2 to the zoom, shown `10/511/340`.

[Geospatial](types.md#geospatial); not ordered; since Jadpo 0.1.0.

## Make one

Build one from its fields, `MapTile { zoom: ...  x: ...  y: ... }`.

Its parts keep these rules; a value that breaks one fails with the rule's name:

- `within_zoom`: `x and y are each below 2 to the zoom`

## Fields

| Field | Type |
|---|---|
| `zoom` | `Int` |
| `x` | `Int` |
| `y` | `Int` |

## Text, JSON and storage

It has no single text form, so `text.from` and `text.parse` don't take it. JSON sends an object of its parts.

| JSON |
|---|
| `{"zoom":0,"x":0,"y":0}` |
| `{"zoom":10,"x":511,"y":340}` |
| `{"zoom":18,"x":130981,"y":87168}` |

It is stored in 3 columns, each named for the field, `_` and its suffix. This is `{"zoom":10,"x":511,"y":340}`:

| Column | Type | Holds |
|---|---|---|
| `<field>_zoom` | `smallint` | `10` |
| `<field>_x` | `integer` | `511` |
| `<field>_y` | `integer` | `340` |

## Shown to people

`text.format(value, locale:)` shows it to people in their locale.

With `locale: Locale.en_gb`:

| Value | Shown |
|---|---|
| `{"zoom":0,"x":0,"y":0}` | `0/0/0` |
| `{"zoom":10,"x":511,"y":340}` | `10/511/340` |
| `{"zoom":18,"x":130981,"y":87168}` | `18/130981/87168` |

## Operations

It has the contract's own operations: `text.format`, `json.read`, `json.write` and `==`. It isn't ordered, so `<` and sorting don't take it. [Every standard type meets one contract](../topics/every-standard-type-meets-one-contract.md) says how they work.
