UNPKG

itowns

Version:

A JS/WebGL framework for 3D geospatial data visualization

2 lines 4.57 kB
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("itowns_lasparser",[],t):"object"==typeof exports?exports.itowns_lasparser=t():e.itowns_lasparser=t()}(self,(()=>(()=>{var e,t,r={10539:()=>{},56794:(e,t,r)=>{"use strict";var n=r(15702),a=r(26977),o=r(15234);function i(e){return 1===e.majorVersion&&e.minorVersion<=2?8:16}const s=new class{constructor(){this._wasmPath="https://cdn.jsdelivr.net/npm/laz-perf@0.0.6/lib",this._wasmPromise=null}_initDecoder(){return this._wasmPromise||(this._wasmPromise=a.LazPerf.create({locateFile:e=>`${this._wasmPath}/${e}`})),this._wasmPromise}_parseView(e,t){const r=t.colorDepth??16,n=["X","Y","Z"].map(e.getter),a=e.getter("Intensity"),o=e.getter("ReturnNumber"),i=e.getter("NumberOfReturns"),s=e.getter("Classification"),p=e.getter("PointSourceId"),c=e.dimensions.Red?["Red","Green","Blue"].map(e.getter):void 0,u=e.getter("ScanAngle"),l=new Float32Array(3*e.pointCount),f=new Uint16Array(e.pointCount),h=new Uint8Array(e.pointCount),m=new Uint8Array(e.pointCount),w=new Uint8Array(e.pointCount),d=new Uint16Array(e.pointCount),y=c?new Uint8Array(4*e.pointCount):void 0,g=new Float32Array(e.pointCount),b=n.map((e=>e(0))).map((e=>Math.floor(e)));for(let t=0;t<e.pointCount;t++){const[e,v,C]=n.map((e=>e(t)));if(l[3*t]=e-b[0],l[3*t+1]=v-b[1],l[3*t+2]=C-b[2],f[t]=a(t),h[t]=o(t),m[t]=i(t),c){let[e,n,a]=c.map((e=>e(t)));16===r&&(e/=256,n/=256,a/=256),y[4*t]=e,y[4*t+1]=n,y[4*t+2]=a,y[4*t+3]=255}w[t]=s(t),d[t]=p(t),g[t]=u(t)}return{position:l,intensity:f,returnNumber:h,numberOfReturns:m,classification:w,pointSourceID:d,color:y,scanAngle:g,origin:b}}set lazPerf(e){this._wasmPath=e,this._wasmPromise=null}async parseChunk(e,t){const{header:r,eb:n,pointCount:a}=t,{pointDataRecordFormat:s,pointDataRecordLength:p}=r,c=t.colorDepth??i(r),u=new Uint8Array(e),l=await o.Las.PointData.decompressChunk(u,{pointCount:a,pointDataRecordFormat:s,pointDataRecordLength:p},this._initDecoder()),f=o.Las.View.create(l,r,n);return{attributes:this._parseView(f,{colorDepth:c})}}async parseFile(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const r=new Uint8Array(e),n=await o.Las.PointData.decompressFile(r,this._initDecoder()),a=o.Las.Header.parse(r),s=t.colorDepth??i(a),p=async(e,t)=>r.slice(e,t),c=await o.Las.Vlr.walk(p,a),u=o.Las.Vlr.find(c,"LASF_Spec",4),l=u&&o.Las.ExtraBytes.parse(await o.Las.Vlr.fetch(p,u)),f=o.Las.View.create(n,a,l);return{header:a,attributes:this._parseView(f,{colorDepth:s})}}};function p(e){return Object.values(e).filter(ArrayBuffer.isView).map((e=>e.buffer))}(0,n.p)({lazPerf(e){s.lazPerf=e},async parseChunk(e,t){const r=await s.parseChunk(e,t);return(0,n.mr)(r,p(r.attributes))},async parseFile(e,t){const r=await s.parseFile(e,t);return(0,n.mr)(r,p(r.attributes))}})}},n={};function a(e){var t=n[e];if(void 0!==t)return t.exports;var o=n[e]={exports:{}};return r[e].call(o.exports,o,o.exports,a),o.exports}return a.m=r,a.x=()=>{var e=a.O(void 0,[455],(()=>a(56794)));return a.O(e)},e=[],a.O=(t,r,n,o)=>{if(!r){var i=1/0;for(u=0;u<e.length;u++){for(var[r,n,o]=e[u],s=!0,p=0;p<r.length;p++)(!1&o||i>=o)&&Object.keys(a.O).every((e=>a.O[e](r[p])))?r.splice(p--,1):(s=!1,o<i&&(i=o));if(s){e.splice(u--,1);var c=n();void 0!==c&&(t=c)}}return t}o=o||0;for(var u=e.length;u>0&&e[u-1][2]>o;u--)e[u]=e[u-1];e[u]=[r,n,o]},a.d=(e,t)=>{for(var r in t)a.o(t,r)&&!a.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},a.f={},a.e=e=>Promise.all(Object.keys(a.f).reduce(((t,r)=>(a.f[r](e,t),t)),[])),a.u=e=>e+".js",a.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),a.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),(()=>{var e;a.g.importScripts&&(e=a.g.location+"");var t=a.g.document;if(!e&&t&&(t.currentScript&&"SCRIPT"===t.currentScript.tagName.toUpperCase()&&(e=t.currentScript.src),!e)){var r=t.getElementsByTagName("script");if(r.length)for(var n=r.length-1;n>-1&&(!e||!/^http(s?):/.test(e));)e=r[n--].src}if(!e)throw new Error("Automatic publicPath is not supported in this browser");e=e.replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),a.p=e})(),(()=>{var e={899:1};a.f.i=(t,r)=>{e[t]||importScripts(a.p+a.u(t))};var t=self.webpackChunk=self.webpackChunk||[],r=t.push.bind(t);t.push=t=>{var[n,o,i]=t;for(var s in o)a.o(o,s)&&(a.m[s]=o[s]);for(i&&i(a);n.length;)e[n.pop()]=1;r(t)}})(),t=a.x,a.x=()=>a.e(455).then(t),a.x()})())); //# sourceMappingURL=itowns_lasparser.js.map