UNPKG

well-known-parser

Version:

A WKT/WKB/EWKT/EWKB/TWKB/GeoJSON parser and serializer

56 lines (55 loc) 1.85 kB
import { MultiLineString as a } from "./well-known-parser8.js"; import { LineString as c } from "./well-known-parser5.js"; import { Point as g } from "./well-known-parser4.js"; import { parseLineStringGeoJSON as S } from "./well-known-parser17.js"; import { parseRelativePointTwkb as l } from "./well-known-parser16.js"; import { parseWkb as d } from "./well-known-parser11.js"; function Z(r, t) { const n = new a(); if (n.srid = t.srid, n.hasZ = t.hasZ ?? !1, n.hasM = t.hasM ?? !1, r.isMatch(["EMPTY"])) return n; r.expectGroupStart(); do { r.expectGroupStart(); const i = r.matchCoordinates(t); n.lineStrings.push(new c(i)), r.expectGroupEnd(); } while (r.isMatch([","])); return r.expectGroupEnd(), n; } function G(r, t) { const n = new a(); n.srid = t.srid, n.hasZ = t.hasZ ?? !1, n.hasM = t.hasM ?? !1; const i = r.readUInt32(); for (let e = 0; e < i; e++) n.lineStrings.push(d(r, t)); return n; } function k(r, t) { const n = new a(); if (n.hasZ = t.hasZ ?? !1, n.hasM = t.hasM ?? !1, t.isEmpty) return n; const i = new g(0, 0, t.hasZ ? 0 : void 0, t.hasM ? 0 : void 0), e = r.readVarInt(); for (let o = 0; o < e; o++) { const s = new c(); s.hasZ = t.hasZ ?? !1, s.hasM = t.hasM ?? !1; const f = r.readVarInt(); for (let h = 0; h < f; h++) s.points.push(l(r, t, i)); n.lineStrings.push(s); } return n; } function x(r) { const t = new a(); r.coordinates.length > 0 && r.coordinates[0].length > 0 && (t.hasZ = r.coordinates[0][0].length > 2); for (let n = 0; n < r.coordinates.length; n++) t.lineStrings.push(S({ coordinates: r.coordinates[n] })); return t; } export { x as parseMultiLineStringGeoJSON, k as parseMultiLineStringTwkb, G as parseMultiLineStringWkb, Z as parseMultiLineStringWkt }; //# sourceMappingURL=well-known-parser20.js.map