@loaders.gl/wkt 4.2.0-alpha.5 → 4.2.0-beta.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 +25 -9
- package/dist/dist.min.js +2 -2
- package/dist/hex-wkb-loader.d.ts +23 -2
- package/dist/hex-wkb-loader.d.ts.map +1 -1
- package/dist/hex-wkb-loader.js +2 -0
- package/dist/index.cjs +26 -10
- package/dist/index.cjs.map +2 -2
- package/dist/lib/parse-wkb.js +6 -6
- package/dist/lib/utils/binary-reader.js +4 -0
- package/dist/lib/utils/binary-writer.js +4 -2
- package/dist/lib/utils/version.js +1 -1
- package/dist/twkb-loader.d.ts +41 -4
- package/dist/twkb-loader.d.ts.map +1 -1
- package/dist/twkb-loader.js +2 -0
- package/dist/twkb-writer.d.ts +16 -2
- package/dist/twkb-writer.d.ts.map +1 -1
- package/dist/wkb-loader.d.ts +41 -3
- package/dist/wkb-loader.d.ts.map +1 -1
- package/dist/wkb-loader.js +2 -0
- package/dist/wkb-writer.d.ts +16 -2
- package/dist/wkb-writer.d.ts.map +1 -1
- package/dist/wkt-crs-loader.d.ts +20 -3
- package/dist/wkt-crs-loader.d.ts.map +1 -1
- package/dist/wkt-crs-loader.js +2 -0
- package/dist/wkt-crs-writer.d.ts +17 -3
- package/dist/wkt-crs-writer.d.ts.map +1 -1
- package/dist/wkt-loader.d.ts +50 -4
- package/dist/wkt-loader.d.ts.map +1 -1
- package/dist/wkt-loader.js +3 -1
- package/dist/wkt-worker.js +7 -3
- package/dist/wkt-writer.d.ts +18 -2
- package/dist/wkt-writer.d.ts.map +1 -1
- package/package.json +5 -4
- package/src/hex-wkb-loader.ts +4 -2
- package/src/lib/parse-wkb.ts +6 -6
- package/src/twkb-loader.ts +7 -4
- package/src/twkb-writer.ts +2 -2
- package/src/wkb-loader.ts +6 -4
- package/src/wkb-writer.ts +2 -2
- package/src/wkt-crs-loader.ts +4 -2
- package/src/wkt-crs-writer.ts +2 -2
- package/src/wkt-loader.ts +13 -7
- package/src/wkt-writer.ts +2 -2
package/dist/dist.dev.js
CHANGED
|
@@ -172,6 +172,8 @@ var __exports__ = (() => {
|
|
|
172
172
|
|
|
173
173
|
// src/wkt-crs-loader.ts
|
|
174
174
|
var WKTCRSLoader = {
|
|
175
|
+
dataType: null,
|
|
176
|
+
batchType: null,
|
|
175
177
|
name: "WKT CRS (Well-Known Text Coordinate Reference System)",
|
|
176
178
|
id: "wkt-crs",
|
|
177
179
|
module: "wkt-crs",
|
|
@@ -472,6 +474,8 @@ var __exports__ = (() => {
|
|
|
472
474
|
|
|
473
475
|
// src/wkt-loader.ts
|
|
474
476
|
var WKTWorkerLoader = {
|
|
477
|
+
dataType: null,
|
|
478
|
+
batchType: null,
|
|
475
479
|
name: "WKT (Well-Known Text)",
|
|
476
480
|
id: "wkt",
|
|
477
481
|
module: "wkt",
|
|
@@ -493,7 +497,7 @@ var __exports__ = (() => {
|
|
|
493
497
|
var WKTLoader = {
|
|
494
498
|
...WKTWorkerLoader,
|
|
495
499
|
parse: async (arrayBuffer, options) => parseWKT(new TextDecoder().decode(arrayBuffer), options),
|
|
496
|
-
parseTextSync: parseWKT
|
|
500
|
+
parseTextSync: (string, options) => parseWKT(string, options)
|
|
497
501
|
};
|
|
498
502
|
|
|
499
503
|
// src/lib/encode-wkt.ts
|
|
@@ -807,7 +811,7 @@ var __exports__ = (() => {
|
|
|
807
811
|
geometry: {
|
|
808
812
|
type: "LineString",
|
|
809
813
|
positions: { value: positions, size: dimension },
|
|
810
|
-
pathIndices: { value: new
|
|
814
|
+
pathIndices: { value: new Uint32Array(pathIndices), size: 1 }
|
|
811
815
|
},
|
|
812
816
|
offset
|
|
813
817
|
};
|
|
@@ -835,10 +839,10 @@ var __exports__ = (() => {
|
|
|
835
839
|
type: "Polygon",
|
|
836
840
|
positions: { value: concatenatedPositions, size: dimension },
|
|
837
841
|
polygonIndices: {
|
|
838
|
-
value: new
|
|
842
|
+
value: new Uint32Array(polygonIndices),
|
|
839
843
|
size: 1
|
|
840
844
|
},
|
|
841
|
-
primitivePolygonIndices: { value: new
|
|
845
|
+
primitivePolygonIndices: { value: new Uint32Array(primitivePolygonIndices), size: 1 }
|
|
842
846
|
},
|
|
843
847
|
offset
|
|
844
848
|
};
|
|
@@ -910,7 +914,7 @@ var __exports__ = (() => {
|
|
|
910
914
|
return {
|
|
911
915
|
type: "LineString",
|
|
912
916
|
positions: { value: concatenatedPositions, size: dimension },
|
|
913
|
-
pathIndices: { value: new
|
|
917
|
+
pathIndices: { value: new Uint32Array(pathIndices), size: 1 }
|
|
914
918
|
};
|
|
915
919
|
}
|
|
916
920
|
function concatenateBinaryPolygonGeometries(binaryPolygonGeometries, dimension) {
|
|
@@ -933,8 +937,8 @@ var __exports__ = (() => {
|
|
|
933
937
|
return {
|
|
934
938
|
type: "Polygon",
|
|
935
939
|
positions: { value: concatenatedPositions, size: dimension },
|
|
936
|
-
polygonIndices: { value: new
|
|
937
|
-
primitivePolygonIndices: { value: new
|
|
940
|
+
polygonIndices: { value: new Uint32Array(polygonIndices), size: 1 },
|
|
941
|
+
primitivePolygonIndices: { value: new Uint32Array(primitivePolygonIndices), size: 1 }
|
|
938
942
|
};
|
|
939
943
|
}
|
|
940
944
|
function concatTypedArrays(arrays) {
|
|
@@ -956,6 +960,8 @@ var __exports__ = (() => {
|
|
|
956
960
|
|
|
957
961
|
// src/wkb-loader.ts
|
|
958
962
|
var WKBWorkerLoader = {
|
|
963
|
+
dataType: null,
|
|
964
|
+
batchType: null,
|
|
959
965
|
name: "WKB",
|
|
960
966
|
id: "wkb",
|
|
961
967
|
module: "wkt",
|
|
@@ -983,9 +989,11 @@ var __exports__ = (() => {
|
|
|
983
989
|
var LE = true;
|
|
984
990
|
var BE = false;
|
|
985
991
|
var BinaryWriter = class {
|
|
992
|
+
arrayBuffer;
|
|
993
|
+
dataView;
|
|
994
|
+
byteOffset = 0;
|
|
995
|
+
allowResize = false;
|
|
986
996
|
constructor(size, allowResize) {
|
|
987
|
-
this.byteOffset = 0;
|
|
988
|
-
this.allowResize = false;
|
|
989
997
|
this.arrayBuffer = new ArrayBuffer(size);
|
|
990
998
|
this.dataView = new DataView(this.arrayBuffer);
|
|
991
999
|
this.byteOffset = 0;
|
|
@@ -1387,6 +1395,8 @@ var __exports__ = (() => {
|
|
|
1387
1395
|
|
|
1388
1396
|
// src/hex-wkb-loader.ts
|
|
1389
1397
|
var HexWKBLoader = {
|
|
1398
|
+
dataType: null,
|
|
1399
|
+
batchType: null,
|
|
1390
1400
|
name: "Hexadecimal WKB",
|
|
1391
1401
|
id: "wkb",
|
|
1392
1402
|
module: "wkt",
|
|
@@ -1422,6 +1432,10 @@ var __exports__ = (() => {
|
|
|
1422
1432
|
|
|
1423
1433
|
// src/lib/utils/binary-reader.ts
|
|
1424
1434
|
var BinaryReader = class {
|
|
1435
|
+
arrayBuffer;
|
|
1436
|
+
dataView;
|
|
1437
|
+
byteOffset;
|
|
1438
|
+
littleEndian;
|
|
1425
1439
|
constructor(arrayBuffer, isBigEndian = false) {
|
|
1426
1440
|
this.arrayBuffer = arrayBuffer;
|
|
1427
1441
|
this.dataView = new DataView(arrayBuffer);
|
|
@@ -1700,6 +1714,8 @@ var __exports__ = (() => {
|
|
|
1700
1714
|
|
|
1701
1715
|
// src/twkb-loader.ts
|
|
1702
1716
|
var TWKBWorkerLoader = {
|
|
1717
|
+
dataType: null,
|
|
1718
|
+
batchType: null,
|
|
1703
1719
|
name: "TWKB (Tiny Well-Known Binary)",
|
|
1704
1720
|
id: "twkb",
|
|
1705
1721
|
module: "wkt",
|
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:()=>
|
|
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={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=z(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=z(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=z(e);return t?{type:"Polygon",coordinates:t}:null}function it(e){if(!f(/^(MULTIPOLYGON)/i,e))return null;g(e);let t=z(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 z(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={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:X};function V(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(V).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 be={name:"WKT (Well Known Text)",id:"wkt",module:"wkt",version:p,extensions:["wkt"],text:!0,encode:async e=>Pe(e),encodeSync:Pe,encodeTextSync:V,options:{wkt:{}}};function Pe(e){return new TextEncoder().encode(V(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 Uint16Array(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 Uint16Array(c),size:1},primitivePolygonIndices:{value:new Uint16Array(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 Uint16Array(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 Uint16Array(i),size:1},primitivePolygonIndices:{value:new Uint16Array(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={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{constructor(t,n){this.byteOffset=0,this.allowResize=!1,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 P;(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"})(P||(P={}));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 Pt(e,t);case"MultiLineString":return It(e,t);case"GeometryCollection":return bt(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),b(n,P.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),b(r,P.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),b(n,P.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),b(n,P.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),b(n,P.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 Pt(e,t){let n=new d(ke(e,t)),r=e.coordinates;n.writeInt8(1),b(n,P.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 bt(e,t){let n=new d(Ue(e,t));n.writeInt8(1),b(n,P.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 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 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 ze(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={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=>Ve(new TextDecoder().decode(e)),parseTextSync:Ve};function Ve(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{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={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 zt(e,n,t);case"MultiPoint":return Vt(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 zt(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 Vt(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 _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.2.0-alpha.6";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);})();
|
|
9
9
|
return __exports__;
|
|
10
10
|
});
|
package/dist/hex-wkb-loader.d.ts
CHANGED
|
@@ -1,11 +1,31 @@
|
|
|
1
|
-
import type { LoaderWithParser } from '@loaders.gl/loader-utils';
|
|
2
1
|
import { BinaryGeometry } from '@loaders.gl/schema';
|
|
3
2
|
import type { WKBLoaderOptions } from "./wkb-loader.js";
|
|
4
3
|
export type HexWKBLoaderOptions = WKBLoaderOptions;
|
|
5
4
|
/**
|
|
6
5
|
* Worker loader for Hex-encoded WKB (Well-Known Binary)
|
|
7
6
|
*/
|
|
8
|
-
export declare const HexWKBLoader:
|
|
7
|
+
export declare const HexWKBLoader: {
|
|
8
|
+
readonly dataType: BinaryGeometry;
|
|
9
|
+
readonly batchType: never;
|
|
10
|
+
readonly name: "Hexadecimal WKB";
|
|
11
|
+
readonly id: "wkb";
|
|
12
|
+
readonly module: "wkt";
|
|
13
|
+
readonly version: any;
|
|
14
|
+
readonly worker: true;
|
|
15
|
+
readonly category: "geometry";
|
|
16
|
+
readonly extensions: ["wkb"];
|
|
17
|
+
readonly mimeTypes: [];
|
|
18
|
+
readonly options: {
|
|
19
|
+
readonly wkb: {
|
|
20
|
+
readonly shape: "binary-geometry";
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
readonly text: true;
|
|
24
|
+
readonly testText: typeof isHexWKB;
|
|
25
|
+
readonly parse: (arrayBuffer: ArrayBuffer) => Promise<BinaryGeometry>;
|
|
26
|
+
readonly parseTextSync: typeof parseHexWKB;
|
|
27
|
+
};
|
|
28
|
+
declare function parseHexWKB(text: string, options?: HexWKBLoaderOptions): BinaryGeometry;
|
|
9
29
|
/**
|
|
10
30
|
* Check if string is a valid Well-known binary (WKB) in HEX format
|
|
11
31
|
* https://en.wikipedia.org/wiki/Well-known_text_representation_of_geometry
|
|
@@ -14,4 +34,5 @@ export declare const HexWKBLoader: LoaderWithParser<BinaryGeometry, never, HexWK
|
|
|
14
34
|
* @returns true if string is a valid WKB in HEX format
|
|
15
35
|
*/
|
|
16
36
|
export declare function isHexWKB(string: string | null): boolean;
|
|
37
|
+
export {};
|
|
17
38
|
//# sourceMappingURL=hex-wkb-loader.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hex-wkb-loader.d.ts","sourceRoot":"","sources":["../src/hex-wkb-loader.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"hex-wkb-loader.d.ts","sourceRoot":"","sources":["../src/hex-wkb-loader.ts"],"names":[],"mappings":"AAKA,OAAO,EAAC,cAAc,EAAC,MAAM,oBAAoB,CAAC;AAElD,OAAO,KAAK,EAAC,gBAAgB,EAAC,wBAAqB;AAKnD,MAAM,MAAM,mBAAmB,GAAG,gBAAgB,CAAC;AAEnD;;GAEG;AACH,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;kCAeI,WAAW;;CAEyC,CAAC;AAElF,iBAAS,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,mBAAmB,GAAG,cAAc,CAKhF;AAED;;;;;;GAMG;AACH,wBAAgB,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAcvD"}
|
package/dist/hex-wkb-loader.js
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -41,7 +41,7 @@ __export(dist_exports, {
|
|
|
41
41
|
module.exports = __toCommonJS(dist_exports);
|
|
42
42
|
|
|
43
43
|
// dist/lib/utils/version.js
|
|
44
|
-
var VERSION = true ? "4.2.0-alpha.
|
|
44
|
+
var VERSION = true ? "4.2.0-alpha.6" : "latest";
|
|
45
45
|
|
|
46
46
|
// dist/lib/parse-wkt-crs.js
|
|
47
47
|
function parseWKTCRS(wkt, options) {
|
|
@@ -144,6 +144,8 @@ function sort(data, options) {
|
|
|
144
144
|
|
|
145
145
|
// dist/wkt-crs-loader.js
|
|
146
146
|
var WKTCRSLoader = {
|
|
147
|
+
dataType: null,
|
|
148
|
+
batchType: null,
|
|
147
149
|
name: "WKT CRS (Well-Known Text Coordinate Reference System)",
|
|
148
150
|
id: "wkt-crs",
|
|
149
151
|
module: "wkt-crs",
|
|
@@ -447,6 +449,8 @@ function white(state) {
|
|
|
447
449
|
|
|
448
450
|
// dist/wkt-loader.js
|
|
449
451
|
var WKTWorkerLoader = {
|
|
452
|
+
dataType: null,
|
|
453
|
+
batchType: null,
|
|
450
454
|
name: "WKT (Well-Known Text)",
|
|
451
455
|
id: "wkt",
|
|
452
456
|
module: "wkt",
|
|
@@ -468,7 +472,7 @@ var WKTWorkerLoader = {
|
|
|
468
472
|
var WKTLoader = {
|
|
469
473
|
...WKTWorkerLoader,
|
|
470
474
|
parse: async (arrayBuffer, options) => parseWKT(new TextDecoder().decode(arrayBuffer), options),
|
|
471
|
-
parseTextSync: parseWKT
|
|
475
|
+
parseTextSync: (string, options) => parseWKT(string, options)
|
|
472
476
|
};
|
|
473
477
|
|
|
474
478
|
// dist/lib/encode-wkt.js
|
|
@@ -714,7 +718,7 @@ function parseLineString2(dataView, offset, dimension, littleEndian) {
|
|
|
714
718
|
geometry: {
|
|
715
719
|
type: "LineString",
|
|
716
720
|
positions: { value: positions, size: dimension },
|
|
717
|
-
pathIndices: { value: new
|
|
721
|
+
pathIndices: { value: new Uint32Array(pathIndices), size: 1 }
|
|
718
722
|
},
|
|
719
723
|
offset
|
|
720
724
|
};
|
|
@@ -742,10 +746,10 @@ function parsePolygon2(dataView, offset, dimension, littleEndian) {
|
|
|
742
746
|
type: "Polygon",
|
|
743
747
|
positions: { value: concatenatedPositions, size: dimension },
|
|
744
748
|
polygonIndices: {
|
|
745
|
-
value: new
|
|
749
|
+
value: new Uint32Array(polygonIndices),
|
|
746
750
|
size: 1
|
|
747
751
|
},
|
|
748
|
-
primitivePolygonIndices: { value: new
|
|
752
|
+
primitivePolygonIndices: { value: new Uint32Array(primitivePolygonIndices), size: 1 }
|
|
749
753
|
},
|
|
750
754
|
offset
|
|
751
755
|
};
|
|
@@ -817,7 +821,7 @@ function concatenateBinaryLineGeometries(binaryLineGeometries, dimension) {
|
|
|
817
821
|
return {
|
|
818
822
|
type: "LineString",
|
|
819
823
|
positions: { value: concatenatedPositions, size: dimension },
|
|
820
|
-
pathIndices: { value: new
|
|
824
|
+
pathIndices: { value: new Uint32Array(pathIndices), size: 1 }
|
|
821
825
|
};
|
|
822
826
|
}
|
|
823
827
|
function concatenateBinaryPolygonGeometries(binaryPolygonGeometries, dimension) {
|
|
@@ -838,8 +842,8 @@ function concatenateBinaryPolygonGeometries(binaryPolygonGeometries, dimension)
|
|
|
838
842
|
return {
|
|
839
843
|
type: "Polygon",
|
|
840
844
|
positions: { value: concatenatedPositions, size: dimension },
|
|
841
|
-
polygonIndices: { value: new
|
|
842
|
-
primitivePolygonIndices: { value: new
|
|
845
|
+
polygonIndices: { value: new Uint32Array(polygonIndices), size: 1 },
|
|
846
|
+
primitivePolygonIndices: { value: new Uint32Array(primitivePolygonIndices), size: 1 }
|
|
843
847
|
};
|
|
844
848
|
}
|
|
845
849
|
function concatTypedArrays(arrays) {
|
|
@@ -861,6 +865,8 @@ function concatTypedArrays(arrays) {
|
|
|
861
865
|
|
|
862
866
|
// dist/wkb-loader.js
|
|
863
867
|
var WKBWorkerLoader = {
|
|
868
|
+
dataType: null,
|
|
869
|
+
batchType: null,
|
|
864
870
|
name: "WKB",
|
|
865
871
|
id: "wkb",
|
|
866
872
|
module: "wkt",
|
|
@@ -888,9 +894,11 @@ var WKBLoader = {
|
|
|
888
894
|
var LE = true;
|
|
889
895
|
var BE = false;
|
|
890
896
|
var BinaryWriter = class {
|
|
897
|
+
arrayBuffer;
|
|
898
|
+
dataView;
|
|
899
|
+
byteOffset = 0;
|
|
900
|
+
allowResize = false;
|
|
891
901
|
constructor(size, allowResize) {
|
|
892
|
-
this.byteOffset = 0;
|
|
893
|
-
this.allowResize = false;
|
|
894
902
|
this.arrayBuffer = new ArrayBuffer(size);
|
|
895
903
|
this.dataView = new DataView(this.arrayBuffer);
|
|
896
904
|
this.byteOffset = 0;
|
|
@@ -1302,6 +1310,8 @@ function decodeHex(string) {
|
|
|
1302
1310
|
|
|
1303
1311
|
// dist/hex-wkb-loader.js
|
|
1304
1312
|
var HexWKBLoader = {
|
|
1313
|
+
dataType: null,
|
|
1314
|
+
batchType: null,
|
|
1305
1315
|
name: "Hexadecimal WKB",
|
|
1306
1316
|
id: "wkb",
|
|
1307
1317
|
module: "wkt",
|
|
@@ -1338,6 +1348,10 @@ function isHexWKB(string) {
|
|
|
1338
1348
|
|
|
1339
1349
|
// dist/lib/utils/binary-reader.js
|
|
1340
1350
|
var BinaryReader = class {
|
|
1351
|
+
arrayBuffer;
|
|
1352
|
+
dataView;
|
|
1353
|
+
byteOffset;
|
|
1354
|
+
littleEndian;
|
|
1341
1355
|
constructor(arrayBuffer, isBigEndian = false) {
|
|
1342
1356
|
this.arrayBuffer = arrayBuffer;
|
|
1343
1357
|
this.dataView = new DataView(arrayBuffer);
|
|
@@ -1616,6 +1630,8 @@ function parseNextPoint(reader, context, previousPoint) {
|
|
|
1616
1630
|
|
|
1617
1631
|
// dist/twkb-loader.js
|
|
1618
1632
|
var TWKBWorkerLoader = {
|
|
1633
|
+
dataType: null,
|
|
1634
|
+
batchType: null,
|
|
1619
1635
|
name: "TWKB (Tiny Well-Known Binary)",
|
|
1620
1636
|
id: "twkb",
|
|
1621
1637
|
module: "wkt",
|