# parseWkt

Reads a Well-Known Text string into a GeoJSON geometry.

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

## Signature

```ts
import { parseWkt } from "@mapcairn/core";
 
function parseWkt(text: string, options?: ParseWktOptions): Geometry;
```

## Description

It reads `POINT`, `LINESTRING`, `POLYGON` (with holes), their `MULTI`
forms and `GEOMETRYCOLLECTION`, in any case and with any spacing, the
`EMPTY` form of each, and a height as a third number, with or without the
`Z` tag. A `MULTIPOINT` may bracket its points or not. It reads an EWKT
`SRID=4326;` prefix and refuses any other SRID as `unsupported`. It does
not read a measure (`M`, `ZM`) or curved shapes.

The parser is a hand-written tokenizer that never backtracks, so its time
grows with the length of the text however hostile the text is, and a
collection nested past `MAX_COLLECTION_DEPTH` is refused. The
result is checked as [`validateGeometry`](https://docs.mapcairn.com/api/core/validateGeometry.md) checks a shape, apart from
the range of the coordinates: WKT may hold projected coordinates, so
longitude and latitude are not held to degrees.

Positions are read as longitude then latitude; pass `axisOrder: "lat-lng"`
for text that writes latitude first. The result is always GeoJSON order.

## Parameters

- `text` (`string`)
- `options?` (`ParseWktOptions`)

## Returns

`Geometry`

## Throws

- `GeometryError` of kind `invalid` for text that is not WKT or whose shape
   is wrong (a message names the position), `unsupported` for a valid WKT
   feature this reader leaves out.

## See also

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

Source: [packages/core/src/geometry/wkt.ts:852](https://github.com/MapCairn/mapcairn/blob/main/packages/core/src/geometry/wkt.ts#L852)
