@loaders.gl/wkt 4.3.1 → 4.4.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dist.dev.js +1281 -1266
- package/dist/dist.min.js +2 -2
- package/dist/hex-wkb-loader.d.ts +6 -5
- package/dist/hex-wkb-loader.d.ts.map +1 -1
- package/dist/hex-wkb-loader.js +4 -4
- package/dist/index.cjs +51 -1622
- package/dist/index.cjs.map +4 -4
- package/dist/index.d.ts +0 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -5
- package/dist/lib/version.d.ts.map +1 -0
- package/dist/lib/{utils/version.js → version.js} +1 -1
- package/dist/twkb-loader.d.ts +3 -3
- package/dist/twkb-loader.d.ts.map +1 -1
- package/dist/twkb-loader.js +4 -4
- package/dist/twkb-writer.d.ts +2 -1
- package/dist/twkb-writer.d.ts.map +1 -1
- package/dist/twkb-writer.js +5 -4
- package/dist/wkb-loader.d.ts +13 -11
- package/dist/wkb-loader.d.ts.map +1 -1
- package/dist/wkb-loader.js +14 -6
- package/dist/wkb-writer.d.ts +3 -2
- package/dist/wkb-writer.d.ts.map +1 -1
- package/dist/wkb-writer.js +5 -4
- package/dist/wkt-crs-loader.d.ts +1 -1
- package/dist/wkt-crs-loader.d.ts.map +1 -1
- package/dist/wkt-crs-loader.js +2 -2
- package/dist/wkt-crs-writer.d.ts +1 -1
- package/dist/wkt-crs-writer.d.ts.map +1 -1
- package/dist/wkt-crs-writer.js +2 -2
- package/dist/wkt-loader.d.ts +2 -2
- package/dist/wkt-loader.d.ts.map +1 -1
- package/dist/wkt-loader.js +4 -4
- package/dist/wkt-worker.js +26 -13
- package/dist/wkt-writer.d.ts +6 -5
- package/dist/wkt-writer.d.ts.map +1 -1
- package/dist/wkt-writer.js +10 -7
- package/package.json +6 -6
- package/src/hex-wkb-loader.ts +8 -8
- package/src/index.ts +0 -10
- package/src/twkb-loader.ts +5 -5
- package/src/twkb-writer.ts +6 -5
- package/src/wkb-loader.ts +24 -12
- package/src/wkb-writer.ts +8 -7
- package/src/wkt-crs-loader.ts +3 -3
- package/src/wkt-crs-writer.ts +3 -5
- package/src/wkt-loader.ts +6 -5
- package/src/wkt-writer.ts +11 -8
- package/dist/lib/encode-twkb.d.ts +0 -6
- package/dist/lib/encode-twkb.d.ts.map +0 -1
- package/dist/lib/encode-twkb.js +0 -195
- package/dist/lib/encode-wkb.d.ts +0 -33
- package/dist/lib/encode-wkb.d.ts.map +0 -1
- package/dist/lib/encode-wkb.js +0 -286
- package/dist/lib/encode-wkt-crs.d.ts +0 -10
- package/dist/lib/encode-wkt-crs.d.ts.map +0 -1
- package/dist/lib/encode-wkt-crs.js +0 -35
- package/dist/lib/encode-wkt.d.ts +0 -8
- package/dist/lib/encode-wkt.d.ts.map +0 -1
- package/dist/lib/encode-wkt.js +0 -47
- package/dist/lib/parse-hex-wkb.d.ts +0 -1
- package/dist/lib/parse-hex-wkb.d.ts.map +0 -1
- package/dist/lib/parse-hex-wkb.js +0 -1
- package/dist/lib/parse-twkb.d.ts +0 -9
- package/dist/lib/parse-twkb.d.ts.map +0 -1
- package/dist/lib/parse-twkb.js +0 -253
- package/dist/lib/parse-wkb-header.d.ts +0 -39
- package/dist/lib/parse-wkb-header.d.ts.map +0 -1
- package/dist/lib/parse-wkb-header.js +0 -134
- package/dist/lib/parse-wkb.d.ts +0 -5
- package/dist/lib/parse-wkb.d.ts.map +0 -1
- package/dist/lib/parse-wkb.js +0 -241
- package/dist/lib/parse-wkt-crs.d.ts +0 -15
- package/dist/lib/parse-wkt-crs.d.ts.map +0 -1
- package/dist/lib/parse-wkt-crs.js +0 -120
- package/dist/lib/parse-wkt.d.ts +0 -30
- package/dist/lib/parse-wkt.d.ts.map +0 -1
- package/dist/lib/parse-wkt.js +0 -288
- package/dist/lib/utils/base64-encoder.d.ts +0 -5
- package/dist/lib/utils/base64-encoder.d.ts.map +0 -1
- package/dist/lib/utils/base64-encoder.js +0 -153
- package/dist/lib/utils/binary-reader.d.ts +0 -18
- package/dist/lib/utils/binary-reader.d.ts.map +0 -1
- package/dist/lib/utils/binary-reader.js +0 -69
- package/dist/lib/utils/binary-writer.d.ts +0 -28
- package/dist/lib/utils/binary-writer.d.ts.map +0 -1
- package/dist/lib/utils/binary-writer.js +0 -121
- package/dist/lib/utils/hex-encoder.d.ts +0 -15
- package/dist/lib/utils/hex-encoder.d.ts.map +0 -1
- package/dist/lib/utils/hex-encoder.js +0 -54
- package/dist/lib/utils/hex-transcoder.d.ts +0 -15
- package/dist/lib/utils/hex-transcoder.d.ts.map +0 -1
- package/dist/lib/utils/hex-transcoder.js +0 -50
- package/dist/lib/utils/version.d.ts.map +0 -1
- package/src/lib/encode-twkb.ts +0 -308
- package/src/lib/encode-wkb.ts +0 -390
- package/src/lib/encode-wkt-crs.ts +0 -41
- package/src/lib/encode-wkt.ts +0 -56
- package/src/lib/parse-hex-wkb.ts +0 -0
- package/src/lib/parse-twkb.ts +0 -365
- package/src/lib/parse-wkb-header.ts +0 -174
- package/src/lib/parse-wkb.ts +0 -343
- package/src/lib/parse-wkt-crs.ts +0 -149
- package/src/lib/parse-wkt.ts +0 -327
- package/src/lib/utils/base64-encoder.ts +0 -157
- package/src/lib/utils/binary-reader.ts +0 -76
- package/src/lib/utils/binary-writer.ts +0 -127
- package/src/lib/utils/hex-encoder.ts +0 -60
- package/src/lib/utils/hex-transcoder.ts +0 -54
- /package/dist/lib/{utils/version.d.ts → version.d.ts} +0 -0
- /package/src/lib/{utils/version.ts → version.ts} +0 -0
package/dist/dist.min.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
else if (typeof define === 'function' && define.amd) define([], factory);
|
|
5
5
|
else if (typeof exports === 'object') exports['loaders'] = factory();
|
|
6
6
|
else root['loaders'] = factory();})(globalThis, function () {
|
|
7
|
-
"use strict";var __exports__=(()=>{var _e=Object.create;var K=Object.defineProperty;var $e=Object.getOwnPropertyDescriptor;var De=Object.getOwnPropertyNames;var Ze=Object.getPrototypeOf,je=Object.prototype.hasOwnProperty;var He=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Je=(e,t)=>{for(var n in t)K(e,n,{get:t[n],enumerable:!0})},U=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of De(t))!je.call(e,o)&&o!==n&&K(e,o,{get:()=>t[o],enumerable:!(r=$e(t,o))||r.enumerable});return e},A=(e,t,n)=>(U(e,t,"default"),n&&U(n,t,"default")),Ye=(e,t,n)=>(n=e!=null?_e(Ze(e)):{},U(t||!e||!e.__esModule?K(n,"default",{value:e,enumerable:!0}):n,e)),Xe=e=>U(K({},"__esModule",{value:!0}),e);var ae=He((_t,le)=>{le.exports=globalThis.loaders});var k={};Je(k,{HexWKBLoader:()=>ve,TWKBLoader:()=>Fe,TWKBWriter:()=>Ne,WKBLoader:()=>O,WKBWorkerLoader:()=>oe,WKBWriter:()=>Ke,WKTCRSLoader:()=>ye,WKTCRSWriter:()=>pe,WKTLoader:()=>we,WKTWorkerLoader:()=>q,WKTWriter:()=>Pe,decodeHex:()=>j,encodeHex:()=>Ve,isTWKB:()=>H,isWKB:()=>F,isWKT:()=>G,parseWKBHeader:()=>R});A(k,Ye(ae(),1));var p="4.3.0";function J(e,t){t?.debug&&console.log(`[wktcrs] parse starting with
|
|
8
|
-
`,e),e=e.replace(/[A-Z][A-Z\d_]+\[/gi,i=>`["${i.substr(0,i.length-1)}",`),e=e.replace(/, ?([A-Z][A-Z\d_]+[,\]])/gi,(i,s)=>{let c=s.substr(0,s.length-1);return`,"${t?.raw?"raw:":""}${c}"${s[s.length-1]}`}),t?.raw&&(e=e.replace(/, {0,2}(-?[\.\d]+)(?=,|\])/g,function(i,s){return`,"${t?.raw?"raw:":""}${s}"`})),t?.debug&&console.log(`[wktcrs] json'd wkt: '${e}'`);let n;try{n=JSON.parse(e)}catch(i){throw console.error(`[wktcrs] failed to parse '${e}'`),i}t?.debug&&console.log(`[wktcrs] json parsed: '${e}'`);function r(i,s){let c=i[0];i.forEach(function(l){Array.isArray(l)&&r(l,i)});let u=`MULTIPLE_${c}`;return u in s?s[u].push(i):c in s?(s[u]=[s[c],i],delete s[c]):s[c]=i,s}let o=r(n,[n]);return t?.debug&&console.log("[wktcrs] parse returning",o),t?.sort&&fe(o,t),o}function fe(e,t){let n=Object.keys(e).filter(o=>!/\d+/.test(o)),r=t?.keywords||[];if(!t?.keywords){let o={};if(Array.isArray(e)){e.forEach(i=>{if(Array.isArray(i)&&i.length>=2&&typeof i[1]=="string"){let s=i[0];o[s]||(o[s]=0),o[s]++}});for(let i in o)o[i]>0&&r.push(i)}}return n.forEach(o=>{e[o]=fe(e[o])}),r.forEach(o=>{let i=[],s=[];e.forEach((c,u)=>{Array.isArray(c)&&c[0]===o&&(i.push(u),s.push(c))}),s.sort((c,u)=>(c=c[1].toString(),u=u[1].toString(),c<u?-1:c>u?1:0)),s.forEach((c,u)=>{e[i[u]]=c})}),e}var ye={dataType:null,batchType:null,name:"WKT CRS (Well-Known Text Coordinate Reference System)",id:"wkt-crs",module:"wkt-crs",version:p,worker:!0,extensions:[],mimeTypes:["text/plain"],category:"json",text:!0,options:{"wkt-crs":{}},parse:async(e,t)=>J(new TextDecoder().decode(e),t?.["wkt-crs"]),parseTextSync:(e,t)=>J(e,t?.["wkt-crs"])};function M(e,t){Array.isArray(e)&&e.length===1&&Array.isArray(e[0])&&(e=e[0]);let[n,...r]=e;return`${n}[${r.map(i=>{if(Array.isArray(i))return M(i,t);if(typeof i=="number")return i.toString();if(typeof i=="string")return i.startsWith("raw:")?i.replace("raw:",""):`"${i}"`;throw new Error(`[wktcrs] unexpected attribute "${i}"`)}).join(",")}]`}var pe={name:"WKT CRS (Well-Known Text Coordinate Reference System)",id:"wkt-crs",module:"wkt-crs",version:p,worker:!0,extensions:[],mimeTypes:["text/plain"],text:!0,options:{"wkt-crs":{}},encode:async(e,t)=>new TextEncoder().encode(M(e,t?.["wkt-crs"])),encodeSync:(e,t)=>new TextEncoder().encode(M(e,t?.["wkt-crs"])),encodeTextSync:(e,t)=>M(e,t?.["wkt-crs"])};var ge=/[-+]?([0-9]*\.[0-9]+|[0-9]+)([eE][-+]?[0-9]+)?/,he=new RegExp("^"+ge.source+"(\\s"+ge.source+"){1,}"),Y=["POINT(","LINESTRING(","POLYGON(","MULTIPOINT(","MULTILINESTRING(","MULTIPOLYGON(","GEOMETRYCOLLECTION("];function G(e){return Y.some(t=>e.startsWith(t))}function X(e,t){return qe(e,t)}function qe(e,t){let n=e.split(";"),r=n.pop(),o=(n.shift()||"").split("=").pop(),s=de({parts:n,_:r,i:0});return t?.wkt?.crs?Qe(s,o):s}function de(e){return et(e)||nt(e)||ot(e)||tt(e)||rt(e)||it(e)||st(e)}function Qe(e,t){if(e&&t?.match(/\d+/)){let n={type:"name",properties:{name:"urn:ogc:def:crs:EPSG::"+t}};e.crs=n}return e}function et(e){if(!f(/^(POINT(\sz)?)/i,e)||(g(e),!f(/^(\()/,e)))return null;let t=me(e);return!t||(g(e),!f(/^(\))/,e))?null:{type:"Point",coordinates:t[0]}}function tt(e){if(!f(/^(MULTIPOINT)/i,e))return null;g(e);let t=e._?.substring(e._?.indexOf("(")+1,e._.length-1).replace(/\(/g,"").replace(/\)/g,"");e._="MULTIPOINT ("+t+")";let n=V(e);return n?(g(e),{type:"MultiPoint",coordinates:n}):null}function nt(e){if(!f(/^(LINESTRING(\sz)?)/i,e)||(g(e),!f(/^(\()/,e)))return null;let t=me(e);return!t||!f(/^(\))/,e)?null:{type:"LineString",coordinates:t}}function rt(e){if(!f(/^(MULTILINESTRING)/i,e))return null;g(e);let t=V(e);return t?(g(e),{type:"MultiLineString",coordinates:t}):null}function ot(e){if(!f(/^(POLYGON(\sz)?)/i,e))return null;g(e);let t=V(e);return t?{type:"Polygon",coordinates:t}:null}function it(e){if(!f(/^(MULTIPOLYGON)/i,e))return null;g(e);let t=V(e);return t?{type:"MultiPolygon",coordinates:t}:null}function st(e){let t=[],n;if(!f(/^(GEOMETRYCOLLECTION)/i,e)||(g(e),!f(/^(\()/,e)))return null;for(;n=de(e);)t.push(n),g(e),f(/^(,)/,e),g(e);return f(/^(\))/,e)?{type:"GeometryCollection",geometries:t}:null}function V(e){g(e);let t=0,n=[],r=[n],o=n,i;for(;i=f(/^(\()/,e)||f(/^(\))/,e)||f(/^(,)/,e)||f(he,e);){if(i==="(")r.push(o),o=[],r[r.length-1].push(o),t++;else if(i===")"){if(o.length===0||(o=r.pop(),!o))return null;if(t--,t===0)break}else if(i===",")o=[],r[r.length-1].push(o);else if(!i.split(/\s/g).some(isNaN))Array.prototype.push.apply(o,i.split(/\s/g).map(parseFloat));else return null;g(e)}return t!==0?null:n}function me(e){let t=[],n,r;for(;r=f(he,e)||f(/^(,)/,e);)r===","?(t.push(n),n=[]):r.split(/\s/g).some(isNaN)||(n||(n=[]),Array.prototype.push.apply(n,r.split(/\s/g).map(parseFloat))),g(e);if(n)t.push(n);else return null;return t.length?t:null}function f(e,t){let n=t._?.substring(t.i).match(e);return n?(t.i+=n[0].length,n[0]):null}function g(e){f(/^\s*/,e)}var q={dataType:null,batchType:null,name:"WKT (Well-Known Text)",id:"wkt",module:"wkt",version:p,worker:!0,extensions:["wkt"],mimeTypes:["text/plain"],category:"geometry",text:!0,tests:Y,testText:G,options:{wkt:{shape:"geojson-geometry",crs:!0}}},we={...q,parse:async(e,t)=>X(new TextDecoder().decode(e),t),parseTextSync:(e,t)=>X(e,t)};function z(e){switch(e.type==="Feature"&&(e=e.geometry),e.type){case"Point":return`POINT ${I(Ie(e.coordinates))}`;case"LineString":return`LINESTRING ${I(Q(e.coordinates))}`;case"Polygon":return`POLYGON ${I(ee(e.coordinates))}`;case"MultiPoint":return`MULTIPOINT ${I(Q(e.coordinates))}`;case"MultiPolygon":return`MULTIPOLYGON ${I(ct(e.coordinates))}`;case"MultiLineString":return`MULTILINESTRING ${I(ee(e.coordinates))}`;case"GeometryCollection":return`GEOMETRYCOLLECTION ${I(e.geometries.map(z).join(", "))}`;default:throw new Error("stringify requires a valid GeoJSON Feature or geometry object as input")}}function Ie(e){return e.join(" ")}function Q(e){return e.map(Ie).join(", ")}function ee(e){return e.map(Q).map(I).join(", ")}function ct(e){return e.map(ee).map(I).join(", ")}function I(e){return`(${e})`}var Pe={name:"WKT (Well Known Text)",id:"wkt",module:"wkt",version:p,extensions:["wkt"],text:!0,encode:async e=>be(e),encodeSync:be,encodeTextSync:z,options:{wkt:{}}};function be(e){return new TextEncoder().encode(z(e)).buffer}function C(e,t,n){switch(e.type){case"Point":return lt(e,t,n);case"LineString":return ut(e,t,n);case"Polygon":return Se(e,t,n);default:let r=e;throw new Error(`Unsupported geometry type: ${r?.type}`)}}function Se(e,t=-1/0,n=1/0){let{positions:r}=e,o=e.polygonIndices.value.filter(u=>u>=t&&u<=n),i=e.primitivePolygonIndices.value.filter(u=>u>=t&&u<=n);if(!(o.length>2)){let u=[];for(let l=0;l<i.length-1;l++){let y=i[l],h=i[l+1],m=v(r,y,h);u.push(m)}return{type:"Polygon",coordinates:u}}let c=[];for(let u=0;u<o.length-1;u++){let l=o[u],y=o[u+1],h=Se(e,l,y).coordinates;c.push(h)}return{type:"MultiPolygon",coordinates:c}}function ut(e,t=-1/0,n=1/0){let{positions:r}=e,o=e.pathIndices.value.filter(c=>c>=t&&c<=n);if(!(o.length>2))return{type:"LineString",coordinates:v(r,o[0],o[1])};let s=[];for(let c=0;c<o.length-1;c++){let u=v(r,o[c],o[c+1]);s.push(u)}return{type:"MultiLineString",coordinates:s}}function lt(e,t,n){let{positions:r}=e,o=v(r,t,n);return o.length>1?{type:"MultiPoint",coordinates:o}:{type:"Point",coordinates:o[0]}}function v(e,t,n){t=t||0,n=n||e.value.length/e.size;let r=[];for(let o=t;o<n;o++){let i=Array();for(let s=o*e.size;s<(o+1)*e.size;s++)i.push(Number(e.value[s]));r.push(i)}return r}var a;(function(e){e[e.Point=1]="Point",e[e.LineString=2]="LineString",e[e.Polygon=3]="Polygon",e[e.MultiPoint=4]="MultiPoint",e[e.MultiLineString=5]="MultiLineString",e[e.MultiPolygon=6]="MultiPolygon",e[e.GeometryCollection=7]="GeometryCollection"})(a||(a={}));function F(e){let t=new DataView(e),n=0,r=t.getUint8(n);if(n+=1,r>1)return!1;let o=r===1,i=t.getUint32(n,o);n+=4;let s=i&7;if(s===0||s>7)return!1;let c=i-s;if(c===0||c===1e3||c===2e3||c===3e3)return!0;if(c&536870911)return!1;if(c&536870912){let u=t.getUint32(n,o);if(n+=4,u>1e4)return!1}return!0}function R(e,t){let n=Object.assign(t||{},{type:"wkb",geometryType:1,dimensions:2,coordinates:"xy",littleEndian:!0,byteOffset:0});n.littleEndian=e.getUint8(n.byteOffset)===1,n.byteOffset++;let r=e.getUint32(n.byteOffset,n.littleEndian);n.byteOffset+=4,n.geometryType=r&7;let o=(r-n.geometryType)/1e3;switch(o){case 0:break;case 1:n.type="iso-wkb",n.dimensions=3,n.coordinates="xyz";break;case 2:n.type="iso-wkb",n.dimensions=3,n.coordinates="xym";break;case 3:n.type="iso-wkb",n.dimensions=4,n.coordinates="xyzm";break;default:throw new Error(`WKB: Unsupported iso-wkb type: ${o}`)}let i=r&2147483648,s=r&1073741824,c=r&536870912;return i&&s?(n.type="ewkb",n.dimensions=4,n.coordinates="xyzm"):i?(n.type="ewkb",n.dimensions=3,n.coordinates="xyz"):s&&(n.type="ewkb",n.dimensions=3,n.coordinates="xym"),c&&(n.type="ewkb",n.srid=e.getUint32(n.byteOffset,n.littleEndian),n.byteOffset+=4),n}function te(e,t){let n=at(e,t),r=t?.wkb?.shape||"binary-geometry";switch(r){case"binary-geometry":return n;case"geojson-geometry":return C(n);case"geometry":return console.error('WKBLoader: "geometry" shape is deprecated, use "binary-geometry" instead'),C(n);default:throw new Error(r)}}function at(e,t){let n=new DataView(e),r=R(n),{geometryType:o,dimensions:i,littleEndian:s}=r,c=r.byteOffset;switch(o){case a.Point:return Le(n,c,i,s).geometry;case a.LineString:return ne(n,c,i,s).geometry;case a.Polygon:return Ee(n,c,i,s).geometry;case a.MultiPoint:let h=ft(n,c,i,s);return h.type="Point",h;case a.MultiLineString:let m=yt(n,c,i,s);return m.type="LineString",m;case a.MultiPolygon:let T=pt(n,c,i,s);return T.type="Polygon",T;default:throw new Error(`WKB: Unsupported geometry type: ${o}`)}}function Le(e,t,n,r){let o=new Float64Array(n);for(let i=0;i<n;i++)o[i]=e.getFloat64(t,r),t+=8;return{geometry:{type:"Point",positions:{value:o,size:n}},offset:t}}function ne(e,t,n,r){let o=e.getUint32(t,r);t+=4;let i=new Float64Array(o*n);for(let c=0;c<o*n;c++)i[c]=e.getFloat64(t,r),t+=8;let s=[0];return o>0&&s.push(o),{geometry:{type:"LineString",positions:{value:i,size:n},pathIndices:{value:new Uint32Array(s),size:1}},offset:t}}var re=e=>t=>e+=t;function Ee(e,t,n,r){let o=e.getUint32(t,r);t+=4;let i=[];for(let l=0;l<o;l++){let y=ne(e,t,n,r),{positions:h}=y.geometry;t=y.offset,i.push(h.value)}let s=new Float64Array(N(i).buffer),c=[0];s.length>0&&c.push(s.length/n);let u=i.map(l=>l.length/n).map(re(0));return u.unshift(0),{geometry:{type:"Polygon",positions:{value:s,size:n},polygonIndices:{value:new Uint32Array(c),size:1},primitivePolygonIndices:{value:new Uint32Array(u),size:1}},offset:t}}function ft(e,t,n,r){let o=e.getUint32(t,r);t+=4;let i=[];for(let s=0;s<o;s++){let c=e.getUint8(t)===1;if(t++,e.getUint32(t,c)%1e3!==1)throw new Error("WKB: Inner geometries of MultiPoint not of type Point");t+=4;let u=Le(e,t,n,c);t=u.offset,i.push(u.geometry)}return gt(i,n)}function yt(e,t,n,r){let o=e.getUint32(t,r);t+=4;let i=[];for(let s=0;s<o;s++){let c=e.getUint8(t)===1;if(t++,e.getUint32(t,c)%1e3!==2)throw new Error("WKB: Inner geometries of MultiLineString not of type LineString");t+=4;let u=ne(e,t,n,c);t=u.offset,i.push(u.geometry)}return ht(i,n)}function pt(e,t,n,r){let o=e.getUint32(t,r);t+=4;let i=[];for(let s=0;s<o;s++){let c=e.getUint8(t)===1;if(t++,e.getUint32(t,c)%1e3!==3)throw new Error("WKB: Inner geometries of MultiPolygon not of type Polygon");t+=4;let u=Ee(e,t,n,c);t=u.offset,i.push(u.geometry)}return dt(i,n)}function gt(e,t){let n=e.map(o=>o.positions.value);return{type:"Point",positions:{value:new Float64Array(N(n).buffer),size:t}}}function ht(e,t){let n=e.map(i=>i.positions.value),r=new Float64Array(N(n).buffer),o=n.map(i=>i.length/t).map(re(0));return o.unshift(0),{type:"LineString",positions:{value:r,size:t},pathIndices:{value:new Uint32Array(o),size:1}}}function dt(e,t){let n=[],r=[];for(let c of e){let{positions:u,primitivePolygonIndices:l}=c;n.push(u.value),r.push(l.value)}let o=new Float64Array(N(n).buffer),i=n.map(c=>c.length/t).map(re(0));i.unshift(0);let s=[0];for(let c of r)s.push(...c.filter(u=>u>0).map(u=>u+s[s.length-1]));return{type:"Polygon",positions:{value:o,size:t},polygonIndices:{value:new Uint32Array(i),size:1},primitivePolygonIndices:{value:new Uint32Array(s),size:1}}}function N(e){let t=0;for(let o=0;o<e.length;++o)t+=e[o].byteLength;let n=new Uint8Array(t),r=0;for(let o=0;o<e.length;++o){let i=new Uint8Array(e[o].buffer);t=i.length;for(let s=0;s<t;++s)n[r++]=i[s]}return n}var oe={dataType:null,batchType:null,name:"WKB",id:"wkb",module:"wkt",version:p,worker:!0,category:"geometry",extensions:["wkb"],mimeTypes:[],tests:[F],options:{wkb:{shape:"binary-geometry"}}},O={...oe,parse:async e=>te(e),parseSync:te};var d=class{arrayBuffer;dataView;byteOffset=0;allowResize=!1;constructor(t,n){this.arrayBuffer=new ArrayBuffer(t),this.dataView=new DataView(this.arrayBuffer),this.byteOffset=0,this.allowResize=n||!1}writeUInt8(t){this._ensureSize(1),this.dataView.setUint8(this.byteOffset,t),this.byteOffset+=1}writeUInt16LE(t){this._ensureSize(2),this.dataView.setUint16(this.byteOffset,t,!0),this.byteOffset+=2}writeUInt16BE(t){this._ensureSize(2),this.dataView.setUint16(this.byteOffset,t,!1),this.byteOffset+=2}writeUInt32LE(t){this._ensureSize(4),this.dataView.setUint32(this.byteOffset,t,!0),this.byteOffset+=4}writeUInt32BE(t){this._ensureSize(4),this.dataView.setUint32(this.byteOffset,t,!1),this.byteOffset+=4}writeInt8(t){this._ensureSize(1),this.dataView.setInt8(this.byteOffset,t),this.byteOffset+=1}writeInt16LE(t){this._ensureSize(2),this.dataView.setInt16(this.byteOffset,t,!0),this.byteOffset+=2}writeInt16BE(t){this._ensureSize(2),this.dataView.setInt16(this.byteOffset,t,!1),this.byteOffset+=2}writeInt32LE(t){this._ensureSize(4),this.dataView.setInt32(this.byteOffset,t,!0),this.byteOffset+=4}writeInt32BE(t){this._ensureSize(4),this.dataView.setInt32(this.byteOffset,t,!1),this.byteOffset+=4}writeFloatLE(t){this._ensureSize(4),this.dataView.setFloat32(this.byteOffset,t,!0),this.byteOffset+=4}writeFloatBE(t){this._ensureSize(4),this.dataView.setFloat32(this.byteOffset,t,!1),this.byteOffset+=4}writeDoubleLE(t){this._ensureSize(8),this.dataView.setFloat64(this.byteOffset,t,!0),this.byteOffset+=8}writeDoubleBE(t){this._ensureSize(8),this.dataView.setFloat64(this.byteOffset,t,!1),this.byteOffset+=8}writeVarInt(t){let n=1;for(;t&4294967168;)this.writeUInt8(t&127|128),t>>>=7,n++;return this.writeUInt8(t&127),n}writeBuffer(t){this._ensureSize(t.byteLength),new Uint8Array(this.arrayBuffer).set(new Uint8Array(t),this.byteOffset),this.byteOffset+=t.byteLength}_ensureSize(t){if(this.arrayBuffer.byteLength<this.byteOffset+t)if(this.allowResize){let n=new ArrayBuffer(this.byteOffset+t);new Uint8Array(n).set(new Uint8Array(this.arrayBuffer)),this.arrayBuffer=n}else throw new Error("BinaryWriter overflow")}};var b;(function(e){e[e.Point=1]="Point",e[e.LineString=2]="LineString",e[e.Polygon=3]="Polygon",e[e.MultiPoint=4]="MultiPoint",e[e.MultiLineString=5]="MultiLineString",e[e.MultiPolygon=6]="MultiPolygon",e[e.GeometryCollection=7]="GeometryCollection"})(b||(b={}));function $(e,t={}){switch(e.type==="Feature"&&(e=e.geometry),e.type){case"Point":return Te(e.coordinates,t);case"LineString":return Oe(e.coordinates,t);case"Polygon":return xe(e.coordinates,t);case"MultiPoint":return wt(e,t);case"MultiPolygon":return bt(e,t);case"MultiLineString":return It(e,t);case"GeometryCollection":return Pt(e,t);default:let n=e;throw new Error(`Unhandled case: ${n}`)}}function mt(e,t){switch(e.type){case"Point":return Me(t);case"LineString":return ie(e.coordinates,t);case"Polygon":return se(e.coordinates,t);case"MultiPoint":return Be(e,t);case"MultiPolygon":return ke(e,t);case"MultiLineString":return We(e,t);case"GeometryCollection":return Ue(e,t);default:let n=e;throw new Error(`Unhandled case: ${n}`)}}function Te(e,t){let n=new d(Me(t));return n.writeInt8(1),P(n,b.Point,t),typeof e[0]>"u"&&typeof e[1]>"u"?(n.writeDoubleLE(NaN),n.writeDoubleLE(NaN),t.hasZ&&n.writeDoubleLE(NaN),t.hasM&&n.writeDoubleLE(NaN)):_(n,e,t),n.arrayBuffer}function _(e,t,n){e.writeDoubleLE(t[0]),e.writeDoubleLE(t[1]),n.hasZ&&e.writeDoubleLE(t[2]),n.hasM&&e.writeDoubleLE(t[3])}function Me(e){let t=D(e);return 1+4+t}function Oe(e,t){let n=ie(e,t),r=new d(n);r.writeInt8(1),P(r,b.LineString,t),r.writeUInt32LE(e.length);for(let o of e)_(r,o,t);return r.arrayBuffer}function ie(e,t){let n=D(t);return 1+4+4+e.length*n}function xe(e,t){let n=new d(se(e,t));n.writeInt8(1),P(n,b.Polygon,t);let[r,...o]=e;r.length>0?(n.writeUInt32LE(1+o.length),n.writeUInt32LE(r.length)):n.writeUInt32LE(0);for(let i of r)_(n,i,t);for(let i of o){n.writeUInt32LE(i.length);for(let s of i)_(n,s,t)}return n.arrayBuffer}function se(e,t){let n=D(t),[r,...o]=e,i=1+4+4;r.length>0&&(i+=4+r.length*n);for(let s of o)i+=4+s.length*n;return i}function wt(e,t){let n=new d(Be(e,t)),r=e.coordinates;n.writeInt8(1),P(n,b.MultiPoint,t),n.writeUInt32LE(r.length);for(let o of r){let i=Te(o,t);n.writeBuffer(i)}return n.arrayBuffer}function Be(e,t){let n=D(t),r=e.coordinates;return n+=5,1+4+4+r.length*n}function It(e,t){let n=new d(We(e,t)),r=e.coordinates;n.writeInt8(1),P(n,b.MultiLineString,t),n.writeUInt32LE(r.length);for(let o of r){let i=Oe(o,t);n.writeBuffer(i)}return n.arrayBuffer}function We(e,t){let n=9,r=e.coordinates;for(let o of r)n+=ie(o,t);return n}function bt(e,t){let n=new d(ke(e,t)),r=e.coordinates;n.writeInt8(1),P(n,b.MultiPolygon,t),n.writeUInt32LE(r.length);for(let o of r){let i=xe(o,t);n.writeBuffer(i)}return n.arrayBuffer}function ke(e,t){let n=9,r=e.coordinates;for(let o of r)n+=se(o,t);return n}function Pt(e,t){let n=new d(Ue(e,t));n.writeInt8(1),P(n,b.GeometryCollection,t),n.writeUInt32LE(e.geometries.length);for(let r of e.geometries){let o=$(r,t);n.writeBuffer(o)}return n.arrayBuffer}function Ue(e,t){let n=9;for(let r of e.geometries)n+=mt(r,t);return n}function P(e,t,n){let{hasZ:r,hasM:o,srid:i}=n,s=0;i?(r&&(s|=2147483648),o&&(s|=1073741824)):r&&o?s+=3e3:r?s+=1e3:o&&(s+=2e3),e.writeUInt32LE(s+t>>>0)}function D(e){let t=16;return e.hasZ&&(t+=8),e.hasM&&(t+=8),t}var Ke={name:"WKB (Well Known Binary)",id:"wkb",module:"wkt",version:p,extensions:["wkb"],options:{wkb:{hasZ:!1,hasM:!1}},async encode(e,t){return $(e,t?.wkb)},encodeSync(e,t){return $(e,t?.wkb)}};var Ae="0123456789abcdef",Ge=[],Z=[];for(let e=0;e<256;e++)Ge[e]=Ae[e>>4&15]+Ae[e&15],e<16&&(e<10?Z[48+e]=e:Z[97-10+e]=e);function Ve(e){let t=e.length,n="",r=0;for(;r<t;)n+=Ge[e[r++]];return n}function j(e){let t=e.length>>1,n=t<<1,r=new Uint8Array(t),o=0,i=0;for(;i<n;)r[o++]=Z[e.charCodeAt(i++)]<<4|Z[e.charCodeAt(i++)];return r}var ve={dataType:null,batchType:null,name:"Hexadecimal WKB",id:"wkb",module:"wkt",version:p,worker:!0,category:"geometry",extensions:["wkb"],mimeTypes:[],options:O.options,text:!0,testText:St,parse:async e=>ze(new TextDecoder().decode(e)),parseTextSync:ze};function ze(e,t){let n=j(e);return O.parseSync?.(n.buffer,t)}function St(e){return!e||e.length<10||e.length%2!==0||!e.startsWith("00")&&!e.startsWith("01")?!1:/^[0-9a-fA-F]+$/.test(e.slice(2))}var x=class{arrayBuffer;dataView;byteOffset;littleEndian;constructor(t,n=!1){this.arrayBuffer=t,this.dataView=new DataView(t),this.byteOffset=0,this.littleEndian=!n}readUInt8(){let t=this.dataView.getUint8(this.byteOffset);return this.byteOffset+=1,t}readUInt16(){let t=this.dataView.getUint16(this.byteOffset,this.littleEndian);return this.byteOffset+=2,t}readUInt32(){let t=this.dataView.getUint32(this.byteOffset,this.littleEndian);return this.byteOffset+=4,t}readInt8(){let t=this.dataView.getInt8(this.byteOffset);return this.byteOffset+=1,t}readInt16(){let t=this.dataView.getInt16(this.byteOffset,this.littleEndian);return this.byteOffset+=2,t}readInt32(){let t=this.dataView.getInt32(this.byteOffset,this.littleEndian);return this.byteOffset+=4,t}readFloat(){let t=this.dataView.getFloat32(this.byteOffset,this.littleEndian);return this.byteOffset+=4,t}readDouble(){let t=this.dataView.getFloat64(this.byteOffset,this.littleEndian);return this.byteOffset+=8,t}readVarInt(){let t=0,n=0,r;do r=this.dataView.getUint8(this.byteOffset+n),t+=(r&127)<<7*n,n++;while(r>=128);return this.byteOffset+=n,t}};function H(e){let r=new x(e).readUInt8()&15;return!(r<1||r>7)}function ce(e){let t=new x(e),n=Lt(t);if(n.hasSizeAttribute&&t.readVarInt(),n.hasBoundingBox){let r=2;n.hasZ&&r++,n.hasM&&r++;for(let o=0;o<r;o++)t.readVarInt(),t.readVarInt()}return Et(t,n,n.geometryType)}function Lt(e){let t=e.readUInt8(),n=e.readUInt8(),r=t&15,o=w(t>>4),i=Boolean(n>>3&1),s=!1,c=!1,u=0,l=1,y=0,h=1;if(i){let m=e.readUInt8();s=(m&1)===1,c=(m&2)===2,u=w((m&28)>>2),l=Math.pow(10,u),y=w((m&224)>>5),h=Math.pow(10,y)}return{geometryType:r,precision:o,precisionFactor:Math.pow(10,o),hasBoundingBox:Boolean(n>>0&1),hasSizeAttribute:Boolean(n>>1&1),hasIdList:Boolean(n>>2&1),hasExtendedPrecision:i,isEmpty:Boolean(n>>4&1),hasZ:s,hasM:c,zPrecision:u,zPrecisionFactor:l,mPrecision:y,mPrecisionFactor:h}}function Et(e,t,n){switch(n){case a.Point:return Tt(e,t);case a.LineString:return Mt(e,t);case a.Polygon:return Ot(e,t);case a.MultiPoint:return xt(e,t);case a.MultiLineString:return Bt(e,t);case a.MultiPolygon:return Wt(e,t);case a.GeometryCollection:return kt(e,t);default:throw new Error(`GeometryType ${n} not supported`)}}function Tt(e,t){return t.isEmpty?{type:"Point",coordinates:[]}:{type:"Point",coordinates:Ut(e,t)}}function Mt(e,t){if(t.isEmpty)return{type:"LineString",coordinates:[]};let n=e.readVarInt(),r=B(t),o=[];for(let i=0;i<n;i++)o.push(S(e,t,r));return{type:"LineString",coordinates:o}}function Ot(e,t){if(t.isEmpty)return{type:"Polygon",coordinates:[]};let n=e.readVarInt(),r=B(t),o=e.readVarInt(),i=[];for(let c=0;c<o;c++)i.push(S(e,t,r));let s=[i];for(let c=1;c<n;c++){let u=e.readVarInt(),l=[];for(let y=0;y<u;y++)l.push(S(e,t,r));s.push(l)}return{type:"Polygon",coordinates:s}}function xt(e,t){if(t.isEmpty)return{type:"MultiPoint",coordinates:[]};let n=B(t),r=e.readVarInt(),o=[];for(let i=0;i<r;i++)o.push(S(e,t,n));return{type:"MultiPoint",coordinates:o}}function Bt(e,t){if(t.isEmpty)return{type:"MultiLineString",coordinates:[]};let n=B(t),r=e.readVarInt(),o=[];for(let i=0;i<r;i++){let s=e.readVarInt(),c=[];for(let u=0;u<s;u++)c.push(S(e,t,n));o.push(c)}return{type:"MultiLineString",coordinates:o}}function Wt(e,t){if(t.isEmpty)return{type:"MultiPolygon",coordinates:[]};let n=B(t),r=e.readVarInt(),o=[];for(let i=0;i<r;i++){let s=e.readVarInt(),c=e.readVarInt(),u=[];for(let y=0;y<c;y++)u.push(S(e,t,n));let l=u?[u]:[];for(let y=1;y<s;y++){let h=[],m=e.readVarInt();for(let T=0;T<m;T++)h.push(S(e,t,n));l.push(h)}o.push(l)}return{type:"MultiPolygon",coordinates:o}}function kt(e,t){return{type:"GeometryCollection",geometries:[]}}function w(e){return e>>1^-(e&1)}function Ce(e,t,n,r){return n!==void 0?r!==void 0?[e,t,n,r]:[e,t,n]:[e,t]}function B(e){return Ce(0,0,e.hasZ?0:void 0,e.hasM?0:void 0)}function Ut(e,t){let n=w(e.readVarInt())/t.precisionFactor,r=w(e.readVarInt())/t.precisionFactor,o=t.hasZ?w(e.readVarInt())/t.zPrecisionFactor:void 0,i=t.hasM?w(e.readVarInt())/t.mPrecisionFactor:void 0;return Ce(n,r,o,i)}function S(e,t,n){return n[0]+=w(e.readVarInt())/t.precisionFactor,n[1]+=w(e.readVarInt())/t.precisionFactor,t.hasZ&&(n[2]+=w(e.readVarInt())/t.zPrecisionFactor),t.hasM&&(n[3]+=w(e.readVarInt())/t.mPrecisionFactor),n.slice()}var Kt={dataType:null,batchType:null,name:"TWKB (Tiny Well-Known Binary)",id:"twkb",module:"wkt",version:p,worker:!0,category:"geometry",extensions:["twkb"],mimeTypes:[],tests:[H],options:{wkb:{shape:"binary-geometry"}}},Fe={...Kt,parse:async e=>ce(e),parseSync:ce};function ue(e,t){let n=new d(0,!0),r={...Rt(5,0,0),hasZ:t?.hasZ,hasM:t?.hasM};return Re(n,e,r),n.arrayBuffer}function Re(e,t,n){switch(t.type){case"Point":return At(e,n,t);case"LineString":return Gt(e,n,t);case"Polygon":return Vt(e,n,t);case"MultiPoint":return zt(e,n,t);case"MultiLineString":return vt(e,n,t);case"MultiPolygon":return Ct(e,n,t);case"GeometryCollection":return Ft(e,n,t);default:throw new Error("unsupported geometry type")}}function At(e,t,n){let r=n.coordinates.length===0||n[0]==="undefined"||n[1]==="undefined";if(L(e,t,a.Point,r),!r){let o=[0,0,0,0];E(e,t,n.coordinates,o)}}function Gt(e,t,n){let r=n.coordinates,o=r.length===0;if(L(e,t,a.LineString,o),!o){e.writeVarInt(r.length);let i=[0,0,0,0];for(let s of r)E(e,t,s,i)}return e.arrayBuffer}function Vt(e,t,n){let r=n.coordinates,o=r.length===0;if(L(e,t,a.Polygon,o),!o){e.writeVarInt(r.length);let i=[0,0,0,0];for(let s of r){e.writeVarInt(s.length);for(let c of s)E(e,t,i,c)}}return e.arrayBuffer}function zt(e,t,n){let r=n.coordinates,o=r.length===0;if(L(e,t,a.MultiPoint,o),!o){e.writeVarInt(r.length);let i=[0,0,0,0];for(let s=0;s<r.length;s++)E(e,t,i,r[s])}}function vt(e,t,n){let r=n.coordinates,o=r.length===0;if(L(e,t,a.MultiLineString,o),!o){e.writeVarInt(r.length);let i=[0,0,0,0];for(let s of r){e.writeVarInt(s.length);for(let c of s)E(e,t,i,c)}}return e.arrayBuffer}function Ct(e,t,n){let{coordinates:r}=n,o=r.length===0;if(L(e,t,a.MultiPolygon,o),!o){let i=r;e.writeVarInt(i.length);let s=[0,0,0,0];for(let c of i){e.writeVarInt(c.length);for(let u of c){e.writeVarInt(u.length);for(let l of u)E(e,t,s,l)}}}}function Ft(e,t,n){let{geometries:r}=n,o=r.length===0;if(L(e,t,a.GeometryCollection,o),r.length>0){e.writeVarInt(r.length);for(let i of r)Re(e,i,t)}}function L(e,t,n,r){let o=(W(t.xy)<<4)+n,i=t.hasZ||t.hasM?1<<3:0;if(i+=r?1<<4:0,e.writeUInt8(o),e.writeUInt8(i),t.hasZ||t.hasM){let s=0;t.hasZ&&(s|=1),t.hasM&&(s|=2),e.writeUInt8(s)}}function E(e,t,n,r){let o=n[0]*t.xyFactor,i=n[1]*t.xyFactor,s=n[2]*t.zFactor,c=n[3]*t.mFactor;e.writeVarInt(W(o-r[0])),e.writeVarInt(W(i-r[1])),t.hasZ&&e.writeVarInt(W(s-r[2])),t.hasM&&e.writeVarInt(W(c-r[3])),r[0]=o,r[1]=i,r[2]=s,r[3]=c}function W(e){return e<<1^e>>31}function Rt(e,t,n){return{xy:e,z:t,m:n,xyFactor:Math.pow(10,e),zFactor:Math.pow(10,t),mFactor:Math.pow(10,n)}}var Ne={name:"TWKB (Tiny Well Known Binary)",id:"twkb",module:"wkt",version:p,extensions:["twkb"],encode:async(e,t)=>ue(e,t?.twkb),encodeSync:(e,t)=>ue(e,t?.twkb),options:{twkb:{hasZ:!1,hasM:!1}}};return Xe(k);})();
|
|
7
|
+
"use strict";var __exports__=(()=>{var Je=Object.create;var k=Object.defineProperty;var Xe=Object.getOwnPropertyDescriptor;var qe=Object.getOwnPropertyNames;var Qe=Object.getPrototypeOf,et=Object.prototype.hasOwnProperty;var tt=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),nt=(e,t)=>{for(var n in t)k(e,n,{get:t[n],enumerable:!0})},v=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of qe(t))!et.call(e,o)&&o!==n&&k(e,o,{get:()=>t[o],enumerable:!(r=Xe(t,o))||r.enumerable});return e},U=(e,t,n)=>(v(e,t,"default"),n&&v(n,t,"default")),rt=(e,t,n)=>(n=e!=null?Je(Qe(e)):{},v(t||!e||!e.__esModule?k(n,"default",{value:e,enumerable:!0}):n,e)),ot=e=>v(k({},"__esModule",{value:!0}),e);var le=tt((Yt,ae)=>{ae.exports=globalThis.loaders});var K={};nt(K,{HexWKBLoader:()=>De,TWKBLoader:()=>He,TWKBWriter:()=>Ye,WKBLoader:()=>H,WKBWorkerLoader:()=>se,WKBWriter:()=>$e,WKTCRSLoader:()=>Ve,WKTCRSWriter:()=>Fe,WKTLoader:()=>Re,WKTWorkerLoader:()=>ie,WKTWriter:()=>_e});U(K,rt(le(),1));function ue(e,t,n){switch(e.type){case"Point":return st(e,t,n);case"LineString":return it(e,t,n);case"Polygon":return fe(e,t,n);default:let r=e;throw new Error(`Unsupported geometry type: ${r?.type}`)}}function fe(e,t=-1/0,n=1/0){let{positions:r}=e,o=e.polygonIndices.value.filter(a=>a>=t&&a<=n),i=e.primitivePolygonIndices.value.filter(a=>a>=t&&a<=n);if(!(o.length>2)){let a=[];for(let u=0;u<i.length-1;u++){let f=i[u],h=i[u+1],m=A(r,f,h);a.push(m)}return{type:"Polygon",coordinates:a}}let c=[];for(let a=0;a<o.length-1;a++){let u=o[a],f=o[a+1],h=fe(e,u,f).coordinates;c.push(h)}return{type:"MultiPolygon",coordinates:c}}function it(e,t=-1/0,n=1/0){let{positions:r}=e,o=e.pathIndices.value.filter(c=>c>=t&&c<=n);if(!(o.length>2))return{type:"LineString",coordinates:A(r,o[0],o[1])};let s=[];for(let c=0;c<o.length-1;c++){let a=A(r,o[c],o[c+1]);s.push(a)}return{type:"MultiLineString",coordinates:s}}function st(e,t,n){let{positions:r}=e,o=A(r,t,n);return o.length>1?{type:"MultiPoint",coordinates:o}:{type:"Point",coordinates:o[0]}}function A(e,t,n){t=t||0,n=n||e.value.length/e.size;let r=[];for(let o=t;o<n;o++){let i=Array();for(let s=o*e.size;s<(o+1)*e.size;s++)i.push(Number(e.value[s]));r.push(i)}return r}function P(e){let t=0;for(let o=0;o<e.length;++o)t+=e[o].byteLength;let n=new Uint8Array(t),r=0;for(let o=0;o<e.length;++o){let i=new Uint8Array(e[o].buffer);t=i.length;for(let s=0;s<t;++s)n[r++]=i[s]}return n}function ye(e,t){let n=e.map(o=>o.positions.value);return{type:"Point",positions:{value:new Float64Array(P(n).buffer),size:t}}}function pe(e,t){let n=e.map(i=>i.positions.value),r=new Float64Array(P(n).buffer),o=n.map(i=>i.length/t).map(he(0));return o.unshift(0),{type:"LineString",positions:{value:r,size:t},pathIndices:{value:new Uint32Array(o),size:1}}}function ge(e,t){let n=[],r=[];for(let c of e){let{positions:a,primitivePolygonIndices:u}=c;n.push(a.value),r.push(u.value)}let o=new Float64Array(P(n).buffer),i=n.map(c=>c.length/t).map(he(0));i.unshift(0);let s=[0];for(let c of r)s.push(...c.filter(a=>a>0).map(a=>a+s[s.length-1]));return{type:"Polygon",positions:{value:o,size:t},polygonIndices:{value:new Uint32Array(i),size:1},primitivePolygonIndices:{value:new Uint32Array(s),size:1}}}var he=e=>t=>e+=t;var l;(function(e){e[e.Point=1]="Point",e[e.LineString=2]="LineString",e[e.Polygon=3]="Polygon",e[e.MultiPoint=4]="MultiPoint",e[e.MultiLineString=5]="MultiLineString",e[e.MultiPolygon=6]="MultiPolygon",e[e.GeometryCollection=7]="GeometryCollection"})(l||(l={}));var Y=2147483648,J=1073741824,C=536870912,de=1e4,L=["POINT(","LINESTRING(","POLYGON(","MULTIPOINT(","MULTILINESTRING(","MULTIPOLYGON(","GEOMETRYCOLLECTION("],ct=new TextEncoder,me=L.map(e=>ct.encode(e));function z(e){return at(e)!==null}function at(e){if(typeof e=="string"){let r=L.findIndex(o=>e.startsWith(o));return r>=0?r+1:null}let t=new Uint8Array(e),n=me.findIndex(r=>r.every((o,i)=>o===t[i]));return n>=0?n+1:null}function X(e){let t=new DataView(e),n=0,o=t.getUint8(n)&15;return!(o<1||o>7)}function q(e){let t=new DataView(e),n=0,r=t.getUint8(n);if(n+=1,r>1)return!1;let o=r===1,i=t.getUint32(n,o);n+=4;let s=i&7;if(s===0||s>7)return!1;let c=i-s;if(c===0||c===1e3||c===2e3||c===3e3)return!0;if(c&~(Y|J|C))return!1;if(c&C){let a=t.getUint32(n,o);if(n+=4,a>de)return!1}return!0}function we(e,t){let n=Object.assign(t||{},{type:"wkb",variant:"wkb",geometryType:1,dimensions:2,coordinates:"xy",littleEndian:!0,byteOffset:0});if(z(e.buffer))throw new Error("WKB: Cannot parse WKT data");n.littleEndian=e.getUint8(n.byteOffset)===1,n.byteOffset++;let r=e.getUint32(n.byteOffset,n.littleEndian);n.byteOffset+=4,n.geometryType=r&7;let o=(r-n.geometryType)/1e3;switch(o){case 0:break;case 1:n.variant="iso-wkb",n.dimensions=3,n.coordinates="xyz";break;case 2:n.variant="iso-wkb",n.dimensions=3,n.coordinates="xym";break;case 3:n.variant="iso-wkb",n.dimensions=4,n.coordinates="xyzm";break;default:throw new Error(`WKB: Unsupported iso-wkb type: ${o}`)}let i=r&Y,s=r&J,c=r&C;return i&&s?(n.variant="ewkb",n.dimensions=4,n.coordinates="xyzm"):i?(n.variant="ewkb",n.dimensions=3,n.coordinates="xyz"):s&&(n.variant="ewkb",n.dimensions=3,n.coordinates="xym"),c&&(n.variant="ewkb",n.srid=e.getUint32(n.byteOffset,n.littleEndian),n.byteOffset+=4),n}function Te(e){let t=new DataView(e),n=we(t),{geometryType:r,dimensions:o,littleEndian:i}=n,s=n.byteOffset;switch(r){case l.Point:return Ie(t,s,o,i).geometry;case l.LineString:return Q(t,s,o,i).geometry;case l.Polygon:return be(t,s,o,i).geometry;case l.MultiPoint:let f=ut(t,s,o,i);return f.type="Point",f;case l.MultiLineString:let h=ft(t,s,o,i);return h.type="LineString",h;case l.MultiPolygon:let m=yt(t,s,o,i);return m.type="Polygon",m;default:throw new Error(`WKB: Unsupported geometry type: ${r}`)}}function Ie(e,t,n,r){let o=new Float64Array(n);for(let i=0;i<n;i++)o[i]=e.getFloat64(t,r),t+=8;return{geometry:{type:"Point",positions:{value:o,size:n}},offset:t}}function Q(e,t,n,r){let o=e.getUint32(t,r);t+=4;let i=new Float64Array(o*n);for(let c=0;c<o*n;c++)i[c]=e.getFloat64(t,r),t+=8;let s=[0];return o>0&&s.push(o),{geometry:{type:"LineString",positions:{value:i,size:n},pathIndices:{value:new Uint32Array(s),size:1}},offset:t}}var lt=e=>t=>e+=t;function be(e,t,n,r){let o=e.getUint32(t,r);t+=4;let i=[];for(let u=0;u<o;u++){let f=Q(e,t,n,r),{positions:h}=f.geometry;t=f.offset,i.push(h.value)}let s=new Float64Array(P(i).buffer),c=[0];s.length>0&&c.push(s.length/n);let a=i.map(u=>u.length/n).map(lt(0));return a.unshift(0),{geometry:{type:"Polygon",positions:{value:s,size:n},polygonIndices:{value:new Uint32Array(c),size:1},primitivePolygonIndices:{value:new Uint32Array(a),size:1}},offset:t}}function ut(e,t,n,r){let o=e.getUint32(t,r);t+=4;let i=[];for(let s=0;s<o;s++){let c=e.getUint8(t)===1;if(t++,e.getUint32(t,c)%1e3!==1)throw new Error("WKB: Inner geometries of MultiPoint not of type Point");t+=4;let a=Ie(e,t,n,c);t=a.offset,i.push(a.geometry)}return ye(i,n)}function ft(e,t,n,r){let o=e.getUint32(t,r);t+=4;let i=[];for(let s=0;s<o;s++){let c=e.getUint8(t)===1;if(t++,e.getUint32(t,c)%1e3!==2)throw new Error("WKB: Inner geometries of MultiLineString not of type LineString");t+=4;let a=Q(e,t,n,c);t=a.offset,i.push(a.geometry)}return pe(i,n)}function yt(e,t,n,r){let o=e.getUint32(t,r);t+=4;let i=[];for(let s=0;s<o;s++){let c=e.getUint8(t)===1;if(t++,e.getUint32(t,c)%1e3!==3)throw new Error("WKB: Inner geometries of MultiPolygon not of type Polygon");t+=4;let a=be(e,t,n,c);t=a.offset,i.push(a.geometry)}return ge(i,n)}function x(e){let t=Te(e);return ue(t)}var Se=/[-+]?([0-9]*\.[0-9]+|[0-9]+)([eE][-+]?[0-9]+)?/,Pe=new RegExp("^"+Se.source+"(\\s"+Se.source+"){1,}");function V(e,t){let n=e.split(";"),r=n.pop(),o=(n.shift()||"").split("=").pop(),s=Le({parts:n,_:r,i:0});return t?.wkt?.crs?pt(s,o):s}function Le(e){return gt(e)||dt(e)||wt(e)||ht(e)||mt(e)||Tt(e)||It(e)}function pt(e,t){if(e&&t?.match(/\d+/)){let n={type:"name",properties:{name:"urn:ogc:def:crs:EPSG::"+t}};e.crs=n}return e}function gt(e){if(!y(/^(POINT(\sz)?)/i,e)||(g(e),!y(/^(\()/,e)))return null;let t=Be(e);return!t||(g(e),!y(/^(\))/,e))?null:{type:"Point",coordinates:t[0]}}function ht(e){if(!y(/^(MULTIPOINT)/i,e))return null;g(e);let t=e._?.substring(e._?.indexOf("(")+1,e._.length-1).replace(/\(/g,"").replace(/\)/g,"");e._="MULTIPOINT ("+t+")";let n=F(e);return n?(g(e),{type:"MultiPoint",coordinates:n}):null}function dt(e){if(!y(/^(LINESTRING(\sz)?)/i,e)||(g(e),!y(/^(\()/,e)))return null;let t=Be(e);return!t||!y(/^(\))/,e)?null:{type:"LineString",coordinates:t}}function mt(e){if(!y(/^(MULTILINESTRING)/i,e))return null;g(e);let t=F(e);return t?(g(e),{type:"MultiLineString",coordinates:t}):null}function wt(e){if(!y(/^(POLYGON(\sz)?)/i,e))return null;g(e);let t=F(e);return t?{type:"Polygon",coordinates:t}:null}function Tt(e){if(!y(/^(MULTIPOLYGON)/i,e))return null;g(e);let t=F(e);return t?{type:"MultiPolygon",coordinates:t}:null}function It(e){let t=[],n;if(!y(/^(GEOMETRYCOLLECTION)/i,e)||(g(e),!y(/^(\()/,e)))return null;for(;n=Le(e);)t.push(n),g(e),y(/^(,)/,e),g(e);return y(/^(\))/,e)?{type:"GeometryCollection",geometries:t}:null}function F(e){g(e);let t=0,n=[],r=[n],o=n,i;for(;i=y(/^(\()/,e)||y(/^(\))/,e)||y(/^(,)/,e)||y(Pe,e);){if(i==="(")r.push(o),o=[],r[r.length-1].push(o),t++;else if(i===")"){if(o.length===0||(o=r.pop(),!o))return null;if(t--,t===0)break}else if(i===",")o=[],r[r.length-1].push(o);else if(!i.split(/\s/g).some(isNaN))Array.prototype.push.apply(o,i.split(/\s/g).map(parseFloat));else return null;g(e)}return t!==0?null:n}function Be(e){let t=[],n,r;for(;r=y(Pe,e)||y(/^(,)/,e);)r===","?(t.push(n),n=[]):r.split(/\s/g).some(isNaN)||(n||(n=[]),Array.prototype.push.apply(n,r.split(/\s/g).map(parseFloat))),g(e);if(n)t.push(n);else return null;return t.length?t:null}function y(e,t){let n=t._?.substring(t.i).match(e);return n?(t.i+=n[0].length,n[0]):null}function g(e){y(/^\s*/,e)}var R=class{arrayBuffer;dataView;byteOffset;littleEndian;constructor(t,n=!1){this.arrayBuffer=t,this.dataView=new DataView(t),this.byteOffset=0,this.littleEndian=!n}readUInt8(){let t=this.dataView.getUint8(this.byteOffset);return this.byteOffset+=1,t}readUInt16(){let t=this.dataView.getUint16(this.byteOffset,this.littleEndian);return this.byteOffset+=2,t}readUInt32(){let t=this.dataView.getUint32(this.byteOffset,this.littleEndian);return this.byteOffset+=4,t}readInt8(){let t=this.dataView.getInt8(this.byteOffset);return this.byteOffset+=1,t}readInt16(){let t=this.dataView.getInt16(this.byteOffset,this.littleEndian);return this.byteOffset+=2,t}readInt32(){let t=this.dataView.getInt32(this.byteOffset,this.littleEndian);return this.byteOffset+=4,t}readFloat(){let t=this.dataView.getFloat32(this.byteOffset,this.littleEndian);return this.byteOffset+=4,t}readDouble(){let t=this.dataView.getFloat64(this.byteOffset,this.littleEndian);return this.byteOffset+=8,t}readVarInt(){let t=0,n=0,r;do r=this.dataView.getUint8(this.byteOffset+n),t+=(r&127)<<7*n,n++;while(r>=128);return this.byteOffset+=n,t}};function N(e){let t=new R(e),n=bt(t);if(n.hasSizeAttribute&&t.readVarInt(),n.hasBoundingBox){let r=2;n.hasZ&&r++,n.hasM&&r++;for(let o=0;o<r;o++)t.readVarInt(),t.readVarInt()}return St(t,n,n.geometryType)}function bt(e){let t=e.readUInt8(),n=e.readUInt8(),r=t&15,o=w(t>>4),i=Boolean(n>>3&1),s=!1,c=!1,a=0,u=1,f=0,h=1;if(i){let m=e.readUInt8();s=(m&1)===1,c=(m&2)===2,a=w((m&28)>>2),u=Math.pow(10,a),f=w((m&224)>>5),h=Math.pow(10,f)}return{geometryType:r,precision:o,precisionFactor:Math.pow(10,o),hasBoundingBox:Boolean(n>>0&1),hasSizeAttribute:Boolean(n>>1&1),hasIdList:Boolean(n>>2&1),hasExtendedPrecision:i,isEmpty:Boolean(n>>4&1),hasZ:s,hasM:c,zPrecision:a,zPrecisionFactor:u,mPrecision:f,mPrecisionFactor:h}}function St(e,t,n){switch(n){case l.Point:return Pt(e,t);case l.LineString:return Lt(e,t);case l.Polygon:return Bt(e,t);case l.MultiPoint:return Et(e,t);case l.MultiLineString:return xt(e,t);case l.MultiPolygon:return Wt(e,t);case l.GeometryCollection:return Gt(e,t);default:throw new Error(`GeometryType ${n} not supported`)}}function Pt(e,t){return t.isEmpty?{type:"Point",coordinates:[]}:{type:"Point",coordinates:Mt(e,t)}}function Lt(e,t){if(t.isEmpty)return{type:"LineString",coordinates:[]};let n=e.readVarInt(),r=W(t),o=[];for(let i=0;i<n;i++)o.push(I(e,t,r));return{type:"LineString",coordinates:o}}function Bt(e,t){if(t.isEmpty)return{type:"Polygon",coordinates:[]};let n=e.readVarInt(),r=W(t),o=e.readVarInt(),i=[];for(let c=0;c<o;c++)i.push(I(e,t,r));let s=[i];for(let c=1;c<n;c++){let a=e.readVarInt(),u=[];for(let f=0;f<a;f++)u.push(I(e,t,r));s.push(u)}return{type:"Polygon",coordinates:s}}function Et(e,t){if(t.isEmpty)return{type:"MultiPoint",coordinates:[]};let n=W(t),r=e.readVarInt(),o=[];for(let i=0;i<r;i++)o.push(I(e,t,n));return{type:"MultiPoint",coordinates:o}}function xt(e,t){if(t.isEmpty)return{type:"MultiLineString",coordinates:[]};let n=W(t),r=e.readVarInt(),o=[];for(let i=0;i<r;i++){let s=e.readVarInt(),c=[];for(let a=0;a<s;a++)c.push(I(e,t,n));o.push(c)}return{type:"MultiLineString",coordinates:o}}function Wt(e,t){if(t.isEmpty)return{type:"MultiPolygon",coordinates:[]};let n=W(t),r=e.readVarInt(),o=[];for(let i=0;i<r;i++){let s=e.readVarInt(),c=e.readVarInt(),a=[];for(let f=0;f<c;f++)a.push(I(e,t,n));let u=a?[a]:[];for(let f=1;f<s;f++){let h=[],m=e.readVarInt();for(let ce=0;ce<m;ce++)h.push(I(e,t,n));u.push(h)}o.push(u)}return{type:"MultiPolygon",coordinates:o}}function Gt(e,t){return{type:"GeometryCollection",geometries:[]}}function w(e){return e>>1^-(e&1)}function Ee(e,t,n,r){return n!==void 0?r!==void 0?[e,t,n,r]:[e,t,n]:[e,t]}function W(e){return Ee(0,0,e.hasZ?0:void 0,e.hasM?0:void 0)}function Mt(e,t){let n=w(e.readVarInt())/t.precisionFactor,r=w(e.readVarInt())/t.precisionFactor,o=t.hasZ?w(e.readVarInt())/t.zPrecisionFactor:void 0,i=t.hasM?w(e.readVarInt())/t.mPrecisionFactor:void 0;return Ee(n,r,o,i)}function I(e,t,n){return n[0]+=w(e.readVarInt())/t.precisionFactor,n[1]+=w(e.readVarInt())/t.precisionFactor,t.hasZ&&(n[2]+=w(e.readVarInt())/t.zPrecisionFactor),t.hasM&&(n[3]+=w(e.readVarInt())/t.mPrecisionFactor),n.slice()}function G(e){switch(e.type){case"Point":return`POINT ${T(xe(e.coordinates))}`;case"LineString":return`LINESTRING ${T(ee(e.coordinates))}`;case"Polygon":return`POLYGON ${T(te(e.coordinates))}`;case"MultiPoint":return`MULTIPOINT ${T(ee(e.coordinates))}`;case"MultiPolygon":return`MULTIPOLYGON ${T(Ot(e.coordinates))}`;case"MultiLineString":return`MULTILINESTRING ${T(te(e.coordinates))}`;case"GeometryCollection":return`GEOMETRYCOLLECTION ${T(e.geometries.map(G).join(", "))}`;default:throw new Error("convertGeometryToWKT requires a valid GeoJSON Geometry (not Feature) as input")}}function xe(e){return e.join(" ")}function ee(e){return e.map(xe).join(", ")}function te(e){return e.map(ee).map(T).join(", ")}function Ot(e){return e.map(te).map(T).join(", ")}function T(e){return`(${e})`}var d=class{arrayBuffer;dataView;byteOffset=0;allowResize=!1;constructor(t,n){this.arrayBuffer=new ArrayBuffer(t),this.dataView=new DataView(this.arrayBuffer),this.byteOffset=0,this.allowResize=n||!1}writeUInt8(t){this._ensureSize(1),this.dataView.setUint8(this.byteOffset,t),this.byteOffset+=1}writeUInt16LE(t){this._ensureSize(2),this.dataView.setUint16(this.byteOffset,t,!0),this.byteOffset+=2}writeUInt16BE(t){this._ensureSize(2),this.dataView.setUint16(this.byteOffset,t,!1),this.byteOffset+=2}writeUInt32LE(t){this._ensureSize(4),this.dataView.setUint32(this.byteOffset,t,!0),this.byteOffset+=4}writeUInt32BE(t){this._ensureSize(4),this.dataView.setUint32(this.byteOffset,t,!1),this.byteOffset+=4}writeInt8(t){this._ensureSize(1),this.dataView.setInt8(this.byteOffset,t),this.byteOffset+=1}writeInt16LE(t){this._ensureSize(2),this.dataView.setInt16(this.byteOffset,t,!0),this.byteOffset+=2}writeInt16BE(t){this._ensureSize(2),this.dataView.setInt16(this.byteOffset,t,!1),this.byteOffset+=2}writeInt32LE(t){this._ensureSize(4),this.dataView.setInt32(this.byteOffset,t,!0),this.byteOffset+=4}writeInt32BE(t){this._ensureSize(4),this.dataView.setInt32(this.byteOffset,t,!1),this.byteOffset+=4}writeFloatLE(t){this._ensureSize(4),this.dataView.setFloat32(this.byteOffset,t,!0),this.byteOffset+=4}writeFloatBE(t){this._ensureSize(4),this.dataView.setFloat32(this.byteOffset,t,!1),this.byteOffset+=4}writeDoubleLE(t){this._ensureSize(8),this.dataView.setFloat64(this.byteOffset,t,!0),this.byteOffset+=8}writeDoubleBE(t){this._ensureSize(8),this.dataView.setFloat64(this.byteOffset,t,!1),this.byteOffset+=8}writeVarInt(t){let n=1;for(;t&4294967168;)this.writeUInt8(t&127|128),t>>>=7,n++;return this.writeUInt8(t&127),n}writeTypedArray(t){this._ensureSize(t.byteLength),new Uint8Array(this.arrayBuffer).set(t,this.byteOffset),this.byteOffset+=t.byteLength}writeBuffer(t){this._ensureSize(t.byteLength),new Uint8Array(this.arrayBuffer).set(new Uint8Array(t),this.byteOffset),this.byteOffset+=t.byteLength}_ensureSize(t){if(this.arrayBuffer.byteLength<this.byteOffset+t)if(this.allowResize){let n=new ArrayBuffer(this.byteOffset+t);new Uint8Array(n).set(new Uint8Array(this.arrayBuffer)),this.arrayBuffer=n}else throw new Error("BinaryWriter overflow")}};function M(e,t={}){switch(e.type==="Feature"&&(e=e.geometry),e.type){case"Point":return We(e.coordinates,t);case"LineString":return Me(e.coordinates,t);case"Polygon":return Oe(e.coordinates,t);case"MultiPoint":return vt(e,t);case"MultiPolygon":return Ut(e,t);case"MultiLineString":return kt(e,t);case"GeometryCollection":return At(e,t);default:let n=e;throw new Error(`Unhandled case: ${n}`)}}function Kt(e,t){switch(e.type){case"Point":return Ge(t);case"LineString":return ne(e.coordinates,t);case"Polygon":return re(e.coordinates,t);case"MultiPoint":return Ke(e,t);case"MultiPolygon":return ke(e,t);case"MultiLineString":return ve(e,t);case"GeometryCollection":return Ue(e,t);default:let n=e;throw new Error(`Unhandled case: ${n}`)}}function We(e,t){let n=new d(Ge(t));return n.writeInt8(1),b(n,l.Point,t),typeof e[0]>"u"&&typeof e[1]>"u"?(n.writeDoubleLE(NaN),n.writeDoubleLE(NaN),t.hasZ&&n.writeDoubleLE(NaN),t.hasM&&n.writeDoubleLE(NaN)):_(n,e,t),n.arrayBuffer}function _(e,t,n){e.writeDoubleLE(t[0]),e.writeDoubleLE(t[1]),n.hasZ&&e.writeDoubleLE(t[2]),n.hasM&&e.writeDoubleLE(t[3])}function Ge(e){let t=j(e);return 1+4+t}function Me(e,t){let n=ne(e,t),r=new d(n);r.writeInt8(1),b(r,l.LineString,t),r.writeUInt32LE(e.length);for(let o of e)_(r,o,t);return r.arrayBuffer}function ne(e,t){let n=j(t);return 1+4+4+e.length*n}function Oe(e,t){let n=new d(re(e,t));n.writeInt8(1),b(n,l.Polygon,t);let[r=[],...o]=e;r.length>0?(n.writeUInt32LE(1+o.length),n.writeUInt32LE(r.length)):n.writeUInt32LE(0);for(let i of r)_(n,i,t);for(let i of o){n.writeUInt32LE(i.length);for(let s of i)_(n,s,t)}return n.arrayBuffer}function re(e,t){let n=j(t),[r=[],...o]=e,i=1+4+4;r.length>0&&(i+=4+r.length*n);for(let s of o)i+=4+s.length*n;return i}function vt(e,t){let n=new d(Ke(e,t)),r=e.coordinates;n.writeInt8(1),b(n,l.MultiPoint,t),n.writeUInt32LE(r.length);for(let o of r){let i=We(o,t);n.writeBuffer(i)}return n.arrayBuffer}function Ke(e,t){let n=j(t),r=e.coordinates;return n+=5,1+4+4+r.length*n}function kt(e,t){let n=new d(ve(e,t)),r=e.coordinates;n.writeInt8(1),b(n,l.MultiLineString,t),n.writeUInt32LE(r.length);for(let o of r){let i=Me(o,t);n.writeBuffer(i)}return n.arrayBuffer}function ve(e,t){let n=9,r=e.coordinates;for(let o of r)n+=ne(o,t);return n}function Ut(e,t){let n=new d(ke(e,t)),r=e.coordinates;n.writeInt8(1),b(n,l.MultiPolygon,t),n.writeUInt32LE(r.length);for(let o of r){let i=Oe(o,t);n.writeBuffer(i)}return n.arrayBuffer}function ke(e,t){let n=9,r=e.coordinates;for(let o of r)n+=re(o,t);return n}function At(e,t){let n=new d(Ue(e,t));n.writeInt8(1),b(n,l.GeometryCollection,t),n.writeUInt32LE(e.geometries.length);for(let r of e.geometries){let o=M(r,t);n.writeBuffer(o)}return n.arrayBuffer}function Ue(e,t){let n=9;for(let r of e.geometries)n+=Kt(r,t);return n}function b(e,t,n){let{hasZ:r,hasM:o,srid:i}=n,s=0;i?(r&&(s|=2147483648),o&&(s|=1073741824)):r&&o?s+=3e3:r?s+=1e3:o&&(s+=2e3),e.writeUInt32LE(s+t>>>0)}function j(e){let t=16;return e.hasZ&&(t+=8),e.hasM&&(t+=8),t}function $(e,t){let n=new d(0,!0),r={...jt(5,0,0),hasZ:t?.hasZ,hasM:t?.hasM};return Ae(n,e,r),n.arrayBuffer}function Ae(e,t,n){switch(t.type){case"Point":return Ct(e,n,t);case"LineString":return zt(e,n,t);case"Polygon":return Vt(e,n,t);case"MultiPoint":return Ft(e,n,t);case"MultiLineString":return Rt(e,n,t);case"MultiPolygon":return Nt(e,n,t);case"GeometryCollection":return _t(e,n,t);default:throw new Error("unsupported geometry type")}}function Ct(e,t,n){let r=n.coordinates.length===0||n[0]==="undefined"||n[1]==="undefined";if(S(e,t,l.Point,r),!r){let o=[0,0,0,0];B(e,t,n.coordinates,o)}}function zt(e,t,n){let r=n.coordinates,o=r.length===0;if(S(e,t,l.LineString,o),!o){e.writeVarInt(r.length);let i=[0,0,0,0];for(let s of r)B(e,t,s,i)}return e.arrayBuffer}function Vt(e,t,n){let r=n.coordinates,o=r.length===0;if(S(e,t,l.Polygon,o),!o){e.writeVarInt(r.length);let i=[0,0,0,0];for(let s of r){e.writeVarInt(s.length);for(let c of s)B(e,t,i,c)}}return e.arrayBuffer}function Ft(e,t,n){let r=n.coordinates,o=r.length===0;if(S(e,t,l.MultiPoint,o),!o){e.writeVarInt(r.length);let i=[0,0,0,0];for(let s=0;s<r.length;s++)B(e,t,i,r[s])}}function Rt(e,t,n){let r=n.coordinates,o=r.length===0;if(S(e,t,l.MultiLineString,o),!o){e.writeVarInt(r.length);let i=[0,0,0,0];for(let s of r){e.writeVarInt(s.length);for(let c of s)B(e,t,i,c)}}return e.arrayBuffer}function Nt(e,t,n){let{coordinates:r}=n,o=r.length===0;if(S(e,t,l.MultiPolygon,o),!o){let i=r;e.writeVarInt(i.length);let s=[0,0,0,0];for(let c of i){e.writeVarInt(c.length);for(let a of c){e.writeVarInt(a.length);for(let u of a)B(e,t,s,u)}}}}function _t(e,t,n){let{geometries:r}=n,o=r.length===0;if(S(e,t,l.GeometryCollection,o),r.length>0){e.writeVarInt(r.length);for(let i of r)Ae(e,i,t)}}function S(e,t,n,r){let o=(O(t.xy)<<4)+n,i=t.hasZ||t.hasM?1<<3:0;if(i+=r?1<<4:0,e.writeUInt8(o),e.writeUInt8(i),t.hasZ||t.hasM){let s=0;t.hasZ&&(s|=1),t.hasM&&(s|=2),e.writeUInt8(s)}}function B(e,t,n,r){let o=n[0]*t.xyFactor,i=n[1]*t.xyFactor,s=n[2]*t.zFactor,c=n[3]*t.mFactor;e.writeVarInt(O(o-r[0])),e.writeVarInt(O(i-r[1])),t.hasZ&&e.writeVarInt(O(s-r[2])),t.hasM&&e.writeVarInt(O(c-r[3])),r[0]=o,r[1]=i,r[2]=s,r[3]=c}function O(e){return e<<1^e>>31}function jt(e,t,n){return{xy:e,z:t,m:n,xyFactor:Math.pow(10,e),zFactor:Math.pow(10,t),mFactor:Math.pow(10,n)}}function Z(e,t){t?.debug&&console.log(`[wktcrs] parse starting with
|
|
8
|
+
`,e),e=e.replace(/[A-Z][A-Z\d_]+\[/gi,i=>`["${i.substr(0,i.length-1)}",`),e=e.replace(/, ?([A-Z][A-Z\d_]+[,\]])/gi,(i,s)=>{let c=s.substr(0,s.length-1);return`,"${t?.raw?"raw:":""}${c}"${s[s.length-1]}`}),t?.raw&&(e=e.replace(/, {0,2}(-?[\.\d]+)(?=,|\])/g,function(i,s){return`,"${t?.raw?"raw:":""}${s}"`})),t?.debug&&console.log(`[wktcrs] json'd wkt: '${e}'`);let n;try{n=JSON.parse(e)}catch(i){throw console.error(`[wktcrs] failed to parse '${e}'`),i}t?.debug&&console.log(`[wktcrs] json parsed: '${e}'`);function r(i,s){let c=i[0];i.forEach(function(u){Array.isArray(u)&&r(u,i)});let a=`MULTIPLE_${c}`;return a in s?s[a].push(i):c in s?(s[a]=[s[c],i],delete s[c]):s[c]=i,s}let o=r(n,[n]);return t?.debug&&console.log("[wktcrs] parse returning",o),t?.sort&&Ce(o,t),o}function Ce(e,t){let n=Object.keys(e).filter(o=>!/\d+/.test(o)),r=t?.keywords||[];if(!t?.keywords){let o={};if(Array.isArray(e)){e.forEach(i=>{if(Array.isArray(i)&&i.length>=2&&typeof i[1]=="string"){let s=i[0];o[s]||(o[s]=0),o[s]++}});for(let i in o)o[i]>0&&r.push(i)}}return n.forEach(o=>{e[o]=Ce(e[o])}),r.forEach(o=>{let i=[],s=[];e.forEach((c,a)=>{Array.isArray(c)&&c[0]===o&&(i.push(a),s.push(c))}),s.sort((c,a)=>(c=c[1].toString(),a=a[1].toString(),c<a?-1:c>a?1:0)),s.forEach((c,a)=>{e[i[a]]=c})}),e}function E(e,t){Array.isArray(e)&&e.length===1&&Array.isArray(e[0])&&(e=e[0]);let[n,...r]=e;return`${n}[${r.map(i=>{if(Array.isArray(i))return E(i,t);if(typeof i=="number")return i.toString();if(typeof i=="string")return i.startsWith("raw:")?i.replace("raw:",""):`"${i}"`;throw new Error(`[wktcrs] unexpected attribute "${i}"`)}).join(",")}]`}var ze="0123456789abcdef",$t=[],D=[];for(let e=0;e<256;e++)$t[e]=ze[e>>4&15]+ze[e&15],e<16&&(e<10?D[48+e]=e:D[97-10+e]=e);function oe(e){let t=e.length>>1,n=t<<1,r=new Uint8Array(t),o=0,i=0;for(;i<n;)r[o++]=D[e.charCodeAt(i++)]<<4|D[e.charCodeAt(i++)];return r}var p="4.4.0-alpha.0";var Ve={dataType:null,batchType:null,name:"WKT CRS (Well-Known Text Coordinate Reference System)",id:"wkt-crs",module:"wkt-crs",version:p,worker:!0,extensions:[],mimeTypes:["text/plain"],category:"json",text:!0,options:{"wkt-crs":{}},parse:async(e,t)=>Z(new TextDecoder().decode(e),t?.["wkt-crs"]),parseTextSync:(e,t)=>Z(e,t?.["wkt-crs"])};var Fe={name:"WKT CRS (Well-Known Text Coordinate Reference System)",id:"wkt-crs",module:"wkt-crs",version:p,worker:!0,extensions:[],mimeTypes:["text/plain"],text:!0,options:{"wkt-crs":{}},encode:async(e,t)=>new TextEncoder().encode(E(e,t?.["wkt-crs"])),encodeSync:(e,t)=>new TextEncoder().encode(E(e,t?.["wkt-crs"])),encodeTextSync:(e,t)=>E(e,t?.["wkt-crs"])};var ie={dataType:null,batchType:null,name:"WKT (Well-Known Text)",id:"wkt",module:"wkt",version:p,worker:!0,extensions:["wkt"],mimeTypes:["text/plain"],category:"geometry",text:!0,tests:L,testText:z,options:{wkt:{shape:"geojson-geometry",crs:!0}}},Re={...ie,parse:async(e,t)=>V(new TextDecoder().decode(e),t),parseTextSync:(e,t)=>V(e,t)};var _e={name:"WKT (Well Known Text)",id:"wkt",module:"wkt",version:p,extensions:["wkt"],mimeTypes:["application/wkt","text/plain"],text:!0,encode:async e=>Ne(e),encodeSync:Ne,encodeTextSync:G,options:{wkt:{}}};function Ne(e){let t=G(e);return new TextEncoder().encode(t).buffer}var se={dataType:null,batchType:null,name:"WKB",id:"wkb",module:"wkt",version:p,worker:!0,category:"geometry",extensions:["wkb"],mimeTypes:[],tests:[q],options:{wkb:{shape:"geojson-geometry"}}},H={...se,parse:async(e,t)=>je(e,t?.wkb),parseSync:(e,t)=>je(e,t?.wkb)};function je(e,t){let n=t?.shape||"geojson-geometry";switch(n){case"geojson-geometry":return x(e);default:throw new Error(n)}}var $e={name:"WKB (Well Known Binary)",id:"wkb",module:"wkt",version:p,extensions:["wkb"],mimeTypes:["application/wkb","application/octet-stream"],options:{wkb:{hasZ:!1,hasM:!1}},async encode(e,t){return M(e)},encodeSync(e,t){return M(e)}};var De={dataType:null,batchType:null,name:"Hexadecimal WKB",id:"wkb",module:"wkt",version:p,worker:!0,category:"geometry",extensions:["wkb"],mimeTypes:[],options:H.options,text:!0,testText:Zt,parse:async e=>Ze(new TextDecoder().decode(e)),parseTextSync:Ze};function Ze(e,t){let n=oe(e);return x(n.buffer)}function Zt(e){return!e||e.length<10||e.length%2!==0||!e.startsWith("00")&&!e.startsWith("01")?!1:/^[0-9a-fA-F]+$/.test(e.slice(2))}var Dt={dataType:null,batchType:null,name:"TWKB (Tiny Well-Known Binary)",id:"twkb",module:"wkt",version:p,worker:!0,category:"geometry",extensions:["twkb"],mimeTypes:[],tests:[X],options:{wkb:{shape:"binary-geometry"}}},He={...Dt,parse:async e=>N(e),parseSync:N};var Ye={name:"TWKB (Tiny Well Known Binary)",id:"twkb",module:"wkt",version:p,extensions:["twkb"],mimeTypes:["application/text"],encode:async(e,t)=>$(e,t?.twkb),encodeSync:(e,t)=>$(e,t?.twkb),options:{twkb:{hasZ:!1,hasM:!1}}};return ot(K);})();
|
|
9
9
|
return __exports__;
|
|
10
10
|
});
|
package/dist/hex-wkb-loader.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { Geometry } from '@loaders.gl/schema';
|
|
2
2
|
import type { WKBLoaderOptions } from "./wkb-loader.js";
|
|
3
3
|
export type HexWKBLoaderOptions = WKBLoaderOptions;
|
|
4
4
|
/**
|
|
5
5
|
* Worker loader for Hex-encoded WKB (Well-Known Binary)
|
|
6
6
|
*/
|
|
7
7
|
export declare const HexWKBLoader: {
|
|
8
|
-
readonly dataType:
|
|
8
|
+
readonly dataType: Geometry;
|
|
9
9
|
readonly batchType: never;
|
|
10
10
|
readonly name: "Hexadecimal WKB";
|
|
11
11
|
readonly id: "wkb";
|
|
@@ -17,21 +17,22 @@ export declare const HexWKBLoader: {
|
|
|
17
17
|
readonly mimeTypes: [];
|
|
18
18
|
readonly options: {
|
|
19
19
|
readonly wkb: {
|
|
20
|
-
readonly shape: "
|
|
20
|
+
readonly shape: "geojson-geometry";
|
|
21
21
|
};
|
|
22
22
|
};
|
|
23
23
|
readonly text: true;
|
|
24
24
|
readonly testText: typeof isHexWKB;
|
|
25
|
-
readonly parse: (arrayBuffer: ArrayBuffer) => Promise<
|
|
25
|
+
readonly parse: (arrayBuffer: ArrayBuffer) => Promise<Geometry>;
|
|
26
26
|
readonly parseTextSync: typeof parseHexWKB;
|
|
27
27
|
};
|
|
28
|
-
declare function parseHexWKB(text: string, options?: HexWKBLoaderOptions):
|
|
28
|
+
declare function parseHexWKB(text: string, options?: HexWKBLoaderOptions): Geometry;
|
|
29
29
|
/**
|
|
30
30
|
* Check if string is a valid Well-known binary (WKB) in HEX format
|
|
31
31
|
* https://en.wikipedia.org/wiki/Well-known_text_representation_of_geometry
|
|
32
32
|
*
|
|
33
33
|
* @param str input string
|
|
34
34
|
* @returns true if string is a valid WKB in HEX format
|
|
35
|
+
* @todo Avoid costly regex check
|
|
35
36
|
*/
|
|
36
37
|
export declare function isHexWKB(string: string | null): boolean;
|
|
37
38
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hex-wkb-loader.d.ts","sourceRoot":"","sources":["../src/hex-wkb-loader.ts"],"names":[],"mappings":"AAKA,OAAO,EAAC,
|
|
1
|
+
{"version":3,"file":"hex-wkb-loader.d.ts","sourceRoot":"","sources":["../src/hex-wkb-loader.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAC,QAAQ,EAAC,MAAM,oBAAoB,CAAC;AAGjD,OAAO,KAAK,EAAC,gBAAgB,EAAC,wBAAqB;AAInD,MAAM,MAAM,mBAAmB,GAAG,gBAAgB,CAAC;AAEnD;;GAEG;AACH,eAAO,MAAM,YAAY;uBACM,QAAQ;wBAClB,KAAK;;;;;;;;;;;;;;;;kCAaG,WAAW;;CAEmC,CAAC;AAE5E,iBAAS,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,mBAAmB,GAAG,QAAQ,CAI1E;AAED;;;;;;;GAOG;AACH,wBAAgB,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAcvD"}
|
package/dist/hex-wkb-loader.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// loaders.gl
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
|
+
import { convertWKBToGeometry, decodeHex } from '@loaders.gl/gis';
|
|
4
5
|
import { WKBLoader } from "./wkb-loader.js";
|
|
5
|
-
import { VERSION } from "./lib/
|
|
6
|
-
import { decodeHex } from "./lib/utils/hex-transcoder.js";
|
|
6
|
+
import { VERSION } from "./lib/version.js";
|
|
7
7
|
/**
|
|
8
8
|
* Worker loader for Hex-encoded WKB (Well-Known Binary)
|
|
9
9
|
*/
|
|
@@ -27,8 +27,7 @@ export const HexWKBLoader = {
|
|
|
27
27
|
};
|
|
28
28
|
function parseHexWKB(text, options) {
|
|
29
29
|
const uint8Array = decodeHex(text);
|
|
30
|
-
const binaryGeometry =
|
|
31
|
-
// @ts-expect-error
|
|
30
|
+
const binaryGeometry = convertWKBToGeometry(uint8Array.buffer); // , options?.wkb);
|
|
32
31
|
return binaryGeometry;
|
|
33
32
|
}
|
|
34
33
|
/**
|
|
@@ -37,6 +36,7 @@ function parseHexWKB(text, options) {
|
|
|
37
36
|
*
|
|
38
37
|
* @param str input string
|
|
39
38
|
* @returns true if string is a valid WKB in HEX format
|
|
39
|
+
* @todo Avoid costly regex check
|
|
40
40
|
*/
|
|
41
41
|
export function isHexWKB(string) {
|
|
42
42
|
if (!string) {
|