@loaders.gl/wkt 3.1.0-alpha.5 → 3.1.0-beta.5

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.
Files changed (50) hide show
  1. package/dist/bundle.d.ts +1 -0
  2. package/dist/bundle.d.ts.map +1 -0
  3. package/dist/bundle.js +596 -0
  4. package/dist/es5/lib/parse-wkb.js +4 -3
  5. package/dist/es5/lib/parse-wkb.js.map +1 -1
  6. package/dist/es5/lib/utils/version.js +1 -1
  7. package/dist/es5/lib/utils/version.js.map +1 -1
  8. package/dist/es5/wkb-loader.js.map +1 -1
  9. package/dist/esm/lib/parse-wkb.js +4 -3
  10. package/dist/esm/lib/parse-wkb.js.map +1 -1
  11. package/dist/esm/lib/utils/version.js +1 -1
  12. package/dist/esm/lib/utils/version.js.map +1 -1
  13. package/dist/esm/wkb-loader.js.map +1 -1
  14. package/dist/index.d.ts +1 -0
  15. package/dist/index.d.ts.map +1 -0
  16. package/dist/index.js +11 -0
  17. package/dist/lib/encode-wkt.d.ts +1 -0
  18. package/dist/lib/encode-wkt.d.ts.map +1 -0
  19. package/dist/lib/encode-wkt.js +48 -0
  20. package/dist/lib/parse-wkb.d.ts +2 -1
  21. package/dist/lib/parse-wkb.d.ts.map +1 -0
  22. package/dist/lib/parse-wkb.js +236 -0
  23. package/dist/lib/parse-wkt.d.ts +1 -0
  24. package/dist/lib/parse-wkt.d.ts.map +1 -0
  25. package/dist/lib/parse-wkt.js +227 -0
  26. package/dist/lib/utils/version.d.ts +1 -0
  27. package/dist/lib/utils/version.d.ts.map +1 -0
  28. package/dist/lib/utils/version.js +7 -0
  29. package/dist/wkb-loader.d.ts +2 -1
  30. package/dist/wkb-loader.d.ts.map +1 -0
  31. package/dist/wkb-loader.js +34 -0
  32. package/dist/wkt-loader.d.ts +1 -0
  33. package/dist/wkt-loader.d.ts.map +1 -0
  34. package/dist/wkt-loader.js +33 -0
  35. package/dist/wkt-worker.js +380 -2
  36. package/dist/wkt-writer.d.ts +1 -0
  37. package/dist/wkt-writer.d.ts.map +1 -0
  38. package/dist/wkt-writer.js +23 -0
  39. package/dist/workers/wkb-worker.d.ts +1 -0
  40. package/dist/workers/wkb-worker.d.ts.map +1 -0
  41. package/dist/workers/wkb-worker.js +5 -0
  42. package/dist/workers/wkt-worker.d.ts +1 -0
  43. package/dist/workers/wkt-worker.d.ts.map +1 -0
  44. package/dist/workers/wkt-worker.js +5 -0
  45. package/package.json +6 -7
  46. package/src/lib/parse-wkb.ts +35 -19
  47. package/src/wkb-loader.ts +1 -1
  48. package/dist/dist.min.js +0 -2
  49. package/dist/dist.min.js.map +0 -1
  50. package/dist/wkt-worker.js.map +0 -1
