@geoscene/core 4.34.8 → 4.34.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (95) hide show
  1. package/analysis/ViewshedVideo.js +5 -0
  2. package/analysis/viewshedVideo/ViewshedAnalysisView3DVideo.js +5 -0
  3. package/analysis/viewshedVideo/ViewshedComputedDataVideo.js +5 -0
  4. package/analysis/viewshedVideo/ViewshedSubVisualizationVideo.js +5 -0
  5. package/analysis/viewshedVideo/ViewshedVisualizationVideo.js +5 -0
  6. package/analysis/viewshedVideo/render/ViewshedTechniqueVideo.js +5 -0
  7. package/analysis/viewshedVideo/render/ViewshedVideo.glsl.js +243 -0
  8. package/analysis/viewshedVideo/render/ViewshedVideo.js +5 -0
  9. package/assets/geoscene/core/workers/chunks/0f4e9846d074864b39c2.js +1 -1
  10. package/assets/geoscene/core/workers/chunks/38b9ec5f73f2467262dc.js +1 -1
  11. package/assets/geoscene/core/workers/chunks/50e1c63d0b6196dd365e.js +1 -1
  12. package/assets/geoscene/core/workers/chunks/bc3df7ef6d001bb8192e.js +1 -1
  13. package/assets/geoscene/core/workers/chunks/db8d4a12a67a62ec3704.js +1 -1
  14. package/assets/geoscene/core/workers/chunks/dfbf2e17058aa876f96a.js +1 -1
  15. package/bundle/lib/fflate.js +12 -0
  16. package/interfaces.d.ts +15 -0
  17. package/layers/MapImageTileLayer.js +355 -0
  18. package/layers/mixins/SceneService.js +1 -1
  19. package/layers/mixins/SublayersOwner.js +1 -1
  20. package/layers/mixins/operationalLayers.js +1 -1
  21. package/layers/support/LercWorker.js +1 -5
  22. package/layers/support/layersCreator.js +1 -1
  23. package/layers/support/lazyLayerLoader.js +1 -1
  24. package/layers/support/rasterDatasets/ImageServerRaster.js +1 -1
  25. package/layers/support/rasterFormats/ImageCanvasDecoder.js +1 -1
  26. package/layers/support/rasterFormats/RasterCodec.js +1 -1
  27. package/layers/voxel/drill/VoxelContinuousDrill.js +5 -0
  28. package/layers/voxel/drill/VoxelDiscreteDrill.js +5 -0
  29. package/layers/voxel/drill/common.js +5 -0
  30. package/package.json +1 -1
  31. package/portal/support/portalLayers.js +1 -1
  32. package/rest/query/executeQueryFGB.js +1 -0
  33. package/rest/query/operations/flatgeobufGeojson.js +3 -0
  34. package/rest/query/operations/flatgeobufGeojson.min.js +15 -0
  35. package/rest/query/operations/query.js +1 -1
  36. package/rest/query.d.ts +1 -0
  37. package/rest/query.js +1 -1
  38. package/views/3d/analysis/analysisViewModuleImportUtils.js +1 -1
  39. package/views/3d/layers/I3SMeshView3D.js +1 -1
  40. package/views/3d/layers/ImageryTileLayerView3D.js +1 -1
  41. package/views/3d/layers/IntegratedMesh3DTilesLayerView3D.js +1 -1
  42. package/views/3d/layers/IntegratedMeshLayerView3D.js +1 -1
  43. package/views/3d/layers/ViewshedLayerView3D.js +1 -1
  44. package/views/3d/layers/i3s/I3SIndex.js +1 -1
  45. package/views/3d/layers/i3s/I3SNodeLoader.js +1 -1
  46. package/views/3d/layers/support/LayerViewAnalysisViewManager.js +1 -1
  47. package/views/draw/expert/AttackArrowDrawer.js +5 -0
  48. package/views/draw/expert/AttackTailedArrowDrawer.js +5 -0
  49. package/views/draw/expert/BaseDrawer.js +5 -0
  50. package/views/draw/expert/Constant.js +5 -0
  51. package/views/draw/expert/CurveDrawer.js +5 -0
  52. package/views/draw/expert/CurveFlagDrawer.js +5 -0
  53. package/views/draw/expert/CurvedArrowDrawer.js +5 -0
  54. package/views/draw/expert/EllipseDrawer.js +5 -0
  55. package/views/draw/expert/ExpertDraw.js +5 -0
  56. package/views/draw/expert/GatheringPlaceDrawer.js +5 -0
  57. package/views/draw/expert/LuneDrawer.js +5 -0
  58. package/views/draw/expert/PincerArrowDrawer.js +5 -0
  59. package/views/draw/expert/SectorDrawer.js +5 -0
  60. package/views/draw/expert/SquadCombatDrawer.js +5 -0
  61. package/views/draw/expert/StraightArrowDrawer.js +5 -0
  62. package/views/draw/expert/TailedSquadCombatDrawer.js +5 -0
  63. package/views/draw/expert/plot/Constants.js +5 -0
  64. package/views/draw/expert/plot/PlotTypes.js +5 -0
  65. package/views/draw/expert/plot/plots/Arc.js +41 -0
  66. package/views/draw/expert/plot/plots/AssaultDirection.js +15 -0
  67. package/views/draw/expert/plot/plots/AttackArrow.js +5 -0
  68. package/views/draw/expert/plot/plots/Circle.js +5 -0
  69. package/views/draw/expert/plot/plots/ClosedCurve.js +5 -0
  70. package/views/draw/expert/plot/plots/Curve.js +5 -0
  71. package/views/draw/expert/plot/plots/CurveFlag.js +5 -0
  72. package/views/draw/expert/plot/plots/CurvedArrow.js +5 -0
  73. package/views/draw/expert/plot/plots/DoubleArrow.js +5 -0
  74. package/views/draw/expert/plot/plots/Ellipse.js +5 -0
  75. package/views/draw/expert/plot/plots/FineArrow.js +5 -0
  76. package/views/draw/expert/plot/plots/FreehandLine.js +19 -0
  77. package/views/draw/expert/plot/plots/FreehandPolygon.js +19 -0
  78. package/views/draw/expert/plot/plots/GatheringPlace.js +5 -0
  79. package/views/draw/expert/plot/plots/Lune.js +5 -0
  80. package/views/draw/expert/plot/plots/Marker.js +16 -0
  81. package/views/draw/expert/plot/plots/Plot.js +5 -0
  82. package/views/draw/expert/plot/plots/Polygon.js +18 -0
  83. package/views/draw/expert/plot/plots/Polyline.js +19 -0
  84. package/views/draw/expert/plot/plots/Rectangle.js +28 -0
  85. package/views/draw/expert/plot/plots/Sector.js +5 -0
  86. package/views/draw/expert/plot/plots/SquadCombat.js +5 -0
  87. package/views/draw/expert/plot/plots/StraightArrow.js +5 -0
  88. package/views/draw/expert/plot/plots/TailedAttackArrow.js +5 -0
  89. package/views/draw/expert/plot/plots/TailedSquadCombat.js +5 -0
  90. package/views/draw/expert/plot/utils/plot_util.js +5 -0
  91. package/views/layers/support/MapServiceLayerViewHelper.js +1 -1
  92. package/widgets/Features/FeaturesViewModel.js +1 -1
  93. package/widgets/LayerList/LayerListItem.js +1 -1
  94. package/widgets/Legend/LegendViewModel.js +1 -1
  95. package/widgets/Legend/support/ActiveLayerInfo.js +1 -1
@@ -2,4 +2,4 @@
2
2
  All material copyright GeoScene, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.geoscene.cn/4.34/geoscene/copyright.txt for details.
4
4
  */
