well-known-parser
Version:
A WKT/WKB/EWKT/EWKB/TWKB/GeoJSON parser and serializer
3 lines (2 loc) • 1.63 kB
JavaScript
;Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("./well-known-parser12.cjs"),h=require("./well-known-parser13.cjs");class d{constructor(){this.srid=void 0,this.hasZ=!1,this.hasM=!1}toEwkt(){return`SRID=${this.srid};${this.toWkt()}`}toEwkb(){const t=new n.BinaryWriter(this.getWkbSize()+4,!1),i=this.toWkb();return t.writeInt8(1),t.writeUInt32LE((i.subarray(1,5).readUInt32LE(0)|536870912)>>>0),t.writeUInt32LE(this.srid),t.writeBuffer(i.subarray(5)),t.buffer}getWktType(t,i){let e=t;return this.hasZ&&this.hasM?e+=" ZM ":this.hasZ?e+=" Z ":this.hasM&&(e+=" M "),i&&!this.hasZ&&!this.hasM&&(e+=" "),i&&(e+="EMPTY"),e}writeWkbType(t,i,e){let s=0;typeof this.srid>"u"&&(!e||typeof e.srid>"u")?this.hasZ&&this.hasM?s+=3e3:this.hasZ?s+=1e3:this.hasM&&(s+=2e3):(this.hasZ&&(s|=2147483648),this.hasM&&(s|=1073741824)),t.writeUInt32LE(s+i>>>0)}static getTwkbPrecision(t,i,e){return{xy:t,z:i,m:e,xyFactor:Math.pow(10,t),zFactor:Math.pow(10,i),mFactor:Math.pow(10,e)}}writeTwkbHeader(t,i,e,s){const a=(h.encode(e.xy)<<4)+i;let o=(this.hasZ||this.hasM?1:0)<<3;if(o+=s?16:0,t.writeUInt8(a),t.writeUInt8(o),this.hasZ||this.hasM){let r=0;this.hasZ&&(r|=1),this.hasM&&(r|=2),this.hasZ&&(r|=h.encode(e.z)<<2),this.hasM&&(r|=h.encode(e.m)<<5),t.writeUInt8(r)}}toGeoJSON(){throw new Error("Method not implemented.")}toWkt(){throw new Error("Method not implemented.")}toWkb(t){throw new Error("Method not implemented.")}toTwkb(){throw new Error("Method not implemented.")}getWkbSize(){throw new Error("Method not implemented.")}}exports.Geometry=d;
//# sourceMappingURL=well-known-parser3.cjs.map