# Geometry types

Geometry types are named aliases over typed tuples and arrays. They preserve the shape and numeric types of coordinate collections.

## Supported types

| Type              | Structure                                            |
| ----------------- | ---------------------------------------------------- |
| `Point`           | `Tuple(Float64, Float64)` — two coordinates.         |
| `MultiPoint`      | `Array(Point)` — independent points.                 |
| `Ring`            | `Array(Point)` — a polygon boundary.                 |
| `LineString`      | `Array(Point)` — an ordered path.                    |
| `MultiLineString` | `Array(LineString)` — a collection of paths.         |
| `Polygon`         | `Array(Ring)` — an outer boundary followed by holes. |
| `MultiPolygon`    | `Array(Polygon)` — a collection of polygons.         |

The types validate the collection shape and coordinate conversions. They do not validate topology, such as self-intersections or whether holes lie inside an outer ring.

Use consistent coordinate units for a calculation. The aliases do not assign a coordinate reference system or convert between geographic and projected coordinates.

## Examples

### A point

```sql
SELECT CAST('[1,2]' AS Point)
FORMAT csv;
```

```text
"[1,2]"
```

### Testing polygon membership

`point_in_polygon` includes the outer boundary and excludes hole boundaries:

```sql
SELECT point_in_polygon(
    tuple(1, 1),
    CAST('[[0,0],[2,0],[2,2],[0,2]]' AS Ring)
)
FORMAT csv;
```

```text
true
```

### Storing a polygon

```sql
CREATE TABLE regions(name String, boundary Polygon);
INSERT INTO regions VALUES
    ('square', '[[[0,0],[2,0],[2,2],[0,2]]]');
```

```sql
SELECT name, point_in_polygon(tuple(1, 1), boundary)
FROM regions
FORMAT csv;
```

```text
"square",true
```

See [geometry functions](https://coordinatordb.com/docs/reference/functions/regular-functions/geo) and [GeoJSON](https://coordinatordb.com/docs/reference/formats/geo-json) for geometry operations and interchange.
