qy-vue-plugins 0.1.13 → 0.1.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunks/MapView-CUWE_HAc.js +5 -0
- package/dist/chunks/{MapView-DbLjmir0.js → MapView-Dz9RRuER.js} +954 -928
- package/dist/chunks/{lerc-CGdROG8b.js → lerc-Co91bPqT.js} +1 -1
- package/dist/chunks/{lerc-g9Kisblb.js → lerc-DqIsP2wF.js} +1 -1
- package/dist/chunks/{utils-4f8T_cMD.js → utils-7p2Zpotx.js} +1 -1
- package/dist/chunks/{utils-DQ_qL6Bu.js → utils-DpLgeZ2k.js} +13 -11
- package/dist/mapbox/MapView.cjs +1 -1
- package/dist/mapbox/MapView.mjs +1 -1
- package/dist/mapbox/components/MapLegend.cjs +1 -1
- package/dist/mapbox/components/MapLegend.mjs +1 -1
- package/dist/mapbox/utils.cjs +1 -1
- package/dist/mapbox/utils.mjs +27 -25
- package/dist/mapbox/widgets/CustomShapeDialog.cjs +1 -1
- package/dist/mapbox/widgets/CustomShapeDialog.mjs +1 -1
- package/dist/mapbox/widgets/LegendDialogLine.cjs +1 -1
- package/dist/mapbox/widgets/LegendDialogLine.mjs +1 -1
- package/dist/mapbox/widgets/LegendDialogPoint.cjs +1 -1
- package/dist/mapbox/widgets/LegendDialogPoint.mjs +1 -1
- package/dist/mapbox/widgets/LegendLine.cjs +1 -1
- package/dist/mapbox/widgets/LegendLine.mjs +1 -1
- package/dist/mapbox/widgets/LegendPoint.cjs +1 -1
- package/dist/mapbox/widgets/LegendPoint.mjs +1 -1
- package/dist/mapbox/widgets/LegendPopLine.cjs +1 -1
- package/dist/mapbox/widgets/LegendPopLine.mjs +1 -1
- package/dist/mapbox/widgets/LegendPopPoint.cjs +1 -1
- package/dist/mapbox/widgets/LegendPopPoint.mjs +1 -1
- package/dist/mapbox/widgets/LegendShape.cjs +1 -1
- package/dist/mapbox/widgets/LegendShape.mjs +1 -1
- package/dist/mapbox/widgets/ShapeDialog.cjs +1 -1
- package/dist/mapbox/widgets/ShapeDialog.mjs +1 -1
- package/dist/mapbox.cjs +1 -1
- package/dist/mapbox.mjs +1 -1
- package/dist/qy-vue-plugins.css +1 -1
- package/dist/types/mapbox/MapView.vue.d.ts +12 -2
- package/dist/types/mapbox/useTif.d.ts +11 -2
- package/package/mapbox/useTif.ts +68 -63
- package/package/mapbox/utils.ts +2 -0
- package/package.json +4 -1
- package/dist/chunks/MapView-BjgU9M87.js +0 -5
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";const G=require("vue"),he=require("mapbox-gl"),Pt=require("./mapStore-Dir9bFfQ.js"),Lt=require("./map-CAu4wyVU.js"),R=require("./utils-7p2Zpotx.js"),le=require("./EventKeys-BLmCVdTJ.js"),be=require("./constant-Bc8XErtI.js"),Dt=require("@turf/turf"),Pe=require("./ProvideKeys-jy8dfV9u.js"),ut=require("./_commonjsHelpers-DwGv2jUC.js"),Ct=require("./_plugin-vue_export-helper-BHFhmbuH.js");function Et(t){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const i in t)if(i!=="default"){const n=Object.getOwnPropertyDescriptor(t,i);Object.defineProperty(e,i,n.get?n:{enumerable:!0,get:()=>t[i]})}}return e.default=t,Object.freeze(e)}const Le=Et(Dt);function X(t){return(e,...i)=>Mt(t,e,i)}function me(t,e){return X(ft(t,e).get)}const{apply:Mt,getOwnPropertyDescriptor:ft,getPrototypeOf:Ke,ownKeys:At}=Reflect,{iterator:ve,toStringTag:Ot}=Symbol,Rt=Object,{create:je,defineProperty:Nt}=Rt,Ft=Array,Bt=Ft.prototype,dt=Bt[ve],Gt=X(dt),ht=ArrayBuffer,kt=ht.prototype;me(kt,"byteLength");const it=typeof SharedArrayBuffer<"u"?SharedArrayBuffer:null;it&&me(it.prototype,"byteLength");const gt=Ke(Uint8Array);gt.from;const W=gt.prototype;W[ve];X(W.keys);X(W.values);X(W.entries);X(W.set);X(W.reverse);X(W.fill);X(W.copyWithin);X(W.sort);X(W.slice);X(W.subarray);me(W,"buffer");me(W,"byteOffset");me(W,"length");me(W,Ot);const Ut=Uint8Array,yt=Uint16Array,qe=Uint32Array,Vt=Float32Array,we=Ke([][ve]()),mt=X(we.next),Kt=X(function*(){}().next),jt=Ke(we),qt=DataView.prototype,zt=X(qt.getUint16),ze=WeakMap,pt=ze.prototype,xt=X(pt.get),Yt=X(pt.set),It=new ze,$t=je(null,{next:{value:function(){const e=xt(It,this);return mt(e)}},[ve]:{value:function(){return this}}});function Zt(t){if(t[ve]===dt&&we.next===mt)return t;const e=je($t);return Yt(It,e,Gt(t)),e}const Xt=new ze,Jt=je(jt,{next:{value:function(){const e=xt(Xt,this);return Kt(e)},writable:!0,configurable:!0}});for(const t of At(we))t!=="next"&&Nt(Jt,t,ft(we,t));const wt=new ht(4),Ht=new Vt(wt),Qt=new qe(wt),oe=new yt(512),ne=new Ut(512);for(let t=0;t<256;++t){const e=t-127;e<-24?(oe[t]=0,oe[t|256]=32768,ne[t]=24,ne[t|256]=24):e<-14?(oe[t]=1024>>-e-14,oe[t|256]=1024>>-e-14|32768,ne[t]=-e-1,ne[t|256]=-e-1):e<=15?(oe[t]=e+15<<10,oe[t|256]=e+15<<10|32768,ne[t]=13,ne[t|256]=13):e<128?(oe[t]=31744,oe[t|256]=64512,ne[t]=24,ne[t|256]=24):(oe[t]=31744,oe[t|256]=64512,ne[t]=13,ne[t|256]=13)}const Ye=new qe(2048);for(let t=1;t<1024;++t){let e=t<<13,i=0;for(;(e&8388608)===0;)e<<=1,i-=8388608;e&=-8388609,i+=947912704,Ye[t]=e|i}for(let t=1024;t<2048;++t)Ye[t]=939524096+(t-1024<<13);const pe=new qe(64);for(let t=1;t<31;++t)pe[t]=t<<23;pe[31]=1199570944;pe[32]=2147483648;for(let t=33;t<63;++t)pe[t]=2147483648+(t-32<<23);pe[63]=3347054592;const vt=new yt(64);for(let t=1;t<64;++t)t!==32&&(vt[t]=1024);function Wt(t){const e=t>>10;return Qt[0]=Ye[vt[e]+(t&1023)]+pe[e],Ht[0]}function St(t,e,...i){return Wt(zt(t,e,...Zt(i)))}var De={exports:{}},ot;function _t(){if(ot)return De.exports;ot=1;function t(e,i,n){const o=n&&n.debug||!1;o&&console.log("[xml-utils] getting "+i+" in "+e);const r=typeof e=="object"?e.outer:e,c=r.slice(0,r.indexOf(">")+1),s=['"',"'"];for(let u=0;u<s.length;u++){const l=s[u],h=i+"\\="+l+"([^"+l+"]*)"+l;o&&console.log("[xml-utils] pattern:",h);const m=new RegExp(h).exec(c);if(o&&console.log("[xml-utils] match:",m),m)return m[1]}}return De.exports=t,De.exports.default=t,De.exports}var er=_t();const Ge=ut.getDefaultExportFromCjs(er);var Ce={exports:{}},Ee={exports:{}},Me={exports:{}},nt;function tr(){if(nt)return Me.exports;nt=1;function t(e,i,n){const r=new RegExp(i).exec(e.slice(n));return r?n+r.index:-1}return Me.exports=t,Me.exports.default=t,Me.exports}var Ae={exports:{}},at;function rr(){if(at)return Ae.exports;at=1;function t(e,i,n){const r=new RegExp(i).exec(e.slice(n));return r?n+r.index+r[0].length-1:-1}return Ae.exports=t,Ae.exports.default=t,Ae.exports}var Oe={exports:{}},st;function ir(){if(st)return Oe.exports;st=1;function t(e,i){const n=new RegExp(i,"g"),o=e.match(n);return o?o.length:0}return Oe.exports=t,Oe.exports.default=t,Oe.exports}var lt;function or(){if(lt)return Ee.exports;lt=1;const t=tr(),e=rr(),i=ir();function n(o,r,c){const s=c&&c.debug||!1,u=!(c&&typeof c.nested===!1),l=c&&c.startIndex||0;s&&console.log("[xml-utils] starting findTagByName with",r," and ",c);const h=t(o,`<${r}[
|
|
2
|
+
>/]`,l);if(s&&console.log("[xml-utils] start:",h),h===-1)return;const y=o.slice(h+r.length);let m=e(y,"^[^<]*[ /]>",0);const g=m!==-1&&y[m-1]==="/";if(s&&console.log("[xml-utils] selfClosing:",g),g===!1)if(u){let P=0,S=1,v=0;for(;(m=e(y,"[ /]"+r+">",P))!==-1;){const M=y.substring(P,m+1);if(S+=i(M,"<"+r+`[
|
|
3
|
+
>]`),v+=i(M,"</"+r+">"),v>=S)break;P=m}}else m=e(y,"[ /]"+r+">",0);const f=h+r.length+m+1;if(s&&console.log("[xml-utils] end:",f),f===-1)return;const w=o.slice(h,f);let p;return g?p=null:p=w.slice(w.indexOf(">")+1,w.lastIndexOf("<")),{inner:p,outer:w,start:h,end:f}}return Ee.exports=n,Ee.exports.default=n,Ee.exports}var ct;function nr(){if(ct)return Ce.exports;ct=1;const t=or();function e(i,n,o){const r=[],c=o&&o.debug||!1,s=o&&typeof o.nested=="boolean"?o.nested:!0;let u=o&&o.startIndex||0,l;for(;l=t(i,n,{debug:c,startIndex:u});)s?u=l.start+1+n.length:u=l.end,r.push(l);return c&&console.log("findTagsByName found",r.length,"tags"),r}return Ce.exports=e,Ce.exports.default=e,Ce.exports}var ar=nr();const sr=ut.getDefaultExportFromCjs(ar),Ie={315:"Artist",258:"BitsPerSample",265:"CellLength",264:"CellWidth",320:"ColorMap",259:"Compression",33432:"Copyright",306:"DateTime",338:"ExtraSamples",266:"FillOrder",289:"FreeByteCounts",288:"FreeOffsets",291:"GrayResponseCurve",290:"GrayResponseUnit",316:"HostComputer",270:"ImageDescription",257:"ImageLength",256:"ImageWidth",271:"Make",281:"MaxSampleValue",280:"MinSampleValue",272:"Model",254:"NewSubfileType",274:"Orientation",262:"PhotometricInterpretation",284:"PlanarConfiguration",296:"ResolutionUnit",278:"RowsPerStrip",277:"SamplesPerPixel",305:"Software",279:"StripByteCounts",273:"StripOffsets",255:"SubfileType",263:"Threshholding",282:"XResolution",283:"YResolution",326:"BadFaxLines",327:"CleanFaxData",343:"ClipPath",328:"ConsecutiveBadFaxLines",433:"Decode",434:"DefaultImageColor",269:"DocumentName",336:"DotRange",321:"HalftoneHints",346:"Indexed",347:"JPEGTables",285:"PageName",297:"PageNumber",317:"Predictor",319:"PrimaryChromaticities",532:"ReferenceBlackWhite",339:"SampleFormat",340:"SMinSampleValue",341:"SMaxSampleValue",559:"StripRowCounts",330:"SubIFDs",292:"T4Options",293:"T6Options",325:"TileByteCounts",323:"TileLength",324:"TileOffsets",322:"TileWidth",301:"TransferFunction",318:"WhitePoint",344:"XClipPathUnits",286:"XPosition",529:"YCbCrCoefficients",531:"YCbCrPositioning",530:"YCbCrSubSampling",345:"YClipPathUnits",287:"YPosition",37378:"ApertureValue",40961:"ColorSpace",36868:"DateTimeDigitized",36867:"DateTimeOriginal",34665:"Exif IFD",36864:"ExifVersion",33434:"ExposureTime",41728:"FileSource",37385:"Flash",40960:"FlashpixVersion",33437:"FNumber",42016:"ImageUniqueID",37384:"LightSource",37500:"MakerNote",37377:"ShutterSpeedValue",37510:"UserComment",33723:"IPTC",34675:"ICC Profile",700:"XMP",42112:"GDAL_METADATA",42113:"GDAL_NODATA",34377:"Photoshop",33550:"ModelPixelScale",33922:"ModelTiepoint",34264:"ModelTransformation",34735:"GeoKeyDirectory",34736:"GeoDoubleParams",34737:"GeoAsciiParams",50674:"LercParameters"},ae={};for(const t in Ie)Ie.hasOwnProperty(t)&&(ae[Ie[t]]=parseInt(t,10));const lr=[ae.BitsPerSample,ae.ExtraSamples,ae.SampleFormat,ae.StripByteCounts,ae.StripOffsets,ae.StripRowCounts,ae.TileByteCounts,ae.TileOffsets,ae.SubIFDs],ke={1:"BYTE",2:"ASCII",3:"SHORT",4:"LONG",5:"RATIONAL",6:"SBYTE",7:"UNDEFINED",8:"SSHORT",9:"SLONG",10:"SRATIONAL",11:"FLOAT",12:"DOUBLE",13:"IFD",16:"LONG8",17:"SLONG8",18:"IFD8"},N={};for(const t in ke)ke.hasOwnProperty(t)&&(N[ke[t]]=parseInt(t,10));const _={WhiteIsZero:0,BlackIsZero:1,RGB:2,Palette:3,CMYK:5,YCbCr:6,CIELab:8},cr={Unspecified:0},ur={AddCompression:1},fr={None:0,Deflate:1,Zstandard:2},dr={1024:"GTModelTypeGeoKey",1025:"GTRasterTypeGeoKey",1026:"GTCitationGeoKey",2048:"GeographicTypeGeoKey",2049:"GeogCitationGeoKey",2050:"GeogGeodeticDatumGeoKey",2051:"GeogPrimeMeridianGeoKey",2052:"GeogLinearUnitsGeoKey",2053:"GeogLinearUnitSizeGeoKey",2054:"GeogAngularUnitsGeoKey",2055:"GeogAngularUnitSizeGeoKey",2056:"GeogEllipsoidGeoKey",2057:"GeogSemiMajorAxisGeoKey",2058:"GeogSemiMinorAxisGeoKey",2059:"GeogInvFlatteningGeoKey",2060:"GeogAzimuthUnitsGeoKey",2061:"GeogPrimeMeridianLongGeoKey",2062:"GeogTOWGS84GeoKey",3072:"ProjectedCSTypeGeoKey",3073:"PCSCitationGeoKey",3074:"ProjectionGeoKey",3075:"ProjCoordTransGeoKey",3076:"ProjLinearUnitsGeoKey",3077:"ProjLinearUnitSizeGeoKey",3078:"ProjStdParallel1GeoKey",3079:"ProjStdParallel2GeoKey",3080:"ProjNatOriginLongGeoKey",3081:"ProjNatOriginLatGeoKey",3082:"ProjFalseEastingGeoKey",3083:"ProjFalseNorthingGeoKey",3084:"ProjFalseOriginLongGeoKey",3085:"ProjFalseOriginLatGeoKey",3086:"ProjFalseOriginEastingGeoKey",3087:"ProjFalseOriginNorthingGeoKey",3088:"ProjCenterLongGeoKey",3089:"ProjCenterLatGeoKey",3090:"ProjCenterEastingGeoKey",3091:"ProjCenterNorthingGeoKey",3092:"ProjScaleAtNatOriginGeoKey",3093:"ProjScaleAtCenterGeoKey",3094:"ProjAzimuthAngleGeoKey",3095:"ProjStraightVertPoleLongGeoKey",3096:"ProjRectifiedGridAngleGeoKey",4096:"VerticalCSTypeGeoKey",4097:"VerticalCitationGeoKey",4098:"VerticalDatumGeoKey",4099:"VerticalUnitsGeoKey"};function hr(t,e){const{width:i,height:n}=t,o=new Uint8Array(i*n*3);let r;for(let c=0,s=0;c<t.length;++c,s+=3)r=256-t[c]/e*256,o[s]=r,o[s+1]=r,o[s+2]=r;return o}function gr(t,e){const{width:i,height:n}=t,o=new Uint8Array(i*n*3);let r;for(let c=0,s=0;c<t.length;++c,s+=3)r=t[c]/e*256,o[s]=r,o[s+1]=r,o[s+2]=r;return o}function yr(t,e){const{width:i,height:n}=t,o=new Uint8Array(i*n*3),r=e.length/3,c=e.length/3*2;for(let s=0,u=0;s<t.length;++s,u+=3){const l=t[s];o[u]=e[l]/65536*256,o[u+1]=e[l+r]/65536*256,o[u+2]=e[l+c]/65536*256}return o}function mr(t){const{width:e,height:i}=t,n=new Uint8Array(e*i*3);for(let o=0,r=0;o<t.length;o+=4,r+=3){const c=t[o],s=t[o+1],u=t[o+2],l=t[o+3];n[r]=255*((255-c)/256)*((255-l)/256),n[r+1]=255*((255-s)/256)*((255-l)/256),n[r+2]=255*((255-u)/256)*((255-l)/256)}return n}function pr(t){const{width:e,height:i}=t,n=new Uint8ClampedArray(e*i*3);for(let o=0,r=0;o<t.length;o+=3,r+=3){const c=t[o],s=t[o+1],u=t[o+2];n[r]=c+1.402*(u-128),n[r+1]=c-.34414*(s-128)-.71414*(u-128),n[r+2]=c+1.772*(s-128)}return n}const xr=.95047,Ir=1,wr=1.08883;function vr(t){const{width:e,height:i}=t,n=new Uint8Array(e*i*3);for(let o=0,r=0;o<t.length;o+=3,r+=3){const c=t[o+0],s=t[o+1]<<24>>24,u=t[o+2]<<24>>24;let l=(c+16)/116,h=s/500+l,y=l-u/200,m,g,f;h=xr*(h*h*h>.008856?h*h*h:(h-16/116)/7.787),l=Ir*(l*l*l>.008856?l*l*l:(l-16/116)/7.787),y=wr*(y*y*y>.008856?y*y*y:(y-16/116)/7.787),m=h*3.2406+l*-1.5372+y*-.4986,g=h*-.9689+l*1.8758+y*.0415,f=h*.0557+l*-.204+y*1.057,m=m>.0031308?1.055*m**(1/2.4)-.055:12.92*m,g=g>.0031308?1.055*g**(1/2.4)-.055:12.92*g,f=f>.0031308?1.055*f**(1/2.4)-.055:12.92*f,n[r]=Math.max(0,Math.min(1,m))*255,n[r+1]=Math.max(0,Math.min(1,g))*255,n[r+2]=Math.max(0,Math.min(1,f))*255}return n}const Tt=new Map;function ce(t,e){Array.isArray(t)||(t=[t]),t.forEach(i=>Tt.set(i,e))}async function Sr(t){const e=Tt.get(t.Compression);if(!e)throw new Error(`Unknown compression method identifier: ${t.Compression}`);const i=await e();return new i(t)}ce([void 0,1],()=>Promise.resolve().then(()=>require("./raw-Cm78EGPL.js")).then(t=>t.default));ce(5,()=>Promise.resolve().then(()=>require("./lzw-Cbi9AOTI.js")).then(t=>t.default));ce(6,()=>{throw new Error("old style JPEG compression is not supported.")});ce(7,()=>Promise.resolve().then(()=>require("./jpeg-ClJ__b4h.js")).then(t=>t.default));ce([8,32946],()=>Promise.resolve().then(()=>require("./deflate-DEFE2aFp.js")).then(t=>t.default));ce(32773,()=>Promise.resolve().then(()=>require("./packbits-BXw9Z-3g.js")).then(t=>t.default));ce(34887,()=>Promise.resolve().then(()=>require("./lerc-DqIsP2wF.js")).then(async t=>(await t.zstd.init(),t)).then(t=>t.default));ce(50001,()=>Promise.resolve().then(()=>require("./webimage-CCSZWcNO.js")).then(t=>t.default));function Ne(t,e,i,n=1){return new(Object.getPrototypeOf(t)).constructor(e*i*n)}function Tr(t,e,i,n,o){const r=e/n,c=i/o;return t.map(s=>{const u=Ne(s,n,o);for(let l=0;l<o;++l){const h=Math.min(Math.round(c*l),i-1);for(let y=0;y<n;++y){const m=Math.min(Math.round(r*y),e-1),g=s[h*e+m];u[l*n+y]=g}}return u})}function ye(t,e,i){return(1-i)*t+i*e}function br(t,e,i,n,o){const r=e/n,c=i/o;return t.map(s=>{const u=Ne(s,n,o);for(let l=0;l<o;++l){const h=c*l,y=Math.floor(h),m=Math.min(Math.ceil(h),i-1);for(let g=0;g<n;++g){const f=r*g,w=f%1,p=Math.floor(f),P=Math.min(Math.ceil(f),e-1),S=s[y*e+p],v=s[y*e+P],M=s[m*e+p],V=s[m*e+P],q=ye(ye(S,v,w),ye(M,V,w),h%1);u[l*n+g]=q}}return u})}function Pr(t,e,i,n,o,r="nearest"){switch(r.toLowerCase()){case"nearest":return Tr(t,e,i,n,o);case"bilinear":case"linear":return br(t,e,i,n,o);default:throw new Error(`Unsupported resampling method: '${r}'`)}}function Lr(t,e,i,n,o,r){const c=e/n,s=i/o,u=Ne(t,n,o,r);for(let l=0;l<o;++l){const h=Math.min(Math.round(s*l),i-1);for(let y=0;y<n;++y){const m=Math.min(Math.round(c*y),e-1);for(let g=0;g<r;++g){const f=t[h*e*r+m*r+g];u[l*n*r+y*r+g]=f}}}return u}function Dr(t,e,i,n,o,r){const c=e/n,s=i/o,u=Ne(t,n,o,r);for(let l=0;l<o;++l){const h=s*l,y=Math.floor(h),m=Math.min(Math.ceil(h),i-1);for(let g=0;g<n;++g){const f=c*g,w=f%1,p=Math.floor(f),P=Math.min(Math.ceil(f),e-1);for(let S=0;S<r;++S){const v=t[y*e*r+p*r+S],M=t[y*e*r+P*r+S],V=t[m*e*r+p*r+S],q=t[m*e*r+P*r+S],K=ye(ye(v,M,w),ye(V,q,w),h%1);u[l*n*r+g*r+S]=K}}}return u}function Cr(t,e,i,n,o,r,c="nearest"){switch(c.toLowerCase()){case"nearest":return Lr(t,e,i,n,o,r);case"bilinear":case"linear":return Dr(t,e,i,n,o,r);default:throw new Error(`Unsupported resampling method: '${c}'`)}}function Er(t,e,i){let n=0;for(let o=e;o<i;++o)n+=t[o];return n}function Ue(t,e,i){switch(t){case 1:if(e<=8)return new Uint8Array(i);if(e<=16)return new Uint16Array(i);if(e<=32)return new Uint32Array(i);break;case 2:if(e===8)return new Int8Array(i);if(e===16)return new Int16Array(i);if(e===32)return new Int32Array(i);break;case 3:switch(e){case 16:case 32:return new Float32Array(i);case 64:return new Float64Array(i)}break}throw Error("Unsupported data format/bitsPerSample")}function Mr(t,e){return(t===1||t===2)&&e<=32&&e%8===0?!1:!(t===3&&(e===16||e===32||e===64))}function Ar(t,e,i,n,o,r,c){const s=new DataView(t),u=i===2?c*r:c*r*n,l=i===2?1:n,h=Ue(e,o,u),y=parseInt("1".repeat(o),2);if(e===1){let m;i===1?m=n*o:m=o;let g=r*m;(g&7)!==0&&(g=g+7&-8);for(let f=0;f<c;++f){const w=f*g;for(let p=0;p<r;++p){const P=w+p*l*o;for(let S=0;S<l;++S){const v=P+S*o,M=(f*r+p)*l+S,V=Math.floor(v/8),q=v%8;if(q+o<=8)h[M]=s.getUint8(V)>>8-o-q&y;else if(q+o<=16)h[M]=s.getUint16(V)>>16-o-q&y;else if(q+o<=24){const K=s.getUint16(V)<<8|s.getUint8(V+2);h[M]=K>>24-o-q&y}else h[M]=s.getUint32(V)>>32-o-q&y}}}}return h.buffer}class Or{constructor(e,i,n,o,r,c){this.fileDirectory=e,this.geoKeys=i,this.dataView=n,this.littleEndian=o,this.tiles=r?{}:null,this.isTiled=!e.StripOffsets;const s=e.PlanarConfiguration;if(this.planarConfiguration=typeof s>"u"?1:s,this.planarConfiguration!==1&&this.planarConfiguration!==2)throw new Error("Invalid planar configuration.");this.source=c}getFileDirectory(){return this.fileDirectory}getGeoKeys(){return this.geoKeys}getWidth(){return this.fileDirectory.ImageWidth}getHeight(){return this.fileDirectory.ImageLength}getSamplesPerPixel(){return typeof this.fileDirectory.SamplesPerPixel<"u"?this.fileDirectory.SamplesPerPixel:1}getTileWidth(){return this.isTiled?this.fileDirectory.TileWidth:this.getWidth()}getTileHeight(){return this.isTiled?this.fileDirectory.TileLength:typeof this.fileDirectory.RowsPerStrip<"u"?Math.min(this.fileDirectory.RowsPerStrip,this.getHeight()):this.getHeight()}getBlockWidth(){return this.getTileWidth()}getBlockHeight(e){return this.isTiled||(e+1)*this.getTileHeight()<=this.getHeight()?this.getTileHeight():this.getHeight()-e*this.getTileHeight()}getBytesPerPixel(){let e=0;for(let i=0;i<this.fileDirectory.BitsPerSample.length;++i)e+=this.getSampleByteSize(i);return e}getSampleByteSize(e){if(e>=this.fileDirectory.BitsPerSample.length)throw new RangeError(`Sample index ${e} is out of range.`);return Math.ceil(this.fileDirectory.BitsPerSample[e]/8)}getReaderForSample(e){const i=this.fileDirectory.SampleFormat?this.fileDirectory.SampleFormat[e]:1,n=this.fileDirectory.BitsPerSample[e];switch(i){case 1:if(n<=8)return DataView.prototype.getUint8;if(n<=16)return DataView.prototype.getUint16;if(n<=32)return DataView.prototype.getUint32;break;case 2:if(n<=8)return DataView.prototype.getInt8;if(n<=16)return DataView.prototype.getInt16;if(n<=32)return DataView.prototype.getInt32;break;case 3:switch(n){case 16:return function(o,r){return St(this,o,r)};case 32:return DataView.prototype.getFloat32;case 64:return DataView.prototype.getFloat64}break}throw Error("Unsupported data format/bitsPerSample")}getSampleFormat(e=0){return this.fileDirectory.SampleFormat?this.fileDirectory.SampleFormat[e]:1}getBitsPerSample(e=0){return this.fileDirectory.BitsPerSample[e]}getArrayForSample(e,i){const n=this.getSampleFormat(e),o=this.getBitsPerSample(e);return Ue(n,o,i)}async getTileOrStrip(e,i,n,o,r){const c=Math.ceil(this.getWidth()/this.getTileWidth()),s=Math.ceil(this.getHeight()/this.getTileHeight());let u;const{tiles:l}=this;this.planarConfiguration===1?u=i*c+e:this.planarConfiguration===2&&(u=n*c*s+i*c+e);let h,y;this.isTiled?(h=this.fileDirectory.TileOffsets[u],y=this.fileDirectory.TileByteCounts[u]):(h=this.fileDirectory.StripOffsets[u],y=this.fileDirectory.StripByteCounts[u]);const m=(await this.source.fetch([{offset:h,length:y}],r))[0];let g;return l===null||!l[u]?(g=(async()=>{let f=await o.decode(this.fileDirectory,m);const w=this.getSampleFormat(),p=this.getBitsPerSample();return Mr(w,p)&&(f=Ar(f,w,this.planarConfiguration,this.getSamplesPerPixel(),p,this.getTileWidth(),this.getBlockHeight(i))),f})(),l!==null&&(l[u]=g)):g=l[u],{x:e,y:i,sample:n,data:await g}}async _readRaster(e,i,n,o,r,c,s,u,l){const h=this.getTileWidth(),y=this.getTileHeight(),m=this.getWidth(),g=this.getHeight(),f=Math.max(Math.floor(e[0]/h),0),w=Math.min(Math.ceil(e[2]/h),Math.ceil(m/h)),p=Math.max(Math.floor(e[1]/y),0),P=Math.min(Math.ceil(e[3]/y),Math.ceil(g/y)),S=e[2]-e[0];let v=this.getBytesPerPixel();const M=[],V=[];for(let k=0;k<i.length;++k)this.planarConfiguration===1?M.push(Er(this.fileDirectory.BitsPerSample,0,i[k])/8):M.push(0),V.push(this.getReaderForSample(i[k]));const q=[],{littleEndian:K}=this;for(let k=p;k<P;++k)for(let Y=f;Y<w;++Y){let $;this.planarConfiguration===1&&($=this.getTileOrStrip(Y,k,0,r,l));for(let z=0;z<i.length;++z){const J=z,ee=i[z];this.planarConfiguration===2&&(v=this.getSampleByteSize(ee),$=this.getTileOrStrip(Y,k,ee,r,l));const te=$.then(re=>{const Fe=re.data,Be=new DataView(Fe),ue=this.getBlockHeight(re.y),se=re.y*y,fe=re.x*h,Se=se+ue,a=(re.x+1)*h,d=V[J],I=Math.min(ue,ue-(Se-e[3]),g-se),D=Math.min(h,h-(a-e[2]),m-fe);for(let T=Math.max(0,e[1]-se);T<I;++T)for(let x=Math.max(0,e[0]-fe);x<D;++x){const A=(T*h+x)*v,C=d.call(Be,A+M[J],K);let B;o?(B=(T+se-e[1])*S*i.length+(x+fe-e[0])*i.length+J,n[B]=C):(B=(T+se-e[1])*S+x+fe-e[0],n[J][B]=C)}});q.push(te)}}if(await Promise.all(q),c&&e[2]-e[0]!==c||s&&e[3]-e[1]!==s){let k;return o?k=Cr(n,e[2]-e[0],e[3]-e[1],c,s,i.length,u):k=Pr(n,e[2]-e[0],e[3]-e[1],c,s,u),k.width=c,k.height=s,k}return n.width=c||e[2]-e[0],n.height=s||e[3]-e[1],n}async readRasters({window:e,samples:i=[],interleave:n,pool:o=null,width:r,height:c,resampleMethod:s,fillValue:u,signal:l}={}){const h=e||[0,0,this.getWidth(),this.getHeight()];if(h[0]>h[2]||h[1]>h[3])throw new Error("Invalid subsets");const y=h[2]-h[0],m=h[3]-h[1],g=y*m,f=this.getSamplesPerPixel();if(!i||!i.length)for(let S=0;S<f;++S)i.push(S);else for(let S=0;S<i.length;++S)if(i[S]>=f)return Promise.reject(new RangeError(`Invalid sample index '${i[S]}'.`));let w;if(n){const S=this.fileDirectory.SampleFormat?Math.max.apply(null,this.fileDirectory.SampleFormat):1,v=Math.max.apply(null,this.fileDirectory.BitsPerSample);w=Ue(S,v,g*i.length),u&&w.fill(u)}else{w=[];for(let S=0;S<i.length;++S){const v=this.getArrayForSample(i[S],g);Array.isArray(u)&&S<u.length?v.fill(u[S]):u&&!Array.isArray(u)&&v.fill(u),w.push(v)}}const p=o||await Sr(this.fileDirectory);return await this._readRaster(h,i,w,n,p,r,c,s,l)}async readRGB({window:e,interleave:i=!0,pool:n=null,width:o,height:r,resampleMethod:c,enableAlpha:s=!1,signal:u}={}){const l=e||[0,0,this.getWidth(),this.getHeight()];if(l[0]>l[2]||l[1]>l[3])throw new Error("Invalid subsets");const h=this.fileDirectory.PhotometricInterpretation;if(h===_.RGB){let P=[0,1,2];if(this.fileDirectory.ExtraSamples!==cr.Unspecified&&s){P=[];for(let S=0;S<this.fileDirectory.BitsPerSample.length;S+=1)P.push(S)}return this.readRasters({window:e,interleave:i,samples:P,pool:n,width:o,height:r,resampleMethod:c,signal:u})}let y;switch(h){case _.WhiteIsZero:case _.BlackIsZero:case _.Palette:y=[0];break;case _.CMYK:y=[0,1,2,3];break;case _.YCbCr:case _.CIELab:y=[0,1,2];break;default:throw new Error("Invalid or unsupported photometric interpretation.")}const m={window:l,interleave:!0,samples:y,pool:n,width:o,height:r,resampleMethod:c,signal:u},{fileDirectory:g}=this,f=await this.readRasters(m),w=2**this.fileDirectory.BitsPerSample[0];let p;switch(h){case _.WhiteIsZero:p=hr(f,w);break;case _.BlackIsZero:p=gr(f,w);break;case _.Palette:p=yr(f,g.ColorMap);break;case _.CMYK:p=mr(f);break;case _.YCbCr:p=pr(f);break;case _.CIELab:p=vr(f);break;default:throw new Error("Unsupported photometric interpretation.")}if(!i){const P=new Uint8Array(p.length/3),S=new Uint8Array(p.length/3),v=new Uint8Array(p.length/3);for(let M=0,V=0;M<p.length;M+=3,++V)P[V]=p[M],S[V]=p[M+1],v[V]=p[M+2];p=[P,S,v]}return p.width=f.width,p.height=f.height,p}getTiePoints(){if(!this.fileDirectory.ModelTiepoint)return[];const e=[];for(let i=0;i<this.fileDirectory.ModelTiepoint.length;i+=6)e.push({i:this.fileDirectory.ModelTiepoint[i],j:this.fileDirectory.ModelTiepoint[i+1],k:this.fileDirectory.ModelTiepoint[i+2],x:this.fileDirectory.ModelTiepoint[i+3],y:this.fileDirectory.ModelTiepoint[i+4],z:this.fileDirectory.ModelTiepoint[i+5]});return e}getGDALMetadata(e=null){const i={};if(!this.fileDirectory.GDAL_METADATA)return null;const n=this.fileDirectory.GDAL_METADATA;let o=sr(n,"Item");e===null?o=o.filter(r=>Ge(r,"sample")===void 0):o=o.filter(r=>Number(Ge(r,"sample"))===e);for(let r=0;r<o.length;++r){const c=o[r];i[Ge(c,"name")]=c.inner}return i}getGDALNoData(){if(!this.fileDirectory.GDAL_NODATA)return null;const e=this.fileDirectory.GDAL_NODATA;return Number(e.substring(0,e.length-1))}getOrigin(){const e=this.fileDirectory.ModelTiepoint,i=this.fileDirectory.ModelTransformation;if(e&&e.length===6)return[e[3],e[4],e[5]];if(i)return[i[3],i[7],i[11]];throw new Error("The image does not have an affine transformation.")}getResolution(e=null){const i=this.fileDirectory.ModelPixelScale,n=this.fileDirectory.ModelTransformation;if(i)return[i[0],-i[1],i[2]];if(n)return n[1]===0&&n[4]===0?[n[0],-n[5],n[10]]:[Math.sqrt(n[0]*n[0]+n[4]*n[4]),-Math.sqrt(n[1]*n[1]+n[5]*n[5]),n[10]];if(e){const[o,r,c]=e.getResolution();return[o*e.getWidth()/this.getWidth(),r*e.getHeight()/this.getHeight(),c*e.getWidth()/this.getWidth()]}throw new Error("The image does not have an affine transformation.")}pixelIsArea(){return this.geoKeys.GTRasterTypeGeoKey===1}getBoundingBox(e=!1){const i=this.getHeight(),n=this.getWidth();if(this.fileDirectory.ModelTransformation&&!e){const[o,r,c,s,u,l,h,y]=this.fileDirectory.ModelTransformation,g=[[0,0],[0,i],[n,0],[n,i]].map(([p,P])=>[s+o*p+r*P,y+u*p+l*P]),f=g.map(p=>p[0]),w=g.map(p=>p[1]);return[Math.min(...f),Math.min(...w),Math.max(...f),Math.max(...w)]}else{const o=this.getOrigin(),r=this.getResolution(),c=o[0],s=o[1],u=c+r[0]*n,l=s+r[1]*i;return[Math.min(c,u),Math.min(s,l),Math.max(c,u),Math.max(s,l)]}}}class Rr{constructor(e){this._dataView=new DataView(e)}get buffer(){return this._dataView.buffer}getUint64(e,i){const n=this.getUint32(e,i),o=this.getUint32(e+4,i);let r;if(i){if(r=n+2**32*o,!Number.isSafeInteger(r))throw new Error(`${r} exceeds MAX_SAFE_INTEGER. Precision may be lost. Please report if you get this message to https://github.com/geotiffjs/geotiff.js/issues`);return r}if(r=2**32*n+o,!Number.isSafeInteger(r))throw new Error(`${r} exceeds MAX_SAFE_INTEGER. Precision may be lost. Please report if you get this message to https://github.com/geotiffjs/geotiff.js/issues`);return r}getInt64(e,i){let n=0;const o=(this._dataView.getUint8(e+(i?7:0))&128)>0;let r=!0;for(let c=0;c<8;c++){let s=this._dataView.getUint8(e+(i?c:7-c));o&&(r?s!==0&&(s=~(s-1)&255,r=!1):s=~s&255),n+=s*256**c}return o&&(n=-n),n}getUint8(e,i){return this._dataView.getUint8(e,i)}getInt8(e,i){return this._dataView.getInt8(e,i)}getUint16(e,i){return this._dataView.getUint16(e,i)}getInt16(e,i){return this._dataView.getInt16(e,i)}getUint32(e,i){return this._dataView.getUint32(e,i)}getInt32(e,i){return this._dataView.getInt32(e,i)}getFloat16(e,i){return St(this._dataView,e,i)}getFloat32(e,i){return this._dataView.getFloat32(e,i)}getFloat64(e,i){return this._dataView.getFloat64(e,i)}}class Nr{constructor(e,i,n,o){this._dataView=new DataView(e),this._sliceOffset=i,this._littleEndian=n,this._bigTiff=o}get sliceOffset(){return this._sliceOffset}get sliceTop(){return this._sliceOffset+this.buffer.byteLength}get littleEndian(){return this._littleEndian}get bigTiff(){return this._bigTiff}get buffer(){return this._dataView.buffer}covers(e,i){return this.sliceOffset<=e&&this.sliceTop>=e+i}readUint8(e){return this._dataView.getUint8(e-this._sliceOffset,this._littleEndian)}readInt8(e){return this._dataView.getInt8(e-this._sliceOffset,this._littleEndian)}readUint16(e){return this._dataView.getUint16(e-this._sliceOffset,this._littleEndian)}readInt16(e){return this._dataView.getInt16(e-this._sliceOffset,this._littleEndian)}readUint32(e){return this._dataView.getUint32(e-this._sliceOffset,this._littleEndian)}readInt32(e){return this._dataView.getInt32(e-this._sliceOffset,this._littleEndian)}readFloat32(e){return this._dataView.getFloat32(e-this._sliceOffset,this._littleEndian)}readFloat64(e){return this._dataView.getFloat64(e-this._sliceOffset,this._littleEndian)}readUint64(e){const i=this.readUint32(e),n=this.readUint32(e+4);let o;if(this._littleEndian){if(o=i+2**32*n,!Number.isSafeInteger(o))throw new Error(`${o} exceeds MAX_SAFE_INTEGER. Precision may be lost. Please report if you get this message to https://github.com/geotiffjs/geotiff.js/issues`);return o}if(o=2**32*i+n,!Number.isSafeInteger(o))throw new Error(`${o} exceeds MAX_SAFE_INTEGER. Precision may be lost. Please report if you get this message to https://github.com/geotiffjs/geotiff.js/issues`);return o}readInt64(e){let i=0;const n=(this._dataView.getUint8(e+(this._littleEndian?7:0))&128)>0;let o=!0;for(let r=0;r<8;r++){let c=this._dataView.getUint8(e+(this._littleEndian?r:7-r));n&&(o?c!==0&&(c=~(c-1)&255,o=!1):c=~c&255),i+=c*256**r}return n&&(i=-i),i}readOffset(e){return this._bigTiff?this.readUint64(e):this.readUint32(e)}}class Fr{async fetch(e,i=void 0){return Promise.all(e.map(n=>this.fetchSlice(n,i)))}async fetchSlice(e){throw new Error(`fetching of slice ${e} not possible, not implemented`)}get fileSize(){return null}async close(){}}class $e extends Error{constructor(e){super(e),Error.captureStackTrace&&Error.captureStackTrace(this,$e),this.name="AbortError"}}class Br extends Fr{constructor(e){super(),this.arrayBuffer=e}fetchSlice(e,i){if(i&&i.aborted)throw new $e("Request aborted");return this.arrayBuffer.slice(e.offset,e.offset+e.length)}}function Gr(t){return new Br(t)}function Ve(t){switch(t){case N.BYTE:case N.ASCII:case N.SBYTE:case N.UNDEFINED:return 1;case N.SHORT:case N.SSHORT:return 2;case N.LONG:case N.SLONG:case N.FLOAT:case N.IFD:return 4;case N.RATIONAL:case N.SRATIONAL:case N.DOUBLE:case N.LONG8:case N.SLONG8:case N.IFD8:return 8;default:throw new RangeError(`Invalid field type: ${t}`)}}function kr(t){const e=t.GeoKeyDirectory;if(!e)return null;const i={};for(let n=4;n<=e[3]*4;n+=4){const o=dr[e[n]],r=e[n+1]?Ie[e[n+1]]:null,c=e[n+2],s=e[n+3];let u=null;if(!r)u=s;else{if(u=t[r],typeof u>"u"||u===null)throw new Error(`Could not get value of geoKey '${o}'.`);typeof u=="string"?u=u.substring(s,s+c-1):u.subarray&&(u=u.subarray(s,s+c),c===1&&(u=u[0]))}i[o]=u}return i}function ge(t,e,i,n){let o=null,r=null;const c=Ve(e);switch(e){case N.BYTE:case N.ASCII:case N.UNDEFINED:o=new Uint8Array(i),r=t.readUint8;break;case N.SBYTE:o=new Int8Array(i),r=t.readInt8;break;case N.SHORT:o=new Uint16Array(i),r=t.readUint16;break;case N.SSHORT:o=new Int16Array(i),r=t.readInt16;break;case N.LONG:case N.IFD:o=new Uint32Array(i),r=t.readUint32;break;case N.SLONG:o=new Int32Array(i),r=t.readInt32;break;case N.LONG8:case N.IFD8:o=new Array(i),r=t.readUint64;break;case N.SLONG8:o=new Array(i),r=t.readInt64;break;case N.RATIONAL:o=new Uint32Array(i*2),r=t.readUint32;break;case N.SRATIONAL:o=new Int32Array(i*2),r=t.readInt32;break;case N.FLOAT:o=new Float32Array(i),r=t.readFloat32;break;case N.DOUBLE:o=new Float64Array(i),r=t.readFloat64;break;default:throw new RangeError(`Invalid field type: ${e}`)}if(e===N.RATIONAL||e===N.SRATIONAL)for(let s=0;s<i;s+=2)o[s]=r.call(t,n+s*c),o[s+1]=r.call(t,n+(s*c+4));else for(let s=0;s<i;++s)o[s]=r.call(t,n+s*c);return e===N.ASCII?new TextDecoder("utf-8").decode(o):o}class Ur{constructor(e,i,n){this.fileDirectory=e,this.geoKeyDirectory=i,this.nextIFDByteOffset=n}}class Re extends Error{constructor(e){super(`No image at index ${e}`),this.index=e}}class Vr{async readRasters(e={}){const{window:i,width:n,height:o}=e;let{resX:r,resY:c,bbox:s}=e;const u=await this.getImage();let l=u;const h=await this.getImageCount(),y=u.getBoundingBox();if(i&&s)throw new Error('Both "bbox" and "window" passed.');if(n||o){if(i){const[f,w]=u.getOrigin(),[p,P]=u.getResolution();s=[f+i[0]*p,w+i[1]*P,f+i[2]*p,w+i[3]*P]}const g=s||y;if(n){if(r)throw new Error("Both width and resX passed");r=(g[2]-g[0])/n}if(o){if(c)throw new Error("Both width and resY passed");c=(g[3]-g[1])/o}}if(r||c){const g=[];for(let f=0;f<h;++f){const w=await this.getImage(f),{SubfileType:p,NewSubfileType:P}=w.fileDirectory;(f===0||p===2||P&1)&&g.push(w)}g.sort((f,w)=>f.getWidth()-w.getWidth());for(let f=0;f<g.length;++f){const w=g[f],p=(y[2]-y[0])/w.getWidth(),P=(y[3]-y[1])/w.getHeight();if(l=w,r&&r>p||c&&c>P)break}}let m=i;if(s){const[g,f]=u.getOrigin(),[w,p]=l.getResolution(u);m=[Math.round((s[0]-g)/w),Math.round((s[1]-f)/p),Math.round((s[2]-g)/w),Math.round((s[3]-f)/p)],m=[Math.min(m[0],m[2]),Math.min(m[1],m[3]),Math.max(m[0],m[2]),Math.max(m[1],m[3])]}return l.readRasters({...e,window:m})}}class Ze extends Vr{constructor(e,i,n,o,r={}){super(),this.source=e,this.littleEndian=i,this.bigTiff=n,this.firstIFDOffset=o,this.cache=r.cache||!1,this.ifdRequests=[],this.ghostValues=null}async getSlice(e,i){const n=this.bigTiff?4048:1024;return new Nr((await this.source.fetch([{offset:e,length:typeof i<"u"?i:n}]))[0],e,this.littleEndian,this.bigTiff)}async parseFileDirectoryAt(e){const i=this.bigTiff?20:12,n=this.bigTiff?8:2;let o=await this.getSlice(e);const r=this.bigTiff?o.readUint64(e):o.readUint16(e),c=r*i+(this.bigTiff?16:6);o.covers(e,c)||(o=await this.getSlice(e,c));const s={};let u=e+(this.bigTiff?8:2);for(let y=0;y<r;u+=i,++y){const m=o.readUint16(u),g=o.readUint16(u+2),f=this.bigTiff?o.readUint64(u+4):o.readUint32(u+4);let w,p;const P=Ve(g),S=u+(this.bigTiff?12:8);if(P*f<=(this.bigTiff?8:4))w=ge(o,g,f,S);else{const v=o.readOffset(S),M=Ve(g)*f;if(o.covers(v,M))w=ge(o,g,f,v);else{const V=await this.getSlice(v,M);w=ge(V,g,f,v)}}f===1&&lr.indexOf(m)===-1&&!(g===N.RATIONAL||g===N.SRATIONAL)?p=w[0]:p=w,s[Ie[m]]=p}const l=kr(s),h=o.readOffset(e+n+i*r);return new Ur(s,l,h)}async requestIFD(e){if(this.ifdRequests[e])return this.ifdRequests[e];if(e===0)return this.ifdRequests[e]=this.parseFileDirectoryAt(this.firstIFDOffset),this.ifdRequests[e];if(!this.ifdRequests[e-1])try{this.ifdRequests[e-1]=this.requestIFD(e-1)}catch(i){throw i instanceof Re?new Re(e):i}return this.ifdRequests[e]=(async()=>{const i=await this.ifdRequests[e-1];if(i.nextIFDByteOffset===0)throw new Re(e);return this.parseFileDirectoryAt(i.nextIFDByteOffset)})(),this.ifdRequests[e]}async getImage(e=0){const i=await this.requestIFD(e);return new Or(i.fileDirectory,i.geoKeyDirectory,this.dataView,this.littleEndian,this.cache,this.source)}async getImageCount(){let e=0,i=!0;for(;i;)try{await this.requestIFD(e),++e}catch(n){if(n instanceof Re)i=!1;else throw n}return e}async getGhostValues(){const e=this.bigTiff?16:8;if(this.ghostValues)return this.ghostValues;const i="GDAL_STRUCTURAL_METADATA_SIZE=",n=i.length+100;let o=await this.getSlice(e,n);if(i===ge(o,N.ASCII,i.length,e)){const c=ge(o,N.ASCII,n,e).split(`
|
|
4
|
+
`)[0],s=Number(c.split("=")[1].split(" ")[0])+c.length;s>n&&(o=await this.getSlice(e,s));const u=ge(o,N.ASCII,s,e);this.ghostValues={},u.split(`
|
|
5
|
+
`).filter(l=>l.length>0).map(l=>l.split("=")).forEach(([l,h])=>{this.ghostValues[l]=h})}return this.ghostValues}static async fromSource(e,i,n){const o=(await e.fetch([{offset:0,length:1024}],n))[0],r=new Rr(o),c=r.getUint16(0,0);let s;if(c===18761)s=!0;else if(c===19789)s=!1;else throw new TypeError("Invalid byte order value.");const u=r.getUint16(2,s);let l;if(u===42)l=!1;else if(u===43){if(l=!0,r.getUint16(4,s)!==8)throw new Error("Unsupported offset byte-size.")}else throw new TypeError("Invalid magic number.");const h=l?r.getUint64(8,s):r.getUint32(4,s);return new Ze(e,s,l,h,i)}close(){return typeof this.source.close=="function"?this.source.close():!1}}async function Kr(t,e){return Ze.fromSource(Gr(t),e)}function jr(t){const e=G.ref([]);let i=null,n={min:null,max:null,originalMin:null,originalMax:null};async function o(l,h=["#000000","#FFFFFF"]){console.log("Adding TIF layer with URL/File:",l,h);const y=`tif-layer-${new Date().getTime()}`;if(l instanceof File){const m=await R.readFileAsArrayBuffer(l);await r(m,h,y),e.value.push(y)}else if(typeof l=="string"){const g=await(await fetch(l)).arrayBuffer();await r(g,h,y),e.value.push(y)}return{tifId:y,dataRange:n}}async function r(l,h=["#000000","#FFFFFF"],y="geotiff-layer"){var q;const g=await(await Kr(l)).getImage(),f=g.getWidth(),w=g.getHeight(),p=R.calculateBounds(g),P=await g.readRasters();i={image:g,data:P,width:f,height:w},console.log("GeoTIFF data loaded:",i);const S=Array.isArray(P)?P:[P];let v=1/0,M=-1/0;for(const K of S)for(const k of K)k>-1e10&&(v=Math.min(v,k),M=Math.max(M,k));(!isFinite(v)||!isFinite(M)||v>=M)&&(console.warn("无效的数据范围,使用默认值"),v=0,M=255),n={min:v,max:M,originalMin:v,originalMax:M};const V=u(P,f,w,h);if(!V){console.error("Failed to create image data from GeoTIFF.");return}c(V,f,w,p,y),(q=t.value)==null||q.fitBounds([[p[0],p[1]],[p[2],p[3]]],{padding:50})}function c(l,h,y,m,g="geotiff-layer"){var v,M,V,q;const f=g,w=g+"-source";(v=t.value)!=null&&v.getLayer(f)&&t.value.removeLayer(f),(M=t.value)!=null&&M.getSource(w)&&t.value.removeSource(w);const p=document.createElement("canvas");p.width=h,p.height=y;const P=p.getContext("2d");P==null||P.putImageData(l,0,0);const S=p.toDataURL("image/png");(V=t.value)==null||V.addSource(w,{type:"image",url:S,coordinates:[[m[0],m[3]],[m[2],m[3]],[m[2],m[1]],[m[0],m[1]]]}),(q=t.value)==null||q.addLayer({id:f,type:"raster",source:w,paint:{"raster-opacity":.8}})}function s(l){var g,f;const h=l,y=l+"-source";(g=t.value)!=null&&g.getLayer(h)&&t.value.removeLayer(h),(f=t.value)!=null&&f.getSource(y)&&t.value.removeSource(y);const m=e.value.indexOf(l);m!==-1&&e.value.splice(m,1)}function u(l,h,y,m){const g=document.createElement("canvas");g.width=h,g.height=y;const f=g.getContext("2d"),w=f==null?void 0:f.createImageData(h,y),p=Array.isArray(l)?l:[l],P=h*y;let S=n.min,v=n.max;(S===null||v===null)&&(S=0,v=255);const M=m.map(R.hexToRgb),V=M.length;function q(K){if(V===1||K<=0)return M[0];if(K>=1)return M[V-1];const k=1/(V-1),Y=Math.floor(K/k),$=(K-Y*k)/k,z=M[Y],J=M[Math.min(Y+1,V-1)];return[Math.round(z[0]+(J[0]-z[0])*$),Math.round(z[1]+(J[1]-z[1])*$),Math.round(z[2]+(J[2]-z[2])*$)]}for(let K=0;K<P;K++){let k,Y,$,z;if(p.length>=3)k=Math.floor(255*R.clamp((p[0][K]-S)/(v-S),0,1)),Y=Math.floor(255*R.clamp((p[1][K]-S)/(v-S),0,1)),$=Math.floor(255*R.clamp((p[2][K]-S)/(v-S),0,1)),z=255;else if(p.length===1){const J=p[0][K];if(J<S)z=0,k=Y=$=0;else if(J>v)k=255,Y=$=0,z=255;else{const ee=(J-S)/(v-S),te=.15;if(ee<te)k=Y=$=0,z=0;else{const re=(ee-te)/(1-te);[k,Y,$]=q(re),z=255}}}else{const ee=(p[0][K]-S)/(v-S);ee<.15?(k=Y=$=0,z=0):(k=Y=$=Math.floor(255*(ee-.15)/.85),z=255)}w.data[K*4]=k,w.data[K*4+1]=Y,w.data[K*4+2]=$,w.data[K*4+3]=z}return f==null||f.putImageData(w,0,0),w}return{addTifLayer:o,processGeoTIFF:r,removeTifLayer:s}}const qr=["id"],zr={class:"left-bar"},Yr={class:"right-bar"},$r={class:"bottom-bar"},Zr=G.defineComponent({name:"MapView",__name:"MapView",props:{mapRootId:{default:"mapbox-map"},tdtToken:{},mapBoxToken:{},maxZoom:{default:17},minZoom:{default:3},zoom:{default:10},pitch:{default:60},hasScale:{type:Boolean,default:!0},scalePosition:{default:"bottom-right"},center:{},dbfDataRequest:{type:Function},researchDataRequest:{type:Function},dialogConfig:{default:()=>({center:!1,top:"50px",customClass:"hiper-map-dialog"})},loadIcon:{type:Boolean,default:!0}},emits:["mapReady"],setup(t,{expose:e,emit:i}){const n=G.useTemplateRef("mapRoot"),o=Pt.useMapStore();t.dialogConfig&&o.setDialogConfig(t.dialogConfig);const r=G.ref(),{addTifLayer:c,processGeoTIFF:s,removeTifLayer:u}=jr(r),l=i,h=()=>{var d;he.accessToken=t.mapBoxToken;const a=o.mapInstances[t.mapRootId];if(r.value=new he.Map({container:t.mapRootId,style:o.getCurrentMapStyle(t.mapRootId),center:a.center,zoom:a.zoom,pitch:a.pitch,bearing:0,antialias:!0,maxZoom:a.maxZoom,minZoom:a.minZoom,attributionControl:!1}),r.value.on("load",()=>{r.value&&(z(),l("mapReady",r.value)),le.mapLoadedBus.emit({mapRootId:t.mapRootId})}),r.value.on("zoomend",()=>{var I;o.setZoom(t.mapRootId,((I=r.value)==null?void 0:I.getZoom())||0)}),t.hasScale){const I=new he.ScaleControl({maxWidth:80,unit:"metric"});(d=r.value)==null||d.addControl(I,t.scalePosition)}r.value.on("load",()=>{})},y=()=>{var a,d;(a=r.value)==null||a.setStyle(o.getCurrentMapStyle(t.mapRootId)),(d=r.value)==null||d.once("styledata",()=>{console.log("地图样式更新完成,重新加载图层"),f.value.forEach(I=>{w(I)}),le.mapStyleChangedBus.emit({mapRootId:t.mapRootId})})},m=G.ref(!1),g=()=>{if(r.value){const a=o.mapInstances[t.mapRootId];m.value=!0,r.value.flyTo({center:a.center,zoom:a.zoom,bearing:0,pitch:a.threeDPitch,duration:2e3}),a.is3DMode=a.threeDPitch>0,a.pitch=a.threeDPitch,setTimeout(()=>{m.value=!1},2e3)}},f=G.ref([]),w=a=>{var I;if(!r.value){console.warn("地图实例未初始化,无法添加图层");return}const d=f.value.find(D=>D.id===a.id);if(d?Object.assign(d,a):f.value.push(a),a.geoJSON)console.log("渲染geoJSON---->"),P(a);else{const D=R.getLayerId(a);((I=r.value)==null?void 0:I.getLayer(D))==null?(console.log("首次渲染---->"),S(a)):(console.log("非首次渲染---->更新图层"),p(a,JSON.parse(a.layerPaintConfig)))}};function p(a,d){var B,b,O,F,E,L,j,Z,Q,H,ie,xe,de,Xe,Je,He,Qe,We;d.fillColorList&&d.fillColorList.length&&(d.fillColorList=d.fillColorList.filter(U=>U.key&&U.value||U.type=="default"));const I=R.getLayerType(a);console.log("currentLayerType--->",I);const D=JSON.parse(JSON.stringify(d));console.log("newStyleConfig---->",D);const T=R.getFillStyle(D);console.log("newFillColorConfig---->",T);const x=R.getOutLineStyle(D);if(console.log("outlineStyle---->",x),I=="fill"&&T&&x)(B=r.value)==null||B.setPaintProperty(R.getLayerId(a),"fill-color",T["fill-color"]),(b=r.value)==null||b.setPaintProperty(R.getLayerId(a),"fill-opacity",T["fill-opacity"]),(O=r.value)==null||O.setPaintProperty(R.getLayerId(a),"fill-outline-color",T["fill-outline-color"]),x&&x["line-color"]&&((F=r.value)==null||F.setPaintProperty(R.getLayerId(a)+"-outline","line-color",x["line-color"])),x&&x["line-opacity"],x&&x["line-width"]&&((E=r.value)==null||E.setPaintProperty(R.getLayerId(a)+"-outline","line-width",x["line-width"])),(L=r.value)==null||L.setPaintProperty(R.getLayerId(a)+"-outline","line-dasharray",[]),x&&x["line-dasharray"]&&(console.log("outlineStyle['line-dasharray']----->",x["line-dasharray"]),(j=r.value)==null||j.setPaintProperty(R.getLayerId(a)+"-outline","line-dasharray",x["line-dasharray"]));else if(I=="line")x&&x["line-color"]&&((Z=r.value)==null||Z.setPaintProperty(R.getLayerId(a),"line-color",x["line-color"])),x&&x["line-opacity"]&&((Q=r.value)==null||Q.setPaintProperty(R.getLayerId(a),"line-opacity",x["line-opacity"])),x&&x["line-width"]&&((H=r.value)==null||H.setPaintProperty(R.getLayerId(a),"line-width",x["line-width"])),(ie=r.value)==null||ie.setPaintProperty(R.getLayerId(a),"line-dasharray",[]),x&&x["line-dasharray"]&&((xe=r.value)==null||xe.setPaintProperty(R.getLayerId(a),"line-dasharray",x["line-dasharray"]));else if(I=="circle"){const U=R.getCircleStyle(D);U&&U["circle-color"]&&((de=r.value)==null||de.setPaintProperty(R.getLayerId(a),"circle-color",U["circle-color"])),U&&U["circle-opacity"]&&((Xe=r.value)==null||Xe.setPaintProperty(R.getLayerId(a),"circle-opacity",U["circle-opacity"])),U&&U["circle-radius"]&&((Je=r.value)==null||Je.setPaintProperty(R.getLayerId(a),"circle-radius",U["circle-radius"])),U&&U["circle-stroke-color"]&&((He=r.value)==null||He.setPaintProperty(R.getLayerId(a),"circle-stroke-color",U["circle-stroke-color"])),U&&U["circle-stroke-width"]&&((Qe=r.value)==null||Qe.setPaintProperty(R.getLayerId(a),"circle-stroke-width",U["circle-stroke-width"]))}else if(I=="symbol"){const U=R.getCircleStyle(D);U&&U["icon-image"]&&((We=r.value)==null||We.setLayoutProperty(R.getLayerId(a),"icon-image",U["icon-image"]))}const A=[];let{symbolConfigList:C}=D;C=C.filter(U=>U.fontSize&&U.field&&U.textColor),C.forEach((U,Jr)=>{var _e,et,tt,rt;const Te="points-symbol-"+a.id+U.field,bt=R.getSourceId(a);((_e=r.value)==null?void 0:_e.getLayer(Te))?((tt=r.value)==null||tt.setLayoutProperty(Te,"text-size",U.fontSize),(rt=r.value)==null||rt.setPaintProperty(Te,"text-color",U.textColor)):((et=r.value)==null||et.addLayer({id:Te,type:"symbol",source:bt,layout:{visibility:"visible","text-field":["get",U.field],"text-size":U.fontSize,"symbol-avoid-edges":!0,"icon-image":"circle-11","text-ignore-placement":!1,"text-max-angle":38},paint:{"text-color":U.textColor}}),A.push(U.field))})}function P(a){var x,A,C,B,b,O,F,E,L,j;if(!a.customLayerConfig||!a.geoJSON){console.warn("图层配置缺失,无法渲染图层");return}const d=JSON.parse(a.customLayerConfig),I=R.getLayerId(a);((x=r.value)==null?void 0:x.getLayer(I))!==void 0&&(console.warn(`图层 ${I} 已存在,无法重复添加`),(A=r.value)==null||A.removeLayer(I),(C=r.value)==null||C.removeSource(I));const T=JSON.parse(a.geoJSON);switch(a.layerType){case"symbol":const Z={id:I,type:"symbol",source:{type:"geojson",data:{type:"FeatureCollection",features:[{type:"Feature",geometry:{type:"Point",coordinates:T.features[0].geometry.coordinates},properties:{title:a.layerName||d.iconName,icon:`${d.iconName}`}}]}},layout:{"icon-image":"{icon}","icon-size":.1,"icon-anchor":"center","text-field":"{title}","text-font":["Open Sans Semibold","Arial Unicode MS Bold"],"text-offset":[0,1.8],"text-anchor":"center","text-size":12,"text-allow-overlap":!0,"text-optional":!0},paint:{"text-color":d.textColor,"text-halo-color":"rgba(0,0,0,0.32)","text-halo-width":1,"text-halo-blur":2,"text-translate":[0,0]}};(B=r.value)==null||B.addLayer(Z);break;case"line":const Q={id:I,type:"line",source:{type:"geojson",data:T},layout:{"line-join":"round","line-cap":"round"},paint:{"line-color":d.lineColor,"line-width":Number(d.lineWidth)}};d.lineStyle=="dotted"&&(Q.paint["line-dasharray"]=[5.2,5.2]),(b=r.value)==null||b.addLayer(Q);break;case"shape":let H=I+"-outline";const ie={id:H,type:"line",source:{type:"geojson",data:JSON.parse(a.geoJSON)},layout:{"line-join":"round","line-cap":"round"},paint:{"line-color":d.fillColor,"line-width":Number(d.lineWidth)}};((O=r.value)==null?void 0:O.getLayer(H))!==void 0&&((F=r.value)==null||F.removeLayer(H),(E=r.value)==null||E.removeSource(H)),(L=r.value)==null||L.addLayer(ie);const de={id:I,type:"fill",source:{type:"geojson",data:T},layout:{},paint:{"fill-color":d.fillColor,"fill-opacity":.32}};(j=r.value)==null||j.addLayer(de);break}}function S(a){var C,B,b,O,F;console.log("加载图层---->",a);const d=R.getLayerId(a),I=R.getSourceId(a);console.log("sourceId--->",I);const D=R.parseStyleConfig(a);console.log("styleConfig",D);const T=R.getLayerType(a);((C=r.value)==null?void 0:C.getSource(I))||(b=r.value)==null||b.addSource(I,{type:"geojson",data:(B=a.url)==null?void 0:B.replace("bjhweb","bjh")}),console.log("layerType--->",T);const A={id:d,source:I,name:d,layout:{visibility:"visible"},type:T};if(T!="symbol")A.paint=R.getLayerStyle(a);else{const E=R.getLayerStyle(a);A.layout={visibility:"visible","symbol-placement":"line","symbol-spacing":10,"icon-size":.1,"icon-keep-upright":!0,"icon-rotate":0,"icon-allow-overlap":!0,...E}}if(console.log("layerConfig--->",A),(O=r.value)==null||O.addLayer(A),T=="fill"){const E=R.getOutLineStyle(D);(F=r.value)==null||F.addLayer({id:d+"-outline",source:I,name:d+"-outline",layout:{visibility:"visible","line-join":"round","line-cap":"round"},type:"line",paint:{"line-color":E["line-color"],"line-width":E["line-width"],"line-dasharray":E["line-dasharray"]||[]}})}}const v=G.ref([]);function M(a){if(!r.value){console.warn("地图实例未初始化,无法添加调查数据图层");return}$(a);const d=a.pointInfo?a.pointInfo:JSON.parse(a.rowDataInstance??"{}");let I=null;if(d.latitude&&d.longitude&&(I=[parseFloat(d.longitude),parseFloat(d.latitude)]),d.latitudeStart&&d.longitudeStart&&(I=[parseFloat(d.longitudeStart),parseFloat(d.latitudeStart)]),a.layerType=="line"){const D={outlineColor:"#02d2e0",outlineWidth:3};let T=a.layerPaintConfig?JSON.parse(a.layerPaintConfig):D;if(!a.lineInfo){console.error("调查数据缺失,无法添加线图层");return}const x=a.lineInfo;let A=[];I&&I.length&&A.push(I),x.forEach(L=>{A.push([Number(L.longitude),Number(L.latitude)])});const B={type:"geojson",data:{type:"FeatureCollection",features:[{type:"Feature",geometry:{type:"LineString",coordinates:A}}]}},b=`${a.id}-geo-line-source`,O=r.value.getSource(b),F=`${a.id}-geo-line-layer`,E=r.value.getLayer(F);if(A.length>0){O||r.value.addSource(b,B),E&&r.value.removeLayer(F);let L={"line-color":T.outlineColor,"line-width":T.outlineWidth,"line-opacity":1};switch(T.outlineStyle){case"simple-dash":L["line-dasharray"]=[2,2];break;case"dot-dash":L["line-dasharray"]=[1,2,3,2];break;case"long-dash":L["line-dasharray"]=[4,2];break;case"dot-line":L["line-dasharray"]=[.1,2];break;case"complex-pattern":L["line-dasharray"]=[2,2,1,2];break}r.value.addLayer({id:F,type:"line",source:b,paint:L})}r.value.easeTo({zoom:17,center:A[0]})}else{const D={pointTintColor:"#02d2e0",pointRenderType:"points"};let T=a.layerPaintConfig?JSON.parse(a.layerPaintConfig):D;if(console.log("走这里---->",a),!a.lineInfo){console.error("调查数据缺失,无法添加点图层");return}if(!r.value){console.warn("地图实例未初始化,无法添加点图层");return}a.lineInfo.forEach(x=>{var E;let A=[0,0];x.latitude&&x.longitude&&(A=[Number(x.longitude),Number(x.latitude)]),x.latitudeStart&&x.longitudeStart&&(A=[Number(x.longitudeStart),Number(x.latitudeStart)]),console.log("layerPaintConfig.pointRenderType ",T);const C=document.createElement("div");if(T.pointRenderType=="icons"){C.className="research-location-icon-el";const L=document.createElement("img");L.className="research-location-img-el",L.src=be.mapIconBaseUrl+T.currentMapIconName,C.appendChild(L)}else{C.className="research-location-point";const L=document.createElement("div");L.className="research-location-point-content",C.appendChild(L);const j=document.createElement("div");j.className="research-location-point-content-inner",j.style.backgroundColor=T.pointTintColor?T.pointTintColor:"#02d2e0",L.appendChild(j);const Z=document.createElement("div");Z.className="research-location-point-line",C.appendChild(Z)}C.onclick=L=>{Y(L,JSON.parse(a.rowDataInstance??"{}"))};const B=`${a.id}-research-point`,b=v.value.find(L=>L.id==B);b&&b.marker&&((E=b.marker)==null||E.remove());let O=new he.Marker(C).setLngLat(A).setOffset([0,-22]).addTo(r.value),F=-1;v.value.forEach((L,j)=>{L.id==B&&(F=j)}),F>-1?v.value[F].marker=O:v.value.push({id:B,marker:O})})}K()}const V=G.ref(),q=G.ref();function K(){V.value&&V.value.hidePopup(),q.value&&q.value.hidePopup(),k.value&&k.value.hidePopup()}const k=G.ref();function Y(a,d){const{clientX:I,clientY:D}=a,T=I+28,x=D-60;k.value.showPopup(T,x,d)}function $(a){const d=f.value.find(I=>I.id===a.id);d?Object.assign(d,a):f.value.push(a)}function z(){if(!t.loadIcon)return Promise.resolve(!0);if(!r.value)return Promise.reject(new Error("地图实例未初始化,无法加载图标资源"));const a=be.mapIconNameList.map(d=>new Promise((I,D)=>{var T;(T=r.value)==null||T.loadImage(be.mapIconBaseUrl+d.fileName,(x,A)=>{var C;x?D(x):(A&&((C=r.value)==null||C.addImage(d.fileName,A)),I(!0))})}));return Promise.all(a)}function J(a){var x,A,C,B,b,O,F,E;console.log("removeThirdPartyLayer---->",a);const d=R.getLayerId(a),I=R.getLayerType(a),D=(x=r.value)==null?void 0:x.getLayer(d);console.log("currentLayerType---->",I,D);let T=-1;if(f.value.forEach((L,j)=>{L.id==a.id&&(T=j)}),T>-1&&f.value.splice(T,1),D){const L=(A=r.value)==null?void 0:A.getLayer(d);if(L){const j=L.source;(C=r.value)==null||C.removeLayer(d),a.geoJSON&&j&&((B=r.value)==null||B.removeSource(j))}}if(I=="fill"){console.log("移除边框----->");const L=d+"-outline",j=(b=r.value)==null?void 0:b.getLayer(L),Z=(O=r.value)==null?void 0:O.getLayer(L);if(Z){const Q=Z.source;j&&((F=r.value)==null||F.removeLayer(L)),a.geoJSON&&Q&&((E=r.value)==null||E.removeSource(Q))}}K()}G.watch(()=>{var a;return(a=o.mapInstances[t.mapRootId])==null?void 0:a.activeMapLayer},()=>{r.value&&y()},{immediate:!0}),G.watch(()=>{var a;return(a=o.mapInstances[t.mapRootId])==null?void 0:a.zoom},()=>{r.value&&!m.value&&r.value.flyTo({zoom:o.mapInstances[t.mapRootId].zoom,duration:500})},{immediate:!0}),G.watch(()=>{var a;return(a=o.mapInstances[t.mapRootId])==null?void 0:a.pitch},()=>{r.value&&!m.value&&(o.isDragging?r.value.setPitch(o.mapInstances[t.mapRootId].pitch):r.value.flyTo({pitch:o.mapInstances[t.mapRootId].pitch,duration:1e3}))},{immediate:!0}),G.watch(()=>{var a;return(a=o.mapInstances[t.mapRootId])==null?void 0:a.bearing},()=>{r.value&&!m.value&&(o.isDragging?r.value.setBearing(o.mapInstances[t.mapRootId].bearing):r.value.flyTo({bearing:o.mapInstances[t.mapRootId].bearing,duration:1e3}))},{immediate:!0});const ee=a=>{r.value&&(r.value.flyTo({zoom:4,duration:400}),setTimeout(async()=>{var T,x,A,C,B;if(!a)return;let d=R.getSourceId(a);if(a.geoJSON&&(d=R.getLayerId(a)),a.url&&!a.geoJSON)try{const b=a.url.replace("bjhweb","bjh"),F=await(await fetch(b)).json();if(F&&F.features&&F.features.length>0){const E=Le.bbox(F);if(E&&!te(E)){(T=r.value)==null||T.fitBounds([[E[0],E[1]],[E[2],E[3]]],{padding:{top:50,bottom:50,left:50,right:50}});return}}}catch(b){console.warn("从URL获取GeoJSON数据失败,尝试其他方法",b)}const I=(x=r.value)==null?void 0:x.getSource(d);if(I&&I._data&&I._data.features){const b=I._data,O=Le.bbox(b);if(!te(O)){(A=r.value)==null||A.fitBounds([[O[0],O[1]],[O[2],O[3]]],{padding:{top:50,bottom:50,left:50,right:50}});return}}const D=(C=r.value)==null?void 0:C.querySourceFeatures(d);if(D&&D.length>0){const b=Le.featureCollection(D),O=Le.bbox(b);te(O)?console.warn("获取的边界框无效"):(B=r.value)==null||B.fitBounds([[O[0],O[1]],[O[2],O[3]]],{padding:{top:50,bottom:50,left:50,right:50}})}else console.warn("没有查询到图层数据")},500))};function te(a){return a[0]===1/0||a[1]===1/0||a[2]===-1/0||a[3]===-1/0||isNaN(a[0])||isNaN(a[1])||isNaN(a[2])||isNaN(a[3])}G.provide("resetMapView",g),G.provide("mapRootId",t.mapRootId),t.dbfDataRequest&&G.provide(Pe.dbfDataRequestKey,t.dbfDataRequest),t.researchDataRequest&&G.provide(Pe.researchDataRequestKey,t.researchDataRequest),G.provide(Pe.mapInstanceKey,r),G.provide(Pe.thirdPartyLayersKey,f);const re=({mapRootId:a,layer:d})=>{a===a&&(console.log("接收到渲染地理数据事件",d),d.layerDataType=="research"&&w(d))};le.renderGeographicDataKeyBus.on(re),e({mapInstance:r,initMap:h,handleSetMapStyle:y,resetMapView:g,addThirdPartyLayer:w,addResearchMapLayer:M,addTifLayer:c,processGeoTIFF:s,removeTifLayer:u}),G.onBeforeMount(()=>{o.mapInstances[t.mapRootId]={maxZoom:t.maxZoom,minZoom:t.minZoom,zoom:t.zoom,pitch:t.pitch,threeDPitch:t.pitch,center:t.center||[120.1551,30.2741],bearing:0,is3DMode:t.pitch>0,activeMapLayer:Lt.MapLayerType.SATELLITE,mapHeight:600,mapWidth:600,mapX:0,mapY:0}});function Fe(a){var D,T,x,A;$(a);const d={outlineColor:"#02d2e0",outlineWidth:3,outlineOpacity:.72,pointTintColor:"#02d2e0"};let I=a.layerPaintConfig?JSON.parse(a.layerPaintConfig):d;if(console.log("layerPaintConfig--->",I),I.pointRenderType&&I.pointRenderType=="heatMap"){let C=a.id+"-source",B=a.id+"-layer",b=[];a.children&&a.children.forEach(O=>{let F=[0,0];const E=JSON.parse(O.rowDataInstance);E.latitude&&E.longitude&&(F=[Number(E.longitude),Number(E.latitude)]),E.latitudeStart&&E.longitudeStart&&(F=[Number(E.longitudeStart),Number(E.latitudeStart)]),b.push({type:"Feature",properties:{},geometry:{type:"Point",coordinates:F}})}),(D=r.value)==null||D.addSource(C,{type:"geojson",data:{type:"FeatureCollection",features:b}}),(T=r.value)==null||T.addLayer({id:B,type:"heatmap",source:C,maxzoom:9,paint:{"heatmap-weight":1,"heatmap-intensity":["interpolate",["linear"],["zoom"],0,1,9,3],"heatmap-color":["interpolate",["linear"],["heatmap-density"],0,"rgba(33,102,172,0)",.2,"blue",.4,"cyan",.6,"lime",.8,"yellow",1,"red"],"heatmap-radius":["interpolate",["linear"],["zoom"],0,2,9,20],"heatmap-opacity":["interpolate",["linear"],["zoom"],7,1,9,0]}})}else I.pointRenderType&&I.pointRenderType=="icons"?(console.log("走这里----->, icons",v.value),console.log("mapLayer.children",a.children),(x=a.children)==null||x.forEach(C=>{var j;let B=[0,0];const b=JSON.parse(C.rowDataInstance);b.latitude&&b.longitude&&(B=[Number(b.longitude),Number(b.latitude)]),b.latitudeStart&&b.longitudeStart&&(B=[Number(b.longitudeStart),Number(b.latitudeStart)]);const O=document.createElement("div");O.className="research-location-icon-el";const F=document.createElement("img");F.className="research-location-img-el",F.src=be.mapIconBaseUrl+I.currentMapIconName,O.appendChild(F);const E=`${C.id}-research-point`,L=v.value.find(Z=>Z.id==E);if(L&&L.marker&&((j=L.marker)==null||j.remove()),r.value){let Z=new he.Marker(O).setLngLat(B).setOffset([0,-22]).addTo(r.value),Q=-1;v.value.forEach((H,ie)=>{H.id==E&&(Q=ie)}),Q>-1?v.value[Q].marker=Z:v.value.push({id:E,marker:Z})}})):(A=a.children)==null||A.forEach(C=>{var Q;let B=[0,0];const b=JSON.parse(C.rowDataInstance);b.latitude&&b.longitude&&(B=[Number(b.longitude),Number(b.latitude)]),b.latitudeStart&&b.longitudeStart&&(B=[Number(b.longitudeStart),Number(b.latitudeStart)]);const O=document.createElement("div");O.className="research-location-point";const F=document.createElement("div");F.className="research-location-point-content",O.appendChild(F);const E=document.createElement("div");E.className="research-location-point-content-inner",E.style.backgroundColor=I.pointTintColor?I.pointTintColor:"#02d2e0",F.appendChild(E);const L=document.createElement("div");L.className="research-location-point-line",O.appendChild(L),O.onclick=H=>{console.log(H)};const j=`${C.id}-research-point`,Z=v.value.find(H=>H.id==j);if(Z&&Z.marker&&((Q=Z.marker)==null||Q.remove()),r.value){let H=new he.Marker(O).setLngLat(B).setOffset([0,-22]).addTo(r.value),ie=-1;v.value.forEach((xe,de)=>{xe.id==j&&(ie=de)}),ie>-1?v.value[ie].marker=H:v.value.push({id:j,marker:H})}});K()}function Be(a){var x,A,C;se(a);const d=`${a.id}-geo-line-layer`,I=`${a.id}-research-point`;((x=r.value)==null?void 0:x.getLayer(d))&&((A=r.value)==null||A.removeLayer(d));let T=-1;v.value.forEach((B,b)=>{B.id==I&&(T=b)}),T>-1&&(v.value[T].marker&&((C=v.value[T].marker)==null||C.remove()),v.value.splice(T,1)),K()}const ue=async({mapRootId:a,topic:d,visible:I,delLayer:D})=>{var T;if(console.log("接收到图层切换事件",t.mapRootId,a,d),a===t.mapRootId&&r.value)if(I)if(console.log("delLayer",D),D&&(console.log("mmb: 删除图层",d),J(d)),d.layerType=="species-group")Fe(d);else if(d.layerDataType=="research"){if(d.layerType=="line"||d.layerType=="symbol"){if(!d.lineInfo){const x=await((T=t.researchDataRequest)==null?void 0:T.call(t,d));if(x){const{lineInfo:A,pointInfo:C}=x;d.lineInfo=A,d.pointInfo=C}}M(d)}}else w(d);else d.layerType=="species-group"?fe(d):d.layerDataType=="research"?Be(d):J(d)};function se(a){let d=-1;f.value.forEach((I,D)=>{I.id==a.id&&(d=D)}),d>-1&&f.value.splice(d,1)}function fe(a){var d,I,D;if(se(a),a.layerPaintConfig){const T=JSON.parse(a.layerPaintConfig);if(T&&T.pointRenderType=="heatMap"){let x=a.id+"-source",A=a.id+"-layer";(d=r.value)==null||d.removeLayer(A),(I=r.value)==null||I.removeSource(x)}else(D=a.children)==null||D.forEach(x=>{var O,F,E;const A=`${x.id}-geo-line-layer`,C=`${x.id}-research-point`;((O=r.value)==null?void 0:O.getLayer(A))&&((F=r.value)==null||F.removeLayer(A));let b=-1;v.value.forEach((L,j)=>{L.id==C&&(b=j)}),b>-1&&(v.value[b].marker&&((E=v.value[b].marker)==null||E.remove()),v.value.splice(b,1))})}K()}const Se=({mapRootId:a,layer:d})=>{a===t.mapRootId&&(console.log("接收到定位到图层中心事件",d),r.value&&ee(d))};return G.onMounted(()=>{var a,d,I,D;o.setMapBoxToken(t.mapBoxToken),o.setTdtToken(t.tdtToken),o.setMaxZoom(t.mapRootId,t.maxZoom),o.setMinZoom(t.mapRootId,t.minZoom),o.setZoom(t.mapRootId,t.zoom),o.setPitch(t.mapRootId,t.pitch),o.setThreeDPitch(t.mapRootId,t.pitch),t.center&&Array.isArray(t.center)&&t.center.length>0?(o.setCenter(t.mapRootId,t.center),h()):navigator.geolocation.getCurrentPosition(T=>{const{latitude:x,longitude:A}=T.coords;o.setCenter(t.mapRootId,[A,x]),h()},()=>{o.setCenter(t.mapRootId,[104.1954,35.8617]),o.setZoom(t.mapRootId,4),h()}),o.mapInstances[t.mapRootId]&&(o.mapInstances[t.mapRootId].mapHeight=((a=n.value)==null?void 0:a.clientHeight)??600,o.mapInstances[t.mapRootId].mapWidth=((d=n.value)==null?void 0:d.clientWidth)??600,o.mapInstances[t.mapRootId].mapX=((I=n.value)==null?void 0:I.getBoundingClientRect().left)??600,o.mapInstances[t.mapRootId].mapY=((D=n.value)==null?void 0:D.getBoundingClientRect().top)??600),console.log("mapStore.mapInstances[mapRootId]--->",t.mapRootId),le.toggleGeographicLayerKeyBus.on(ue),le.locateToLayerCenterKeyBus.on(Se)}),G.onUnmounted(()=>{console.log("组件卸载,清理事件监听"),le.renderGeographicDataKeyBus.off(re),le.toggleGeographicLayerKeyBus.off(ue),le.locateToLayerCenterKeyBus.off(Se)}),(a,d)=>(G.openBlock(),G.createElementBlock("div",{class:"qy-map",ref_key:"mapRoot",ref:n},[G.createElementVNode("div",{class:"hiper-map-warper",id:a.mapRootId},[G.createElementVNode("div",zr,[G.renderSlot(a.$slots,"leftBar",{},void 0,!0)]),G.createElementVNode("div",Yr,[G.renderSlot(a.$slots,"rightBar",{},void 0,!0)]),G.createElementVNode("div",{class:"top-bar",style:G.normalizeStyle({left:G.unref(o).topicVisible?G.unref(o).topicWidth+50+"px":"70px"})},[G.renderSlot(a.$slots,"topBar",{},void 0,!0)],4),G.createElementVNode("div",$r,[G.renderSlot(a.$slots,"bottomBar",{},void 0,!0)]),G.renderSlot(a.$slots,"default",{},void 0,!0)],8,qr)],512))}}),Xr=Ct._export_sfc(Zr,[["__scopeId","data-v-e8cac047"]]);exports.LercAddCompression=fr;exports.LercParameters=ur;exports.MapView=Xr;
|