readWktRecovering
Reads WKT text that holds one geometry or more, as readWktSequence
does, but goes on after a geometry it cannot use instead of giving up. It
gives each stretch of the text in turn, as a GeoJSON geometry (unchecked, as
readWktSequence leaves it) or as the GeometryError that says why
the stretch was left out, and is lazy: a caller that has enough stops
asking and the rest is never read.
This is a function exported by @mapcairn/core, checked against version 0.2.0.
Signature
import { readWktRecovering } from "@mapcairn/core";
function readWktRecovering(text: string, options?: ParseWktOptions): Generator<Geometry | GeometryError, void>;
Description
A geometry that is valid WKT the reader leaves out (a measure, a curved
type, a SRID other than 4326) is skipped to its closing bracket, so the
geometries after it, on the same line or not, are kept; once a bracket of it
is open the skip goes on over lines, so a collection written over several
lines is skipped whole. A skip that the end of the text, or a character the
reader does not know, ends inside a bracket is made again to the end of the
line the geometry began on; the tokens read for nothing are added up, and
once they are more than the length of the text every later skip ends at the
end of its line. Text that is damaged is skipped up
to the next line that starts with a geometry type or an SRID= prefix, and
counts as one stretch. Text with a character the reader does not know is
damaged in the same way. The time grows with the length of the text, however
many geometries are left open, and a few stray brackets do not change how
the geometries after them are read.
The text always gives at least one reading: an error for empty text.
Parameters
text(string)options?(ParseWktOptions)
Returns
Generator<Geometry | GeometryError, void>
Throws
GeometryErrorof kindinvalidwhen the text is not a string.