# `MapTile`

One square of a web map at one zoom level: `10/511/340`.

Use it to cache or address map images. For a place on Earth, use [`Point`](/docs/types/type-point.md).

## Shape

| Field | Type | Required? |
|---|---|---|
| `zoom` | `Int` | Yes |
| `x` | `Int` | Yes |
| `y` | `Int` | Yes |

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

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

## Example

```jadpo
MapTile { zoom: 10 x: 511 y: 340 }
```

## Good to know

- Zoom runs from 0 to 30, and `x` and `y` must each be below 2 to the zoom.
- `==` tells you whether two are the same. `<` and `list.sort_by` don't take it, so sort by one of its parts instead.

## In JSON

An object of its parts, in a request, a response or `json.write`:

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

## Details

<details>
<summary>Text form, storage, how it is shown, and operations</summary>

`MapTile` is in the group Geospatial, and has been in Jadpo since 0.1.0.

### Text form

It has no single text form, so `text.from` and `text.parse` don't take it.

### How it is stored

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

### How it is 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 also takes `text.format`, `json.read`, `json.write` and `==`. [How every standard type behaves](/docs/every-standard-type-meets-one-contract.md) says how they work.

</details>