@@ -1,2 +1,380 @@
1
- !function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=7)}([function(e,t,r){e.exports=r(6)},function(e,t){function r(e,t,r,n,o,i,a){try{var u=e[i](a),s=u.value}catch(e){return void r(e)}u.done?t(s):Promise.resolve(s).then(n,o)}e.exports=function(e){return function(){var t=this,n=arguments;return new Promise((function(o,i){var a=e.apply(t,n);function u(e){r(a,o,i,u,s,"next",e)}function s(e){r(a,o,i,u,s,"throw",e)}u(void 0)}))}},e.exports.default=e.exports,e.exports.__esModule=!0},function(e,t){e.exports=function(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e},e.exports.default=e.exports,e.exports.__esModule=!0},function(e,t){e.exports=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},e.exports.default=e.exports,e.exports.__esModule=!0},function(e,t){function r(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}e.exports=function(e,t,n){return t&&r(e.prototype,t),n&&r(e,n),e},e.exports.default=e.exports,e.exports.__esModule=!0},function(e,t){function r(t){return"function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?(e.exports=r=function(e){return typeof e},e.exports.default=e.exports,e.exports.__esModule=!0):(e.exports=r=function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e.exports.default=e.exports,e.exports.__esModule=!0),r(t)}e.exports=r,e.exports.default=e.exports,e.exports.__esModule=!0},function(e,t,r){var n=function(e){"use strict";var t=Object.prototype,r=t.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",i=n.asyncIterator||"@@asyncIterator",a=n.toStringTag||"@@toStringTag";function u(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{u({},"")}catch(e){u=function(e,t,r){return e[t]=r}}function s(e,t,r,n){var o=t&&t.prototype instanceof l?t:l,i=Object.create(o.prototype),a=new j(n||[]);return i._invoke=function(e,t,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return E()}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var u=w(a,r);if(u){if(u===f)continue;return u}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var s=c(e,t,r);if("normal"===s.type){if(n=r.done?"completed":"suspendedYield",s.arg===f)continue;return{value:s.arg,done:r.done}}"throw"===s.type&&(n="completed",r.method="throw",r.arg=s.arg)}}}(e,r,a),i}function c(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}e.wrap=s;var f={};function l(){}function p(){}function y(){}var h={};h[o]=function(){return this};var d=Object.getPrototypeOf,v=d&&d(d(P([])));v&&v!==t&&r.call(v,o)&&(h=v);var g=y.prototype=l.prototype=Object.create(h);function m(e){["next","throw","return"].forEach((function(t){u(e,t,(function(e){return this._invoke(t,e)}))}))}function b(e,t){var n;this._invoke=function(o,i){function a(){return new t((function(n,a){!function n(o,i,a,u){var s=c(e[o],e,i);if("throw"!==s.type){var f=s.arg,l=f.value;return l&&"object"==typeof l&&r.call(l,"__await")?t.resolve(l.__await).then((function(e){n("next",e,a,u)}),(function(e){n("throw",e,a,u)})):t.resolve(l).then((function(e){f.value=e,a(f)}),(function(e){return n("throw",e,a,u)}))}u(s.arg)}(o,i,n,a)}))}return n=n?n.then(a,a):a()}}function w(e,t){var r=e.iterator[t.method];if(void 0===r){if(t.delegate=null,"throw"===t.method){if(e.iterator.return&&(t.method="return",t.arg=void 0,w(e,t),"throw"===t.method))return f;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return f}var n=c(r,e.iterator,t.arg);if("throw"===n.type)return t.method="throw",t.arg=n.arg,t.delegate=null,f;var o=n.arg;return o?o.done?(t[e.resultName]=o.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,f):o:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,f)}function x(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function O(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function j(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(x,this),this.reset(!0)}function P(e){if(e){var t=e[o];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var n=-1,i=function t(){for(;++n<e.length;)if(r.call(e,n))return t.value=e[n],t.done=!1,t;return t.value=void 0,t.done=!0,t};return i.next=i}}return{next:E}}function E(){return{value:void 0,done:!0}}return p.prototype=g.constructor=y,y.constructor=p,p.displayName=u(y,a,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===p||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,y):(e.__proto__=y,u(e,a,"GeneratorFunction")),e.prototype=Object.create(g),e},e.awrap=function(e){return{__await:e}},m(b.prototype),b.prototype[i]=function(){return this},e.AsyncIterator=b,e.async=function(t,r,n,o,i){void 0===i&&(i=Promise);var a=new b(s(t,r,n,o),i);return e.isGeneratorFunction(r)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},m(g),u(g,a,"Generator"),g[o]=function(){return this},g.toString=function(){return"[object Generator]"},e.keys=function(e){var t=[];for(var r in e)t.push(r);return t.reverse(),function r(){for(;t.length;){var n=t.pop();if(n in e)return r.value=n,r.done=!1,r}return r.done=!0,r}},e.values=P,j.prototype={constructor:j,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(O),!e)for(var t in this)"t"===t.charAt(0)&&r.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function n(r,n){return a.type="throw",a.arg=e,t.next=r,n&&(t.method="next",t.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var u=r.call(i,"catchLoc"),s=r.call(i,"finallyLoc");if(u&&s){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(u){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!s)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===e||"continue"===e)&&i.tryLoc<=t&&t<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=e,a.arg=t,i?(this.method="next",this.next=i.finallyLoc,f):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),f},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),O(r),f}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var o=n.arg;O(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:P(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},e}(e.exports);try{regeneratorRuntime=n}catch(e){Function("r","regeneratorRuntime = r")(n)}},function(e,t,r){"use strict";r.r(t);var n=r(2),o=r.n(n),i=r(1),a=r.n(i),u=r(0),s=r.n(u),c=r(3),f=r.n(c),l=r(4),p=r.n(l),y=r(5),h=r.n(y);function d(e){return!!e&&(e instanceof ArrayBuffer||("undefined"!=typeof MessagePort&&e instanceof MessagePort||("undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap||"undefined"!=typeof OffscreenCanvas&&e instanceof OffscreenCanvas)))}var v=new Map,g=function(){function e(){f()(this,e)}return p()(e,null,[{key:"onmessage",set:function(e){self.onmessage=function(t){if(m(t)){var r=t.data,n=r.type,o=r.payload;e(n,o)}}}},{key:"addEventListener",value:function(e){var t=v.get(e);t||(t=function(t){if(m(t)){var r=t.data,n=r.type,o=r.payload;e(n,o)}}),self.addEventListener("message",t)}},{key:"removeEventListener",value:function(e){var t=v.get(e);v.delete(e),self.removeEventListener("message",t)}},{key:"postMessage",value:function(e,t){if(self){var r={source:"loaders.gl",type:e,payload:t},n=function e(t){var r=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],n=arguments.length>2?arguments[2]:void 0,o=n||new Set;if(t){if(d(t))o.add(t);else if(d(t.buffer))o.add(t.buffer);else if(ArrayBuffer.isView(t));else if(r&&"object"===h()(t))for(var i in t)e(t[i],r,o)}else;return void 0===n?Array.from(o):[]}(t);self.postMessage(r,n)}}}]),e}();function m(e){var t=e.type,r=e.data;return"message"===t&&r&&"string"==typeof r.source&&r.source.startsWith("loaders.gl")}function b(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function w(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?b(Object(r),!0).forEach((function(t){o()(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):b(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var x=0;function O(e,t){return new Promise((function(r,n){var o=x++;g.addEventListener((function e(t,i){if(i.id===o)switch(t){case"done":g.removeEventListener(e),r(i.result);break;case"error":g.removeEventListener(e),n(i.error)}}));var i={id:o,input:e,options:t};g.postMessage("process",i)}))}function j(e){return P.apply(this,arguments)}function P(){return(P=a()(s.a.mark((function e(t){var r,n,o,i,a,u,c;return s.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=t.loader,n=t.arrayBuffer,o=t.options,i=t.context,!r.parseSync&&!r.parse){e.next=6;break}a=n,u=r.parseSync||r.parse,e.next=13;break;case 6:if(!r.parseTextSync){e.next=12;break}c=new TextDecoder,a=c.decode(n),u=r.parseTextSync,e.next=13;break;case 12:throw new Error("Could not load data with ".concat(r.name," loader"));case 13:return o=w(w({},o),{},{modules:r&&r.options&&r.options.modules||{},worker:!1}),e.next=16,u(a,w({},o),i,r);case 16:return e.abrupt("return",e.sent);case 17:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var E=/[-+]?([0-9]*\.[0-9]+|[0-9]+)([eE][-+]?[0-9]+)?/,L=new RegExp("^"+E.source+"(\\s"+E.source+"){1,}");function _(e){var t,r=e.split(";"),n=r.pop(),o=(r.shift()||"").split("=").pop(),i=0;function a(e){var t=n.substring(i).match(e);return t?(i+=t[0].length,t[0]):null}function u(){a(/^\s*/)}function s(){u();for(var e,t=0,r=[],n=[r],o=r;e=a(/^(\()/)||a(/^(\))/)||a(/^(,)/)||a(L);){if("("===e)n.push(o),o=[],n[n.length-1].push(o),t++;else if(")"===e){if(0===o.length)return null;if(!(o=n.pop()))return null;if(0===--t)break}else if(","===e)o=[],n[n.length-1].push(o);else{if(e.split(/\s/g).some(isNaN))return null;Array.prototype.push.apply(o,e.split(/\s/g).map(parseFloat))}u()}return 0!==t?null:r}function c(){for(var e,t,r=[];t=a(L)||a(/^(,)/);)","===t?(r.push(e),e=[]):t.split(/\s/g).some(isNaN)||(e||(e=[]),Array.prototype.push.apply(e,t.split(/\s/g).map(parseFloat))),u();return e?(r.push(e),r.length?r:null):null}function f(){return function(){if(!a(/^(point(\sz)?)/i))return null;if(u(),!a(/^(\()/))return null;var e=c();return e?(u(),a(/^(\))/)?{type:"Point",coordinates:e[0]}:null):null}()||function(){if(!a(/^(linestring(\sz)?)/i))return null;if(u(),!a(/^(\()/))return null;var e=c();return e&&a(/^(\))/)?{type:"LineString",coordinates:e}:null}()||function(){if(!a(/^(polygon(\sz)?)/i))return null;u();var e=s();return e?{type:"Polygon",coordinates:e}:null}()||function(){if(!a(/^(multipoint)/i))return null;u();var e=n.substring(n.indexOf("(")+1,n.length-1).replace(/\(/g,"").replace(/\)/g,"");n="MULTIPOINT ("+e+")";var t=s();return t?(u(),{type:"MultiPoint",coordinates:t}):null}()||function(){if(!a(/^(multilinestring)/i))return null;u();var e=s();return e?(u(),{type:"MultiLineString",coordinates:e}):null}()||function(){if(!a(/^(multipolygon)/i))return null;u();var e=s();return e?{type:"MultiPolygon",coordinates:e}:null}()||function(){var e,t=[];if(!a(/^(geometrycollection)/i))return null;if(u(),!a(/^(\()/))return null;for(;e=f();)t.push(e),u(),a(/^(,)/),u();return a(/^(\))/)?{type:"GeometryCollection",geometries:t}:null}()}return(t=f())&&o.match(/\d+/)&&(t.crs={type:"name",properties:{name:"urn:ogc:def:crs:EPSG::"+o}}),t}function k(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function S(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?k(Object(r),!0).forEach((function(t){o()(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):k(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var M,T,N=S(S({},{name:"WKT (Well-Known Text)",id:"wkt",module:"wkt",version:"3.1.0-alpha.5",worker:!0,extensions:["wkt"],mimeTypes:["text/plain"],category:"geometry",text:!0,options:{wkt:{}}}),{},{parse:(M=a()(s.a.mark((function e(t){return s.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",_((new TextDecoder).decode(t)));case 1:case"end":return e.stop()}}),e)}))),function(e){return M.apply(this,arguments)}),parseTextSync:_});T=N,"undefined"!=typeof self&&(g.onmessage=function(){var e=a()(s.a.mark((function e(t,r){var n,o,i,a,u;return s.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:e.t0=t,e.next="process"===e.t0?3:16;break;case 3:return e.prev=3,n=r.input,o=r.options,i=void 0===o?{}:o,e.next=7,j({loader:T,arrayBuffer:n,options:i,context:{parse:O}});case 7:a=e.sent,g.postMessage("done",{result:a}),e.next=15;break;case 11:e.prev=11,e.t1=e.catch(3),u=e.t1 instanceof Error?e.t1.message:"",g.postMessage("error",{error:u});case 15:return e.abrupt("break",16);case 16:case"end":return e.stop()}}),e,null,[[3,11]])})));return function(t,r){return e.apply(this,arguments)}}())}]);
2
- //# sourceMappingURL=wkt-worker.js.map
1
+ (() => {
2
+ // ../worker-utils/src/lib/worker-utils/get-transfer-list.ts
3
+ function getTransferList(object, recursive = true, transfers) {
4
+ const transfersSet = transfers || new Set();
5
+ if (!object) {
6
+ } else if (isTransferable(object)) {
7
+ transfersSet.add(object);
8
+ } else if (isTransferable(object.buffer)) {
9
+ transfersSet.add(object.buffer);
10
+ } else if (ArrayBuffer.isView(object)) {
11
+ } else if (recursive && typeof object === "object") {
12
+ for (const key in object) {
13
+ getTransferList(object[key], recursive, transfersSet);
14
+ }
15
+ }
16
+ return transfers === void 0 ? Array.from(transfersSet) : [];
17
+ }
18
+ function isTransferable(object) {
19
+ if (!object) {
20
+ return false;
21
+ }
22
+ if (object instanceof ArrayBuffer) {
23
+ return true;
24
+ }
25
+ if (typeof MessagePort !== "undefined" && object instanceof MessagePort) {
26
+ return true;
27
+ }
28
+ if (typeof ImageBitmap !== "undefined" && object instanceof ImageBitmap) {
29
+ return true;
30
+ }
31
+ if (typeof OffscreenCanvas !== "undefined" && object instanceof OffscreenCanvas) {
32
+ return true;
33
+ }
34
+ return false;
35
+ }
36
+
37
+ // ../worker-utils/src/lib/worker-farm/worker-body.ts
38
+ var onMessageWrapperMap = new Map();
39
+ var WorkerBody = class {
40
+ static set onmessage(onMessage) {
41
+ self.onmessage = (message) => {
42
+ if (!isKnownMessage(message)) {
43
+ return;
44
+ }
45
+ const { type, payload } = message.data;
46
+ onMessage(type, payload);
47
+ };
48
+ }
49
+ static addEventListener(onMessage) {
50
+ let onMessageWrapper = onMessageWrapperMap.get(onMessage);
51
+ if (!onMessageWrapper) {
52
+ onMessageWrapper = (message) => {
53
+ if (!isKnownMessage(message)) {
54
+ return;
55
+ }
56
+ const { type, payload } = message.data;
57
+ onMessage(type, payload);
58
+ };
59
+ }
60
+ self.addEventListener("message", onMessageWrapper);
61
+ }
62
+ static removeEventListener(onMessage) {
63
+ const onMessageWrapper = onMessageWrapperMap.get(onMessage);
64
+ onMessageWrapperMap.delete(onMessage);
65
+ self.removeEventListener("message", onMessageWrapper);
66
+ }
67
+ static postMessage(type, payload) {
68
+ if (self) {
69
+ const data = { source: "loaders.gl", type, payload };
70
+ const transferList = getTransferList(payload);
71
+ self.postMessage(data, transferList);
72
+ }
73
+ }
74
+ };
75
+ function isKnownMessage(message) {
76
+ const { type, data } = message;
77
+ return type === "message" && data && typeof data.source === "string" && data.source.startsWith("loaders.gl");
78
+ }
79
+
80
+ // ../loader-utils/src/lib/worker-loader-utils/create-loader-worker.ts
81
+ var requestId = 0;
82
+ function createLoaderWorker(loader) {
83
+ if (typeof self === "undefined") {
84
+ return;
85
+ }
86
+ WorkerBody.onmessage = async (type, payload) => {
87
+ switch (type) {
88
+ case "process":
89
+ try {
90
+ const { input, options = {} } = payload;
91
+ const result = await parseData({
92
+ loader,
93
+ arrayBuffer: input,
94
+ options,
95
+ context: {
96
+ parse: parseOnMainThread
97
+ }
98
+ });
99
+ WorkerBody.postMessage("done", { result });
100
+ } catch (error) {
101
+ const message = error instanceof Error ? error.message : "";
102
+ WorkerBody.postMessage("error", { error: message });
103
+ }
104
+ break;
105
+ default:
106
+ }
107
+ };
108
+ }
109
+ function parseOnMainThread(arrayBuffer, options) {
110
+ return new Promise((resolve, reject) => {
111
+ const id = requestId++;
112
+ const onMessage = (type, payload2) => {
113
+ if (payload2.id !== id) {
114
+ return;
115
+ }
116
+ switch (type) {
117
+ case "done":
118
+ WorkerBody.removeEventListener(onMessage);
119
+ resolve(payload2.result);
120
+ break;
121
+ case "error":
122
+ WorkerBody.removeEventListener(onMessage);
123
+ reject(payload2.error);
124
+ break;
125
+ default:
126
+ }
127
+ };
128
+ WorkerBody.addEventListener(onMessage);
129
+ const payload = { id, input: arrayBuffer, options };
130
+ WorkerBody.postMessage("process", payload);
131
+ });
132
+ }
133
+ async function parseData({ loader, arrayBuffer, options, context }) {
134
+ let data;
135
+ let parser;
136
+ if (loader.parseSync || loader.parse) {
137
+ data = arrayBuffer;
138
+ parser = loader.parseSync || loader.parse;
139
+ } else if (loader.parseTextSync) {
140
+ const textDecoder = new TextDecoder();
141
+ data = textDecoder.decode(arrayBuffer);
142
+ parser = loader.parseTextSync;
143
+ } else {
144
+ throw new Error(`Could not load data with ${loader.name} loader`);
145
+ }
146
+ options = {
147
+ ...options,
148
+ modules: loader && loader.options && loader.options.modules || {},
149
+ worker: false
150
+ };
151
+ return await parser(data, { ...options }, context, loader);
152
+ }
153
+
154
+ // src/lib/utils/version.ts
155
+ var VERSION = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
156
+
157
+ // src/lib/parse-wkt.ts
158
+ var numberRegexp = /[-+]?([0-9]*\.[0-9]+|[0-9]+)([eE][-+]?[0-9]+)?/;
159
+ var tuples = new RegExp("^" + numberRegexp.source + "(\\s" + numberRegexp.source + "){1,}");
160
+ function parseWKT(input) {
161
+ const parts = input.split(";");
162
+ let _ = parts.pop();
163
+ const srid = (parts.shift() || "").split("=").pop();
164
+ let i = 0;
165
+ function $(re) {
166
+ const match = _.substring(i).match(re);
167
+ if (!match)
168
+ return null;
169
+ else {
170
+ i += match[0].length;
171
+ return match[0];
172
+ }
173
+ }
174
+ function crs(obj) {
175
+ if (obj && srid.match(/\d+/)) {
176
+ obj.crs = {
177
+ type: "name",
178
+ properties: {
179
+ name: "urn:ogc:def:crs:EPSG::" + srid
180
+ }
181
+ };
182
+ }
183
+ return obj;
184
+ }
185
+ function white() {
186
+ $(/^\s*/);
187
+ }
188
+ function multicoords() {
189
+ white();
190
+ let depth = 0;
191
+ const rings = [];
192
+ const stack = [rings];
193
+ let pointer = rings;
194
+ let elem;
195
+ while (elem = $(/^(\()/) || $(/^(\))/) || $(/^(,)/) || $(tuples)) {
196
+ if (elem === "(") {
197
+ stack.push(pointer);
198
+ pointer = [];
199
+ stack[stack.length - 1].push(pointer);
200
+ depth++;
201
+ } else if (elem === ")") {
202
+ if (pointer.length === 0)
203
+ return null;
204
+ pointer = stack.pop();
205
+ if (!pointer)
206
+ return null;
207
+ depth--;
208
+ if (depth === 0)
209
+ break;
210
+ } else if (elem === ",") {
211
+ pointer = [];
212
+ stack[stack.length - 1].push(pointer);
213
+ } else if (!elem.split(/\s/g).some(isNaN)) {
214
+ Array.prototype.push.apply(pointer, elem.split(/\s/g).map(parseFloat));
215
+ } else {
216
+ return null;
217
+ }
218
+ white();
219
+ }
220
+ if (depth !== 0)
221
+ return null;
222
+ return rings;
223
+ }
224
+ function coords() {
225
+ const list = [];
226
+ let item;
227
+ let pt;
228
+ while (pt = $(tuples) || $(/^(,)/)) {
229
+ if (pt === ",") {
230
+ list.push(item);
231
+ item = [];
232
+ } else if (!pt.split(/\s/g).some(isNaN)) {
233
+ if (!item)
234
+ item = [];
235
+ Array.prototype.push.apply(item, pt.split(/\s/g).map(parseFloat));
236
+ }
237
+ white();
238
+ }
239
+ if (item)
240
+ list.push(item);
241
+ else
242
+ return null;
243
+ return list.length ? list : null;
244
+ }
245
+ function point() {
246
+ if (!$(/^(point(\sz)?)/i))
247
+ return null;
248
+ white();
249
+ if (!$(/^(\()/))
250
+ return null;
251
+ const c = coords();
252
+ if (!c)
253
+ return null;
254
+ white();
255
+ if (!$(/^(\))/))
256
+ return null;
257
+ return {
258
+ type: "Point",
259
+ coordinates: c[0]
260
+ };
261
+ }
262
+ function multipoint() {
263
+ if (!$(/^(multipoint)/i))
264
+ return null;
265
+ white();
266
+ const newCoordsFormat = _.substring(_.indexOf("(") + 1, _.length - 1).replace(/\(/g, "").replace(/\)/g, "");
267
+ _ = "MULTIPOINT (" + newCoordsFormat + ")";
268
+ const c = multicoords();
269
+ if (!c)
270
+ return null;
271
+ white();
272
+ return {
273
+ type: "MultiPoint",
274
+ coordinates: c
275
+ };
276
+ }
277
+ function multilinestring() {
278
+ if (!$(/^(multilinestring)/i))
279
+ return null;
280
+ white();
281
+ const c = multicoords();
282
+ if (!c)
283
+ return null;
284
+ white();
285
+ return {
286
+ type: "MultiLineString",
287
+ coordinates: c
288
+ };
289
+ }
290
+ function linestring() {
291
+ if (!$(/^(linestring(\sz)?)/i))
292
+ return null;
293
+ white();
294
+ if (!$(/^(\()/))
295
+ return null;
296
+ const c = coords();
297
+ if (!c)
298
+ return null;
299
+ if (!$(/^(\))/))
300
+ return null;
301
+ return {
302
+ type: "LineString",
303
+ coordinates: c
304
+ };
305
+ }
306
+ function polygon() {
307
+ if (!$(/^(polygon(\sz)?)/i))
308
+ return null;
309
+ white();
310
+ const c = multicoords();
311
+ if (!c)
312
+ return null;
313
+ return {
314
+ type: "Polygon",
315
+ coordinates: c
316
+ };
317
+ }
318
+ function multipolygon() {
319
+ if (!$(/^(multipolygon)/i))
320
+ return null;
321
+ white();
322
+ const c = multicoords();
323
+ if (!c)
324
+ return null;
325
+ return {
326
+ type: "MultiPolygon",
327
+ coordinates: c
328
+ };
329
+ }
330
+ function geometrycollection() {
331
+ const geometries = [];
332
+ let geometry;
333
+ if (!$(/^(geometrycollection)/i))
334
+ return null;
335
+ white();
336
+ if (!$(/^(\()/))
337
+ return null;
338
+ while (geometry = root()) {
339
+ geometries.push(geometry);
340
+ white();
341
+ $(/^(,)/);
342
+ white();
343
+ }
344
+ if (!$(/^(\))/))
345
+ return null;
346
+ return {
347
+ type: "GeometryCollection",
348
+ geometries
349
+ };
350
+ }
351
+ function root() {
352
+ return point() || linestring() || polygon() || multipoint() || multilinestring() || multipolygon() || geometrycollection();
353
+ }
354
+ return crs(root());
355
+ }
356
+
357
+ // src/wkt-loader.ts
358
+ var WKTWorkerLoader = {
359
+ name: "WKT (Well-Known Text)",
360
+ id: "wkt",
361
+ module: "wkt",
362
+ version: VERSION,
363
+ worker: true,
364
+ extensions: ["wkt"],
365
+ mimeTypes: ["text/plain"],
366
+ category: "geometry",
367
+ text: true,
368
+ options: {
369
+ wkt: {}
370
+ }
371
+ };
372
+ var WKTLoader = {
373
+ ...WKTWorkerLoader,
374
+ parse: async (arrayBuffer) => parseWKT(new TextDecoder().decode(arrayBuffer)),
375
+ parseTextSync: parseWKT
376
+ };
377
+
378
+ // src/workers/wkt-worker.ts
379
+ createLoaderWorker(WKTLoader);
380
+ })();
@@ -3,3 +3,4 @@ import type { Writer } from '@loaders.gl/loader-utils';
3
3
  * WKT exporter
