UNPKG

well-known-parser

Version:

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

3 lines (2 loc) 1.39 kB
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("./well-known-parser4.cjs"),i=require("./well-known-parser13.cjs");function o(r,t){const e=new a.Point;if(e.srid=t.srid,e.hasZ=t.hasZ??!1,e.hasM=t.hasM??!1,r.isMatch(["EMPTY"]))return e;r.expectGroupStart();const n=r.matchCoordinate({hasZ:e.hasZ,hasM:e.hasM});return e.x=n.x,e.y=n.y,e.z=n.z,e.m=n.m,r.expectGroupEnd(),e}function h(r,t){const e=r.readDouble(),n=r.readDouble(),d=t.hasZ?r.readDouble():void 0,c=t.hasM?r.readDouble():void 0;return new a.Point(e,n,d,c,t.srid)}function P(r,t){if(t.isEmpty){const e=new a.Point(void 0,void 0,void 0,void 0,t.srid);return e.hasZ=t.hasZ??!1,e.hasM=t.hasM??!1,e}return s(r,t,new a.Point(0,0,t.hasZ?0:void 0,t.hasM?0:void 0))}function s(r,t,e){const n=t.precisionFactor??1,d=t.zPrecisionFactor??1,c=t.mPrecisionFactor??1;return e.x+=i.decode(r.readVarInt())/n,e.y+=i.decode(r.readVarInt())/n,t.hasZ&&(e.z+=i.decode(r.readVarInt())/d),t.hasM&&(e.m+=i.decode(r.readVarInt())/c),new a.Point(e.x,e.y,e.z,e.m,t.srid)}function f(r){return r.length===0?new a.Point(void 0,void 0,void 0,void 0):r.length>2?new a.Point(r[0],r[1],r[2],void 0):new a.Point(r[0],r[1],void 0,void 0)}exports.parsePointGeoJSON=f;exports.parsePointTwkb=P;exports.parsePointWkb=h;exports.parsePointWkt=o;exports.parseRelativePointTwkb=s; //# sourceMappingURL=well-known-parser16.cjs.map