@geoscene/core 4.34.9 → 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.
- package/analysis/ViewshedVideo.js +5 -0
- package/analysis/viewshedVideo/ViewshedAnalysisView3DVideo.js +5 -0
- package/analysis/viewshedVideo/ViewshedComputedDataVideo.js +5 -0
- package/analysis/viewshedVideo/ViewshedSubVisualizationVideo.js +5 -0
- package/analysis/viewshedVideo/ViewshedVisualizationVideo.js +5 -0
- package/analysis/viewshedVideo/render/ViewshedTechniqueVideo.js +5 -0
- package/analysis/viewshedVideo/render/ViewshedVideo.glsl.js +243 -0
- package/analysis/viewshedVideo/render/ViewshedVideo.js +5 -0
- package/bundle/lib/fflate.js +12 -0
- package/layers/mixins/SceneService.js +1 -1
- package/layers/support/rasterDatasets/ImageServerRaster.js +1 -1
- package/layers/support/rasterFormats/ImageCanvasDecoder.js +1 -1
- package/layers/support/rasterFormats/RasterCodec.js +1 -1
- package/layers/voxel/drill/VoxelContinuousDrill.js +5 -0
- package/layers/voxel/drill/VoxelDiscreteDrill.js +5 -0
- package/layers/voxel/drill/common.js +5 -0
- package/package.json +1 -1
- package/views/3d/analysis/analysisViewModuleImportUtils.js +1 -1
- package/views/3d/layers/I3SMeshView3D.js +1 -1
- package/views/3d/layers/IntegratedMesh3DTilesLayerView3D.js +1 -1
- package/views/3d/layers/IntegratedMeshLayerView3D.js +1 -1
- package/views/3d/layers/ViewshedLayerView3D.js +1 -1
- package/views/3d/layers/i3s/I3SIndex.js +1 -1
- package/views/3d/layers/i3s/I3SNodeLoader.js +1 -1
- package/views/3d/layers/support/LayerViewAnalysisViewManager.js +1 -1
- package/views/draw/expert/AttackArrowDrawer.js +5 -0
- package/views/draw/expert/AttackTailedArrowDrawer.js +5 -0
- package/views/draw/expert/BaseDrawer.js +5 -0
- package/views/draw/expert/Constant.js +5 -0
- package/views/draw/expert/CurveDrawer.js +5 -0
- package/views/draw/expert/CurveFlagDrawer.js +5 -0
- package/views/draw/expert/CurvedArrowDrawer.js +5 -0
- package/views/draw/expert/EllipseDrawer.js +5 -0
- package/views/draw/expert/ExpertDraw.js +5 -0
- package/views/draw/expert/GatheringPlaceDrawer.js +5 -0
- package/views/draw/expert/LuneDrawer.js +5 -0
- package/views/draw/expert/PincerArrowDrawer.js +5 -0
- package/views/draw/expert/SectorDrawer.js +5 -0
- package/views/draw/expert/SquadCombatDrawer.js +5 -0
- package/views/draw/expert/StraightArrowDrawer.js +5 -0
- package/views/draw/expert/TailedSquadCombatDrawer.js +5 -0
- package/views/draw/expert/plot/Constants.js +5 -0
- package/views/draw/expert/plot/PlotTypes.js +5 -0
- package/views/draw/expert/plot/plots/Arc.js +41 -0
- package/views/draw/expert/plot/plots/AssaultDirection.js +15 -0
- package/views/draw/expert/plot/plots/AttackArrow.js +5 -0
- package/views/draw/expert/plot/plots/Circle.js +5 -0
- package/views/draw/expert/plot/plots/ClosedCurve.js +5 -0
- package/views/draw/expert/plot/plots/Curve.js +5 -0
- package/views/draw/expert/plot/plots/CurveFlag.js +5 -0
- package/views/draw/expert/plot/plots/CurvedArrow.js +5 -0
- package/views/draw/expert/plot/plots/DoubleArrow.js +5 -0
- package/views/draw/expert/plot/plots/Ellipse.js +5 -0
- package/views/draw/expert/plot/plots/FineArrow.js +5 -0
- package/views/draw/expert/plot/plots/FreehandLine.js +19 -0
- package/views/draw/expert/plot/plots/FreehandPolygon.js +19 -0
- package/views/draw/expert/plot/plots/GatheringPlace.js +5 -0
- package/views/draw/expert/plot/plots/Lune.js +5 -0
- package/views/draw/expert/plot/plots/Marker.js +16 -0
- package/views/draw/expert/plot/plots/Plot.js +5 -0
- package/views/draw/expert/plot/plots/Polygon.js +18 -0
- package/views/draw/expert/plot/plots/Polyline.js +19 -0
- package/views/draw/expert/plot/plots/Rectangle.js +28 -0
- package/views/draw/expert/plot/plots/Sector.js +5 -0
- package/views/draw/expert/plot/plots/SquadCombat.js +5 -0
- package/views/draw/expert/plot/plots/StraightArrow.js +5 -0
- package/views/draw/expert/plot/plots/TailedAttackArrow.js +5 -0
- package/views/draw/expert/plot/plots/TailedSquadCombat.js +5 -0
- package/views/draw/expert/plot/utils/plot_util.js +5 -0
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/*
|
|
2
|
+
All material copyright GeoScene, All Rights Reserved, unless otherwise specified.
|
|
3
|
+
See https://js.geoscene.cn/4.33/geoscene/copyright.txt for details.
|
|
4
|
+
*/
|
|
5
|
+
import{__decorate as e}from"tslib";import{featureReferenceEquals as r}from"../analysis/featureReferenceUtils.js";import{equalsMaybe as a}from"../core/maybe.js";import{property as l}from"../core/accessorSupport/decorators/property.js";import{subclass as p}from"../core/accessorSupport/decorators/subclass.js";import geosceneError from"../core/Error.js";import{Texture}from"../views/3d/webgl-engine/lib/Texture.js";import VideoElement from"../layers/support/VideoElement.js";import Color from"../Color.js";import Viewshed from"../analysis/Viewshed.js";async function loadVideo(b){if(b instanceof HTMLVideoElement||b instanceof ImageData){return b}const videoParamTemp=new VideoElement({video:b,});await videoParamTemp.load();return videoParamTemp.content}function formatColor(b){return b instanceof Color?b:new Color(b)}let u=class extends(Viewshed){constructor(s){super(s);this._texture=undefined;this._type='video';this._limitHorizontal=90.0;this._limitVertical=60.0;this._textureVertical=1.0;this._parameters={opacity:0.7,fisheyeLens:false,frustum:false,shadowColor:[0,0,0,0.5],trimmingVertical:0.0,...s,}}get textureVertical(){return this._textureVertical}get limitHorizontal(){return this._limitHorizontal}get limitVertical(){return this._limitVertical}set fisheyeLens(fisheye){this._parameters.fisheyeLens=fisheye}get fisheyeLens(){return this._parameters?.fisheyeLens}get type(){return this._type}get parameters(){return this._parameters}get texture(){return this._texture}set texture(tex){this._texture=tex}get video(){return this.texture?._data}get opacity(){return this._texture?._parameters.opacity}set opacity(opa){if(this._texture){this._texture._parameters.opacity=opa}}async loadVideo(videoUrl){if(!videoUrl){throw new Error("请传入视频地址")}const video=await loadVideo(videoUrl);const width=video instanceof HTMLImageElement?video.naturalWidth:video.width,height=video instanceof HTMLImageElement?video.naturalHeight:video.height;if("getFrame"in video)throw new geosceneError("media-layer-view-3d","animation is not supported");const{opacity,fisheyeLens,view}=this.parameters;const shadowColorTemp=formatColor(this.parameters.shadowColor)?.toRgba();const shadowColor=shadowColorTemp.slice(0,3);const shadowOpacity=shadowColorTemp[3];this.texture=new Texture(video,{wrap:{s:33071,t:33071},preMultiplyAlpha:!0,width,height,mipmap:!0,reloadable:!0,opacity,fisheyeLens,shadowColor,shadowOpacity,textureVertical:this.textureVertical,view,updateCallback:function(){return view.basemapTerrain.overlayManager.requestRender()}});return this.texture}equals(e){return a(this.observer,e.observer)&&this.farDistance===e.farDistance&&this.heading===e.heading&&this.tilt===e.tilt&&this.horizontalFieldOfView===e.horizontalFieldOfView&&this.verticalFieldOfView===e.verticalFieldOfView&&this.trimmingVertical===e.trimmingVertical&&this.frustum===e.frustum&&r(this.feature,e.feature)}clearVideo(){this._texture?._data?.pause();this._texture?._data?.remove()}destroy(){this.clearVideo();this._texture?.unload();this._texture?.dispose();super.destroy()}};e([l({type:Number,nonNullable:!0,range:{min:-10,max:10},json:{write:{isRequired:!0}}})],u.prototype,"trimmingVertical",void 0),e([l({type:Boolean,})],u.prototype,"frustum",void 0),u=e([p("geoscene.analysis.ViewshedVideo")],u);export{u as default};
|
|
@@ -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{__decorate as e}from"tslib";import{getFeatureId as t,updatePointsFromFeatureReference as s}from"../../analysis/featureReferenceUtils.js";import"../../core/has.js";import i from"../../core/Logger.js";import{mapCollection as r}from"../../core/mapCollectionUtils.js";import{abortMaybe as o,destroyMaybe as a}from"../../core/maybe.js";import{watch as d,initial as n,when as l,syncAndInitial as h}from"../../core/reactiveUtils.js";import{property as p}from"../../core/accessorSupport/decorators/property.js";import"../../core/RandomLCG.js";import{subclass as c}from"../../core/accessorSupport/decorators/subclass.js";import{d as u,q as m}from"../../chunks/vec32.js";import{create as v}from"../../core/libs/gl-matrix-2/factories/vec3f64.js";import{canProjectWithoutEngine as w,isLoaded as f,projectOrLoad as V}from"../../geometry/projectionUtils.js";import{projectBoundingRect as y}from"../../geometry/projection/projectBoundingRect.js";import{empty as _,containsPoint as g}from"../../geometry/support/aaBoundingRect.js";import{AnalysisView3D as j}from"../../views/3d/analysis/AnalysisView3D.js";import{logFailedGeometryProjectionError as R}from"../../views/3d/analysis/support/projectionUtils.js";import{ViewshedComputedDataVideo as b}from"../../analysis/viewshedVideo/ViewshedComputedDataVideo.js";import D from"../../views/3d/analysis/Viewshed/ViewshedTool.js";import{ViewshedVisualizationVideo as C}from"../../analysis/viewshedVideo/ViewshedVisualizationVideo.js";import{Intersector as F}from"../../views/3d/webgl-engine/lib/Intersector.js";import{ViewshedVideo as H}from"../../analysis/viewshedVideo/render/ViewshedVideo.js";import{connectAnalysisViewToTool as O,removeAnalysisViewTool as U,startPlaceOperation as S}from"../../views/analysis/analysisViewUtils.js";let A=class extends j{constructor(e){super(e),this.type="viewshed-view-3d",this.analysis=null,this.tool=null,this._selectedViewshed=null,this.viewshedComputedDataHandles=null,this.userOperation=null,this._viewshedRenderNode=null,this._intersector=null}get visible(){return super.visible}set visible(e){super.visible=e}get interactive(){return super.interactive}set interactive(e){super.interactive=e}get selectedViewshed(){return this._selectedViewshed}set selectedViewshed(e){this._unselectOtherViewsheds(e),this._selectedViewshed=e}get selectedViewshedComputedData(){return this.tool?.selectedViewshedComputedData}get _isDecoration(){return!this.parent}initialize(){const e=this.view;this._viewshedRenderNode=new H({view:e,selectedViewshed:()=>this.selectedViewshed??this.tool?.stagedViewshed,isDecoration:this._isDecoration}),this._intersector=new F(this.view.state.viewingMode),this._intersector.options.hud=!1,this._intersector.options.store=0,this.viewshedComputedDataHandles=r(()=>this.analysis.viewsheds,t=>{const s=new b({renderCoordsHelper:e.renderCoordsHelper,viewshed:t}),r=Symbol();return this.addHandles([d(()=>({valid:s.valid,canProject:w(s.observer?.spatialReference,this.view.spatialReference)||f()}),({valid:e,canProject:t},r)=>{this.visible&&(e&&t?this._addViewshedsToRenderer(s):r?.valid&&r?.canProject&&this._removeViewshedsFromRenderer(s),t||R(this.analysis,s.observer.spatialReference,i.getLogger(this)))},n),...this._createFeatureReferenceHandles(s)],r),{viewshedComputedData:s,remove:()=>{this.removeHandles(r),this._removeViewshedsFromRenderer(s),s.destroy()}}}),this._visualization=new C({view:e,analysisViewData:this,isDecoration:this._isDecoration}),this.addHandles([d(()=>this.visible,e=>{const t=this.viewshedComputedDataHandles;if(null==t)return;e||(this.selectedViewshed=null);const s=t.map(e=>e.viewshedComputedData).filter(e=>e.valid).toArray();e?this._addViewshedsToRenderer(s):this._removeViewshedsFromRenderer(s)}),d(()=>e.renderCoordsHelper,e=>{this.viewshedComputedDataHandles?.forEach(({viewshedComputedData:t})=>t.renderCoordsHelper=e)}),O(this,D),l(()=>this.interactive,()=>{this._unselectOtherViewsheds(this.selectedViewshed)},h)])}destroy(){this.userOperation=o(this.userOperation),U(this),this._visualization=a(this._visualization);const e=this.viewshedComputedDataHandles;null!=e&&this._removeViewshedsFromRenderer(e.map(e=>e.viewshedComputedData).toArray())}_createFeatureReferenceHandles(e){const{view:t}=this;return[d(()=>[t.state.camera,t.slice.plane,e.viewshed.observer,e.targetRenderSpace,e.verticalFieldOfView,e.horizontalFieldOfView,e.feature],()=>{this._updateObserverFromFeature(t,e)},n),this._createElevationUpdateHandle(e),l(()=>e.needUpdateByFeature,()=>{this._updateObserverFromFeature(t,e),e.needUpdateByFeature=!1})]}_createElevationUpdateHandle(e){const t=(s,i)=>{const{view:r}=this,{observer:o}=e;if(null==o)return;const a=V(o,r.spatialReference);if(null!=a.pending)return void a.pending.finally(()=>t(s,i));const d=a.geometry;null!=d&&(y(s,i,z,r.spatialReference),g(z,[d.x,d.y])&&(e.needUpdateByFeature=!0))};return this.view.elevationProvider.on("elevation-change",({extent:e,spatialReference:s})=>t(e,s))}async createViewsheds(e){await S(this,{placementOptions:e,onToolActivated:e=>e.place("multiple")})}place(e){return S(this,{placementOptions:e,onToolActivated:e=>e.place("single")})}_addViewshedsToRenderer(e){this._viewshedRenderNode.updateViewsheds({adds:e})}_removeViewshedsFromRenderer(e){this._viewshedRenderNode.updateViewsheds({removes:e})}_updateObserverFromFeature(e,i){const r=i.observerRenderSpace,o=i.targetRenderSpace,a=u(v(),r),d={observer:r,observerSurfaceNormal:null,observerAdjusted:a,observerFeatureId:t(i.feature),target:o,targetSurfaceNormal:null,targetAdjusted:u(v(),o),targetFeatureId:null};s(e,this._intersector,d,e=>Math.min(e,.05*i.farDistanceRenderSpace)),i.observerRenderSpaceOverride=m(a,r)?null:a}_unselectOtherViewsheds(e){if(null!=e)for(const t of this.view.tools.items)t!==this.tool&&t instanceof D&&(t.analysisViewData.selectedViewshed=null)}get test(){}};e([p({readOnly:!0})],A.prototype,"type",void 0),e([p({constructOnly:!0,nonNullable:!0})],A.prototype,"analysis",void 0),e([p()],A.prototype,"tool",void 0),e([p()],A.prototype,"_selectedViewshed",void 0),e([p()],A.prototype,"selectedViewshed",null),e([p()],A.prototype,"selectedViewshedComputedData",null),e([p()],A.prototype,"viewshedComputedDataHandles",void 0),e([p()],A.prototype,"userOperation",void 0),e([p()],A.prototype,"_visualization",void 0),e([p()],A.prototype,"_viewshedRenderNode",void 0),A=e([c("geoscene.views.3d.analysis.ViewshedAnalysisView3DVideo")],A);const N=A,z=_();export{N as default};
|
|
@@ -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{__decorate as e}from"tslib";import t from"../../core/Accessor.js";import{deg2rad as r}from"../../core/mathUtils.js";import{property as o}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as i}from"../../core/accessorSupport/decorators/subclass.js";import{create as s}from"../../core/libs/gl-matrix-2/factories/mat4f64.js";import{a as n,g as l,h,i as a,n as p,u as c}from"../../chunks/vec32.js";import{create as d,fromArray as f,fromValues as u}from"../../core/libs/gl-matrix-2/factories/vec3f64.js";import v from"../../geometry/Point.js";import{rotateBy as g}from"../../views/3d/analysis/Viewshed/viewshedToolUtils.js";var S;let m=S=class extends t{constructor(e){super(e),this.observerRenderSpaceOverride=null,this.needUpdateByFeature=!1}get observer(){return this.viewshed.observer??new v}get effectiveObserverRenderSpace(){return this.observerRenderSpaceOverride??this.observerRenderSpace}get effectiveObserver(){return this.renderSpaceToPoint(this.effectiveObserverRenderSpace,this.observer.spatialReference)}get effectiveTargetRenderSpace(){return this._computeTargetRenderSpace(this.effectiveObserverRenderSpace)}get farDistance(){return this.viewshed.farDistance}get farDistanceRenderSpace(){return this.farDistance/this.metersPerUnit}get heading(){return this.viewshed.heading}get tilt(){return this.viewshed.tilt}get feature(){return this.viewshed.feature}get tiltParallelToSurface(){return this.tilt-90}get horizontalFieldOfView(){return this.viewshed.horizontalFieldOfView}get verticalFieldOfView(){return this.viewshed.verticalFieldOfView}get observerRenderSpace(){return this._pointToRenderSpace(this.observer,d())}get target(){const e=this.targetRenderSpace;return this.renderSpaceToPoint(e,this.observer.spatialReference)}get targetRenderSpace(){return this._computeTargetRenderSpace(this.observerRenderSpace)}get targetDirection(){const e=n(d(),this.targetRenderSpace,this.observerRenderSpace);return p(e,e)}get tiltedUpVector(){const e=g(d(),this.upVector,-r(this.tiltParallelToSurface),this.leftVector);return p(e,e)}get _basis(){return this.renderCoordsHelper.basisMatrixAtPosition(this.observerRenderSpace,s())}get upVector(){const e=this._basis;return u(e[8],e[9],e[10])}get northVector(){const e=this._basis;return u(e[4],e[5],e[6])}get leftVector(){const e=this.upVector,t=g(d(),this.northVector,-r(this.heading),e);return a(t,e,t)}get rightVector(){return c(d(),this.leftVector)}clone(){return new S({renderCoordsHelper:this.renderCoordsHelper,viewshed:this.viewshed.clone()})}get valid(){return this.viewshed.valid}get metersPerUnit(){return this.renderCoordsHelper.spatialReference.metersPerUnit}pointOnSphere(e,t,o){const{observerRenderSpace:i,targetRenderSpace:s}=this,p=n(R,s,i);return g(p,p,-r(t),this.leftVector),g(p,p,-r(e),this.tiltedUpVector),l(o,p,i)}cornerPoints(e){const t=this.horizontalFieldOfView/2,r=this.verticalFieldOfView/2+this.trimmingVertical;this.pointOnSphere(-t,r,e.topLeft),this.pointOnSphere(t,r,e.topRight),this.pointOnSphere(-t,-r,e.bottomLeft),this.pointOnSphere(t,-r,e.bottomRight)}arcCentersPoints(e){const t=this.horizontalFieldOfView/2,r=this.verticalFieldOfView/2;this.pointOnSphere(0,r,e.top),this.pointOnSphere(0,-r,e.bottom),this.pointOnSphere(-t,0,e.left),this.pointOnSphere(t,0,e.right)}parallelCenterPoints(e){const t=this.observerRenderSpace,o=this.farDistanceRenderSpace*Math.sin(r(this.verticalFieldOfView/2)),i=h(R,this.tiltedUpVector,o);l(e.top,t,i),n(e.bottom,t,i)}renderSpaceToPoint(e,t){const r=R;return this.renderCoordsHelper.fromRenderCoords(e,r,t),new v(r[0],r[1],r[2],t)}_pointToRenderSpace(e,t){const r=f(e.toArray());return this.renderCoordsHelper.toRenderCoords(r,e.spatialReference,t),t}_computeTargetRenderSpace(e){const{leftVector:t,northVector:o,upVector:i}=this,s=this.farDistanceRenderSpace,n=d();return h(n,o,s),g(n,n,-r(this.heading),i),g(n,n,-r(this.tiltParallelToSurface),t),l(n,e,n),n}};e([o()],m.prototype,"renderCoordsHelper",void 0),e([o()],m.prototype,"viewshed",void 0),e([o()],m.prototype,"observerRenderSpaceOverride",void 0),e([o()],m.prototype,"needUpdateByFeature",void 0),e([o()],m.prototype,"observer",null),e([o()],m.prototype,"effectiveObserverRenderSpace",null),e([o()],m.prototype,"effectiveObserver",null),e([o()],m.prototype,"effectiveTargetRenderSpace",null),e([o()],m.prototype,"farDistance",null),e([o()],m.prototype,"farDistanceRenderSpace",null),e([o()],m.prototype,"heading",null),e([o()],m.prototype,"tilt",null),e([o()],m.prototype,"feature",null),e([o()],m.prototype,"tiltParallelToSurface",null),e([o()],m.prototype,"horizontalFieldOfView",null),e([o()],m.prototype,"verticalFieldOfView",null),e([o()],m.prototype,"observerRenderSpace",null),e([o()],m.prototype,"target",null),e([o()],m.prototype,"targetRenderSpace",null),e([o()],m.prototype,"targetDirection",null),e([o()],m.prototype,"tiltedUpVector",null),e([o()],m.prototype,"_basis",null),e([o()],m.prototype,"upVector",null),e([o()],m.prototype,"northVector",null),e([o()],m.prototype,"leftVector",null),e([o()],m.prototype,"rightVector",null),e([o()],m.prototype,"valid",null),e([o()],m.prototype,"metersPerUnit",null),m=S=e([i("geoscene.views.3d.analysis.Viewshed.ViewshedComputedDataVideo")],m);const R=d();export{m as ViewshedComputedDataVideo};
|
|
@@ -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{__decorate as e}from"tslib";import t from"../../Color.js";import i from"../../core/Accessor.js";import"../../core/has.js";import{equals as s}from"../../core/lang.js";import{deg2rad as o}from"../../core/mathUtils.js";import{destroyMaybe as r}from"../../core/maybe.js";import{initial as l,watch as a}from"../../core/reactiveUtils.js";import{property as n}from"../../core/accessorSupport/decorators/property.js";import"../../core/Logger.js";import{subclass as c}from"../../core/accessorSupport/decorators/subclass.js";import{fromRotation as h}from"../../core/libs/gl-matrix-2/math/mat4.js";import{create as m}from"../../core/libs/gl-matrix-2/factories/mat4f64.js";import{a as p,d as E,g as b,H as _,h as f,j as u,n as V,p as v,t as d,u as w}from"../../chunks/vec32.js";import{clone as C,create as g}from"../../core/libs/gl-matrix-2/factories/vec3f64.js";import{arcAnglePerSegment as A,viewshedVisualizationConfiguration as L}from"../../views/3d/analysis/Viewshed/ViewshedConfiguration.js";import{ViewshedShapeVisualElement as D}from"../../views/3d/analysis/Viewshed/ViewshedShapeVisualElement.js";import y from"../../views/3d/analysis/Viewshed/ViewshedTool.js";import{LineVisualElement as j}from"../../views/3d/interactive/visualElements/LineVisualElement.js";import{PointVisualElement as F}from"../../views/3d/interactive/visualElements/PointVisualElement.js";import{createStipplePatternSimple as R}from"../../views/3d/webgl-engine/materials/lineStippleUtils.js";import Graphic from"../../Graphic.js";import Mesh from"../../geometry/Mesh.js";import GraphicsLayer from"../../layers/GraphicsLayer.js";let S=class extends i{constructor(e){super(e),this.visible=!0,this._viewshedCorners={topLeft:g(),topRight:g(),bottomLeft:g(),bottomRight:g()},this._arcCenterPoints={top:g(),bottom:g(),left:g(),right:g()},this._parallelCenters={top:g(),bottom:g()}}initialize(){const e={view:this.view,isDecoration:!0},t={...e,color:this._color,renderOccluded:4},i={...t,stipplePattern:R(2)};this._observerVisualElement=new F({...e,...L.observerPointConfiguration}),this._shapeVisualElement=new D({...e,isDecoration:this.isDecoration}),this._frameLinesVisualElement=new j(t),this._leftArcVisualElement=new j(t),this._rightArcVisualElement=new j(t),this._topArcVisualElement=new j(t),this._bottomArcVisualElement=new j(t),this._centralLongitude=new j(i),this._centralLatitude=new j(i),this.addHandles([a(()=>{const e=this.viewshedComputedData;if(!e?.valid)return null;const viewshed=this.viewshedComputedData.viewshed;if(viewshed?.type!=='video'||viewshed?.fisheyeLens){e.trimmingVertical=0.0}else{e.trimmingVertical=viewshed.trimmingVertical??0.0}const t=this._viewshedCorners,i=this._arcCenterPoints,s=this._parallelCenters;return e.cornerPoints(t),e.arcCentersPoints(i),e.parallelCenterPoints(s),{viewshedComputedData:e,corners:t,arcCenters:i,parallelCenters:s,interactive:this.analysisViewData.interactive,selected:this._selected}},e=>{const t=null!=e;e.viewshedComputedData.viewshed.finishedVideo=this.analysisViewData?.tool?.selectedViewshed?true:false;this._forEachVisualElement(e=>e.attached=t),t&&this._updateVisualElements(e)},{initial:!0,equals:s}),a(()=>{const{viewshedComputedData:e}=this,{horizontalFieldOfView:t,verticalFieldOfView:i}=e??{};return{viewshedComputedData:e,horizontalFieldOfView:t,verticalFieldOfView:i}},({viewshedComputedData:e})=>{const{_shapeVisualElement:t}=this;e!==t.viewshedComputedData&&(t.viewshedComputedData=e),this._shapeVisualElement.recreateGeometry()},l),a(()=>{const{interactive:e}=this.analysisViewData;return{visible:this.visible,selected:e&&this._selected,staged:e&&this._staged,horFovNot360:360!==this.viewshedComputedData?.horizontalFieldOfView}},({visible:e,selected:t,staged:i,horFovNot360:s})=>{const o=t||i;this._shapeVisualElement.visible=e,this._topArcVisualElement.visible=e,this._bottomArcVisualElement.visible=e,this._frameLinesVisualElement.visible=e&&s;const r=e&&(t||s);this._leftArcVisualElement.visible=r,this._rightArcVisualElement.visible=r,this._forEachLineVisualElement(e=>{e.width=o?L.frameWidthSelected:L.frameWidthNotSelected,e.renderOccluded=t?4:1}),[this._centralLatitude,this._centralLongitude].forEach(i=>{i.width=2*(o?L.frameWidthSelected:L.frameWidthNotSelected),i.visible=e&&t})},l),a(()=>{const{analysisViewData:{interactive:e,tool:t},_selected:i,visible:s}=this,o=this.view.activeTool,r=!t?.active&&o instanceof y&&o.creating;return{observerVisible:s&&!i&&(!e||(t?.creating??!1)||r),color:this._color}},({observerVisible:e,color:t})=>{this._observerVisualElement.visible=e,this._forEachLineVisualElement(e=>e.color=t)},l)])}get _color(){const{viewshedComputedData:e,_selected:i,analysisViewData:s}=this;if(null==e)return t.toUnitRGBA(L.frameColor);const o=s.tool?.active||s.interactive,r=e.viewshed===s.tool?.stagedViewshed,a=o&&(i||r)?this.view.effectiveTheme.accentColor:L.frameColor;return t.toUnitRGBA(a)}get _selected(){const{viewshedComputedData:e,analysisViewData:{selectedViewshedComputedData:t}}=this;return null!=e&&e===t}get _staged(){const{analysisViewData:{tool:e},viewshedComputedData:t}=this;return null!=e&&e.creating&&e.stagedViewshed===t?.viewshed}destroy(){this._observerVisualElement=r(this._observerVisualElement),this._shapeVisualElement=r(this._shapeVisualElement),this._frameLinesVisualElement=r(this._frameLinesVisualElement),this._leftArcVisualElement=r(this._leftArcVisualElement),this._rightArcVisualElement=r(this._rightArcVisualElement),this._topArcVisualElement=r(this._topArcVisualElement),this._bottomArcVisualElement=r(this._bottomArcVisualElement),this._centralLongitude=r(this._centralLongitude),this._centralLatitude=r(this._centralLatitude);this._videoFrustumLayer?.removeAll();this._videoFrustumLayer=undefined}_forEachLineVisualElement(e){[this._frameLinesVisualElement,this._leftArcVisualElement,this._rightArcVisualElement,this._topArcVisualElement,this._bottomArcVisualElement,this._centralLatitude,this._centralLongitude].forEach(e)}_forEachVisualElement(e){this._forEachLineVisualElement(e),e(this._observerVisualElement),e(this._shapeVisualElement)}_updateVisualElements(e){const{viewshedComputedData:t,corners:i,arcCenters:s,parallelCenters:o}=e,r=C(t.observerRenderSpace);const tool=this.analysisViewData.tool;const viewshed=t.viewshed;const finishedVideo=viewshed.finishedVideo;if(viewshed.type==='video'){let horizontalFieldOfView=t.horizontalFieldOfView;let verticalFieldOfView=t.verticalFieldOfView;const fieldOfViewH=viewshed.limitHorizontal;const fieldOfViewV=viewshed.limitVertical;if(horizontalFieldOfView>fieldOfViewH){e.viewshedComputedData.horizontalFieldOfView=fieldOfViewH;return};if(verticalFieldOfView>fieldOfViewV){e.viewshedComputedData.verticalFieldOfView=fieldOfViewV;return}if(!this._videoFrustumLayer){this._videoFrustumLayer=new GraphicsLayer({title:'视频融合视椎体',listMode:'hide'});this.view.map.add(this._videoFrustumLayer);a((()=>this.visible),(e=>this._videoFrustumLayer.visible=e),l);a((()=>viewshed.frustum),(e=>{this._videoFrustumLayer.visible=e;this._updateVideoFrustum(e.viewshedComputedData,s)}),l)}if(!tool||(finishedVideo||tool?.selectedViewshed)){this._forEachVisualElement((e=>e.attached=false));if(viewshed.frustum===true){this._updateVideoFrustum(e.viewshedComputedData,s)}else{this._videoFrustumLayer.visible=false}}}this._observerVisualElement.geometry=t.observer,this._shapeVisualElement.updateTransform(),this._updateFrameLines(r,i),this._updateFrameArcs(t,i,o),this._updateCentralHelperArcs(t,s)}_updateVideoFrustum(){const{_viewshedCorners,viewshedComputedData}=this;let center=_viewshedCorners.center||viewshedComputedData.observerRenderSpace;let bottomLeft=_viewshedCorners.bottomLeft;let bottomRight=_viewshedCorners.bottomRight;let topLeft=_viewshedCorners.topLeft;let topRight=_viewshedCorners.topRight;const spatialReference=viewshedComputedData.observer.spatialReference;function renderSpaceToPoint(renderSpace){const spatialCoordinates=viewshedComputedData.renderSpaceToPoint(renderSpace,spatialReference);return[spatialCoordinates.x,spatialCoordinates.y,spatialCoordinates.z,]};let cameraPositionGeographic=[...renderSpaceToPoint(center),...renderSpaceToPoint(topLeft),...renderSpaceToPoint(topRight),...renderSpaceToPoint(bottomRight),...renderSpaceToPoint(bottomLeft)];const transparentMaterial={color:"transparent"};const faceConfigurations=[[0,2,1],[0,2,3],[0,3,4],[0,4,1],[1,2,4],[2,3,4]];const mesh=new Mesh({vertexAttributes:{position:cameraPositionGeographic,},components:faceConfigurations.map(faces=>({faces,material:transparentMaterial})),spatialReference,});const frustumGraphic=new Graphic({geometry:mesh,symbol:{type:"mesh-3d",symbolLayers:[{type:"fill",material:{color:"red"},edges:{type:"solid",color:"rgba(255, 127, 0, 1)",size:2},},],},});this._videoFrustumLayer.graphics=[frustumGraphic]}_updateFrameLines(e,t){this._frameLinesVisualElement.geometry=[[e,t.topLeft],[e,t.topRight],[e,t.bottomLeft],[e,t.bottomRight]]}_updateFrameArcs(e,t,i){const{observerRenderSpace:s,rightVector:r,horizontalFieldOfView:a,tiltedUpVector:l}=e,n=o(a),c=g(),p=m();h(p,n/2,l),d(c,r,p),O(this._leftArcVisualElement,s,t.bottomLeft,t.topLeft,"forward",c),h(p,-n/2,l),u(c,0,0,0),d(c,r,p),O(this._rightArcVisualElement,s,t.bottomRight,t.topRight,"forward",c);const _=a>180?"backward":"forward";O(this._topArcVisualElement,i.top,t.topRight,t.topLeft,_,l),O(this._bottomArcVisualElement,i.bottom,t.bottomRight,t.bottomLeft,_,l)}_updateCentralHelperArcs(e,t){const i=e.observerRenderSpace,s=e.horizontalFieldOfView>=180?"backward":"forward";O(this._centralLatitude,i,t.right,t.left,s,e.tiltedUpVector),O(this._centralLongitude,i,t.top,t.bottom,"forward",e.leftVector)}get test(){}};function O(e,t,i,s,o,r,a=A){const l=g();p(l,i,t);const n=_(l),c=g();p(c,s,t),V(c,c),f(c,c,n);let u=v(l,c);const L=C(r);"backward"===o&&(w(L,L),u=-(2*Math.PI-u));const D=[],y=Math.ceil(Math.abs(u)/a),j=m();h(j,u/y,L);const F=g();E(F,l);const R=g();E(R,i);for(let h=0;h<y;h++){const e=g();E(e,R),d(F,F,j),b(R,t,F);const i=g();E(i,R),D.push([e,i])}e.geometry=D}e([n()],S.prototype,"view",void 0),e([n({constructOnly:!0})],S.prototype,"isDecoration",void 0),e([n()],S.prototype,"analysisViewData",void 0),e([n()],S.prototype,"viewshedComputedData",void 0),e([n()],S.prototype,"visible",void 0),e([n()],S.prototype,"_color",null),e([n()],S.prototype,"_selected",null),e([n()],S.prototype,"_staged",null),S=e([c("geoscene.views.3d.analysis.Viewshed.ViewshedSubVisualizationVideo")],S);export{S as default};
|
|
@@ -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{__decorate as i}from"tslib";import s from"../../core/Accessor.js";import{destroyHandle as o}from"../../core/handleUtils.js";import"../../core/has.js";import{mapCollection as t}from"../../core/mapCollectionUtils.js";import{initial as r,watch as e}from"../../core/reactiveUtils.js";import{property as a}from"../../core/accessorSupport/decorators/property.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as l}from"../../core/accessorSupport/decorators/subclass.js";import n from"./ViewshedSubVisualizationVideo.js";let c=class extends s{get visible(){return this.analysisViewData.visible}constructor(i){super(i)}initialize(){const i=this.analysisViewData,s=t(()=>this.analysisViewData.viewshedComputedDataHandles,({viewshedComputedData:s})=>{const o=new n({view:this.view,viewshedComputedData:s,analysisViewData:i,isDecoration:this.isDecoration});return{visualization:o,remove:()=>o.destroy()}});this._subVisualizations=s,this.addHandles([o(s),e(()=>this.visible,i=>this._subVisualizations.forEach(({visualization:s})=>s.visible=i),r)])}get test(){}};i([a({constructOnly:!0})],c.prototype,"analysisViewData",void 0),i([a({constructOnly:!0,nonNullable:!0})],c.prototype,"view",void 0),i([a({constructOnly:!0})],c.prototype,"isDecoration",void 0),i([a()],c.prototype,"visible",null),c=i([l("geoscene.views.3d.analysis.Viewshed.ViewshedVisualizationVideo")],c);export{c as ViewshedVisualizationVideo};
|
|
@@ -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{ReloadableShaderModule as e}from"../../../views/3d/webgl-engine/core/shaderTechnique/ReloadableShaderModule.js";import{ShaderTechnique as r}from"../../../views/3d/webgl-engine/core/shaderTechnique/ShaderTechnique.js";import{Pos2Locations as o}from"../../../views/3d/webgl-engine/lib/DefaultVertexBufferLayouts.js";import{a as i}from"./ViewshedVideo.glsl.js";import{makePipelineState as s,unpremultipliedAlphaToPremultipliedAlpha as t,defaultColorWrite as l}from"../../../views/webgl/renderState.js";class a extends r{constructor(r,s){super(r,s,new e(i,()=>import("./ViewshedVideo.glsl.js")),o)}initializePipeline(){return s({colorWrite:l,blending:t})}}export{a as ViewshedTechniqueVideo};
|
|
@@ -0,0 +1,243 @@
|
|
|
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{invertOrIdentity as e}from"../../../core/libs/gl-matrix-2/math/mat4.js";import{IDENTITY as i,create as o}from"../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{ScreenSpacePass as t}from"../../../views/3d/webgl-engine/core/shaderLibrary/ScreenSpacePass.glsl.js";import{ReadDepth as s}from"../../../views/3d/webgl-engine/core/shaderLibrary/output/ReadDepth.glsl.js";import{PiUtils as a}from"../../../views/3d/webgl-engine/core/shaderLibrary/shading/PiUtils.glsl.js";import{LocalFromScreenSpacePassParameters as r,localFromScreenSpace as n}from"../../../views/3d/webgl-engine/core/shaderLibrary/util/LocalFromScreenSpace.glsl.js";import{Float2PassUniform as d}from"../../../views/3d/webgl-engine/core/shaderModules/Float2PassUniform.js";import{Float3PassUniform as l}from"../../../views/3d/webgl-engine/core/shaderModules/Float3PassUniform.js";import{FloatPassUniform as h}from"../../../views/3d/webgl-engine/core/shaderModules/FloatPassUniform.js";import{FloatsPassUniform as v}from"../../../views/3d/webgl-engine/core/shaderModules/FloatsPassUniform.js";import{glsl as c}from"../../../views/3d/webgl-engine/core/shaderModules/glsl.js";import{IntegerPassUniform as w}from"../../../views/3d/webgl-engine/core/shaderModules/IntegerPassUniform.js";import{Matrix4BindUniform as f}from"../../../views/3d/webgl-engine/core/shaderModules/Matrix4BindUniform.js";import{Matrix4sPassUniform as p}from"../../../views/3d/webgl-engine/core/shaderModules/Matrix4sPassUniform.js";import{Texture2DBindUniform as m}from"../../../views/3d/webgl-engine/core/shaderModules/Texture2DBindUniform.js";import{Texture2DPassUniform as g}from"../../../views/3d/webgl-engine/core/shaderModules/Texture2DPassUniform.js";import{ShaderBuilder as u}from"../../../views/webgl/ShaderBuilder.js";class x extends r{constructor(){super(...arguments),this.shadowMap={depthTexture:null,nearFar:[1,100],numActiveFaces:1,atlasRegions:[[0,0,1,1]]},this.targetVector=[1,0,0],this.upVector=[0,0,1],this.fovs=[45,45],this.headingAndTilt=[0,0],this.observerOffset=[0,0,0],this.projectionMatrices=i.flat(),this.viewMatrices=i.flat(),this.volumeOffset=0}}function V() {const i = new u, o = i.fragment;return i.include(t), i.include(n), o.include(s), o.include(a), o.uniforms.add(new m("depthTexture", e => e.depth?.attachment), new f("inverseProjectionMatrix", e => e.camera.inverseProjectionMatrix), new f("inverseViewNormalMatrix", ({camera: i}) => e(b, i.viewInverseTransposeMatrix)), new l("viewshedObserverOffset", e => e.observerOffset), new l("viewshedTargetVector", e => e.targetVector), new l("viewshedUpVector", e => e.upVector), new d("viewshedFOVs", e => e.fovs), new d("viewshedHeadingAndTilt", e => e.headingAndTilt), new h("videoFlag",function(e,i){return e.viewshedVideo?1:0}),new h("fisheyeLens",function(e,i){return e.viewshedVideo&&e.viewshedVideo.parameters.fisheyeLens?1:0}),new h("videoOpacity",function(e,i){return e.viewshedVideo?e.viewshedVideo.parameters.opacity:1}),new g("videoTexture",function(e,i){const o=e.viewshedVideo,s=o?._data;if(s&&!s.paused&&o&&o.update){const e=o.parameters.view;o.loadedToView||(o.load(e._stage.renderView.renderingContext),e._stage.addTexture(o),o.loadedToView=!0),o?.update(),s.playEvent||(s.addEventListener("play",function(){e._stage.renderView.requestRender()}),s.playEvent=!0)}return o?.glTexture}),new l("shadowColor",function(e){if(e.viewshedVideo){const i=e.viewshedVideo.parameters.shadowColor;return Array.isArray(i)?i:[0,0,0]}return[1,0,0]}),new h("shadowOpacity",function(e,i){return e.viewshedVideo?e.viewshedVideo.parameters.shadowOpacity:.5}),new h("textureVertical",function(e,i){return e.viewshedVideo?e.viewshedVideo.parameters.textureVertical:1}), new d("viewshedNearFar", e => e.shadowMap.nearFar ?? [1, 100]), new h("viewshedVolumeOffset", e => e.volumeOffset), new g("viewshedShadowMap", e => e.shadowMap.depthTexture), new p("viewshedProjectionMatrices", e => e.projectionMatrices, 6), new p("viewshedViewMatrices", e => e.viewMatrices, 6), new w("viewshedNumFaces", e => e.shadowMap.numActiveFaces), new v("viewshedAtlasRegions", e => e.shadowMap.atlasRegions.flat(), 24), new g("normalMap", e => e.normals)), o.constants.add("visibleColor", "vec4", [0, 1, 0, .5]), o.constants.add("occludedColor", "vec4", [1, 0, 0, .5]), o.code.add(c`vec2 getViewshedUv(vec4 worldPosition, int face) {
|
|
6
|
+
mat4 viewshedMatrix = viewshedProjectionMatrices[face];
|
|
7
|
+
vec4 viewshedUv4 = viewshedMatrix * worldPosition;
|
|
8
|
+
vec3 viewshedUv = viewshedUv4.xyz / viewshedUv4.w;
|
|
9
|
+
return viewshedUv.xy;
|
|
10
|
+
}
|
|
11
|
+
float viewshedDepthToFloat(float depth) {
|
|
12
|
+
return (depth - viewshedNearFar[0]) / (viewshedNearFar[1] - viewshedNearFar[0]);
|
|
13
|
+
}
|
|
14
|
+
float getOrthographicDepthToViewshed(vec4 worldPosition, int face) {
|
|
15
|
+
mat4 viewshedViewMatrix = viewshedViewMatrices[face];
|
|
16
|
+
vec4 viewshedUv4 = viewshedViewMatrix * worldPosition;
|
|
17
|
+
vec3 viewshedUv = viewshedUv4.xyz / viewshedUv4.w;
|
|
18
|
+
float depth = -viewshedUv.z;
|
|
19
|
+
return viewshedDepthToFloat(depth);
|
|
20
|
+
}
|
|
21
|
+
float viewshedReadShadowMapDepth(sampler2D _viewshedShadowmap, ivec2 uv) {
|
|
22
|
+
return texelFetch(_viewshedShadowmap, uv, 0).r;
|
|
23
|
+
}
|
|
24
|
+
float viewshedFilterShadow(sampler2D _viewshedShadowmap, vec2 uv) {
|
|
25
|
+
vec2 uvScaled = uv * vec2(textureSize(_viewshedShadowmap, 0));
|
|
26
|
+
vec2 st = fract(uvScaled);
|
|
27
|
+
ivec2 base = ivec2(uvScaled);
|
|
28
|
+
float s00 = viewshedReadShadowMapDepth( _viewshedShadowmap, ivec2(base.x, base.y ));
|
|
29
|
+
float s10 = viewshedReadShadowMapDepth( _viewshedShadowmap, ivec2(base.x + 1, base.y ));
|
|
30
|
+
float s11 = viewshedReadShadowMapDepth( _viewshedShadowmap, ivec2(base.x + 1, base.y + 1));
|
|
31
|
+
float s01 = viewshedReadShadowMapDepth( _viewshedShadowmap, ivec2(base.x, base.y + 1));
|
|
32
|
+
return mix(mix(s00, s10, st.x), mix(s01, s11, st.x), st.y);
|
|
33
|
+
}
|
|
34
|
+
float viewshedTextureAtlasLookup(sampler2D _viewshedShadowmap, vec2 uv, vec4 atlasRegion) {
|
|
35
|
+
vec2 atlasScale = atlasRegion.zw - atlasRegion.xy;
|
|
36
|
+
vec2 uvAtlas = fract(uv) * atlasScale + atlasRegion.xy;
|
|
37
|
+
return viewshedFilterShadow(_viewshedShadowmap, uvAtlas);
|
|
38
|
+
}
|
|
39
|
+
float getDepthFromShadowMap(vec2 uv, int face) {
|
|
40
|
+
int index = 4 * face;
|
|
41
|
+
float umin = viewshedAtlasRegions[index];
|
|
42
|
+
float umax = viewshedAtlasRegions[index + 1];
|
|
43
|
+
float vmin = viewshedAtlasRegions[index + 2];
|
|
44
|
+
float vmax = viewshedAtlasRegions[index + 3];
|
|
45
|
+
vec4 atlasRegion = vec4(umin, vmin, umax, vmax);
|
|
46
|
+
return viewshedTextureAtlasLookup(viewshedShadowMap, uv, atlasRegion);
|
|
47
|
+
}
|
|
48
|
+
struct ViewshedPoint {
|
|
49
|
+
int face;
|
|
50
|
+
vec2 uv;
|
|
51
|
+
bool isWithin;
|
|
52
|
+
float orthographicDepth;
|
|
53
|
+
};
|
|
54
|
+
mat3 rotationMatrix(vec3 axis, float angle)
|
|
55
|
+
{
|
|
56
|
+
float s = sin(angle);
|
|
57
|
+
float c = cos(angle);
|
|
58
|
+
float oc = 1.0 - c;
|
|
59
|
+
return mat3(
|
|
60
|
+
oc * axis.xxz * axis.xyx + vec3(c, axis.zy) * vec3(1., -s, s),
|
|
61
|
+
oc * axis.xyy * axis.yyz + vec3(axis.z, c, axis.x) * vec3(s, 1., -s),
|
|
62
|
+
oc * axis.zyz * axis.xzz + vec3(axis.yx, c) * vec3(-s, s, 1.)
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
float distanceToPlane(vec3 position, vec3 normal) {
|
|
66
|
+
return dot(position, normal);
|
|
67
|
+
}
|
|
68
|
+
bool outsideViewshed(float distance) {
|
|
69
|
+
return distance > -viewshedVolumeOffset;
|
|
70
|
+
}
|
|
71
|
+
bool isWithinViewshed(vec3 position) {
|
|
72
|
+
float positionLength = length(position - viewshedObserverOffset);
|
|
73
|
+
float farSphereDistance = positionLength - viewshedNearFar[1];
|
|
74
|
+
if (outsideViewshed(farSphereDistance)) { return false; }
|
|
75
|
+
float nearSphereDistance = viewshedNearFar[0] - positionLength;
|
|
76
|
+
if (outsideViewshed(nearSphereDistance)) { return false; }
|
|
77
|
+
vec3 westVector = normalize(cross(viewshedUpVector, viewshedTargetVector));
|
|
78
|
+
bool leftOfTarget = distanceToPlane(position, westVector) > 0.0;
|
|
79
|
+
if (viewshedFOVs[0] < TWO_PI) {
|
|
80
|
+
float horAngle = viewshedFOVs[0] / 2.0;
|
|
81
|
+
horAngle = leftOfTarget ? horAngle : -horAngle;
|
|
82
|
+
vec3 sideVector = viewshedTargetVector * rotationMatrix(viewshedUpVector, horAngle);
|
|
83
|
+
bool inFront = distanceToPlane(position, sideVector) > 0.0;
|
|
84
|
+
if (inFront) {
|
|
85
|
+
vec3 sideNormal = cross(viewshedUpVector, sideVector) * (leftOfTarget ? 1. : -1.);
|
|
86
|
+
float sideDistance = distanceToPlane(position, normalize(sideNormal));
|
|
87
|
+
if (outsideViewshed(sideDistance)) { return false; }
|
|
88
|
+
} else if (viewshedFOVs[0] < PI) { return false; }
|
|
89
|
+
}
|
|
90
|
+
if (viewshedFOVs[1] < PI) {
|
|
91
|
+
float t = dot(viewshedUpVector, position);
|
|
92
|
+
vec3 nProjVector = normalize(position - t * viewshedUpVector);
|
|
93
|
+
float heading = acos(clamp(dot(normalize(viewshedTargetVector), nProjVector), -1.0, 1.0));
|
|
94
|
+
heading = leftOfTarget ? heading : -heading;
|
|
95
|
+
bool aboveTarget = distanceToPlane(position, viewshedUpVector) > 0.0;
|
|
96
|
+
float verFOV = viewshedFOVs[1] / 2.0;
|
|
97
|
+
verFOV = aboveTarget ? -verFOV : verFOV;
|
|
98
|
+
mat3 rotateByHeading = rotationMatrix(viewshedUpVector, heading);
|
|
99
|
+
vec3 sideVector = viewshedTargetVector * rotationMatrix(westVector, verFOV) * rotateByHeading;
|
|
100
|
+
vec3 leftVector = westVector * rotateByHeading;
|
|
101
|
+
vec3 sideNormal = cross(sideVector, leftVector) * (aboveTarget ? 1. : -1.);
|
|
102
|
+
float sideDistance = distanceToPlane(position, normalize(sideNormal));
|
|
103
|
+
if (outsideViewshed(sideDistance)) { return false; }
|
|
104
|
+
}
|
|
105
|
+
return true;
|
|
106
|
+
}
|
|
107
|
+
bool getViewshedPoint(vec4 localPosition, out ViewshedPoint point) {
|
|
108
|
+
for(int i=0; i < viewshedNumFaces; i++) {
|
|
109
|
+
vec2 viewshedUv = getViewshedUv(localPosition, i);
|
|
110
|
+
if (viewshedUv.x > 0. && viewshedUv.x < 1. && viewshedUv.y > 0. && viewshedUv.y < 1.) {
|
|
111
|
+
float orthoDepth = getOrthographicDepthToViewshed(localPosition, i);
|
|
112
|
+
if (orthoDepth >= 0.) {
|
|
113
|
+
bool isWithin = isWithinViewshed(localPosition.xyz);
|
|
114
|
+
point = ViewshedPoint(i, viewshedUv, isWithin, orthoDepth);
|
|
115
|
+
return true;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
return false;
|
|
120
|
+
}
|
|
121
|
+
float normalCosAngle(float linearDepth, vec3 localPosition) {
|
|
122
|
+
vec4 normal4 = texture(normalMap, uv);
|
|
123
|
+
vec3 normalN = normalize(normal4.xyz * 2.0 - 1.0);
|
|
124
|
+
vec3 normal = normalize((inverseViewNormalMatrix * vec4(normalN, 1.0)).xyz);
|
|
125
|
+
vec3 viewingDir = normalize(localPosition);
|
|
126
|
+
return dot(normal, viewingDir);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
// 源码修改 第二处修改 start ======================================================
|
|
133
|
+
// 可视域三维坐标
|
|
134
|
+
vec3 getViewshedXyz(vec4 worldPosition, int face) {
|
|
135
|
+
mat4 viewshedMatrix = viewshedProjectionMatrices[face];
|
|
136
|
+
vec4 viewshedUv4 = viewshedMatrix * worldPosition;
|
|
137
|
+
vec3 viewshedUv = viewshedUv4.xyz / viewshedUv4.w;
|
|
138
|
+
return viewshedUv.xyz;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
bool isWithinViewshed_complete(vec3 position) {
|
|
142
|
+
float positionLength = length(position - viewshedObserverOffset);
|
|
143
|
+
float farSphereDistance = positionLength - viewshedNearFar[1];
|
|
144
|
+
if (outsideViewshed(farSphereDistance)) { return false; }
|
|
145
|
+
float nearSphereDistance = viewshedNearFar[0] - positionLength;
|
|
146
|
+
if (outsideViewshed(nearSphereDistance)) { return false; }
|
|
147
|
+
vec3 westVector = normalize(cross(viewshedUpVector, viewshedTargetVector));
|
|
148
|
+
bool leftOfTarget = distanceToPlane(position, westVector) > 0.0;
|
|
149
|
+
if (viewshedFOVs[0] < TWO_PI) {
|
|
150
|
+
float horAngle = viewshedFOVs[0] / 2.0;
|
|
151
|
+
horAngle = leftOfTarget ? horAngle : -horAngle;
|
|
152
|
+
vec3 sideVector = viewshedTargetVector * rotationMatrix(viewshedUpVector, horAngle);
|
|
153
|
+
bool inFront = distanceToPlane(position, sideVector) > 0.0;
|
|
154
|
+
if (inFront) {
|
|
155
|
+
vec3 sideNormal = cross(viewshedUpVector, sideVector) * (leftOfTarget ? 1. : -1.);
|
|
156
|
+
float sideDistance = distanceToPlane(position, normalize(sideNormal));
|
|
157
|
+
if (outsideViewshed(sideDistance)) { return false; }
|
|
158
|
+
} else if (viewshedFOVs[0] < PI) { return false; }
|
|
159
|
+
}
|
|
160
|
+
if (viewshedFOVs[1] < PI) {
|
|
161
|
+
bool aboveTarget = distanceToPlane(position, viewshedUpVector) > 0.0;
|
|
162
|
+
float verFOV = viewshedFOVs[1] / 2.0;
|
|
163
|
+
verFOV = aboveTarget ? -verFOV : verFOV;
|
|
164
|
+
vec3 sideVector = viewshedTargetVector *
|
|
165
|
+
rotationMatrix(westVector, verFOV * textureVertical * 2.0f);
|
|
166
|
+
bool inFront = distanceToPlane(position, sideVector) > 0.0;
|
|
167
|
+
if (inFront) {
|
|
168
|
+
vec3 sideNormal = -cross(westVector, sideVector) * (aboveTarget ? 1. : -1.);
|
|
169
|
+
float sideDistance = distanceToPlane(position, normalize(sideNormal));
|
|
170
|
+
if (outsideViewshed(sideDistance)) { return false; }
|
|
171
|
+
} else {
|
|
172
|
+
return false;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
return true;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
bool getViewshedPointVideo(vec4 localPosition, out ViewshedPoint point) {
|
|
179
|
+
for (int i=0; i < viewshedNumFaces; i++) {
|
|
180
|
+
vec3 viewshedXyz = getViewshedXyz(localPosition, i);
|
|
181
|
+
if (!(any(lessThan(viewshedXyz.xyz, vec3(0.0)))
|
|
182
|
+
|| any(greaterThan(viewshedXyz.xyz, vec3(1.0))))) {
|
|
183
|
+
float orthoDepth = getOrthographicDepthToViewshed(localPosition, i);
|
|
184
|
+
if (orthoDepth >= 0.) {
|
|
185
|
+
bool isWithin = (fisheyeLens == 1.0) ? isWithinViewshed(localPosition.xyz)
|
|
186
|
+
: isWithinViewshed_complete(localPosition.xyz);
|
|
187
|
+
point = ViewshedPoint(i, viewshedXyz.xy, isWithin, orthoDepth);
|
|
188
|
+
return true;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
return false;
|
|
193
|
+
}
|
|
194
|
+
// 源码修改 第二处修改 end ======================================================
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
`), o.main.add(c`
|
|
201
|
+
|
|
202
|
+
float depth = depthFromTexture(depthTexture, uv);
|
|
203
|
+
if (depth >= 1.0 || depth <= 0.0) {
|
|
204
|
+
return;
|
|
205
|
+
}
|
|
206
|
+
float linearDepth = linearizeDepth(depth);
|
|
207
|
+
vec4 localPosition = reconstructLocalPosition(gl_FragCoord.xy, linearDepth);
|
|
208
|
+
ViewshedPoint point;
|
|
209
|
+
|
|
210
|
+
|
|
211
|
+
// 源码修改 第三处修改 start ======================================================
|
|
212
|
+
bool foundFace = (videoFlag == 1.0) ? getViewshedPointVideo(localPosition, point)
|
|
213
|
+
: getViewshedPoint(localPosition, point);
|
|
214
|
+
|
|
215
|
+
if (!foundFace || !point.isWithin) {
|
|
216
|
+
return;
|
|
217
|
+
}
|
|
218
|
+
float viewshedDepth = getDepthFromShadowMap(point.uv, point.face);
|
|
219
|
+
float distance = point.orthographicDepth;
|
|
220
|
+
bool visible = distance < viewshedDepth;
|
|
221
|
+
|
|
222
|
+
vec4 occludedColorShadow = vec4(shadowColor,shadowOpacity);
|
|
223
|
+
|
|
224
|
+
if(videoFlag == 1.0){
|
|
225
|
+
point.uv.x -= 0.0885;
|
|
226
|
+
point.uv.x *= 1.215;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
vec4 videoColor = (videoFlag == 1.0) ? vec4(texture(videoTexture, point.uv).xyz,videoOpacity)
|
|
230
|
+
: visibleColor;
|
|
231
|
+
|
|
232
|
+
fragColor = visible ? videoColor :
|
|
233
|
+
((videoFlag == 1.0) ? occludedColorShadow : occludedColor);
|
|
234
|
+
|
|
235
|
+
float cosAngle = normalCosAngle(linearDepth, localPosition.xyz);
|
|
236
|
+
float threshold = -0.01;
|
|
237
|
+
if (cosAngle > threshold) {
|
|
238
|
+
fragColor = (videoFlag == 1.0) ? occludedColorShadow : occludedColor;
|
|
239
|
+
}
|
|
240
|
+
// 源码修改 第三处修改 end ======================================================
|
|
241
|
+
|
|
242
|
+
|
|
243
|
+
`), i}const b=o(),M=Object.freeze(Object.defineProperty({__proto__:null,ViewshedPassParameters:x,build:V},Symbol.toStringTag,{value:"Module"}));export{x as V,M as a,V as b};
|
|
@@ -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{__decorate as e}from"tslib";import s from"../../../core/Collection.js";import{deg2rad as t}from"../../../core/mathUtils.js";import{disposeMaybe as r}from"../../../core/maybe.js";import{watch as i,when as o,initial as a,sync as n}from"../../../core/reactiveUtils.js";import{property as h}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as d}from"../../../core/accessorSupport/decorators/subclass.js";import{translate as c,fromTranslation as p,scale as w,mul as l}from"../../../core/libs/gl-matrix-2/math/mat4.js";import{create as m}from"../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{a as u,k as f}from"../../../chunks/vec32.js";import{create as v,fromValues as _}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{j as V}from"../../../chunks/sphere.js";import{InternalRenderCategory as g}from"../../../views/3d/webgl.js";import M from"../../../views/3d/webgl/RenderNode.js";import{ViewshedShadowMap as b}from"../../../views/3d/webgl-engine/lib/ViewshedShadowMap.js";import{V as S}from"../../../analysis/viewshedVideo/render/ViewshedVideo.glsl.js";import{ViewshedTechniqueVideo as y}from"../../../analysis/viewshedVideo/render/ViewshedTechniqueVideo.js";let j=class extends M{get shadowMap(){return this._shadowMap}get hasViewsheds(){return this._viewsheds.length>0}get _contentPixelRatio(){return this.view.state.contentPixelRatio}get _viewshedsInView(){return this._viewsheds.items.filter(e=>x(this.view,e))}constructor(e){super(e),this.isDecoration=!1,this._passParameters=new S,this._viewsheds=new s,this._shadowMap=null,this.consumes={required:[g.VIEWSHED,"normals"]},this.produces=g.VIEWSHED,this.requireGeometryDepth=!0}initialize(){this._shadowMap=new b(this.fboCache),this.addHandles([i(()=>this.view.resolutionScale,e=>{const s=this._shadowMap;s&&(s.settings.textureSizeQuality=e)},a),o(()=>!this.hasViewsheds,()=>this._shadowMap?.dispose()),i(()=>this._viewshedsInView.map(e=>[e.observerRenderSpace,e.heading,e.tilt,e.farDistance,e.horizontalFieldOfView,e.verticalFieldOfView]),()=>this.requestRender(1),n)])}destroy(){this._shadowMap=r(this._shadowMap)}precompile(){if(this.hasViewsheds){this.techniques.precompile(y);for(const e of this._viewshedsInView)if(this._shadowMap?.isActive(e))return void this.view.stage.renderer.precompileViewshedShadowMap()}}render(e){const s=this.bindParameters,t=this.renderingContext,r=e.find(({name:e})=>e===g.VIEWSHED);if(!this.hasViewsheds||!s.depth||this.isDecoration&&!s.decorations)return r;this._passParameters.shadowMap=this._shadowMap??this._passParameters.shadowMap,this._passParameters.normals=e.find(({name:e})=>"normals"===e)?.getTexture();const i=this.techniques.get(y);if(!i?.compiled)return this.requestRender(1),r;const o=this.view.stage.renderer.isFeatureEnabled(7);for(const a of this._viewshedsInView){if(!this._renderShadowCubeMap(s,a,o)||!this._shadowMap?.ready)continue;const e=this._setupViewshedParameters(a,s.camera);t.bindTechnique(i,s,e),t.bindFramebuffer(r.fbo),t.screen.draw()}return this.shadowMap?.dispose(),r}updateViewsheds(e){const s=this._viewsheds,{removes:t,adds:r}=e;if(t&&(Array.isArray(t)?s.removeMany(t):s.remove(t)),r)if(Array.isArray(r)){const e=r.filter(e=>!s.includes(e));s.addMany(e)}else s.includes(r)||s.add(r)}_renderShadowCubeMap(e,s,t){const r=this._shadowMap;if(!r)return!1;const i=this.view.basemapTerrain.hasStencilEnabledExtents,o=r.start(e.camera,s,t,this._contentPixelRatio,i);return o&&r.faces.forEach(e=>this.view.stage.renderer.renderViewshedShadowMap(e)),r.finish(),o}_setupViewshedParameters(e,s){const r=this._shadowMap;if(!r)return this._passParameters;const i=this._passParameters,o=e.effectiveObserverRenderSpace;i.localOrigin=o,i.observerOffset=u(E,e.observerRenderSpace,e.effectiveObserverRenderSpace),i.fovs=[t(e.horizontalFieldOfView),t(e.verticalFieldOfView)],i.headingAndTilt=[t(e.heading),t(e.tiltParallelToSurface)],i.upVector=e.tiltedUpVector;i.viewshedVideo=e.viewshed.texture;const a=R(e.targetRenderSpace,o);i.targetVector=a;const n=new Array,h=new Array;for(let t=0;t<r.numActiveFaces;t++)c(I,r.viewshedViewMatrices[t],o),n.push(...I),P(r.viewshedProjectionMatrices[t],I,D),h.push(...D);return i.viewMatrices=n,i.projectionMatrices=h,i.volumeOffset=this.selectedViewshed?.()===e.viewshed?A(e,this.view,s.eye):0,i}get test(){return{viewsheds:this._viewsheds,shadowMap:this._shadowMap,viewshedsInView:this._viewshedsInView}}};function R(e,s){const t=v();return u(t,e,s)}function P(e,s,t){const r=_(.5,.5,.5);return p(t,r),w(t,t,r),l(t,t,e),l(t,t,s),t}function x(e,s){const t=V(s.observerRenderSpace,s.farDistanceRenderSpace);return!!e.ready&&e.frustum.intersectsSphere(t)}function A(e,s,t){if(null==e)return 0;const{observerRenderSpace:r,targetRenderSpace:i}=e,o=f(t,r)>f(t,i)?e.observer:e.target;return s.pixelSizeAt(o)}e([h()],j.prototype,"selectedViewshed",void 0),e([h()],j.prototype,"isDecoration",void 0),e([h()],j.prototype,"shadowMap",null),e([h()],j.prototype,"hasViewsheds",null),e([h()],j.prototype,"_contentPixelRatio",null),e([h()],j.prototype,"_viewshedsInView",null),e([h()],j.prototype,"consumes",void 0),e([h()],j.prototype,"produces",void 0),j=e([d("geoscene.views.3d.webgl-engine.lib.ViewshedVideo")],j);const E=v(),I=m(),D=m();export{j as ViewshedVideo,A as computeOffsetScale};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// fflate.js - ES6 模块版本
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
const fflate = (function(){
|
|
5
|
+
var _e={};
|
|
6
|
+
"use strict";
|
|
7
|
+
var t=(typeof module!='undefined'&&typeof exports=='object'?function(_f){"use strict";var e,t=";var __w=require('worker_threads');__w.parentPort.on('message',function(m){onmessage({data:m})}),postMessage=function(m,t){__w.parentPort.postMessage(m,t)},close=process.exit;self=global";try{e=require("worker_threads").Worker}catch(e){}exports.default=e?function(r,n,o,a,s){var u=!1,i=new e(r+t,{eval:!0}).on("error",(function(e){return s(e,null)})).on("message",(function(e){return s(null,e)})).on("exit",(function(e){e&&!u&&s(Error("exited with code "+e),null)}));return i.postMessage(o,a),i.terminate=function(){return u=!0,e.prototype.terminate.call(i)},i}:function(e,t,r,n,o){setImmediate((function(){return o(Error("async operations unsupported - update to Node 12+ (or Node 10-11 with the --experimental-worker CLI flag)"),null)}));var a=function(){};return{terminate:a,postMessage:a}};return _f}:function(_f){"use strict";var e={};_f.default=function(r,t,s,a,n){var o=new Worker(e[t]||(e[t]=URL.createObjectURL(new Blob([r+';addEventListener("error",function(e){e=e.error;postMessage({$e$:[e.message,e.code,e.stack]})})'],{type:"text/javascript"}))));return o.onmessage=function(e){var r=e.data,t=r.$e$;if(t){var s=Error(t[0]);s.code=t[1],s.stack=t[2],n(s,null)}else n(null,r)},o.postMessage(s,a),o};return _f})({}),n=Uint8Array,r=Uint16Array,e=Int32Array,i=new n([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),o=new n([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),s=new n([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),a=function(t,n){for(var i=new r(31),o=0;o<31;++o)i[o]=n+=1<<t[o-1];var s=new e(i[30]);for(o=1;o<30;++o)for(var a=i[o];a<i[o+1];++a)s[a]=a-i[o]<<5|o;return{b:i,r:s}},u=a(i,2),h=u.b,f=u.r;h[28]=258,f[258]=28;for(var l=a(o,0),c=l.b,p=l.r,v=new r(32768),d=0;d<32768;++d){var g=(43690&d)>>1|(21845&d)<<1;v[d]=((65280&(g=(61680&(g=(52428&g)>>2|(13107&g)<<2))>>4|(3855&g)<<4))>>8|(255&g)<<8)>>1}var y=function(t,n,e){for(var i=t.length,o=0,s=new r(n);o<i;++o)t[o]&&++s[t[o]-1];var a,u=new r(n);for(o=1;o<n;++o)u[o]=u[o-1]+s[o-1]<<1;if(e){a=new r(1<<n);var h=15-n;for(o=0;o<i;++o)if(t[o])for(var f=o<<4|t[o],l=n-t[o],c=u[t[o]-1]++<<l,p=c|(1<<l)-1;c<=p;++c)a[v[c]>>h]=f}else for(a=new r(i),o=0;o<i;++o)t[o]&&(a[o]=v[u[t[o]-1]++]>>15-t[o]);return a},m=new n(288);for(d=0;d<144;++d)m[d]=8;for(d=144;d<256;++d)m[d]=9;for(d=256;d<280;++d)m[d]=7;for(d=280;d<288;++d)m[d]=8;var b=new n(32);for(d=0;d<32;++d)b[d]=5;var w=y(m,9,0),x=y(m,9,1),z=y(b,5,0),k=y(b,5,1),M=function(t){for(var n=t[0],r=1;r<t.length;++r)t[r]>n&&(n=t[r]);return n},S=function(t,n,r){var e=n/8|0;return(t[e]|t[e+1]<<8)>>(7&n)&r},A=function(t,n){var r=n/8|0;return(t[r]|t[r+1]<<8|t[r+2]<<16)>>(7&n)},T=function(t){return(t+7)/8|0},D=function(t,r,e){return(null==r||r<0)&&(r=0),(null==e||e>t.length)&&(e=t.length),new n(t.subarray(r,e))};_e.FlateErrorCode={UnexpectedEOF:0,InvalidBlockType:1,InvalidLengthLiteral:2,InvalidDistance:3,StreamFinished:4,NoStreamHandler:5,InvalidHeader:6,NoCallback:7,InvalidUTF8:8,ExtraFieldTooLong:9,InvalidDate:10,FilenameTooLong:11,StreamFinishing:12,InvalidZipData:13,UnknownCompressionMethod:14};var C=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],I=function(t,n,r){var e=Error(n||C[t]);if(e.code=t,Error.captureStackTrace&&Error.captureStackTrace(e,I),!r)throw e;return e},U=function(t,r,e,a){var u=t.length,f=a?a.length:0;if(!u||r.f&&!r.l)return e||new n(0);var l=!e,p=l||2!=r.i,v=r.i;l&&(e=new n(3*u));var d=function(t){var r=e.length;if(t>r){var i=new n(Math.max(2*r,t));i.set(e),e=i}},g=r.f||0,m=r.p||0,b=r.b||0,w=r.l,z=r.d,C=r.m,U=r.n,F=8*u;do{if(!w){g=S(t,m,1);var E=S(t,m+1,3);if(m+=3,!E){var Z=t[(J=T(m)+4)-4]|t[J-3]<<8,q=J+Z;if(q>u){v&&I(0);break}p&&d(b+Z),e.set(t.subarray(J,q),b),r.b=b+=Z,r.p=m=8*q,r.f=g;continue}if(1==E)w=x,z=k,C=9,U=5;else if(2==E){var O=S(t,m,31)+257,G=S(t,m+10,15)+4,L=O+S(t,m+5,31)+1;m+=14;for(var H=new n(L),j=new n(19),N=0;N<G;++N)j[s[N]]=S(t,m+3*N,7);m+=3*G;var P=M(j),B=(1<<P)-1,Y=y(j,P,1);for(N=0;N<L;){var J,K=Y[S(t,m,B)];if(m+=15&K,(J=K>>4)<16)H[N++]=J;else{var Q=0,R=0;for(16==J?(R=3+S(t,m,3),m+=2,Q=H[N-1]):17==J?(R=3+S(t,m,7),m+=3):18==J&&(R=11+S(t,m,127),m+=7);R--;)H[N++]=Q}}var V=H.subarray(0,O),W=H.subarray(O);C=M(V),U=M(W),w=y(V,C,1),z=y(W,U,1)}else I(1);if(m>F){v&&I(0);break}}p&&d(b+131072);for(var X=(1<<C)-1,$=(1<<U)-1,_=m;;_=m){var tt=(Q=w[A(t,m)&X])>>4;if((m+=15&Q)>F){v&&I(0);break}if(Q||I(2),tt<256)e[b++]=tt;else{if(256==tt){_=m,w=null;break}var nt=tt-254;tt>264&&(nt=S(t,m,(1<<(it=i[N=tt-257]))-1)+h[N],m+=it);var rt=z[A(t,m)&$],et=rt>>4;if(rt||I(3),m+=15&rt,W=c[et],et>3){var it=o[et];W+=A(t,m)&(1<<it)-1,m+=it}if(m>F){v&&I(0);break}p&&d(b+131072);var ot=b+nt;if(b<W){var st=f-W,at=Math.min(W,ot);for(st+b<0&&I(3);b<at;++b)e[b]=a[st+b]}for(;b<ot;++b)e[b]=e[b-W]}}r.l=w,r.p=_,r.b=b,r.f=g,w&&(g=1,r.m=C,r.d=z,r.n=U)}while(!g);return b!=e.length&&l?D(e,0,b):e.subarray(0,b)},F=function(t,n,r){var e=n/8|0;t[e]|=r<<=7&n,t[e+1]|=r>>8},E=function(t,n,r){var e=n/8|0;t[e]|=r<<=7&n,t[e+1]|=r>>8,t[e+2]|=r>>16},Z=function(t,e){for(var i=[],o=0;o<t.length;++o)t[o]&&i.push({s:o,f:t[o]});var s=i.length,a=i.slice();if(!s)return{t:N,l:0};if(1==s){var u=new n(i[0].s+1);return u[i[0].s]=1,{t:u,l:1}}i.sort((function(t,n){return t.f-n.f})),i.push({s:-1,f:25001});var h=i[0],f=i[1],l=0,c=1,p=2;for(i[0]={s:-1,f:h.f+f.f,l:h,r:f};c!=s-1;)h=i[i[l].f<i[p].f?l++:p++],f=i[l!=c&&i[l].f<i[p].f?l++:p++],i[c++]={s:-1,f:h.f+f.f,l:h,r:f};var v=a[0].s;for(o=1;o<s;++o)a[o].s>v&&(v=a[o].s);var d=new r(v+1),g=q(i[c-1],d,0);if(g>e){o=0;var y=0,m=g-e,b=1<<m;for(a.sort((function(t,n){return d[n.s]-d[t.s]||t.f-n.f}));o<s;++o){var w=a[o].s;if(!(d[w]>e))break;y+=b-(1<<g-d[w]),d[w]=e}for(y>>=m;y>0;){var x=a[o].s;d[x]<e?y-=1<<e-d[x]++-1:++o}for(;o>=0&&y;--o){var z=a[o].s;d[z]==e&&(--d[z],++y)}g=e}return{t:new n(d),l:g}},q=function(t,n,r){return-1==t.s?Math.max(q(t.l,n,r+1),q(t.r,n,r+1)):n[t.s]=r},O=function(t){for(var n=t.length;n&&!t[--n];);for(var e=new r(++n),i=0,o=t[0],s=1,a=function(t){e[i++]=t},u=1;u<=n;++u)if(t[u]==o&&u!=n)++s;else{if(!o&&s>2){for(;s>138;s-=138)a(32754);s>2&&(a(s>10?s-11<<5|28690:s-3<<5|12305),s=0)}else if(s>3){for(a(o),--s;s>6;s-=6)a(8304);s>2&&(a(s-3<<5|8208),s=0)}for(;s--;)a(o);s=1,o=t[u]}return{c:e.subarray(0,i),n:n}},G=function(t,n){for(var r=0,e=0;e<n.length;++e)r+=t[e]*n[e];return r},L=function(t,n,r){var e=r.length,i=T(n+2);t[i]=255&e,t[i+1]=e>>8,t[i+2]=255^t[i],t[i+3]=255^t[i+1];for(var o=0;o<e;++o)t[i+o+4]=r[o];return 8*(i+4+e)},H=function(t,n,e,a,u,h,f,l,c,p,v){F(n,v++,e),++u[256];for(var d=Z(u,15),g=d.t,x=d.l,k=Z(h,15),M=k.t,S=k.l,A=O(g),T=A.c,D=A.n,C=O(M),I=C.c,U=C.n,q=new r(19),H=0;H<T.length;++H)++q[31&T[H]];for(H=0;H<I.length;++H)++q[31&I[H]];for(var j=Z(q,7),N=j.t,P=j.l,B=19;B>4&&!N[s[B-1]];--B);var Y,J,K,Q,R=p+5<<3,V=G(u,m)+G(h,b)+f,W=G(u,g)+G(h,M)+f+14+3*B+G(q,N)+2*q[16]+3*q[17]+7*q[18];if(c>=0&&R<=V&&R<=W)return L(n,v,t.subarray(c,c+p));if(F(n,v,1+(W<V)),v+=2,W<V){Y=y(g,x,0),J=g,K=y(M,S,0),Q=M;var X=y(N,P,0);for(F(n,v,D-257),F(n,v+5,U-1),F(n,v+10,B-4),v+=14,H=0;H<B;++H)F(n,v+3*H,N[s[H]]);v+=3*B;for(var $=[T,I],_=0;_<2;++_){var tt=$[_];for(H=0;H<tt.length;++H)F(n,v,X[rt=31&tt[H]]),v+=N[rt],rt>15&&(F(n,v,tt[H]>>5&127),v+=tt[H]>>12)}}else Y=w,J=m,K=z,Q=b;for(H=0;H<l;++H){var nt=a[H];if(nt>255){var rt;E(n,v,Y[257+(rt=nt>>18&31)]),v+=J[rt+257],rt>7&&(F(n,v,nt>>23&31),v+=i[rt]);var et=31&nt;E(n,v,K[et]),v+=Q[et],et>3&&(E(n,v,nt>>5&8191),v+=o[et])}else E(n,v,Y[nt]),v+=J[nt]}return E(n,v,Y[256]),v+J[256]},j=new e([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),N=new n(0),P=function(t,s,a,u,h,l){var c=l.z||t.length,v=new n(u+c+5*(1+Math.ceil(c/7e3))+h),d=v.subarray(u,v.length-h),g=l.l,y=7&(l.r||0);if(s){y&&(d[0]=l.r>>3);for(var m=j[s-1],b=m>>13,w=8191&m,x=(1<<a)-1,z=l.p||new r(32768),k=l.h||new r(x+1),M=Math.ceil(a/3),S=2*M,A=function(n){return(t[n]^t[n+1]<<M^t[n+2]<<S)&x},C=new e(25e3),I=new r(288),U=new r(32),F=0,E=0,Z=l.i||0,q=0,O=l.w||0,G=0;Z+2<c;++Z){var N=A(Z),P=32767&Z,B=k[N];if(z[P]=B,k[N]=P,O<=Z){var Y=c-Z;if((F>7e3||q>24576)&&(Y>423||!g)){y=H(t,d,0,C,I,U,E,q,G,Z-G,y),q=F=E=0,G=Z;for(var J=0;J<286;++J)I[J]=0;for(J=0;J<30;++J)U[J]=0}var K=2,Q=0,R=w,V=P-B&32767;if(Y>2&&N==A(Z-V))for(var W=Math.min(b,Y)-1,X=Math.min(32767,Z),$=Math.min(258,Y);V<=X&&--R&&P!=B;){if(t[Z+K]==t[Z+K-V]){for(var _=0;_<$&&t[Z+_]==t[Z+_-V];++_);if(_>K){if(K=_,Q=V,_>W)break;var tt=Math.min(V,_-2),nt=0;for(J=0;J<tt;++J){var rt=Z-V+J&32767,et=rt-z[rt]&32767;et>nt&&(nt=et,B=rt)}}}V+=(P=B)-(B=z[P])&32767}if(Q){C[q++]=268435456|f[K]<<18|p[Q];var it=31&f[K],ot=31&p[Q];E+=i[it]+o[ot],++I[257+it],++U[ot],O=Z+K,++F}else C[q++]=t[Z],++I[t[Z]]}}for(Z=Math.max(Z,O);Z<c;++Z)C[q++]=t[Z],++I[t[Z]];y=H(t,d,g,C,I,U,E,q,G,Z-G,y),g||(l.r=7&y|d[y/8|0]<<3,y-=7,l.h=k,l.p=z,l.i=Z,l.w=O)}else{for(Z=l.w||0;Z<c+g;Z+=65535){var st=Z+65535;st>=c&&(d[y/8|0]=g,st=c),y=L(d,y+1,t.subarray(Z,st))}l.i=c}return D(v,0,u+T(y)+h)},B=function(){for(var t=new Int32Array(256),n=0;n<256;++n){for(var r=n,e=9;--e;)r=(1&r&&-306674912)^r>>>1;t[n]=r}return t}(),Y=function(){var t=-1;return{p:function(n){for(var r=t,e=0;e<n.length;++e)r=B[255&r^n[e]]^r>>>8;t=r},d:function(){return~t}}},J=function(){var t=1,n=0;return{p:function(r){for(var e=t,i=n,o=0|r.length,s=0;s!=o;){for(var a=Math.min(s+2655,o);s<a;++s)i+=e+=r[s];e=(65535&e)+15*(e>>16),i=(65535&i)+15*(i>>16)}t=e,n=i},d:function(){return(255&(t%=65521))<<24|(65280&t)<<8|(255&(n%=65521))<<8|n>>8}}},K=function(t,r,e,i,o){if(!o&&(o={l:1},r.dictionary)){var s=r.dictionary.subarray(-32768),a=new n(s.length+t.length);a.set(s),a.set(t,s.length),t=a,o.w=s.length}return P(t,null==r.level?6:r.level,null==r.mem?o.l?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(t.length)))):20:12+r.mem,e,i,o)},Q=function(t,n){var r={};for(var e in t)r[e]=t[e];for(var e in n)r[e]=n[e];return r},R=function(t,n,r){for(var e=t(),i=""+t,o=i.slice(i.indexOf("[")+1,i.lastIndexOf("]")).replace(/\s+/g,"").split(","),s=0;s<e.length;++s){var a=e[s],u=o[s];if("function"==typeof a){n+=";"+u+"=";var h=""+a;if(a.prototype)if(-1!=h.indexOf("[native code]")){var f=h.indexOf(" ",8)+1;n+=h.slice(f,h.indexOf("(",f))}else for(var l in n+=h,a.prototype)n+=";"+u+".prototype."+l+"="+a.prototype[l];else n+=h}else r[u]=a}return n},V=[],W=function(t){var n=[];for(var r in t)t[r].buffer&&n.push((t[r]=new t[r].constructor(t[r])).buffer);return n},X=function(n,r,e,i){if(!V[e]){for(var o="",s={},a=n.length-1,u=0;u<a;++u)o=R(n[u],o,s);V[e]={c:R(n[a],o,s),e:s}}var h=Q({},V[e].e);return(0,t.default)(V[e].c+";onmessage=function(e){for(var k in e.data)self[k]=e.data[k];onmessage="+r+"}",e,h,W(h),i)},$=function(){return[n,r,e,i,o,s,h,c,x,k,v,C,y,M,S,A,T,D,I,U,Tt,it,ot]},_=function(){return[n,r,e,i,o,s,f,p,w,m,z,b,v,j,N,y,F,E,Z,q,O,G,L,H,T,D,P,K,kt,it]},tt=function(){return[pt,gt,ct,Y,B]},nt=function(){return[vt,dt]},rt=function(){return[yt,ct,J]},et=function(){return[mt]},it=function(t){return postMessage(t,[t.buffer])},ot=function(t){return t&&{out:t.size&&new n(t.size),dictionary:t.dictionary}},st=function(t,n,r,e,i,o){var s=X(r,e,i,(function(t,n){s.terminate(),o(t,n)}));return s.postMessage([t,n],n.consume?[t.buffer]:[]),function(){s.terminate()}},at=function(t){return t.ondata=function(t,n){return postMessage([t,n],[t.buffer])},function(n){n.data.length?(t.push(n.data[0],n.data[1]),postMessage([n.data[0].length])):t.flush()}},ut=function(t,n,r,e,i,o,s){var a,u=X(t,e,i,(function(t,r){t?(u.terminate(),n.ondata.call(n,t)):Array.isArray(r)?1==r.length?(n.queuedSize-=r[0],n.ondrain&&n.ondrain(r[0])):(r[1]&&u.terminate(),n.ondata.call(n,t,r[0],r[1])):s(r)}));u.postMessage(r),n.queuedSize=0,n.push=function(t,r){n.ondata||I(5),a&&n.ondata(I(4,0,1),null,!!r),n.queuedSize+=t.length,u.postMessage([t,a=r],[t.buffer])},n.terminate=function(){u.terminate()},o&&(n.flush=function(){u.postMessage([])})},ht=function(t,n){return t[n]|t[n+1]<<8},ft=function(t,n){return(t[n]|t[n+1]<<8|t[n+2]<<16|t[n+3]<<24)>>>0},lt=function(t,n){return ft(t,n)+4294967296*ft(t,n+4)},ct=function(t,n,r){for(;r;++n)t[n]=r,r>>>=8},pt=function(t,n){var r=n.filename;if(t[0]=31,t[1]=139,t[2]=8,t[8]=n.level<2?4:9==n.level?2:0,t[9]=3,0!=n.mtime&&ct(t,4,Math.floor(new Date(n.mtime||Date.now())/1e3)),r){t[3]=8;for(var e=0;e<=r.length;++e)t[e+10]=r.charCodeAt(e)}},vt=function(t){31==t[0]&&139==t[1]&&8==t[2]||I(6,"invalid gzip data");var n=t[3],r=10;4&n&&(r+=2+(t[10]|t[11]<<8));for(var e=(n>>3&1)+(n>>4&1);e>0;e-=!t[r++]);return r+(2&n)},dt=function(t){var n=t.length;return(t[n-4]|t[n-3]<<8|t[n-2]<<16|t[n-1]<<24)>>>0},gt=function(t){return 10+(t.filename?t.filename.length+1:0)},yt=function(t,n){var r=n.level,e=0==r?0:r<6?1:9==r?3:2;if(t[0]=120,t[1]=e<<6|(n.dictionary&&32),t[1]|=31-(t[0]<<8|t[1])%31,n.dictionary){var i=J();i.p(n.dictionary),ct(t,2,i.d())}},mt=function(t,n){return(8!=(15&t[0])||t[0]>>4>7||(t[0]<<8|t[1])%31)&&I(6,"invalid zlib data"),(t[1]>>5&1)==+!n&&I(6,"invalid zlib data: "+(32&t[1]?"need":"unexpected")+" dictionary"),2+(t[1]>>3&4)};function bt(t,n){return"function"==typeof t&&(n=t,t={}),this.ondata=n,t}var wt=function(){function t(t,r){if("function"==typeof t&&(r=t,t={}),this.ondata=r,this.o=t||{},this.s={l:0,i:32768,w:32768,z:32768},this.b=new n(98304),this.o.dictionary){var e=this.o.dictionary.subarray(-32768);this.b.set(e,32768-e.length),this.s.i=32768-e.length}}return t.prototype.p=function(t,n){this.ondata(K(t,this.o,0,0,this.s),n)},t.prototype.push=function(t,r){this.ondata||I(5),this.s.l&&I(4);var e=t.length+this.s.z;if(e>this.b.length){if(e>2*this.b.length-32768){var i=new n(-32768&e);i.set(this.b.subarray(0,this.s.z)),this.b=i}var o=this.b.length-this.s.z;this.b.set(t.subarray(0,o),this.s.z),this.s.z=this.b.length,this.p(this.b,!1),this.b.set(this.b.subarray(-32768)),this.b.set(t.subarray(o),32768),this.s.z=t.length-o+32768,this.s.i=32766,this.s.w=32768}else this.b.set(t,this.s.z),this.s.z+=t.length;this.s.l=1&r,(this.s.z>this.s.w+8191||r)&&(this.p(this.b,r||!1),this.s.w=this.s.i,this.s.i-=2)},t.prototype.flush=function(){this.ondata||I(5),this.s.l&&I(4),this.p(this.b,!1),this.s.w=this.s.i,this.s.i-=2},t}();_e.Deflate=wt;var xt=function(){return function(t,n){ut([_,function(){return[at,wt]}],this,bt.call(this,t,n),(function(t){var n=new wt(t.data);onmessage=at(n)}),6,1)}}();function zt(t,n,r){return r||(r=n,n={}),"function"!=typeof r&&I(7),st(t,n,[_],(function(t){return it(kt(t.data[0],t.data[1]))}),0,r)}function kt(t,n){return K(t,n||{},0,0)}_e.AsyncDeflate=xt,_e.deflate=zt,_e.deflateSync=kt;var Mt=function(){function t(t,r){"function"==typeof t&&(r=t,t={}),this.ondata=r;var e=t&&t.dictionary&&t.dictionary.subarray(-32768);this.s={i:0,b:e?e.length:0},this.o=new n(32768),this.p=new n(0),e&&this.o.set(e)}return t.prototype.e=function(t){if(this.ondata||I(5),this.d&&I(4),this.p.length){if(t.length){var r=new n(this.p.length+t.length);r.set(this.p),r.set(t,this.p.length),this.p=r}}else this.p=t},t.prototype.c=function(t){this.s.i=+(this.d=t||!1);var n=this.s.b,r=U(this.p,this.s,this.o);this.ondata(D(r,n,this.s.b),this.d),this.o=D(r,this.s.b-32768),this.s.b=this.o.length,this.p=D(this.p,this.s.p/8|0),this.s.p&=7},t.prototype.push=function(t,n){this.e(t),this.c(n)},t}();_e.Inflate=Mt;var St=function(){return function(t,n){ut([$,function(){return[at,Mt]}],this,bt.call(this,t,n),(function(t){var n=new Mt(t.data);onmessage=at(n)}),7,0)}}();function At(t,n,r){return r||(r=n,n={}),"function"!=typeof r&&I(7),st(t,n,[$],(function(t){return it(Tt(t.data[0],ot(t.data[1])))}),1,r)}function Tt(t,n){return U(t,{i:2},n&&n.out,n&&n.dictionary)}_e.AsyncInflate=St,_e.inflate=At,_e.inflateSync=Tt;var Dt=function(){function t(t,n){this.c=Y(),this.l=0,this.v=1,wt.call(this,t,n)}return t.prototype.push=function(t,n){this.c.p(t),this.l+=t.length,wt.prototype.push.call(this,t,n)},t.prototype.p=function(t,n){var r=K(t,this.o,this.v&>(this.o),n&&8,this.s);this.v&&(pt(r,this.o),this.v=0),n&&(ct(r,r.length-8,this.c.d()),ct(r,r.length-4,this.l)),this.ondata(r,n)},t.prototype.flush=function(){wt.prototype.flush.call(this)},t}();_e.Gzip=Dt,_e.Compress=Dt;var Ct=function(){return function(t,n){ut([_,tt,function(){return[at,wt,Dt]}],this,bt.call(this,t,n),(function(t){var n=new Dt(t.data);onmessage=at(n)}),8,1)}}();function It(t,n,r){return r||(r=n,n={}),"function"!=typeof r&&I(7),st(t,n,[_,tt,function(){return[Ut]}],(function(t){return it(Ut(t.data[0],t.data[1]))}),2,r)}function Ut(t,n){n||(n={});var r=Y(),e=t.length;r.p(t);var i=K(t,n,gt(n),8),o=i.length;return pt(i,n),ct(i,o-8,r.d()),ct(i,o-4,e),i}_e.AsyncGzip=Ct,_e.AsyncCompress=Ct,_e.gzip=It,_e.compress=It,_e.gzipSync=Ut,_e.compressSync=Ut;var Ft=function(){function t(t,n){this.v=1,this.r=0,Mt.call(this,t,n)}return t.prototype.push=function(t,r){if(Mt.prototype.e.call(this,t),this.r+=t.length,this.v){var e=this.p.subarray(this.v-1),i=e.length>3?vt(e):4;if(i>e.length){if(!r)return}else this.v>1&&this.onmember&&this.onmember(this.r-e.length);this.p=e.subarray(i),this.v=0}Mt.prototype.c.call(this,r),!this.s.f||this.s.l||r||(this.v=T(this.s.p)+9,this.s={i:0},this.o=new n(0),this.push(new n(0),r))},t}();_e.Gunzip=Ft;var Et=function(){return function(t,n){var r=this;ut([$,nt,function(){return[at,Mt,Ft]}],this,bt.call(this,t,n),(function(t){var n=new Ft(t.data);n.onmember=function(t){return postMessage(t)},onmessage=at(n)}),9,0,(function(t){return r.onmember&&r.onmember(t)}))}}();function Zt(t,n,r){return r||(r=n,n={}),"function"!=typeof r&&I(7),st(t,n,[$,nt,function(){return[qt]}],(function(t){return it(qt(t.data[0],t.data[1]))}),3,r)}function qt(t,r){var e=vt(t);return e+8>t.length&&I(6,"invalid gzip data"),U(t.subarray(e,-8),{i:2},r&&r.out||new n(dt(t)),r&&r.dictionary)}_e.AsyncGunzip=Et,_e.gunzip=Zt,_e.gunzipSync=qt;var Ot=function(){function t(t,n){this.c=J(),this.v=1,wt.call(this,t,n)}return t.prototype.push=function(t,n){this.c.p(t),wt.prototype.push.call(this,t,n)},t.prototype.p=function(t,n){var r=K(t,this.o,this.v&&(this.o.dictionary?6:2),n&&4,this.s);this.v&&(yt(r,this.o),this.v=0),n&&ct(r,r.length-4,this.c.d()),this.ondata(r,n)},t.prototype.flush=function(){wt.prototype.flush.call(this)},t}();_e.Zlib=Ot;var Gt=function(){return function(t,n){ut([_,rt,function(){return[at,wt,Ot]}],this,bt.call(this,t,n),(function(t){var n=new Ot(t.data);onmessage=at(n)}),10,1)}}();function Lt(t,n,r){return r||(r=n,n={}),"function"!=typeof r&&I(7),st(t,n,[_,rt,function(){return[Ht]}],(function(t){return it(Ht(t.data[0],t.data[1]))}),4,r)}function Ht(t,n){n||(n={});var r=J();r.p(t);var e=K(t,n,n.dictionary?6:2,4);return yt(e,n),ct(e,e.length-4,r.d()),e}_e.AsyncZlib=Gt,_e.zlib=Lt,_e.zlibSync=Ht;var jt=function(){function t(t,n){Mt.call(this,t,n),this.v=t&&t.dictionary?2:1}return t.prototype.push=function(t,n){if(Mt.prototype.e.call(this,t),this.v){if(this.p.length<6&&!n)return;this.p=this.p.subarray(mt(this.p,this.v-1)),this.v=0}n&&(this.p.length<4&&I(6,"invalid zlib data"),this.p=this.p.subarray(0,-4)),Mt.prototype.c.call(this,n)},t}();_e.Unzlib=jt;var Nt=function(){return function(t,n){ut([$,et,function(){return[at,Mt,jt]}],this,bt.call(this,t,n),(function(t){var n=new jt(t.data);onmessage=at(n)}),11,0)}}();function Pt(t,n,r){return r||(r=n,n={}),"function"!=typeof r&&I(7),st(t,n,[$,et,function(){return[Bt]}],(function(t){return it(Bt(t.data[0],ot(t.data[1])))}),5,r)}function Bt(t,n){return U(t.subarray(mt(t,n&&n.dictionary),-4),{i:2},n&&n.out,n&&n.dictionary)}_e.AsyncUnzlib=Nt,_e.unzlib=Pt,_e.unzlibSync=Bt;var Yt=function(){function t(t,n){this.o=bt.call(this,t,n)||{},this.G=Ft,this.I=Mt,this.Z=jt}return t.prototype.i=function(){var t=this;this.s.ondata=function(n,r){t.ondata(n,r)}},t.prototype.push=function(t,r){if(this.ondata||I(5),this.s)this.s.push(t,r);else{if(this.p&&this.p.length){var e=new n(this.p.length+t.length);e.set(this.p),e.set(t,this.p.length)}else this.p=t;this.p.length>2&&(this.s=31==this.p[0]&&139==this.p[1]&&8==this.p[2]?new this.G(this.o):8!=(15&this.p[0])||this.p[0]>>4>7||(this.p[0]<<8|this.p[1])%31?new this.I(this.o):new this.Z(this.o),this.i(),this.s.push(this.p,r),this.p=null)}},t}();_e.Decompress=Yt;var Jt=function(){function t(t,n){Yt.call(this,t,n),this.queuedSize=0,this.G=Et,this.I=St,this.Z=Nt}return t.prototype.i=function(){var t=this;this.s.ondata=function(n,r,e){t.ondata(n,r,e)},this.s.ondrain=function(n){t.queuedSize-=n,t.ondrain&&t.ondrain(n)}},t.prototype.push=function(t,n){this.queuedSize+=t.length,Yt.prototype.push.call(this,t,n)},t}();function Kt(t,n,r){return r||(r=n,n={}),"function"!=typeof r&&I(7),31==t[0]&&139==t[1]&&8==t[2]?Zt(t,n,r):8!=(15&t[0])||t[0]>>4>7||(t[0]<<8|t[1])%31?At(t,n,r):Pt(t,n,r)}function Qt(t,n){return 31==t[0]&&139==t[1]&&8==t[2]?qt(t,n):8!=(15&t[0])||t[0]>>4>7||(t[0]<<8|t[1])%31?Tt(t,n):Bt(t,n)}_e.AsyncDecompress=Jt,_e.decompress=Kt,_e.decompressSync=Qt;var Rt=function(t,r,e,i){for(var o in t){var s=t[o],a=r+o,u=i;Array.isArray(s)&&(u=Q(i,s[1]),s=s[0]),s instanceof n?e[a]=[s,u]:(e[a+="/"]=[new n(0),u],Rt(s,a,e,i))}},Vt="undefined"!=typeof TextEncoder&&new TextEncoder,Wt="undefined"!=typeof TextDecoder&&new TextDecoder,Xt=0;try{Wt.decode(N,{stream:!0}),Xt=1}catch(t){}var $t=function(t){for(var n="",r=0;;){var e=t[r++],i=(e>127)+(e>223)+(e>239);if(r+i>t.length)return{s:n,r:D(t,r-1)};i?3==i?(e=((15&e)<<18|(63&t[r++])<<12|(63&t[r++])<<6|63&t[r++])-65536,n+=String.fromCharCode(55296|e>>10,56320|1023&e)):n+=String.fromCharCode(1&i?(31&e)<<6|63&t[r++]:(15&e)<<12|(63&t[r++])<<6|63&t[r++]):n+=String.fromCharCode(e)}},_t=function(){function t(t){this.ondata=t,Xt?this.t=new TextDecoder:this.p=N}return t.prototype.push=function(t,r){if(this.ondata||I(5),r=!!r,this.t)return this.ondata(this.t.decode(t,{stream:!0}),r),void(r&&(this.t.decode().length&&I(8),this.t=null));this.p||I(4);var e=new n(this.p.length+t.length);e.set(this.p),e.set(t,this.p.length);var i=$t(e),o=i.s,s=i.r;r?(s.length&&I(8),this.p=null):this.p=s,this.ondata(o,r)},t}();_e.DecodeUTF8=_t;var tn=function(){function t(t){this.ondata=t}return t.prototype.push=function(t,n){this.ondata||I(5),this.d&&I(4),this.ondata(nn(t),this.d=n||!1)},t}();function nn(t,r){if(r){for(var e=new n(t.length),i=0;i<t.length;++i)e[i]=t.charCodeAt(i);return e}if(Vt)return Vt.encode(t);var o=t.length,s=new n(t.length+(t.length>>1)),a=0,u=function(t){s[a++]=t};for(i=0;i<o;++i){if(a+5>s.length){var h=new n(a+8+(o-i<<1));h.set(s),s=h}var f=t.charCodeAt(i);f<128||r?u(f):f<2048?(u(192|f>>6),u(128|63&f)):f>55295&&f<57344?(u(240|(f=65536+(1047552&f)|1023&t.charCodeAt(++i))>>18),u(128|f>>12&63),u(128|f>>6&63),u(128|63&f)):(u(224|f>>12),u(128|f>>6&63),u(128|63&f))}return D(s,0,a)}function rn(t,n){if(n){for(var r="",e=0;e<t.length;e+=16384)r+=String.fromCharCode.apply(null,t.subarray(e,e+16384));return r}if(Wt)return Wt.decode(t);var i=$t(t),o=i.s;return(r=i.r).length&&I(8),o}_e.EncodeUTF8=tn,_e.strToU8=nn,_e.strFromU8=rn;var en=function(t){return 1==t?3:t<6?2:9==t?1:0},on=function(t,n){return n+30+ht(t,n+26)+ht(t,n+28)},sn=function(t,n,r){var e=ht(t,n+28),i=rn(t.subarray(n+46,n+46+e),!(2048&ht(t,n+8))),o=n+46+e,s=ft(t,n+20),a=r&&4294967295==s?an(t,o):[s,ft(t,n+24),ft(t,n+42)],u=a[0],h=a[1],f=a[2];return[ht(t,n+10),u,h,i,o+ht(t,n+30)+ht(t,n+32),f]},an=function(t,n){for(;1!=ht(t,n);n+=4+ht(t,n+2));return[lt(t,n+12),lt(t,n+4),lt(t,n+20)]},un=function(t){var n=0;if(t)for(var r in t){var e=t[r].length;e>65535&&I(9),n+=e+4}return n},hn=function(t,n,r,e,i,o,s,a){var u=e.length,h=r.extra,f=a&&a.length,l=un(h);ct(t,n,null!=s?33639248:67324752),n+=4,null!=s&&(t[n++]=20,t[n++]=r.os),t[n]=20,n+=2,t[n++]=r.flag<<1|(o<0&&8),t[n++]=i&&8,t[n++]=255&r.compression,t[n++]=r.compression>>8;var c=new Date(null==r.mtime?Date.now():r.mtime),p=c.getFullYear()-1980;if((p<0||p>119)&&I(10),ct(t,n,p<<25|c.getMonth()+1<<21|c.getDate()<<16|c.getHours()<<11|c.getMinutes()<<5|c.getSeconds()>>1),n+=4,-1!=o&&(ct(t,n,r.crc),ct(t,n+4,o<0?-o-2:o),ct(t,n+8,r.size)),ct(t,n+12,u),ct(t,n+14,l),n+=16,null!=s&&(ct(t,n,f),ct(t,n+6,r.attrs),ct(t,n+10,s),n+=14),t.set(e,n),n+=u,l)for(var v in h){var d=h[v],g=d.length;ct(t,n,+v),ct(t,n+2,g),t.set(d,n+4),n+=4+g}return f&&(t.set(a,n),n+=f),n},fn=function(t,n,r,e,i){ct(t,n,101010256),ct(t,n+8,r),ct(t,n+10,r),ct(t,n+12,e),ct(t,n+16,i)},ln=function(){function t(t){this.filename=t,this.c=Y(),this.size=0,this.compression=0}return t.prototype.process=function(t,n){this.ondata(null,t,n)},t.prototype.push=function(t,n){this.ondata||I(5),this.c.p(t),this.size+=t.length,n&&(this.crc=this.c.d()),this.process(t,n||!1)},t}();_e.ZipPassThrough=ln;var cn=function(){function t(t,n){var r=this;n||(n={}),ln.call(this,t),this.d=new wt(n,(function(t,n){r.ondata(null,t,n)})),this.compression=8,this.flag=en(n.level)}return t.prototype.process=function(t,n){try{this.d.push(t,n)}catch(t){this.ondata(t,null,n)}},t.prototype.push=function(t,n){ln.prototype.push.call(this,t,n)},t}();_e.ZipDeflate=cn;var pn=function(){function t(t,n){var r=this;n||(n={}),ln.call(this,t),this.d=new xt(n,(function(t,n,e){r.ondata(t,n,e)})),this.compression=8,this.flag=en(n.level),this.terminate=this.d.terminate}return t.prototype.process=function(t,n){this.d.push(t,n)},t.prototype.push=function(t,n){ln.prototype.push.call(this,t,n)},t}();_e.AsyncZipDeflate=pn;var vn=function(){function t(t){this.ondata=t,this.u=[],this.d=1}return t.prototype.add=function(t){var r=this;if(this.ondata||I(5),2&this.d)this.ondata(I(4+8*(1&this.d),0,1),null,!1);else{var e=nn(t.filename),i=e.length,o=t.comment,s=o&&nn(o),a=i!=t.filename.length||s&&o.length!=s.length,u=i+un(t.extra)+30;i>65535&&this.ondata(I(11,0,1),null,!1);var h=new n(u);hn(h,0,t,e,a,-1);var f=[h],l=function(){for(var t=0,n=f;t<n.length;t++)r.ondata(null,n[t],!1);f=[]},c=this.d;this.d=0;var p=this.u.length,v=Q(t,{f:e,u:a,o:s,t:function(){t.terminate&&t.terminate()},r:function(){if(l(),c){var t=r.u[p+1];t?t.r():r.d=1}c=1}}),d=0;t.ondata=function(e,i,o){if(e)r.ondata(e,i,o),r.terminate();else if(d+=i.length,f.push(i),o){var s=new n(16);ct(s,0,134695760),ct(s,4,t.crc),ct(s,8,d),ct(s,12,t.size),f.push(s),v.c=d,v.b=u+d+16,v.crc=t.crc,v.size=t.size,c&&v.r(),c=1}else c&&l()},this.u.push(v)}},t.prototype.end=function(){var t=this;2&this.d?this.ondata(I(4+8*(1&this.d),0,1),null,!0):(this.d?this.e():this.u.push({r:function(){1&t.d&&(t.u.splice(-1,1),t.e())},t:function(){}}),this.d=3)},t.prototype.e=function(){for(var t=0,r=0,e=0,i=0,o=this.u;i<o.length;i++)e+=46+(h=o[i]).f.length+un(h.extra)+(h.o?h.o.length:0);for(var s=new n(e+22),a=0,u=this.u;a<u.length;a++){var h;hn(s,t,h=u[a],h.f,h.u,-h.c-2,r,h.o),t+=46+h.f.length+un(h.extra)+(h.o?h.o.length:0),r+=h.b}fn(s,t,this.u.length,e,r),this.ondata(null,s,!0),this.d=2},t.prototype.terminate=function(){for(var t=0,n=this.u;t<n.length;t++)n[t].t();this.d=2},t}();function dn(t,r,e){e||(e=r,r={}),"function"!=typeof e&&I(7);var i={};Rt(t,"",i,r);var o=Object.keys(i),s=o.length,a=0,u=0,h=s,f=Array(s),l=[],c=function(){for(var t=0;t<l.length;++t)l[t]()},p=function(t,n){xn((function(){e(t,n)}))};xn((function(){p=e}));var v=function(){var t=new n(u+22),r=a,e=u-a;u=0;for(var i=0;i<h;++i){var o=f[i];try{var s=o.c.length;hn(t,u,o,o.f,o.u,s);var l=30+o.f.length+un(o.extra),c=u+l;t.set(o.c,c),hn(t,a,o,o.f,o.u,s,u,o.m),a+=16+l+(o.m?o.m.length:0),u=c+s}catch(t){return p(t,null)}}fn(t,a,f.length,e,r),p(null,t)};s||v();for(var d=function(t){var n=o[t],r=i[n],e=r[0],h=r[1],d=Y(),g=e.length;d.p(e);var y=nn(n),m=y.length,b=h.comment,w=b&&nn(b),x=w&&w.length,z=un(h.extra),k=0==h.level?0:8,M=function(r,e){if(r)c(),p(r,null);else{var i=e.length;f[t]=Q(h,{size:g,crc:d.d(),c:e,f:y,m:w,u:m!=n.length||w&&b.length!=x,compression:k}),a+=30+m+z+i,u+=76+2*(m+z)+(x||0)+i,--s||v()}};if(m>65535&&M(I(11,0,1),null),k)if(g<16e4)try{M(null,kt(e,h))}catch(t){M(t,null)}else l.push(zt(e,h,M));else M(null,e)},g=0;g<h;++g)d(g);return c}function gn(t,r){r||(r={});var e={},i=[];Rt(t,"",e,r);var o=0,s=0;for(var a in e){var u=e[a],h=u[0],f=u[1],l=0==f.level?0:8,c=(M=nn(a)).length,p=f.comment,v=p&&nn(p),d=v&&v.length,g=un(f.extra);c>65535&&I(11);var y=l?kt(h,f):h,m=y.length,b=Y();b.p(h),i.push(Q(f,{size:h.length,crc:b.d(),c:y,f:M,m:v,u:c!=a.length||v&&p.length!=d,o:o,compression:l})),o+=30+c+g+m,s+=76+2*(c+g)+(d||0)+m}for(var w=new n(s+22),x=o,z=s-o,k=0;k<i.length;++k){var M;hn(w,(M=i[k]).o,M,M.f,M.u,M.c.length);var S=30+M.f.length+un(M.extra);w.set(M.c,M.o+S),hn(w,o,M,M.f,M.u,M.c.length,M.o,M.m),o+=16+S+(M.m?M.m.length:0)}return fn(w,o,i.length,z,x),w}_e.Zip=vn,_e.zip=dn,_e.zipSync=gn;var yn=function(){function t(){}return t.prototype.push=function(t,n){this.ondata(null,t,n)},t.compression=0,t}();_e.UnzipPassThrough=yn;var mn=function(){function t(){var t=this;this.i=new Mt((function(n,r){t.ondata(null,n,r)}))}return t.prototype.push=function(t,n){try{this.i.push(t,n)}catch(t){this.ondata(t,null,n)}},t.compression=8,t}();_e.UnzipInflate=mn;var bn=function(){function t(t,n){var r=this;n<32e4?this.i=new Mt((function(t,n){r.ondata(null,t,n)})):(this.i=new St((function(t,n,e){r.ondata(t,n,e)})),this.terminate=this.i.terminate)}return t.prototype.push=function(t,n){this.i.terminate&&(t=D(t,0)),this.i.push(t,n)},t.compression=8,t}();_e.AsyncUnzipInflate=bn;var wn=function(){function t(t){this.onfile=t,this.k=[],this.o={0:yn},this.p=N}return t.prototype.push=function(t,r){var e=this;if(this.onfile||I(5),this.p||I(4),this.c>0){var i=Math.min(this.c,t.length),o=t.subarray(0,i);if(this.c-=i,this.d?this.d.push(o,!this.c):this.k[0].push(o),(t=t.subarray(i)).length)return this.push(t,r)}else{var s=0,a=0,u=void 0,h=void 0;this.p.length?t.length?((h=new n(this.p.length+t.length)).set(this.p),h.set(t,this.p.length)):h=this.p:h=t;for(var f=h.length,l=this.c,c=l&&this.d,p=function(){var t,n=ft(h,a);if(67324752==n){s=1,u=a,v.d=null,v.c=0;var r=ht(h,a+6),i=ht(h,a+8),o=2048&r,c=8&r,p=ht(h,a+26),d=ht(h,a+28);if(f>a+30+p+d){var g=[];v.k.unshift(g),s=2;var y,m=ft(h,a+18),b=ft(h,a+22),w=rn(h.subarray(a+30,a+=30+p),!o);4294967295==m?(t=c?[-2]:an(h,a),m=t[0],b=t[1]):c&&(m=-1),a+=d,v.c=m;var x={name:w,compression:i,start:function(){if(x.ondata||I(5),m){var t=e.o[i];t||x.ondata(I(14,"unknown compression type "+i,1),null,!1),(y=m<0?new t(w):new t(w,m,b)).ondata=function(t,n,r){x.ondata(t,n,r)};for(var n=0,r=g;n<r.length;n++)y.push(r[n],!1);e.k[0]==g&&e.c?e.d=y:y.push(N,!0)}else x.ondata(null,N,!0)},terminate:function(){y&&y.terminate&&y.terminate()}};m>=0&&(x.size=m,x.originalSize=b),v.onfile(x)}return"break"}if(l){if(134695760==n)return u=a+=12+(-2==l&&8)-(134695760==ft(h,u-16)&&4),s=3,v.c=0,"break";if(33639248==n)return u=a-=4,s=3,v.c=0,"break"}},v=this;a<f-4&&"break"!==p();++a);if(this.p=N,l<0){var d=h.subarray(0,s?u-12-(-2==l&&8)-(134695760==ft(h,u-16)&&4):a);c?c.push(d,!!s):this.k[+(2==s)].push(d)}if(2&s)return this.push(h.subarray(a),r);this.p=h.subarray(a)}r&&(this.c&&I(13),this.p=null)},t.prototype.register=function(t){this.o[t.compression]=t},t}();_e.Unzip=wn;var xn="function"==typeof queueMicrotask?queueMicrotask:"function"==typeof setTimeout?setTimeout:function(t){t()};function zn(t,r,e){e||(e=r,r={}),"function"!=typeof e&&I(7);var i=[],o=function(){for(var t=0;t<i.length;++t)i[t]()},s={},a=function(t,n){xn((function(){e(t,n)}))};xn((function(){a=e}));for(var u=t.length-22;101010256!=ft(t,u);--u)if(!u||t.length-u>65558)return a(I(13,0,1),null),o;var h=ht(t,u+8);if(h){var f=h,l=ft(t,u+16),c=4294967295==l||65535==f;if(c){var p=ft(t,u-12);(c=101075792==ft(t,p))&&(f=h=ft(t,p+32),l=ft(t,p+48))}for(var v=r&&r.filter,d=function(r){var e=sn(t,l,c),u=e[0],f=e[1],p=e[2],d=e[3],g=e[4],y=on(t,e[5]);l=g;var m=function(t,n){t?(o(),a(t,null)):(n&&(s[d]=n),--h||a(null,s))};if(!v||v({name:d,size:f,originalSize:p,compression:u}))if(u)if(8==u){var b=t.subarray(y,y+f);if(p<524288||f>.8*p)try{m(null,Tt(b,{out:new n(p)}))}catch(t){m(t,null)}else i.push(At(b,{size:p},m))}else m(I(14,"unknown compression type "+u,1),null);else m(null,D(t,y,y+f));else m(null,null)},g=0;g<f;++g)d()}else a(null,{});return o}function kn(t,r){for(var e={},i=t.length-22;101010256!=ft(t,i);--i)(!i||t.length-i>65558)&&I(13);var o=ht(t,i+8);if(!o)return{};var s=ft(t,i+16),a=4294967295==s||65535==o;if(a){var u=ft(t,i-12);(a=101075792==ft(t,u))&&(o=ft(t,u+32),s=ft(t,u+48))}for(var h=r&&r.filter,f=0;f<o;++f){var l=sn(t,s,a),c=l[0],p=l[1],v=l[2],d=l[3],g=l[4],y=on(t,l[5]);s=g,h&&!h({name:d,size:p,originalSize:v,compression:c})||(c?8==c?e[d]=Tt(t.subarray(y,y+p),{out:new n(v)}):I(14,"unknown compression type "+c):e[d]=D(t,y,y+p))}return e}_e.unzip=zn,_e.unzipSync=kn;
|
|
8
|
+
return _e;
|
|
9
|
+
})();
|
|
10
|
+
|
|
11
|
+
// 导出 ES6 模块
|
|
12
|
+
export default fflate;
|
|
@@ -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{__decorate as e}from"tslib";import t from"../../request.js";import r from"../../core/Error.js";import o from"../../core/Logger.js";import{debounce as i}from"../../core/promiseUtils.js";import{property as s}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/RandomLCG.js";import{reader as a}from"../../core/accessorSupport/decorators/reader.js";import{subclass as n}from"../../core/accessorSupport/decorators/subclass.js";import{updateOrigins as l}from"../../core/accessorSupport/originUtils.js";import p from"../../geometry/Extent.js";import c from"../../geometry/HeightModelInfo.js";import d from"../../geometry/SpatialReference.js";import{titleFromUrlAndName as m,parse as u,cleanTitle as h}from"../support/arcgisLayerUrl.js";import{id as y}from"../support/commonProperties.js";import{fetchIndexInfo as f}from"../support/I3SIndexInfo.js";import{urlProperty as v,normalizeParsedUrlObject as S}from"../support/multiLayerServiceUtils.js";import{getLoader as g}from"../support/schemaValidatorLoader.js";import w from"../../portal/Portal.js";import x from"../../portal/PortalItem.js";import{createForItemWrite as I}from"../../portal/support/jsonContext.js";import{saveResources as j,updateItemWithResources as b}from"../../webdoc/support/resourceUtils.js";import{evaluateWriteErrors as N}from"../../webdoc/support/saveUtils.js";const _=_=>{const A=_;let E=class extends A{constructor(){super(...arguments),this.spatialReference=null,this.fullExtent=null,this.heightModelInfo=null,this.minScale=0,this.maxScale=0,this.version={major:Number.NaN,minor:Number.NaN,versionString:""},this.copyright=null,this.sublayerTitleMode="item-title",this.title=null,this.layerId=null,this.url=null,this.indexInfo=null,this._debouncedSaveOperations=i(async(e,t,r)=>{switch(e){case 0:return this._save(t);case 1:return this._saveAs(r,t)}})}readSpatialReference(e,t){return L(t)}readFullExtent(e,t,r){if(null!=e&&"object"==typeof e){const o=null==e.spatialReference?{...e,spatialReference:L(t)}:e;return p.fromJSON(o,r)}const o=t.store,i=L(t);return null==i||null==o?.extent||!Array.isArray(o.extent)||o.extent.some(e=>e<R)?null:new p({xmin:o.extent[0],ymin:o.extent[1],xmax:o.extent[2],ymax:o.extent[3],spatialReference:i})}parseVersionString(e){const t={major:Number.NaN,minor:Number.NaN,versionString:e},r=e.split(".");return r.length>=2&&(t.major=parseInt(r[0],10),t.minor=parseInt(r[1],10)),t}readVersion(e,t){const r=t.store,o=null!=r.version?r.version.toString():"";return this.parseVersionString(o)}readTitlePortalItem(e){return"item-title"!==this.sublayerTitleMode?void 0:e}readTitleService(e,t){const r=this.portalItem?.title;if("item-title"===this.sublayerTitleMode)return this.url?m(this.url,t.name):t.name;let o=t.name;if(!o&&this.url){const e=u(this.url);null!=e&&(o=e.title)}return"item-title-and-service-name"===this.sublayerTitleMode&&r&&(o=r+" - "+o),h(o)}get parsedUrl(){return S(this,{separator:"layers"})}async _fetchIndexAndUpdateExtent(e,t){this.indexInfo=f(this.parsedUrl?.path??"",this.rootNode,e,this.customParameters,this.apiKey,o.getLogger(this),t);const{fullExtent:r}=this;null==r||r.hasZ||this._updateExtent(r,await this.indexInfo)}_updateExtent(e,t){if("page"===t?.type){const r=t.rootIndex%t.pageSize,o=t.rootPage?.nodes?.[r];O(e,o?.obb)}else if("node"===t?.type){const r=t.rootNode?.mbs;if(!Array.isArray(r)||4!==r.length||r[0]<R)return;const o=r[2],i=r[3];e.zmin=o-i,e.zmax=o+i}}async _fetchService(e){if(null==this.url)throw new r("sceneservice:url-not-set","Scene service can not be loaded without valid portal item or url");if(null==this.layerId&&/SceneServer\/*$/i.test(this.url)){const t=await this._fetchFirstLayerId(e);null!=t&&(this.layerId=t)}return this._fetchServiceLayer(e)}async _fetchFirstLayerId(e){const r=await t(this.url??"",{query:{f:"json",...this.customParameters,token:this.apiKey},responseType:"json",signal:e});if(r.data&&Array.isArray(r.data.layers)&&r.data.layers.length>0)return r.data.layers[0].id}async _fetchServiceLayer(e){const r=await t(this.parsedUrl?.path??"",{query:{f:"json",...this.customParameters,token:this.apiKey},responseType:"json",signal:e});r.ssl&&this.url&&(this.url=this.url.replace(/^http:/i,"https:"));let o=!1;if(r.data.layerType&&"Voxel"===r.data.layerType&&(o=!0),o)return this._fetchVoxelServiceLayer();const i=r.data;this.read(i,this._getServiceContext()),this.validateLayer(i)}async _fetchVoxelServiceLayer(e){const r=(await t(this.parsedUrl?.path+"/layer",{query:{f:"json",...this.customParameters,token:this.apiKey},responseType:"json",signal:e})).data;this.read(r,this._getServiceContext()),this.validateLayer(r)}_getServiceContext(){return{origin:"service",portalItem:this.portalItem,portal:this.portalItem?.portal,url:this.parsedUrl}}async _ensureLoadBeforeSave(){await this.load(),"beforeSave"in this&&"function"==typeof this.beforeSave&&await this.beforeSave()}validateLayer(e){}async _saveAs(e,t){const o={...P,...t};let i=x.from(e);if(!i)throw new r("sceneservice:portal-item-required","_saveAs() requires a portal item to save to");i.id&&(i=i.clone(),i.id=null);const s=i.portal||w.getDefault();await this._ensureLoadBeforeSave(),i.type=U,i.portal=s;const a=I(i,"portal-item",!0),n={layers:[this.write({},a)]};return await Promise.all(a.resources.pendingOperations??[]),await this._validateAgainstJSONSchema(n,a,o),this.url&&(i.url=this.url),i.title||(i.title=this.title),T(i,o,1),await s.signIn(),await s.user.addItem({item:i,folder:o?.folder,data:n}),await j(this.resourceReferences,a),this.portalItem=i,l(a),a.portalItem=i,i}async _save(e){const t={...P,...e};if(!this.portalItem)throw new r("sceneservice:portal-item-not-set","Portal item to save to has not been set on this SceneService");if(this.portalItem.type!==U)throw new r("sceneservice:portal-item-wrong-type",`Portal item needs to have type
|
|
5
|
+
import{__decorate as e}from"tslib";import t from"../../request.js";import r from"../../core/Error.js";import o from"../../core/Logger.js";import{debounce as i}from"../../core/promiseUtils.js";import{property as s}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/RandomLCG.js";import{reader as a}from"../../core/accessorSupport/decorators/reader.js";import{subclass as n}from"../../core/accessorSupport/decorators/subclass.js";import{updateOrigins as l}from"../../core/accessorSupport/originUtils.js";import p from"../../geometry/Extent.js";import c from"../../geometry/HeightModelInfo.js";import d from"../../geometry/SpatialReference.js";import{titleFromUrlAndName as m,parse as u,cleanTitle as h}from"../support/arcgisLayerUrl.js";import{id as y}from"../support/commonProperties.js";import{fetchIndexInfo as f}from"../support/I3SIndexInfo.js";import{urlProperty as v,normalizeParsedUrlObject as S}from"../support/multiLayerServiceUtils.js";import{getLoader as g}from"../support/schemaValidatorLoader.js";import w from"../../portal/Portal.js";import x from"../../portal/PortalItem.js";import{createForItemWrite as I}from"../../portal/support/jsonContext.js";import{saveResources as j,updateItemWithResources as b}from"../../webdoc/support/resourceUtils.js";import{evaluateWriteErrors as N}from"../../webdoc/support/saveUtils.js";const _=_=>{const A=_;let E=class extends A{constructor(){super(...arguments),this.spatialReference=null,this.fullExtent=null,this.heightModelInfo=null,this.minScale=0,this.maxScale=0,this.version={major:Number.NaN,minor:Number.NaN,versionString:""},this.copyright=null,this.sublayerTitleMode="item-title",this.title=null,this.layerId=null,this.url=null,this.indexInfo=null,this._debouncedSaveOperations=i(async(e,t,r)=>{switch(e){case 0:return this._save(t);case 1:return this._saveAs(r,t)}})}readSpatialReference(e,t){return L(t)}readFullExtent(e,t,r){if(null!=e&&"object"==typeof e){const o=null==e.spatialReference?{...e,spatialReference:L(t)}:e;return p.fromJSON(o,r)}const o=t.store,i=L(t);return null==i||null==o?.extent||!Array.isArray(o.extent)||o.extent.some(e=>e<R)?null:new p({xmin:o.extent[0],ymin:o.extent[1],xmax:o.extent[2],ymax:o.extent[3],spatialReference:i})}parseVersionString(e){const t={major:Number.NaN,minor:Number.NaN,versionString:e},r=e.split(".");return r.length>=2&&(t.major=parseInt(r[0],10),t.minor=parseInt(r[1],10)),t}readVersion(e,t){const r=t.store,o=null!=r.version?r.version.toString():"";return this.parseVersionString(o)}readTitlePortalItem(e){return"item-title"!==this.sublayerTitleMode?void 0:e}readTitleService(e,t){const r=this.portalItem?.title;if("item-title"===this.sublayerTitleMode)return this.url?m(this.url,t.name):t.name;let o=t.name;if(!o&&this.url){const e=u(this.url);null!=e&&(o=e.title)}return"item-title-and-service-name"===this.sublayerTitleMode&&r&&(o=r+" - "+o),h(o)}get parsedUrl(){return S(this,{separator:"layers"})}async _fetchIndexAndUpdateExtent(e,t){this.indexInfo=f(this.parsedUrl?.path??"",this.rootNode,e,this.customParameters,this.apiKey,o.getLogger(this),t);const{fullExtent:r}=this;null==r||r.hasZ||this._updateExtent(r,await this.indexInfo)}_updateExtent(e,t){if("page"===t?.type){const r=t.rootIndex%t.pageSize,o=t.rootPage?.nodes?.[r];O(e,o?.obb)}else if("node"===t?.type){const r=t.rootNode?.mbs;if(!Array.isArray(r)||4!==r.length||r[0]<R)return;const o=r[2],i=r[3];e.zmin=o-i,e.zmax=o+i}}async _fetchService(e){if(null==this.url)throw new r("sceneservice:url-not-set","Scene service can not be loaded without valid portal item or url");if(null==this.layerId&&/SceneServer\/*$/i.test(this.url)){const t=await this._fetchFirstLayerId(e);null!=t&&(this.layerId=t)}return this._fetchServiceLayer(e)}async _fetchFirstLayerId(e){const r=await t(this.url??"",{query:{f:"json",...this.customParameters,token:this.apiKey},responseType:"json",signal:e});try{const decryptEnabled=this.decrypt?.enabled??true;if(decryptEnabled&&this.decrypt?.url){this._decodeData=await t(this.decrypt?.url,{query:{},responseType:"json"})}}catch(error){console.log(error)}if(r.data&&Array.isArray(r.data.layers)&&r.data.layers.length>0)return r.data.layers[0].id}async _fetchServiceLayer(e){const r=await t(this.parsedUrl?.path??"",{query:{f:"json",...this.customParameters,token:this.apiKey},responseType:"json",signal:e});r.ssl&&this.url&&(this.url=this.url.replace(/^http:/i,"https:"));let o=!1;if(r.data.layerType&&"Voxel"===r.data.layerType&&(o=!0),o)return this._fetchVoxelServiceLayer();const i=r.data;this.read(i,this._getServiceContext()),this.validateLayer(i)}async _fetchVoxelServiceLayer(e){const r=(await t(this.parsedUrl?.path+"/layer",{query:{f:"json",...this.customParameters,token:this.apiKey},responseType:"json",signal:e})).data;this.read(r,this._getServiceContext()),this.validateLayer(r)}_getServiceContext(){return{origin:"service",portalItem:this.portalItem,portal:this.portalItem?.portal,url:this.parsedUrl}}async _ensureLoadBeforeSave(){await this.load(),"beforeSave"in this&&"function"==typeof this.beforeSave&&await this.beforeSave()}validateLayer(e){}async _saveAs(e,t){const o={...P,...t};let i=x.from(e);if(!i)throw new r("sceneservice:portal-item-required","_saveAs() requires a portal item to save to");i.id&&(i=i.clone(),i.id=null);const s=i.portal||w.getDefault();await this._ensureLoadBeforeSave(),i.type=U,i.portal=s;const a=I(i,"portal-item",!0),n={layers:[this.write({},a)]};return await Promise.all(a.resources.pendingOperations??[]),await this._validateAgainstJSONSchema(n,a,o),this.url&&(i.url=this.url),i.title||(i.title=this.title),T(i,o,1),await s.signIn(),await s.user.addItem({item:i,folder:o?.folder,data:n}),await j(this.resourceReferences,a),this.portalItem=i,l(a),a.portalItem=i,i}async _save(e){const t={...P,...e};if(!this.portalItem)throw new r("sceneservice:portal-item-not-set","Portal item to save to has not been set on this SceneService");if(this.portalItem.type!==U)throw new r("sceneservice:portal-item-wrong-type",`Portal item needs to have type"${U}"`);await this._ensureLoadBeforeSave();const o=I(this.portalItem,"portal-item",!0),i={layers:[this.write({},o)]};return await Promise.all(o.resources.pendingOperations??[]),await this._validateAgainstJSONSchema(i,o,t),this.url&&(this.portalItem.url=this.url),this.portalItem.title||(this.portalItem.title=this.title),T(this.portalItem,t,0),await b(this.portalItem,i,this.resourceReferences,o),l(o),this.portalItem}async _validateAgainstJSONSchema(e,t,i){const s=i?.validationOptions;N(t,{errorName:"sceneservice:save"},{ignoreUnsupported:s?.ignoreUnsupported,supplementalUnsupportedErrors:["scenemodification:unsupported"]});const a=s?.enabled,n=g();if(a&&n){const t=(await n()).validate(e,i.portalItemLayerType);if(!t.length)return;const a=`Layer item did not validate:\n${t.join("\n")}`;if(o.getLogger(this).error(`_validateAgainstJSONSchema():${a}`),"throw"===s.failPolicy){const e=t.map(e=>new r("sceneservice:schema-validation",e));throw new r("sceneservice-validate:error","Failed to save layer item due to schema validation, see `details.errors`.",{validationErrors:e})}}}};return e([s(y)],E.prototype,"id",void 0),e([s({type:d})],E.prototype,"spatialReference",void 0),e([a("spatialReference",["spatialReference","store.indexCRS","store.geographicCRS"])],E.prototype,"readSpatialReference",null),e([s({type:p})],E.prototype,"fullExtent",void 0),e([a("fullExtent",["fullExtent","store.extent","spatialReference","store.indexCRS","store.geographicCRS"])],E.prototype,"readFullExtent",null),e([s({readOnly:!0,type:c})],E.prototype,"heightModelInfo",void 0),e([s({type:Number,json:{name:"layerDefinition.minScale",write:!0,origins:{service:{read:{source:"minScale"},write:!1}}}})],E.prototype,"minScale",void 0),e([s({type:Number,json:{name:"layerDefinition.maxScale",write:!0,origins:{service:{read:{source:"maxScale"},write:!1}}}})],E.prototype,"maxScale",void 0),e([s({readOnly:!0})],E.prototype,"version",void 0),e([a("version",["store.version"])],E.prototype,"readVersion",null),e([s({type:String,json:{read:{source:"copyrightText"}}})],E.prototype,"copyright",void 0),e([s({type:String,json:{read:!1}})],E.prototype,"sublayerTitleMode",void 0),e([s({type:String})],E.prototype,"title",void 0),e([a("portal-item","title")],E.prototype,"readTitlePortalItem",null),e([a("service","title",["name"])],E.prototype,"readTitleService",null),e([s({type:Number,json:{origins:{service:{read:{source:"id"}},"portal-item":{write:{target:"id",isRequired:!0,ignoreOrigin:!0},read:!1}}}})],E.prototype,"layerId",void 0),e([s(v({separator:"layers"}))],E.prototype,"url",void 0),e([s({readOnly:!0})],E.prototype,"parsedUrl",null),e([s({readOnly:!0})],E.prototype,"store",void 0),e([s({type:String,readOnly:!0,json:{read:{source:"store.rootNode"}}})],E.prototype,"rootNode",void 0),E=e([n("geoscene.layers.mixins.SceneService")],E),E},R=-1e38;function L(e){if(null!=e.spatialReference)return d.fromJSON(e.spatialReference);const t=e.store,r=t.indexCRS||t.geographicCRS,o=r&&parseInt(r.slice(r.lastIndexOf("/")+1),10);return null!=o?new d(o):null}function O(e,t){if(null==t?.center||null==t.halfSize)throw new r("sceneservice:invalid-node-page","Invalid node page.");if(t.center[0]<R)return;const o=t.halfSize,i=t.center[2],s=Math.sqrt(o[0]*o[0]+o[1]*o[1]+o[2]*o[2]);e.zmin=i-s,e.zmax=i+s}function T(e,t,r){e.typeKeywords||(e.typeKeywords=[]);const o=t.getTypeKeywords();for(const i of o)e.typeKeywords.push(i);e.typeKeywords&&(e.typeKeywords=e.typeKeywords.filter((e,t,r)=>r.indexOf(e)===t),1===r&&(e.typeKeywords=e.typeKeywords.filter(e=>"Hosted Service"!==e)))}const U="Scene Service",P={getTypeKeywords:()=>[],portalItemLayerType:"unknown",validationOptions:{enabled:!0,ignoreUnsupported:!1,failPolicy:"throw"}};export{_ as SceneService,U as sceneServiceItemType,O as updateExtentFromPageObb};
|
|
@@ -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{__decorate as e}from"tslib";import t from"../../../core/Error.js";import{assertIsSome as i}from"../../../core/maybe.js";import{urlToObject as s}from"../../../core/urlUtils.js";import{property as r}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as a}from"../../../core/accessorSupport/decorators/subclass.js";import l from"../../../geometry/Extent.js";import n from"../../../geometry/Point.js";import o from"../../../geometry/SpatialReference.js";import c from"../RasterInfo.js";import m from"../RasterStorageInfo.js";import u from"../TileInfo.js";import{TilemapCache as h}from"../TilemapCache.js";import f from"./BaseRaster.js";import{setValidBoundary as p}from"../rasterFunctions/pixelUtils.js";import d from"../rasterTransforms/GCSShiftTransform.js";import{patchServiceInfo as y,fetchServiceRasterInfo as x}from"../../../rest/imageService/fetchRasterInfo.js";let g=class extends f{constructor(){super(...arguments),this._levelOffset=0,this._tilemapCache=null,this._slices=null,this.datasetFormat="RasterTileServer",this.tileType=null}async fetchRawTile(e,t,i,s={}){const{storageInfo:r,extent:a}=this.rasterInfo,{transposeInfo:l}=r,n=null!=l&&!!s.transposedVariableName;if(this._slices&&!n&&null==s.sliceId)return null;const o=n?0:r.maximumPyramidLevel-e+this._levelOffset,c=`${this.url}/tile/${o}/${t}/${i}`,m=this._slices?n?{variable:s.transposedVariableName}:{sliceId:s.sliceId||0}:null;let u,h;if(r.isBsqTile){const e=(s.bandIds?.length?s.bandIds:[0,1,2]).map(e=>this.request(c,{query:{...m,bandId:e},responseType:"array-buffer",signal:s.signal})),t=await Promise.all(e),i=t.map(e=>e.data.byteLength).reduce((e,t)=>e+t),r=new Uint8Array(i);h=[];let a=0;for(const{data:s}of t)h.push(a),r.set(new Uint8Array(s),a),a+=s.byteLength;u=r.buffer}else{u=(await this.request(c,{query:m,responseType:"array-buffer",signal:s.signal})).data}if(!u)return null;const f=n?l.tileSize:r.tileInfo.size,d=await this.decodePixelBlock(u,{width:f[0],height:f[1],planes:h?.length,offsets:h,pixelType:null,isPoint:"Elevation"===this.tileType,returnInterleaved:n,noDataValue:this.rasterInfo.noDataValue});if(null==d)return null;const y=r.blockBoundary[e];if("jpg"!==r.compression||i>y.minCol&&i<y.maxCol&&t>y.minRow&&t<y.maxRow)return d;const{origin:x,blockWidth:g,blockHeight:v}=r,{x:S,y:I}=this.getPyramidPixelSize(e),w=Math.round((a.xmin-x.x)/S)%g,b=Math.round((a.xmax-x.x)/S)%g||g,T=Math.round((x.y-a.ymax)/I)%v,M=Math.round((x.y-a.ymin)/I)%v||v,j=i===y.minCol?w:0,_=t===y.minRow?T:0,O=i===y.maxCol?b:g,R=t===y.maxRow?M:v;return p(d,{x:j,y:_},{width:O-j,height:R-_}),d}getSliceIndex(e){if(!this._slices||null==e||0===e.length)return null;const t=e;for(let i=0;i<this._slices.length;i++){const e=this._slices[i].multidimensionalDefinition;if(e.length===t.length&&!e.some(e=>{const i=t.find(t=>e.variableName===t.variableName&&t.dimensionName===e.dimensionName);if(!i)return!0;return(Array.isArray(e.values[0])?`${e.values[0][0]}-${e.values[0][1]}`:e.values[0])!==(Array.isArray(i.values[0])?`${i.values[0][0]}-${i.values[0][1]}`:i.values[0])}))return i}return null}async fetchVariableStatisticsHistograms(e,t){const i=this.request(this.url+"/statistics",{query:{variable:e,f:"json"},signal:t}).then(e=>e.data?.statistics),s=this.request(this.url+"/histograms",{query:{variable:e,f:"json"},signal:t}).then(e=>e.data?.histograms),r=await Promise.all([i,s]);return r[0]&&r[0].forEach(e=>{e.avg=e.mean,e.stddev=e.standardDeviation}),r[1]?.[0]?.counts?.length||(r[1]=null),{statistics:r[0]||null,histograms:r[1]||null}}async computeBestPyramidLevelForLocation(e,t={}){if(!this._tilemapCache)return 0;let i=this.identifyPixelLocation(e,0,t.datumTransformation);if(null===i)return null;let s=0;const{maximumPyramidLevel:r}=this.rasterInfo.storageInfo;let a=r-s+this._levelOffset;const l=i.srcLocation;for(;a>=0;){try{if("available"===await this._tilemapCache.fetchAvailability(a,i.row,i.col,t))break}catch{}if(a--,s++,i=this.identifyPixelLocation(l,s,t.datumTransformation),null===i)return null}return-1===a||null==i?null:s}async _open(e){const r=e?.signal,a=this.sourceJSON?{data:this.sourceJSON}:await this.request(this.url,{query:{f:"json"},signal:r});a.ssl&&(this.url=this.url.replace(/^http:/i,"https:"));const l=a.data;if(this.sourceJSON=l,!l)throw new t("imageserverraster:open","cannot initialize tiled image service, missing service info");if(!l.tileInfo)throw new t("imageserverraster:open","use ImageryLayer to open non-tiled image services");this._fixScaleInServiceInfo();const n=["jpg","jpeg","png","png8","png24","png32","mixed","terrainrgb","terraindem"];this.tileType=l.cacheType,null==this.tileType&&(n.includes(l.tileInfo.format.toLowerCase())?this.tileType="Map":"lerc"===l.tileInfo.format.toLowerCase()?this.tileType="Elevation":this.tileType="Raster"),this.datasetName=l.name?.slice(l.name.indexOf("/")+1)??"";const o=await this._fetchRasterInfo({signal:r});if(null==o)throw new t("image-server-raster:open","cannot initialize image service");y(o,l);const c="Map"===this.tileType?v(l.tileInfo,l):u.fromJSON(l.tileInfo);i(c);const[f,p]=this._computeMinMaxLOD(o,c),{extent:d,pixelSize:x}=o,g=.5/o.width*x.x,I=Math.max(x.x,x.y),{lods:w}=c;("Map"!==this.tileType&&0!==l.maxScale||Math.abs(x.x-x.y)>g||!w.some(e=>Math.abs(e.resolution-I)<g))&&(x.x=x.y=f.resolution,o.width=Math.ceil((d.xmax-d.xmin)/x.x-.1),o.height=Math.ceil((d.ymax-d.ymin)/x.y-.1));const b=f.level-p.level,[T,M]=c.size,j=[],_=[];w.forEach((e,t)=>{e.level>=p.level&&e.level<=f.level&&j.push({x:e.resolution,y:e.resolution}),t<w.length-1&&_.push(Math.round(10*e.resolution/w[t+1].resolution)/10)}),j.sort((e,t)=>e.x-t.x);const O=this.computeBlockBoundary(d,T,M,c.origin,j,b),R=j.length>1?j.slice(1):null;let L;l.transposeInfo&&(L={tileSize:[l.transposeInfo.rows,l.transposeInfo.cols],packetSize:o.keyProperties?._yxs.PacketSize??0});const z=_.length<=1||_.length>=3&&_.slice(0,-1).every(e=>e===_[0])?_[0]??2:Math.round(10/(p.resolution/f.resolution)**(-1/b))/10;if(o.storageInfo=new m({blockWidth:c.size[0],blockHeight:c.size[1],pyramidBlockWidth:c.size[0],pyramidBlockHeight:c.size[1],pyramidResolutions:R,pyramidScalingFactor:z,compression:c.format,origin:c.origin,firstPyramidLevel:1,maximumPyramidLevel:b,tileInfo:c,isBsqTile:!!l.bsq,transposeInfo:L,blockBoundary:O}),S(o),this._set("rasterInfo",o),l.capabilities.toLowerCase().includes("tilemap")){const e={tileInfo:o.storageInfo.tileInfo,parsedUrl:s(this.url),url:this.url,tileServers:[]};this._tilemapCache=new h({layer:e})}}async _fetchRasterInfo(e){const t=this.sourceJSON;if("Map"===this.tileType){const e=t.fullExtent||t.extent,i=Math.ceil((e.xmax-e.xmin)/t.pixelSizeX-.1),s=Math.ceil((e.ymax-e.ymin)/t.pixelSizeY-.1),r=o.fromJSON(t.spatialReference||e.spatialReference),a=new n({x:t.pixelSizeX,y:t.pixelSizeY,spatialReference:r});return new c({width:i,height:s,bandCount:3,extent:l.fromJSON(e),spatialReference:r,pixelSize:a,pixelType:"u8",statistics:null,keyProperties:{DataType:"processed"}})}const{signal:i}=e,s=x(this.url,this.sourceJSON,{signal:i,query:this.ioConfig.customFetchParameters}),r=t.hasMultidimensions?this.request(`${this.url}/slices`,{query:{f:"json"},signal:i}).then(e=>e.data?.slices).catch(()=>null):null,a=await Promise.all([s,r]);return this._slices=a[1],a[0]}_fixScaleInServiceInfo(){const{sourceJSON:e}=this;e.minScale&&e.minScale<0&&(e.minScale=0),e.maxScale&&e.maxScale<0&&(e.maxScale=0)}_computeMinMaxLOD(e,t){const{pixelSize:i}=e,s=.5/e.width*i.x,{lods:r}=t,a=t.lodAt(Math.max.apply(null,r.map(e=>e.level))),l=t.lodAt(Math.min.apply(null,r.map(e=>e.level))),{tileType:n}=this;if("Map"===n)return this._levelOffset=r[0].level,[a,l];if("Raster"===n){return[r.find(e=>e.resolution===i.x)??a,l]}const{minScale:o,maxScale:c}=this.sourceJSON;let m=a;c>0&&(m=r.find(e=>Math.abs(e.scale-c)<s),m||(m=r.filter(e=>e.scale>c).sort((e,t)=>e.scale>t.scale?1:-1)[0]??a));let u=l;return o>0&&(u=r.find(e=>Math.abs(e.scale-o)<s)??l,this._levelOffset=u.level-l.level),[m,u]}};function v(e,t){if(!e)return null;const{minScale:i,maxScale:s,minLOD:r,maxLOD:a}=t;if(null!=r&&null!=a)return u.fromJSON({...e,lods:e.lods.filter(({level:e})=>null!=e&&e>=r&&e<=a)});if(0!==i&&0!==s){const t=e=>Math.round(1e4*e)/1e4,r=i?t(i):1/0,a=s?t(s):-1/0;return u.fromJSON({...e,lods:e.lods.filter(e=>{const i=t(e.scale);return i<=r&&i>=a})})}return u.fromJSON(e)}function S(e){const{extent:t,spatialReference:i}=e;t.xmin>-1&&t.xmax>181&&i?.wkid&&i.isGeographic&&(e.nativeExtent=e.extent,e.transform=new d,e.extent=e.transform.forwardTransform(t))}e([r({type:String,json:{write:!0}})],g.prototype,"datasetFormat",void 0),e([r()],g.prototype,"tileType",void 0),g=e([a("geoscene.layers.support.rasterDatasets.ImageServerRaster")],g);const I=g;export{I as default};
|
|
5
|
+
import{__decorate as e}from"tslib";import t from"../../../core/Error.js";import{assertIsSome as i}from"../../../core/maybe.js";import{urlToObject as s}from"../../../core/urlUtils.js";import{property as r}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as a}from"../../../core/accessorSupport/decorators/subclass.js";import l from"../../../geometry/Extent.js";import n from"../../../geometry/Point.js";import o from"../../../geometry/SpatialReference.js";import c from"../RasterInfo.js";import m from"../RasterStorageInfo.js";import u from"../TileInfo.js";import{TilemapCache as h}from"../TilemapCache.js";import f from"./BaseRaster.js";import{setValidBoundary as p}from"../rasterFunctions/pixelUtils.js";import d from"../rasterTransforms/GCSShiftTransform.js";import{patchServiceInfo as y,fetchServiceRasterInfo as x}from"../../../rest/imageService/fetchRasterInfo.js";let g=class extends f{constructor(){super(...arguments),this._levelOffset=0,this._tilemapCache=null,this._slices=null,this.datasetFormat="RasterTileServer",this.tileType=null}async fetchRawTile(e,t,i,s={}){const{storageInfo:r,extent:a}=this.rasterInfo,{transposeInfo:l}=r,n=null!=l&&!!s.transposedVariableName;if(this._slices&&!n&&null==s.sliceId)return null;const o=n?0:r.maximumPyramidLevel-e+this._levelOffset,c=`${this.url}/tile/${o}/${t}/${i}`,m=this._slices?n?{variable:s.transposedVariableName}:{sliceId:s.sliceId||0}:null;let u,h;if(r.isBsqTile){const e=(s.bandIds?.length?s.bandIds:[0,1,2]).map(e=>this.request(c,{query:{...m,bandId:e},responseType:"array-buffer",signal:s.signal})),t=await Promise.all(e),i=t.map(e=>e.data.byteLength).reduce((e,t)=>e+t),r=new Uint8Array(i);h=[];let a=0;for(const{data:s}of t)h.push(a),r.set(new Uint8Array(s),a),a+=s.byteLength;u=r.buffer}else{u=(await this.request(c,{query:m,responseType:"array-buffer",signal:s.signal})).data}if(!u)return null;const f=n?l.tileSize:r.tileInfo.size,d=await this.decodePixelBlock(u,{width:f[0],height:f[1],planes:h?.length,offsets:h,pixelType:null,isPoint:"Elevation"===this.tileType,returnInterleaved:n,noDataValue:this.rasterInfo.noDataValue,useCanvas: r.tileInfo?.format === "TerrainDEM"});if(null==d)return null;const y=r.blockBoundary[e];if("jpg"!==r.compression||i>y.minCol&&i<y.maxCol&&t>y.minRow&&t<y.maxRow)return d;const{origin:x,blockWidth:g,blockHeight:v}=r,{x:S,y:I}=this.getPyramidPixelSize(e),w=Math.round((a.xmin-x.x)/S)%g,b=Math.round((a.xmax-x.x)/S)%g||g,T=Math.round((x.y-a.ymax)/I)%v,M=Math.round((x.y-a.ymin)/I)%v||v,j=i===y.minCol?w:0,_=t===y.minRow?T:0,O=i===y.maxCol?b:g,R=t===y.maxRow?M:v;return p(d,{x:j,y:_},{width:O-j,height:R-_}),d}getSliceIndex(e){if(!this._slices||null==e||0===e.length)return null;const t=e;for(let i=0;i<this._slices.length;i++){const e=this._slices[i].multidimensionalDefinition;if(e.length===t.length&&!e.some(e=>{const i=t.find(t=>e.variableName===t.variableName&&t.dimensionName===e.dimensionName);if(!i)return!0;return(Array.isArray(e.values[0])?`${e.values[0][0]}-${e.values[0][1]}`:e.values[0])!==(Array.isArray(i.values[0])?`${i.values[0][0]}-${i.values[0][1]}`:i.values[0])}))return i}return null}async fetchVariableStatisticsHistograms(e,t){const i=this.request(this.url+"/statistics",{query:{variable:e,f:"json"},signal:t}).then(e=>e.data?.statistics),s=this.request(this.url+"/histograms",{query:{variable:e,f:"json"},signal:t}).then(e=>e.data?.histograms),r=await Promise.all([i,s]);return r[0]&&r[0].forEach(e=>{e.avg=e.mean,e.stddev=e.standardDeviation}),r[1]?.[0]?.counts?.length||(r[1]=null),{statistics:r[0]||null,histograms:r[1]||null}}async computeBestPyramidLevelForLocation(e,t={}){if(!this._tilemapCache)return 0;let i=this.identifyPixelLocation(e,0,t.datumTransformation);if(null===i)return null;let s=0;const{maximumPyramidLevel:r}=this.rasterInfo.storageInfo;let a=r-s+this._levelOffset;const l=i.srcLocation;for(;a>=0;){try{if("available"===await this._tilemapCache.fetchAvailability(a,i.row,i.col,t))break}catch{}if(a--,s++,i=this.identifyPixelLocation(l,s,t.datumTransformation),null===i)return null}return-1===a||null==i?null:s}async _open(e){const r=e?.signal,a=this.sourceJSON?{data:this.sourceJSON}:await this.request(this.url,{query:{f:"json"},signal:r});a.ssl&&(this.url=this.url.replace(/^http:/i,"https:"));const l=a.data;if(this.sourceJSON=l,!l)throw new t("imageserverraster:open","cannot initialize tiled image service, missing service info");if(!l.tileInfo)throw new t("imageserverraster:open","use ImageryLayer to open non-tiled image services");this._fixScaleInServiceInfo();const n=["jpg","jpeg","png","png8","png24","png32","mixed","terrainrgb","terraindem"];this.tileType=l.cacheType,null==this.tileType&&(n.includes(l.tileInfo.format.toLowerCase())?this.tileType="Map":"lerc"===l.tileInfo.format.toLowerCase()?this.tileType="Elevation":this.tileType="Raster"),this.datasetName=l.name?.slice(l.name.indexOf("/")+1)??"";const o=await this._fetchRasterInfo({signal:r});if(null==o)throw new t("image-server-raster:open","cannot initialize image service");y(o,l);const c="Map"===this.tileType?v(l.tileInfo,l):u.fromJSON(l.tileInfo);i(c);const[f,p]=this._computeMinMaxLOD(o,c),{extent:d,pixelSize:x}=o,g=.5/o.width*x.x,I=Math.max(x.x,x.y),{lods:w}=c;("Map"!==this.tileType&&0!==l.maxScale||Math.abs(x.x-x.y)>g||!w.some(e=>Math.abs(e.resolution-I)<g))&&(x.x=x.y=f.resolution,o.width=Math.ceil((d.xmax-d.xmin)/x.x-.1),o.height=Math.ceil((d.ymax-d.ymin)/x.y-.1));const b=f.level-p.level,[T,M]=c.size,j=[],_=[];w.forEach((e,t)=>{e.level>=p.level&&e.level<=f.level&&j.push({x:e.resolution,y:e.resolution}),t<w.length-1&&_.push(Math.round(10*e.resolution/w[t+1].resolution)/10)}),j.sort((e,t)=>e.x-t.x);const O=this.computeBlockBoundary(d,T,M,c.origin,j,b),R=j.length>1?j.slice(1):null;let L;l.transposeInfo&&(L={tileSize:[l.transposeInfo.rows,l.transposeInfo.cols],packetSize:o.keyProperties?._yxs.PacketSize??0});const z=_.length<=1||_.length>=3&&_.slice(0,-1).every(e=>e===_[0])?_[0]??2:Math.round(10/(p.resolution/f.resolution)**(-1/b))/10;if(o.storageInfo=new m({blockWidth:c.size[0],blockHeight:c.size[1],pyramidBlockWidth:c.size[0],pyramidBlockHeight:c.size[1],pyramidResolutions:R,pyramidScalingFactor:z,compression:c.format,origin:c.origin,firstPyramidLevel:1,maximumPyramidLevel:b,tileInfo:c,isBsqTile:!!l.bsq,transposeInfo:L,blockBoundary:O}),S(o),this._set("rasterInfo",o),l.capabilities.toLowerCase().includes("tilemap")){const e={tileInfo:o.storageInfo.tileInfo,parsedUrl:s(this.url),url:this.url,tileServers:[]};this._tilemapCache=new h({layer:e})}}async _fetchRasterInfo(e){const t=this.sourceJSON;if("Map"===this.tileType){const e=t.fullExtent||t.extent,i=Math.ceil((e.xmax-e.xmin)/t.pixelSizeX-.1),s=Math.ceil((e.ymax-e.ymin)/t.pixelSizeY-.1),r=o.fromJSON(t.spatialReference||e.spatialReference),a=new n({x:t.pixelSizeX,y:t.pixelSizeY,spatialReference:r});return new c({width:i,height:s,bandCount:3,extent:l.fromJSON(e),spatialReference:r,pixelSize:a,pixelType:"u8",statistics:null,keyProperties:{DataType:"processed"}})}const{signal:i}=e,s=x(this.url,this.sourceJSON,{signal:i,query:this.ioConfig.customFetchParameters}),r=t.hasMultidimensions?this.request(`${this.url}/slices`,{query:{f:"json"},signal:i}).then(e=>e.data?.slices).catch(()=>null):null,a=await Promise.all([s,r]);return this._slices=a[1],a[0]}_fixScaleInServiceInfo(){const{sourceJSON:e}=this;e.minScale&&e.minScale<0&&(e.minScale=0),e.maxScale&&e.maxScale<0&&(e.maxScale=0)}_computeMinMaxLOD(e,t){const{pixelSize:i}=e,s=.5/e.width*i.x,{lods:r}=t,a=t.lodAt(Math.max.apply(null,r.map(e=>e.level))),l=t.lodAt(Math.min.apply(null,r.map(e=>e.level))),{tileType:n}=this;if("Map"===n)return this._levelOffset=r[0].level,[a,l];if("Raster"===n){return[r.find(e=>e.resolution===i.x)??a,l]}const{minScale:o,maxScale:c}=this.sourceJSON;let m=a;c>0&&(m=r.find(e=>Math.abs(e.scale-c)<s),m||(m=r.filter(e=>e.scale>c).sort((e,t)=>e.scale>t.scale?1:-1)[0]??a));let u=l;return o>0&&(u=r.find(e=>Math.abs(e.scale-o)<s)??l,this._levelOffset=u.level-l.level),[m,u]}};function v(e,t){if(!e)return null;const{minScale:i,maxScale:s,minLOD:r,maxLOD:a}=t;if(null!=r&&null!=a)return u.fromJSON({...e,lods:e.lods.filter(({level:e})=>null!=e&&e>=r&&e<=a)});if(0!==i&&0!==s){const t=e=>Math.round(1e4*e)/1e4,r=i?t(i):1/0,a=s?t(s):-1/0;return u.fromJSON({...e,lods:e.lods.filter(e=>{const i=t(e.scale);return i<=r&&i>=a})})}return u.fromJSON(e)}function S(e){const{extent:t,spatialReference:i}=e;t.xmin>-1&&t.xmax>181&&i?.wkid&&i.isGeographic&&(e.nativeExtent=e.extent,e.transform=new d,e.extent=e.transform.forwardTransform(t))}e([r({type:String,json:{write:!0}})],g.prototype,"datasetFormat",void 0),e([r()],g.prototype,"tileType",void 0),g=e([a("geoscene.layers.support.rasterDatasets.ImageServerRaster")],g);const I=g;export{I as default};
|
|
@@ -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{isAborted as e,createAbortError as a}from"../../../core/promiseUtils.js";import{Z as n}from"../../../chunks/Zlib.js";class i{constructor(t){this._canvas=null,this._ctx=null,t&&(this._canvas=t.canvas,this._ctx=t.ctx||t.canvas&&t.canvas.getContext("2d"))}decode(n,s,r){if(!n||n.byteLength<10)throw new t("imagecanvasdecoder: decode","required a valid encoded data as input.");let{width:c=0,height:h=0,format:o}=s;const{applyJpegMask:l}=s;if(l&&(!c||!h))throw new t("imagecanvasdecoder: decode","image width and height are needed to apply jpeg mask directly to canvas");return new Promise((t,d)=>{let g=null;"jpg"===o&&l&&(g=i._getMask(n,{width:c,height:h}));const w=new Blob([new Uint8Array(n)],{type:"image/"+o=="jpg"?"jpeg":o}),v=URL.createObjectURL(w),m=new Image;let _;m.src=v,m.onload=()=>{if(URL.revokeObjectURL(v),e(r))return void d(a());c=m.width,h=m.height,this._canvas&&this._ctx?(this._canvas.width===c&&this._canvas.height===h||(this._canvas.width=c,this._canvas.height=h),this._ctx.clearRect(0,0,c,h)):(this._canvas=document.createElement("canvas"),this._canvas.width=c,this._canvas.height=h,this._ctx=this._canvas.getContext("2d")),this._ctx.drawImage(m,0,0);const n=this._ctx.getImageData(0,0,c,h);let i;if(_=n.data,s.renderOnCanvas){if(g)for(i=0;i<g.length;i++)g[i]?_[4*i+3]=255:_[4*i+3]=0;return this._ctx.putImageData(n,0,0),void t(null)}const o=c*h,l=new Uint8Array(o),w=new Uint8Array(o),p=new Uint8Array(o);if(g)for(i=0;i<o;i++)l[i]=_[4*i],w[i]=_[4*i+1],p[i]=_[4*i+2];else for(g=new Uint8Array(o),i=0;i<o;i++)l[i]=_[4*i],w[i]=_[4*i+1],p[i]=_[4*i+2],g[i]=_[4*i+3];t({width:c,height:h,pixels:[l,w,p],mask:g,pixelType:"u8"})},m.onerror=()=>{URL.revokeObjectURL(v),d("cannot load image")}})}static _getMask(t,e){let a=null;try{const i=new Uint8Array(t),s=Math.ceil(i.length/2);let r=0;const c=i.length-2;for(r=s;r<c&&(255!==i[r]||217!==i[r+1]);r++);if(r+=2,r<i.length-1){const t=new n(i.subarray(r)).getBytes();a=new Uint8Array(e.width*e.height);let s=0;for(let e=0;e<t.length;e++)for(let n=7;n>=0;n--)a[s++]=t[e]>>n&1}}catch(i){}return a}}export{i as default};
|
|
5
|
+
import t from"../../../core/Error.js";import{isAborted as e,createAbortError as a}from"../../../core/promiseUtils.js";import{Z as n}from"../../../chunks/Zlib.js";class i{constructor(t){this._canvas=null,this._ctx=null,t&&(this._canvas=t.canvas,this._ctx=t.ctx||t.canvas&&t.canvas.getContext("2d"))}decode(n,s,r){if(!n||n.byteLength<10)throw new t("imagecanvasdecoder: decode","required a valid encoded data as input.");let{width:c=0,height:h=0,format:o}=s;const{applyJpegMask:l}=s;if(l&&(!c||!h))throw new t("imagecanvasdecoder: decode","image width and height are needed to apply jpeg mask directly to canvas");return new Promise((t,d)=>{let g=null;"jpg"===o&&l&&(g=i._getMask(n,{width:c,height:h}));const w=new Blob([new Uint8Array(n)],{type:"image/"+o=="jpg"?"jpeg":o}),v=URL.createObjectURL(w),m=new Image;let _;o==="webp"&&(m.width=c,m.height=h),m.src=v,m.onload=()=>{if(URL.revokeObjectURL(v),e(r))return void d(a());c=m.width,h=m.height,this._canvas&&this._ctx?(this._canvas.width===c&&this._canvas.height===h||(this._canvas.width=c,this._canvas.height=h),this._ctx.clearRect(0,0,c,h)):(this._canvas=document.createElement("canvas"),this._canvas.width=c,this._canvas.height=h,this._ctx=this._canvas.getContext("2d")),this._ctx.drawImage(m,0,0);const n=this._ctx.getImageData(0,0,c,h);let i;if(_=n.data,s.renderOnCanvas){if(g)for(i=0;i<g.length;i++)g[i]?_[4*i+3]=255:_[4*i+3]=0;return this._ctx.putImageData(n,0,0),void t(null)}const o=c*h,l=new Uint8Array(o),w=new Uint8Array(o),p=new Uint8Array(o);if(g)for(i=0;i<o;i++)l[i]=_[4*i],w[i]=_[4*i+1],p[i]=_[4*i+2];else for(g=new Uint8Array(o),i=0;i<o;i++)l[i]=_[4*i],w[i]=_[4*i+1],p[i]=_[4*i+2],g[i]=_[4*i+3];t({width:c,height:h,pixels:[l,w,p],mask:g,pixelType:"u8"})},m.onerror=()=>{URL.revokeObjectURL(v),d("cannot load image")}})}static _getMask(t,e){let a=null;try{const i=new Uint8Array(t),s=Math.ceil(i.length/2);let r=0;const c=i.length-2;for(r=s;r<c&&(255!==i[r]||217!==i[r+1]);r++);if(r+=2,r<i.length-1){const t=new n(i.subarray(r)).getBytes();a=new Uint8Array(e.width*e.height);let s=0;for(let e=0;e<t.length;e++)for(let n=7;n>=0;n--)a[s++]=t[e]>>n&1}}catch(i){}return a}}export{i as default};
|