well-known-parser
Version:
A WKT/WKB/EWKT/EWKB/TWKB/GeoJSON parser and serializer
48 lines (47 loc) • 1.38 kB
JavaScript
import { LineString as o } from "./well-known-parser5.js";
import { Point as a } from "./well-known-parser4.js";
import { parseRelativePointTwkb as c, parsePointGeoJSON as h, parsePointWkb as f } from "./well-known-parser16.js";
function S(r, n) {
const t = new o();
if (t.srid = n.srid, t.hasZ = n.hasZ ?? !1, t.hasM = n.hasM ?? !1, r.isMatch(["EMPTY"]))
return t;
r.expectGroupStart();
const i = r.matchCoordinates(n);
for (const s of i)
t.points.push(s);
return r.expectGroupEnd(), t;
}
function g(r, n) {
const t = new o();
t.srid = n.srid, t.hasZ = n.hasZ ?? !1, t.hasM = n.hasM ?? !1;
const i = r.readUInt32(), s = {
...n,
srid: void 0
};
for (let e = 0; e < i; e++)
t.points.push(f(r, s));
return t;
}
function l(r, n) {
const t = new o();
if (t.hasZ = n.hasZ ?? !1, t.hasM = n.hasM ?? !1, n.isEmpty)
return t;
const i = new a(0, 0, n.hasZ ? 0 : void 0, n.hasM ? 0 : void 0), s = r.readVarInt();
for (let e = 0; e < s; e++)
t.points.push(c(r, n, i));
return t;
}
function M(r) {
const n = new o();
r.coordinates.length > 0 && (n.hasZ = r.coordinates[0].length > 2);
for (const t of r.coordinates)
n.points.push(h(t));
return n;
}
export {
M as parseLineStringGeoJSON,
l as parseLineStringTwkb,
g as parseLineStringWkb,
S as parseLineStringWkt
};
//# sourceMappingURL=well-known-parser17.js.map