4
4
  */
5
5
  export declare const WKTWriter: Writer;
6
+ //# sourceMappingURL=wkt-writer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wkt-writer.d.ts","sourceRoot":"","sources":["../src/wkt-writer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,0BAA0B,CAAC;AAIrD;;GAEG;AACH,eAAO,MAAM,SAAS,EAAE,MAWvB,CAAC"}
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.WKTWriter = void 0;
7
+ const version_1 = require("./lib/utils/version");
8
+ const encode_wkt_1 = __importDefault(require("./lib/encode-wkt"));
9
+ /**
10
+ * WKT exporter
11
+ */
12
+ exports.WKTWriter = {
13
+ name: 'WKT (Well Known Text)',
14
+ id: 'wkt',
15
+ module: 'wkt',
16
+ version: version_1.VERSION,
17
+ extensions: ['wkt'],
18
+ // @ts-ignore
19
+ encode: encode_wkt_1.default,
20
+ options: {
21
+ wkt: {}
22
+ }
23
+ };
@@ -1 +1,2 @@
1
1
  export {};
2
+ //# sourceMappingURL=wkb-worker.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wkb-worker.d.ts","sourceRoot":"","sources":["../../src/workers/wkb-worker.ts"],"names":[],"mappings":""}
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const loader_utils_1 = require("@loaders.gl/loader-utils");
4
+ const wkb_loader_1 = require("../wkb-loader");
5
+ (0, loader_utils_1.createLoaderWorker)(wkb_loader_1.WKBLoader);
@@ -1 +1,2 @@
1
1
  export {};
