UNPKG

@doegis/core

Version:

DOE GIS API

3 lines (1 loc) 9.5 kB
import{_ as e}from"../../../chunks/tslib.es6.js";import"../../../geometry.js";import"../../../Graphic.js";import"../../../renderers/ClassBreaksRenderer.js";import"../../../renderers/DictionaryRenderer.js";import"../../../renderers/DotDensityRenderer.js";import"../../../renderers/HeatmapRenderer.js";import"../../../renderers/PieChartRenderer.js";import"../../../renderers/Renderer.js";import"../../../renderers/SimpleRenderer.js";import"../../../renderers/UniqueValueRenderer.js";import"../../../renderers/support/jsonUtils.js";import"../../../symbols.js";import t from"../../../core/Collection.js";import"../../../core/has.js";import r from"../../../core/Logger.js";import{getOrCreateMapValue as s}from"../../../core/MapUtils.js";import{isSome as i,isNone as n}from"../../../core/maybe.js";import{isAbortError as o}from"../../../core/promiseUtils.js";import{on as l}from"../../../core/reactiveUtils.js";import{property as a}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import"../../../core/arrayUtils.js";import{subclass as m}from"../../../core/accessorSupport/decorators/subclass.js";import{create as p}from"../../../geometry/support/aaBoundingRect.js";import{ringsContainsCoords as c}from"../../../geometry/support/contains.js";import{extentIntersectsPolygon as h}from"../../../geometry/support/intersectsBase.js";import{MediaElementView as u}from"../../../layers/support/MediaElementView.js";import"../../../core/Error.js";import"../../../core/scheduling.js";import"../../../request.js";import"../../../chunks/index2.js";import"../../../core/urlUtils.js";import"../../../chunks/index3.js";import"../../../layers/effects/EffectView.js";import"../engine/DisplayObject.js";import"../engine/webgl/effects/highlight/HighlightGradient.js";import"../engine/webgl/BufferPool.js";import"../engine/webgl/enums.js";import"../engine/webgl/brushes/BrushBitmap.js";import"../../../chunks/vec4f32.js";import"../engine/webgl/Utils.js";import"../engine/webgl/shaders/BackgroundPrograms.js";import"../../webgl/enums.js";import"../../webgl/checkWebGLError.js";import"../../webgl/context-util.js";import"../../../chunks/builtins.js";import"../../../core/RandomLCG.js";import"../engine/webgl/materialKey/MaterialKey.js";import"../engine/webgl/techniques/Technique.js";import"../engine/webgl/techniques/dotDensity/TechniqueDotDensity.js";import"../engine/webgl/techniques/heatmap/TechniqueHeatmap.js";import"../engine/webgl/techniques/pieChart/TechniquePieChart.js";import"../../webgl/BufferObject.js";import"../../webgl/FramebufferObject.js";import"../../webgl/Texture.js";import"../../webgl/VertexArrayObject.js";import"../engine/webgl/brushes/WGLBrushHeatmap.js";import"../engine/webgl/DefaultVertexAttributeLayouts.js";import"../engine/webgl/shaders/TileInfoPrograms.js";import"../engine/webgl/brushes/WGLGeometryBrushMarker.js";import"../../../core/mathUtils.js";import"../engine/webgl/number.js";import"../engine/vectorTiles/style/StyleDefinition.js";import"../../../chunks/vec2f32.js";import"../engine/vectorTiles/enums.js";import"../engine/vectorTiles/shaders/sources/resolver.js";import"../engine/webgl/shaders/BitBlitPrograms.js";import"../engine/webgl/shaders/sources/resolver.js";import"../engine/webgl/TextureManager.js";import"../engine/webgl/shaders/StencilPrograms.js";import"../engine/webgl/effects/BlendEffect.js";import"../engine/webgl/shaders/HighlightPrograms.js";import"../engine/webgl/Profiler.js";import"../../webgl/renderState.js";import"../../3d/webgl-engine/core/shaderModules/interfaces.js";import"../../../core/floatRGBA.js";import"../../3d/webgl-engine/lib/OrderIndependentTransparency.js";import"../../../chunks/webgl-debug.js";import"../LabelManager.js";import"./graphics/GraphicsView2D.js";import"../engine/webgl/AttributeStoreView.js";import"../../../chunks/earcut.js";import"../../../layers/graphics/featureConversionUtils.js";import"../../../core/unitUtils.js";import"../../../renderers/support/lengthUtils.js";import"../../../chunks/vec3f32.js";import"../../../geometry/support/normalizeUtils.js";import"../navigation/MapViewNavigation.js";import"../../../core/asyncUtils.js";import"../engine/webgl/shaders/MagnifierPrograms.js";import"../tiling/PagedTileQueue.js";import"../tiling/TileInfoView.js";import"../tiling/TileKey.js";import d from"../tiling/TileQueue.js";import g from"../tiling/TileStrategy.js";import f from"../engine/webgl/Overlay.js";import j from"../engine/webgl/OverlayContainer.js";import{LayerView2DMixin as y}from"./LayerView2D.js";import w from"../../layers/LayerView.js";import b from"../../../geometry/Extent.js";let _=class extends(y(w)){constructor(){super(...arguments),this._overlayContainer=null,this._fetchQueue=null,this._tileStrategy=null,this._elementReferences=new Map,this._debugGraphicsView=null,this.layer=null,this.elements=new t}attach(){this.addAttachHandles([l((()=>this.layer.effectiveSource),"refresh",(()=>{for(const e of this._tileStrategy.tiles)this._updateTile(e);this.requestUpdate()})),l((()=>this.layer.effectiveSource),"change",(({element:e})=>this._elementUpdateHandler(e)))]),this._overlayContainer=new j,this.container.addChild(this._overlayContainer),this._fetchQueue=new d({tileInfoView:this.view.featuresTilingScheme,concurrency:10,process:(e,t)=>this._queryElements(e,t)}),this._tileStrategy=new g({cachePolicy:"purge",resampling:!0,acquireTile:e=>this._acquireTile(e),releaseTile:e=>this._releaseTile(e),tileInfoView:this.view.featuresTilingScheme}),this.requestUpdate()}detach(){this.elements.removeAll(),this._tileStrategy.destroy(),this._fetchQueue.destroy(),this._overlayContainer.removeAllChildren(),this.container.removeAllChildren(),this._elementReferences.clear(),this._debugGraphicsView?.destroy()}supportsSpatialReference(e){return!0}moveStart(){this.requestUpdate()}viewChange(){this.requestUpdate()}moveEnd(){this.requestUpdate()}update(e){this._tileStrategy.update(e),this._debugGraphicsView?.update(e)}async hitTest(e,t){const r=[],s=e.normalize(),n=[s.x,s.y];for(const{projectedElement:{normalizedCoords:o,element:l}}of this._elementReferences.values())i(o)&&c(o.rings,n)&&r.push({type:"media",element:l,layer:this.layer,mapPoint:e});return r.reverse()}canResume(){return null!=this.layer.source&&super.canResume()}async doRefresh(){this._fetchQueue.reset(),this._tileStrategy.tiles.forEach((e=>this._updateTile(e)))}_acquireTile(e){const t=new E(e.clone());return this._updateTile(t),t}_updateTile(e){this.updatingHandles.addPromise(this._fetchQueue.push(e.key).then((t=>{const[r,s]=e.setElements(t);this._referenceElements(e,r),this._dereferenceElements(e,s),this.requestUpdate()}),(e=>{o(e)||r.getLogger(this.declaredClass).error(e)})))}_releaseTile(e){this._fetchQueue.abort(e.key.id),e.elements&&this._dereferenceElements(e,e.elements),this.requestUpdate()}async _queryElements(e,t){const r=this.layer.effectiveSource;if(n(r))return[];this.view.featuresTilingScheme.getTileBounds(v,e,!0);const s=new b({xmin:v[0],ymin:v[1],xmax:v[2],ymax:v[3],spatialReference:this.view.spatialReference});return r.queryElements(s,t)}_referenceElements(e,t){const r=this.layer.source;if(!n(r))for(const s of t)this._referenceElement(e,s)}_referenceElement(e,t){s(this._elementReferences,t.uid,(()=>{const e=new u({element:t,spatialReference:this.view.spatialReference}),r=new f(e);this._overlayContainer.addChild(r),this.elements.add(t);let s=null;return{tiles:new Set,projectedElement:e,overlay:r,debugGraphic:s}})).tiles.add(e)}_dereferenceElements(e,t){for(const r of t)this._dereferenceElement(e,r)}_dereferenceElement(e,t){const r=this._elementReferences.get(t.uid);r.tiles.delete(e),r.tiles.size||(this._overlayContainer.removeChild(r.overlay),r.overlay.destroy(),r.projectedElement.destroy(),this._elementReferences.delete(t.uid),this.elements.remove(t),this._debugGraphicsView?.graphics.remove(r.debugGraphic))}_elementUpdateHandler(e){let t=this._elementReferences.get(e.uid);if(t){const r=t.projectedElement.normalizedCoords;if(n(r))return this._overlayContainer.removeChild(t.overlay),t.overlay.destroy(),t.projectedElement.destroy(),this._elementReferences.delete(e.uid),this.elements.remove(e),void this._debugGraphicsView?.graphics.remove(t.debugGraphic);const s=[],i=[];for(const e of this._tileStrategy.tiles){const n=R(this.view.featuresTilingScheme,e,r);t.tiles.has(e)?n||i.push(e):n&&s.push(e)}for(const t of s)this._referenceElement(t,e);for(const t of i)this._dereferenceElement(t,e);return t=this._elementReferences.get(e.uid),void(t?.debugGraphic&&(t.debugGraphic.geometry=t.projectedElement.normalizedCoords,this._debugGraphicsView.graphicUpdateHandler({graphic:t.debugGraphic,property:"geometry"})))}const r=new u({element:e,spatialReference:this.view.spatialReference}).normalizedCoords;if(i(r))for(const s of this._tileStrategy.tiles){R(this.view.featuresTilingScheme,s,r)&&this._referenceElement(s,e)}}};e([a()],_.prototype,"_fetchQueue",void 0),e([a()],_.prototype,"layer",void 0),e([a({readOnly:!0})],_.prototype,"elements",void 0),_=e([m("esri.views.2d.layers.MediaLayerView2D")],_);const v=p(),T={xmin:0,ymin:0,xmax:0,ymax:0};function R(e,t,r){return e.getTileBounds(v,t.key,!0),T.xmin=v[0],T.ymin=v[1],T.xmax=v[2],T.ymax=v[3],h(T,r)}class E{constructor(e){this.key=e,this.elements=null,this.isReady=!1,this.visible=!0}setElements(e){const t=[],r=new Set(this.elements);this.elements=e;for(const s of e)r.has(s)?r.delete(s):t.push(s);return this.isReady=!0,[t,Array.from(r)]}destroy(){}}const S=_;export{S as default};