# validateGeometry

Checks that `input` is a well-formed GeoJSON geometry, or a feature holding
one, and returns the geometry itself (the same object, not a copy).

This is a function exported by `@mapcairn/core`, checked against version 0.2.0.

## Signature

```ts
import { validateGeometry } from "@mapcairn/core";
 
function validateGeometry(input: unknown, options?: ValidateOptions): Geometry;
```

## Description

It accepts empty geometries (a `Point` with `[]` for coordinates, a
`GeometryCollection` with no members) because they are legal GeoJSON; the
operations that cannot work on nothing refuse them with an `empty` error.
It refuses a position that is not two or three finite numbers, a line with
fewer than two positions, a ring that is open or shorter than four
positions, positions of different sizes inside one shape, and a collection
nested more than `MAX_COLLECTION_DEPTH` deep. By default it also
refuses a longitude or latitude outside the globe, which is how a shape
that runs past the antimeridian shows up: GeoJSON wants such a shape split
at 180 degrees.

## Parameters

- `input` (`unknown`)
- `options?` (`ValidateOptions`)

## Returns

`Geometry`

## Throws

- `GeometryError` of kind `invalid` for a malformed shape, `empty` for a
   feature with no geometry, `unsupported` for a feature collection.

## See also

- [`ValidateOptions`](https://docs.mapcairn.com/api/core/ValidateOptions.md)

Source: [packages/core/src/geometry/validate.ts:219](https://github.com/MapCairn/mapcairn/blob/main/packages/core/src/geometry/validate.ts#L219)
