well-known-parser
Version:
A WKT/WKB/EWKT/EWKB/TWKB/GeoJSON parser and serializer
3 lines (2 loc) • 2.01 kB
JavaScript
;Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("./well-known-parser9.cjs"),d=require("./well-known-parser6.cjs"),f=require("./well-known-parser4.cjs"),M=require("./well-known-parser18.cjs"),u=require("./well-known-parser16.cjs"),P=require("./well-known-parser11.cjs");function w(o,t){const n=new a.MultiPolygon;if(n.srid=t.srid,n.hasZ=t.hasZ??!1,n.hasM=t.hasM??!1,o.isMatch(["EMPTY"]))return n;o.expectGroupStart();do{o.expectGroupStart();const e=[],s=[];o.expectGroupStart();const c=o.matchCoordinates(t);for(const r of c)e.push(r);for(o.expectGroupEnd();o.isMatch([","]);){o.expectGroupStart();const r=o.matchCoordinates(t),l=[];for(const g of r)l.push(g);s.push(l),o.expectGroupEnd()}n.polygons.push(new d.Polygon(e,s)),o.expectGroupEnd()}while(o.isMatch([","]));return o.expectGroupEnd(),n}function x(o,t){const n=new a.MultiPolygon;n.srid=t.srid,n.hasZ=t.hasZ??!1,n.hasM=t.hasM??!1;const e=o.readUInt32();for(let s=0;s<e;s++)n.polygons.push(P.parseWkb(o,t));return n}function G(o,t){const n=new a.MultiPolygon;if(n.hasZ=t.hasZ??!1,n.hasM=t.hasM??!1,t.isEmpty)return n;const e=new f.Point(0,0,t.hasZ?0:void 0,t.hasM?0:void 0),s=o.readVarInt();for(let c=0;c<s;c++){const r=new d.Polygon;r.hasZ=t.hasZ??!1,r.hasM=t.hasM??!1;const l=o.readVarInt(),g=o.readVarInt();for(let i=0;i<g;i++)r.exteriorRing.push(u.parseRelativePointTwkb(o,t,e));for(let i=1;i<l;i++){const h=[],y=o.readVarInt();for(let p=0;p<y;p++)h.push(u.parseRelativePointTwkb(o,t,e));r.interiorRings.push(h)}n.polygons.push(r)}return n}function k(o){const t=new a.MultiPolygon;o.coordinates.length>0&&o.coordinates[0].length>0&&o.coordinates[0][0].length>0&&(t.hasZ=o.coordinates[0][0][0].length>2);for(let n=0;n<o.coordinates.length;n++)t.polygons.push(M.parsePolygonGeoJSON({coordinates:o.coordinates[n]}));return t}exports.parseMultiPolygonGeoJSON=k;exports.parseMultiPolygonTwkb=G;exports.parseMultiPolygonWkb=x;exports.parseMultiPolygonWkt=w;
//# sourceMappingURL=well-known-parser21.cjs.map