@geoscene/core 4.33.15 → 4.33.17

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.
@@ -1 +1 @@
1
- "use strict";(self.webpackChunkRemoteClient=self.webpackChunkRemoteClient||[]).push([[7087],{34727:(e,t,n)=>{n.d(t,{$8:()=>B,Cc:()=>s,Hx:()=>g,Io:()=>M,KJ:()=>u,Sp:()=>c,XM:()=>f,YN:()=>m,ZH:()=>d,cU:()=>a,gg:()=>h,hs:()=>l,kU:()=>o,or:()=>v,pF:()=>U,pq:()=>b,qE:()=>r});const i=new Float32Array(1);function a(e){--e;for(let t=1;t<32;t<<=1)e|=e>>t;return e+1}function r(e,t,n){return Math.min(Math.max(e,t),n)}function s(e,t,n){return e+(t-e)*n}function l(e,t,n,i,a){return s(i,a,(e-t)/(n-t))}function o(e){return e*Math.PI/180}function u(e){return 180*e/Math.PI}function f(e){return Math.acos(r(e,-1,1))}function m(e){return Math.asin(r(e,-1,1))}function c(e,t,n=1e-6){return e===t||!(!Number.isFinite(e)||!Number.isFinite(t))&&(e>t?e-t:t-e)<=n}function h(e,t,n=1e-6){return!c(e,t,n)&&e>t}function d(e,t,n=1e-6){return!c(e,t,n)&&e<t}function g(e,t,n=1e-6){return c(e,t,n)||e>t}const k=new DataView(new ArrayBuffer(Float64Array.BYTES_PER_ELEMENT));function x(e){return k.setFloat64(0,e),k.getBigInt64(0)}const p=BigInt("1000000"),w=y(1);function y(e){const t=x(e=Math.abs(e)),n=function(e){return k.setBigInt64(0,e),k.getFloat64(0)}(t<=p?p:t-p);return Math.abs(e-n)}function M(e,t,n=w){if(e===t)return!0;if(!Number.isFinite(e)||!Number.isFinite(t))return!1;if(null!=n&&y(Math.min(Math.abs(e),Math.abs(t)))<n)return Math.abs(e-t)<=n;const i=x(e),a=x(t);return i<0==a<0&&!((i<a?a-i:i-a)>p)}function B(e){return V(Math.max(-b,Math.min(e,b)))}function V(e){return i[0]=e,i[0]}function v(e){const t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=e[3]*e[3]+e[4]*e[4]+e[5]*e[5],i=e[6]*e[6]+e[7]*e[7]+e[8]*e[8];return!(c(t,1)&&c(n,1)&&c(i,1))}const b=V(34028234663852886e22);function U(e,t,n){if(void 0===n||0===+n)return Math[e](t);if(t=+t,n=+n,isNaN(t)||"number"!=typeof n||n%1!=0)return NaN;let i=t.toString().split("e");return i=(t=Math[e](+(i[0]+"e"+(i[1]?+i[1]-n:-n)))).toString().split("e"),+(i[0]+"e"+(i[1]?+i[1]+n:n))}},57087:(e,t,n)=>{n.r(t),n.d(t,{default:()=>c});var i=n(34727),a={};a.defaultNoDataValue=(0,i.$8)(-1/0),a.decode=function(e,t){var n=(t=t||{}).encodedMaskData||null===t.encodedMaskData,u=o(e,t.inputOffset||0,n),f=null!=t.noDataValue?(0,i.$8)(t.noDataValue):a.defaultNoDataValue,m=r(u,t.pixelType||Float32Array,t.encodedMaskData,f,t.returnMask),c={width:u.width,height:u.height,pixelData:m.resultPixels,minValue:u.pixels.minValue,maxValue:u.pixels.maxValue,noDataValue:f};return m.resultMask&&(c.maskData=m.resultMask),t.returnEncodedMask&&u.mask&&(c.encodedMaskData=u.mask.bitset?u.mask.bitset:null),t.returnFileInfo&&(c.fileInfo=s(u,f),t.computeUsedBitDepths&&(c.fileInfo.bitDepths=l(u))),c};var r=function(e,t,n,i,a){var r,s,l=0,o=e.pixels.numBlocksX,f=e.pixels.numBlocksY,m=Math.floor(e.width/o),c=Math.floor(e.height/f),h=2*e.maxZError;n=n||(e.mask?e.mask.bitset:null),r=new t(e.width*e.height),a&&n&&(s=new Uint8Array(e.width*e.height));for(var d,g,k=new Float32Array(m*c),x=0;x<=f;x++){var p=x!==f?c:e.height%f;if(0!==p)for(var w=0;w<=o;w++){var y=w!==o?m:e.width%o;if(0!==y){var M,B,V,v,b=x*e.width*c+w*m,U=e.width-y,D=e.pixels.blocks[l];if(D.encoding<2?(0===D.encoding?M=D.rawData:(u(D.stuffedData,D.bitsPerPixel,D.numValidPixels,D.offset,h,k,e.pixels.maxValue),M=k),B=0):V=2===D.encoding?0:D.offset,n)for(g=0;g<p;g++){for(7&b&&(v=n[b>>3],v<<=7&b),d=0;d<y;d++)7&b||(v=n[b>>3]),128&v?(s&&(s[b]=1),r[b++]=D.encoding<2?M[B++]:V):(s&&(s[b]=0),r[b++]=i),v<<=1;b+=U}else if(D.encoding<2)for(g=0;g<p;g++){for(d=0;d<y;d++)r[b++]=M[B++];b+=U}else for(g=0;g<p;g++)if(r.fill)r.fill(V,b,b+y),b+=y+U;else{for(d=0;d<y;d++)r[b++]=V;b+=U}if(1===D.encoding&&B!==D.numValidPixels)throw"Block and Mask do not match";l++}}}return{resultPixels:r,resultMask:s}},s=function(e,t){return{fileIdentifierString:e.fileIdentifierString,fileVersion:e.fileVersion,imageType:e.imageType,height:e.height,width:e.width,maxZError:e.maxZError,eofOffset:e.eofOffset,mask:e.mask?{numBlocksX:e.mask.numBlocksX,numBlocksY:e.mask.numBlocksY,numBytes:e.mask.numBytes,maxValue:e.mask.maxValue}:null,pixels:{numBlocksX:e.pixels.numBlocksX,numBlocksY:e.pixels.numBlocksY,numBytes:e.pixels.numBytes,maxValue:e.pixels.maxValue,minValue:e.pixels.minValue,noDataValue:t}}},l=function(e){for(var t=e.pixels.numBlocksX*e.pixels.numBlocksY,n={},i=0;i<t;i++){var a=e.pixels.blocks[i];0===a.encoding?n.float32=!0:1===a.encoding?n[a.bitsPerPixel]=!0:n[0]=!0}return Object.keys(n)},o=function(e,t,n){var i={},a=new Uint8Array(e,t,10);if(i.fileIdentifierString=String.fromCharCode.apply(null,a),"CntZImage"!=i.fileIdentifierString.trim())throw"Unexpected file identifier string: "+i.fileIdentifierString;t+=10;var r=new DataView(e,t,24);if(i.fileVersion=r.getInt32(0,!0),i.imageType=r.getInt32(4,!0),i.height=r.getUint32(8,!0),i.width=r.getUint32(12,!0),i.maxZError=r.getFloat64(16,!0),t+=24,!n)if(r=new DataView(e,t,16),i.mask={},i.mask.numBlocksY=r.getUint32(0,!0),i.mask.numBlocksX=r.getUint32(4,!0),i.mask.numBytes=r.getUint32(8,!0),i.mask.maxValue=r.getFloat32(12,!0),t+=16,i.mask.numBytes>0){var s=new Uint8Array(Math.ceil(i.width*i.height/8)),l=(r=new DataView(e,t,i.mask.numBytes)).getInt16(0,!0),o=2,u=0;do{if(l>0)for(;l--;)s[u++]=r.getUint8(o++);else{var f=r.getUint8(o++);for(l=-l;l--;)s[u++]=f}l=r.getInt16(o,!0),o+=2}while(o<i.mask.numBytes);if(-32768!==l||u<s.length)throw"Unexpected end of mask RLE encoding";i.mask.bitset=s,t+=i.mask.numBytes}else 0===(i.mask.numBytes|i.mask.numBlocksY|i.mask.maxValue)&&(s=new Uint8Array(Math.ceil(i.width*i.height/8)),i.mask.bitset=s);r=new DataView(e,t,16),i.pixels={},i.pixels.numBlocksY=r.getUint32(0,!0),i.pixels.numBlocksX=r.getUint32(4,!0),i.pixels.numBytes=r.getUint32(8,!0),i.pixels.maxValue=r.getFloat32(12,!0),t+=16;var m=i.pixels.numBlocksX,c=i.pixels.numBlocksY,h=m+(i.width%m>0?1:0),d=c+(i.height%c>0?1:0);i.pixels.blocks=new Array(h*d);for(var g=1e9,k=0,x=0;x<d;x++)for(var p=0;p<h;p++){var w=0,y=e.byteLength-t;r=new DataView(e,t,Math.min(10,y));var M={};i.pixels.blocks[k++]=M;var B=r.getUint8(0);if(w++,M.encoding=63&B,M.encoding>3)throw"Invalid block encoding ("+M.encoding+")";if(2!==M.encoding){if(0!==B&&2!==B){if(B>>=6,M.offsetType=B,2===B)M.offset=r.getInt8(1),w++;else if(1===B)M.offset=r.getInt16(1,!0),w+=2;else{if(0!==B)throw"Invalid block offset type";M.offset=r.getFloat32(1,!0),w+=4}if(g=Math.min(M.offset,g),1===M.encoding)if(B=r.getUint8(w),w++,M.bitsPerPixel=63&B,B>>=6,M.numValidPixelsType=B,2===B)M.numValidPixels=r.getUint8(w),w++;else if(1===B)M.numValidPixels=r.getUint16(w,!0),w+=2;else{if(0!==B)throw"Invalid valid pixel count type";M.numValidPixels=r.getUint32(w,!0),w+=4}}var V;if(t+=w,3!=M.encoding)if(0===M.encoding){var v=(i.pixels.numBytes-1)/4;if(v!==Math.floor(v))throw"uncompressed block has invalid length";V=new ArrayBuffer(4*v),new Uint8Array(V).set(new Uint8Array(e,t,4*v));for(var b=new Float32Array(V),U=0;U<b.length;U++)g=Math.min(g,b[U]);M.rawData=b,t+=4*v}else if(1===M.encoding){var D=Math.ceil(M.numValidPixels*M.bitsPerPixel/8),I=Math.ceil(D/4);V=new ArrayBuffer(4*I),new Uint8Array(V).set(new Uint8Array(e,t,D)),M.stuffedData=new Uint32Array(V),t+=D}}else t++,g=Math.min(g,0)}return i.pixels.minValue=g,i.eofOffset=t,i},u=function(e,t,n,i,a,r,s){var l,o,u,f=(1<<t)-1,m=0,c=0,h=Math.ceil((s-i)/a),d=4*e.length-Math.ceil(t*n/8);for(e[e.length-1]<<=8*d,l=0;l<n;l++){if(0===c&&(u=e[m++],c=32),c>=t)o=u>>>c-t&f,c-=t;else{var g=t-c;o=(u&f)<<g&f,o+=(u=e[m++])>>>(c=32-g)}r[l]=o<h?i+o*a:s}return r};const f=a.decode;class m{_decode(e){const t=f(e.buffer,e.options);return Promise.resolve({result:t,transferList:[t.pixelData.buffer]})}}function c(){return new m}}}]);
1
+ "use strict";(self.webpackChunkRemoteClient=self.webpackChunkRemoteClient||[]).push([[7087],{34727:(e,t,n)=>{n.d(t,{$8:()=>V,Cc:()=>l,Hx:()=>g,Io:()=>B,KJ:()=>u,Sp:()=>c,XM:()=>f,YN:()=>m,ZH:()=>d,cU:()=>a,gg:()=>h,hs:()=>s,kU:()=>o,or:()=>v,pF:()=>D,pq:()=>b,qE:()=>r});const i=new Float32Array(1);function a(e){--e;for(let t=1;t<32;t<<=1)e|=e>>t;return e+1}function r(e,t,n){return Math.min(Math.max(e,t),n)}function l(e,t,n){return e+(t-e)*n}function s(e,t,n,i,a){return l(i,a,(e-t)/(n-t))}function o(e){return e*Math.PI/180}function u(e){return 180*e/Math.PI}function f(e){return Math.acos(r(e,-1,1))}function m(e){return Math.asin(r(e,-1,1))}function c(e,t,n=1e-6){return e===t||!(!Number.isFinite(e)||!Number.isFinite(t))&&(e>t?e-t:t-e)<=n}function h(e,t,n=1e-6){return!c(e,t,n)&&e>t}function d(e,t,n=1e-6){return!c(e,t,n)&&e<t}function g(e,t,n=1e-6){return c(e,t,n)||e>t}const w=new DataView(new ArrayBuffer(Float64Array.BYTES_PER_ELEMENT));function k(e){return w.setFloat64(0,e),w.getBigInt64(0)}const x=BigInt("1000000"),p=y(1);function y(e){const t=k(e=Math.abs(e)),n=function(e){return w.setBigInt64(0,e),w.getFloat64(0)}(t<=x?x:t-x);return Math.abs(e-n)}function B(e,t,n=p){if(e===t)return!0;if(!Number.isFinite(e)||!Number.isFinite(t))return!1;if(null!=n&&y(Math.min(Math.abs(e),Math.abs(t)))<n)return Math.abs(e-t)<=n;const i=k(e),a=k(t);return i<0==a<0&&!((i<a?a-i:i-a)>x)}function V(e){return M(Math.max(-b,Math.min(e,b)))}function M(e){return i[0]=e,i[0]}function v(e){const t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=e[3]*e[3]+e[4]*e[4]+e[5]*e[5],i=e[6]*e[6]+e[7]*e[7]+e[8]*e[8];return!(c(t,1)&&c(n,1)&&c(i,1))}const b=M(34028234663852886e22);function D(e,t,n){if(void 0===n||0==+n)return Math[e](t);if(t=+t,n=+n,isNaN(t)||"number"!=typeof n||n%1!=0)return NaN;let i=t.toString().split("e");return i=(t=Math[e](+(i[0]+"e"+(i[1]?+i[1]-n:-n)))).toString().split("e"),+(i[0]+"e"+(i[1]?+i[1]+n:n))}},57087:(e,t,n)=>{n.r(t),n.d(t,{default:()=>h});var i=n(34727),a={};a.defaultNoDataValue=(0,i.$8)(-1/0),a.decode=async(e,t)=>{if(-1!==String.fromCharCode.apply(null,new Uint8Array(e,t.inputOffset||0,20)).indexOf("PNG")||-1!==String.fromCharCode.apply(null,new Uint8Array(e,t.inputOffset||0,20)).indexOf("WEBP"))h=await f(e,t);else{var n=(t=t||{}).encodedMaskData||null===t.encodedMaskData,u=o(e,t.inputOffset||0,n),m=null!=t.noDataValue?(0,i.$8)(t.noDataValue):a.defaultNoDataValue,c=r(u,t.pixelType||Float32Array,t.encodedMaskData,m,t.returnMask),h={width:u.width,height:u.height,pixelData:c.resultPixels,minValue:u.pixels.minValue,maxValue:u.pixels.maxValue,noDataValue:m};c.resultMask&&(h.maskData=c.resultMask),t.returnEncodedMask&&u.mask&&(h.encodedMaskData=u.mask.bitset?u.mask.bitset:null),t.returnFileInfo&&(h.fileInfo=l(u,m),t.computeUsedBitDepths&&(h.fileInfo.bitDepths=s(u)))}return h};var r=function(e,t,n,i,a){var r,l,s=0,o=e.pixels.numBlocksX,f=e.pixels.numBlocksY,m=Math.floor(e.width/o),c=Math.floor(e.height/f),h=2*e.maxZError;n=n||(e.mask?e.mask.bitset:null),r=new t(e.width*e.height),a&&n&&(l=new Uint8Array(e.width*e.height));for(var d,g,w=new Float32Array(m*c),k=0;k<=f;k++){var x=k!==f?c:e.height%f;if(0!==x)for(var p=0;p<=o;p++){var y=p!==o?m:e.width%o;if(0!==y){var B,V,M,v,b=k*e.width*c+p*m,D=e.width-y,U=e.pixels.blocks[s];if(U.encoding<2?(0===U.encoding?B=U.rawData:(u(U.stuffedData,U.bitsPerPixel,U.numValidPixels,U.offset,h,w,e.pixels.maxValue),B=w),V=0):M=2===U.encoding?0:U.offset,n)for(g=0;g<x;g++){for(7&b&&(v=n[b>>3],v<<=7&b),d=0;d<y;d++)7&b||(v=n[b>>3]),128&v?(l&&(l[b]=1),r[b++]=U.encoding<2?B[V++]:M):(l&&(l[b]=0),r[b++]=i),v<<=1;b+=D}else if(U.encoding<2)for(g=0;g<x;g++){for(d=0;d<y;d++)r[b++]=B[V++];b+=D}else for(g=0;g<x;g++)if(r.fill)r.fill(M,b,b+y),b+=y+D;else{for(d=0;d<y;d++)r[b++]=M;b+=D}if(1===U.encoding&&V!==U.numValidPixels)throw"Block and Mask do not match";s++}}}return{resultPixels:r,resultMask:l}},l=function(e,t){return{fileIdentifierString:e.fileIdentifierString,fileVersion:e.fileVersion,imageType:e.imageType,height:e.height,width:e.width,maxZError:e.maxZError,eofOffset:e.eofOffset,mask:e.mask?{numBlocksX:e.mask.numBlocksX,numBlocksY:e.mask.numBlocksY,numBytes:e.mask.numBytes,maxValue:e.mask.maxValue}:null,pixels:{numBlocksX:e.pixels.numBlocksX,numBlocksY:e.pixels.numBlocksY,numBytes:e.pixels.numBytes,maxValue:e.pixels.maxValue,minValue:e.pixels.minValue,noDataValue:t}}},s=function(e){for(var t=e.pixels.numBlocksX*e.pixels.numBlocksY,n={},i=0;i<t;i++){var a=e.pixels.blocks[i];0===a.encoding?n.float32=!0:1===a.encoding?n[a.bitsPerPixel]=!0:n[0]=!0}return Object.keys(n)},o=function(e,t,n){var i={},a=new Uint8Array(e,t,10);if(i.fileIdentifierString=String.fromCharCode.apply(null,a),"CntZImage"!=i.fileIdentifierString.trim())throw"Unexpected file identifier string: "+i.fileIdentifierString;t+=10;var r=new DataView(e,t,24);if(i.fileVersion=r.getInt32(0,!0),i.imageType=r.getInt32(4,!0),i.height=r.getUint32(8,!0),i.width=r.getUint32(12,!0),i.maxZError=r.getFloat64(16,!0),t+=24,!n)if(r=new DataView(e,t,16),i.mask={},i.mask.numBlocksY=r.getUint32(0,!0),i.mask.numBlocksX=r.getUint32(4,!0),i.mask.numBytes=r.getUint32(8,!0),i.mask.maxValue=r.getFloat32(12,!0),t+=16,i.mask.numBytes>0){var l=new Uint8Array(Math.ceil(i.width*i.height/8)),s=(r=new DataView(e,t,i.mask.numBytes)).getInt16(0,!0),o=2,u=0;do{if(s>0)for(;s--;)l[u++]=r.getUint8(o++);else{var f=r.getUint8(o++);for(s=-s;s--;)l[u++]=f}s=r.getInt16(o,!0),o+=2}while(o<i.mask.numBytes);if(-32768!==s||u<l.length)throw"Unexpected end of mask RLE encoding";i.mask.bitset=l,t+=i.mask.numBytes}else 0==(i.mask.numBytes|i.mask.numBlocksY|i.mask.maxValue)&&(l=new Uint8Array(Math.ceil(i.width*i.height/8)),i.mask.bitset=l);r=new DataView(e,t,16),i.pixels={},i.pixels.numBlocksY=r.getUint32(0,!0),i.pixels.numBlocksX=r.getUint32(4,!0),i.pixels.numBytes=r.getUint32(8,!0),i.pixels.maxValue=r.getFloat32(12,!0),t+=16;var m=i.pixels.numBlocksX,c=i.pixels.numBlocksY,h=m+(i.width%m>0?1:0),d=c+(i.height%c>0?1:0);i.pixels.blocks=new Array(h*d);for(var g=1e9,w=0,k=0;k<d;k++)for(var x=0;x<h;x++){var p=0,y=e.byteLength-t;r=new DataView(e,t,Math.min(10,y));var B={};i.pixels.blocks[w++]=B;var V=r.getUint8(0);if(p++,B.encoding=63&V,B.encoding>3)throw"Invalid block encoding ("+B.encoding+")";if(2!==B.encoding){if(0!==V&&2!==V){if(V>>=6,B.offsetType=V,2===V)B.offset=r.getInt8(1),p++;else if(1===V)B.offset=r.getInt16(1,!0),p+=2;else{if(0!==V)throw"Invalid block offset type";B.offset=r.getFloat32(1,!0),p+=4}if(g=Math.min(B.offset,g),1===B.encoding)if(V=r.getUint8(p),p++,B.bitsPerPixel=63&V,V>>=6,B.numValidPixelsType=V,2===V)B.numValidPixels=r.getUint8(p),p++;else if(1===V)B.numValidPixels=r.getUint16(p,!0),p+=2;else{if(0!==V)throw"Invalid valid pixel count type";B.numValidPixels=r.getUint32(p,!0),p+=4}}var M;if(t+=p,3!=B.encoding)if(0===B.encoding){var v=(i.pixels.numBytes-1)/4;if(v!==Math.floor(v))throw"uncompressed block has invalid length";M=new ArrayBuffer(4*v),new Uint8Array(M).set(new Uint8Array(e,t,4*v));for(var b=new Float32Array(M),D=0;D<b.length;D++)g=Math.min(g,b[D]);B.rawData=b,t+=4*v}else if(1===B.encoding){var U=Math.ceil(B.numValidPixels*B.bitsPerPixel/8),I=Math.ceil(U/4);M=new ArrayBuffer(4*I),new Uint8Array(M).set(new Uint8Array(e,t,U)),B.stuffedData=new Uint32Array(M),t+=U}}else t++,g=Math.min(g,0)}return i.pixels.minValue=g,i.eofOffset=t,i},u=function(e,t,n,i,a,r,l){var s,o,u,f=(1<<t)-1,m=0,c=0,h=Math.ceil((l-i)/a),d=4*e.length-Math.ceil(t*n/8);for(e[e.length-1]<<=8*d,s=0;s<n;s++){if(0===c&&(u=e[m++],c=32),c>=t)o=u>>>c-t&f,c-=t;else{var g=t-c;o=(u&f)<<g&f,o+=(u=e[m++])>>>(c=32-g)}r[s]=o<h?i+o*a:l}return r},f=async(e,t)=>{const n=new Blob([e]),i=await createImageBitmap(n),a=new OffscreenCanvas(i.width,i.height),r=a.width=i.width,l=a.height=i.height,s=a.getContext("2d",{willReadFrequently:!0});if(!s)throw new Error("无法获取2D上下文");s.drawImage(i,0,0);const o=s.getImageData(0,0,a.width,a.height).data;for(var u=new(t.pixelType||Float32Array)(r*l),f=1/0,m=-1/0,c=0;c<l;c++)for(var h=0;h<r;h++){var d=c*r+h,g=4*d,w=.1*(256*(t=o[g])*256+256*o[g+1]+o[g+2])-1e4;u[d]=w,w<f&&(f=w),w>m&&(m=w)}return f===1/0&&(f=0),m===-1/0&&(m=0),{width:r,height:l,pixelData:u,minValue:f,maxValue:m,noDataValue:t.noDataValue||t.defaultNoDataValue}};const m=a.decode;class c{_decode(e){return m(e.buffer,e.options).then((e=>Promise.resolve({result:e,transferList:[e.pixelData.buffer]})))}}function h(){return new c}}}]);
@@ -1 +1 @@
1
- import{_ as e}from"../chunks/tslib.es6.js";import r from"../request.js";import t from"../core/Error.js";import{loadAll as s}from"../core/loadAll.js";import{MultiOriginJSONMixin as i}from"../core/MultiOriginJSONSupport.js";import{throwIfAbortError as o}from"../core/promiseUtils.js";import{urlToObject as a,objectToQuery as l,makeAbsolute as n}from"../core/urlUtils.js";import{property as p}from"../core/accessorSupport/decorators/property.js";import{cast as c}from"../core/accessorSupport/decorators/cast.js";import"../core/has.js";import"../core/RandomLCG.js";import{reader as u}from"../core/accessorSupport/decorators/reader.js";import{subclass as m}from"../core/accessorSupport/decorators/subclass.js";import{writer as h}from"../core/accessorSupport/decorators/writer.js";import d from"../geometry/SpatialReference.js";import y from"./Layer.js";import{APIKeyMixin as f}from"./mixins/APIKeyMixin.js";import{ArcGISCachedService as v}from"./mixins/ArcGISCachedService.js";import{ArcGISMapService as g}from"./mixins/ArcGISMapService.js";import{ArcGISService as S}from"./mixins/ArcGISService.js";import{BlendLayer as _}from"./mixins/BlendLayer.js";import{CustomParametersMixin as j}from"./mixins/CustomParametersMixin.js";import{OperationalLayer as b}from"./mixins/OperationalLayer.js";import{PortalLayer as T}from"./mixins/PortalLayer.js";import{RefreshableLayer as w}from"./mixins/RefreshableLayer.js";import{ScaleRangeLayer as O}from"./mixins/ScaleRangeLayer.js";import{SublayersOwner as L}from"./mixins/SublayersOwner.js";import{parse as R,isHostedAgolService as U,isArcGISUrl as P}from"./support/arcgisLayerUrl.js";import{url as x}from"./support/commonProperties.js";import{createTileBitmap as A}from"./support/imageBitmapUtils.js";import I from"./support/Sublayer.js";import Z from"../layers/MapImageLayer.js";import Y from"../geometry/Extent.js";import*as Q from"../core/reactiveUtils.js";import M from"../symbols/support/ElevationInfo.js";var W;const B=["Canvas/World_Dark_Gray_Base","Canvas/World_Dark_Gray_Reference","Canvas/World_Light_Gray_Base","Canvas/World_Light_Gray_Reference","Elevation/World_Hillshade","Elevation/World_Hillshade_Dark","Ocean/World_Ocean_Base","Ocean/World_Ocean_Reference","Ocean_Basemap","Reference/World_Boundaries_and_Places","Reference/World_Boundaries_and_Places_Alternate","Reference/World_Transportation","World_Imagery","World_Street_Map","World_Topo_Map"];let C=W=class extends(_(O(L(v(g(b(T(S(i(w(f(j(y))))))))))))){constructor(...e){super(...e),this.listMode="show",this.elevationInfo=new M({mode:"on-the-ground"}),this.isReference=null,this.operationalLayerType="ArcGISMapServiceTileLayer",this.resampling=!0,this.sourceJSON=null,this.spatialReference=null,this.path=null,this.sublayers=null,this.type="base-tile",this.__init_error_info={title:`Failed to create layerview for layer title:'${this.title}', id: '${this.id}' of type '${this.type}'.`,name:"tilingscheme:tile-info-missing_or_invalid",message:"Tiling scheme must have valid tiling information",details:["方法一:先在 Map 组件上加载一个 TileLayer 类型的地图服务图层,从而获取到这个图层的 spatialReference,fullExtent 和 tileInfo 属性值",`方法二:直接对这个${this.declaredClass}类型的图层的 spatialReference,fullExtent 和 tileInfo 属性进行赋值`]},this.url=e[0]?.url,this.url?(this._coreLayer=new Z({url:this.url}),this._coreLayer.load()):this._coreLayer=new Z,e[0]&&Object.keys(e[0]).forEach((r=>{this._coreLayer[r]=e[0][r]}))}normalizeCtorArgs(e,r){return"string"==typeof e?{url:e,...r}:e}normalizeCtorArgs(e,r){return"string"==typeof e?{url:e,...r}:e}load(e){this._coreLayer.url=this.url,this._coreLayer.url&&this._coreLayer.load().then((e=>{var r=this;Q.whenOnce((()=>r.parent.allLayers.find((e=>{const t="base-tile"!=e.type&&1==e.loaded;return t&&(r.firstLayer=e),t})))).then((()=>{try{r.firstLayer?.spatialReference&&r.firstLayer?.fullExtent&&r.firstLayer?.tileInfo?(r.spatialReference=r.firstLayer.spatialReference,r.fullExtent=r.firstLayer.fullExtent,r.tileInfo=r.firstLayer.tileInfo):r._throwMapLoadError()}catch(e){r._showMapLoadError(e)}})),Q.whenOnce((()=>e.loaded)).then((()=>{r.sublayers=e.sublayers}))}));const r=null!=e?e.signal:null;return this.addResolvingPromise(this.loadFromPortal({supportedTypes:["Map Service"]},e).catch(o).then((()=>this._fetchService(r)))),Promise.resolve(this)}get attributionDataUrl(){const e=this.parsedUrl?.path.toLowerCase();return e?this._getDefaultAttribution(this._getMapName(e)):null}readSpatialReference(e,r){return(e=e||r.tileInfo?.spatialReference)&&d.fromJSON(e)}writeSublayers(e,r,t,i){if(!this.loaded||!e)return;const s=e.slice().reverse().flatten((({sublayers:e})=>e&&e.toArray().reverse())).toArray(),o=[],a={writeSublayerStructure:!1,...i};s.forEach((e=>{const r=e.write({},a);o.push(r)})),o.some((e=>Object.keys(e).length>1))&&(r.layers=o)}get tileServers(){return this._getDefaultTileServers(this.parsedUrl?.path)}castTileServers(e){return Array.isArray(e)?e.map((e=>a(e).path)):null}fetchTile(e,r,t,i={}){return this.getTileImage(e,r,t,i)}async fetchImageBitmapTile(e,r,t,i={}){const{signal:s}=i,o=await this.getTileImage(e,r,t,i);return A(o,e,r,t,s)}getTileImage(e,r,t,i={}){const s=this.tileInfo.origin.x+t*this.tileInfo.lods[e].resolution*this.tileInfo.size[0],o=this.tileInfo.origin.y-r*this.tileInfo.lods[e].resolution*this.tileInfo.size[1],a=this.tileInfo.origin.x+(t+1)*this.tileInfo.lods[e].resolution*this.tileInfo.size[0],l=this.tileInfo.origin.y-(r+1)*this.tileInfo.lods[e].resolution*this.tileInfo.size[1],n=new Y({xmin:s,ymin:l,xmax:a,ymax:o,spatialReference:this.spatialReference});return this._coreLayer.fetchImage(n,this.tileInfo.size[0],this.tileInfo.size[1],i)}getTileUrl(e,r,t){const i=!this.capabilities.operations.supportsTileMap&&this.supportsBlankTile,s=l({...this.parsedUrl?.query,blankTile:!i&&null,...this.customParameters,token:this.apiKey}),o=this.tileServers;return`${o&&o.length?o[r%o.length]:this.parsedUrl?.path}/tile/${e}/${r}/${t}${s?"?"+s:""}`}loadAll(){return s(this,(e=>{e(this.allSublayers)}))}_fetchService(e){return new Promise(((i,s)=>{if(this.sourceJSON){if(null!=this.sourceJSON.bandCount&&null!=this.sourceJSON.pixelSizeX)throw new t("tile-layer:unsupported-url","use ImageryTileLayer to open a tiled image service");return void i({data:this.sourceJSON})}if(!this.parsedUrl)throw new t("tile-layer:undefined-url","layer's url is not defined");const o=R(this.parsedUrl.path);if(null!=o&&"ImageServer"===o.serverType)throw new t("tile-layer:unsupported-url","use ImageryTileLayer to open a tiled image service");r(this.parsedUrl.path,{query:{f:"json",...this.parsedUrl.query,...this.customParameters,token:this.apiKey},responseType:"json",signal:e}).then(i,s)})).then((r=>{let t=this.url;if(r.ssl&&(t=this.url=t.replace(/^http:/i,"https:")),this.sourceJSON=r.data,this.read(r.data,{origin:"service",url:this.parsedUrl}),10.1===this.version&&!U(t))return this._fetchServerVersion(t,e).then((e=>{this.read({currentVersion:e})})).catch((()=>{}))}))}_fetchServerVersion(e,i){if(!P(e))return Promise.reject();const s=e.replace(/(.*\/rest)\/.*/i,"$1")+"/info";return r(s,{query:{f:"json",...this.customParameters,token:this.apiKey},responseType:"json",signal:i}).then((e=>{if(e.data?.currentVersion)return e.data.currentVersion;throw new t("tile-layer:version-not-available","Server did not provide a version")}))}_getMapName(e){}_getDefaultAttribution(e){return null}_getDefaultTileServers(e){return[]}get hasOverriddenFetchTile(){return!this.fetchTile[N]}_throwMapLoadError(){throw new t(this.__init_error_info.name,this.__init_error_info.message,this.__init_error_info.details)}_showMapLoadError(e){}findSublayerById(e){return this._coreLayer?.findSublayerById(e)}createExportImageParameters(e,r,t,i){return this._coreLayer?.createExportImageParameters(e,r,t,i)}findSublayerByTitle(e){return this._coreLayer?.allSublayers.items.find((r=>r.title===e))}};e([p({readOnly:!0})],C.prototype,"attributionDataUrl",null),e([p({type:["show","hide","hide-children"]})],C.prototype,"listMode",void 0),e([p({json:{read:!0,write:!0}})],C.prototype,"blendMode",void 0),e([p()],C.prototype,"elevationInfo",void 0),e([p({type:Boolean,json:{read:!1,write:{enabled:!0,overridePolicy:()=>({enabled:!1})}}})],C.prototype,"isReference",void 0),e([p({readOnly:!0,type:["ArcGISMapServiceTileLayer"]})],C.prototype,"operationalLayerType",void 0),e([p({type:Boolean})],C.prototype,"resampling",void 0),e([p()],C.prototype,"sourceJSON",void 0),e([p({type:d})],C.prototype,"spatialReference",void 0),e([u("spatialReference",["spatialReference","tileInfo"])],C.prototype,"readSpatialReference",null),e([p({type:String,json:{origins:{"web-scene":{read:!0,write:!0}},read:!1}})],C.prototype,"path",void 0),e([p()],C.prototype,"sublayers",void 0),e([h("sublayers",{layers:{type:[I]}})],C.prototype,"writeSublayers",null),e([p({json:{read:!1,write:!1}})],C.prototype,"popupEnabled",void 0),e([p()],C.prototype,"tileServers",null),e([c("tileServers")],C.prototype,"castTileServers",null),e([p({readOnly:!0,json:{read:!1}})],C.prototype,"type",void 0),e([p(x)],C.prototype,"url",void 0),C=W=e([m("geoscene.layers.MapImageTileLayer")],C);const N=Symbol("default-fetch-tile");C.prototype.fetchTile[N]=!1;const k=C;export{k as default};
1
+ import{_ as e}from"../chunks/tslib.es6.js";import r from"../request.js";import t from"../core/Error.js";import{loadAll as s}from"../core/loadAll.js";import{MultiOriginJSONMixin as i}from"../core/MultiOriginJSONSupport.js";import{throwIfAbortError as o}from"../core/promiseUtils.js";import{urlToObject as a,objectToQuery as l,makeAbsolute as n}from"../core/urlUtils.js";import{property as p}from"../core/accessorSupport/decorators/property.js";import{cast as c}from"../core/accessorSupport/decorators/cast.js";import"../core/has.js";import"../core/RandomLCG.js";import{reader as u}from"../core/accessorSupport/decorators/reader.js";import{subclass as m}from"../core/accessorSupport/decorators/subclass.js";import{writer as h}from"../core/accessorSupport/decorators/writer.js";import d from"../geometry/SpatialReference.js";import y from"./Layer.js";import{APIKeyMixin as f}from"./mixins/APIKeyMixin.js";import{ArcGISCachedService as v}from"./mixins/ArcGISCachedService.js";import{ArcGISMapService as g}from"./mixins/ArcGISMapService.js";import{ArcGISService as S}from"./mixins/ArcGISService.js";import{BlendLayer as _}from"./mixins/BlendLayer.js";import{CustomParametersMixin as j}from"./mixins/CustomParametersMixin.js";import{OperationalLayer as b}from"./mixins/OperationalLayer.js";import{PortalLayer as T}from"./mixins/PortalLayer.js";import{RefreshableLayer as w}from"./mixins/RefreshableLayer.js";import{ScaleRangeLayer as O}from"./mixins/ScaleRangeLayer.js";import{SublayersOwner as L}from"./mixins/SublayersOwner.js";import{parse as R,isHostedAgolService as U,isArcGISUrl as P}from"./support/arcgisLayerUrl.js";import{url as x}from"./support/commonProperties.js";import{createTileBitmap as A}from"./support/imageBitmapUtils.js";import I from"./support/Sublayer.js";import Z from"../layers/MapImageLayer.js";import Y from"../geometry/Extent.js";import*as Q from"../core/reactiveUtils.js";import M from"../symbols/support/ElevationInfo.js";var W;const B=["Canvas/World_Dark_Gray_Base","Canvas/World_Dark_Gray_Reference","Canvas/World_Light_Gray_Base","Canvas/World_Light_Gray_Reference","Elevation/World_Hillshade","Elevation/World_Hillshade_Dark","Ocean/World_Ocean_Base","Ocean/World_Ocean_Reference","Ocean_Basemap","Reference/World_Boundaries_and_Places","Reference/World_Boundaries_and_Places_Alternate","Reference/World_Transportation","World_Imagery","World_Street_Map","World_Topo_Map"];let C=W=class extends(_(O(L(v(g(b(T(S(i(w(f(j(y))))))))))))){constructor(...e){super(...e),this.listMode="show",this.elevationInfo=new M({mode:"on-the-ground"}),this.isReference=null,this.operationalLayerType="ArcGISMapServiceTileLayer",this.resampling=!0,this.sourceJSON=null,this.spatialReference=null,this.path=null,this.sublayers=null,this.type="base-tile",this.__init_error_info={title:`Failed to create layerview for layer title:'${this.title}', id: '${this.id}' of type '${this.type}'.`,name:"tilingscheme:tile-info-missing_or_invalid",message:"Tiling scheme must have valid tiling information",details:["方法一:先在 Map 组件上加载一个 TileLayer 类型的地图服务图层,从而获取到这个图层的 spatialReference,fullExtent 和 tileInfo 属性值",`方法二:直接对这个${this.declaredClass}类型的图层的 spatialReference,fullExtent 和 tileInfo 属性进行赋值`]},this.url=e[0]?.url,this.url?(this._coreLayer=new Z({url:this.url}),this._coreLayer.load()):this._coreLayer=new Z,e[0]&&Object.keys(e[0]).forEach((r=>{this._coreLayer[r]=e[0][r]}))}normalizeCtorArgs(e,r){return"string"==typeof e?{url:e,...r}:e}normalizeCtorArgs(e,r){return"string"==typeof e?{url:e,...r}:e}load(e){const r=null!=e?e.signal:null;return this.addResolvingPromise(this.loadFromPortal({supportedTypes:["Map Service"]},e).catch(o).then((()=>this._fetchService(r)))),this._coreLayer.url||(this._coreLayer.url=this.url,this._coreLayer.load()),Q.whenOnce((()=>this.parent.allLayers.find((e=>{const r="base-tile"!=e.type&&1==e.loaded;return r&&(this.firstLayer=e),r})))).then((()=>{try{this.firstLayer?.spatialReference&&this.firstLayer?.fullExtent&&this.firstLayer?.tileInfo?(this.spatialReference=this.firstLayer.spatialReference,this.fullExtent=this.firstLayer.fullExtent,this.tileInfo=this.firstLayer.tileInfo):this._throwMapLoadError()}catch(e){this._showMapLoadError(e)}})),Q.whenOnce((()=>this._coreLayer.loaded)).then((()=>{this.sublayers=this._coreLayer.sublayers})),Promise.resolve(this)}get attributionDataUrl(){const e=this.parsedUrl?.path.toLowerCase();return e?this._getDefaultAttribution(this._getMapName(e)):null}readSpatialReference(e,r){return(e=e||r.tileInfo?.spatialReference)&&d.fromJSON(e)}writeSublayers(e,r,t,i){if(!this.loaded||!e)return;const s=e.slice().reverse().flatten((({sublayers:e})=>e&&e.toArray().reverse())).toArray(),o=[],a={writeSublayerStructure:!1,...i};s.forEach((e=>{const r=e.write({},a);o.push(r)})),o.some((e=>Object.keys(e).length>1))&&(r.layers=o)}get tileServers(){return this._getDefaultTileServers(this.parsedUrl?.path)}castTileServers(e){return Array.isArray(e)?e.map((e=>a(e).path)):null}fetchTile(e,r,t,i={}){return this.getTileImage(e,r,t,i)}async fetchImageBitmapTile(e,r,t,i={}){const{signal:s}=i,o=await this.getTileImage(e,r,t,i);return A(o,e,r,t,s)}getTileImage(e,r,t,i={}){const s=this.tileInfo.origin.x+t*this.tileInfo.lods[e].resolution*this.tileInfo.size[0],o=this.tileInfo.origin.y-r*this.tileInfo.lods[e].resolution*this.tileInfo.size[1],a=this.tileInfo.origin.x+(t+1)*this.tileInfo.lods[e].resolution*this.tileInfo.size[0],l=this.tileInfo.origin.y-(r+1)*this.tileInfo.lods[e].resolution*this.tileInfo.size[1],n=new Y({xmin:s,ymin:l,xmax:a,ymax:o,spatialReference:this.spatialReference});return this._coreLayer.fetchImage(n,this.tileInfo.size[0],this.tileInfo.size[1],i)}getTileUrl(e,r,t){const i=!this.capabilities.operations.supportsTileMap&&this.supportsBlankTile,s=l({...this.parsedUrl?.query,blankTile:!i&&null,...this.customParameters,token:this.apiKey}),o=this.tileServers;return`${o&&o.length?o[r%o.length]:this.parsedUrl?.path}/tile/${e}/${r}/${t}${s?"?"+s:""}`}loadAll(){return s(this,(e=>{e(this.allSublayers)}))}_fetchService(e){return new Promise(((i,s)=>{if(this.sourceJSON){if(null!=this.sourceJSON.bandCount&&null!=this.sourceJSON.pixelSizeX)throw new t("tile-layer:unsupported-url","use ImageryTileLayer to open a tiled image service");return void i({data:this.sourceJSON})}if(!this.parsedUrl)throw new t("tile-layer:undefined-url","layer's url is not defined");const o=R(this.parsedUrl.path);if(null!=o&&"ImageServer"===o.serverType)throw new t("tile-layer:unsupported-url","use ImageryTileLayer to open a tiled image service");r(this.parsedUrl.path,{query:{f:"json",...this.parsedUrl.query,...this.customParameters,token:this.apiKey},responseType:"json",signal:e}).then(i,s)})).then((r=>{let t=this.url;if(r.ssl&&(t=this.url=t.replace(/^http:/i,"https:")),this.sourceJSON=r.data,this.read(r.data,{origin:"service",url:this.parsedUrl}),10.1===this.version&&!U(t))return this._fetchServerVersion(t,e).then((e=>{this.read({currentVersion:e})})).catch((()=>{}))}))}_fetchServerVersion(e,i){if(!P(e))return Promise.reject();const s=e.replace(/(.*\/rest)\/.*/i,"$1")+"/info";return r(s,{query:{f:"json",...this.customParameters,token:this.apiKey},responseType:"json",signal:i}).then((e=>{if(e.data?.currentVersion)return e.data.currentVersion;throw new t("tile-layer:version-not-available","Server did not provide a version")}))}_getMapName(e){}_getDefaultAttribution(e){return null}_getDefaultTileServers(e){return[]}get hasOverriddenFetchTile(){return!this.fetchTile[N]}_throwMapLoadError(){throw new t(this.__init_error_info.name,this.__init_error_info.message,this.__init_error_info.details)}_showMapLoadError(e){}findSublayerById(e){return this._coreLayer?.findSublayerById(e)}createExportImageParameters(e,r,t,i){return this._coreLayer?.createExportImageParameters(e,r,t,i)}findSublayerByTitle(e){return this._coreLayer?.allSublayers.items.find((r=>r.title===e))}};e([p({readOnly:!0})],C.prototype,"attributionDataUrl",null),e([p({type:["show","hide","hide-children"]})],C.prototype,"listMode",void 0),e([p({json:{read:!0,write:!0}})],C.prototype,"blendMode",void 0),e([p()],C.prototype,"elevationInfo",void 0),e([p({type:Boolean,json:{read:!1,write:{enabled:!0,overridePolicy:()=>({enabled:!1})}}})],C.prototype,"isReference",void 0),e([p({readOnly:!0,type:["ArcGISMapServiceTileLayer"]})],C.prototype,"operationalLayerType",void 0),e([p({type:Boolean})],C.prototype,"resampling",void 0),e([p()],C.prototype,"sourceJSON",void 0),e([p({type:d})],C.prototype,"spatialReference",void 0),e([u("spatialReference",["spatialReference","tileInfo"])],C.prototype,"readSpatialReference",null),e([p({type:String,json:{origins:{"web-scene":{read:!0,write:!0}},read:!1}})],C.prototype,"path",void 0),e([p()],C.prototype,"sublayers",void 0),e([h("sublayers",{layers:{type:[I]}})],C.prototype,"writeSublayers",null),e([p({json:{read:!1,write:!1}})],C.prototype,"popupEnabled",void 0),e([p()],C.prototype,"tileServers",null),e([c("tileServers")],C.prototype,"castTileServers",null),e([p({readOnly:!0,json:{read:!1}})],C.prototype,"type",void 0),e([p(x)],C.prototype,"url",void 0),C=W=e([m("geoscene.layers.MapImageTileLayer")],C);const N=Symbol("default-fetch-tile");C.prototype.fetchTile[N]=!1;const k=C;export{k as default};
@@ -1,5 +1 @@
1
- /*
2
- All material copyright GeoScene, All Rights Reserved, unless otherwise specified.
3
- See https://js.geoscene.cn/4.33/geoscene/copyright.txt for details.
4
- */
5
- import{clampFloat32 as e}from"../../core/mathUtils.js";var t={};t.defaultNoDataValue=e(-1/0),t.decode=function(s,r){var o=(r=r||{}).encodedMaskData||null===r.encodedMaskData,f=l(s,r.inputOffset||0,o),u=null!=r.noDataValue?e(r.noDataValue):t.defaultNoDataValue,m=i(f,r.pixelType||Float32Array,r.encodedMaskData,u,r.returnMask),d={width:f.width,height:f.height,pixelData:m.resultPixels,minValue:f.pixels.minValue,maxValue:f.pixels.maxValue,noDataValue:u};return m.resultMask&&(d.maskData=m.resultMask),r.returnEncodedMask&&f.mask&&(d.encodedMaskData=f.mask.bitset?f.mask.bitset:null),r.returnFileInfo&&(d.fileInfo=n(f,u),r.computeUsedBitDepths&&(d.fileInfo.bitDepths=a(f))),d};var i=function(e,t,i,n,a){var l,r,o=0,f=e.pixels.numBlocksX,u=e.pixels.numBlocksY,m=Math.floor(e.width/f),d=Math.floor(e.height/u),c=2*e.maxZError;i=i||(e.mask?e.mask.bitset:null),l=new t(e.width*e.height),a&&i&&(r=new Uint8Array(e.width*e.height));for(var g,h,k=new Float32Array(m*d),x=0;x<=u;x++){var p=x!==u?d:e.height%u;if(0!==p)for(var w=0;w<=f;w++){var y=w!==f?m:e.width%f;if(0!==y){var V,B,v,U,D=x*e.width*d+w*m,M=e.width-y,b=e.pixels.blocks[o];if(b.encoding<2?(0===b.encoding?V=b.rawData:(s(b.stuffedData,b.bitsPerPixel,b.numValidPixels,b.offset,c,k,e.pixels.maxValue),V=k),B=0):v=2===b.encoding?0:b.offset,i)for(h=0;h<p;h++){for(7&D&&(U=i[D>>3],U<<=7&D),g=0;g<y;g++)7&D||(U=i[D>>3]),128&U?(r&&(r[D]=1),l[D++]=b.encoding<2?V[B++]:v):(r&&(r[D]=0),l[D++]=n),U<<=1;D+=M}else if(b.encoding<2)for(h=0;h<p;h++){for(g=0;g<y;g++)l[D++]=V[B++];D+=M}else for(h=0;h<p;h++)if(l.fill)l.fill(v,D,D+y),D+=y+M;else{for(g=0;g<y;g++)l[D++]=v;D+=M}if(1===b.encoding&&B!==b.numValidPixels)throw"Block and Mask do not match";o++}}}return{resultPixels:l,resultMask:r}},n=function(e,t){return{fileIdentifierString:e.fileIdentifierString,fileVersion:e.fileVersion,imageType:e.imageType,height:e.height,width:e.width,maxZError:e.maxZError,eofOffset:e.eofOffset,mask:e.mask?{numBlocksX:e.mask.numBlocksX,numBlocksY:e.mask.numBlocksY,numBytes:e.mask.numBytes,maxValue:e.mask.maxValue}:null,pixels:{numBlocksX:e.pixels.numBlocksX,numBlocksY:e.pixels.numBlocksY,numBytes:e.pixels.numBytes,maxValue:e.pixels.maxValue,minValue:e.pixels.minValue,noDataValue:t}}},a=function(e){for(var t=e.pixels.numBlocksX*e.pixels.numBlocksY,i={},n=0;n<t;n++){var a=e.pixels.blocks[n];0===a.encoding?i.float32=!0:1===a.encoding?i[a.bitsPerPixel]=!0:i[0]=!0}return Object.keys(i)},l=function(e,t,i){var n={},a=new Uint8Array(e,t,10);if(n.fileIdentifierString=String.fromCharCode.apply(null,a),"CntZImage"!=n.fileIdentifierString.trim())throw"Unexpected file identifier string: "+n.fileIdentifierString;t+=10;var l=new DataView(e,t,24);if(n.fileVersion=l.getInt32(0,!0),n.imageType=l.getInt32(4,!0),n.height=l.getUint32(8,!0),n.width=l.getUint32(12,!0),n.maxZError=l.getFloat64(16,!0),t+=24,!i)if(l=new DataView(e,t,16),n.mask={},n.mask.numBlocksY=l.getUint32(0,!0),n.mask.numBlocksX=l.getUint32(4,!0),n.mask.numBytes=l.getUint32(8,!0),n.mask.maxValue=l.getFloat32(12,!0),t+=16,n.mask.numBytes>0){var s=new Uint8Array(Math.ceil(n.width*n.height/8)),r=(l=new DataView(e,t,n.mask.numBytes)).getInt16(0,!0),o=2,f=0;do{if(r>0)for(;r--;)s[f++]=l.getUint8(o++);else{var u=l.getUint8(o++);for(r=-r;r--;)s[f++]=u}r=l.getInt16(o,!0),o+=2}while(o<n.mask.numBytes);if(-32768!==r||f<s.length)throw"Unexpected end of mask RLE encoding";n.mask.bitset=s,t+=n.mask.numBytes}else if(0===(n.mask.numBytes|n.mask.numBlocksY|n.mask.maxValue)){s=new Uint8Array(Math.ceil(n.width*n.height/8));n.mask.bitset=s}l=new DataView(e,t,16),n.pixels={},n.pixels.numBlocksY=l.getUint32(0,!0),n.pixels.numBlocksX=l.getUint32(4,!0),n.pixels.numBytes=l.getUint32(8,!0),n.pixels.maxValue=l.getFloat32(12,!0),t+=16;var m=n.pixels.numBlocksX,d=n.pixels.numBlocksY,c=m+(n.width%m>0?1:0),g=d+(n.height%d>0?1:0);n.pixels.blocks=new Array(c*g);for(var h=1e9,k=0,x=0;x<g;x++)for(var p=0;p<c;p++){var w=0,y=e.byteLength-t;l=new DataView(e,t,Math.min(10,y));var V={};n.pixels.blocks[k++]=V;var B=l.getUint8(0);if(w++,V.encoding=63&B,V.encoding>3)throw"Invalid block encoding ("+V.encoding+")";if(2!==V.encoding){if(0!==B&&2!==B){if(B>>=6,V.offsetType=B,2===B)V.offset=l.getInt8(1),w++;else if(1===B)V.offset=l.getInt16(1,!0),w+=2;else{if(0!==B)throw"Invalid block offset type";V.offset=l.getFloat32(1,!0),w+=4}if(h=Math.min(V.offset,h),1===V.encoding)if(B=l.getUint8(w),w++,V.bitsPerPixel=63&B,B>>=6,V.numValidPixelsType=B,2===B)V.numValidPixels=l.getUint8(w),w++;else if(1===B)V.numValidPixels=l.getUint16(w,!0),w+=2;else{if(0!==B)throw"Invalid valid pixel count type";V.numValidPixels=l.getUint32(w,!0),w+=4}}var v;if(t+=w,3!=V.encoding)if(0===V.encoding){var U=(n.pixels.numBytes-1)/4;if(U!==Math.floor(U))throw"uncompressed block has invalid length";v=new ArrayBuffer(4*U),new Uint8Array(v).set(new Uint8Array(e,t,4*U));for(var D=new Float32Array(v),M=0;M<D.length;M++)h=Math.min(h,D[M]);V.rawData=D,t+=4*U}else if(1===V.encoding){var b=Math.ceil(V.numValidPixels*V.bitsPerPixel/8),I=Math.ceil(b/4);v=new ArrayBuffer(4*I),new Uint8Array(v).set(new Uint8Array(e,t,b)),V.stuffedData=new Uint32Array(v),t+=b}}else t++,h=Math.min(h,0)}return n.pixels.minValue=h,n.eofOffset=t,n},s=function(e,t,i,n,a,l,s){var r,o,f,u=(1<<t)-1,m=0,d=0,c=Math.ceil((s-n)/a),g=4*e.length-Math.ceil(t*i/8);for(e[e.length-1]<<=8*g,r=0;r<i;r++){if(0===d&&(f=e[m++],d=32),d>=t)o=f>>>d-t&u,d-=t;else{var h=t-d;o=(f&u)<<h&u,o+=(f=e[m++])>>>(d=32-h)}l[r]=o<c?n+o*a:s}return l};const r=t.decode;class o{_decode(e){const t=r(e.buffer,e.options);return Promise.resolve({result:t,transferList:[t.pixelData.buffer]})}}function f(){return new o}export{f as default};
1
+ import{clampFloat32 as e}from"../../core/mathUtils.js";var t={};t.defaultNoDataValue=e(-1/0),t.decode=async(r,s)=>{if(-1!==String.fromCharCode.apply(null,new Uint8Array(r,s.inputOffset||0,20)).indexOf("PNG")||-1!==String.fromCharCode.apply(null,new Uint8Array(r,s.inputOffset||0,20)).indexOf("WEBP"))d=await decodeTerrainRGB(r,s);else{var o=(s=s||{}).encodedMaskData||null===s.encodedMaskData,f=l(r,s.inputOffset||0,o),u=null!=s.noDataValue?e(s.noDataValue):t.defaultNoDataValue,m=i(f,s.pixelType||Float32Array,s.encodedMaskData,u,s.returnMask),d={width:f.width,height:f.height,pixelData:m.resultPixels,minValue:f.pixels.minValue,maxValue:f.pixels.maxValue,noDataValue:u};m.resultMask&&(d.maskData=m.resultMask),s.returnEncodedMask&&f.mask&&(d.encodedMaskData=f.mask.bitset?f.mask.bitset:null),s.returnFileInfo&&(d.fileInfo=n(f,u),s.computeUsedBitDepths&&(d.fileInfo.bitDepths=a(f)))}return d};var i=function(e,t,i,a,n){var l,r,o=0,f=e.pixels.numBlocksX,u=e.pixels.numBlocksY,m=Math.floor(e.width/f),d=Math.floor(e.height/u),h=2*e.maxZError;i=i||(e.mask?e.mask.bitset:null),l=new t(e.width*e.height),n&&i&&(r=new Uint8Array(e.width*e.height));for(var c,g,w=new Float32Array(m*d),x=0;x<=u;x++){var k=x!==u?d:e.height%u;if(0!==k)for(var p=0;p<=f;p++){var y=p!==f?m:e.width%f;if(0!==y){var V,B,v,D,U=x*e.width*d+p*m,M=e.width-y,b=e.pixels.blocks[o];if(b.encoding<2?(0===b.encoding?V=b.rawData:(s(b.stuffedData,b.bitsPerPixel,b.numValidPixels,b.offset,h,w,e.pixels.maxValue),V=w),B=0):v=2===b.encoding?0:b.offset,i)for(g=0;g<k;g++){for(7&U&&(D=i[U>>3],D<<=7&U),c=0;c<y;c++)7&U||(D=i[U>>3]),128&D?(r&&(r[U]=1),l[U++]=b.encoding<2?V[B++]:v):(r&&(r[U]=0),l[U++]=a),D<<=1;U+=M}else if(b.encoding<2)for(g=0;g<k;g++){for(c=0;c<y;c++)l[U++]=V[B++];U+=M}else for(g=0;g<k;g++)if(l.fill)l.fill(v,U,U+y),U+=y+M;else{for(c=0;c<y;c++)l[U++]=v;U+=M}if(1===b.encoding&&B!==b.numValidPixels)throw"Block and Mask do not match";o++}}}return{resultPixels:l,resultMask:r}},n=function(e,t){return{fileIdentifierString:e.fileIdentifierString,fileVersion:e.fileVersion,imageType:e.imageType,height:e.height,width:e.width,maxZError:e.maxZError,eofOffset:e.eofOffset,mask:e.mask?{numBlocksX:e.mask.numBlocksX,numBlocksY:e.mask.numBlocksY,numBytes:e.mask.numBytes,maxValue:e.mask.maxValue}:null,pixels:{numBlocksX:e.pixels.numBlocksX,numBlocksY:e.pixels.numBlocksY,numBytes:e.pixels.numBytes,maxValue:e.pixels.maxValue,minValue:e.pixels.minValue,noDataValue:t}}},a=function(e){for(var t=e.pixels.numBlocksX*e.pixels.numBlocksY,i={},a=0;a<t;a++){var n=e.pixels.blocks[a];0===n.encoding?i.float32=!0:1===n.encoding?i[n.bitsPerPixel]=!0:i[0]=!0}return Object.keys(i)},l=function(e,t,i){var a={},n=new Uint8Array(e,t,10);if(a.fileIdentifierString=String.fromCharCode.apply(null,n),"CntZImage"!=a.fileIdentifierString.trim())throw"Unexpected file identifier string: "+a.fileIdentifierString;t+=10;var l=new DataView(e,t,24);if(a.fileVersion=l.getInt32(0,!0),a.imageType=l.getInt32(4,!0),a.height=l.getUint32(8,!0),a.width=l.getUint32(12,!0),a.maxZError=l.getFloat64(16,!0),t+=24,!i)if(l=new DataView(e,t,16),a.mask={},a.mask.numBlocksY=l.getUint32(0,!0),a.mask.numBlocksX=l.getUint32(4,!0),a.mask.numBytes=l.getUint32(8,!0),a.mask.maxValue=l.getFloat32(12,!0),t+=16,a.mask.numBytes>0){var r=new Uint8Array(Math.ceil(a.width*a.height/8)),s=(l=new DataView(e,t,a.mask.numBytes)).getInt16(0,!0),o=2,f=0;do{if(s>0)for(;s--;)r[f++]=l.getUint8(o++);else{var u=l.getUint8(o++);for(s=-s;s--;)r[f++]=u}s=l.getInt16(o,!0),o+=2}while(o<a.mask.numBytes);if(-32768!==s||f<r.length)throw"Unexpected end of mask RLE encoding";a.mask.bitset=r,t+=a.mask.numBytes}else 0==(a.mask.numBytes|a.mask.numBlocksY|a.mask.maxValue)&&(r=new Uint8Array(Math.ceil(a.width*a.height/8)),a.mask.bitset=r);l=new DataView(e,t,16),a.pixels={},a.pixels.numBlocksY=l.getUint32(0,!0),a.pixels.numBlocksX=l.getUint32(4,!0),a.pixels.numBytes=l.getUint32(8,!0),a.pixels.maxValue=l.getFloat32(12,!0),t+=16;var m=a.pixels.numBlocksX,d=a.pixels.numBlocksY,h=m+(a.width%m>0?1:0),c=d+(a.height%d>0?1:0);a.pixels.blocks=new Array(h*c);for(var g=1e9,w=0,x=0;x<c;x++)for(var k=0;k<h;k++){var p=0,y=e.byteLength-t;l=new DataView(e,t,Math.min(10,y));var V={};a.pixels.blocks[w++]=V;var B=l.getUint8(0);if(p++,V.encoding=63&B,V.encoding>3)throw"Invalid block encoding ("+V.encoding+")";if(2!==V.encoding){if(0!==B&&2!==B){if(B>>=6,V.offsetType=B,2===B)V.offset=l.getInt8(1),p++;else if(1===B)V.offset=l.getInt16(1,!0),p+=2;else{if(0!==B)throw"Invalid block offset type";V.offset=l.getFloat32(1,!0),p+=4}if(g=Math.min(V.offset,g),1===V.encoding)if(B=l.getUint8(p),p++,V.bitsPerPixel=63&B,B>>=6,V.numValidPixelsType=B,2===B)V.numValidPixels=l.getUint8(p),p++;else if(1===B)V.numValidPixels=l.getUint16(p,!0),p+=2;else{if(0!==B)throw"Invalid valid pixel count type";V.numValidPixels=l.getUint32(p,!0),p+=4}}var v;if(t+=p,3!=V.encoding)if(0===V.encoding){var D=(a.pixels.numBytes-1)/4;if(D!==Math.floor(D))throw"uncompressed block has invalid length";v=new ArrayBuffer(4*D),new Uint8Array(v).set(new Uint8Array(e,t,4*D));for(var U=new Float32Array(v),M=0;M<U.length;M++)g=Math.min(g,U[M]);V.rawData=U,t+=4*D}else if(1===V.encoding){var b=Math.ceil(V.numValidPixels*V.bitsPerPixel/8),I=Math.ceil(b/4);v=new ArrayBuffer(4*I),new Uint8Array(v).set(new Uint8Array(e,t,b)),V.stuffedData=new Uint32Array(v),t+=b}}else t++,g=Math.min(g,0)}return a.pixels.minValue=g,a.eofOffset=t,a},s=function(e,t,i,a,n,l,r){var s,o,f,u=(1<<t)-1,m=0,d=0,h=Math.ceil((r-a)/n),c=4*e.length-Math.ceil(t*i/8);for(e[e.length-1]<<=8*c,s=0;s<i;s++){if(0===d&&(f=e[m++],d=32),d>=t)o=f>>>d-t&u,d-=t;else{var g=t-d;o=(f&u)<<g&u,o+=(f=e[m++])>>>(d=32-g)}l[s]=o<h?a+o*n:r}return l},decodeTerrainRGB=async(e,t)=>{const i=new Blob([e]),a=await createImageBitmap(i),n=new OffscreenCanvas(a.width,a.height),l=n.width=a.width,r=n.height=a.height,s=n.getContext("2d",{willReadFrequently:!0});if(!s)throw new Error("无法获取2D上下文");s.drawImage(a,0,0);const o=s.getImageData(0,0,n.width,n.height).data;for(var f=new(t.pixelType||Float32Array)(l*r),u=1/0,m=-1/0,d=0;d<r;d++)for(var h=0;h<l;h++){var c=d*l+h,g=4*c,w=.1*(256*(t=o[g])*256+256*o[g+1]+o[g+2])-1e4;f[c]=w,w<u&&(u=w),w>m&&(m=w)}return u===1/0&&(u=0),m===-1/0&&(m=0),{width:l,height:r,pixelData:f,minValue:u,maxValue:m,noDataValue:t.noDataValue||t.defaultNoDataValue}};const r=t.decode;class o{_decode(e){return r(e.buffer,e.options).then((e=>Promise.resolve({result:e,transferList:[e.pixelData.buffer]})))}}function f(){return new o}export{f as default};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@geoscene/core",
3
- "version": "4.33.15",
3
+ "version": "4.33.17",
4
4
  "homepage": "https://js.geoscene.cn",
5
5
  "description": "GeoScene Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API",
6
6
  "keywords": [