5
- import t from"../../../core/Error.js";import{assertIsSome as e}from"../../../core/maybe.js";import a from"../PixelBlock.js";import{SimpleBandStatistics as i}from"../SimpleBandStatistics.js";import s from"./ImageCanvasDecoder.js";import r from"./JpgPlus.js";import{load as n,decode as o}from"./Lerc.js";import{decode as h}from"./Lzw.js";import{convertNoDataToMask as c}from"./pixelRangeUtils.js";import{Z as l}from"../../../chunks/Zlib.js";import{load as p,decode as d}from"./Qb3.js";import u from"./Raw.js";import{decodeTileOrStrip as f,decode as m}from"./TiffDecoder.js";import{isPlatformLittleEndian as g}from"./utils.js";var w=function(t){var e,a,i,s,r,n;function o(t){var e,a,i,s,r,n,o,h,c,l,p,d,u;for(this.data=t,this.pos=8,this.palette=[],this.imgData=[],this.transparency={},this.animation=null,this.text={},r=null;;){switch(e=this.readUInt32(),h=function(){var t,e;for(e=[],t=0;t<4;++t)e.push(String.fromCharCode(this.data[this.pos++]));return e}.call(this).join(""),h){case"IHDR":this.width=this.readUInt32(),this.height=this.readUInt32(),this.bits=this.data[this.pos++],this.colorType=this.data[this.pos++],this.compressionMethod=this.data[this.pos++],this.filterMethod=this.data[this.pos++],this.interlaceMethod=this.data[this.pos++];break;case"acTL":this.animation={numFrames:this.readUInt32(),numPlays:this.readUInt32()||1/0,frames:[]};break;case"PLTE":this.palette=this.read(e);break;case"fcTL":r&&this.animation.frames.push(r),this.pos+=4,r={width:this.readUInt32(),height:this.readUInt32(),xOffset:this.readUInt32(),yOffset:this.readUInt32()},s=this.readUInt16(),i=this.readUInt16()||100,r.delay=1e3*s/i,r.disposeOp=this.data[this.pos++],r.blendOp=this.data[this.pos++],r.data=[];break;case"IDAT":case"fdAT":for("fdAT"===h&&(this.pos+=4,e-=4),t=(null!=r?r.data:void 0)||this.imgData,p=0;0<=e?p<e:p>e;0<=e?++p:--p)t.push(this.data[this.pos++]);break;case"tRNS":switch(this.transparency={},this.colorType){case 3:if(this.transparency.indexed=this.read(e),(c=255-this.transparency.indexed.length)>0)for(d=0;0<=c?d<c:d>c;0<=c?++d:--d)this.transparency.indexed.push(255);break;case 0:this.transparency.grayscale=this.read(e)[0];break;case 2:this.transparency.rgb=this.read(e)}break;case"tEXt":n=(l=this.read(e)).indexOf(0),o=String.fromCharCode.apply(String,l.slice(0,n)),this.text[o]=String.fromCharCode.apply(String,l.slice(n+1));break;case"IEND":return r&&this.animation.frames.push(r),this.colors=function(){switch(this.colorType){case 0:case 3:case 4:return 1;case 2:case 6:return 3}}.call(this),this.hasAlphaChannel=4===(u=this.colorType)||6===u,a=this.colors+(this.hasAlphaChannel?1:0),this.pixelBitlength=this.bits*a,this.colorSpace=function(){switch(this.colors){case 1:return"DeviceGray";case 3:return"DeviceRGB"}}.call(this),void(this.imgData=new Uint8Array(this.imgData));default:this.pos+=e}if(this.pos+=4,this.pos>this.data.length)throw new Error("Incomplete or corrupt PNG file")}}return o.load=function(t,e,a){var i;return"function"==typeof e&&(a=e),(i=new XMLHttpRequest).open("GET",t,!0),i.responseType="arraybuffer",i.onload=function(){var t;return t=new o(new Uint8Array(i.response||i.mozResponseArrayBuffer)),"function"==typeof(null!=e?e.getContext:void 0)&&t.render(e),"function"==typeof a?a(t):void 0},i.send(null)},a=1,i=2,e=0,o.prototype.read=function(t){var e,a;for(a=[],e=0;0<=t?e<t:e>t;0<=t?++e:--e)a.push(this.data[this.pos++]);return a},o.prototype.readUInt32=function(){return this.data[this.pos++]<<24|this.data[this.pos++]<<16|this.data[this.pos++]<<8|this.data[this.pos++]},o.prototype.readUInt16=function(){return this.data[this.pos++]<<8|this.data[this.pos++]},o.prototype.decodePixels=function(t){var e,a,i,s,r,n,o,h,c,p,d,u,f,m,g,w,y,b,x,k,T,C,I;if(null==t&&(t=this.imgData),0===t.length)return new Uint8Array(0);for(t=(t=new l(t)).getBytes(),w=(u=this.pixelBitlength/8)*this.width,f=new Uint8Array(w*this.height),n=t.length,g=0,m=0,a=0;m<n;){switch(t[m++]){case 0:for(s=x=0;x<w;s=x+=1)f[a++]=t[m++];break;case 1:for(s=k=0;k<w;s=k+=1)e=t[m++],r=s<u?0:f[a-u],f[a++]=(e+r)%256;break;case 2:for(s=T=0;T<w;s=T+=1)e=t[m++],i=(s-s%u)/u,y=g&&f[(g-1)*w+i*u+s%u],f[a++]=(y+e)%256;break;case 3:for(s=C=0;C<w;s=C+=1)e=t[m++],i=(s-s%u)/u,r=s<u?0:f[a-u],y=g&&f[(g-1)*w+i*u+s%u],f[a++]=(e+Math.floor((r+y)/2))%256;break;case 4:for(s=I=0;I<w;s=I+=1)e=t[m++],i=(s-s%u)/u,r=s<u?0:f[a-u],0===g?y=b=0:(y=f[(g-1)*w+i*u+s%u],b=i&&f[(g-1)*w+(i-1)*u+s%u]),o=r+y-b,h=Math.abs(o-r),p=Math.abs(o-y),d=Math.abs(o-b),c=h<=p&&h<=d?r:p<=d?y:b,f[a++]=(e+c)%256;break;default:throw new Error("Invalid filter algorithm: "+t[m-1])}g++}return f},o.prototype.decodePalette=function(){var t,e,a,i,s,r,n,o,h;for(a=this.palette,r=this.transparency.indexed||[],s=new Uint8Array((r.length||0)+a.length),i=0,a.length,t=0,e=n=0,o=a.length;n<o;e=n+=3)s[i++]=a[e],s[i++]=a[e+1],s[i++]=a[e+2],s[i++]=null!=(h=r[t++])?h:255;return s},o.prototype.copyToImageData=function(t,e){var a,i,s,r,n,o,h,c,l,p,d;if(i=this.colors,l=null,a=this.hasAlphaChannel,this.palette.length&&(l=null!=(d=this._decodedPalette)?d:this._decodedPalette=this.decodePalette(),i=4,a=!0),c=(s=t.data||t).length,n=l||e,r=o=0,1===i)for(;r<c;)h=l?4*e[r/4]:o,p=n[h++],s[r++]=p,s[r++]=p,s[r++]=p,s[r++]=a?n[h++]:this.transparency.grayscale&&this.transparency.grayscale===p?0:255,o=h;else for(;r<c;)h=l?4*e[r/4]:o,s[r++]=n[h++],s[r++]=n[h++],s[r++]=n[h++],s[r++]=a?n[h++]:this.transparency.rgb&&this.transparency.rgb[1]===n[h-3]&&this.transparency.rgb[3]===n[h-2]&&this.transparency.rgb[5]===n[h-1]?0:255,o=h},o.prototype.decode=function(){var t;return t=new Uint8Array(this.width*this.height*4),this.copyToImageData(t,this.decodePixels()),t},r=t.document&&t.document.createElement("canvas"),n=r&&r.getContext("2d"),s=function(t){var e;return n.width=t.width,n.height=t.height,n.clearRect(0,0,t.width,t.height),n.putImageData(t,0,0),(e=new Image).src=r.toDataURL(),e},o.prototype.decodeFrames=function(t){var e,a,i,r,n,o,h,c;if(this.animation){for(c=[],a=n=0,o=(h=this.animation.frames).length;n<o;a=++n)e=h[a],i=t.createImageData(e.width,e.height),r=this.decodePixels(new Uint8Array(e.data)),this.copyToImageData(i,r),e.imageData=i,c.push(e.image=s(i));return c}},o.prototype.renderFrame=function(t,s){var r,n,o;return r=(n=this.animation.frames)[s],o=n[s-1],0===s&&t.clearRect(0,0,this.width,this.height),(null!=o?o.disposeOp:void 0)===a?t.clearRect(o.xOffset,o.yOffset,o.width,o.height):(null!=o?o.disposeOp:void 0)===i&&t.putImageData(o.imageData,o.xOffset,o.yOffset),r.blendOp===e&&t.clearRect(r.xOffset,r.yOffset,r.width,r.height),t.drawImage(r.image,r.xOffset,r.yOffset)},o.prototype.animate=function(t){var e,a,i,s,r,n,o=this;return a=0,n=this.animation,s=n.numFrames,i=n.frames,r=n.numPlays,(e=function(){var n,h;if(n=a++%s,h=i[n],o.renderFrame(t,n),s>1&&a/s<r)return o.animation._timeout=setTimeout(e,h.delay)})()},o.prototype.stopAnimation=function(){var t;return clearTimeout(null!=(t=this.animation)?t._timeout:void 0)},o.prototype.render=function(t){var e,a;return t._png&&t._png.stopAnimation(),t._png=this,t.width=this.width,t.height=this.height,e=t.getContext("2d"),this.animation?(this.decodeFrames(e),this.animate(e)):(a=e.createImageData(this.width,this.height),this.copyToImageData(a,this.decodePixels()),e.putImageData(a,0,0))},o}(self);const y=new Set(["jpg","png","bmp","gif"]);async function b(e,s){if(!g)throw new t("rasterCoded:decode","lerc decoder is not supported on big endian platform");await n();const{offset:r}=s,{width:h,height:c,pixelType:l,statistics:p,depthCount:d,noDataValues:u,bandMasks:f,pixels:m,mask:w}=o(e,{inputOffset:r,returnInterleaved:s.returnInterleaved}),y=new a({width:h,height:c,pixelType:l.toLowerCase(),pixels:m,mask:w,statistics:p.map(({minValue:t,maxValue:e})=>new i(t,e)),bandMasks:f,depthCount:d,noDataValues:u});return p?.length||y.updateStatistics(),y}async function x(e,i){await p();const s=d(e);if(!s)throw new t("rasterCodec:decode","failed to decode the input data.");const{width:r,height:n,pixels:o}=s,h=new a({width:r,height:n,pixelType:"u16",pixels:o});return h.updateStatistics(),h}async function k(t,i){const s=await m(t,{...i,noDataValue:i.tiffNoDataValue,matchAllNoData:i.matchAllNoData});e(s);const r=new a({width:s.width,height:s.height,pixels:s.pixels,pixelType:s.pixelType.toLowerCase(),mask:s.mask,bandMasks:s.bandMasks,statistics:null});return r.updateStatistics(),r}async function T(t,e){const i=await f(t,e.customOptions),s=new a({width:i.width,height:i.height,pixels:i.pixels,pixelType:i.pixelType.toLowerCase(),mask:i.mask,statistics:null});return s.updateStatistics(),s}function C(t,e){const i=e.pixelType||"u8",s=a.getPixelArrayConstructor(i),r="u8"===i?t:new s(t.buffer),n=[],o=e.planes||1;if(1===o)n.push(r);else for(let a=0;a<o;a++){const i=(e.width||1)*(e.height||t.length),h=new s(i);for(let t=0;t<i;t++)h[t]=r[t*o+a];n.push(h)}const h=new a({width:e.width||1,height:e.height||t.length,pixels:n,pixelType:i,statistics:null});return h.updateStatistics(),h}function I(t,e){return C(new l(new Uint8Array(t)).getBytes(),e)}function A(t,e){return C(h(t,e.offset,e.eof,!e.isInputBigEndian),e)}function v(t,e,i){const{pixelTypeCtor:s}=P(e.pixelType),r=(0,u.decode)(t,{width:e.width,height:e.height,pixelType:s,format:i}),n=new a({width:e.width,height:e.height,pixels:r.pixels,pixelType:e.pixelType,mask:r.mask,statistics:null});return n.updateStatistics(),n}function D(t,e){const i=r.decode(t,e.hasNoZlibMask??void 0),s=new a({width:i.width,height:i.height,pixels:i.pixels,pixelType:"u8",mask:i.mask,statistics:null});return s.updateStatistics(),s}function U(t,e){const i=new Uint8Array(t),s=new w(i),{width:r,height:n}=e,o=r*n,h=s.decode();let c,l=0,p=0;const d=new Uint8Array(o);for(l=0;l<o;l++)d[l]=h[4*l+3];const u=new a({width:r,height:n,pixels:[],pixelType:"u8",mask:d,statistics:[]});for(l=0;l<3;l++){for(c=new Uint8Array(o),p=0;p<o;p++)c[p]=h[4*p+l];u.addData({pixels:c})}return u.updateStatistics(),u}async function S(t,e,i,r){const n=new s,o={applyJpegMask:!1,format:e,...i},h=await n.decode(t,o,r),c=new a(h);return c.updateStatistics(),c}function j(e){if(null==e)throw new t("rasterCodec:decode","parameter encodeddata is required.");const a=new Uint8Array(e,0,10);let i="";return 255===a[0]&&216===a[1]?i="jpg":137===a[0]&&80===a[1]&&78===a[2]&&71===a[3]?i="png":67===a[0]&&110===a[1]&&116===a[2]&&90===a[3]&&73===a[4]&&109===a[5]&&97===a[6]&&103===a[7]&&101===a[8]&&32===a[9]?i="lerc":76===a[0]&&101===a[1]&&114===a[2]&&99===a[3]&&50===a[4]&&32===a[5]?i="lerc2":73===a[0]&&73===a[1]&&42===a[2]&&0===a[3]||77===a[0]&&77===a[1]&&0===a[2]&&42===a[3]||73===a[0]&&73===a[1]&&43===a[2]&&0===a[3]||77===a[0]&&77===a[1]&&0===a[2]&&43===a[3]?i="tiff":71===a[0]&&73===a[1]&&70===a[2]?i="gif":66===a[0]&&77===a[1]?i="bmp":81===a[0]&&66===a[1]&&51===a[2]?i="qb3":String.fromCharCode.apply(null,a).toLowerCase().includes("error")&&(i="error"),i}function O(e){let a=null;switch(e){case"lerc":case"lerc2":a=b;break;case"jpg":a=D;break;case"png":a=U;break;case"bsq":case"bip":a=(t,a)=>v(t,a,e);break;case"tiff":a=k;break;case"deflate":a=I;break;case"lzw":a=A;break;case"qb3":a=x;break;case"error":a=()=>{throw new t("rasterCodec:decode","input data contains error")};break;default:a=()=>{throw new t("rasterCodec:decode","unsupported raster format")}}return a}function P(t){let e=null,a=null;switch(t?t.toLowerCase():"f32"){case"u1":case"u2":case"u4":case"u8":a=255,e=Uint8Array;break;case"u16":a=a||65535,e=Uint16Array;break;case"u32":a=a||2**32-1,e=Uint32Array;break;case"s8":a=a||-128,e=Int8Array;break;case"s16":a=a||-32768,e=Int16Array;break;case"s32":a=a||0-2**31,e=Int32Array;break;default:e=Float32Array}return{pixelTypeCtor:e,noDataValue:a}}function M(t,e=1){if(!t)return;const{pixels:i,width:s,height:r,mask:n}=t;if(!i||0===i.length)return;const o=i.length,h=s-1,c=r-1,l=[];let p,d,u,f,m,g,w=null;const y=a.getPixelArrayConstructor(t.pixelType);if(0===e){for(p=0;p<o;p++){for(m=i[p],g=new y(h*c),d=0;d<c;d++)for(f=d*s,u=0;u<h;u++)g[d*h+u]=m[f+u];l.push(g)}if(null!=n)for(w=new Uint8Array(h*c),d=0;d<c;d++)for(f=d*s,u=0;u<h;u++)w[d*h+u]=n[f+u]}else{for(p=0;p<o;p++){for(m=i[p],g=new y(h*c),d=0;d<c;d++)for(f=d*s,u=0;u<h;u++)g[d*h+u]=(m[f+u]+m[f+u+1]+m[f+s+u]+m[f+s+u+1])/4;l.push(g)}if(n)for(w=new Uint8Array(h*c),d=0;d<c;d++)for(f=d*s,u=0;u<h;u++)w[d*h+u]=Math.min.apply(null,[n[f+u],n[f+u+1],n[f+s+u],n[f+s+u+1]])}t.width=h,t.height=c,t.mask=w,t.pixels=l}function L(t){let e=j(t);return"lerc2"===e?e="lerc":"error"===e&&(e=""),e}async function R(e,i={},s){if(null==e)throw new t("rasterCodec:decode","missing encodeddata parameter.");let r=i.format?.toLowerCase();if(!("bsq"!==r&&"bip"!==r||null!=i.width&&null!=i.height))throw new t("rasterCodec:decode","requires width and height in options parameter.");if("tiff"===r&&i.customOptions)return T(e,i);if((!r||"bsq"!==r&&"bip"!==r&&"deflate"!==r&&"lzw"!==r)&&(r=j(e)),i.useCanvas&&y.has(r))return S(e,r,i,s);const n=O(r);let o;i.isPoint&&(null!=(i={...i}).width&&i.width++,null!=i.height&&i.height++);const{offsets:h}=i;if(h&&h.length>1){const t=h.map((t,a)=>n(e.slice(t,h[a+1]),i)),s=await Promise.all(t);o=s[0],o.pixels=s.map(t=>t.pixels[0]);const r=s.map(t=>t.mask);s.some(t=>null!=t)&&(r.forEach((t,e)=>{null==t&&(r[e]=new Uint8Array(o.width*o.height).fill(255))}),o.bandMasks=r,o.mask=a.combineBandMasks(r)),o.updateStatistics()}else o=await n(e,{...i,offset:h?.[0]??i.offset});return"jpg"!==r&&null!=i.noDataValue&&1===o.depthCount&&c(o,i.noDataValue,{customFloatTolerance:i.tolerance}),i.isPoint&&M(o),o}export{R as decode,L as getFormat};
5
+ import t from"../../../core/Error.js";import{assertIsSome as e}from"../../../core/maybe.js";import a from"../PixelBlock.js";import{SimpleBandStatistics as i}from"../SimpleBandStatistics.js";import s from"./ImageCanvasDecoder.js";import r from"./JpgPlus.js";import{load as n,decode as o}from"./Lerc.js";import{decode as h}from"./Lzw.js";import{convertNoDataToMask as c}from"./pixelRangeUtils.js";import{Z as l}from"../../../chunks/Zlib.js";import{load as p,decode as d}from"./Qb3.js";import u from"./Raw.js";import{decodeTileOrStrip as f,decode as m}from"./TiffDecoder.js";import{isPlatformLittleEndian as g}from"./utils.js";var w=function(t){var e,a,i,s,r,n;function o(t){var e,a,i,s,r,n,o,h,c,l,p,d,u;for(this.data=t,this.pos=8,this.palette=[],this.imgData=[],this.transparency={},this.animation=null,this.text={},r=null;;){switch(e=this.readUInt32(),h=function(){var t,e;for(e=[],t=0;t<4;++t)e.push(String.fromCharCode(this.data[this.pos++]));return e}.call(this).join(""),h){case"IHDR":this.width=this.readUInt32(),this.height=this.readUInt32(),this.bits=this.data[this.pos++],this.colorType=this.data[this.pos++],this.compressionMethod=this.data[this.pos++],this.filterMethod=this.data[this.pos++],this.interlaceMethod=this.data[this.pos++];break;case"acTL":this.animation={numFrames:this.readUInt32(),numPlays:this.readUInt32()||1/0,frames:[]};break;case"PLTE":this.palette=this.read(e);break;case"fcTL":r&&this.animation.frames.push(r),this.pos+=4,r={width:this.readUInt32(),height:this.readUInt32(),xOffset:this.readUInt32(),yOffset:this.readUInt32()},s=this.readUInt16(),i=this.readUInt16()||100,r.delay=1e3*s/i,r.disposeOp=this.data[this.pos++],r.blendOp=this.data[this.pos++],r.data=[];break;case"IDAT":case"fdAT":for("fdAT"===h&&(this.pos+=4,e-=4),t=(null!=r?r.data:void 0)||this.imgData,p=0;0<=e?p<e:p>e;0<=e?++p:--p)t.push(this.data[this.pos++]);break;case"tRNS":switch(this.transparency={},this.colorType){case 3:if(this.transparency.indexed=this.read(e),(c=255-this.transparency.indexed.length)>0)for(d=0;0<=c?d<c:d>c;0<=c?++d:--d)this.transparency.indexed.push(255);break;case 0:this.transparency.grayscale=this.read(e)[0];break;case 2:this.transparency.rgb=this.read(e)}break;case"tEXt":n=(l=this.read(e)).indexOf(0),o=String.fromCharCode.apply(String,l.slice(0,n)),this.text[o]=String.fromCharCode.apply(String,l.slice(n+1));break;case"IEND":return r&&this.animation.frames.push(r),this.colors=function(){switch(this.colorType){case 0:case 3:case 4:return 1;case 2:case 6:return 3}}.call(this),this.hasAlphaChannel=4===(u=this.colorType)||6===u,a=this.colors+(this.hasAlphaChannel?1:0),this.pixelBitlength=this.bits*a,this.colorSpace=function(){switch(this.colors){case 1:return"DeviceGray";case 3:return"DeviceRGB"}}.call(this),void(this.imgData=new Uint8Array(this.imgData));default:this.pos+=e}if(this.pos+=4,this.pos>this.data.length)throw new Error("Incomplete or corrupt PNG file")}}return o.load=function(t,e,a){var i;return"function"==typeof e&&(a=e),(i=new XMLHttpRequest).open("GET",t,!0),i.responseType="arraybuffer",i.onload=function(){var t;return t=new o(new Uint8Array(i.response||i.mozResponseArrayBuffer)),"function"==typeof(null!=e?e.getContext:void 0)&&t.render(e),"function"==typeof a?a(t):void 0},i.send(null)},a=1,i=2,e=0,o.prototype.read=function(t){var e,a;for(a=[],e=0;0<=t?e<t:e>t;0<=t?++e:--e)a.push(this.data[this.pos++]);return a},o.prototype.readUInt32=function(){return this.data[this.pos++]<<24|this.data[this.pos++]<<16|this.data[this.pos++]<<8|this.data[this.pos++]},o.prototype.readUInt16=function(){return this.data[this.pos++]<<8|this.data[this.pos++]},o.prototype.decodePixels=function(t){var e,a,i,s,r,n,o,h,c,p,d,u,f,m,g,w,y,b,x,k,T,C,I;if(null==t&&(t=this.imgData),0===t.length)return new Uint8Array(0);for(t=(t=new l(t)).getBytes(),w=(u=this.pixelBitlength/8)*this.width,f=new Uint8Array(w*this.height),n=t.length,g=0,m=0,a=0;m<n;){switch(t[m++]){case 0:for(s=x=0;x<w;s=x+=1)f[a++]=t[m++];break;case 1:for(s=k=0;k<w;s=k+=1)e=t[m++],r=s<u?0:f[a-u],f[a++]=(e+r)%256;break;case 2:for(s=T=0;T<w;s=T+=1)e=t[m++],i=(s-s%u)/u,y=g&&f[(g-1)*w+i*u+s%u],f[a++]=(y+e)%256;break;case 3:for(s=C=0;C<w;s=C+=1)e=t[m++],i=(s-s%u)/u,r=s<u?0:f[a-u],y=g&&f[(g-1)*w+i*u+s%u],f[a++]=(e+Math.floor((r+y)/2))%256;break;case 4:for(s=I=0;I<w;s=I+=1)e=t[m++],i=(s-s%u)/u,r=s<u?0:f[a-u],0===g?y=b=0:(y=f[(g-1)*w+i*u+s%u],b=i&&f[(g-1)*w+(i-1)*u+s%u]),o=r+y-b,h=Math.abs(o-r),p=Math.abs(o-y),d=Math.abs(o-b),c=h<=p&&h<=d?r:p<=d?y:b,f[a++]=(e+c)%256;break;default:throw new Error("Invalid filter algorithm: "+t[m-1])}g++}return f},o.prototype.decodePalette=function(){var t,e,a,i,s,r,n,o,h;for(a=this.palette,r=this.transparency.indexed||[],s=new Uint8Array((r.length||0)+a.length),i=0,a.length,t=0,e=n=0,o=a.length;n<o;e=n+=3)s[i++]=a[e],s[i++]=a[e+1],s[i++]=a[e+2],s[i++]=null!=(h=r[t++])?h:255;return s},o.prototype.copyToImageData=function(t,e){var a,i,s,r,n,o,h,c,l,p,d;if(i=this.colors,l=null,a=this.hasAlphaChannel,this.palette.length&&(l=null!=(d=this._decodedPalette)?d:this._decodedPalette=this.decodePalette(),i=4,a=!0),c=(s=t.data||t).length,n=l||e,r=o=0,1===i)for(;r<c;)h=l?4*e[r/4]:o,p=n[h++],s[r++]=p,s[r++]=p,s[r++]=p,s[r++]=a?n[h++]:this.transparency.grayscale&&this.transparency.grayscale===p?0:255,o=h;else for(;r<c;)h=l?4*e[r/4]:o,s[r++]=n[h++],s[r++]=n[h++],s[r++]=n[h++],s[r++]=a?n[h++]:this.transparency.rgb&&this.transparency.rgb[1]===n[h-3]&&this.transparency.rgb[3]===n[h-2]&&this.transparency.rgb[5]===n[h-1]?0:255,o=h},o.prototype.decode=function(){var t;return t=new Uint8Array(this.width*this.height*4),this.copyToImageData(t,this.decodePixels()),t},r=t.document&&t.document.createElement("canvas"),n=r&&r.getContext("2d"),s=function(t){var e;return n.width=t.width,n.height=t.height,n.clearRect(0,0,t.width,t.height),n.putImageData(t,0,0),(e=new Image).src=r.toDataURL(),e},o.prototype.decodeFrames=function(t){var e,a,i,r,n,o,h,c;if(this.animation){for(c=[],a=n=0,o=(h=this.animation.frames).length;n<o;a=++n)e=h[a],i=t.createImageData(e.width,e.height),r=this.decodePixels(new Uint8Array(e.data)),this.copyToImageData(i,r),e.imageData=i,c.push(e.image=s(i));return c}},o.prototype.renderFrame=function(t,s){var r,n,o;return r=(n=this.animation.frames)[s],o=n[s-1],0===s&&t.clearRect(0,0,this.width,this.height),(null!=o?o.disposeOp:void 0)===a?t.clearRect(o.xOffset,o.yOffset,o.width,o.height):(null!=o?o.disposeOp:void 0)===i&&t.putImageData(o.imageData,o.xOffset,o.yOffset),r.blendOp===e&&t.clearRect(r.xOffset,r.yOffset,r.width,r.height),t.drawImage(r.image,r.xOffset,r.yOffset)},o.prototype.animate=function(t){var e,a,i,s,r,n,o=this;return a=0,n=this.animation,s=n.numFrames,i=n.frames,r=n.numPlays,(e=function(){var n,h;if(n=a++%s,h=i[n],o.renderFrame(t,n),s>1&&a/s<r)return o.animation._timeout=setTimeout(e,h.delay)})()},o.prototype.stopAnimation=function(){var t;return clearTimeout(null!=(t=this.animation)?t._timeout:void 0)},o.prototype.render=function(t){var e,a;return t._png&&t._png.stopAnimation(),t._png=this,t.width=this.width,t.height=this.height,e=t.getContext("2d"),this.animation?(this.decodeFrames(e),this.animate(e)):(a=e.createImageData(this.width,this.height),this.copyToImageData(a,this.decodePixels()),e.putImageData(a,0,0))},o}(self);const y=new Set(["jpg","png","bmp","gif","webp"]);async function b(e,s){if(!g)throw new t("rasterCoded:decode","lerc decoder is not supported on big endian platform");await n();const{offset:r}=s,{width:h,height:c,pixelType:l,statistics:p,depthCount:d,noDataValues:u,bandMasks:f,pixels:m,mask:w}=o(e,{inputOffset:r,returnInterleaved:s.returnInterleaved}),y=new a({width:h,height:c,pixelType:l.toLowerCase(),pixels:m,mask:w,statistics:p.map(({minValue:t,maxValue:e})=>new i(t,e)),bandMasks:f,depthCount:d,noDataValues:u});return p?.length||y.updateStatistics(),y}async function x(e,i){await p();const s=d(e);if(!s)throw new t("rasterCodec:decode","failed to decode the input data.");const{width:r,height:n,pixels:o}=s,h=new a({width:r,height:n,pixelType:"u16",pixels:o});return h.updateStatistics(),h}async function k(t,i){const s=await m(t,{...i,noDataValue:i.tiffNoDataValue,matchAllNoData:i.matchAllNoData});e(s);const r=new a({width:s.width,height:s.height,pixels:s.pixels,pixelType:s.pixelType.toLowerCase(),mask:s.mask,bandMasks:s.bandMasks,statistics:null});return r.updateStatistics(),r}async function T(t,e){const i=await f(t,e.customOptions),s=new a({width:i.width,height:i.height,pixels:i.pixels,pixelType:i.pixelType.toLowerCase(),mask:i.mask,statistics:null});return s.updateStatistics(),s}function C(t,e){const i=e.pixelType||"u8",s=a.getPixelArrayConstructor(i),r="u8"===i?t:new s(t.buffer),n=[],o=e.planes||1;if(1===o)n.push(r);else for(let a=0;a<o;a++){const i=(e.width||1)*(e.height||t.length),h=new s(i);for(let t=0;t<i;t++)h[t]=r[t*o+a];n.push(h)}const h=new a({width:e.width||1,height:e.height||t.length,pixels:n,pixelType:i,statistics:null});return h.updateStatistics(),h}function I(t,e){return C(new l(new Uint8Array(t)).getBytes(),e)}function A(t,e){return C(h(t,e.offset,e.eof,!e.isInputBigEndian),e)}function v(t,e,i){const{pixelTypeCtor:s}=P(e.pixelType),r=(0,u.decode)(t,{width:e.width,height:e.height,pixelType:s,format:i}),n=new a({width:e.width,height:e.height,pixels:r.pixels,pixelType:e.pixelType,mask:r.mask,statistics:null});return n.updateStatistics(),n}function D(t,e){const i=r.decode(t,e.hasNoZlibMask??void 0),s=new a({width:i.width,height:i.height,pixels:i.pixels,pixelType:"u8",mask:i.mask,statistics:null});return s.updateStatistics(),s}function U(t,e){const i=new Uint8Array(t),s=new w(i),{width:r,height:n}=e,o=r*n,h=s.decode();let c,l=0,p=0;const d=new Uint8Array(o);for(l=0;l<o;l++)d[l]=h[4*l+3];const u=new a({width:r,height:n,pixels:[],pixelType:"u8",mask:d,statistics:[]});for(l=0;l<3;l++){for(c=new Uint8Array(o),p=0;p<o;p++)c[p]=h[4*p+l];u.addData({pixels:c})}return u.updateStatistics(),u}async function S(t,e,i,r){const n=new s,o={applyJpegMask:!1,format:e,...i},h=await n.decode(t,o,r),c=new a(h);return c.updateStatistics(),c}function j(e){if(null==e)throw new t("rasterCodec:decode","parameter encodeddata is required.");const headerLength = Math.min(e.byteLength, 12);const a = new Uint8Array(e, 0, headerLength);let i="";if (headerLength >= 12 && 82 === a[0] && 73 === a[1] && 70 === a[2] && 70 === a[3] && 87 === a[8] && 69 === a[9] && 66 === a[10] && 80 === a[11]) {return i = "webp";}return 255===a[0]&&216===a[1]?i="jpg":137===a[0]&&80===a[1]&&78===a[2]&&71===a[3]?i="png":67===a[0]&&110===a[1]&&116===a[2]&&90===a[3]&&73===a[4]&&109===a[5]&&97===a[6]&&103===a[7]&&101===a[8]&&32===a[9]?i="lerc":76===a[0]&&101===a[1]&&114===a[2]&&99===a[3]&&50===a[4]&&32===a[5]?i="lerc2":73===a[0]&&73===a[1]&&42===a[2]&&0===a[3]||77===a[0]&&77===a[1]&&0===a[2]&&42===a[3]||73===a[0]&&73===a[1]&&43===a[2]&&0===a[3]||77===a[0]&&77===a[1]&&0===a[2]&&43===a[3]?i="tiff":71===a[0]&&73===a[1]&&70===a[2]?i="gif":66===a[0]&&77===a[1]?i="bmp":81===a[0]&&66===a[1]&&51===a[2]?i="qb3":String.fromCharCode.apply(null,a).toLowerCase().includes("error")&&(i="error"),i}function O(e){let a=null;switch(e){case"lerc":case"lerc2":a=b;break;case"jpg":a=D;break;case"png":a=U;break;case"bsq":case"bip":a=(t,a)=>v(t,a,e);break;case"tiff":a=k;break;case"deflate":a=I;break;case"lzw":a=A;break;case"qb3":a=x;break;case"error":a=()=>{throw new t("rasterCodec:decode","input data contains error")};break;default:a=()=>{throw new t("rasterCodec:decode","unsupported raster format")}}return a}function P(t){let e=null,a=null;switch(t?t.toLowerCase():"f32"){case"u1":case"u2":case"u4":case"u8":a=255,e=Uint8Array;break;case"u16":a=a||65535,e=Uint16Array;break;case"u32":a=a||2**32-1,e=Uint32Array;break;case"s8":a=a||-128,e=Int8Array;break;case"s16":a=a||-32768,e=Int16Array;break;case"s32":a=a||0-2**31,e=Int32Array;break;default:e=Float32Array}return{pixelTypeCtor:e,noDataValue:a}}function M(t,e=1){if(!t)return;const{pixels:i,width:s,height:r,mask:n}=t;if(!i||0===i.length)return;const o=i.length,h=s-1,c=r-1,l=[];let p,d,u,f,m,g,w=null;const y=a.getPixelArrayConstructor(t.pixelType);if(0===e){for(p=0;p<o;p++){for(m=i[p],g=new y(h*c),d=0;d<c;d++)for(f=d*s,u=0;u<h;u++)g[d*h+u]=m[f+u];l.push(g)}if(null!=n)for(w=new Uint8Array(h*c),d=0;d<c;d++)for(f=d*s,u=0;u<h;u++)w[d*h+u]=n[f+u]}else{for(p=0;p<o;p++){for(m=i[p],g=new y(h*c),d=0;d<c;d++)for(f=d*s,u=0;u<h;u++)g[d*h+u]=(m[f+u]+m[f+u+1]+m[f+s+u]+m[f+s+u+1])/4;l.push(g)}if(n)for(w=new Uint8Array(h*c),d=0;d<c;d++)for(f=d*s,u=0;u<h;u++)w[d*h+u]=Math.min.apply(null,[n[f+u],n[f+u+1],n[f+s+u],n[f+s+u+1]])}t.width=h,t.height=c,t.mask=w,t.pixels=l}function L(t){let e=j(t);return"lerc2"===e?e="lerc":"error"===e&&(e=""),e}async function R(e,i={},s){if(null==e)throw new t("rasterCodec:decode","missing encodeddata parameter.");let r=i.format?.toLowerCase();if(!("bsq"!==r&&"bip"!==r||null!=i.width&&null!=i.height))throw new t("rasterCodec:decode","requires width and height in options parameter.");if("tiff"===r&&i.customOptions)return T(e,i);if((!r||"bsq"!==r&&"bip"!==r&&"deflate"!==r&&"lzw"!==r)&&(r=j(e)),i.useCanvas&&y.has(r))return S(e,r,i,s);const n=O(r);let o;i.isPoint&&(null!=(i={...i}).width&&i.width++,null!=i.height&&i.height++);const{offsets:h}=i;if(h&&h.length>1){const t=h.map((t,a)=>n(e.slice(t,h[a+1]),i)),s=await Promise.all(t);o=s[0],o.pixels=s.map(t=>t.pixels[0]);const r=s.map(t=>t.mask);s.some(t=>null!=t)&&(r.forEach((t,e)=>{null==t&&(r[e]=new Uint8Array(o.width*o.height).fill(255))}),o.bandMasks=r,o.mask=a.combineBandMasks(r)),o.updateStatistics()}else o=await n(e,{...i,offset:h?.[0]??i.offset});return"jpg"!==r&&null!=i.noDataValue&&1===o.depthCount&&c(o,i.noDataValue,{customFloatTolerance:i.tolerance}),i.isPoint&&M(o),o}export{R as decode,L as getFormat};
@@ -0,0 +1,5 @@
1
+ /*
2
+ All material copyright GeoScene, All Rights Reserved, unless otherwise specified.
3
+ See https://js.geoscene.cn/4.34/geoscene/copyright.txt for details.
4
+ */
5
+ import Point from'../../../geometry/Point.js';import MeshSymbol3D from'../../../symbols/MeshSymbol3D.js';import FillSymbol3DLayer from'../../../symbols/FillSymbol3DLayer.js';import GraphicsLayer from"../../../layers/GraphicsLayer.js";import GroupLayer from"../../../layers/GroupLayer.js";import VoxelSlice from"../../../layers/voxel/VoxelSlice.js";import TimeSlider from"../../../widgets/TimeSlider.js";import TimeExtent from"../../../time/TimeExtent.js";import{merge}from'../../../geometry/support/meshUtils.js';import Graphic from"../../../Graphic.js";import{GeometryCreator}from'./common.js';const CANVAS_SIZE=16*2;class VoxelContinuousDrill{constructor(optional){const config={currentVariableId:1,verticalExaggeration:1,fixedCylinderRadius:false,widthCylinder:20,depthCylinder:20,densificationFactor:1,drillType:'cylinder',...optional,offsetGraphicsLayer:{x:0,y:0,z:0,...optional.offsetGraphicsLayer}};const _drillData=config.drillData;if(!_drillData)throw new Error('请传入钻孔数据!');const _view=config.view;if(!_view)throw new Error('请传入 SceneView 对象!');const _vxlLayer=config.vxlLayer;if(!_vxlLayer)throw new Error('请传入体元图层!');const _map=_view.map;const{data,variable}=_drillData;if(!validArray(data)||!validArray(variable))throw new Error('数据格式不正确,或者数据为空!');Object.assign(this,{view:_view,map:_map,data_:data,_vxlLayer:_vxlLayer,variable,_currentVariableId:config.currentVariableId,_verticalExaggeration:config.verticalExaggeration,_drillType:config.drillType,fixedCylinderRadius:config.fixedCylinderRadius,widthCylinder:config.widthCylinder,depthCylinder:config.depthCylinder,densificationFactor:config.densificationFactor,offsetGraphicsLayer:config.offsetGraphicsLayer,});this._drillingGraphicsLayers=[];this._locationCylinders=[];this._timeSliderStops=[];this._colorAndValues={};this._originalZs=[];this._currentZs=[];this.cachedCanvas=null;this._heightCylinders=new Array(this.data_.length);this._heightOrigins=new Array(this.data_.length);this._originalFirstZs=[];this._gui=dat?new dat.GUI():null;this._timeSlider=null;this._meshSymbol3D=new MeshSymbol3D({symbolLayers:[new FillSymbol3DLayer({castShadows:false})]});this.initializeOriginalZs();this.createDrillLayers();this.bindAllControls()}initializeOriginalZs(){this.data_.forEach((item,index)=>{this._originalZs[index]=[...item.zs];this._currentZs[index]=[...item.zs];this._originalFirstZs[index]=item.zs[0];if(item.zs.length>=2){this._heightOrigins[index]=Math.abs(item.zs[1]-item.zs[0])}else{this._heightOrigins[index]=0}this._heightCylinders[index]=this._heightOrigins[index]})}createDrillLayers(){const{data_:drillData,map,_locationCylinders:locationPoints,_drillingGraphicsLayers:drillingLayers,_timeSliderStops:timeStops,}=this;if(!drillData?.length)throw new Error('Invalid drill data');if(!map)throw new Error('Map not initialized');const processDrillData=(item,index)=>{const{xy}=item;locationPoints[index]=new Point({spatialReference:this.view.spatialReference??map.spatialReference,x:xy[0],y:xy[1],z:this._currentZs[index][0]})};const createTimeSlice=(time,drillIndex,sliceIndex)=>{const date=new Date(time);return new GraphicsLayer({id:`graphicsLayer${drillIndex}${sliceIndex}`,visibilityTimeExtent:{start:date,end:date}})};drillData.forEach((drillItem,drillIndex)=>{processDrillData(drillItem,drillIndex);const timeLayers=new GroupLayer({id:`groupLayer${drillIndex}`,layers:Object.values(drillItem.volume).map((volumeItem,sliceIndex)=>{if(drillIndex===0){timeStops.push(new Date(volumeItem.time))}return createTimeSlice(volumeItem.time,drillIndex,sliceIndex)})});drillingLayers.push(timeLayers)});map.addMany(drillingLayers)}bindAllControls(){['bindTimeSlider','bindDrillLayerVisibilityToggle','bindDrillLayerOffsetToggle','bindLayerSliceToggle','bindDrillTypeToggle','bindVariableToggle','bindExaggerationToggle'].forEach(method=>this[method]())}createCylinderForGradient(zArray,drillIndex,voxelData){const{_locationCylinders:locations,_meshSymbol3D:symbol,fixedCylinderRadius,widthCylinder,depthCylinder,densificationFactor,verticalExaggeration,drillType,_heightCylinders:heights,_colorAndValues:colorMap}=this;if(!validArray(zArray)||!validArray(voxelData))return[];if(zArray.length!==voxelData.length)throw new Error('数据长度不匹配');const scale=fixedCylinderRadius?1:Math.max(1,Math.sqrt(verticalExaggeration));const width=widthCylinder*scale;const depth=depthCylinder*scale;const location=locations[drillIndex];const totalHeight=heights[drillIndex];if(!totalHeight||totalHeight<=0){console.warn(`钻孔${drillIndex}的高度无效:${totalHeight}`);return[]}const geometryCreator=GeometryCreator[drillType];console.time('createCylinderForGradient');const geometries=zArray.map((zValue,index)=>{location.z=zValue;const dataPoints=(index>0&&index<zArray.length-1)?[voxelData[index-1],voxelData[index]]:[voxelData[index]];const colors=dataPoints.map(value=>{const key=findClosestKey(colorMap,value);return colorMap.get(key)});this.cachedCanvas=this.cachedCanvas||document.createElement('canvas');let cachedCanvas=this.cachedCanvas;cachedCanvas.width=cachedCanvas.height=CANVAS_SIZE;let imageData;if(dataPoints.length===1||dataPoints[0]===dataPoints[1]){imageData=createLinearGradient(cachedCanvas,[colors[0]])}else{imageData=createLinearGradient(cachedCanvas,colors)}const material={colorTexture:{data:imageData,wrap:'clamp'}};return geometryCreator(location,{size:{height:totalHeight,width,depth},densificationFactor,material})});console.timeEnd('createCylinderForGradient');return new Graphic({geometry:merge(geometries),symbol})}updateVerticalData(){const{data_,verticalExaggeration,_vxlLayer,_heightOrigins,_originalZs,}=this;if(!verticalExaggeration){throw new Error('体元未渲染!');}const dataLength=data_.length;if(_vxlLayer){_vxlLayer.getVolumeStyle().verticalExaggeration=verticalExaggeration}if(!this._bottomZs){this._bottomZs=new Array(dataLength);this.data_.forEach((item,index)=>{const baseZ=this._originalZs[index][0];const height=this._heightOrigins[index];this._bottomZs[index]=baseZ-height/2})}for(let i=0;i<dataLength;i++){const originalZs=_originalZs[i];const bottomZ=this._bottomZs[i];const step=_heightOrigins[i]*verticalExaggeration;const initialValue=bottomZ+(step*0.5);const len=originalZs.length;this._currentZs[i]=[];let current=initialValue;for(let j=0;j<len;j++){this._currentZs[i][j]=current;current+=step}this._heightCylinders[i]=step;data_[i].zs=[...this._currentZs[i]]}}updateDrillingGraphics(){const{data_,variable,_drillingGraphicsLayers,stretchRange,currentVariableId,_currentZs,}=this;for(let i=0;i<_drillingGraphicsLayers.length;i++){const timeGraphicsLayers=_drillingGraphicsLayers[i];const currentData=data_[i];const currentVariableValue=variable[currentVariableId];timeGraphicsLayers.allLayers.forEach((graphicsLayer,index)=>{const zsData=_currentZs[i];const volumeData=currentData.volume[index];const variableData=volumeData[currentVariableValue];const normalizedData=normalizeArray(variableData,stretchRange);graphicsLayer.graphics=[this.createCylinderForGradient(zsData,i,normalizedData)]})}console.log('钻孔图形更新完成',_drillingGraphicsLayers)}updateSlices(voxelPosition){const{voxelSliceX,voxelSliceY,_vxlLayer,sliceXAxisSlider,sliceYAxisSlider,}=this;voxelSliceX.point=voxelPosition;voxelSliceY.point=voxelPosition;const sliceAxisSliders=[sliceXAxisSlider,sliceYAxisSlider];const voxelSlices=[voxelSliceX,voxelSliceY];function bindAxis(){for(let i=0;i<sliceAxisSliders.length;i++){const sliceAxisSlider=sliceAxisSliders[i];const xslc=voxelSlices[i];_vxlLayer.getVolumeStyle(null).slices.add(xslc);if(sliceAxisSlider){sliceAxisSlider.value=voxelPosition[i].toFixed(2);sliceAxisSlider.addEventListener("calciteSliderInput",function(){xslc.point[i]=sliceAxisSlider.value;xslc.point=xslc.point})}}}bindAxis()}render(pointObjectArray){const{view,}=this;const vxlLayer=this._vxlLayer;view.whenLayerView(vxlLayer).then(()=>{const vm=vxlLayer.getVolume();const vs=vxlLayer.getVariableStyle();const voxelPosition=validArray(pointObjectArray)&&vm.computeVoxelSpaceLocation(pointObjectArray.at(-1));this.updateSlices(voxelPosition);this._colorAndValues=new Map();if(vs.transferFunction){this.stretchRange=vs.transferFunction.stretchRange;const colorStops=vs.transferFunction.colorStops;colorStops.forEach((item)=>{this._colorAndValues.set(item.position,item.color)})}this.verticalExaggeration=vxlLayer.getVolumeStyle()?.verticalExaggeration;if(this.verticalExaggerationToggle){this.verticalExaggerationToggle.setValue(this.verticalExaggeration)}view.goTo({target:this._drillingGraphicsLayers,fov:35,tilt:78.3926687063094,heading:243.2677195416981,},{duration:1500})})}set drillType(drillType){this._drillType=drillType;this.updateDrillingGraphics()}get drillType(){return this._drillType}set currentVariableId(variableId){this._currentVariableId=variableId;this._vxlLayer.currentVariableId=this._currentVariableId;this.updateDrillingGraphics()}get currentVariableId(){return this._currentVariableId}set verticalExaggeration(value){this._verticalExaggeration=value;const startTime=performance.now();this.updateVerticalData();const endTime=performance.now();console.log(`垂直夸张更新执行时间:${endTime-startTime}ms`);this.updateDrillingGraphics()}get verticalExaggeration(){return this._verticalExaggeration}bindLayerSliceToggle(axis){axis={...axis,x:"sliceXAxisSlider",y:"sliceYAxisSlider",z:"sliceZAxisSlider",};this.sliceXAxisSlider=document.getElementById(axis.x);this.sliceYAxisSlider=document.getElementById(axis.y);this.sliceZAxisSlider=document.getElementById(axis.z);this.voxelSliceX=new VoxelSlice({orientation:270,tilt:90,point:[0,0,0]});this.voxelSliceY=new VoxelSlice({orientation:180,tilt:90,point:[0,0,0]});this.voxelSliceZ=new VoxelSlice({orientation:0,tilt:0,point:[0,0,0]})}bindDrillLayerOffsetToggle(){const{offsetGraphicsLayer,_drillingGraphicsLayers}=this;function offsetXY(val,lastOffset){for(let i=0;i<_drillingGraphicsLayers.length;i++){const timeGraphicsLayers=_drillingGraphicsLayers[i];timeGraphicsLayers.allLayers.forEach((graphicsLayer)=>{const graphics=graphicsLayer.graphics;graphics.forEach((graphic)=>{graphic.geometry.offset(...lastOffset);graphic.geometry.offset(...val)})})}}let lastOffsetX=0;let lastOffsetY=0;let lastOffsetZ=0;function changeEventX(val){offsetXY([val,0,0],[lastOffsetX,0,0]);lastOffsetX=-val}function changeEventY(val){offsetXY([0,val,0],[0,lastOffsetY,0]);lastOffsetY=-val}function changeEventZ(val){offsetXY([0,0,val],[0,0,lastOffsetZ]);lastOffsetZ=-val}this._gui?.add(offsetGraphicsLayer,'x',-100,100).name("调整x值").step(0.1).onFinishChange(changeEventX);this._gui?.add(offsetGraphicsLayer,'y',-100,100).name("调整y值").step(0.1).onFinishChange(changeEventY);this._gui?.add(offsetGraphicsLayer,'z',-100,1000).name("调整z值").step(1).onFinishChange(changeEventZ)}bindDrillLayerVisibilityToggle(id="layerVisibilityToggle"){const layerVisibilityToggle=document.getElementById(id);layerVisibilityToggle?.addEventListener("calciteSwitchChange",()=>{for(let i=0;i<this._drillingGraphicsLayers.length;i++){const timeGraphicsLayers=this._drillingGraphicsLayers[i];timeGraphicsLayers.visible=!timeGraphicsLayers.visible}})}bindTimeSlider(container="timeSlider"){const{_timeSliderStops:dates,view}=this;this._timeSlider=new TimeSlider({container,mode:"instant",timeVisible:true,playRate:2000,stops:{dates},loop:true,fullTimeExtent:new TimeExtent({start:dates[0],end:dates[dates.length-1]}),view});view.ui.add(this._timeSlider,"bottom-left")}bindVariableToggle(id="variableSelect"){const thisObject=this;const variableSelect=document.getElementById(id);if(variableSelect){for(let i=0;i<this.variable.length;++i){const vxlVariable={id:i,label:this.variable[i]};const item=document.createElement("calcite-option");item.setAttribute("label",vxlVariable.label);item.setAttribute("value",vxlVariable.id);if(i===thisObject.currentVariableId){item.selected=true}variableSelect.hidden=false;variableSelect.appendChild(item)}variableSelect.addEventListener("calciteSelectChange",function(){thisObject.currentVariableId=variableSelect.selectedOption.value})}}bindDrillTypeToggle(id="switchDrillTypeToggle"){const thisObject=this;const switchDrillTypeToggle=document.getElementById("switchDrillTypeToggle");switchDrillTypeToggle&&(switchDrillTypeToggle.disabled=false);switchDrillTypeToggle?.addEventListener("calciteSwitchChange",()=>{thisObject.drillType='cylinder'===thisObject.drillType?'box':'cylinder'})}bindExaggerationToggle(){const thisObject=this;this.verticalExaggerationToggle=this._gui?.add(this,'_verticalExaggeration',1.0,10.0).name("调整夸张值").step(0.1).onFinishChange(function(value){thisObject.verticalExaggeration=value})}destroy(){this._gui?.destroy();this.view?.ui.remove(this._timeSlider);this.map?.removeMany(this.map?.allLayers.filter((layer)=>layer.type==="group"));if(this.cachedCanvas){this.cachedCanvas.width=1;this.cachedCanvas.height=1;this.cachedCanvas=null}delete this.sliceXAxisSlider;delete this.sliceYAxisSlider;delete this.sliceZAxisSlider;delete this.voxelSliceX;delete this.voxelSliceY;delete this.voxelSliceZ}}function findClosestKey(map,target){const keys=Array.from(map.keys());if(keys.length===0)return undefined;return keys.reduce((prev,curr)=>Math.abs(curr-target)<Math.abs(prev-target)?curr:prev)}function normalizeArray(arr,stretchRange){const[min,max]=stretchRange;const rangeDiff=max-min;if(rangeDiff===0)return arr.map(()=>0);return arr.map(value=>{const clamped=Math.max(min,Math.min(value,max));return(clamped-min)/rangeDiff})}function validArray(array){return Array.isArray(array)&&array.length>0}function createLinearGradient(canvas,colors){const DEFAULT_COLOR=[1,1,1,1];if(!validArray(colors)){return createFallbackCanvas(DEFAULT_COLOR)}const ctx=canvas.getContext('2d',{willReadFrequently:true,alpha:false});configureContext(ctx);const gradient=ctx.createLinearGradient(0,0,0,CANVAS_SIZE);configureColorStops(gradient,colors);ctx.fillStyle=colors.length===1?colors[0]:gradient;ctx.fillRect(0,0,CANVAS_SIZE,CANVAS_SIZE);const img=new Image();img.src=canvas.toDataURL();ctx.clearRect(0,0,canvas.width,canvas.height);return img;function createCanvas(size){const cachedCanvas=document.createElement('canvas');cachedCanvas.width=cachedCanvas.height=size;return cachedCanvas}function configureContext(context){context.globalAlpha=1;context.globalCompositeOperation='lighter'}function configureColorStops(gradientObj,colorArray){const stopCount=colorArray.length;colorArray.forEach((color,index)=>{const stopPosition=stopCount>1?index/(stopCount-1):1;gradientObj.addColorStop(stopPosition,color)})}function createFallbackCanvas(color){const canvas=createCanvas(1);const ctx=canvas.getContext('2d');ctx.fillStyle=`rgba(${color.join(',')})`;ctx.fillRect(0,0,1,1);return canvas}}export default VoxelContinuousDrill;
@@ -0,0 +1,5 @@
1
+ /*
2
+ All material copyright GeoScene, All Rights Reserved, unless otherwise specified.
3
+ See https://js.geoscene.cn/4.34/geoscene/copyright.txt for details.
4
+ */
5
+ import Point from'../../../geometry/Point.js';import{merge}from'../../../geometry/support/meshUtils.js';import MeshSymbol3D from'../../../symbols/MeshSymbol3D.js';import FillSymbol3DLayer from'../../../symbols/FillSymbol3DLayer.js';import Graphic from'../../../Graphic.js';import GraphicsLayer from'../../../layers/GraphicsLayer.js';import VoxelSlice from'../../../layers/voxel/VoxelSlice.js';import{GeometryCreator}from'./common.js';const CONFIG={voxelSlice:{orientation:270,tilt:90,initialPoint:[71.1,0,0]},drillType:'cylinder',cylinder:{width:2000,depth:2000,densificationFactor:1},view:{fov:35,zoom:13,tilt:85.3926687063094,heading:-95.2677195416981,duration:1500},};function validArray(array){return Array.isArray(array)&&array.length>0}function createVoxelSlice(point){return new VoxelSlice({orientation:CONFIG.voxelSlice.orientation,tilt:CONFIG.voxelSlice.tilt,point:point})}class VoxelDiscreteDrill{constructor(optional){const config={currentVariableId:1,verticalExaggeration:1,fixedCylinderRadius:false,popupEnabled:false,widthCylinder:20,depthCylinder:20,densificationFactor:1,drillType:'cylinder',...optional,};const _drillData=config.drillData;if(!_drillData)throw new Error('请传入钻孔数据!');const _view=config.view;if(!_view)throw new Error('请传入 SceneView 对象!');const _vxlLayer=config.vxlLayer;if(!_vxlLayer)throw new Error('请传入体元图层!');const _map=_view.map;const{data,variable}=_drillData;if(!validArray(data)||!validArray(variable))throw new Error('数据格式不正确,或者数据为空!');this.currentVariableId=0;this.lastOffsetX=0;this.lastOffsetY=0;this.originalZsArray=[];this.zArrays=[];this.heightOrigins=[];this.heightCylinders=[];this.originalFirstZs=[];this.drillLocations=[];this.drillType=CONFIG.drillType;this._data=data;this.voxelLayer=_vxlLayer;this.map=_map;this.view=_view;this.displayMode='all';this.currentPointIndex=0}render(pointObjectArray){this.graphicsLayer=new GraphicsLayer();this.map.add(this.graphicsLayer);this.map.ground.navigationConstraint='none';this.view.whenLayerView(this.voxelLayer).then(()=>{this.setupVoxelControls();this.setupDrillHoles();const vm=this.voxelLayer.getVolume();const voxelPosition=validArray(pointObjectArray)&&vm.computeVoxelSpaceLocation(pointObjectArray.at(-1));const xSliceObj=this.voxelLayer.getVolumeStyle(null).slices.getItemAt(0);xSliceObj.point=voxelPosition})}setupVoxelControls(){const xSlice=createVoxelSlice(CONFIG.voxelSlice.initialPoint);this.voxelLayer.getVolumeStyle(null).slices=[xSlice];this.voxelLayer.currentVariableId=this.currentVariableId;this.voxelLayer.popupEnabled=true}setupDrillHoles(){this.voxelStyle=this.voxelLayer.getVolumeStyle();this.updateVariableStyle();this.initializeAllZParameters();this.updateAllZArrays();this.initAllDrillLocations();this.updateDrillHoles();this.setupGUI();this.view.goTo({target:this.graphicsLayer,...CONFIG.view},{duration:CONFIG.view.duration})}initializeAllZParameters(){this.originalZsArray=[];this.heightOrigins=[];this.heightCylinders=[];this.originalFirstZs=[];this.zArrays=[];this._data.forEach((pointData,index)=>{this.originalZsArray[index]=[...pointData.zs];this.originalFirstZs[index]=pointData.zs[0];this.heightOrigins[index]=pointData.zs[1]-pointData.zs[0];this.heightCylinders[index]=this.heightOrigins[index];this.zArrays[index]=[...pointData.zs]})}initAllDrillLocations(){this.drillLocations=[];this._data.forEach((pointData,index)=>{this.drillLocations[index]=new Point({spatialReference:this.view.spatialReference??this.map.spatialReference,x:pointData.xy[0],y:pointData.xy[1],z:pointData.zs[0]})})}updateAllZArrays(){const stl=this.voxelStyle;const exaggeration=stl.verticalExaggeration;console.log("垂直夸张值:",exaggeration);this._data.forEach((pointData,index)=>{const originalZs=pointData.zs;if(exaggeration!==1.0){this.zArrays[index]=originalZs.map(z=>z*exaggeration);this.heightCylinders[index]=this.heightOrigins[index]*exaggeration}else{this.zArrays[index]=[...originalZs];this.heightCylinders[index]=this.heightOrigins[index]}})}updateVariableStyle(){this.variableStyle=this.voxelLayer.getVariableStyle();this.colorMap={};const uniqueValues=this.variableStyle.uniqueValues?.items||[];uniqueValues.forEach(item=>{if(item.value!==undefined){this.colorMap[item.value]=item.color}})}updateDrillHoles(){this.graphicsLayer.removeAll();let renderIndices=Array.from({length:this._data.length},(_,i)=>i);this.geometryCreator=GeometryCreator[this.drillType];renderIndices.forEach(pointIndex=>{const pointData=this._data[pointIndex];const pollutantData=pointData.volume.Attr;const zArray=this.zArrays[pointIndex];const height=this.heightCylinders[pointIndex];const verticalExaggeration=this.voxelStyle.verticalExaggeration||1.0;if(!pollutantData){console.warn(`点位${pointIndex}的污染物数据不存在`);return}const width=CONFIG.cylinder.width*Math.max(1,Math.sqrt(verticalExaggeration));const depth=CONFIG.cylinder.depth*Math.max(1,Math.sqrt(verticalExaggeration));const geometries=[];for(let i=0;i<zArray.length;i++){const value=pollutantData[i];if(value===null)continue;this.drillLocations[pointIndex].z=zArray[i];geometries.push(this.geometryCreator(this.drillLocations[pointIndex],{size:{height,width,depth},densificationFactor:CONFIG.cylinder.densificationFactor,material:{color:this.colorMap[value]||[255,255,255,0.5]}}).offset(0,-depth/2,0))}this.graphicsLayer.add(new Graphic({geometry:merge(geometries),symbol:new MeshSymbol3D({symbolLayers:[new FillSymbol3DLayer()]}),attributes:{pointIndex:pointIndex}}))});console.log('钻孔更新完成:',{renderIndices:renderIndices,verticalExaggeration:this.voxelStyle.verticalExaggeration,graphicsCount:this.graphicsLayer.graphics.length})}offsetGraphics(valX,valY){const graphics=this.graphicsLayer.graphics;graphics.forEach(graphic=>{graphic.geometry.offset(this.lastOffsetX,this.lastOffsetY,0);graphic.geometry.offset(valX,valY,0)});this.lastOffsetX=-valX;this.lastOffsetY=-valY}setupGUI(){if(typeof dat==='undefined'){console.warn('dat.GUI 未加载,跳过GUI初始化');return}try{const gui=new dat.GUI({name:'钻孔控制'});const offsetControls={x:0,y:0};gui.add(offsetControls,'x',-1000,1000).name('X偏移').step(0.1).onChange((val)=>this.offsetGraphics(val,0));gui.add(offsetControls,'y',-1000,1000).name('Y偏移').step(0.1).onChange((val)=>this.offsetGraphics(0,val));const verticalExaggerationCtrl=gui.add(this.voxelStyle,'verticalExaggeration',1.0,5.0).name('垂直夸张').step(0.1);verticalExaggerationCtrl.onFinishChange((value)=>{this.updateAllZArrays();this.updateDrillHoles()});gui.add({type:this.drillType},'type',['box','cylinder']).name('钻孔类型').onChange((value)=>{if(value!==this.drillType){this.drillType=value;this.updateDrillHoles()}});const sliceCtrl={position:CONFIG.voxelSlice.initialPoint[0]};gui.add(sliceCtrl,'position',0,700).name('切片位置').step(0.1).onChange((value)=>{const xSliceObj=this.voxelLayer.getVolumeStyle(null).slices.getItemAt(0);xSliceObj.point=[value,0,0]})}catch(error){console.error('初始化GUI时出错:',error)}}}export default VoxelDiscreteDrill;
@@ -0,0 +1,5 @@
1
+ /*
2
+ All material copyright GeoScene, All Rights Reserved, unless otherwise specified.
3
+ See https://js.geoscene.cn/4.34/geoscene/copyright.txt for details.
4
+ */
5
+ import Mesh from'../../../geometry/Mesh.js';export const BoxVertexAttributesGenerator=(()=>{const cache=new Map();return{get(){const cacheKey=`boxVertexAttributes`;if(!cache.has(cacheKey)){const uvs=[];const frontUV=[0,0,0,1,1,1,1,0];uvs.push(...frontUV,...frontUV);const faceConfigs=[{indices:[0,1,2,0,2,3],isTransparent:false},{indices:[1,5,6,1,6,2],isTransparent:true},{indices:[5,4,7,5,7,6],isTransparent:false},{indices:[4,0,3,4,3,7],isTransparent:true},{indices:[4,5,1,4,1,0],isTransparent:false},{indices:[3,2,6,3,6,7],isTransparent:false}];cache.set(cacheKey,{uvs,faceConfigs})}return cache.get(cacheKey)}}})();export const CylinderVertexAttributesGenerator=(()=>{const cache=new Map();const precomputeAngles=(segments)=>{const cosTable=new Array(segments);const sinTable=new Array(segments);const step=(Math.PI*2)/segments;for(let i=0;i<segments;i++){const angle=i*step;cosTable[i]=Math.cos(angle);sinTable[i]=Math.sin(angle)}return{cosTable,sinTable}};const generatePositions=(center,size,segments,cosTable,sinTable)=>{const{x:cx,y:cy,z:cz}=center;const{width,depth,height}=size;const positions=new Array(segments*2*3);const radiusX=width/2;const radiusY=depth/2;for(let i=0;i<segments;i++){const cos=cosTable[i];const sin=sinTable[i];const x=cx+cos*radiusX;const y=cy+sin*radiusY;const baseIdx=i*3;const topIdx=(i+segments)*3;positions[baseIdx]=x;positions[baseIdx+1]=y;positions[baseIdx+2]=cz;positions[topIdx]=x;positions[topIdx+1]=y;positions[topIdx+2]=cz+height}return positions};return{create(center,segments,size){const cacheKey=`${segments}`;if(!cache.has(cacheKey)){const angleData=precomputeAngles(segments);const uv=new Array(segments*4);const faces=new Array(segments*6);for(let i=0;i<segments;i++){const u=i/segments;const baseUV=i*2;const topUV=(i+segments)*2;uv[baseUV]=u;uv[baseUV+1]=0;uv[topUV]=u;uv[topUV+1]=1}for(let i=0;i<segments;i++){const next=(i+1)%segments;const idx=i*6;faces[idx]=i;faces[idx+1]=i+segments;faces[idx+2]=next+segments;faces[idx+3]=i;faces[idx+4]=next+segments;faces[idx+5]=next}cache.set(cacheKey,{cosTable:angleData.cosTable,sinTable:angleData.sinTable,uv,faces})}const{cosTable,sinTable,uv,faces}=cache.get(cacheKey);return{uv:[...uv],position:generatePositions(center,size,segments,cosTable,sinTable),faces:[...faces]}}}})();export const GeometryCreator={cylinder:function(center,{material,size,densificationFactor}){let height=size.height;let width=size.width;let depth=size.depth;const segments=16*Math.pow(2,densificationFactor);const vertexAttributes=CylinderVertexAttributesGenerator.create(center,segments,size);const faces=vertexAttributes.faces;const position=vertexAttributes.position;const uv=vertexAttributes.uv;const shading='smooth';const vertexSpace='georeferenced';const spatialReference=center.spatialReference;const mesh=new Mesh({center,components:[{faces,shading,material}],vertexSpace,vertexAttributes:{position,uv},spatialReference,});return mesh.offset(width,depth/2,-height/2)},box:function(center,{material,size,geometryPosition}){const{width:fullWidth,depth:fullDepth,height:fullHeight}=size;const halfWidth=fullWidth/2;const halfDepth=fullDepth/2;let height=fullHeight;const vertices=[];const frontX=center.x+halfWidth;vertices.push(frontX,center.y+halfDepth,center.z,frontX,center.y+halfDepth,center.z+height,frontX,center.y-halfDepth,center.z+height,frontX,center.y-halfDepth,center.z);const backX=center.x-halfWidth;vertices.push(backX,center.y+halfDepth,center.z,backX,center.y+halfDepth,center.z+height,backX,center.y-halfDepth,center.z+height,backX,center.y-halfDepth,center.z);let{faceConfigs,uvs}=BoxVertexAttributesGenerator.get(material);const shading='smooth';const components=faceConfigs.map(({indices,isTransparent})=>({faces:indices,shading,material:isTransparent?{color:"transparent"}:material}));const mesh=new Mesh({center,components,vertexSpace:'georeferenced',vertexAttributes:{position:vertices,uv:uvs},spatialReference:center.spatialReference,});return mesh.offset(fullWidth,halfDepth,-height/2)}}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@geoscene/core",
3
- "version": "4.34.8",
3
+ "version": "4.34.10",
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": [
@@ -2,4 +2,4 @@
2
2
  All material copyright GeoScene, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.geoscene.cn/4.34/geoscene/copyright.txt for details.