2
+ //# sourceMappingURL=wkt-worker.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wkt-worker.d.ts","sourceRoot":"","sources":["../../src/workers/wkt-worker.ts"],"names":[],"mappings":""}
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const loader_utils_1 = require("@loaders.gl/loader-utils");
4
+ const wkt_loader_1 = require("../wkt-loader");
5
+ (0, loader_utils_1.createLoaderWorker)(wkt_loader_1.WKTLoader);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@loaders.gl/wkt",
3
3
  "description": "Loader and Writer for the WKT (Well Known Text) Format",
4
- "version": "3.1.0-alpha.5",
4
+ "version": "3.1.0-beta.5",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
7
7
  "access": "public"
@@ -28,16 +28,15 @@
28
28
  ],
29
29
  "scripts": {
30
30
  "pre-build": "npm run build-worker && npm run build-bundle",
31
- "post-build": "tsc",
32
- "build-bundle": "webpack --display=minimal --config ../../scripts/webpack/bundle.js",
33
- "build-worker": "webpack --entry ./src/workers/wkt-worker.ts --output ./dist/wkt-worker.js --config ../../scripts/webpack/worker.js"
31
+ "build-bundle": "esbuild src/bundle.ts --bundle --outfile=dist/bundle.js",
32
+ "build-worker": "esbuild src/workers/wkt-worker.ts --bundle --outfile=dist/wkt-worker.js"
34
33
  },
