Most practical way to parse WKT strings to get array of points?

2.1k Views Asked by At

I'm using open layers to zoomToExtent so I can auto center my screen on a set of randomly placed geometries.

I'm using some hacky regex that doesn't cover a lot of edge-cases and wondering if there is something in javascript to help parse WKT strings for me.

Example:

POLYGON ((35 10, 45 45, 15 40, 10 20, 35 10),
(20 30, 35 35, 30 20, 20 30))

Yields:

[[35,10], [45,45], [15,40].....

I've been looking at Turf, but haven't found anything they can do to solve this.

0

There are 0 best solutions below