4
4
  */
5
- import e from"../../core/Error.js";import{findAssociatedFeatureService as a}from"../../layers/support/associatedFeatureServiceUtils.js";import{getLayerModuleType as r}from"../../layers/support/fetchService.js";import{LayerLoadContext as t}from"../../layers/support/LayerLoadContext.js";import{sceneServiceLayerTypeToClassName as s,applyPreferredHostToPortalItem as n,getPreferredHost as c}from"../../layers/support/layerUtils.js";import{layerLookupMap as o}from"../../layers/support/lazyLayerLoader.js";import i from"../PortalItem.js";import{getFirstLayerOrTable as u,getNumLayersAndTables as l,preprocessFSItemData as y,getLayerOrTable as m,layerTypeToLayerModuleType as f,populateSceneServiceItemData as p}from"./loadUtils.js";import{hasTypeKeyword as d}from"./portalItemUtils.js";async function L(e){let{portalItem:a}=e;!a||a instanceof i||(a=new i(a));const r=await w(a);return new(0,r.constructor)({portalItem:a,...r.properties})}async function w(e){await e.load();const a=new t;return N(await S(e,a))}async function S(a,r){switch(a.type){case"3DTiles Service":return a.typeKeywords.includes("3DObject")?F():a.typeKeywords.includes("GaussianSplat")?b():P();case"CSV":return K();case"Feature Collection":return M(a);case"Feature Service":return h(a,r);case"Feed":return J();case"GeoJson":return G();case"Group Layer":return k();case"Image Service":return g(a,r);case"KML":return V();case"Knowledge Graph Layer":return W();case"Map Service":return v(a,r);case"Media Layer":return $();case"Scene Service":return I(a,r);case"Stream Service":return j();case"Video Service":return T(a,r);case"Vector Tile Service":return C();case"WCS":return U();case"WFS":return D();case"WMS":return O();case"WMTS":return x();default:throw new e("portal:unknown-item-type","Unknown item type '${type}'",{type:a.type})}}async function N(e){const a=e.className,r=o[a];return{constructor:await r(),properties:e.properties}}async function v(e,a){return await A(e,a)?{className:"TileLayer"}:{className:"MapImageLayer"}}async function h(e,a){const r=await E(e,a);if("object"==typeof r){const{sourceJSON:e,className:a}=r,t={sourceJSON:e};return null!=r.id&&(t.layerId=r.id),{className:a||"FeatureLayer",properties:t}}return{className:"GroupLayer"}}async function I(e,r){const t=await E(e,r,async()=>{try{if(!e.url)return[];const{serverUrl:t}=await a(e.url,{sceneLayerItem:e}),s=await r.fetchServiceMetadata(t);return s?.tables??[]}catch{return[]}});if("object"==typeof t){const a={};let n;if(null!=t.id?(a.layerId=t.id,n=`${e.url}/layers/${t.id}`):n=e.url,e.typeKeywords?.length)for(const r of Object.keys(s))if(e.typeKeywords.includes(r))return{className:s[r]};const c=await r.fetchServiceMetadata(n,{customParameters:await r.fetchCustomParameters(e,e=>u(e)?.customParameters)});return{className:s[c?.layerType]||"SceneLayer",properties:a}}if(!1===t){const a=await r.fetchServiceMetadata(e.url);if("Voxel"===a?.layerType)return{className:"VoxelLayer"}}return{className:"GroupLayer"}}async function M(e){await e.load();const a=d(e,"Map Notes"),r=d(e,"Markup");if(a||r)return{className:"MapNotesLayer"};if(d(e,"Route Layer"))return{className:"RouteLayer"};const t=await e.fetchData();return 1===l(t)?{className:"FeatureLayer"}:{className:"GroupLayer"}}async function g(e,a){await e.load();const r=e.typeKeywords?.map(e=>e.toLowerCase())??[];if(r.includes("elevation 3d layer"))return{className:"ElevationLayer"};if(r.includes("tiled imagery"))return{className:"ImageryTileLayer"};const t=await a.fetchItemData(e),s=t?.layerType;if("ArcGISTiledImageServiceLayer"===s)return{className:"ImageryTileLayer"};if("ArcGISImageServiceLayer"===s)return{className:"ImageryLayer"};const n=await a.fetchServiceMetadata(e.url,{customParameters:await a.fetchCustomParameters(e)}),c=n.cacheType?.toLowerCase(),o=n.capabilities?.toLowerCase().includes("tilesonly"),i=n.tileInfo?.format?.toLowerCase()??"",u=null==c&&["jpg","jpeg","png","png8","png24","png32","mixed"].includes(i);return"map"===c||u||o?{className:"ImageryTileLayer"}:{className:"ImageryLayer"}}function j(){return{className:"StreamLayer"}}async function T(e,a){return"object"==typeof await E(e,a)?{className:"VideoLayer"}:{className:"GroupLayer"}}function C(){return{className:"VectorTileLayer"}}function G(){return{className:"GeoJSONLayer"}}function P(){return{className:"IntegratedMesh3DTilesLayer"}}function b(){return{className:"GaussianSplatLayer"}}function F(){return{className:"UnsupportedLayer"}}function K(){return{className:"CSVLayer"}}function V(){return{className:"KMLLayer"}}function W(){return{className:"KnowledgeGraphLayer"}}function U(){return{className:"WCSLayer"}}function D(){return{className:"WFSLayer"}}function O(){return{className:"WMSLayer"}}function x(){return{className:"WMTSLayer"}}function J(){return{className:"StreamLayer"}}function k(){return{className:"GroupLayer"}}function $(){return{className:"MediaLayer"}}async function A(e,a){const{tileInfo:r}=await a.fetchServiceMetadata(e.url,{customParameters:await a.fetchCustomParameters(e)});return r}async function E(e,a,t){const{url:s,type:o}=e,i="Feature Service"===o;if(!s)return{};if(/\/\d+$/.test(s)){if(i){const t=await a.fetchServiceMetadata(s,{customParameters:await a.fetchCustomParameters(e,e=>u(e)?.customParameters)});return n(e,c()),{id:t.id,className:r(t.type),sourceJSON:t}}return{}}if("Video Service"===o){const e=await a.fetchServiceMetadata(s);return!((e.layers?.length??0)>1)&&{}}await e.load();let d=await a.fetchItemData(e);if(i){const{data:r,preferredHost:t}=await y(d,s,a);n(e,t);const c=R(r);if("object"==typeof c){const e=m(r,c.id);c.className=f(e?.layerType)}return c}"Scene Service"===o&&(d=await p(e,d,a));if(l(d)>0)return R(d);const L=await a.fetchServiceMetadata(s);return t&&(L.tables=await t()),R(L)}function R(e){return 1===l(e)&&{id:u(e)?.id}}export{L as fromItem,S as selectLayerClassPath};
5
+ import e from"../../core/Error.js";import{findAssociatedFeatureService as a}from"../../layers/support/associatedFeatureServiceUtils.js";import{getLayerModuleType as r}from"../../layers/support/fetchService.js";import{LayerLoadContext as t}from"../../layers/support/LayerLoadContext.js";import{sceneServiceLayerTypeToClassName as s,applyPreferredHostToPortalItem as n,getPreferredHost as c}from"../../layers/support/layerUtils.js";import{layerLookupMap as o}from"../../layers/support/lazyLayerLoader.js";import i from"../PortalItem.js";import{getFirstLayerOrTable as u,getNumLayersAndTables as l,preprocessFSItemData as y,getLayerOrTable as m,layerTypeToLayerModuleType as f,populateSceneServiceItemData as p}from"./loadUtils.js";import{hasTypeKeyword as d}from"./portalItemUtils.js";async function L(e){let{portalItem:a}=e;!a||a instanceof i||(a=new i(a));const r=await w(a);return new(0,r.constructor)({portalItem:a,...r.properties})}async function w(e){await e.load();const a=new t;return N(await S(e,a))}async function S(a,r){switch(a.type){case"3DTiles Service":return a.typeKeywords.includes("3DObject")?F():a.typeKeywords.includes("GaussianSplat")?b():P();case"CSV":return K();case"Feature Collection":return M(a);case"Feature Service":return h(a,r);case"Feed":return J();case"GeoJson":return G();case"Group Layer":return k();case"Image Service":return g(a,r);case"KML":return V();case"Knowledge Graph Layer":return W();case"Map Service":return v(a,r);case"Media Layer":return $();case"Scene Service":return I(a,r);case"Stream Service":return j();case"Video Service":return T(a,r);case"Vector Tile Service":return C();case"WCS":return U();case"WFS":return D();case"WMS":return O();case"WMTS":return x();default:throw new e("portal:unknown-item-type","Unknown item type '${type}'",{type:a.type})}}async function N(e){const a=e.className,r=o[a];return{constructor:await r(),properties:e.properties}}async function v(e,a){return await A(e,a)?{className:"TileLayer"}:{className:"MapImageLayer"}}async function h(e,a){const r=await E(e,a);if("object"==typeof r){const{sourceJSON:e,className:a}=r,t={sourceJSON:e};return null!=r.id&&(t.layerId=r.id),{className:a||"FeatureLayer",properties:t}}return{className:"GroupLayer"}}async function I(e,r){const t=await E(e,r,async()=>{try{if(!e.url)return[];const{serverUrl:t}=await a(e.url,{sceneLayerItem:e}),s=await r.fetchServiceMetadata(t);return s?.tables??[]}catch{return[]}});if("object"==typeof t){const a={};let n;if(null!=t.id?(a.layerId=t.id,n=`${e.url}/layers/${t.id}`):n=e.url,e.typeKeywords?.length)for(const r of Object.keys(s))if(e.typeKeywords.includes(r))return{className:s[r]};const c=await r.fetchServiceMetadata(n,{customParameters:await r.fetchCustomParameters(e,e=>u(e)?.customParameters)});return{className:s[c?.layerType]||"SceneLayer",properties:a}}if(!1===t){const a=await r.fetchServiceMetadata(e.url);if("Voxel"===a?.layerType)return{className:"VoxelLayer"}}return{className:"GroupLayer"}}async function M(e){await e.load();const a=d(e,"Map Notes"),r=d(e,"Markup");if(a||r)return{className:"MapNotesLayer"};if(d(e,"Route Layer"))return{className:"RouteLayer"};const t=await e.fetchData();return 1===l(t)?{className:"FeatureLayer"}:{className:"GroupLayer"}}async function g(e,a){await e.load();const r=e.typeKeywords?.map(e=>e.toLowerCase())??[];if(r.includes("elevation 3d layer"))return{className:"ElevationLayer"};if(r.includes("tiled imagery"))return{className:"ImageryTileLayer"};const t=await a.fetchItemData(e),s=t?.layerType;if("ArcGISTiledImageServiceLayer"===s)return{className:"ImageryTileLayer"};if("ArcGISImageServiceLayer"===s)return{className:"ImageryLayer"};const n=await a.fetchServiceMetadata(e.url,{customParameters:await a.fetchCustomParameters(e)}),c=n.cacheType?.toLowerCase(),o=n.capabilities?.toLowerCase().includes("tilesonly"),i=n.tileInfo?.format?.toLowerCase()??"",u=null==c&&["jpg","jpeg","png","png8","png24","png32","mixed","terrainrgb","terraindem"].includes(i);return"map"===c||u||o?{className:"ImageryTileLayer"}:{className:"ImageryLayer"}}function j(){return{className:"StreamLayer"}}async function T(e,a){return"object"==typeof await E(e,a)?{className:"VideoLayer"}:{className:"GroupLayer"}}function C(){return{className:"VectorTileLayer"}}function G(){return{className:"GeoJSONLayer"}}function P(){return{className:"IntegratedMesh3DTilesLayer"}}function b(){return{className:"GaussianSplatLayer"}}function F(){return{className:"UnsupportedLayer"}}function K(){return{className:"CSVLayer"}}function V(){return{className:"KMLLayer"}}function W(){return{className:"KnowledgeGraphLayer"}}function U(){return{className:"WCSLayer"}}function D(){return{className:"WFSLayer"}}function O(){return{className:"WMSLayer"}}function x(){return{className:"WMTSLayer"}}function J(){return{className:"StreamLayer"}}function k(){return{className:"GroupLayer"}}function $(){return{className:"MediaLayer"}}async function A(e,a){const{tileInfo:r}=await a.fetchServiceMetadata(e.url,{customParameters:await a.fetchCustomParameters(e)});return r}async function E(e,a,t){const{url:s,type:o}=e,i="Feature Service"===o;if(!s)return{};if(/\/\d+$/.test(s)){if(i){const t=await a.fetchServiceMetadata(s,{customParameters:await a.fetchCustomParameters(e,e=>u(e)?.customParameters)});return n(e,c()),{id:t.id,className:r(t.type),sourceJSON:t}}return{}}if("Video Service"===o){const e=await a.fetchServiceMetadata(s);return!((e.layers?.length??0)>1)&&{}}await e.load();let d=await a.fetchItemData(e);if(i){const{data:r,preferredHost:t}=await y(d,s,a);n(e,t);const c=R(r);if("object"==typeof c){const e=m(r,c.id);c.className=f(e?.layerType)}return c}"Scene Service"===o&&(d=await p(e,d,a));if(l(d)>0)return R(d);const L=await a.fetchServiceMetadata(s);return t&&(L.tables=await t()),R(L)}function R(e){return 1===l(e)&&{id:u(e)?.id}}export{L as fromItem,S as selectLayerClassPath};
@@ -0,0 +1 @@
1
+ import{parseUrl as r}from"../utils.js";import{JSONFeatureSetParserContext as e}from"./operations/pbfJSONFeatureSet.js";import{executeQueryFGB as t}from"./operations/query.js";import o from"../support/FeatureSet.js";import a from"../support/Query.js";import*as flatgeobufGeojson from"./operations/flatgeobufGeojson.js";function detectSpatialReferenceFromGeoJSON(geojson){if(geojson.crs&&geojson.crs.properties&&"string"==typeof geojson.crs.properties.name){var name,match=geojson.crs.properties.name.match(/EPSG::?(\d+)/i);if(match)return{wkid:parseInt(match[1],10)}}return{wkid:4326}}function convertGeometry(geometry,spatialReference){if(!geometry)return null;const type=geometry.type,coords=geometry.coordinates,base={spatialReference:spatialReference};let data={};if("Point"===type)data={type:"point",x:coords[0],y:coords[1]};else if("LineString"===type)data={type:"polyline",paths:[coords]};else if("Polygon"===type)data={type:"polygon",rings:coords};else if("MultiPoint"===type)data={type:"multipoint",points:coords};else if("MultiLineString"===type)data={type:"polyline",paths:coords};else{if("MultiPolygon"!==type)throw new Error("Unsupported geometry type: "+type);{let rings=[];for(let i=0;i<coords.length;i++)rings=rings.concat(coords[i]);data={type:"polygon",rings:rings}}}return{...data,...base}}function extractFieldsFromProperties(properties){const fields=[];if(!properties)return fields;for(let key in properties)properties.hasOwnProperty(key)&&fields.push({name:key,alias:key,type:inferFieldType(properties[key])});return fields}function inferFieldType(value){const t=typeof value;if("number"===t)return Number.isInteger(value)?"integer":"double";if("string"===t){const date=Date.parse(value);return isNaN(date)||-1===value.indexOf("T")?"string":"date"}return"boolean"===t?"small-integer":"string"}function detectGeometryType(features){if(!features||0===features.length)return null;const firstGeometry=features[0].geometry;if(!firstGeometry||!firstGeometry.type)return null;const type=firstGeometry.type;return"Point"===type||"MultiPoint"===type?"point":"LineString"===type||"MultiLineString"===type?"polyline":"Polygon"===type||"MultiPolygon"===type?"polygon":null}function geojsonToFeatureSet(geojson){if(!geojson||"FeatureCollection"!==geojson.type)throw new Error("Invalid GeoJSON");const reference=detectSpatialReferenceFromGeoJSON(geojson),features=[];for(let i=0;i<geojson.features.length;i++){const feature=geojson.features[i],geometry=convertGeometry(feature.geometry,reference);features.push({geometry:geometry,attributes:feature.properties||{}})}const fields=extractFieldsFromProperties(geojson.features.length>0?geojson.features[0].properties:null),featureSet=new o({features:features,fields:fields,geometryType:detectGeometryType(geojson.features),spatialReference:reference});return featureSet}async function turnToGeoJSON(arraybuffer){const uint8Array=new Uint8Array(arraybuffer);let header=null;const geojson=await flatgeobufGeojson.default.deserialize(uint8Array,()=>{},some=>{header=some});return header&&header.crs&&(geojson.crs={type:"name",properties:{name:header.crs.org+":"+header.crs.code}}),geojson}async function s(r,e,t,s){const p=await n(r,a.from(e),t,s),geojson=await turnToGeoJSON(p);return geojsonToFeatureSet(geojson)}async function n(o,s,n,p){const i=r(o),u={...n},m=a.from(s),f=!m.quantizationParameters,{data:c}=await t(i,m,new e({sourceSpatialReference:m.sourceSpatialReference,applyTransform:f}),u,p);return c}export{s as executeQueryFGB,n as executeRawQueryFGB};
@@ -0,0 +1,3 @@
1
+ import './flatgeobufGeojson.min.js'
2
+ const flatgeobufGeojson = window.flatgeobuf // 或 globalThis.flatgeobuf
3
+ export default flatgeobufGeojson
@@ -0,0 +1,15 @@
1
+ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).flatgeobuf={})}(this,(function(t){"use strict";var e,r=((e={})[e.Unknown=0]="Unknown",e[e.Point=1]="Point",e[e.LineString=2]="LineString",e[e.Polygon=3]="Polygon",e[e.MultiPoint=4]="MultiPoint",e[e.MultiLineString=5]="MultiLineString",e[e.MultiPolygon=6]="MultiPolygon",e[e.GeometryCollection=7]="GeometryCollection",e[e.CircularString=8]="CircularString",e[e.CompoundCurve=9]="CompoundCurve",e[e.CurvePolygon=10]="CurvePolygon",e[e.MultiCurve=11]="MultiCurve",e[e.MultiSurface=12]="MultiSurface",e[e.Curve=13]="Curve",e[e.Surface=14]="Surface",e[e.PolyhedralSurface=15]="PolyhedralSurface",e[e.TIN=16]="TIN",e[e.Triangle=17]="Triangle",e);const n=new Int32Array(2),i=new Float32Array(n.buffer),s=new Float64Array(n.buffer),o=1===new Uint16Array(new Uint8Array([1,0]).buffer)[0];var a,l;!function(t){t[t.UTF8_BYTES=1]="UTF8_BYTES",t[t.UTF16_STRING=2]="UTF16_STRING"}(a||(a={}));class h{constructor(t){this.bytes_=t,this.position_=0,this.text_decoder_=new TextDecoder}static allocate(t){return new h(new Uint8Array(t))}clear(){this.position_=0}bytes(){return this.bytes_}position(){return this.position_}setPosition(t){this.position_=t}capacity(){return this.bytes_.length}readInt8(t){return this.readUint8(t)<<24>>24}readUint8(t){return this.bytes_[t]}readInt16(t){return this.readUint16(t)<<16>>16}readUint16(t){return this.bytes_[t]|this.bytes_[t+1]<<8}readInt32(t){return this.bytes_[t]|this.bytes_[t+1]<<8|this.bytes_[t+2]<<16|this.bytes_[t+3]<<24}readUint32(t){return this.readInt32(t)>>>0}readInt64(t){return BigInt.asIntN(64,BigInt(this.readUint32(t))+(BigInt(this.readUint32(t+4))<<BigInt(32)))}readUint64(t){return BigInt.asUintN(64,BigInt(this.readUint32(t))+(BigInt(this.readUint32(t+4))<<BigInt(32)))}readFloat32(t){return n[0]=this.readInt32(t),i[0]}readFloat64(t){return n[o?0:1]=this.readInt32(t),n[o?1:0]=this.readInt32(t+4),s[0]}writeInt8(t,e){this.bytes_[t]=e}writeUint8(t,e){this.bytes_[t]=e}writeInt16(t,e){this.bytes_[t]=e,this.bytes_[t+1]=e>>8}writeUint16(t,e){this.bytes_[t]=e,this.bytes_[t+1]=e>>8}writeInt32(t,e){this.bytes_[t]=e,this.bytes_[t+1]=e>>8,this.bytes_[t+2]=e>>16,this.bytes_[t+3]=e>>24}writeUint32(t,e){this.bytes_[t]=e,this.bytes_[t+1]=e>>8,this.bytes_[t+2]=e>>16,this.bytes_[t+3]=e>>24}writeInt64(t,e){this.writeInt32(t,Number(BigInt.asIntN(32,e))),this.writeInt32(t+4,Number(BigInt.asIntN(32,e>>BigInt(32))))}writeUint64(t,e){this.writeUint32(t,Number(BigInt.asUintN(32,e))),this.writeUint32(t+4,Number(BigInt.asUintN(32,e>>BigInt(32))))}writeFloat32(t,e){i[0]=e,this.writeInt32(t,n[0])}writeFloat64(t,e){s[0]=e,this.writeInt32(t,n[o?0:1]),this.writeInt32(t+4,n[o?1:0])}getBufferIdentifier(){if(this.bytes_.length<this.position_+4+4)throw new Error("FlatBuffers: ByteBuffer is too short to contain an identifier.");let t="";for(let e=0;e<4;e++)t+=String.fromCharCode(this.readInt8(this.position_+4+e));return t}__offset(t,e){const r=t-this.readInt32(t);return e<this.readInt16(r)?this.readInt16(r+e):0}__union(t,e){return t.bb_pos=e+this.readInt32(e),t.bb=this,t}__string(t,e){t+=this.readInt32(t);const r=this.readInt32(t);t+=4;const n=this.bytes_.subarray(t,t+r);return e===a.UTF8_BYTES?n:this.text_decoder_.decode(n)}__union_with_string(t,e){return"string"==typeof t?this.__string(e):this.__union(t,e)}__indirect(t){return t+this.readInt32(t)}__vector(t){return t+this.readInt32(t)+4}__vector_len(t){return this.readInt32(t+this.readInt32(t))}__has_identifier(t){if(4!=t.length)throw new Error("FlatBuffers: file identifier must be length 4");for(let e=0;e<4;e++)if(t.charCodeAt(e)!=this.readInt8(this.position()+4+e))return!1;return!0}createScalarList(t,e){const r=[];for(let n=0;n<e;++n){const e=t(n);null!==e&&r.push(e)}return r}createObjList(t,e){const r=[];for(let n=0;n<e;++n){const e=t(n);null!==e&&r.push(e.unpack())}return r}}class u{constructor(t){let e;this.minalign=1,this.vtable=null,this.vtable_in_use=0,this.isNested=!1,this.object_start=0,this.vtables=[],this.vector_num_elems=0,this.force_defaults=!1,this.string_maps=null,this.text_encoder=new TextEncoder,e=t||1024,this.bb=h.allocate(e),this.space=e}clear(){this.bb.clear(),this.space=this.bb.capacity(),this.minalign=1,this.vtable=null,this.vtable_in_use=0,this.isNested=!1,this.object_start=0,this.vtables=[],this.vector_num_elems=0,this.force_defaults=!1,this.string_maps=null}forceDefaults(t){this.force_defaults=t}dataBuffer(){return this.bb}asUint8Array(){return this.bb.bytes().subarray(this.bb.position(),this.bb.position()+this.offset())}prep(t,e){t>this.minalign&&(this.minalign=t);const r=1+~(this.bb.capacity()-this.space+e)&t-1;for(;this.space<r+t+e;){const t=this.bb.capacity();this.bb=u.growByteBuffer(this.bb),this.space+=this.bb.capacity()-t}this.pad(r)}pad(t){for(let e=0;e<t;e++)this.bb.writeInt8(--this.space,0)}writeInt8(t){this.bb.writeInt8(this.space-=1,t)}writeInt16(t){this.bb.writeInt16(this.space-=2,t)}writeInt32(t){this.bb.writeInt32(this.space-=4,t)}writeInt64(t){this.bb.writeInt64(this.space-=8,t)}writeFloat32(t){this.bb.writeFloat32(this.space-=4,t)}writeFloat64(t){this.bb.writeFloat64(this.space-=8,t)}addInt8(t){this.prep(1,0),this.writeInt8(t)}addInt16(t){this.prep(2,0),this.writeInt16(t)}addInt32(t){this.prep(4,0),this.writeInt32(t)}addInt64(t){this.prep(8,0),this.writeInt64(t)}addFloat32(t){this.prep(4,0),this.writeFloat32(t)}addFloat64(t){this.prep(8,0),this.writeFloat64(t)}addFieldInt8(t,e,r){(this.force_defaults||e!=r)&&(this.addInt8(e),this.slot(t))}addFieldInt16(t,e,r){(this.force_defaults||e!=r)&&(this.addInt16(e),this.slot(t))}addFieldInt32(t,e,r){(this.force_defaults||e!=r)&&(this.addInt32(e),this.slot(t))}addFieldInt64(t,e,r){(this.force_defaults||e!==r)&&(this.addInt64(e),this.slot(t))}addFieldFloat32(t,e,r){(this.force_defaults||e!=r)&&(this.addFloat32(e),this.slot(t))}addFieldFloat64(t,e,r){(this.force_defaults||e!=r)&&(this.addFloat64(e),this.slot(t))}addFieldOffset(t,e,r){(this.force_defaults||e!=r)&&(this.addOffset(e),this.slot(t))}addFieldStruct(t,e,r){e!=r&&(this.nested(e),this.slot(t))}nested(t){if(t!=this.offset())throw new TypeError("FlatBuffers: struct must be serialized inline.")}notNested(){if(this.isNested)throw new TypeError("FlatBuffers: object serialization must not be nested.")}slot(t){null!==this.vtable&&(this.vtable[t]=this.offset())}offset(){return this.bb.capacity()-this.space}static growByteBuffer(t){const e=t.capacity();if(3221225472&e)throw new Error("FlatBuffers: cannot grow buffer beyond 2 gigabytes.");const r=e<<1,n=h.allocate(r);return n.setPosition(r-e),n.bytes().set(t.bytes(),r-e),n}addOffset(t){this.prep(4,0),this.writeInt32(this.offset()-t+4)}startObject(t){this.notNested(),null==this.vtable&&(this.vtable=[]),this.vtable_in_use=t;for(let e=0;e<t;e++)this.vtable[e]=0;this.isNested=!0,this.object_start=this.offset()}endObject(){if(null==this.vtable||!this.isNested)throw new Error("FlatBuffers: endObject called without startObject");this.addInt32(0);const t=this.offset();let e=this.vtable_in_use-1;for(;e>=0&&0==this.vtable[e];e--);const r=e+1;for(;e>=0;e--)this.addInt16(0!=this.vtable[e]?t-this.vtable[e]:0);this.addInt16(t-this.object_start);const n=2*(r+2);this.addInt16(n);let i=0;const s=this.space;t:for(e=0;e<this.vtables.length;e++){const t=this.bb.capacity()-this.vtables[e];if(n==this.bb.readInt16(t)){for(let e=2;e<n;e+=2)if(this.bb.readInt16(s+e)!=this.bb.readInt16(t+e))continue t;i=this.vtables[e];break}}return i?(this.space=this.bb.capacity()-t,this.bb.writeInt32(this.space,i-t)):(this.vtables.push(this.offset()),this.bb.writeInt32(this.bb.capacity()-t,this.offset()-t)),this.isNested=!1,t}finish(t,e,r){const n=r?4:0;if(e){const t=e;if(this.prep(this.minalign,8+n),4!=t.length)throw new TypeError("FlatBuffers: file identifier must be length 4");for(let e=3;e>=0;e--)this.writeInt8(t.charCodeAt(e))}this.prep(this.minalign,4+n),this.addOffset(t),n&&this.addInt32(this.bb.capacity()-this.space),this.bb.setPosition(this.space)}finishSizePrefixed(t,e){this.finish(t,e,!0)}requiredField(t,e){const r=this.bb.capacity()-t,n=r-this.bb.readInt32(r);if(!(e<this.bb.readInt16(n)&&0!=this.bb.readInt16(n+e)))throw new TypeError("FlatBuffers: field "+e+" must be set")}startVector(t,e,r){this.notNested(),this.vector_num_elems=e,this.prep(4,t*e),this.prep(r,t*e)}endVector(){return this.writeInt32(this.vector_num_elems),this.offset()}createSharedString(t){if(!t)return 0;if(this.string_maps||(this.string_maps=new Map),this.string_maps.has(t))return this.string_maps.get(t);const e=this.createString(t);return this.string_maps.set(t,e),e}createString(t){if(null==t)return 0;let e;return e=t instanceof Uint8Array?t:this.text_encoder.encode(t),this.addInt8(0),this.startVector(1,e.length,1),this.bb.setPosition(this.space-=e.length),this.bb.bytes().set(e,this.space),this.endVector()}createByteVector(t){return null==t?0:(this.startVector(1,t.length,1),this.bb.setPosition(this.space-=t.length),this.bb.bytes().set(t,this.space),this.endVector())}createObjectOffset(t){return null===t?0:"string"==typeof t?this.createString(t):t.pack(this)}createObjectOffsetList(t){const e=[];for(let r=0;r<t.length;++r){const n=t[r];if(null===n)throw new TypeError("FlatBuffers: Argument for createObjectOffsetList cannot contain null.");e.push(this.createObjectOffset(n))}return e}createStructOffsetList(t,e){return e(this,t.length),this.createObjectOffsetList(t.slice().reverse()),this.endVector()}}class b{bb=null;bb_pos=0;__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsGeometry(t,e){return(e||new b).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsGeometry(t,e){return t.setPosition(t.position()+4),(e||new b).__init(t.readInt32(t.position())+t.position(),t)}ends(t){let e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readUint32(this.bb.__vector(this.bb_pos+e)+4*t):0}endsLength(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.__vector_len(this.bb_pos+t):0}endsArray(){let t=this.bb.__offset(this.bb_pos,4);return t?new Uint32Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+t),this.bb.__vector_len(this.bb_pos+t)):null}xy(t){let e=this.bb.__offset(this.bb_pos,6);return e?this.bb.readFloat64(this.bb.__vector(this.bb_pos+e)+8*t):0}xyLength(){let t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__vector_len(this.bb_pos+t):0}xyArray(){let t=this.bb.__offset(this.bb_pos,6);return t?new Float64Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+t),this.bb.__vector_len(this.bb_pos+t)):null}z(t){let e=this.bb.__offset(this.bb_pos,8);return e?this.bb.readFloat64(this.bb.__vector(this.bb_pos+e)+8*t):0}zLength(){let t=this.bb.__offset(this.bb_pos,8);return t?this.bb.__vector_len(this.bb_pos+t):0}zArray(){let t=this.bb.__offset(this.bb_pos,8);return t?new Float64Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+t),this.bb.__vector_len(this.bb_pos+t)):null}m(t){let e=this.bb.__offset(this.bb_pos,10);return e?this.bb.readFloat64(this.bb.__vector(this.bb_pos+e)+8*t):0}mLength(){let t=this.bb.__offset(this.bb_pos,10);return t?this.bb.__vector_len(this.bb_pos+t):0}mArray(){let t=this.bb.__offset(this.bb_pos,10);return t?new Float64Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+t),this.bb.__vector_len(this.bb_pos+t)):null}t(t){let e=this.bb.__offset(this.bb_pos,12);return e?this.bb.readFloat64(this.bb.__vector(this.bb_pos+e)+8*t):0}tLength(){let t=this.bb.__offset(this.bb_pos,12);return t?this.bb.__vector_len(this.bb_pos+t):0}tArray(){let t=this.bb.__offset(this.bb_pos,12);return t?new Float64Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+t),this.bb.__vector_len(this.bb_pos+t)):null}tm(t){let e=this.bb.__offset(this.bb_pos,14);return e?this.bb.readUint64(this.bb.__vector(this.bb_pos+e)+8*t):BigInt(0)}tmLength(){let t=this.bb.__offset(this.bb_pos,14);return t?this.bb.__vector_len(this.bb_pos+t):0}type(){let t=this.bb.__offset(this.bb_pos,16);return t?this.bb.readUint8(this.bb_pos+t):r.Unknown}parts(t,e){let r=this.bb.__offset(this.bb_pos,18);return r?(e||new b).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+4*t),this.bb):null}partsLength(){let t=this.bb.__offset(this.bb_pos,18);return t?this.bb.__vector_len(this.bb_pos+t):0}static startGeometry(t){t.startObject(8)}static addEnds(t,e){t.addFieldOffset(0,e,0)}static createEndsVector(t,e){t.startVector(4,e.length,4);for(let r=e.length-1;r>=0;r--)t.addInt32(e[r]);return t.endVector()}static startEndsVector(t,e){t.startVector(4,e,4)}static addXy(t,e){t.addFieldOffset(1,e,0)}static createXyVector(t,e){t.startVector(8,e.length,8);for(let r=e.length-1;r>=0;r--)t.addFloat64(e[r]);return t.endVector()}static startXyVector(t,e){t.startVector(8,e,8)}static addZ(t,e){t.addFieldOffset(2,e,0)}static createZVector(t,e){t.startVector(8,e.length,8);for(let r=e.length-1;r>=0;r--)t.addFloat64(e[r]);return t.endVector()}static startZVector(t,e){t.startVector(8,e,8)}static addM(t,e){t.addFieldOffset(3,e,0)}static createMVector(t,e){t.startVector(8,e.length,8);for(let r=e.length-1;r>=0;r--)t.addFloat64(e[r]);return t.endVector()}static startMVector(t,e){t.startVector(8,e,8)}static addT(t,e){t.addFieldOffset(4,e,0)}static createTVector(t,e){t.startVector(8,e.length,8);for(let r=e.length-1;r>=0;r--)t.addFloat64(e[r]);return t.endVector()}static startTVector(t,e){t.startVector(8,e,8)}static addTm(t,e){t.addFieldOffset(5,e,0)}static createTmVector(t,e){t.startVector(8,e.length,8);for(let r=e.length-1;r>=0;r--)t.addInt64(e[r]);return t.endVector()}static startTmVector(t,e){t.startVector(8,e,8)}static addType(t,e){t.addFieldInt8(6,e,r.Unknown)}static addParts(t,e){t.addFieldOffset(7,e,0)}static createPartsVector(t,e){t.startVector(4,e.length,4);for(let r=e.length-1;r>=0;r--)t.addOffset(e[r]);return t.endVector()}static startPartsVector(t,e){t.startVector(4,e,4)}static endGeometry(t){return t.endObject()}static createGeometry(t,e,r,n,i,s,o,a,l){return b.startGeometry(t),b.addEnds(t,e),b.addXy(t,r),b.addZ(t,n),b.addM(t,i),b.addT(t,s),b.addTm(t,o),b.addType(t,a),b.addParts(t,l),b.endGeometry(t)}}function c(t,e){let r,n,{xy:i,z:s,ends:o,parts:a,type:l}=e;if(a){let e=a.map((e=>c(t,e))),r=b.createPartsVector(t,e);return b.startGeometry(t),b.addParts(t,r),b.addType(t,l),b.endGeometry(t)}let h=b.createXyVector(t,i);return s&&(r=b.createZVector(t,s)),o&&(n=b.createEndsVector(t,o)),b.startGeometry(t),n&&b.addEnds(t,n),b.addXy(t,h),r&&b.addZ(t,r),b.addType(t,l),b.endGeometry(t)}function d(t,e,r){if(0!==t.length)if(Array.isArray(t[0]))for(let n of t)d(n,e,r);else 2===t.length?e.push(...t):(e.push(t[0],t[1]),r.push(t[2]))}function f(t,e){let r=[];for(let n=0;n<t.length;n+=2){let i=[t[n],t[n+1]];e&&i.push(e[n>>1]),r.push(i)}return r}function _(t){return t?r[t]:r.Unknown}function p(t){let e,r,n=t.coordinates,i=[],s=[],o=_(t.type),a=0;switch(t.type){case"Point":case"MultiPoint":case"LineString":d(n,i,s);break;case"MultiLineString":case"Polygon":d(n,i,s),n.length>1&&(e=n.map((t=>a+=t.length)));break;case"MultiPolygon":r=n.map((t=>({type:"Polygon",coordinates:t}))).map(p)}return{xy:i,z:s.length>0?s:void 0,ends:e,type:o,parts:r}}function y(t){let e=_(t.type),r=[];for(let e=0;e<t.geometries.length;e++){let n=t.geometries[e];"GeometryCollection"===n.type?r.push(y(n)):r.push(p(n))}return{type:e,parts:r}}function g(t,e){let n=e;if(n===r.Unknown&&(n=t.type()),n===r.GeometryCollection){let e=[];for(let r=0;r<t.partsLength();r++){let n=t.parts(r),i=n.type();e.push(g(n,i))}return{type:r[n],geometries:e}}if(n===r.MultiPolygon){let e=[];for(let n=0;n<t.partsLength();n++)e.push(g(t.parts(n),r.Polygon));return{type:r[n],coordinates:e.map((t=>t.coordinates))}}let i=function(t,e){let n=t.xyArray(),i=t.zArray();switch(e){case r.Point:{let t=Array.from(n);return i&&t.push(i[0]),t}case r.MultiPoint:case r.LineString:return f(n,i);case r.MultiLineString:case r.Polygon:return function(t,e,r){let n;if(!r||0===r.length)return[f(t,e)];let i=0,s=Array.from(r).map((e=>t.slice(i,i=e<<1)));return e&&(i=0,n=Array.from(r).map((t=>e.slice(i,i=t)))),s.map(((t,e)=>f(t,n?n[e]:void 0)))}(n,i,t.endsArray())}}(t,n);return{type:r[n],coordinates:i}}var w=((l={})[l.Byte=0]="Byte",l[l.UByte=1]="UByte",l[l.Bool=2]="Bool",l[l.Short=3]="Short",l[l.UShort=4]="UShort",l[l.Int=5]="Int",l[l.UInt=6]="UInt",l[l.Long=7]="Long",l[l.ULong=8]="ULong",l[l.Float=9]="Float",l[l.Double=10]="Double",l[l.String=11]="String",l[l.Json=12]="Json",l[l.DateTime=13]="DateTime",l[l.Binary=14]="Binary",l);class m{bb=null;bb_pos=0;__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsColumn(t,e){return(e||new m).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsColumn(t,e){return t.setPosition(t.position()+4),(e||new m).__init(t.readInt32(t.position())+t.position(),t)}name(t){let e=this.bb.__offset(this.bb_pos,4);return e?this.bb.__string(this.bb_pos+e,t):null}type(){let t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readUint8(this.bb_pos+t):w.Byte}title(t){let e=this.bb.__offset(this.bb_pos,8);return e?this.bb.__string(this.bb_pos+e,t):null}description(t){let e=this.bb.__offset(this.bb_pos,10);return e?this.bb.__string(this.bb_pos+e,t):null}width(){let t=this.bb.__offset(this.bb_pos,12);return t?this.bb.readInt32(this.bb_pos+t):-1}precision(){let t=this.bb.__offset(this.bb_pos,14);return t?this.bb.readInt32(this.bb_pos+t):-1}scale(){let t=this.bb.__offset(this.bb_pos,16);return t?this.bb.readInt32(this.bb_pos+t):-1}nullable(){let t=this.bb.__offset(this.bb_pos,18);return!t||!!this.bb.readInt8(this.bb_pos+t)}unique(){let t=this.bb.__offset(this.bb_pos,20);return!!t&&!!this.bb.readInt8(this.bb_pos+t)}primaryKey(){let t=this.bb.__offset(this.bb_pos,22);return!!t&&!!this.bb.readInt8(this.bb_pos+t)}metadata(t){let e=this.bb.__offset(this.bb_pos,24);return e?this.bb.__string(this.bb_pos+e,t):null}static startColumn(t){t.startObject(11)}static addName(t,e){t.addFieldOffset(0,e,0)}static addType(t,e){t.addFieldInt8(1,e,w.Byte)}static addTitle(t,e){t.addFieldOffset(2,e,0)}static addDescription(t,e){t.addFieldOffset(3,e,0)}static addWidth(t,e){t.addFieldInt32(4,e,-1)}static addPrecision(t,e){t.addFieldInt32(5,e,-1)}static addScale(t,e){t.addFieldInt32(6,e,-1)}static addNullable(t,e){t.addFieldInt8(7,+e,1)}static addUnique(t,e){t.addFieldInt8(8,+e,0)}static addPrimaryKey(t,e){t.addFieldInt8(9,+e,0)}static addMetadata(t,e){t.addFieldOffset(10,e,0)}static endColumn(t){let e=t.endObject();return t.requiredField(e,4),e}static createColumn(t,e,r,n,i,s,o,a,l,h,u,b){return m.startColumn(t),m.addName(t,e),m.addType(t,r),m.addTitle(t,n),m.addDescription(t,i),m.addWidth(t,s),m.addPrecision(t,o),m.addScale(t,a),m.addNullable(t,l),m.addUnique(t,h),m.addPrimaryKey(t,u),m.addMetadata(t,b),m.endColumn(t)}}class v{bb=null;bb_pos=0;__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsFeature(t,e){return(e||new v).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsFeature(t,e){return t.setPosition(t.position()+4),(e||new v).__init(t.readInt32(t.position())+t.position(),t)}geometry(t){let e=this.bb.__offset(this.bb_pos,4);return e?(t||new b).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}properties(t){let e=this.bb.__offset(this.bb_pos,6);return e?this.bb.readUint8(this.bb.__vector(this.bb_pos+e)+t):0}propertiesLength(){let t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__vector_len(this.bb_pos+t):0}propertiesArray(){let t=this.bb.__offset(this.bb_pos,6);return t?new Uint8Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+t),this.bb.__vector_len(this.bb_pos+t)):null}columns(t,e){let r=this.bb.__offset(this.bb_pos,8);return r?(e||new m).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+4*t),this.bb):null}columnsLength(){let t=this.bb.__offset(this.bb_pos,8);return t?this.bb.__vector_len(this.bb_pos+t):0}static startFeature(t){t.startObject(3)}static addGeometry(t,e){t.addFieldOffset(0,e,0)}static addProperties(t,e){t.addFieldOffset(1,e,0)}static createPropertiesVector(t,e){t.startVector(1,e.length,1);for(let r=e.length-1;r>=0;r--)t.addInt8(e[r]);return t.endVector()}static startPropertiesVector(t,e){t.startVector(1,e,1)}static addColumns(t,e){t.addFieldOffset(2,e,0)}static createColumnsVector(t,e){t.startVector(4,e.length,4);for(let r=e.length-1;r>=0;r--)t.addOffset(e[r]);return t.endVector()}static startColumnsVector(t,e){t.startVector(4,e,4)}static endFeature(t){return t.endObject()}static finishFeatureBuffer(t,e){t.finish(e)}static finishSizePrefixedFeatureBuffer(t,e){t.finish(e,void 0,!0)}static createFeature(t,e,r,n){return v.startFeature(t),v.addGeometry(t,e),v.addProperties(t,r),v.addColumns(t,n),v.endFeature(t)}}let I=new TextEncoder,F=new TextDecoder;function x(t,e,r){let n=r.columns,i=new u,s=0,o=1024,a=new Uint8Array(1024),l=new DataView(a.buffer),h=function(t){if(s+t<o)return;let e=new Uint8Array(o=Math.max(o+t,2*o));e.set(a),l=new DataView((a=e).buffer)};if(n)for(let t=0;t<n.length;t++){let r=n[t],i=e[r.name];if(null!==i)switch(h(2),l.setUint16(s,t,!0),s+=2,r.type){case w.Bool:h(1),l.setUint8(s,i),s+=1;break;case w.Short:h(2),l.setInt16(s,i,!0),s+=2;break;case w.UShort:h(2),l.setUint16(s,i,!0),s+=2;break;case w.Int:h(4),l.setInt32(s,i,!0),s+=4;break;case w.UInt:h(4),l.setUint32(s,i,!0),s+=4;break;case w.Long:h(8),l.setBigInt64(s,BigInt(i),!0),s+=8;break;case w.Float:h(4),l.setFloat32(s,i,!0),s+=4;break;case w.Double:h(8),l.setFloat64(s,i,!0),s+=8;break;case w.DateTime:case w.String:{let t=I.encode(i);h(4),l.setUint32(s,t.length,!0),s+=4,h(t.length),a.set(t,s),s+=t.length;break}case w.Json:{let t=I.encode(JSON.stringify(i));h(4),l.setUint32(s,t.length,!0),s+=4,h(t.length),a.set(t,s),s+=t.length;break}case w.Binary:h(4),l.setUint32(s,i.length,!0),s+=4,h(i.length),a.set(i,s),s+=i.length;break;default:throw Error("Unknown type "+r.type)}}let b=0;s>0&&(b=v.createPropertiesVector(i,a.slice(0,s)));let d=c(i,t);v.startFeature(i),v.addGeometry(i,d),b&&v.addProperties(i,b);let f=v.endFeature(i);return i.finishSizePrefixed(f),i.asUint8Array()}function U(t,e){let r={};if(!e||0===e.length)return r;let n=t.propertiesArray();if(!n)return r;let i=new DataView(n.buffer,n.byteOffset),s=t.propertiesLength(),o=0;for(;o<s;){let t=i.getUint16(o,!0);o+=2;let s=e[t],a=s.name;switch(s.type){case w.Bool:r[a]=!!i.getUint8(o),o+=1;break;case w.Byte:r[a]=i.getInt8(o),o+=1;break;case w.UByte:r[a]=i.getUint8(o),o+=1;break;case w.Short:r[a]=i.getInt16(o,!0),o+=2;break;case w.UShort:r[a]=i.getUint16(o,!0),o+=2;break;case w.Int:r[a]=i.getInt32(o,!0),o+=4;break;case w.UInt:r[a]=i.getUint32(o,!0),o+=4;break;case w.Long:r[a]=Number(i.getBigInt64(o,!0)),o+=8;break;case w.ULong:r[a]=Number(i.getBigUint64(o,!0)),o+=8;break;case w.Float:r[a]=i.getFloat32(o,!0),o+=4;break;case w.Double:r[a]=i.getFloat64(o,!0),o+=8;break;case w.DateTime:case w.String:{let t=i.getUint32(o,!0);o+=4,r[a]=F.decode(n.subarray(o,o+t)),o+=t;break}case w.Json:{let t=i.getUint32(o,!0);o+=4;let e=F.decode(n.subarray(o,o+t));r[a]=JSON.parse(e),o+=t;break}case w.Binary:{let t=i.getUint32(o,!0);o+=4,r[a]=n.subarray(o,o+t),o+=t;break}default:throw Error("Unknown type "+s.type)}}return r}function P(t,e,r){let n=r.columns;return{type:"Feature",id:t,geometry:g(e.geometry(),r.geometryType),properties:U(e,n)}}var S=new Uint8Array(0);function O(t,e){if(!t.length)return e;if(!e.length)return t;var r=new Uint8Array(t.length+e.length);return r.set(t),r.set(e,t.length),r}function C(t){this._source=t,this._array=S,this._index=0}C.prototype.read=function(){var t=this,e=t._array.subarray(t._index);return t._source.read().then((function(r){return t._array=S,t._index=0,r.done?e.length>0?{done:!1,value:e}:{done:!0,value:void 0}:{done:!1,value:O(e,r.value)}}))},C.prototype.slice=function(t){if((t|=0)<0)throw new Error("invalid length");var e=this,r=this._array.length-this._index;if(this._index+t<=this._array.length)return Promise.resolve(this._array.subarray(this._index,this._index+=t));var n=new Uint8Array(t);return n.set(this._array.subarray(this._index)),function i(){return e._source.read().then((function(s){return s.done?(e._array=S,e._index=0,r>0?n.subarray(0,r):null):r+s.value.length>=t?(e._array=s.value,e._index=t-r,n.set(s.value.subarray(0,t-r),r),n):(n.set(s.value,r),r+=s.value.length,i())}))}()},C.prototype.cancel=function(){return this._source.cancel()};class B{bb=null;bb_pos=0;__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsCrs(t,e){return(e||new B).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsCrs(t,e){return t.setPosition(t.position()+4),(e||new B).__init(t.readInt32(t.position())+t.position(),t)}org(t){let e=this.bb.__offset(this.bb_pos,4);return e?this.bb.__string(this.bb_pos+e,t):null}code(){let t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readInt32(this.bb_pos+t):0}name(t){let e=this.bb.__offset(this.bb_pos,8);return e?this.bb.__string(this.bb_pos+e,t):null}description(t){let e=this.bb.__offset(this.bb_pos,10);return e?this.bb.__string(this.bb_pos+e,t):null}wkt(t){let e=this.bb.__offset(this.bb_pos,12);return e?this.bb.__string(this.bb_pos+e,t):null}codeString(t){let e=this.bb.__offset(this.bb_pos,14);return e?this.bb.__string(this.bb_pos+e,t):null}static startCrs(t){t.startObject(6)}static addOrg(t,e){t.addFieldOffset(0,e,0)}static addCode(t,e){t.addFieldInt32(1,e,0)}static addName(t,e){t.addFieldOffset(2,e,0)}static addDescription(t,e){t.addFieldOffset(3,e,0)}static addWkt(t,e){t.addFieldOffset(4,e,0)}static addCodeString(t,e){t.addFieldOffset(5,e,0)}static endCrs(t){return t.endObject()}static createCrs(t,e,r,n,i,s,o){return B.startCrs(t),B.addOrg(t,e),B.addCode(t,r),B.addName(t,n),B.addDescription(t,i),B.addWkt(t,s),B.addCodeString(t,o),B.endCrs(t)}}class V{bb=null;bb_pos=0;__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsHeader(t,e){return(e||new V).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsHeader(t,e){return t.setPosition(t.position()+4),(e||new V).__init(t.readInt32(t.position())+t.position(),t)}name(t){let e=this.bb.__offset(this.bb_pos,4);return e?this.bb.__string(this.bb_pos+e,t):null}envelope(t){let e=this.bb.__offset(this.bb_pos,6);return e?this.bb.readFloat64(this.bb.__vector(this.bb_pos+e)+8*t):0}envelopeLength(){let t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__vector_len(this.bb_pos+t):0}envelopeArray(){let t=this.bb.__offset(this.bb_pos,6);return t?new Float64Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+t),this.bb.__vector_len(this.bb_pos+t)):null}geometryType(){let t=this.bb.__offset(this.bb_pos,8);return t?this.bb.readUint8(this.bb_pos+t):r.Unknown}hasZ(){let t=this.bb.__offset(this.bb_pos,10);return!!t&&!!this.bb.readInt8(this.bb_pos+t)}hasM(){let t=this.bb.__offset(this.bb_pos,12);return!!t&&!!this.bb.readInt8(this.bb_pos+t)}hasT(){let t=this.bb.__offset(this.bb_pos,14);return!!t&&!!this.bb.readInt8(this.bb_pos+t)}hasTm(){let t=this.bb.__offset(this.bb_pos,16);return!!t&&!!this.bb.readInt8(this.bb_pos+t)}columns(t,e){let r=this.bb.__offset(this.bb_pos,18);return r?(e||new m).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+4*t),this.bb):null}columnsLength(){let t=this.bb.__offset(this.bb_pos,18);return t?this.bb.__vector_len(this.bb_pos+t):0}featuresCount(){let t=this.bb.__offset(this.bb_pos,20);return t?this.bb.readUint64(this.bb_pos+t):BigInt("0")}indexNodeSize(){let t=this.bb.__offset(this.bb_pos,22);return t?this.bb.readUint16(this.bb_pos+t):16}crs(t){let e=this.bb.__offset(this.bb_pos,24);return e?(t||new B).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}title(t){let e=this.bb.__offset(this.bb_pos,26);return e?this.bb.__string(this.bb_pos+e,t):null}description(t){let e=this.bb.__offset(this.bb_pos,28);return e?this.bb.__string(this.bb_pos+e,t):null}metadata(t){let e=this.bb.__offset(this.bb_pos,30);return e?this.bb.__string(this.bb_pos+e,t):null}static startHeader(t){t.startObject(14)}static addName(t,e){t.addFieldOffset(0,e,0)}static addEnvelope(t,e){t.addFieldOffset(1,e,0)}static createEnvelopeVector(t,e){t.startVector(8,e.length,8);for(let r=e.length-1;r>=0;r--)t.addFloat64(e[r]);return t.endVector()}static startEnvelopeVector(t,e){t.startVector(8,e,8)}static addGeometryType(t,e){t.addFieldInt8(2,e,r.Unknown)}static addHasZ(t,e){t.addFieldInt8(3,+e,0)}static addHasM(t,e){t.addFieldInt8(4,+e,0)}static addHasT(t,e){t.addFieldInt8(5,+e,0)}static addHasTm(t,e){t.addFieldInt8(6,+e,0)}static addColumns(t,e){t.addFieldOffset(7,e,0)}static createColumnsVector(t,e){t.startVector(4,e.length,4);for(let r=e.length-1;r>=0;r--)t.addOffset(e[r]);return t.endVector()}static startColumnsVector(t,e){t.startVector(4,e,4)}static addFeaturesCount(t,e){t.addFieldInt64(8,e,BigInt("0"))}static addIndexNodeSize(t,e){t.addFieldInt16(9,e,16)}static addCrs(t,e){t.addFieldOffset(10,e,0)}static addTitle(t,e){t.addFieldOffset(11,e,0)}static addDescription(t,e){t.addFieldOffset(12,e,0)}static addMetadata(t,e){t.addFieldOffset(13,e,0)}static endHeader(t){return t.endObject()}static finishHeaderBuffer(t,e){t.finish(e)}static finishSizePrefixedHeaderBuffer(t,e){t.finish(e,void 0,!0)}}function T(t){let e=V.getRootAsHeader(t),r=e.featuresCount(),n=e.indexNodeSize(),i=[];for(let t=0;t<e.columnsLength();t++){let r=e.columns(t);if(!r)throw Error("Column unexpectedly missing");if(!r.name())throw Error("Column name unexpectedly missing");i.push({name:r.name(),type:r.type(),title:r.title(),description:r.description(),width:r.width(),precision:r.precision(),scale:r.scale(),nullable:r.nullable(),unique:r.unique(),primary_key:r.primaryKey()})}let s=e.crs(),o=s?{org:s.org(),code:s.code(),name:s.name(),description:s.description(),wkt:s.wkt(),code_string:s.codeString()}:null;return{geometryType:e.geometryType(),columns:i,envelope:null,featuresCount:Number(r),indexNodeSize:n,crs:o,title:e.title(),description:e.description(),metadata:e.metadata()}}
2
+ /*! *****************************************************************************
3
+ Copyright (c) Microsoft Corporation.
4
+
5
+ Permission to use, copy, modify, and/or distribute this software for any
6
+ purpose with or without fee is hereby granted.
7
+
8
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
9
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
10
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
11
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
12
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
13
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
14
+ PERFORMANCE OF THIS SOFTWARE.
15
+ ***************************************************************************** */var A=function(t,e){return A=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])},A(t,e)};function E(t,e,r,n){return new(r||(r=Promise))((function(e,i){function s(t){try{a(n.next(t))}catch(t){i(t)}}function o(t){try{a(n.throw(t))}catch(t){i(t)}}function a(t){var n;t.done?e(t.value):(n=t.value,n instanceof r?n:new r((function(t){t(n)}))).then(s,o)}a((n=n.apply(t,[])).next())}))}function N(t,e){var r,n,i,s,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return s={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(s){return function(a){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;o;)try{if(r=1,n&&(i=2&s[0]?n.return:s[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,s[1])).done)return i;switch(n=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return o.label++,{value:s[1],done:!1};case 5:o.label++,n=s[1],s=[0];continue;case 7:s=o.ops.pop(),o.trys.pop();continue;default:if(!(i=o.trys,(i=i.length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){o=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){o.label=s[1];break}if(6===s[0]&&o.label<i[1]){o.label=i[1],i=s;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(s);break}i[2]&&o.ops.pop(),o.trys.pop();continue}s=e.call(t,o)}catch(t){s=[6,t],n=0}finally{r=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,a])}}}function k(t){var e="function"==typeof Symbol&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function L(t){return this instanceof L?(this.v=t,this):new L(t)}function R(t,e,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n,i=r.apply(t,e||[]),s=[];return n={},o("next"),o("throw"),o("return"),n[Symbol.asyncIterator]=function(){return this},n;function o(t){i[t]&&(n[t]=function(e){return new Promise((function(r,n){s.push([t,e,r,n])>1||a(t,e)}))})}function a(t,e){try{!function(t){t.value instanceof L?Promise.resolve(t.value.v).then(l,h):u(s[0][2],t)}(i[t](e))}catch(t){u(s[0][3],t)}}function l(t){a("next",t)}function h(t){a("throw",t)}function u(t,e){t(e),s.shift(),s.length&&a(s[0][0],s[0][1])}}var j=function(t){function e(e){var r=t.call(this,e)||this;return Object.defineProperty(r,"name",{value:"RepeaterOverflowError",enumerable:!1}),"function"==typeof Object.setPrototypeOf?Object.setPrototypeOf(r,r.constructor.prototype):r.__proto__=r.constructor.prototype,"function"==typeof Error.captureStackTrace&&Error.captureStackTrace(r,r.constructor),r}return function(t,e){function r(){this.constructor=t}A(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}(e,t),e}(Error);function M(t){null!=t&&"function"==typeof t.then&&t.then(z,z)}!function(){function t(t){if(t<0)throw new RangeError("Capacity may not be less than 0");this._c=t,this._q=[]}Object.defineProperty(t.prototype,"empty",{get:function(){return 0===this._q.length},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"full",{get:function(){return this._q.length>=this._c},enumerable:!1,configurable:!0}),t.prototype.add=function(t){if(this.full)throw new Error("Buffer full");this._q.push(t)},t.prototype.remove=function(){if(this.empty)throw new Error("Buffer empty");return this._q.shift()}}(),function(){function t(t){if(t<1)throw new RangeError("Capacity may not be less than 1");this._c=t,this._q=[]}Object.defineProperty(t.prototype,"empty",{get:function(){return 0===this._q.length},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"full",{get:function(){return!1},enumerable:!1,configurable:!0}),t.prototype.add=function(t){for(;this._q.length>=this._c;)this._q.shift();this._q.push(t)},t.prototype.remove=function(){if(this.empty)throw new Error("Buffer empty");return this._q.shift()}}(),function(){function t(t){if(t<1)throw new RangeError("Capacity may not be less than 1");this._c=t,this._q=[]}Object.defineProperty(t.prototype,"empty",{get:function(){return 0===this._q.length},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"full",{get:function(){return!1},enumerable:!1,configurable:!0}),t.prototype.add=function(t){this._q.length<this._c&&this._q.push(t)},t.prototype.remove=function(){if(this.empty)throw new Error("Buffer empty");return this._q.shift()}}();var q=1024,z=function(){};function G(t){var e=t.err,r=Promise.resolve(t.execution).then((function(t){if(null!=e)throw e;return t}));return t.err=void 0,t.execution=r.then((function(){}),(function(){})),void 0===t.pending?r:t.pending.then((function(){return r}))}function D(t,e){var r=t.state>=3;return Promise.resolve(e).then((function(e){return!r&&t.state>=4?G(t).then((function(t){return{value:t,done:!0}})):{value:e,done:r}}))}function H(t,e){var r,n;if(!(t.state>=2))if(t.state=2,t.onnext(),t.onstop(),null==t.err&&(t.err=e),0!==t.pushes.length||void 0!==t.buffer&&!t.buffer.empty)try{for(var i=k(t.pushes),s=i.next();!s.done;s=i.next()){s.value.resolve()}}catch(t){r={error:t}}finally{try{s&&!s.done&&(n=i.return)&&n.call(i)}finally{if(r)throw r.error}}else W(t)}function W(t){var e,r;if(!(t.state>=3)){t.state<2&&H(t),t.state=3,t.buffer=void 0;try{for(var n=k(t.nexts),i=n.next();!i.done;i=n.next()){var s=i.value,o=void 0===t.pending?G(t):t.pending.then((function(){return G(t)}));s.resolve(D(t,o))}}catch(t){e={error:t}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(e)throw e.error}}t.pushes=[],t.nexts=[]}}function X(t){t.state>=4||(t.state<3&&W(t),t.state=4)}function Z(t,e){if(M(e),t.pushes.length>=q)throw new j("No more than 1024 pending calls to push are allowed on a single repeater.");if(t.state>=2)return Promise.resolve(void 0);var r,n=void 0===t.pending?Promise.resolve(e):t.pending.then((function(){return e}));(n=n.catch((function(e){t.state<2&&(t.err=e),X(t)})),t.nexts.length)?(t.nexts.shift().resolve(D(t,n)),r=t.nexts.length?Promise.resolve(t.nexts[0].value):void 0===t.buffer||t.buffer.full?new Promise((function(e){return t.onnext=e})):Promise.resolve(void 0)):void 0===t.buffer||t.buffer.full?r=new Promise((function(e){return t.pushes.push({resolve:e,value:n})})):(t.buffer.add(n),r=Promise.resolve(void 0));var i=!0,s={},o=r.catch((function(t){if(i)throw t}));return s.then=function(t,e){return i=!1,Promise.prototype.then.call(r,t,e)},s.catch=function(t){return i=!1,Promise.prototype.catch.call(r,t)},s.finally=r.finally.bind(r),t.pending=n.then((function(){return o})).catch((function(e){t.err=e,X(t)})),s}function J(t){if(!(t.state>=1)){t.state=1;var e=Z.bind(null,t),r=function(t){var e=H.bind(null,t),r=new Promise((function(e){return t.onstop=e}));return e.then=r.then.bind(r),e.catch=r.catch.bind(r),e.finally=r.finally.bind(r),e}(t);t.execution=new Promise((function(n){return n(t.executor(e,r))})),t.execution.catch((function(){return H(t)}))}}var $=new WeakMap,Y=function(){function t(t,e){$.set(this,{executor:t,buffer:e,err:void 0,state:0,pushes:[],nexts:[],pending:void 0,execution:void 0,onnext:z,onstop:z})}return t.prototype.next=function(t){M(t);var e=$.get(this);if(void 0===e)throw new Error("WeakMap error");if(e.nexts.length>=q)throw new j("No more than 1024 pending calls to next are allowed on a single repeater.");if(e.state<=0&&J(e),e.onnext(t),void 0!==e.buffer&&!e.buffer.empty){var r=D(e,e.buffer.remove());if(e.pushes.length){var n=e.pushes.shift();e.buffer.add(n.value),e.onnext=n.resolve}return r}if(e.pushes.length){var i=e.pushes.shift();return e.onnext=i.resolve,D(e,i.value)}return e.state>=2?(W(e),D(e,G(e))):new Promise((function(r){return e.nexts.push({resolve:r,value:t})}))},t.prototype.return=function(t){M(t);var e=$.get(this);if(void 0===e)throw new Error("WeakMap error");return W(e),e.execution=Promise.resolve(e.execution).then((function(){return t})),D(e,G(e))},t.prototype.throw=function(t){var e=$.get(this);if(void 0===e)throw new Error("WeakMap error");return e.state<=0||e.state>=2||void 0!==e.buffer&&!e.buffer.empty?(W(e),null==e.err&&(e.err=t),D(e,G(e))):this.next(Promise.reject(t))},t.prototype[Symbol.asyncIterator]=function(){return this},t.race=Q,t.merge=tt,t.zip=et,t.latest=rt,t}();function K(t,e){var r,n,i=[],s=function(t){null!=t&&"function"==typeof t[Symbol.asyncIterator]?i.push(t[Symbol.asyncIterator]()):null!=t&&"function"==typeof t[Symbol.iterator]?i.push(t[Symbol.iterator]()):i.push(function(){return R(this,arguments,(function(){return N(this,(function(r){switch(r.label){case 0:return e.yieldValues?[4,L(t)]:[3,3];case 1:return[4,r.sent()];case 2:r.sent(),r.label=3;case 3:return e.returnValues?[4,L(t)]:[3,5];case 4:return[2,r.sent()];case 5:return[2]}}))}))}())};try{for(var o=k(t),a=o.next();!a.done;a=o.next()){s(a.value)}}catch(t){r={error:t}}finally{try{a&&!a.done&&(n=o.return)&&n.call(o)}finally{if(r)throw r.error}}return i}function Q(t){var e=this,r=K(t,{returnValues:!0});return new Y((function(t,n){return E(e,0,void 0,(function(){var e,i,s,o,a,l;return N(this,(function(h){switch(h.label){case 0:if(!r.length)return n(),[2];i=!1,n.then((function(){e(),i=!0})),h.label=1;case 1:h.trys.push([1,,5,7]),o=void 0,a=0,l=function(){var i,l,h,u,b,c;return N(this,(function(d){switch(d.label){case 0:i=a;try{for(b=void 0,l=k(r),h=l.next();!h.done;h=l.next())u=h.value,Promise.resolve(u.next()).then((function(t){t.done?(n(),void 0===s&&(s=t)):a===i&&(a++,e(t))}),(function(t){return n(t)}))}catch(t){b={error:t}}finally{try{h&&!h.done&&(c=l.return)&&c.call(l)}finally{if(b)throw b.error}}return[4,new Promise((function(t){return e=t}))];case 1:return void 0===(o=d.sent())?[3,3]:[4,t(o.value)];case 2:d.sent(),d.label=3;case 3:return[2]}}))},h.label=2;case 2:return i?[3,4]:[5,l()];case 3:return h.sent(),[3,2];case 4:return[2,s&&s.value];case 5:return n(),[4,Promise.race(r.map((function(t){return t.return&&t.return()})))];case 6:return h.sent(),[7];case 7:return[2]}}))}))}))}function tt(t){var e=this,r=K(t,{yieldValues:!0});return new Y((function(t,n){return E(e,0,void 0,(function(){var e,i,s,o=this;return N(this,(function(a){switch(a.label){case 0:if(!r.length)return n(),[2];e=[],i=!1,n.then((function(){var t,r;i=!0;try{for(var n=k(e),s=n.next();!s.done;s=n.next()){(0,s.value)()}}catch(e){t={error:e}}finally{try{s&&!s.done&&(r=n.return)&&r.call(n)}finally{if(t)throw t.error}}})),a.label=1;case 1:return a.trys.push([1,,3,4]),[4,Promise.all(r.map((function(r,a){return E(o,0,void 0,(function(){var o;return N(this,(function(l){switch(l.label){case 0:l.trys.push([0,,6,9]),l.label=1;case 1:return i?[3,5]:(Promise.resolve(r.next()).then((function(t){return e[a](t)}),(function(t){return n(t)})),[4,new Promise((function(t){e[a]=t}))]);case 2:return void 0===(o=l.sent())?[3,4]:o.done?(s=o,[2]):[4,t(o.value)];case 3:l.sent(),l.label=4;case 4:return[3,1];case 5:return[3,9];case 6:return r.return?[4,r.return()]:[3,8];case 7:l.sent(),l.label=8;case 8:return[7];case 9:return[2]}}))}))})))];case 2:return a.sent(),[2,s&&s.value];case 3:return n(),[7];case 4:return[2]}}))}))}))}function et(t){var e=this,r=K(t,{returnValues:!0});return new Y((function(t,n){return E(e,0,void 0,(function(){var e,i,s,o;return N(this,(function(a){switch(a.label){case 0:if(!r.length)return n(),[2,[]];i=!1,n.then((function(){e(),i=!0})),a.label=1;case 1:a.trys.push([1,,6,8]),a.label=2;case 2:return i?[3,5]:(Promise.all(r.map((function(t){return t.next()}))).then((function(t){return e(t)}),(function(t){return n(t)})),[4,new Promise((function(t){return e=t}))]);case 3:return void 0===(s=a.sent())?[2]:(o=s.map((function(t){return t.value})),s.some((function(t){return t.done}))?[2,o]:[4,t(o)]);case 4:return a.sent(),[3,2];case 5:return[3,8];case 6:return n(),[4,Promise.all(r.map((function(t){return t.return&&t.return()})))];case 7:return a.sent(),[7];case 8:return[2]}}))}))}))}function rt(t){var e=this,r=K(t,{yieldValues:!0,returnValues:!0});return new Y((function(t,n){return E(e,0,void 0,(function(){var e,i,s,o,a,l=this;return N(this,(function(h){switch(h.label){case 0:if(!r.length)return n(),[2,[]];i=[],s=!1,n.then((function(){var t,r;e();try{for(var n=k(i),o=n.next();!o.done;o=n.next()){(0,o.value)()}}catch(e){t={error:e}}finally{try{o&&!o.done&&(r=n.return)&&r.call(n)}finally{if(t)throw t.error}}s=!0})),h.label=1;case 1:return h.trys.push([1,,5,7]),Promise.all(r.map((function(t){return t.next()}))).then((function(t){return e(t)}),(function(t){return n(t)})),[4,new Promise((function(t){return e=t}))];case 2:return void 0===(o=h.sent())?[2]:(a=o.map((function(t){return t.value})),o.every((function(t){return t.done}))?[2,a]:[4,t(a.slice())]);case 3:return h.sent(),[4,Promise.all(r.map((function(e,r){return E(l,0,void 0,(function(){var l;return N(this,(function(h){switch(h.label){case 0:if(o[r].done)return[2,o[r].value];h.label=1;case 1:return s?[3,4]:(Promise.resolve(e.next()).then((function(t){return i[r](t)}),(function(t){return n(t)})),[4,new Promise((function(t){return i[r]=t}))]);case 2:return void 0===(l=h.sent())?[2,o[r].value]:l.done?[2,l.value]:(a[r]=l.value,[4,t(a.slice())]);case 3:return h.sent(),[3,1];case 4:return[2]}}))}))})))];case 4:return[2,h.sent()];case 5:return n(),[4,Promise.all(r.map((function(t){return t.return&&t.return()})))];case 6:return h.sent(),[7];case 7:return[2]}}))}))}))}class nt{static global=new nt;_extraRequestThreshold=262144;extraRequestThreshold(){return this._extraRequestThreshold}setExtraRequestThreshold(t){if(t<0)throw Error("extraRequestThreshold cannot be negative");this._extraRequestThreshold=t}}function it(t,e){e=Math.min(Math.max(+e,2),65535);let r=t,n=r;do{n+=r=Math.ceil(r/e)}while(1!==r);return 40*n}async function*st(t,e,r,n){class i{_level;nodes;constructor(t,e){this._level=e,this.nodes=t}level(){return this._level}startNodeIdx(){return this.nodes[0]}endNodeIdx(){return this.nodes[1]}extendEndNodeIdx(t){this.nodes[1]=t}toString(){return`[NodeRange level: ${this._level}, nodes: ${this.nodes[0]}-${this.nodes[1]}]`}}let{minX:s,minY:o,maxX:a,maxY:l}=r,h=function(t,e){if(e<2)throw Error("Node size must be at least 2");if(0===t)throw Error("Number of items must be greater than 0");let r=t,n=r,i=[r];do{n+=r=Math.ceil(r/e),i.push(r)}while(1!==r);let s=[];for(let t of(r=n,i))s.push(r-t),r-=t;let o=[];for(let t=0;t<i.length;t++)o.push([s[t],s[t]+i[t]]);return o}(t,e),u=h[0][0],b=[new i([0,1],h.length-1)];for(;0!=b.length;){let r=b.shift(),c=r.startNodeIdx(),d=c>=u,f=(()=>{let[,t]=h[r.level()],n=Math.min(r.endNodeIdx()+e,t);return d&&n<t?n+1:n})(),_=f-c,p=new DataView(await n(40*c,40*_));for(let e=c;e<f;e++){let n=e-c,h=40*n;if(a<p.getFloat64(h+0,!0)||l<p.getFloat64(h+8,!0)||s>p.getFloat64(h+16,!0)||o>p.getFloat64(h+24,!0))continue;let f=p.getBigUint64(h+32,!0);if(d){let r=(()=>{if(!(e<t-1))return null;{let t=40*(n+1);return p.getBigUint64(t+32,!0)-f}})(),i=e-u;yield[Number(f),i,Number(r)];continue}let _=nt.global.extraRequestThreshold()/40,y=b[b.length-1];if(void 0!==y&&y.level()==r.level()-1&&f<y.endNodeIdx()+_){y.extendEndNodeIdx(Number(f));continue}let g=(()=>{let t=r.level()-1;return new i([Number(f),Number(f)+1],t)})();void 0!==y&&(y.level(),g.level()),b.push(g)}}}const ot=new Uint8Array([102,103,98,3,102,103,98,0]);class at{headerClient;header;headerLength;indexLength;nocache;constructor(t,e,r,n,i){this.headerClient=t,this.header=e,this.headerLength=r,this.indexLength=n,this.nocache=i}static async open(t,e){let r,n=new lt(t,e),i=2024+(()=>{let t,e=0;for(t=0;t<3;t++)e+=16**t*40;return e})();if(!new Uint8Array(await n.getRange(0,8,i,"header")).subarray(0,3).every(((t,e)=>ot[e]===t)))throw Error("Not a FlatGeobuf file");if((r=new DataView(await n.getRange(8,4,i,"header")).getUint32(0,!0))>10485760||r<8)throw Error("Invalid header size");let s=await n.getRange(12,r,i,"header"),o=T(new h(new Uint8Array(s))),a=it(o.featuresCount,o.indexNodeSize);return new at(n,o,r,a,e)}async*selectBbox(t){let e=this.lengthBeforeTree(),r=this.headerClient,n=async function(t,n){return r.getRange(e+t,n,0,"index")},i=[],s=[];for await(let e of st(this.header.featuresCount,this.header.indexNodeSize,t,n)){let[t,r]=e,[,,n]=e;if(n||(n=4),0==s.length){s.push([t,n,r]);continue}let o=s[s.length-1];t-(o[0]+o[1])>nt.global.extraRequestThreshold()&&(i.push(s),s=[]),s.push([t,n,r])}this.headerClient.logUsage("header+index"),s.length>0&&i.push(s);let o=i.flatMap((t=>this.readFeatureBatch(t,this.nocache)));yield*Y.merge(o)}lengthBeforeTree(){return ot.length+4+this.headerLength}lengthBeforeFeatures(){return this.lengthBeforeTree()+this.indexLength}buildFeatureClient(t){return new lt(this.headerClient.httpClient,t)}async*readFeatureBatch(t,e){let[r]=t[0],[n,i]=t[t.length-1],s=this.buildFeatureClient(e),o=n+i-r;for(let[e,,r]of t){let t=await this.readFeature(s,e,o);yield{id:r,feature:t},o=0}s.logUsage("feature")}async readFeature(t,e,r){let n,i=e+this.lengthBeforeFeatures();n=new DataView(await t.getRange(i,4,r,"feature length")).getUint32(0,!0);let s=new Uint8Array(await t.getRange(i+4,n,r,"feature data")),o=new Uint8Array(n+4);o.set(s,4);let a=new h(o);return a.setPosition(4),v.getRootAsFeature(a)}}class lt{httpClient;bytesEverUsed=0;bytesEverFetched=0;buffer=new ArrayBuffer(0);head=0;constructor(t,e){if("string"==typeof t)this.httpClient=new ht(t,e);else{if(!(t instanceof ht))throw Error("Unknown source ");this.httpClient=t}}async getRange(t,e,r,n){this.bytesEverUsed+=e;let i=t-this.head,s=i+e;if(i>=0&&s<=this.buffer.byteLength)return this.buffer.slice(i,s);let o=Math.max(e,r);return this.bytesEverFetched+=o,this.buffer=await this.httpClient.getRange(t,o,n),this.head=t,this.buffer.slice(0,e)}logUsage(t){t.split(" ")[0],(100*this.bytesEverUsed/this.bytesEverFetched).toFixed(2)}}class ht{url;nocache;requestsEverMade=0;bytesEverRequested=0;constructor(t,e){this.url=t,this.nocache=e}async getRange(t,e,r){this.requestsEverMade+=1,this.bytesEverRequested+=e;let n={Range:`bytes=${t}-${t+e-1}`};this.nocache&&(n["Cache-Control"]="no-cache, no-store");let i=await fetch(this.url,{headers:n});return await i.arrayBuffer()}}function ut(t){let e;for(let n of t){if(e===r.Unknown)break;let t=n.getGeometry?_(n.getGeometry().getType()):_(n.geometry.type);void 0===e?e=t:e!==t&&(e=r.Unknown)}if(void 0===e)throw Error("Could not infer geometry type for collection of features.");return e}function bt(t,e,r){if(!t.subarray(0,3).every(((t,e)=>ot[e]===t)))throw Error("Not a FlatGeobuf file");let n=new h(t),i=n.readUint32(ot.length);n.setPosition(ot.length+4);let s=T(n);r&&r(s);let o=ot.length+4+i,{indexNodeSize:a,featuresCount:l}=s;a>0&&(o+=it(l,a));let u=[];for(;o<n.capacity();){let t=n.readUint32(o);n.setPosition(o+4);let r=v.getRootAsFeature(n);u.push(e(u.length,r,s)),o+=4+t}return u}async function*ct(t,e,r){let n,i="function"==typeof(a=t).slice?a:new C("function"==typeof a.read?a:a.getReader()),s=async t=>await i.slice(t),o=new Uint8Array(await s(8));var a;if(!o.subarray(0,3).every(((t,e)=>ot[e]===t)))throw Error("Not a FlatGeobuf file");o=new Uint8Array(await s(4));let l=new h(o),u=l.readUint32(0);o=new Uint8Array(await s(u));let b=T(l=new h(o));r&&r(b);let{indexNodeSize:c,featuresCount:d}=b;if(c>0){let t=it(d,c);await s(t)}let f=0;for(;n=await dt(s,b,e,f++);)yield n}async function dt(t,e,r,n){let i=new Uint8Array(await t(4,"feature length"));if(0===i.byteLength)return;let s=new h(i),o=s.readUint32(0);i=new Uint8Array(await t(o,"feature data"));let a=new Uint8Array(o+4);return a.set(i,4),(s=new h(a)).setPosition(4),r(n,v.getRootAsFeature(s),e)}function ft(t,e=0){let r=function(t){let e=t.features[0].properties,r=null;return e&&(r=Object.keys(e).map((t=>function(t,e){return{name:e,type:function(t){if("boolean"==typeof t)return w.Bool;if("number"==typeof t)return t%1==0?w.Int:w.Double;if("string"==typeof t||null===t)return w.String;if(t instanceof Uint8Array)return w.Binary;if("object"==typeof t)return w.Json;throw Error(`Unknown type (value '${t}')`)}(t[e]),title:null,description:null,width:-1,precision:-1,scale:-1,nullable:!0,unique:!1,primary_key:!1}}(e,t)))),{geometryType:ut(t.features),columns:r,envelope:null,featuresCount:t.features.length,indexNodeSize:0,crs:null,title:null,description:null,metadata:null}}(t),n=function(t,e=0){let r,n=new u,i=0;t.columns&&(i=V.createColumnsVector(n,t.columns.map((t=>function(t,e){let r=t.createString(e.name);return m.startColumn(t),m.addName(t,r),m.addType(t,e.type),m.endColumn(t)}(n,t)))));let s=n.createString("L1");e&&(B.startCrs(n),B.addCode(n,e),r=B.endCrs(n)),V.startHeader(n),r&&V.addCrs(n,r),V.addFeaturesCount(n,BigInt(t.featuresCount)),V.addGeometryType(n,t.geometryType),V.addIndexNodeSize(n,0),i&&V.addColumns(n,i),V.addName(n,s);let o=V.endHeader(n);return n.finishSizePrefixed(o),n.asUint8Array()}(r,e),i=t.features.map((t=>x("GeometryCollection"===t.geometry.type?y(t.geometry):p(t.geometry),t.properties,r))),s=i.map((t=>t.length)).reduce(((t,e)=>t+e)),o=new Uint8Array(ot.length+n.length+s);o.set(n,ot.length);let a=ot.length+n.length;for(let t of i)o.set(t,a),a+=t.length;return o.set(ot),o}function _t(t,e,r,n=!1){return async function*(t,e,r,n,i=!1){let s=await at.open(t,i);for await(let t of(n&&n(s.header),s.selectBbox(e)))yield r(t.id,t.feature,s.header)}(t,e,P,r,n)}t.deserialize=function(t,e,r,n=!1){return t instanceof Uint8Array?function(t,e){return{type:"FeatureCollection",features:bt(t,P,e)}}(t,r):t instanceof ReadableStream?function(t,e){return ct(t,P,e)}(t,r):_t(t,e,r,n)},t.serialize=function(t,e=0){return ft(t,e)}}));
@@ -2,4 +2,4 @@
2
2
  All material copyright GeoScene, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.geoscene.cn/4.34/geoscene/copyright.txt for details.
4
4
  */
5
- import t from"../../../request.js";import{urlToObject as r,join as n}from"../../../core/urlUtils.js";import{normalizeCentralMeridian as e}from"../../../geometry/support/normalizeUtils.js";import{mapParameters as o}from"../../operations/urlUtils.js";import{parsePBFFeatureQuery as u}from"./pbfQueryUtils.js";import{queryLikeToQueryStringParameters as s}from"./queryUtils.js";import{applyFeatureSetZUnitScaling as i}from"./queryZScale.js";const a="Layer does not support extent calculation.";function l(t,r,n){return s(t,r,n)}async function y(t,r,n,e,o){const u=r.timeExtent?.isEmpty?{data:{features:[]}}:await j(t,r,"json",e,void 0,o);return i(r,n,u.data),u}async function f(t,r,n,e,o){if(r.timeExtent?.isEmpty)return{data:n.createFeatureResult()};const s=await c(t,r,e,o),i=s;return i.data=u(s.data,n),i}function c(t,r,n,e){return j(t,r,"pbf",n,void 0,e)}function m(t,r,n,e){return r.timeExtent?.isEmpty?Promise.resolve({data:{objectIds:[]}}):j(t,r,"json",n,{returnIdsOnly:!0},e)}function p(t,r,n,e){return r.timeExtent?.isEmpty?Promise.resolve({data:{count:0}}):j(t,r,"json",n,{returnIdsOnly:!0,returnCountOnly:!0},e)}async function d(t,r,n){if(r.timeExtent?.isEmpty)return{data:{count:0,extent:null}};const e=await j(t,r,"json",n,{returnExtentOnly:!0,returnCountOnly:!0}),o=e.data;if(o.hasOwnProperty("extent"))return e;if(o.features)throw new Error(a);if(o.hasOwnProperty("count"))throw new Error(a);return e}function O(t,r){if(!t.returnIdsOnly||!r.uniqueIdFields)return t;const n={...t,returnUniqueIdsOnly:!0};return delete n.returnIdsOnly,n}async function j(u,s,i,a={},y={},f={}){const c="string"==typeof u?r(u):u,m=s.geometry?[s.geometry]:[],p=await e(m,null,{signal:a.signal}),d=p?.[0];null!=d&&((s=s.clone()).geometry=d);const j=o({...c.query,f:i,...O(y,f),...l(s,y,f)});return t(n(c.path,E(s,y)?"query3d":"query"),{...a,responseType:"pbf"===i?"array-buffer":"json",query:{...j,...a.query}})}function E(t,r){return null!=t.formatOf3DObjects&&!(r.returnCountOnly||r.returnExtentOnly||r.returnIdsOnly)}export{y as executeQuery,p as executeQueryForCount,d as executeQueryForExtent,m as executeQueryForIds,f as executeQueryPBF,c as executeQueryPBFBuffer,l as queryToQueryStringParameters,j as runQuery};
5
+ import t from"../../../request.js";import{urlToObject as r,join as n}from"../../../core/urlUtils.js";import{normalizeCentralMeridian as e}from"../../../geometry/support/normalizeUtils.js";import{mapParameters as o}from"../../operations/urlUtils.js";import{parsePBFFeatureQuery as u}from"./pbfQueryUtils.js";import{queryLikeToQueryStringParameters as s}from"./queryUtils.js";import{applyFeatureSetZUnitScaling as i}from"./queryZScale.js";const a="Layer does not support extent calculation.";function l(t,r,n){return s(t,r,n)}async function y(t,r,n,e,o){const u=r.timeExtent?.isEmpty?{data:{features:[]}}:await j(t,r,"json",e,void 0,o);return i(r,n,u.data),u}async function f(t,r,n,e,o){if(r.timeExtent?.isEmpty)return{data:n.createFeatureResult()};const s=await c(t,r,e,o),i=s;return i.data=u(s.data,n),i}async function v(t,r,n,e,o){if(r.timeExtent?.isEmpty)return{data:n.createFeatureResult()};const s=await g(t,r,e,o);return s}function c(t,r,n,e){return j(t,r,"pbf",n,void 0,e)}function g(t,r,n,e){return j(t,r,"fgb",n,void 0,e)}function m(t,r,n,e){return r.timeExtent?.isEmpty?Promise.resolve({data:{objectIds:[]}}):j(t,r,"json",n,{returnIdsOnly:!0},e)}function p(t,r,n,e){return r.timeExtent?.isEmpty?Promise.resolve({data:{count:0}}):j(t,r,"json",n,{returnIdsOnly:!0,returnCountOnly:!0},e)}async function d(t,r,n){if(r.timeExtent?.isEmpty)return{data:{count:0,extent:null}};const e=await j(t,r,"json",n,{returnExtentOnly:!0,returnCountOnly:!0}),o=e.data;if(o.hasOwnProperty("extent"))return e;if(o.features)throw new Error(a);if(o.hasOwnProperty("count"))throw new Error(a);return e}function O(t,r){if(!t.returnIdsOnly||!r.uniqueIdFields)return t;const n={...t,returnUniqueIdsOnly:!0};return delete n.returnIdsOnly,n}async function j(u,s,i,a={},y={},f={}){const c="string"==typeof u?r(u):u,m=s.geometry?[s.geometry]:[],p=await e(m,null,{signal:a.signal}),d=p?.[0];null!=d&&((s=s.clone()).geometry=d);const j=o({...c.query,f:i,...O(y,f),...l(s,y,f)});return t(n(c.path,E(s,y)?"query3d":"query"),{...a,responseType:"pbf"===i||"fgb"===i?"array-buffer":"json",query:{...j,...a.query}})}function E(t,r){return null!=t.formatOf3DObjects&&!(r.returnCountOnly||r.returnExtentOnly||r.returnIdsOnly)}export{y as executeQuery,p as executeQueryForCount,d as executeQueryForExtent,m as executeQueryForIds,f as executeQueryPBF,v as executeQueryFGB,c as executeQueryPBFBuffer,l as queryToQueryStringParameters,j as runQuery};
package/rest/query.d.ts CHANGED
@@ -9,5 +9,6 @@ export const executeForTopExtents: __geoscene.query["executeForTopExtents"];
9
9
  export const executeForTopIds: __geoscene.query["executeForTopIds"];
10
10
  export const executeQueryJSON: __geoscene.query["executeQueryJSON"];
11
11
  export const executeQueryPBF: __geoscene.query["executeQueryPBF"];
12
+ export const executeQueryFGB: __geoscene.query["executeQueryFGB"];
12
13
  export const executeRelationshipQuery: __geoscene.query["executeRelationshipQuery"];
13
14
  export const executeTopFeaturesQuery: __geoscene.query["executeTopFeaturesQuery"];
package/rest/query.js CHANGED
@@ -2,4 +2,4 @@
2
2
  All material copyright GeoScene, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.geoscene.cn/4.34/geoscene/copyright.txt for details.
4
4
  */
5
- export{executeAttachmentQuery}from"./query/executeAttachmentQuery.js";export{executeAttributeBinsQuery}from"./query/executeAttributeBinsQuery.js";export{executeForCount}from"./query/executeForCount.js";export{executeForExtent}from"./query/executeForExtent.js";export{executeForIds}from"./query/executeForIds.js";export{executeForTopCount}from"./query/executeForTopCount.js";export{executeForTopExtents}from"./query/executeForTopExtents.js";export{executeForTopIds}from"./query/executeForTopIds.js";export{executeQueryJSON,executeRawQueryJSON}from"./query/executeQueryJSON.js";export{executeQueryPBF,executeRawQueryPBF}from"./query/executeQueryPBF.js";export{executeRelationshipQuery,executeRelationshipQueryForCount}from"./query/executeRelationshipQuery.js";export{executeTopFeaturesQuery}from"./query/executeTopFeaturesQuery.js";
5
+ export{executeAttachmentQuery}from"./query/executeAttachmentQuery.js";export{executeAttributeBinsQuery}from"./query/executeAttributeBinsQuery.js";export{executeForCount}from"./query/executeForCount.js";export{executeForExtent}from"./query/executeForExtent.js";export{executeForIds}from"./query/executeForIds.js";export{executeForTopCount}from"./query/executeForTopCount.js";export{executeForTopExtents}from"./query/executeForTopExtents.js";export{executeForTopIds}from"./query/executeForTopIds.js";export{executeQueryJSON,executeRawQueryJSON}from"./query/executeQueryJSON.js";export{executeQueryPBF,executeRawQueryPBF}from"./query/executeQueryPBF.js";export{executeQueryFGB,executeRawQueryFGB}from"./query/executeQueryFGB.js";export{executeRelationshipQuery,executeRelationshipQueryForCount}from"./query/executeRelationshipQuery.js";export{executeTopFeaturesQuery}from"./query/executeTopFeaturesQuery.js";
@@ -2,4 +2,4 @@
2
2
  All material copyright GeoScene, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.geoscene.cn/4.34/geoscene/copyright.txt for details.
4
4
  */
5
- import e from"../../../core/Error.js";const i={"area-measurement":()=>import("./AreaMeasurementAnalysisView3D.js"),dimension:()=>import("./DimensionAnalysisView3D.js"),"direct-line-measurement":()=>import("./DirectLineMeasurementAnalysisView3D.js"),"elevation-profile":()=>import("./ElevationProfileAnalysisView3D.js"),"line-of-sight":()=>import("./LineOfSightAnalysisView3D.js"),slice:()=>import("./SliceAnalysisView3D.js"),viewshed:()=>import("./ViewshedAnalysisView3D.js"),"volume-measurement":()=>import("./VolumeMeasurementAnalysisView3D.js")};function s(s){const n=i[s.type];if(!n)throw new e("analysis-view-module-import-utils:analysis-not-supported",`Analysis "${s.type}" is not supported`);return n()}export{s as importAnalysisViewModule};
5
+ import e from"../../../core/Error.js";const i={"area-measurement":()=>import("./AreaMeasurementAnalysisView3D.js"),dimension:()=>import("./DimensionAnalysisView3D.js"),"direct-line-measurement":()=>import("./DirectLineMeasurementAnalysisView3D.js"),"elevation-profile":()=>import("./ElevationProfileAnalysisView3D.js"),"line-of-sight":()=>import("./LineOfSightAnalysisView3D.js"),slice:()=>import("./SliceAnalysisView3D.js"),viewshed:(viewsheds)=>{let loadVideo=false;try{if(viewsheds?.some(viewshed=>viewshed.type==='video')){loadVideo=true}}catch(e){console.error(e)}return loadVideo?import("../../../analysis/viewshedVideo/ViewshedAnalysisView3DVideo.js"):import("./ViewshedAnalysisView3D.js")},"volume-measurement":()=>import("./VolumeMeasurementAnalysisView3D.js")};function s(s){const n=i[s.type];if(!n)throw new e("analysis-view-module-import-utils:analysis-not-supported",`Analysis"${s.type}"is not supported`);const viewsheds=s.viewsheds?.items;return viewsheds?n(viewsheds):n()}export{s as importAnalysisViewModule};