35
34
  "devDependencies": {
36
35
  "fuzzer": "^0.2.1"
37
36
  },
38
37
  "dependencies": {
39
- "@loaders.gl/loader-utils": "3.1.0-alpha.5",
40
- "@loaders.gl/schema": "3.1.0-alpha.5"
38
+ "@loaders.gl/loader-utils": "3.1.0-beta.5",
39
+ "@loaders.gl/schema": "3.1.0-beta.5"
41
40
  },
42
- "gitHead": "352241dd910a8c6307a235dadbe154ca915b885b"
41
+ "gitHead": "5d66468457cc878d2dbff3d7807d737ceb181c9a"
43
42
  }
@@ -13,8 +13,8 @@ const NUM_DIMENSIONS = {
13
13
  3: 4 // 4D (ZM)
14
14
  };
15
15
 
16
- export default function parseWKB(buffer): BinaryGeometry {
17
- const view = new DataView(buffer);
16
+ export default function parseWKB(arrayBuffer: ArrayBuffer): BinaryGeometry {
17
+ const view = new DataView(arrayBuffer);
18
18
  let offset = 0;
19
19
 
20
20
  // Check endianness of data
@@ -26,7 +26,8 @@ export default function parseWKB(buffer): BinaryGeometry {
26
26
  offset += 4;
27
27
 
28
28
  const geometryType = geometryCode % 1000;
29
- const dimension = NUM_DIMENSIONS[(geometryCode - geometryType) / 1000];
29
+ const type = ((geometryCode - geometryType) / 1000) as 0 | 1 | 2 | 3;
30
+ const dimension = NUM_DIMENSIONS[type];
30
31
 
31
32
  switch (geometryType) {
32
33
  case 1:
@@ -60,10 +61,10 @@ export default function parseWKB(buffer): BinaryGeometry {
60
61
 
61
62
  // Primitives; parse point and linear ring
62
63
  function parsePoint(
63
- view,
64
- offset,
65
- dimension,
66
- littleEndian
64
+ view: DataView,
65
+ offset: number,
66
+ dimension: number,
67
+ littleEndian: boolean
67
68
  ): {geometry: BinaryPointGeometry; offset: number} {
68
69
  const positions = new Float64Array(dimension);
69
70
  for (let i = 0; i < dimension; i++) {
@@ -78,10 +79,10 @@ function parsePoint(
78
79
  }
79
80
 
80
81
  function parseLineString(
81
- view,
82
- offset,
83
- dimension,
84
- littleEndian
82
+ view: DataView,
83
+ offset: number,
84
+ dimension: number,
85
+ littleEndian: boolean
85
86
  ): {geometry: BinaryLineGeometry; offset: number} {
86
87
  const nPoints = view.getUint32(offset, littleEndian);
87
88
  offset += 4;
@@ -109,13 +110,13 @@ function parseLineString(
109
110
  }
110
111
 
111
112
  // https://stackoverflow.com/a/55261098
112
- const cumulativeSum = (sum) => (value) => (sum += value);
113
+ const cumulativeSum = (sum: number) => (value: number) => (sum += value);
113
114
 
114
115
  function parsePolygon(
115
- view,
116
- offset,
117
- dimension,
118
- littleEndian
116
+ view: DataView,
117
+ offset: number,
118
+ dimension: number,
119
+ littleEndian: boolean
119
120
  ): {geometry: BinaryPolygonGeometry; offset: number} {
120
121
  const nRings = view.getUint32(offset, littleEndian);
121
122
  offset += 4;
@@ -150,7 +151,12 @@ function parsePolygon(
150
151
  };
151
152
  }
152
153
 
153
- function parseMultiPoint(view, offset, dimension, littleEndian): BinaryPointGeometry {
154
+ function parseMultiPoint(
155
+ view: DataView,
156
+ offset: number,
157
+ dimension: number,
158
+ littleEndian: boolean
159
+ ): BinaryPointGeometry {
154
160
  const nPoints = view.getUint32(offset, littleEndian);
155
161
  offset += 4;
156
162
 
@@ -175,7 +181,12 @@ function parseMultiPoint(view, offset, dimension, littleEndian): BinaryPointGeom
175
181
  return concatenateBinaryPointGeometries(binaryPointGeometries, dimension);
176
182
  }
177
183
 
178
- function parseMultiLineString(view, offset, dimension, littleEndian): BinaryLineGeometry {
184
+ function parseMultiLineString(
185
+ view: DataView,
186
+ offset: number,
187
+ dimension: number,
188
+ littleEndian: boolean
189
+ ): BinaryLineGeometry {
179
190
  const nLines = view.getUint32(offset, littleEndian);
180
191
  offset += 4;
181
192
 
@@ -199,7 +210,12 @@ function parseMultiLineString(view, offset, dimension, littleEndian): BinaryLine
199
210
  return concatenateBinaryLineGeometries(binaryLineGeometries, dimension);
200
211
  }
201
212
 
202
- function parseMultiPolygon(view, offset, dimension, littleEndian): BinaryPolygonGeometry {
213
+ function parseMultiPolygon(
214
+ view: DataView,
215
+ offset: number,
216
+ dimension: number,
217
+ littleEndian: boolean
218
+ ): BinaryPolygonGeometry {
203
219
  const nPolygons = view.getUint32(offset, littleEndian);
204
220
  offset += 4;
205
221
 
package/src/wkb-loader.ts CHANGED
@@ -24,7 +24,7 @@ export const WKBWorkerLoader = {
24
24
  */
25
25
  export const WKBLoader = {
26
26
  ...WKBWorkerLoader,
27
- parse: async (arrayBuffer) => parseWKB(arrayBuffer),
27
+ parse: async (arrayBuffer: ArrayBuffer) => parseWKB(arrayBuffer),
28
28
  parseSync: parseWKB
29
29
  };
30
30
 
package/dist/dist.min.js DELETED
@@ -1,2 +0,0 @@
1
- !function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var n=e();for(var o in n)("object"==typeof exports?exports:t)[o]=n[o]}}(window,(function(){return function(t){var e={};function n(o){if(e[o])return e[o].exports;var r=e[o]={i:o,l:!1,exports:{}};return t[o].call(r.exports,r,r.exports,n),r.l=!0,r.exports}return n.m=t,n.c=e,n.d=function(t,e,o){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:o})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var o=Object.create(null);if(n.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var r in t)n.d(o,r,function(e){return t[e]}.bind(null,r));return o},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=0)}([function(t,e,n){const o=n(1);globalThis.loaders=globalThis.loaders||{},t.exports=Object.assign(globalThis.loaders,o)},function(t,e,n){"use strict";n.r(e),n.d(e,"WKBLoader",(function(){return f})),n.d(e,"WKBWorkerLoader",(function(){return a})),n.d(e,"WKTLoader",(function(){return m})),n.d(e,"WKTWorkerLoader",(function(){return d})),n.d(e,"WKTWriter",(function(){return h}));const o={0:2,1:3,2:3,3:4};function r(t){const e=new DataView(t);let n=0;const r=1===e.getUint8(n);n++;const a=e.getUint32(n,r);n+=4;const f=a%1e3,p=o[(a-f)/1e3];switch(f){case 1:return i(e,n,p,r).geometry;case 2:return s(e,n,p,r).geometry;case 3:return l(e,n,p,r).geometry;case 4:const t=function(t,e,n,o){const r=t.getUint32(e,o);e+=4;const s=[];for(let o=0;o<r;o++){const o=1===t.getUint8(e);if(e++,t.getUint32(e,o)%1e3!=1)throw new Error("WKB: Inner geometries of MultiPoint not of type Point");const r=i(t,e+=4,n,o);e=r.offset,s.push(r.geometry)}return function(t,e){const n=t.map(t=>t.positions.value);return{type:"Point",positions:{value:new Float64Array(c(n).buffer),size:e}}}(s,n)}(e,n,p,r);return t.type="Point",t;case 5:const o=function(t,e,n,o){const r=t.getUint32(e,o);e+=4;const i=[];for(let o=0;o<r;o++){const o=1===t.getUint8(e);if(e++,t.getUint32(e,o)%1e3!=2)throw new Error("WKB: Inner geometries of MultiLineString not of type LineString");const r=s(t,e+=4,n,o);e=r.offset,i.push(r.geometry)}return function(t,e){const n=t.map(t=>t.positions.value),o=new Float64Array(c(n).buffer),r=n.map(t=>t.length/e).map(u(0));return r.unshift(0),{type:"LineString",positions:{value:o,size:e},pathIndices:{value:new Uint16Array(r),size:1}}}(i,n)}(e,n,p,r);return o.type="LineString",o;case 6:const a=function(t,e,n,o){const r=t.getUint32(e,o);e+=4;const i=[];for(let o=0;o<r;o++){const o=1===t.getUint8(e);if(e++,t.getUint32(e,o)%1e3!=3)throw new Error("WKB: Inner geometries of MultiPolygon not of type Polygon");const r=l(t,e+=4,n,o);e=r.offset,i.push(r.geometry)}return function(t,e){const n=[],o=[];for(const e of t){const{positions:t,primitivePolygonIndices:r}=e;n.push(t.value),o.push(r.value)}const r=new Float64Array(c(n).buffer),i=n.map(t=>t.length/e).map(u(0));i.unshift(0);const s=[0];for(const t of o)s.push(...t.filter(t=>t>0).map(t=>t+s[s.length-1]));return{type:"Polygon",positions:{value:r,size:e},polygonIndices:{value:new Uint16Array(i),size:1},primitivePolygonIndices:{value:new Uint16Array(s),size:1}}}(i,n)}(e,n,p,r);return a.type="Polygon",a;default:throw new Error("WKB: Unsupported geometry type: "+f)}}function i(t,e,n,o){const r=new Float64Array(n);for(let i=0;i<n;i++)r[i]=t.getFloat64(e,o),e+=8;return{geometry:{type:"Point",positions:{value:r,size:n}},offset:e}}function s(t,e,n,o){const r=t.getUint32(e,o);e+=4;const i=new Float64Array(r*n);for(let s=0;s<r*n;s++)i[s]=t.getFloat64(e,o),e+=8;const s=[0];return r>0&&s.push(r),{geometry:{type:"LineString",positions:{value:i,size:n},pathIndices:{value:new Uint16Array(s),size:1}},offset:e}}const u=t=>e=>t+=e;function l(t,e,n,o){const r=t.getUint32(e,o);e+=4;const i=[];for(let u=0;u<r;u++){const r=s(t,e,n,o),{positions:u}=r.geometry;e=r.offset,i.push(u.value)}const l=new Float64Array(c(i).buffer),a=[0];l.length>0&&a.push(l.length/n);const f=i.map(t=>t.length/n).map(u(0));return f.unshift(0),{geometry:{type:"Polygon",positions:{value:l,size:n},polygonIndices:{value:new Uint16Array(a),size:1},primitivePolygonIndices:{value:new Uint16Array(f),size:1}},offset:e}}function c(t){let e=0;for(let n=0;n<t.length;++n)e+=t[n].byteLength;const n=new Uint8Array(e);let o=0;for(let r=0;r<t.length;++r){const i=new Uint8Array(t[r].buffer);e=i.length;for(let t=0;t<e;++t)n[o++]=i[t]}return n}const a={name:"WKB",id:"wkb",module:"wkt",version:"3.1.0-alpha.5",worker:!0,category:"geometry",extensions:["wkb"],mimeTypes:[],options:{wkb:{}}},f={...a,parse:async t=>r(t),parseSync:r},p=/[-+]?([0-9]*\.[0-9]+|[0-9]+)([eE][-+]?[0-9]+)?/,y=new RegExp("^"+p.source+"(\\s"+p.source+"){1,}");function g(t){const e=t.split(";");let n=e.pop();const o=(e.shift()||"").split("=").pop();let r=0;function i(t){const e=n.substring(r).match(t);return e?(r+=e[0].length,e[0]):null}function s(){i(/^\s*/)}function u(){s();let t=0;const e=[],n=[e];let o,r=e;for(;o=i(/^(\()/)||i(/^(\))/)||i(/^(,)/)||i(y);){if("("===o)n.push(r),r=[],n[n.length-1].push(r),t++;else if(")"===o){if(0===r.length)return null;if(r=n.pop(),!r)return null;if(t--,0===t)break}else if(","===o)r=[],n[n.length-1].push(r);else{if(o.split(/\s/g).some(isNaN))return null;Array.prototype.push.apply(r,o.split(/\s/g).map(parseFloat))}s()}return 0!==t?null:e}function l(){const t=[];let e,n;for(;n=i(y)||i(/^(,)/);)","===n?(t.push(e),e=[]):n.split(/\s/g).some(isNaN)||(e||(e=[]),Array.prototype.push.apply(e,n.split(/\s/g).map(parseFloat))),s();return e?(t.push(e),t.length?t:null):null}function c(){return function(){if(!i(/^(point(\sz)?)/i))return null;if(s(),!i(/^(\()/))return null;const t=l();return t?(s(),i(/^(\))/)?{type:"Point",coordinates:t[0]}:null):null}()||function(){if(!i(/^(linestring(\sz)?)/i))return null;if(s(),!i(/^(\()/))return null;const t=l();return t&&i(/^(\))/)?{type:"LineString",coordinates:t}:null}()||function(){if(!i(/^(polygon(\sz)?)/i))return null;s();const t=u();return t?{type:"Polygon",coordinates:t}:null}()||function(){if(!i(/^(multipoint)/i))return null;s();const t=n.substring(n.indexOf("(")+1,n.length-1).replace(/\(/g,"").replace(/\)/g,"");n="MULTIPOINT ("+t+")";const e=u();return e?(s(),{type:"MultiPoint",coordinates:e}):null}()||function(){if(!i(/^(multilinestring)/i))return null;s();const t=u();return t?(s(),{type:"MultiLineString",coordinates:t}):null}()||function(){if(!i(/^(multipolygon)/i))return null;s();const t=u();return t?{type:"MultiPolygon",coordinates:t}:null}()||function(){const t=[];let e;if(!i(/^(geometrycollection)/i))return null;if(s(),!i(/^(\()/))return null;for(;e=c();)t.push(e),s(),i(/^(,)/),s();return i(/^(\))/)?{type:"GeometryCollection",geometries:t}:null}()}return(a=c())&&o.match(/\d+/)&&(a.crs={type:"name",properties:{name:"urn:ogc:def:crs:EPSG::"+o}}),a;var a}const d={name:"WKT (Well-Known Text)",id:"wkt",module:"wkt",version:"3.1.0-alpha.5",worker:!0,extensions:["wkt"],mimeTypes:["text/plain"],category:"geometry",text:!0,options:{wkt:{}}},m={...d,parse:async t=>g((new TextDecoder).decode(t)),parseTextSync:g};const h={name:"WKT (Well Known Text)",id:"wkt",module:"wkt",version:"3.1.0-alpha.5",extensions:["wkt"],encode:function t(e){function n(t){return t.join(" ")}function o(t){return t.map(n).join(", ")}function r(t){return t.map(o).map(i).join(", ")}function i(t){return`(${t})`}switch("Feature"===e.type&&(e=e.geometry),e.type){case"Point":return"POINT "+i(n(e.coordinates));case"LineString":return"LINESTRING "+i(o(e.coordinates));case"Polygon":return"POLYGON "+i(r(e.coordinates));case"MultiPoint":return"MULTIPOINT "+i(o(e.coordinates));case"MultiPolygon":return"MULTIPOLYGON "+i(e.coordinates.map(r).map(i).join(", "));case"MultiLineString":return"MULTILINESTRING "+i(r(e.coordinates));case"GeometryCollection":return"GEOMETRYCOLLECTION "+i(e.geometries.map(t).join(", "));default:return(t=>{throw new Error("stringify requires a valid GeoJSON Feature or geometry object as input")})()}},options:{wkt:{}}}}])}));
2
- //# sourceMappingURL=dist.min.js.map