@arcgis/core 5.2.0-next.163 → 5.2.0-next.165
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/Graphic.d.ts +47 -14
- package/PopupTemplate.js +1 -1
- package/WebScene.d.ts +3 -0
- package/analysis/LineOfSightAnalysis.d.ts +1 -1
- package/analysis/LineOfSightAnalysisObserver.d.ts +5 -4
- package/analysis/LineOfSightAnalysisTarget.d.ts +4 -4
- package/analysis/Viewshed.d.ts +4 -4
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/{97d6ef9e34a43ad2e556.js → 02e10f44edf911832c2a.js} +1 -1
- package/assets/esri/core/workers/chunks/{97b5f4302fb867c829f4.js → 07f7177bfaf9de73bc25.js} +1 -1
- package/assets/esri/core/workers/chunks/{612345f17f5eeb99ea8f.js → 0d9c4c6c571ce26d356b.js} +1 -1
- package/assets/esri/core/workers/chunks/{8e19629899a5becf8e19.js → 150e7a7bd5df25693da7.js} +1 -1
- package/assets/esri/core/workers/chunks/{12a7997a40c77f5c9160.js → 151e5799ede763a03ee2.js} +1 -1
- package/assets/esri/core/workers/chunks/196979cc6a765be3c5cd.js +1 -0
- package/assets/esri/core/workers/chunks/1ab59a97ffa49e9e1659.js +1 -0
- package/assets/esri/core/workers/chunks/{8715661a838361d4211a.js → 1b24a40c0fa197014873.js} +1 -1
- package/assets/esri/core/workers/chunks/{83f29a159b8b5197e76a.js → 266c90d8d56a2da42fcf.js} +1 -1
- package/assets/esri/core/workers/chunks/{b1d989b72203113a06fe.js → 2a36fe3f3f257a779a1b.js} +1 -1
- package/assets/esri/core/workers/chunks/{fcaf9450642fcef83286.js → 3048e74e6246324ce6fc.js} +1 -1
- package/assets/esri/core/workers/chunks/{95b82cbbe355266c65d7.js → 30af63b3b750142faadb.js} +1 -1
- package/assets/esri/core/workers/chunks/{74137ffec5265628c33b.js → 36c780a9527c75b36725.js} +1 -1
- package/assets/esri/core/workers/chunks/{6a0ec102962d2c7b4368.js → 40d803584eeade4df433.js} +1 -1
- package/assets/esri/core/workers/chunks/{a546ec82ba149e12f7bf.js → 41773d858e212468db88.js} +1 -1
- package/assets/esri/core/workers/chunks/{129e04d24ced77c9bb6d.js → 49b967d89d2841cea675.js} +1 -1
- package/assets/esri/core/workers/chunks/{b59aaf30c7fe2c8d1aaa.js → 4b99b4cf729881e616bc.js} +1 -1
- package/assets/esri/core/workers/chunks/{2e096537a3a5555a4a93.js → 4cb751dc8d00bdaeb04c.js} +1 -1
- package/assets/esri/core/workers/chunks/{a09d2e1e2540921e4717.js → 4d3d7ec407ee5cd5f036.js} +1 -1
- package/assets/esri/core/workers/chunks/{85bba551057366cd00ae.js → 4db829a0238024736fe6.js} +1 -1
- package/assets/esri/core/workers/chunks/{2c626f525f3483c03477.js → 548b8f74a6883e364931.js} +1 -1
- package/assets/esri/core/workers/chunks/{25a3bd8bede2d07d3a54.js → 5af8fb4ec2c72697e35b.js} +1 -1
- package/assets/esri/core/workers/chunks/{340256866f524cb069f6.js → 5d2f043ebe1051326c56.js} +1 -1
- package/assets/esri/core/workers/chunks/{3f46acfda693c70abbdd.js → 61552b4b8111a8624d84.js} +1 -1
- package/assets/esri/core/workers/chunks/{e653c81ffb3d818645dd.js → 632fdf1d95ad69109427.js} +1 -1
- package/assets/esri/core/workers/chunks/{434a8ba841a59e0deab9.js → 67e533748435253aaba6.js} +1 -1
- package/assets/esri/core/workers/chunks/69d5f8ef78b9b8b3d33d.js +1 -0
- package/assets/esri/core/workers/chunks/{feb41abc03d677df6f73.js → 6b9961261241fdce0e94.js} +1 -1
- package/assets/esri/core/workers/chunks/6f897b4e7ddd1dd1672b.js +1 -0
- package/assets/esri/core/workers/chunks/{8aa80b892fde552577e8.js → 700b1d5bc67b7e1b3ff3.js} +1 -1
- package/assets/esri/core/workers/chunks/{e251921bc5367258c4d2.js → 710b8251a59884aee31e.js} +1 -1
- package/assets/esri/core/workers/chunks/{f528ac5c648ca6a98582.js → 711cfb84659cb4437679.js} +1 -1
- package/assets/esri/core/workers/chunks/{af349c7bc8ef41a0e1bd.js → 7748c2886d0122b40eeb.js} +1 -1
- package/assets/esri/core/workers/chunks/{8a7b02037151767542f1.js → 7dbf4c7480bf9c72820d.js} +1 -1
- package/assets/esri/core/workers/chunks/{1bca39e0e651426bdbb5.js → 7dfbc31f3b56728485a4.js} +1 -1
- package/assets/esri/core/workers/chunks/{c19f238b55ff2893f7c2.js → 82a022cc21364c9a8539.js} +1 -1
- package/assets/esri/core/workers/chunks/{5cb26bbaa08114aec5ce.js → 89cc1a5539b82fb46216.js} +1 -1
- package/assets/esri/core/workers/chunks/{8ab57cb1bfd3dc8d3c2a.js → 8b8118ab56cc808b5a71.js} +1 -1
- package/assets/esri/core/workers/chunks/{542e5640ea1b80ef801a.js → 9189dfe19a2a2ccd5173.js} +1 -1
- package/assets/esri/core/workers/chunks/{f74ae0eff3f08978e607.js → 9f358c7b052cdc0ac06f.js} +1 -1
- package/assets/esri/core/workers/chunks/{ee08ae5b73439a1ff666.js → a163c6005aba3378edaa.js} +1 -1
- package/assets/esri/core/workers/chunks/{ec9a2425b4a498054a19.js → a17673e691ced46a90d3.js} +1 -1
- package/assets/esri/core/workers/chunks/{72bd866df89b8d92e247.js → a43b33955aa78a2a8deb.js} +1 -1
- package/assets/esri/core/workers/chunks/{46c5371c7a627537098c.js → a88f346786b04bd194dc.js} +6 -6
- package/assets/esri/core/workers/chunks/{092e311cb7aea92a6a26.js → acb265a22be5e12f38e5.js} +1 -1
- package/assets/esri/core/workers/chunks/ad96132bc89671e595f3.js +1 -0
- package/assets/esri/core/workers/chunks/{9e8f012a56237fc8285f.js → aea44253c80493ef5755.js} +1 -1
- package/assets/esri/core/workers/chunks/b5b9d42e1f84ee82429c.js +1 -0
- package/assets/esri/core/workers/chunks/c046c4fc934bc6f54c69.js +1 -0
- package/assets/esri/core/workers/chunks/{c72a904e01dc8c17d992.js → c47d095434d09b5f10c6.js} +1 -1
- package/assets/esri/core/workers/chunks/c4b7111dcedd9d6e1c2a.js +1 -0
- package/assets/esri/core/workers/chunks/{81cad8d2f62a5f671c55.js → cb4db5489388559d6bd9.js} +1 -1
- package/assets/esri/core/workers/chunks/{bbd44ac63d2a317d8ed9.js → cc794bb94ebc1cb66024.js} +1 -1
- package/assets/esri/core/workers/chunks/{be308db5b61a7246edfe.js → cc94bf05b235e65291fc.js} +1 -1
- package/assets/esri/core/workers/chunks/d4af9faa5d901274fad2.js +1 -0
- package/assets/esri/core/workers/chunks/d77c68e0fc3b259bf4f9.js +1 -0
- package/assets/esri/core/workers/chunks/{fc5a36e54929e03efa86.js → dba5f44c4e4a3f075df2.js} +1 -1
- package/assets/esri/core/workers/chunks/{1f43e06dcfe56229bb0f.js → debe45e792212682b304.js} +1 -1
- package/assets/esri/core/workers/chunks/{8414ffd937c1099e0bbc.js → e6d10136bc08aef255ff.js} +1 -1
- package/assets/esri/core/workers/chunks/{45fd2b456a6997584ca1.js → f8379cd45f750f28a3d8.js} +1 -1
- package/assets/esri/core/workers/chunks/{709e019885822b1f6f3e.js → f905f1a1aa4c123cbe83.js} +1 -1
- package/assets/esri/core/workers/chunks/{a2fcbc494333376192aa.js → f9c80e9fc349db4873e8.js} +1 -1
- package/assets/esri/core/workers/chunks/{e0351753f6b4d1adf11e.js → fc0dbb588a4062615cb6.js} +1 -1
- package/assets/esri/core/workers/chunks/feb4f8c807bb0dca488f.js +1 -0
- package/assets/esri/layers/raster/formats/lerc-wasm.wasm +0 -0
- package/chunks/GlobalIllumination.glsl.js +17 -47
- package/config.js +1 -1
- package/core/workers/WorkerFallback.js +4 -2
- package/core/workers/workerFactory.js +1 -1
- package/core/workers/workers.js +4 -2
- package/form/elements/inputs.d.ts +126 -25
- package/form/elements/inputs.js +1 -1
- package/form/elements.d.ts +1 -0
- package/geometry/support/clipRay.js +1 -1
- package/geometry/support/plane.js +1 -1
- package/graphic/AnnotationFeatureGraphicOrigin.d.ts +49 -9
- package/graphic/BuildingGraphicOrigin.d.ts +49 -0
- package/graphic/CSVGraphicOrigin.d.ts +42 -9
- package/graphic/CatalogGraphicOrigin.d.ts +42 -9
- package/graphic/DimensionFeatureGraphicOrigin.d.ts +42 -9
- package/graphic/FeatureGraphicOrigin.d.ts +42 -9
- package/graphic/GeoJSONGraphicOrigin.d.ts +42 -9
- package/graphic/GeoRSSGraphicOrigin.d.ts +42 -9
- package/graphic/GraphicOrigin.d.ts +52 -12
- package/graphic/ImageryGraphicOrigin.d.ts +42 -9
- package/graphic/ImageryTileGraphicOrigin.d.ts +42 -9
- package/graphic/KMLGraphicOrigin.d.ts +47 -10
- package/graphic/KnowledgeGraphGraphicOrigin.d.ts +49 -1
- package/graphic/LinkChartGraphicOrigin.d.ts +49 -1
- package/graphic/MapImageGraphicOrigin.d.ts +49 -1
- package/graphic/MapNotesGraphicOrigin.d.ts +48 -1
- package/graphic/OGCFeatureGraphicOrigin.d.ts +42 -9
- package/graphic/OrientedImageryGraphicOrigin.d.ts +42 -9
- package/graphic/ParquetGraphicOrigin.d.ts +42 -9
- package/graphic/PointCloudGraphicOrigin.d.ts +43 -0
- package/graphic/SceneGraphicOrigin.d.ts +43 -0
- package/graphic/SketchGraphicOrigin.d.ts +43 -0
- package/graphic/StreamGraphicOrigin.d.ts +43 -0
- package/graphic/SubtypeGroupGraphicOrigin.d.ts +49 -1
- package/graphic/TileGraphicOrigin.d.ts +49 -1
- package/graphic/VectorTileGraphicOrigin.d.ts +43 -14
- package/graphic/VoxelGraphicOrigin.d.ts +43 -0
- package/graphic/WCSGraphicOrigin.d.ts +43 -0
- package/graphic/WFSGraphicOrigin.d.ts +42 -9
- package/graphic/getGraphicOriginTitle.d.ts +21 -3
- package/kernel.js +1 -1
- package/layers/GaussianSplatLayer.d.ts +2 -1
- package/layers/GeoJSONLayer.d.ts +2 -107
- package/layers/ParquetLayer.d.ts +24 -1
- package/layers/ParquetLayer.js +1 -1
- package/layers/SceneLayer.d.ts +40 -16
- package/layers/ViewshedLayer.d.ts +10 -4
- package/layers/WMSLayer.d.ts +2 -69
- package/layers/mixins/ReloadableLayer.js +1 -1
- package/layers/mixins/SublayersOwner.js +1 -1
- package/layers/mixins/TemporalLayer.d.ts +70 -48
- package/layers/mixins/TiledImagery.d.ts +0 -11
- package/layers/orientedImagery/transformations/utils.js +1 -1
- package/layers/save/featureLayerUtils.js +1 -1
- package/layers/save/imageryUtils.js +1 -1
- package/layers/save/mapImageLayerUtils.js +1 -1
- package/layers/save/mediaLayerUtils.js +1 -1
- package/layers/save/parquetLayerUtils.js +2 -0
- package/layers/save/streamLayerUtils.js +1 -1
- package/layers/support/LabelClass.d.ts +8 -2
- package/layers/support/Sublayer.js +1 -1
- package/layers/support/SubtypeSublayer.js +1 -1
- package/layers/support/layerUtils.js +1 -1
- package/layers/support/layersMapping.js +1 -1
- package/package.json +2 -2
- package/popup/content.d.ts +38 -1
- package/popup/content.js +1 -1
- package/portal/schemas/definitions.js +1 -1
- package/portal/schemas/webScene.js +1 -1
- package/smartMapping/popup/support/clusterUtils.js +1 -1
- package/smartMapping/popup/support/utils.js +2 -2
- package/smartMapping/renderers/size.js +1 -1
- package/smartMapping/renderers/support/regenerateUtils.js +1 -1
- package/support/timeUtils.d.ts +11 -0
- package/symbols/cim/CIMCursor.js +1 -1
- package/tables/elements.d.ts +1 -0
- package/views/2d/engine/webgl/GlyphWorker.js +1 -1
- package/views/2d/engine/webgl/SpriteMosaic.js +1 -1
- package/views/2d/engine/webgl/animations/instructions.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/animated/AnimatedMarkerMeshWriter.js +1 -1
- package/views/3d/environment/SunLighting.d.ts +0 -1
- package/views/3d/environment/SunLighting.js +1 -1
- package/views/3d/environment/VirtualLighting.d.ts +0 -1
- package/views/3d/environment/VirtualLighting.js +1 -1
- package/views/3d/layers/support/featureTileQuery3D.js +1 -1
- package/views/3d/state/helpers/SceneIntersectionHelper.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/shading/EvaluateSceneLighting.glsl.js +5 -5
- package/views/3d/webgl-engine/effects/globalIllumination/GlobalIllumination.glsl.js +1 -1
- package/views/3d/webgl-engine/effects/globalIllumination/GlobalIllumination.js +1 -1
- package/views/3d/webgl-engine/effects/globalIllumination/GlobalIlluminationTechniqueConfiguration.js +1 -1
- package/views/3d/webgl-engine/effects/glow/applyEmissiveGlow.glsl.js +9 -4
- package/views/3d/webgl-engine/lib/BindParameters.js +1 -1
- package/views/3d/webgl-engine/lib/Intersector.js +1 -1
- package/views/3d/webgl-engine/lib/Renderer.js +1 -1
- package/views/3d/webgl-engine/lib/screenPolygonTriangleIntersections.js +1 -1
- package/views/3d/webgl-engine/materials/ColorMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/DefaultMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/PathMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/RibbonLineMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/TriangleMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/internal/worldSizedRibbonLineIntersectionUtils.js +2 -0
- package/views/layers/LineOfSightLayerView.d.ts +2 -2
- package/views/layers/ViewshedLayerView.d.ts +2 -1
- package/views/selection/SelectionOperation.js +1 -1
- package/views/selection/types.d.ts +43 -3
- package/views/support/layerViewUtils.js +1 -1
- package/views/support/screenshotUtils.js +1 -1
- package/views/support/selectionUtils.js +1 -1
- package/views/webgl/Texture.js +1 -1
- package/webdoc/support/webdocSaveUtils.js +1 -1
- package/webscene/Slide.d.ts +1 -2
- package/widgets/DirectionalPad/VisibleElements.d.ts +5 -1
- package/widgets/Feature/FeatureExpression/FeatureExpressionViewModel.js +1 -1
- package/widgets/FloorFilter/FloorFilterViewModel.js +1 -1
- package/widgets/OrientedImageryViewer/ImageMeasurementWorker.js +1 -1
- package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
- package/widgets/OrientedImageryViewer/imageMeasurementUtils.js +1 -1
- package/widgets/OrientedImageryViewer/services/ImageMeasurementService.js +1 -1
- package/widgets/Search/SearchViewModel.js +1 -1
- package/widgets/Search/support/layerSearchUtils.js +1 -1
- package/widgets/Sketch/SketchViewModel.js +1 -1
- package/widgets/Sketch/support/PluginManager.js +1 -1
- package/widgets/UtilityNetworkTrace/UtilityNetworkTraceFeature.js +1 -1
- package/widgets/UtilityNetworkValidateTopology/UtilityNetworkValidateTopologyViewModel.d.ts +3 -3
- package/widgets/UtilityNetworkValidateTopology.d.ts +1 -1
- package/widgets/support/SelectionList/GroupLayerItem.d.ts +6 -0
- package/widgets/support/SelectionList/GroupLayerItem.js +1 -1
- package/widgets/support/SelectionList/ItemBase.js +1 -1
- package/widgets/support/SelectionToolbar/SelectionToolbarViewModel.d.ts +6 -1
- package/widgets/support/SelectionToolbar/SelectionToolbarViewModel.js +1 -1
- package/widgets/support/SelectionToolbar.d.ts +8 -1
- package/widgets/support/SelectionToolbar.js +1 -1
- package/widgets/support/Selector2D/selectorUtils.js +1 -1
- package/assets/esri/core/workers/chunks/0cb50bc2b2125c5fedf2.js +0 -1
- package/assets/esri/core/workers/chunks/1fe24ffcd88280d84fbe.js +0 -1
- package/assets/esri/core/workers/chunks/2f04b8679c9f15390517.js +0 -1
- package/assets/esri/core/workers/chunks/42045cf46497828cd3c0.js +0 -1
- package/assets/esri/core/workers/chunks/72071ea5de89720fbe42.js +0 -1
- package/assets/esri/core/workers/chunks/9de5ad77bc37ec142218.js +0 -1
- package/assets/esri/core/workers/chunks/c19cd5a03b6d480fe53b.js +0 -1
- package/assets/esri/core/workers/chunks/d1f98c5249c487eb96f1.js +0 -1
- package/assets/esri/core/workers/chunks/e01fc1c31bc023dd0e33.js +0 -1
- package/assets/esri/core/workers/chunks/e077e321a3109c2fbbe2.js +0 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
import{Material as e,MaterialParameters as t}from"../lib/Material.js";import{intersectTriangleGeometryPolygon2D as n}from"../lib/PolygonIntersections2D.js";import{intersectTriangleGeometry as r,intersectTriangleGeometry2D as i}from"../lib/RayIntersections.js";import{
|
|
2
|
+
import{Material as e,MaterialParameters as t}from"../lib/Material.js";import{intersectTriangleGeometryPolygon2D as n}from"../lib/PolygonIntersections2D.js";import{intersectTriangleGeometry as r,intersectTriangleGeometry2D as i}from"../lib/RayIntersections.js";import{intersectTriangleGeometryWithScreenPolygon as a,DrapedHit as o}from"../lib/screenPolygonTriangleIntersections.js";import{intersectWithPolygonOffset as s,applyPolygonOffsetToHit as c}from"./intersectWithPolygonOffset.js";class l extends e{updateConfiguration(e){super.updateConfiguration(e),this._configuration.transparent=this.transparent,this._configuration.enableOITOffset=e.enableOITOffset,this._configuration.polygonOffset=this.parameters.polygonOffset}intersectRay(e,t,n,i,a,o){return o=s(o,this._configuration,i,a),r(e,n,i,a,null,o)}intersectRayDraped(e,t,n,r){return i(n[0],n[1],e,r)}intersectScreenPolygon(e,t,n,r){return c(a(e,n,t,r,null),this._configuration,n.camera.eye)}intersectScreenPolygonDraped(e,t,r,i){let a=n(i,t,e);return a===null?null:new o(a)}}class u extends t{constructor(){super(...arguments),this.polygonOffset=0}}export{l as TriangleMaterial,u as TriangleMaterialParameters};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
+
import e from"../../../../../core/PooledArray.js";import{fromMat4 as t,transpose as n}from"../../../../../core/libs/gl-matrix-2/math/mat3.js";import{create as r}from"../../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{subtract as i,dot as a,scaleAndAdd as o,set as s,length as c,scale as l,transformMat4 as u,transformMat3 as d,cross as f,squaredLength as p,normalize as m,copy as h}from"../../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as g}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{fromValues as _,create as v}from"../../../../../geometry/support/aaBoundingBox.js";import{fromValues as y,clipSlab as b,create as x,getStart as S}from"../../../../../geometry/support/clipRay.js";import{intersectsTransformedAabb as C}from"../../../../../geometry/support/frustumPlanes.js";import{clipClosedNegativeHalfspace as w}from"../../../../../geometry/support/plane.js";import{wrap as T}from"../../../../../geometry/support/ray.js";import{Sphere as E}from"../../../../../geometry/support/sphere.js";import{intersectConvexPolygonWithScreenPolygon as D}from"../../lib/screenPolygonTriangleIntersections.js";function O(e,t,n,r,c,l){y(c,0,1/0,W);for(let r of[0,1,2])if(!b(r,Math.min(e[r],t[r])-n,Math.max(e[r],t[r])+n,W))return null;if(!w(r.frustum[4],W)||!w(r.frustum[5],W))return null;let u=M(e,t,r,L,R,l);if(u===0)return null;i(B,c.origin,e);let d=a(B,l),f=a(c.direction,l),p=P(c.direction,l);if(Math.abs(f)>p){let e=-d/f;return e<W.c0||e>W.c1?null:(o(B,B,c.direction,e),I(a(B,L),a(B,R),u,n*n)?e:null)}if(Math.abs(d)>P(B,l))return null;let m=a(B,L),h=a(B,R),g=a(c.direction,L),_=a(c.direction,R);return s(W.ray.origin,m,h,0),s(W.ray.direction,g,_,0),!b(0,-n,u+n,W)||!b(1,-n,n,W)?null:k(W,u,n)}function k(e,t,n){let r=S(e,B);if(I(r[0],r[1],t,n*n))return e.c0;s(G.center,r[0]<0?0:t,0,0),G.radius=n;let i=e.ray.direction;if(!G.intersectRay(T(r,i),K))return null;let a=Math.abs(i[0])>Math.abs(i[1])?0:1,o=e.c0+(K[a]-r[a])/i[a];return o<=e.c1?o:null}function A(e,t,n,r,i){let a=N(e,t,n,q);if(!C(i.broadPhaseFrustum,a,null)||M(e,t,r,L,R,z)===0)return!1;let[s,c,l,u]=Y;return F(s,e,L,R,-n,-n),F(c,t,L,R,n,-n),F(l,t,L,R,n,n),F(u,e,L,R,-n,n),D(i,Y,r,Z)?(o(s,e,R,-n),o(c,t,R,-n),o(l,t,R,n),o(u,e,R,n),D(i,Y,r,Z)?!0:j(e,-n,L,R,r,i)||j(t,n,L,R,r,i)):!1}function j(e,t,n,r,i,a){let o=Math.abs(t);if(!C(a.broadPhaseFrustum,N(e,e,o,q),null))return!1;X.length=0,h(X.pushNew(),e),F(X.pushNew(),e,n,r,0,o);for(let[i,a]of J)F(X.pushNew(),e,n,r,i*t,a*o);return D(a,X,i,Z)}function M(e,r,a,o,h,g){i(o,r,e);let _=c(o);if(_===0)return 0;l(o,o,1/_);let v=a.viewMatrix;u(V,e,v),t(H,v),d(U,o,H);let y=a.projectionMatrix,b=y[11]*V[2]+y[15],x=y[11]*U[2],S=y[0]*(U[0]*b-V[0]*x),C=y[5]*(U[1]*b-V[1]*x),w=a.fullViewport,T=C*w[3]/(y[0]*w[2]),E=-S*w[2]/(y[5]*w[3]),D=Math.hypot(T,E);if(D===0)return 0;let O=T/D,k=E/D;return s(h,O,k,0),n(H,H),d(h,h,H),f(g,o,h),p(g)===0?0:(m(g,g),f(h,g,o),_)}function N(e,t,n,r){return _(Math.min(e[0],t[0])-n,Math.min(e[1],t[1])-n,Math.min(e[2],t[2])-n,Math.max(e[0],t[0])+n,Math.max(e[1],t[1])+n,Math.max(e[2],t[2])+n,r)}function P(e,t){return 16*2**-52*(Math.abs(e[0]*t[0])+Math.abs(e[1]*t[1])+Math.abs(e[2]*t[2]))}function F(e,t,n,r,i,a){o(e,t,n,i),o(e,e,r,a)}function I(e,t,n,r){let i=e<0?e:e>n?e-n:0;return i*i+t*t<=r}const L=g(),R=g(),z=g(),B=g(),V=g(),H=r(),U=g(),W=x(),G=new E,K=g(),q=v(),J=Array.from({length:3},(e,t)=>{let n=(t+1)*Math.PI/3;return t===2?[0,-1]:[Math.sin(n),Math.cos(n)]}),Y=[g(),g(),g(),g()],X=new e({allocator:e=>e??g()}),Z=new e({allocator:e=>e??g()});export{O as intersectRayWithWorldSizedLineSegment,A as intersectScreenPolygonWithWorldSizedLineSegment};
|
|
@@ -11,8 +11,8 @@ export interface LineOfSightLayerViewProperties extends LayerViewProperties, Par
|
|
|
11
11
|
* Represents the [LayerView](https://developers.arcgis.com/javascript/latest/references/core/views/layers/LayerView/) of a [LineOfSightLayer](https://developers.arcgis.com/javascript/latest/references/core/layers/LineOfSightLayer/)
|
|
12
12
|
* after it has been added to a [Map](https://developers.arcgis.com/javascript/latest/references/core/Map/) in a [SceneView](https://developers.arcgis.com/javascript/latest/references/core/views/SceneView/).
|
|
13
13
|
*
|
|
14
|
-
* The line of sight layer view controls whether the [
|
|
15
|
-
* [LineOfSightLayer](https://developers.arcgis.com/javascript/latest/references/core/layers/LineOfSightLayer
|
|
14
|
+
* The line of sight layer view controls whether the [LineOfSightAnalysis](https://developers.arcgis.com/javascript/latest/references/core/analysis/LineOfSightAnalysis/) in its associated
|
|
15
|
+
* [LineOfSightLayer.analysis](https://developers.arcgis.com/javascript/latest/references/core/layers/LineOfSightLayer/#analysis) can be created or edited interactively.
|
|
16
16
|
*
|
|
17
17
|
* It allows to create an observer and/or targets interactively using the [place()](https://developers.arcgis.com/javascript/latest/references/core/views/layers/LineOfSightLayerView/#place) method, query the [results](https://developers.arcgis.com/javascript/latest/references/core/views/layers/LineOfSightLayerView/#results),
|
|
18
18
|
* or make an existing analysis editable by enabling the [interactive](https://developers.arcgis.com/javascript/latest/references/core/views/layers/LineOfSightLayerView/#interactive) property.
|
|
@@ -10,7 +10,7 @@ export interface ViewshedLayerViewProperties extends LayerViewProperties, Partia
|
|
|
10
10
|
* Represents the [LayerView](https://developers.arcgis.com/javascript/latest/references/core/views/layers/LayerView/) of a [ViewshedLayer](https://developers.arcgis.com/javascript/latest/references/core/layers/ViewshedLayer/)
|
|
11
11
|
* after it has been added to a [Map](https://developers.arcgis.com/javascript/latest/references/core/Map/) in a [SceneView](https://developers.arcgis.com/javascript/latest/references/core/views/SceneView/).
|
|
12
12
|
*
|
|
13
|
-
* The viewshed layer view controls whether the
|
|
13
|
+
* The viewshed layer view controls whether the [ViewshedAnalysis](https://developers.arcgis.com/javascript/latest/references/core/analysis/ViewshedAnalysis/) in its associated
|
|
14
14
|
* [ViewshedLayer.source](https://developers.arcgis.com/javascript/latest/references/core/layers/ViewshedLayer/#source) can be created or edited interactively.
|
|
15
15
|
*
|
|
16
16
|
* It allows to create new viewsheds interactively using the [place()](https://developers.arcgis.com/javascript/latest/references/core/views/layers/ViewshedLayerView/#place) method,
|
|
@@ -43,6 +43,7 @@ export interface ViewshedLayerViewProperties extends LayerViewProperties, Partia
|
|
|
43
43
|
* @see [Viewshed](https://developers.arcgis.com/javascript/latest/references/core/analysis/Viewshed/)
|
|
44
44
|
* @see [ViewshedAnalysis](https://developers.arcgis.com/javascript/latest/references/core/analysis/ViewshedAnalysis/)
|
|
45
45
|
* @see [ViewshedAnalysisView3D](https://developers.arcgis.com/javascript/latest/references/core/views/3d/analysis/ViewshedAnalysisView3D/)
|
|
46
|
+
* @see [ViewOptions](https://developers.arcgis.com/javascript/latest/references/core/views/interactive/options/ViewOptions/)
|
|
46
47
|
* @see [Sample - ViewshedLayer in slides](https://developers.arcgis.com/javascript/latest/sample-code/layers-viewshed/)
|
|
47
48
|
* @see [Async cancellation with AbortController](https://developers.arcgis.com/javascript/latest/async-cancellation-with-abortcontroller/)
|
|
48
49
|
*/
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
import{__decorate as e}from"tslib";import{createTask as t}from"../../core/asyncUtils.js";import n from"../../core/Collection.js";import{EventedAccessor as r}from"../../core/Evented.js";import{makeHandle as i}from"../../core/handleUtils.js";import a from"../../core/Logger.js";import{abortMaybe as o}from"../../core/maybe.js";import{debounce as s,onAbort as c,ignoreAbortErrors as l}from"../../core/promiseUtils.js";import{on as
|
|
2
|
+
import{__decorate as e}from"tslib";import{createTask as t}from"../../core/asyncUtils.js";import n from"../../core/Collection.js";import{EventedAccessor as r}from"../../core/Evented.js";import{makeHandle as i}from"../../core/handleUtils.js";import a from"../../core/Logger.js";import{abortMaybe as o}from"../../core/maybe.js";import{debounce as s,onAbort as c,ignoreAbortErrors as l}from"../../core/promiseUtils.js";import u from"../../core/ReactiveMap.js";import{on as d}from"../../core/reactiveUtils.js";import{createScreenPoint as f}from"../../core/screenUtils.js";import{property as p,subclass as m}from"../../core/accessorSupport/decorators.js";import h from"../../geometry/Point.js";import g from"../../geometry/Polygon.js";import{isClockwise as _}from"../../geometry/support/coordsUtils.js";import{sketchKeys as v,selectionKeys as y}from"../interactive/keybindings.js";import{getSelectionFromGeometry as b}from"../../widgets/support/Selector2D/selectorUtils.js";import{getSelectionFromScreenSelector as x}from"../../widgets/support/Selector3D/selectorUtils.js";let S=class extends r{constructor(e){super(e),this._completed=!1,this._isConstraintKeyDown=!1,this._processTask=null,this.createTool=`rectangle`,this.effectiveSourceMap=new u,this.mode=null,this.persistSelection=!0,this.returnFeatureTitleFields=!1,this.returnGeometry=!0,this.selection=new n,this.selectionManager=null,this.selectOnComplete=!0,this.sources=null,this.toolName=``,this.type=`add`,this._process=s(async(e,n)=>{let{callback:r,completed:i}=e,a=t(async t=>{let{effectiveSelectionManager:n,effectiveSourceMap:a,returnFeatureTitleFields:o,returnGeometry:s,selection:c,sources:l,view:u}=this;if(!l?.length&&!n.sources.length||!u){c.removeAll();return}let d=u.type===`3d`&&`screenSelector`in e&&e.screenSelector&&l!=null?await x({selector:e.screenSelector,signal:t,sources:l,view:u}):`selector`in e&&e.selector&&l!=null?await b({effectiveSourceMap:a,returnFeatureTitleFields:o,returnGeometry:s,selector:e.selector,signal:t,sources:l,view:u}):[];if(c.removeAll(),c.addMany(d),i&&this.persistSelection)switch(this.effectiveType){case`remove`:n.updateSelection({current:[],added:[],removed:d});break;case`replace`:n.clear(),n.updateSelection({current:d,added:[],removed:[]});break;default:n.updateSelection({current:d,added:[],removed:[]})}r?.()});return c(n,()=>a.abort()),this._processTask=a,a.promise},C),this._onOperationFinish=this._onOperationFinish.bind(this)}async initialize(){await this._setup()}get _defaultMode(){return this.createTool===`polygon`?`click`:`hybrid`}get _selectionArea(){let e=this._tool.coordinates;if(e.length===0)return;let t=f(),n=this.view.spatialReference,r=e=>{t.x=e[0],t.y=e[1];let n=this.view.toMap(t);return[n?.x??0,n?.y??0]};if(e.length===1||e.every(([t,n])=>t===e[0][0]&&n===e[0][1])){let[t,i]=r(e[0]);return new h({x:t,y:i,spatialReference:n})}let i=e.map(r);return i.length===0?void 0:(_(i)||i.reverse(),new g({spatialReference:n,rings:[i]}))}get _screenSelector(){let e=this._tool.coordinates;if(e.length===0)return;let t=e=>f(e[0],e[1]);return e.length===1||e.every(([t,n])=>t===e[0][0]&&n===e[0][1])?t(e[0]):e.map(t)}get completed(){return this._completed}get effectiveSelectionManager(){return this.selectionManager??this.view.selectionManager}get effectiveType(){let e=this.type??`add`;if(this._isConstraintKeyDown)switch(e){case`add`:return`remove`;case`remove`:return`add`;case`replace`:return`add`;default:return e}return e}get processingFinalSelection(){return!!(this._processTask&&this._tool?.drawOperation?.isCompleted)}cancel(){this.selection.removeAll(),this._onOperationFinish(!0)}destroy(){this._toolImportController=o(this._toolImportController)}async _setup(){let{createTool:e,view:t}=this;if(await t.whenReady(),this.destroyed||this._toolImportController)return;let n=new AbortController;this._toolImportController=n;let r=await import(`../draw/DrawScreenTool.js`);if(n.signal.aborted)return;let o=Symbol();try{this._tool=new r.DrawScreenTool({view:t,mode:this.mode??this._defaultMode,geometryType:e,cursor:e===`point`?`default`:`crosshair`})}finally{this._toolImportController=null}if(!this._tool){a.getLogger(this).warn(`Unable to import Draw module. SelectionOperation failed to load.`);return}this.selectOnComplete||this.addHandles(this._tool.on([`cursor-update`,`vertex-add`,`vertex-remove`],()=>{this._syncConstraintKeyDown(),l(this._process(this._selectionProcessParams))}),o),this._syncConstraintKeyDown(),this.addHandles([d(()=>t,`key-down`,e=>{if(!e.repeat)switch(this._syncConstraintKeyDown(),e.key){case v.constraint:this._tool.uniformSizeToggled=!0,e.stopPropagation();break;case v.center:this._tool.centeredToggled=!0,e.stopPropagation()}}),d(()=>t,`key-up`,e=>{switch(this._syncConstraintKeyDown(),e.key){case v.constraint:this._tool.uniformSizeToggled=!1,e.stopPropagation();break;case v.center:this._tool.centeredToggled=!1,e.stopPropagation()}}),this.selection.on(`change`,({added:e,removed:t})=>this.emit(`selection-change`,{operationType:this.effectiveType,added:e,removed:t})),this._tool.on(`complete`,async e=>{this._syncConstraintKeyDown(),this.removeHandles(o),e.aborted?this.cancel():(this._tool.cursor=`progress`,await this._process({...this._selectionProcessParams,callback:this._onOperationFinish,completed:!0}))})],o),this.addHandles(i(()=>t.tools.remove(this._tool))),t.addAndActivateTool(this._tool)}_syncConstraintKeyDown(){let{inputManager:e}=this.view;this._isConstraintKeyDown=y.invertType.some(t=>e.isModifierKeyDown(t))}get _selectionProcessParams(){return this.view.type===`3d`?{screenSelector:this._screenSelector}:{selector:this._selectionArea}}_onOperationFinish(e=!1){this.removeAllHandles(),this._processTask?.abort(),this._completed=!0,this.emit(`complete`,{aborted:e,operationType:this.effectiveType,selection:this.selection.toArray(),toolName:this.toolName})}};e([p()],S.prototype,`_completed`,void 0),e([p()],S.prototype,`_defaultMode`,null),e([p()],S.prototype,`_isConstraintKeyDown`,void 0),e([p()],S.prototype,`_processTask`,void 0),e([p()],S.prototype,`_selectionArea`,null),e([p()],S.prototype,`_screenSelector`,null),e([p()],S.prototype,`completed`,null),e([p({constructOnly:!0})],S.prototype,`createTool`,void 0),e([p()],S.prototype,`effectiveSelectionManager`,null),e([p()],S.prototype,`effectiveSourceMap`,void 0),e([p()],S.prototype,`effectiveType`,null),e([p({constructOnly:!0})],S.prototype,`mode`,void 0),e([p()],S.prototype,`persistSelection`,void 0),e([p()],S.prototype,`processingFinalSelection`,null),e([p()],S.prototype,`returnFeatureTitleFields`,void 0),e([p()],S.prototype,`returnGeometry`,void 0),e([p({readOnly:!0})],S.prototype,`selection`,void 0),e([p({constructOnly:!0})],S.prototype,`selectionManager`,void 0),e([p({constructOnly:!0})],S.prototype,`selectOnComplete`,void 0),e([p()],S.prototype,`sources`,void 0),e([p({constructOnly:!0})],S.prototype,`toolName`,void 0),e([p()],S.prototype,`type`,void 0),e([p({constructOnly:!0})],S.prototype,`view`,void 0),S=e([m(`esri.views.selection.SelectionOperation`)],S);const C=100,w=S;export{w as default};
|
|
@@ -14,11 +14,13 @@ import type Polyline from "../../geometry/Polyline.js";
|
|
|
14
14
|
import type GraphicsLayer from "../../layers/GraphicsLayer.js";
|
|
15
15
|
import type KnowledgeGraphLayer from "../../layers/KnowledgeGraphLayer.js";
|
|
16
16
|
import type LinkChartLayer from "../../layers/LinkChartLayer.js";
|
|
17
|
+
import type MapImageLayer from "../../layers/MapImageLayer.js";
|
|
17
18
|
import type MapNotesLayer from "../../layers/MapNotesLayer.js";
|
|
18
19
|
import type SketchLayer from "../../layers/SketchLayer.js";
|
|
19
20
|
import type SubtypeGroupLayer from "../../layers/SubtypeGroupLayer.js";
|
|
20
21
|
import type Field from "../../layers/support/Field.js";
|
|
21
22
|
import type FieldsIndex from "../../layers/support/FieldsIndex.js";
|
|
23
|
+
import type Sublayer from "../../layers/support/Sublayer.js";
|
|
22
24
|
import type SubtypeSublayer from "../../layers/support/SubtypeSublayer.js";
|
|
23
25
|
import type FeatureSet from "../../rest/support/FeatureSet.js";
|
|
24
26
|
import type Query from "../../rest/support/Query.js";
|
|
@@ -26,7 +28,7 @@ import type View from "../View.js";
|
|
|
26
28
|
import type LinkChartView from "../LinkChartView.js";
|
|
27
29
|
import type FeatureLikeLayerView from "../layers/FeatureLikeLayerView.js";
|
|
28
30
|
import type { LoadableMixin } from "../../core/Loadable.js";
|
|
29
|
-
import type { FeatureTitleOptions } from "../../layers/types.js";
|
|
31
|
+
import type { FeatureTitleOptions, ScaleRange } from "../../layers/types.js";
|
|
30
32
|
import type { RendererUnion } from "../../renderers/types.js";
|
|
31
33
|
import type { RequestOptions } from "../../request/types.js";
|
|
32
34
|
import type { MapViewOrSceneView } from "../MapViewOrSceneView.js";
|
|
@@ -40,14 +42,21 @@ import type { CreateTool } from "../../widgets/Sketch/types.js";
|
|
|
40
42
|
*
|
|
41
43
|
* @since 5.1
|
|
42
44
|
*/
|
|
43
|
-
export type SelectableParentLayerUnion = MapNotesLayer | KnowledgeGraphLayer | LinkChartLayer | SubtypeGroupLayer;
|
|
45
|
+
export type SelectableParentLayerUnion = MapNotesLayer | KnowledgeGraphLayer | LinkChartLayer | MapImageLayer | SketchLayer | SubtypeGroupLayer;
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Sublayer source types from which selections can be determined.
|
|
49
|
+
*
|
|
50
|
+
* @since 5.2
|
|
51
|
+
*/
|
|
52
|
+
export type SelectableSublayerUnion = Sublayer | SubtypeSublayer;
|
|
44
53
|
|
|
45
54
|
/**
|
|
46
55
|
* Layer source types from which selections can be determined.
|
|
47
56
|
*
|
|
48
57
|
* @since 5.1
|
|
49
58
|
*/
|
|
50
|
-
export type SelectableLayerSourceUnion = SelectableLayer |
|
|
59
|
+
export type SelectableLayerSourceUnion = SelectableLayer | SelectableSublayerUnion | SelectableParentLayerUnion;
|
|
51
60
|
|
|
52
61
|
/**
|
|
53
62
|
* Types of sources from which selections can be determined.
|
|
@@ -145,6 +154,19 @@ export interface SelectableLayerBase extends Accessor, LoadableMixin {
|
|
|
145
154
|
type: SelectableLayerType;
|
|
146
155
|
/** **Optional:** The name of the field used to display features in the layer. */
|
|
147
156
|
displayField?: string | null;
|
|
157
|
+
/**
|
|
158
|
+
* **Optional:** The effective scale range of the selectable layer.
|
|
159
|
+
*
|
|
160
|
+
* @since 5.2
|
|
161
|
+
*/
|
|
162
|
+
effectiveScaleRange?: ScaleRange;
|
|
163
|
+
/**
|
|
164
|
+
* **Optional:** Indicates whether the layer is visible, accounting for potential
|
|
165
|
+
* parent layer visibility.
|
|
166
|
+
*
|
|
167
|
+
* @since 5.2
|
|
168
|
+
*/
|
|
169
|
+
effectiveVisible?: boolean | null;
|
|
148
170
|
/** **Optional:** The fields used to create feature titles. It can be a single field name or an array of field names. */
|
|
149
171
|
featureTitleFields?: string[];
|
|
150
172
|
/** **Optional:** The name of the global ID field in the layer. */
|
|
@@ -237,6 +259,12 @@ export interface SelectableLayerViewBase extends Accessor {
|
|
|
237
259
|
* @since 5.1
|
|
238
260
|
*/
|
|
239
261
|
layer: SelectableLayer;
|
|
262
|
+
/**
|
|
263
|
+
* A reference to the where clause currently applied to the layer view.
|
|
264
|
+
*
|
|
265
|
+
* @since 5.2
|
|
266
|
+
*/
|
|
267
|
+
definitionExpression?: string | null;
|
|
240
268
|
/**
|
|
241
269
|
* Indicates the layer view is currently suspended.
|
|
242
270
|
*
|
|
@@ -249,6 +277,18 @@ export interface SelectableLayerViewBase extends Accessor {
|
|
|
249
277
|
* @since 5.1
|
|
250
278
|
*/
|
|
251
279
|
updating: boolean;
|
|
280
|
+
/**
|
|
281
|
+
* Indicates whether the layer view is visible.
|
|
282
|
+
*
|
|
283
|
+
* @since 5.2
|
|
284
|
+
*/
|
|
285
|
+
visible: boolean;
|
|
286
|
+
/**
|
|
287
|
+
* Indicates whether the layer view is visible at the current scale.
|
|
288
|
+
*
|
|
289
|
+
* @since 5.2
|
|
290
|
+
*/
|
|
291
|
+
visibleAtCurrentScale: boolean;
|
|
252
292
|
/**
|
|
253
293
|
* A reference to the view associated with the layer view.
|
|
254
294
|
*
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
import e from"../../core/Error.js";import has from"../../core/has.js";function t(e){return e&&typeof e.highlight==`function`}function n(e){return e&&typeof e.maskOccludee==`function`}const r=()=>!has(`disable-feature:layer-based-scale-visibility`);function i(
|
|
2
|
+
import e from"../../core/Error.js";import has from"../../core/has.js";function t(e){return e&&typeof e.highlight==`function`}function n(e){return e&&typeof e.maskOccludee==`function`}const r=()=>!has(`disable-feature:layer-based-scale-visibility`);function i(t,n,r){return new e(`layerview:spatial-reference-incompatible`,`The spatial reference of this ${t} (wkid: ${n??`undefined`}) is incompatible with the spatial reference of the view (wkid: ${r??`undefined`}).`,{})}function a(e){return e.type===`integrated-mesh-3d`||e.type===`integrated-mesh-3dtiles`}export{r as hasLayerBasedScaleVisibility,t as highlightsSupported,a as isIntegratedMeshLayerView,n as occludeesSupported,i as spatialReferenceIncompatibleError};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
import{clamp as e}from"../../core/mathUtils.js";import{createEmptyImageData as t}from"../../core/imageUtils.js";const n=2048;function r(t,n){let{format:r,quality:i,rotation:a,disableDecorations:o}=t||{},s=b(t,n.padding),c=_(t,{width:n.width-s.left-s.right,height:n.height-s.top-s.bottom}),{width:l,height:u}=g(t,c),d=x(r),f=E[d];return{format:d,quality:e(i??f,0,100),area:c,width:l,height:u,rotation:a,disableDecorations:!!o,ignoreBackground:!!t?.ignoreBackground,ignorePadding:!!t?.ignorePadding}}function i(e,t){let n=r(e,t),i=n.area,a=n.width/i.width,o=b(n,t.padding),s=o.left+o.right,c=o.top+o.bottom,l=t.width-s,u=t.height-c,d=Math.floor(l*a+s),f=Math.floor(u*a+c),p=e?.layers??[],m=n.ignoreBackground,h=n.ignorePadding;return{framebufferWidth:d,framebufferHeight:f,region:{x:Math.floor(i.x*a)+o.left,y:Math.floor(i.y*a)+o.top,width:n.width,height:n.height},format:n.format,quality:n.quality,rotation:n.rotation,pixelRatio:a,layers:p,disableDecorations:n.disableDecorations,ignoreBackground:m,ignorePadding:h,olidColor:!1}}function a(e,t,n){let{ctx:r,canvas:i}=s(e,n),a=r.getImageData(0,0,e.width,e.height),o=d(i,t);return c(i),{dataUrl:o,data:a}}function o(e,t){let{ctx:n,canvas:r}=s(e,t),i=n.getImageData(0,0,e.width,e.height);return c(r),i}function s(e,t){let n=l();t.premultipliedAlpha&&C(e),n.width=e.width,n.height=e.height;let r=n.getContext(`2d`,{willReadFrequently:!0});return r.putImageData(e,0,0),t.flipY&&S(r),{ctx:r,canvas:n}}function c(e){e.width=0,e.height=0}function l(){return u??=document.createElement(`canvas`),u}let u=null;function d(e,t){let n=w[t.format],r=t.quality/100;return e.toDataURL(n,r)}function f(t,n){let r=x(t),i=E[r];return{format:r,quality:e(n??i,0,100)}}function p(e,t){return t/Math.max(e[0],e[1])}function m(e,t,n,r=0,i=0,a=e.width-r,o=e.height-i,s=!1){let{data:c}=e,{width:l,height:u,data:d}=t,f=a/l,p=o/u,m=Math.ceil(f/2),h=Math.ceil(p/2),g=e.width;for(let e=0;e<u;e++)for(let t=0;t<l;t++){let a=(t+(s?u-e-1:e)*l)*4,o=0,_=0,v=0,y=0,b=0,x=0,S=(e+.5)*p;for(let a=Math.floor(e*p);a<(e+1)*p;a++){let e=Math.abs(S-(a+.5))/h,s=(t+.5)*f,l=e*e;for(let e=Math.floor(t*f);e<(t+1)*f;e++){let t=Math.abs(s-(e+.5))/m,u=Math.sqrt(l+t*t);if(u>=1)continue;let d=2*u*u*u-3*u*u+1,f=4*(r+e+(i+a)*g);x+=d*c[f+3],_+=d,!n&&c[f+3]<255&&(d=d*c[f+3]/255),v+=d*c[f],y+=d*c[f+1],b+=d*c[f+2],o+=d}}d[a]=v/o,d[a+1]=y/o,d[a+2]=b/o,d[a+3]=x/_}return t}function h(e,t,r){if(!t)return e;let{framebufferWidth:i,framebufferHeight:a,pixelRatio:o,region:s}=e,c=b(e,r),l=c.left+c.right,u=c.top+c.bottom,d=i-l,f=a-u,p=Math.min(8,Math.min((n-l)/d,(n-u)/f));return p<1.5?e:{...e,framebufferWidth:Math.round(d*p)+l,framebufferHeight:Math.round(f*p)+u,pixelRatio:o*p,resample:{region:{x:Math.round((s.x-c.left)*p)+c.left,y:Math.round((s.y-c.top)*p)+c.top,width:Math.round(s.width*p),height:Math.round(s.height*p)},width:i,height:a}}}function g(e,t){if(!e)return t;let n=e.width,r=e.height;if(n!=null&&r!=null)return{width:Math.floor(n),height:Math.floor(r)};if(n==null&&r==null)return t;let i=t.width/t.height;return r==null?{width:Math.floor(n),height:Math.floor(n/i)}:{width:Math.floor(r*i),height:Math.floor(r)}}function _(e,t){let n={x:0,y:0,width:t.width,height:t.height};if(e?.area){e.area.x!=null&&(n.x=Math.floor(e.area.x)),e.area.y!=null&&(n.y=Math.floor(e.area.y));let r=e.area.width==null?null:Math.floor(e.area.width),i=e.area.height==null?null:Math.floor(e.area.height);if(n.width=t.width-n.x,n.height=t.height-n.y,r!=null&&i!=null)n.width=Math.min(n.width,r),n.height=Math.min(n.height,i);else if(r==null&&i!=null){let e=Math.min(n.width,r);n.height=e/n.width*n.height,n.width=e}else if(r!=null&&i==null){let e=Math.min(n.height,i);n.width=e/n.height*n.width,n.height=e}}return v(y(n,e),t)}function v(e,t){let n=Math.floor(Math.max(e.x,0)),r=Math.floor(Math.max(e.y,0)),i={x:n,y:r,width:Math.floor(Math.min(e.width,t.width-n)),height:Math.floor(Math.min(e.height,t.height-r))},a=i.width/i.height,o=e.width/e.height;if(o===a)return i;if(o>a){let e=Math.floor(i.width/o),t=i.height-e;return{x:i.x,y:Math.floor(i.y+t/2),width:i.width,height:e}}let s=Math.floor(i.height*o),c=i.width-s;return{x:Math.floor(i.x+c/2),y:i.y,width:s,height:i.height}}function y(e,t){if(t?.width==null||t.height==null)return e;let n=t.width/t.height,r=e.width/e.height;if(r===n)return e;if(r<n){let t=Math.floor(e.height*n);return e.x-=(t-e.width)/2,e.width=t,e}let i=Math.floor(e.width/n);return e.y-=(i-e.height)/2,e.height=i,e}function b(e,t){return!t||e?.ignorePadding?D:t}function x(e){switch(e){case`png`:case`jpg`:case`jpeg`:return e;case null:case void 0:return T;default:return T}}function S(e){e.save(),e.globalCompositeOperation=`copy`,e.scale(1,-1),e.translate(0,-e.canvas.height),e.drawImage(e.canvas,0,0),e.restore()}function C(e){let t=e.data,n=t.length;for(let e=0;e<n;e+=4){let n=t[e+3];if(n!==255&&n>0){let r=255/n;t[e]=t[e]*r,t[e+1]=t[e+1]*r,t[e+2]=t[e+2]*r}}}const w={png:`image/png`,jpg:`image/jpeg`,jpeg:`image/jpeg`},T=`png`,E={png:100,jpg:98,jpeg:98},D={top:0,right:0,bottom:0,left:0};export{r as completeUserSettings,t as createEmptyImageData,a as encode,o as encodeData,f as getFormatAndQuality,p as getMaximumResolutionScale,m as resampleHermite,h as screenshotSuperSampleSettings,d as toDataUrl,i as toRenderSettings};
|
|
2
|
+
import{clamp as e}from"../../core/mathUtils.js";import{createEmptyImageData as t}from"../../core/imageUtils.js";const n=2048;function r(t,n){let{format:r,quality:i,rotation:a,disableDecorations:o}=t||{},s=b(t,n.padding),c=_(t,{width:n.width-s.left-s.right,height:n.height-s.top-s.bottom}),{width:l,height:u}=g(t,c),d=x(r),f=E[d];return{format:d,quality:e(i??f,0,100),area:c,width:l,height:u,rotation:a,disableDecorations:!!o,ignoreBackground:!!t?.ignoreBackground,ignorePadding:!!t?.ignorePadding}}function i(e,t){let n=r(e,t),i=n.area,a=n.width/i.width,o=b(n,t.padding),s=o.left+o.right,c=o.top+o.bottom,l=t.width-s,u=t.height-c,d=Math.floor(l*a+s),f=Math.floor(u*a+c);(d<=0||f<=0)&&(d=i.width,f=i.height);let p=e?.layers??[],m=n.ignoreBackground,h=n.ignorePadding;return{framebufferWidth:d,framebufferHeight:f,region:{x:Math.floor(i.x*a)+o.left,y:Math.floor(i.y*a)+o.top,width:n.width,height:n.height},format:n.format,quality:n.quality,rotation:n.rotation,pixelRatio:a,layers:p,disableDecorations:n.disableDecorations,ignoreBackground:m,ignorePadding:h,olidColor:!1}}function a(e,t,n){let{ctx:r,canvas:i}=s(e,n),a=r.getImageData(0,0,e.width,e.height),o=d(i,t);return c(i),{dataUrl:o,data:a}}function o(e,t){let{ctx:n,canvas:r}=s(e,t),i=n.getImageData(0,0,e.width,e.height);return c(r),i}function s(e,t){let n=l();t.premultipliedAlpha&&C(e),n.width=e.width,n.height=e.height;let r=n.getContext(`2d`,{willReadFrequently:!0});return r.putImageData(e,0,0),t.flipY&&S(r),{ctx:r,canvas:n}}function c(e){e.width=0,e.height=0}function l(){return u??=document.createElement(`canvas`),u}let u=null;function d(e,t){let n=w[t.format],r=t.quality/100;return e.toDataURL(n,r)}function f(t,n){let r=x(t),i=E[r];return{format:r,quality:e(n??i,0,100)}}function p(e,t){return t/Math.max(e[0],e[1])}function m(e,t,n,r=0,i=0,a=e.width-r,o=e.height-i,s=!1){let{data:c}=e,{width:l,height:u,data:d}=t,f=a/l,p=o/u,m=Math.ceil(f/2),h=Math.ceil(p/2),g=e.width;for(let e=0;e<u;e++)for(let t=0;t<l;t++){let a=(t+(s?u-e-1:e)*l)*4,o=0,_=0,v=0,y=0,b=0,x=0,S=(e+.5)*p;for(let a=Math.floor(e*p);a<(e+1)*p;a++){let e=Math.abs(S-(a+.5))/h,s=(t+.5)*f,l=e*e;for(let e=Math.floor(t*f);e<(t+1)*f;e++){let t=Math.abs(s-(e+.5))/m,u=Math.sqrt(l+t*t);if(u>=1)continue;let d=2*u*u*u-3*u*u+1,f=4*(r+e+(i+a)*g);x+=d*c[f+3],_+=d,!n&&c[f+3]<255&&(d=d*c[f+3]/255),v+=d*c[f],y+=d*c[f+1],b+=d*c[f+2],o+=d}}d[a]=v/o,d[a+1]=y/o,d[a+2]=b/o,d[a+3]=x/_}return t}function h(e,t,r){if(!t)return e;let{framebufferWidth:i,framebufferHeight:a,pixelRatio:o,region:s}=e,c=b(e,r),l=c.left+c.right,u=c.top+c.bottom,d=i-l,f=a-u,p=Math.min(8,Math.min((n-l)/d,(n-u)/f));return p<1.5?e:{...e,framebufferWidth:Math.round(d*p)+l,framebufferHeight:Math.round(f*p)+u,pixelRatio:o*p,resample:{region:{x:Math.round((s.x-c.left)*p)+c.left,y:Math.round((s.y-c.top)*p)+c.top,width:Math.round(s.width*p),height:Math.round(s.height*p)},width:i,height:a}}}function g(e,t){if(!e)return t;let n=e.width,r=e.height;if(n!=null&&r!=null)return{width:Math.floor(n),height:Math.floor(r)};if(n==null&&r==null)return t;let i=t.width/t.height;return r==null?{width:Math.floor(n),height:Math.floor(n/i)}:{width:Math.floor(r*i),height:Math.floor(r)}}function _(e,t){let n={x:0,y:0,width:t.width,height:t.height};if(e?.area){e.area.x!=null&&(n.x=Math.floor(e.area.x)),e.area.y!=null&&(n.y=Math.floor(e.area.y));let r=e.area.width==null?null:Math.floor(e.area.width),i=e.area.height==null?null:Math.floor(e.area.height);if(n.width=t.width-n.x,n.height=t.height-n.y,r!=null&&i!=null)n.width=Math.min(n.width,r),n.height=Math.min(n.height,i);else if(r==null&&i!=null){let e=Math.min(n.width,r);n.height=e/n.width*n.height,n.width=e}else if(r!=null&&i==null){let e=Math.min(n.height,i);n.width=e/n.height*n.width,n.height=e}}return v(y(n,e),t)}function v(e,t){let n=Math.floor(Math.max(e.x,0)),r=Math.floor(Math.max(e.y,0)),i={x:n,y:r,width:t.width>0?Math.floor(Math.min(e.width,t.width-n)):e.width,height:t.height>0?Math.floor(Math.min(e.height,t.height-r)):e.height},a=i.width/i.height,o=e.width/e.height;if(o===a)return i;if(o>a){let e=Math.floor(i.width/o),t=i.height-e;return{x:i.x,y:Math.floor(i.y+t/2),width:i.width,height:e}}let s=Math.floor(i.height*o),c=i.width-s;return{x:Math.floor(i.x+c/2),y:i.y,width:s,height:i.height}}function y(e,t){if(t?.width==null||t.height==null)return e;let n=t.width/t.height,r=e.width>0&&e.height>0?e.width/e.height:0;if(r===0)return e.x=0,e.y=0,e.width=Math.floor(t.width),e.height=Math.floor(t.height),e;if(r===n)return e;if(r<n){let t=Math.floor(e.height*n);return e.x-=(t-e.width)/2,e.width=t,e}let i=Math.floor(e.width/n);return e.y-=(i-e.height)/2,e.height=i,e}function b(e,t){return!t||e?.ignorePadding?D:t}function x(e){switch(e){case`png`:case`jpg`:case`jpeg`:return e;case null:case void 0:return T;default:return T}}function S(e){e.save(),e.globalCompositeOperation=`copy`,e.scale(1,-1),e.translate(0,-e.canvas.height),e.drawImage(e.canvas,0,0),e.restore()}function C(e){let t=e.data,n=t.length;for(let e=0;e<n;e+=4){let n=t[e+3];if(n!==255&&n>0){let r=255/n;t[e]=t[e]*r,t[e+1]=t[e+1]*r,t[e+2]=t[e+2]*r}}}const w={png:`image/png`,jpg:`image/jpeg`,jpeg:`image/jpeg`},T=`png`,E={png:100,jpg:98,jpeg:98},D={top:0,right:0,bottom:0,left:0};export{r as completeUserSettings,t as createEmptyImageData,a as encode,o as encodeData,f as getFormatAndQuality,p as getMaximumResolutionScale,m as resampleHermite,h as screenshotSuperSampleSettings,d as toDataUrl,i as toRenderSettings};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
function
|
|
2
|
+
import{isInEffectiveScaleRange as e}from"../../geometry/support/scaleUtils.js";function t(e){return!!(typeof e==`object`&&e&&`id`in e&&`type`in e)}function n(e){return!!(t(e)&&`on`in e&&e.on)}function r(e){return!!(t(e)&&`graphics`in e&&e.graphics)}function i(e){return!!(t(e)&&`fields`in e&&`fieldsIndex`in e&&`objectIdField`in e&&`createQuery`in e&&e.createQuery&&`queryFeatures`in e&&e.queryFeatures)}function a(e){return i(e)||r(e)}function o(e){return!!(typeof e==`object`&&e&&`layer`in e&&e.layer&&t(e.layer)&&`view`in e)}function s(e){return o(e)&&r(e.layer)}function c(e){return!!(o(e)&&`highlight`in e&&e.highlight)}function l(e){return!!(o(e)&&`createQuery`in e&&e.createQuery&&`queryFeatures`in e&&e.queryFeatures)}function u(e){return l(e)||s(e)}function d(e,t){return!!(typeof e==`object`&&e&&`isTable`in e&&e.isTable||t?.map?.allTables.includes(e))}function f(e,t){return u(e)?m(e)&&p(e.layer,t):!a(e)||p(e,t)}function p(t,n){return t.effectiveVisible!==!1&&e(t.effectiveScaleRange,n?.scale)}function m(e){return e.visible!==!1&&e.visibleAtCurrentScale!==!1}export{a as isSelectableLayer,t as isSelectableLayerBase,n as isSelectableLayerBaseWithEditing,u as isSelectableLayerView,o as isSelectableLayerViewBase,m as isSelectableLayerViewVisible,s as isSelectableLayerViewWithGraphics,c as isSelectableLayerViewWithHighlights,l as isSelectableLayerViewWithObjectIds,p as isSelectableLayerVisible,r as isSelectableLayerWithGraphics,i as isSelectableLayerWithObjectIds,f as isSelectionSourceVisible,d as isTableLayer};
|
package/views/webgl/Texture.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
import e from"../../core/Error.js";import has from"../../core/has.js";import t from"../../core/Logger.js";import{abortMaybe as n}from"../../core/maybe.js";import{hasValue as r}from"../../core/object.js";import{throwIfAborted as i,isAbortError as a}from"../../core/promiseUtils.js";import{checkWebGLError as o}from"./checkWebGLError.js";import{ResourceType as s,CompressedTextureFormat as c}from"./enums.js";import{estimateMemory as l}from"./TextureDescriptor.js";import{isCompressedData as u,deriveInternalFormat as d,isTexImageSource as f,is3DTarget as p,validateTexture as m,isCompressedFormat as h,getDimensions as g,isSizedPixelFormat as _,calcMipmapLevels as v}from"./textureUtils.js";import{ValidatedTextureDescriptor as y}from"./ValidatedTextureDescriptor.js";const b=!!has(`esri-tests-disable-gpu-memory-measurements`),x=()=>t.getLogger(`esri/views/webgl/Texture`);class S{static{this.TEXTURE_UNIT_FOR_UPDATES=0}static{this.compressionWorkerHandle=null}constructor(t,n=null,r=null){if(this.type=1,this._glName=null,this._samplingModeDirty=!1,this._wrapModeDirty=!1,this._shadowFilterDirty=!1,this._wasImmutablyAllocated=!1,`context`in t)this._descriptor=t,r=n;else{let r=y.validate(t,n);if(!r)throw new e(`texture:invalid-descriptor`,`Texture descriptor invalid`);this._descriptor=r}this._descriptor.target===34067?this._setDataCubeMap(r):this.setData(r)}get glName(){return this._glName}get descriptor(){return this._descriptor}get usedMemory(){return b?0:l(this._descriptor)}get isDirty(){return this._samplingModeDirty||this._wrapModeDirty||this._shadowFilterDirty}get hasWebGLTextureObject(){return!!this._glName}dispose(){this.abortCompression(),this.hasWebGLTextureObject&&this._descriptor.context?.gl&&(this._descriptor.context.instanceCounter.decrement(s.Texture,this),this._descriptor.context.unbindTexture(this),this._descriptor.context.gl.deleteTexture(this._glName),this._glName=null)}release(){this.dispose()}[Symbol.dispose](){this.dispose()}resize(t,n){let r=this._descriptor;if(r.width!==t||r.height!==n){if(this._wasImmutablyAllocated)throw new e(`texture:immutable-resize`,`Immutable textures can't be resized!`);r.width=t,r.height=n,this._descriptor.target===34067?this._setDataCubeMap(null):this.setData(null)}}enableCompression(e){this._descriptor.compress=e}disableCompression(){this._descriptor.compress=void 0}setData(e){this.abortCompression(),!u(e)&&this._descriptor.internalFormat&&r(c,this._descriptor.internalFormat)&&(this._descriptor.internalFormat=void 0),this._setData(e),!u(e)&&this._descriptor.compress&&this._compressOnWorker(e)}updateData(t,n,r,i,a,o,s=0){o||x().error(`An attempt to use uninitialized data!`),this.hasWebGLTextureObject||x().error(`An attempt to update uninitialized texture!`);let c=this._descriptor;c.internalFormat=d(c);let{context:l,pixelFormat:p,dataType:m,target:h,isImmutable:g}=c;if(g&&!this._wasImmutablyAllocated)throw new e(`texture:uninitialized`,`Cannot update immutable texture before allocation!`);let _=l.bindTexture(this,S.TEXTURE_UNIT_FOR_UPDATES,!0);(n<0||r<0||n+i>c.width||r+a>c.height)&&x().error(`An attempt to update out of bounds of the texture!`),this._configurePixelStorage();let{gl:v}=l;s&&((!i||!a)&&x().warn("Must pass width and height if `UNPACK_SKIP_ROWS` is used"),v.pixelStorei(v.UNPACK_SKIP_ROWS,s)),f(o)?v.texSubImage2D(h,t,n,r,i,a,p,m,o):u(o)?v.compressedTexSubImage2D(h,t,n,r,i,a,c.internalFormat,o.levels[t]):v.texSubImage2D(h,t,n,r,i,a,p,m,o),s&&v.pixelStorei(v.UNPACK_SKIP_ROWS,0),l.bindTexture(_,S.TEXTURE_UNIT_FOR_UPDATES)}updateData3D(t,n,r,i,a,o,s,c){c||x().error(`An attempt to use uninitialized data!`),this.hasWebGLTextureObject||x().error(`An attempt to update an uninitialized texture!`);let l=this._descriptor;l.internalFormat=d(l);let{context:f,pixelFormat:m,dataType:h,isImmutable:g,target:_}=l;if(g&&!this._wasImmutablyAllocated)throw new e(`texture:uninitialized`,`Cannot update immutable texture before allocation!`);p(_)||x().warn(`Attempting to set 3D texture data on a non-3D texture`);let v=f.bindTexture(this,S.TEXTURE_UNIT_FOR_UPDATES);f.setActiveTexture(S.TEXTURE_UNIT_FOR_UPDATES),(n<0||r<0||i<0||n+a>l.width||r+o>l.height||i+s>l.depth)&&x().error(`An attempt to update out of bounds of the texture!`),this._configurePixelStorage();let{gl:y}=f;if(u(c))c=c.levels[t],y.compressedTexSubImage3D(_,t,n,r,i,a,o,s,l.internalFormat,c);else{let e=c;y.texSubImage3D(_,t,n,r,i,a,o,s,m,h,e)}f.bindTexture(v,S.TEXTURE_UNIT_FOR_UPDATES)}generateMipmap(){let t=this._descriptor;if(t.width===0||t.height===0)return;if(!t.hasMipmap){if(this._wasImmutablyAllocated)throw new e(`texture:immutable-change`,`Cannot add mipmaps to immutable texture after allocation`);t.hasMipmap=!0,this._samplingModeDirty=!0,m(t)}t.samplingMode===9729?(this._samplingModeDirty=!0,t.samplingMode=9985):t.samplingMode===9728&&(this._samplingModeDirty=!0,t.samplingMode=9984);let n=this._descriptor.context.bindTexture(this,S.TEXTURE_UNIT_FOR_UPDATES);this._descriptor.context.setActiveTexture(S.TEXTURE_UNIT_FOR_UPDATES),this._descriptor.context.gl.generateMipmap(t.target),this._descriptor.context.bindTexture(n,S.TEXTURE_UNIT_FOR_UPDATES)}clearMipmap(){let t=this._descriptor;if(t.hasMipmap){if(this._wasImmutablyAllocated)throw new e(`texture:immutable-change`,`Cannot delete mipmaps to immutable texture after allocation`);t.hasMipmap=!1,this._samplingModeDirty=!0,m(t)}t.samplingMode===9985?(this._samplingModeDirty=!0,t.samplingMode=9729):t.samplingMode===9984&&(this._samplingModeDirty=!0,t.samplingMode=9728)}setSamplingMode(e){e!==this._descriptor.samplingMode&&(this._descriptor.samplingMode=e,this._samplingModeDirty=!0)}setWrapMode(e){e!==this._descriptor.wrapMode&&(this._descriptor.wrapMode=e,m(this._descriptor),this._wrapModeDirty=!0)}setShadowFiltering(e){e!==this._descriptor.linearFilterDepth&&(this._descriptor.linearFilterDepth=this._descriptor.compareEnabled=e,this.setSamplingMode(e?9729:9728),m(this._descriptor),this._shadowFilterDirty=!0)}applyChanges(){this._samplingModeDirty&&=(this._applySamplingMode(),!1),this._wrapModeDirty&&=(this._applyWrapMode(),!1),this._shadowFilterDirty&&=(this._applyShadowMode(),!1)}abortCompression(){this._compressionAbortController=n(this._compressionAbortController)}_setData(t,n){let r=this._descriptor,i=r.context?.gl;if(!i)return;o(i),this.hasWebGLTextureObject||(this._glName=i.createTexture(),r.context.instanceCounter.increment(s.Texture,this)),m(r);let a=r.context.bindTexture(this,S.TEXTURE_UNIT_FOR_UPDATES);r.context.setActiveTexture(S.TEXTURE_UNIT_FOR_UPDATES),this._configurePixelStorage(),o(i);let c=n??r.target,l=p(c);if(f(t))this._setDataFromTexImageSource(t,c);else{let{width:n,height:a,depth:s}=r;if(n==null||a==null)throw new e(`texture:missing-size`,`Width and height must be specified!`);if(l&&s==null)throw new e(`texture:missing-depth`,`Depth must be specified!`);if(r.internalFormat=d(r),r.isImmutable&&!this._wasImmutablyAllocated&&this._texStorage(c,r.internalFormat,r.hasMipmap,n,a,s),u(t)){if(!h(r.internalFormat))throw new e(`texture:format-mismatch`,`Attempting to use compressed data with an uncompressed format!`);this._setDataFromCompressedSource(t,r.internalFormat,c)}else this._texImage(c,0,r.internalFormat,n,a,s,t),o(i),r.hasMipmap&&this.generateMipmap()}this._applySamplingMode(),this._applyWrapMode(),this._applyAnisotropicFilteringParameters(),this._applyShadowMode(),o(i),r.context.bindTexture(a,S.TEXTURE_UNIT_FOR_UPDATES)}_setDataCubeMap(e=null){for(let t=34069;t<=34074;t++)this._setData(e,t)}_configurePixelStorage(){let e=this._descriptor.context.gl,{unpackAlignment:t,flipped:n,preMultiplyAlpha:r}=this._descriptor;e.pixelStorei(e.UNPACK_ALIGNMENT,t),e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,+!!n),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,+!!r)}_setDataFromTexImageSource(e,t){let{gl:n}=this._descriptor.context,r=this._descriptor;r.internalFormat=d(r);let i=p(t),{width:a,height:s,depth:c}=g(e);r.width&&r.height,r.width||=a,r.height||=s,i&&r.depth,i&&(r.depth=c),r.isImmutable&&!this._wasImmutablyAllocated&&this._texStorage(t,r.internalFormat,r.hasMipmap,a,s,c),this._texImage(t,0,r.internalFormat,a,s,c,e),o(n),r.hasMipmap&&(this.generateMipmap(),o(n))}_setDataFromCompressedSource(e,t,n){let r=this._descriptor,{width:i,height:a,depth:o}=r,s=e.levels,c=v(n,i,a,o),l=Math.min(c,s.length)-1;this._descriptor.context.gl.texParameteri(r.target,33085,l),this._forEachMipmapLevel((e,r,i,a)=>{let o=s[Math.min(e,s.length-1)];this._compressedTexImage(n,e,t,r,i,a,o)},l)}_texStorage(t,n,r,i,a,o){let{gl:s}=this._descriptor.context;if(!_(n)&&!h(n))throw new e(`texture:missing-format`,`Immutable textures must have a sized or compressed internal format`);if(!this._descriptor.isImmutable)return;let c=r?v(t,i,a,o):1;if(p(t)){if(o==null)throw new e(`texture:missing-depth`,`Missing depth dimension for 3D texture upload`);s.texStorage3D(t,c,n,i,a,o)}else s.texStorage2D(t,c,n,i,a);this._wasImmutablyAllocated=!0}_texImage(t,n,r,i,a,o,s){let c=this._descriptor.context.gl,l=p(t),{isImmutable:u,pixelFormat:d,dataType:f}=this._descriptor;if(u){if(s!=null){let r=s;if(l){if(o==null)throw new e(`texture:missing-depth`,`Missing depth dimension for 3D texture upload`);c.texSubImage3D(t,n,0,0,0,i,a,o,d,f,r)}else c.texSubImage2D(t,n,0,0,i,a,d,f,r)}}else{let u=s;if(l){if(o==null)throw new e(`texture:missing-depth`,`Missing depth dimension for 3D texture upload`);c.texImage3D(t,n,r,i,a,o,0,d,f,u)}else c.texImage2D(t,n,r,i,a,0,d,f,u)}}_compressedTexImage(t,n,r,i,a,o,s){let c=this._descriptor.context.gl,l=p(t);if(this._descriptor.isImmutable){if(s!=null){if(l){if(o==null)throw new e(`texture:missing-depth`,`Missing depth dimension for 3D texture upload`);c.compressedTexSubImage3D(t,n,0,0,0,i,a,o,r,s)}else c.compressedTexSubImage2D(t,n,0,0,i,a,r,s)}}else if(l){if(o==null)throw new e(`texture:missing-depth`,`Missing depth dimension for 3D texture upload`);c.compressedTexImage3D(t,n,r,i,a,o,0,s)}else c.compressedTexImage2D(t,n,r,i,a,0,s)}async _compressOnWorker(e){let{width:t,height:n,context:r,flipped:o,preMultiplyAlpha:s,hasMipmap:c,compress:l}=this._descriptor;if(!l)return;let{compressionTracker:u,compressionCallback:d,preserveSourceBitmap:f}=l,{compressedTextureETC:p,compressedTextureS3TC:m}=r.capabilities;if(!S.compressionWorkerHandle?.isCompressible(e,this._descriptor)||!p&&!m)return;this.abortCompression();let h=new AbortController;this._compressionAbortController=h,u?.increment();let g,_=!1,v=!1;try{e instanceof ImageBitmap?f?(g=await createImageBitmap(e),i(h),v=!0):g=e:e instanceof Uint8Array?(g=e.buffer,_=this.descriptor.flipped):(g=await createImageBitmap(e,{imageOrientation:o?`flipY`:`none`}),i(h),v=!0);let r={data:g,width:t,height:n,needsFlip:_,components:this._descriptor.pixelFormat===6408?4:3,preMultiplyAlpha:s,isOpaque:this._descriptor.isOpaque,hasMipmap:c,hasETC:!!p,hasS3TC:!!m},a=await S.compressionWorkerHandle.invoke(r,h.signal,1);if(i(h),a.compressedTexture&&this.hasWebGLTextureObject){let e=this.usedMemory;this._descriptor.internalFormat=a.internalFormat,this._setData(a.compressedTexture),d?.(e-this.usedMemory)}}catch(e){a(e)||x().error(`Texture compression failed!`)}finally{u?.decrement(),this._compressionAbortController?.signal.aborted&&(this._compressionAbortController=null),v&&g instanceof ImageBitmap&&g.close()}}_forEachMipmapLevel(t,n=1/0){let{width:r,height:i,depth:a,hasMipmap:o,target:s}=this._descriptor,c=s===32879;if(r==null||i==null||c&&a==null)throw new e(`texture:missing-size`,`Missing texture dimensions for mipmap calculation`);for(let e=0;t(e,r,i,a),!(!o||r===1&&i===1&&(!c||a===1)||e>=n);++e)r=Math.max(1,r>>1),i=Math.max(1,i>>1),c&&(a=Math.max(1,a>>1))}_applySamplingMode(){let e=this._descriptor,t=e.context?.gl,n=e.samplingMode,r=e.samplingMode;n===9985||n===9987?(n=9729,e.hasMipmap||(r=9729)):(n===9984||n===9986)&&(n=9728,e.hasMipmap||(r=9728)),t.texParameteri(e.target,t.TEXTURE_MAG_FILTER,n),t.texParameteri(e.target,t.TEXTURE_MIN_FILTER,r)}_applyWrapMode(){let e=this._descriptor,t=e.context?.gl;typeof e.wrapMode==`number`?(t.texParameteri(e.target,t.TEXTURE_WRAP_S,e.wrapMode),t.texParameteri(e.target,t.TEXTURE_WRAP_T,e.wrapMode)):(t.texParameteri(e.target,t.TEXTURE_WRAP_S,e.wrapMode.s),t.texParameteri(e.target,t.TEXTURE_WRAP_T,e.wrapMode.t))}_applyShadowMode(){let e=this._descriptor,t=e.context?.gl,n=e.compareEnabled?t.COMPARE_REF_TO_TEXTURE:t.NONE;t.texParameteri(e.target,t.TEXTURE_COMPARE_MODE,n),e.compareEnabled&&t.texParameteri(e.target,t.TEXTURE_COMPARE_FUNC,t.GREATER),o(t)}_applyAnisotropicFilteringParameters(){let e=this._descriptor,t=e.context.capabilities.textureFilterAnisotropic;t&&e.context.gl.texParameterf(e.target,t.TEXTURE_MAX_ANISOTROPY,e.maxAnisotropy??1)}}export{S as default};
|
|
2
|
+
import e from"../../core/Error.js";import has from"../../core/has.js";import t from"../../core/Logger.js";import{abortMaybe as n}from"../../core/maybe.js";import{hasValue as r}from"../../core/object.js";import{throwIfAborted as i,isAbortError as a}from"../../core/promiseUtils.js";import{checkWebGLError as o}from"./checkWebGLError.js";import{ResourceType as s,CompressedTextureFormat as c}from"./enums.js";import{estimateMemory as l}from"./TextureDescriptor.js";import{isCompressedData as u,deriveInternalFormat as d,isTexImageSource as f,is3DTarget as p,validateTexture as m,isCompressedFormat as h,getDimensions as g,isSizedPixelFormat as _,calcMipmapLevels as v}from"./textureUtils.js";import{ValidatedTextureDescriptor as y}from"./ValidatedTextureDescriptor.js";const b=!!has(`esri-tests-disable-gpu-memory-measurements`),x=()=>t.getLogger(`esri/views/webgl/Texture`);class S{static{this.TEXTURE_UNIT_FOR_UPDATES=0}static{this.compressionWorkerHandle=null}constructor(t,n=null,r=null){if(this.type=1,this._glName=null,this._samplingModeDirty=!1,this._wrapModeDirty=!1,this._shadowFilterDirty=!1,this._wasImmutablyAllocated=!1,`context`in t)this._descriptor=t,r=n;else{let r=y.validate(t,n);if(!r)throw new e(`texture:invalid-descriptor`,`Texture descriptor invalid`);this._descriptor=r}this._descriptor.target===34067?this._setDataCubeMap(r):this.setData(r)}get glName(){return this._glName}get descriptor(){return this._descriptor}get usedMemory(){return b?0:l(this._descriptor)}get isDirty(){return this._samplingModeDirty||this._wrapModeDirty||this._shadowFilterDirty}get hasWebGLTextureObject(){return!!this._glName}dispose(){this.abortCompression(),this.hasWebGLTextureObject&&this._descriptor.context?.gl&&(this._descriptor.context.instanceCounter.decrement(s.Texture,this),this._descriptor.context.unbindTexture(this),this._descriptor.context.gl.deleteTexture(this._glName),this._glName=null)}release(){this.dispose()}[Symbol.dispose](){this.dispose()}resize(t,n){let r=this._descriptor;if(r.width!==t||r.height!==n){if(this._wasImmutablyAllocated)throw new e(`texture:immutable-resize`,`Immutable textures can't be resized!`);r.width=t,r.height=n,this._descriptor.target===34067?this._setDataCubeMap(null):this.setData(null)}}enableCompression(e){this._descriptor.compress=e}disableCompression(){this._descriptor.compress=void 0}setData(e){this.abortCompression(),!u(e)&&this._descriptor.internalFormat&&r(c,this._descriptor.internalFormat)&&(this._descriptor.internalFormat=void 0),this._setData(e),!u(e)&&this._descriptor.compress&&this._compressOnWorker(e)}updateData(t,n,r,i,a,o,s=0){o||x().error(`An attempt to use uninitialized data!`),this.hasWebGLTextureObject||x().error(`An attempt to update uninitialized texture!`);let c=this._descriptor;c.internalFormat=d(c);let{context:l,pixelFormat:p,dataType:m,target:h,isImmutable:g}=c;if(g&&!this._wasImmutablyAllocated)throw new e(`texture:uninitialized`,`Cannot update immutable texture before allocation!`);let _=l.bindTexture(this,S.TEXTURE_UNIT_FOR_UPDATES,!0);(n<0||r<0||n+i>c.width||r+a>c.height)&&x().error(`An attempt to update out of bounds of the texture!`),this._configurePixelStorage();let{gl:v}=l;s&&((!i||!a)&&x().warn("Must pass width and height if `UNPACK_SKIP_ROWS` is used"),v.pixelStorei(v.UNPACK_SKIP_ROWS,s)),f(o)?v.texSubImage2D(h,t,n,r,i,a,p,m,o):u(o)?v.compressedTexSubImage2D(h,t,n,r,i,a,c.internalFormat,o.levels[t]):v.texSubImage2D(h,t,n,r,i,a,p,m,o),s&&v.pixelStorei(v.UNPACK_SKIP_ROWS,0),l.bindTexture(_,S.TEXTURE_UNIT_FOR_UPDATES)}updateData3D(t,n,r,i,a,o,s,c){c||x().error(`An attempt to use uninitialized data!`),this.hasWebGLTextureObject||x().error(`An attempt to update an uninitialized texture!`);let l=this._descriptor;l.internalFormat=d(l);let{context:f,pixelFormat:m,dataType:h,isImmutable:g,target:_}=l;if(g&&!this._wasImmutablyAllocated)throw new e(`texture:uninitialized`,`Cannot update immutable texture before allocation!`);p(_)||x().warn(`Attempting to set 3D texture data on a non-3D texture`);let v=f.bindTexture(this,S.TEXTURE_UNIT_FOR_UPDATES);f.setActiveTexture(S.TEXTURE_UNIT_FOR_UPDATES),(n<0||r<0||i<0||n+a>l.width||r+o>l.height||i+s>l.depth)&&x().error(`An attempt to update out of bounds of the texture!`),this._configurePixelStorage();let{gl:y}=f;if(u(c))c=c.levels[t],y.compressedTexSubImage3D(_,t,n,r,i,a,o,s,l.internalFormat,c);else{let e=c;y.texSubImage3D(_,t,n,r,i,a,o,s,m,h,e)}f.bindTexture(v,S.TEXTURE_UNIT_FOR_UPDATES)}generateMipmap(){let t=this._descriptor;if(t.width===0||t.height===0)return;if(!t.hasMipmap){if(this._wasImmutablyAllocated)throw new e(`texture:immutable-change`,`Cannot add mipmaps to immutable texture after allocation`);t.hasMipmap=!0,this._samplingModeDirty=!0,m(t)}t.samplingMode===9729?(this._samplingModeDirty=!0,t.samplingMode=9985):t.samplingMode===9728&&(this._samplingModeDirty=!0,t.samplingMode=9984);let n=this._descriptor.context.bindTexture(this,S.TEXTURE_UNIT_FOR_UPDATES);this._descriptor.context.setActiveTexture(S.TEXTURE_UNIT_FOR_UPDATES),this._descriptor.context.gl.generateMipmap(t.target),this._descriptor.context.bindTexture(n,S.TEXTURE_UNIT_FOR_UPDATES)}clearMipmap(){let t=this._descriptor;if(t.hasMipmap){if(this._wasImmutablyAllocated)throw new e(`texture:immutable-change`,`Cannot delete mipmaps to immutable texture after allocation`);t.hasMipmap=!1,this._samplingModeDirty=!0,m(t)}t.samplingMode===9985?(this._samplingModeDirty=!0,t.samplingMode=9729):t.samplingMode===9984&&(this._samplingModeDirty=!0,t.samplingMode=9728)}setSamplingMode(e){e!==this._descriptor.samplingMode&&(this._descriptor.samplingMode=e,this._samplingModeDirty=!0)}setWrapMode(e){e!==this._descriptor.wrapMode&&(this._descriptor.wrapMode=e,m(this._descriptor),this._wrapModeDirty=!0)}setShadowFiltering(e){e!==this._descriptor.linearFilterDepth&&(this._descriptor.linearFilterDepth=this._descriptor.compareEnabled=e,this.setSamplingMode(e?9729:9728),m(this._descriptor),this._shadowFilterDirty=!0)}applyChanges(){this._samplingModeDirty&&=(this._applySamplingMode(),!1),this._wrapModeDirty&&=(this._applyWrapMode(),!1),this._shadowFilterDirty&&=(this._applyShadowMode(),!1)}abortCompression(){this._compressionAbortController=n(this._compressionAbortController)}_setData(t,n){let r=this._descriptor,i=r.context?.gl;if(!i)return;o(i),this.hasWebGLTextureObject||(this._glName=i.createTexture(),r.context.instanceCounter.increment(s.Texture,this)),m(r);let a=r.context.bindTexture(this,S.TEXTURE_UNIT_FOR_UPDATES);r.context.setActiveTexture(S.TEXTURE_UNIT_FOR_UPDATES),this._configurePixelStorage(),o(i);let c=n??r.target,l=p(c);if(f(t))this._setDataFromTexImageSource(t,c);else{let{width:n,height:a,depth:s}=r;if(n==null||a==null)throw new e(`texture:missing-size`,`Width and height must be specified!`);if(l&&s==null)throw new e(`texture:missing-depth`,`Depth must be specified!`);if(r.internalFormat=d(r),r.isImmutable&&!this._wasImmutablyAllocated&&this._texStorage(c,r.internalFormat,r.hasMipmap,n,a,s),u(t)){if(!h(r.internalFormat))throw new e(`texture:format-mismatch`,`Attempting to use compressed data with an uncompressed format!`);this._setDataFromCompressedSource(t,r.internalFormat,c)}else this._texImage(c,0,r.internalFormat,n,a,s,t),o(i),r.hasMipmap&&this.generateMipmap()}this._applySamplingMode(),this._applyWrapMode(),this._applyAnisotropicFilteringParameters(),this._applyShadowMode(),o(i),r.context.bindTexture(a,S.TEXTURE_UNIT_FOR_UPDATES)}_setDataCubeMap(e=null){for(let t=34069;t<=34074;t++)this._setData(e,t)}_configurePixelStorage(){let e=this._descriptor.context.gl,{unpackAlignment:t,flipped:n,preMultiplyAlpha:r}=this._descriptor;e.pixelStorei(e.UNPACK_ALIGNMENT,t),e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,+!!n),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,+!!r)}_setDataFromTexImageSource(e,t){let{gl:n}=this._descriptor.context,r=this._descriptor;r.internalFormat=d(r);let i=p(t),{width:a,height:s,depth:c}=g(e);r.width&&r.height,r.width||=a,r.height||=s,i&&r.depth,i&&(r.depth=c),r.isImmutable&&!this._wasImmutablyAllocated&&this._texStorage(t,r.internalFormat,r.hasMipmap,a,s,c),this._texImage(t,0,r.internalFormat,a,s,c,e),o(n),r.hasMipmap&&(this.generateMipmap(),o(n))}_setDataFromCompressedSource(e,t,n){let r=this._descriptor,{width:i,height:a,depth:o}=r,s=e.levels,c=v(n,i,a,o),l=Math.min(c,s.length)-1;this._descriptor.context.gl.texParameteri(r.target,33085,l),this._forEachMipmapLevel((e,r,i,a)=>{let o=s[Math.min(e,s.length-1)];this._compressedTexImage(n,e,t,r,i,a,o)},l)}_texStorage(t,n,r,i,a,o){let{gl:s}=this._descriptor.context;if(!_(n)&&!h(n))throw new e(`texture:missing-format`,`Immutable textures must have a sized or compressed internal format`);if(!this._descriptor.isImmutable)return;let c=r?v(t,i,a,o):1;if(p(t)){if(o==null)throw new e(`texture:missing-depth`,`Missing depth dimension for 3D texture upload`);s.texStorage3D(t,c,n,i,a,o)}else s.texStorage2D(t,c,n,i,a);this._wasImmutablyAllocated=!0}_texImage(t,n,r,i,a,o,s){let c=this._descriptor.context.gl,l=p(t),{isImmutable:u,pixelFormat:d,dataType:f}=this._descriptor;if(u){if(s!=null){let r=s;if(l){if(o==null)throw new e(`texture:missing-depth`,`Missing depth dimension for 3D texture upload`);c.texSubImage3D(t,n,0,0,0,i,a,o,d,f,r)}else c.texSubImage2D(t,n,0,0,i,a,d,f,r)}}else{let u=s;if(l){if(o==null)throw new e(`texture:missing-depth`,`Missing depth dimension for 3D texture upload`);c.texImage3D(t,n,r,i,a,o,0,d,f,u)}else c.texImage2D(t,n,r,i,a,0,d,f,u)}}_compressedTexImage(t,n,r,i,a,o,s){let c=this._descriptor.context.gl,l=p(t);if(this._descriptor.isImmutable){if(s!=null){if(l){if(o==null)throw new e(`texture:missing-depth`,`Missing depth dimension for 3D texture upload`);c.compressedTexSubImage3D(t,n,0,0,0,i,a,o,r,s)}else c.compressedTexSubImage2D(t,n,0,0,i,a,r,s)}}else if(l){if(o==null)throw new e(`texture:missing-depth`,`Missing depth dimension for 3D texture upload`);c.compressedTexImage3D(t,n,r,i,a,o,0,s)}else c.compressedTexImage2D(t,n,r,i,a,0,s)}async _compressOnWorker(e){let{width:t,height:n,context:r,flipped:o,preMultiplyAlpha:s,hasMipmap:c,compress:l}=this._descriptor;if(!l)return;let{compressionTracker:u,compressionCallback:d,preserveSourceBitmap:f}=l,{compressedTextureETC:p,compressedTextureS3TC:m}=r.capabilities;if(!S.compressionWorkerHandle?.isCompressible(e,this._descriptor)||!p&&!m)return;this.abortCompression();let h=new AbortController;this._compressionAbortController=h,u?.increment();let g,_=!1,v=!1;try{e instanceof ImageBitmap?f?(g=await createImageBitmap(e),i(h),v=!0):g=e:e instanceof Uint8Array?(g=e.buffer,_=this.descriptor.flipped):(g=await createImageBitmap(e,{imageOrientation:o?`flipY`:`none`}),i(h),v=!0);let r={data:g,width:t,height:n,needsFlip:_,components:this._descriptor.pixelFormat===6408?4:3,preMultiplyAlpha:s,isOpaque:this._descriptor.isOpaque,hasMipmap:c,hasETC:!!p,hasS3TC:!!m},a=await S.compressionWorkerHandle.invoke(r,h.signal,1);if(i(h),a.compressedTexture&&this.hasWebGLTextureObject){let e=this.usedMemory;this._descriptor.internalFormat=a.internalFormat,this._setData(a.compressedTexture),d?.(e-this.usedMemory)}}catch(e){a(e)||x().error(`Texture compression failed!`)}finally{u?.decrement(),this._compressionAbortController?.signal.aborted&&(this._compressionAbortController=null),v&&g instanceof ImageBitmap&&g.close()}}_forEachMipmapLevel(t,n=1/0){let{width:r,height:i,depth:a,hasMipmap:o,target:s}=this._descriptor,c=s===32879;if(r==null||i==null||c&&a==null)throw new e(`texture:missing-size`,`Missing texture dimensions for mipmap calculation`);for(let e=0;t(e,r,i,a),!(!o||r===1&&i===1&&(!c||a===1)||e>=n);++e)r=Math.max(1,r>>1),i=Math.max(1,i>>1),c&&(a=Math.max(1,a>>1))}_applySamplingMode(){let e=this._descriptor,t=e.context?.gl,n=e.samplingMode,r=e.samplingMode;n===9985||n===9987?(n=9729,e.hasMipmap||(r=9729)):(n===9984||n===9986)&&(n=9728,e.hasMipmap||(r=9728)),t.texParameteri(e.target,t.TEXTURE_MAG_FILTER,n),t.texParameteri(e.target,t.TEXTURE_MIN_FILTER,r),e.maxMipLevel!=null&&t.texParameteri(e.target,t.TEXTURE_MAX_LEVEL,e.maxMipLevel)}_applyWrapMode(){let e=this._descriptor,t=e.context?.gl;typeof e.wrapMode==`number`?(t.texParameteri(e.target,t.TEXTURE_WRAP_S,e.wrapMode),t.texParameteri(e.target,t.TEXTURE_WRAP_T,e.wrapMode)):(t.texParameteri(e.target,t.TEXTURE_WRAP_S,e.wrapMode.s),t.texParameteri(e.target,t.TEXTURE_WRAP_T,e.wrapMode.t))}_applyShadowMode(){let e=this._descriptor,t=e.context?.gl,n=e.compareEnabled?t.COMPARE_REF_TO_TEXTURE:t.NONE;t.texParameteri(e.target,t.TEXTURE_COMPARE_MODE,n),e.compareEnabled&&t.texParameteri(e.target,t.TEXTURE_COMPARE_FUNC,t.GREATER),o(t)}_applyAnisotropicFilteringParameters(){let e=this._descriptor,t=e.context.capabilities.textureFilterAnisotropic;t&&e.context.gl.texParameterf(e.target,t.TEXTURE_MAX_ANISOTROPY,e.maxAnisotropy??1)}}export{S as default};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
import e from"../../core/Error.js";import{MultiOriginJSONSupport as t}from"../../core/MultiOriginJSONSupport.js";import{whenOnce as n}from"../../core/reactiveUtils.js";import{hasSameCanonicalPortal as r,urlToObject as i}from"../../core/urlUtils.js";import{updateOrigins as a}from"../../core/accessorSupport/originUtils.js";import o from"../../geometry/SpatialReference.js";import{webMercatorToGeographic as s}from"../../geometry/support/webMercatorUtils.js";import{isServerOrServicesAGOLUrl as c}from"../../layers/support/arcgisLayerUrl.js";import{isLayerWithFeatureLayerSource as l,isFeatureCollectionLayer as u}from"../../layers/support/layerUtils.js";import d from"../../portal/Portal.js";import f from"../../portal/PortalItem.js";import{createForItemWrite as ee}from"../../portal/support/jsonContext.js";import{removeTypeKeyword as p,
|
|
2
|
+
import e from"../../core/Error.js";import{MultiOriginJSONSupport as t}from"../../core/MultiOriginJSONSupport.js";import{whenOnce as n}from"../../core/reactiveUtils.js";import{hasSameCanonicalPortal as r,urlToObject as i}from"../../core/urlUtils.js";import{updateOrigins as a}from"../../core/accessorSupport/originUtils.js";import o from"../../geometry/SpatialReference.js";import{webMercatorToGeographic as s}from"../../geometry/support/webMercatorUtils.js";import{isServerOrServicesAGOLUrl as c}from"../../layers/support/arcgisLayerUrl.js";import{isLayerWithFeatureLayerSource as l,isFeatureCollectionLayer as u}from"../../layers/support/layerUtils.js";import d from"../../portal/Portal.js";import f from"../../portal/PortalItem.js";import{createForItemWrite as ee}from"../../portal/support/jsonContext.js";import{removeTypeKeyword as p,typeKeyword as m,addTypeKeyword as te,toggleTypeKeyword as h,hasTypeKeyword as g}from"../../portal/support/portalItemUtils.js";import{project as ne}from"../../rest/geometryService/project.js";import _ from"../../rest/support/ProjectParameters.js";import{hasDeveloperBasemapLayer as v,isDeveloperBasemapLayer as y}from"../../support/basemapUtils.js";import{saveResources as b}from"./resourceUtils.js";import{beforeSave as x,evaluateWriteErrors as S,hasCharts as re}from"./saveUtils.js";import{hasWebDocumentAsPrimaryContent as C,hasWebDocumentAsResource as w}from"./utils.js";const T=[`NatGeo_World_Map`,`Ocean_Basemap`,`USA_Topo_Maps`,`World_Imagery`,`World_Street_Map`,`World_Terrain_Base`,`World_Topo_Map`,`World_Hillshade`,`Canvas/World_Light_Gray_Base`,`Canvas/World_Light_Gray_Reference`,`Canvas/World_Dark_Gray_Base`,`Canvas/World_Dark_Gray_Reference`,`Ocean/World_Ocean_Base`,`Ocean/World_Ocean_Reference`,`Reference/World_Boundaries_and_Places`,`Reference/World_Reference_Overlay`,`Reference/World_Transportation`].map(e=>e.toLowerCase());async function E(e,t,r){r??={},k(e,t),await n(()=>!t.updatingFromView),await t.load(),await M(t),await x(t),await j(e,t);let i=t.portalItem,{json:a,jsonContext:o}=await D(t,i,e.origin,t.portalItemResourcePath);return S(o,{errorName:`${e.name}:save`},r),await N(t,i),await ue(e,t,i,a,o),await Promise.all([C(i)?t.updateItemThumbnail():null,b(t.resourceReferences,o)]),i}async function D(e,t,n,r){let i=w(t),a=i&&t.id===e.portalItem?.id&&r!==e.portalItemResourcePath,o=ee(t,n,{withResources:!0,forceNewItemContext:a});o.portalItemResourcePath=i?r:null;let s=e.write({},o);return await Promise.all(o.resources.pendingOperations),{json:s,jsonContext:o}}async function O(e,t,r,i){i??={};let a=t.portalItem,o=await ie(e,t,r,i);await n(()=>!t.updatingFromView),await t.load(),await M(t),await x(t),await j(e,t);let{json:s,jsonContext:c}=await D(t,o,e.origin,i.portalItemResourcePath);S(c,{errorName:`${e.name}:save`},i),await V(t,o);let l,u=C(o);return u&&(l=t.getThumbnailState()),await Y(e,t,o,s,c,i)&&(t.resourceReferences.portalItem=o),l&&t.restoreThumbnailFromState(l),await Promise.all([u?t.updateItemThumbnail(a):null,b(t.resourceReferences,c)]),o}function k(t,n){if(!n.portalItem)throw new e(`${t.name}:portal-item-not-set`,`Portal item to save to has not been set on the WebMap`);A(t,n.portalItem)}function A(t,n){let r=n.type,i=t.supportedItemTypes;if(!r||!i.has(r))throw new e(`${t.name}:portal-item-wrong-type`,`Portal item needs to have one of these types: '${Array.from(i).join(`', '`)}'`)}async function j(t,n){if(t.name!==`linkchart`&&!n.basemap?.baseLayers.length)throw new e(`${t.name}:save`,`Map does not have a valid basemap with a base layer.`)}async function ie(t,n,r,i){let a=f.from(r);a.id&&await a.load();let{portalItemResourcePath:o}=i,{name:s,primaryItemType:c}=t;if(w(a)){if(!o)throw new e(`${s}:missing-portal-item-resource-path`,`'portalItemResourcePath' is required to save a map to '${a.type}' item`);if(o===n.portalItemResourcePath&&a.id===n.portalItem?.id)throw new e(`${s}:invalid-portal-item-resource-path`,`Target 'portalItemResourcePath' should be different from '${s}.portalItemResourcePath'`);return a}if(o)throw new e(`${s}:portal-item-resource-path-not-supported`,`'portalItemResourcePath' is not supported when saving a map to '${c}' item`);return a.id&&(a=a.clone(),a.id=null),a.type||(a.type=c),a.portal||(a.portal=d.getDefault()),A(t,a),a}function M(e){let t=[];return e.basemap&&t.push(e.basemap.load()),e.ground&&t.push(e.ground.load()),Promise.allSettled(t).then(()=>{})}async function N(e,t){w(t)||(t.extent=await q(e.portalItem,e.initialViewProperties.viewpoint.targetGeometry),await H(e,t))}const P=m.JSAPI,F=`CollectorDisabled`,I=`OfflineDisabled`,L=`Workforce Project`,R=`Workforce Worker`,z=`Workforce Dispatcher`,B=m.DEVELOPER_BASEMAP;async function V(e,t){w(t)||(p(t,F),p(t,`FieldMapsDisabled`),p(t,m.METADATA),p(t,I),p(t,`Offline Map Areas`),p(t,z),p(t,L),p(t,R),await N(e,t))}async function H(e,t){te(t,P),await U(e),h(t,`Collector`,!g(t,F)&&!g(t,L)&&!g(t,R)&&!g(t,z)&&G(e)),h(t,`Data Editing`,G(e)),h(t,`Offline`,!g(t,I)&&K(e)),h(t,B,v(e.basemap)),h(t,`UtilityNetwork`,!!e.utilityNetworks?.length),h(t,`ParcelFabric`,!!e.parcelFabric),h(t,`IPS`,!!e.ipsInfo),h(t,m.CHARTS,re(e)),t.typeKeywords&&=t.typeKeywords.filter((e,t,n)=>n.indexOf(e)===t)}function U(e){let t=W(e).map(e=>e.load()).toArray();return Promise.allSettled(t).then(()=>{})}function W(e){return e.allLayers.concat(e.allTables)}function G(e){return W(e).some(e=>e.loaded&&l(e)&&e.capabilities.operations.supportsEditing&&`editingEnabled`in e&&e.editingEnabled&&(e.type!==`subtype-group`||e.sublayers.some(e=>e.editingEnabled)))}function K(e){return W(e).filter(e=>e.type!==`group`).every(t=>t.loaded&&oe(e,t))}async function q(e,t){let n=t.clone().normalize(),r;if(n.length>1)for(let e of n)r?e.width>r.width&&(r=e):r=e;else r=n[0];return J(e,r)}async function J(e,t){let n=t.spatialReference;if(n.isWGS84)return t.clone();if(n.isWebMercator)return s(t);let{getGeometryServiceURL:r}=await import(`../../portal/support/geometryServiceUtils.js`),i=await r(e),a=new _({geometries:[t],outSpatialReference:o.WGS84});return(await ne(i,a))[0]}function ae(e){return u(e)||e.type===`map-notes`||e.type===`route`||e.type===`sketch`}function oe(e,t){return l(t)&&t.capabilities.operations.supportsSync||ae(t)&&!t.portalItem||se(t)&&!ce(t)&&t.spatialReference.equals(e.initialViewProperties.spatialReference)}function se(e){return e.type===`imagery-tile`?e.supportsExportMapTiles():(e.type===`tile`||e.type===`vector-tile`)&&(e.capabilities.operations.supportsExportTiles||le(e)||y(e))}function ce(e){return e.type===`vector-tile`&&Object.keys(e.sourceNameToSource).length>1}function le(e){return e.type===`tile`&&c(e.url)&&T.some(t=>e.url?.toLowerCase().includes(`/`+t+`/`))}async function ue(e,t,n,r,i){C(n)?await n.update({data:r}):(await n.portal.signIn(),await n.resourceFromPath(t.portalItemResourcePath).update($(r))),Q(e,t,n,r,i)}async function Y(t,n,r,i,a,o){let s=n.portalItem,c={item:s,authenticated:!!(s?.id&&s.portal.user)},l=r.portal;await l.signIn();let{copyAllowed:u,itemReloaded:d}=await X(c,l);if(c.authenticated||=d,!u)throw new e(`${t.name}:save-as-copy-not-allowed`,`Owner of this map does not allow others to save a copy`);let f=!1;if(C(r))f=await Z(r,c,i,o);else{let e=r.resourceFromPath(o.portalItemResourcePath);await r.addResource(e,$(i))}return n.portalItem=r,n.portalItemResourcePath=o.portalItemResourcePath,Q(t,n,r,i,a),f}async function X(e,t){let{item:n,authenticated:r}=e;return n&&C(n)&&n.id&&n.typeKeywords?.includes(`useOnly`)?n.portal.portalHostname===t.portalHostname?(r||await n.reload(),{copyAllowed:n.itemControl===`admin`||n.itemControl===`update`,itemReloaded:!0}):{copyAllowed:!1,itemReloaded:!1}:{copyAllowed:!0,itemReloaded:!1}}async function Z(e,t,n,i){let a=e.portal,{item:o}=t,{folder:s,copyAllResources:c}=i,l=!1;if(c&&o?.id&&o.type===e.type&&r(o.portal.url,a.url)&&parseInt(o.portal.currentVersion,10)>=2023){let{total:e}=await o.fetchResources();l=!!e}if(l){let t=await o.copy({copyResources:`all`,folder:s});e.id=t.id,e.portal=t.portal;let r=e.toJSON();await e.load(),e.read(r),await e.update({data:n})}else await a.user.addItem({item:e,folder:s,data:n});return l}function Q(e,n,r,o,s){t.prototype.read.call(n,{version:o.version,authoringApp:o.authoringApp,authoringAppVersion:o.authoringAppVersion},{origin:e.origin,ignoreDefaults:!0,url:r.itemUrl?i(r.itemUrl):void 0}),a(s),n.resourceInfo=o}function $(e){return new Blob([JSON.stringify(e)],{type:`application/json`})}export{D as createJSON,Z as initializeNewItem,X as isCopyAllowed,E as save,O as saveAs};
|
package/webscene/Slide.d.ts
CHANGED
|
@@ -186,8 +186,7 @@ export default class Slide extends SlideSuperclass {
|
|
|
186
186
|
* @param options - Creation options. See properties below for object specifications.
|
|
187
187
|
* @returns When resolved, returns the created slide.
|
|
188
188
|
* @example
|
|
189
|
-
* // Creates a slide from the view and
|
|
190
|
-
* // adds it to the webscene
|
|
189
|
+
* // Creates a slide from the view and adds it to the webscene
|
|
191
190
|
* Slide.createFrom(view).then(function(slide){
|
|
192
191
|
* webscene.presentation.slides.add(slide);
|
|
193
192
|
* });
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import type Accessor from "../../core/Accessor.js";
|
|
2
2
|
|
|
3
|
-
/**
|
|
3
|
+
/**
|
|
4
|
+
* @deprecated since 5.2. Use the `hideDirectionalButtons`, `showRotationResetButton`, and `showRotationSlider` properties on the [Directional Pad component](/references/map-components/components/arcgis-directional-pad/) instead.
|
|
5
|
+
* @since 5.0
|
|
6
|
+
*/
|
|
4
7
|
export interface VisibleElementsProperties extends Partial<Pick<VisibleElements, "directionalButtons" | "rotationResetButton" | "rotationSlider">> {}
|
|
5
8
|
|
|
6
9
|
/**
|
|
@@ -8,6 +11,7 @@ export interface VisibleElementsProperties extends Partial<Pick<VisibleElements,
|
|
|
8
11
|
* This provides the ability to turn individual elements of the widget's display on/off.
|
|
9
12
|
* Alternatively, developers may also use CSS (e.g. `display: none`) to show/hide elements, such as labels.
|
|
10
13
|
*
|
|
14
|
+
* @deprecated since 5.2. Use the `hideDirectionalButtons`, `showRotationResetButton`, and `showRotationSlider` properties on the [Directional Pad component](/references/map-components/components/arcgis-directional-pad/) instead.
|
|
11
15
|
* @since 5.0
|
|
12
16
|
*/
|
|
13
17
|
export default class VisibleElements extends Accessor {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
import{__decorate as e}from"tslib";import t from"../../../Graphic.js";import n from"../../../core/Accessor.js";import{createTask as r}from"../../../core/asyncUtils.js";import{abortMaybe as i}from"../../../core/maybe.js";import{throwIfAborted as a}from"../../../core/promiseUtils.js";import{watch as o,initial as s,when as c}from"../../../core/reactiveUtils.js";import{throttle as l}from"../../../core/throttle.js";import{property as u,subclass as d}from"../../../core/accessorSupport/decorators.js";import f from"../../../geometry/Point.js";import
|
|
2
|
+
import{__decorate as e}from"tslib";import t from"../../../Graphic.js";import n from"../../../core/Accessor.js";import{createTask as r}from"../../../core/asyncUtils.js";import{abortMaybe as i}from"../../../core/maybe.js";import{throwIfAborted as a}from"../../../core/promiseUtils.js";import{watch as o,initial as s,when as c}from"../../../core/reactiveUtils.js";import{throttle as l}from"../../../core/throttle.js";import{property as u,subclass as d}from"../../../core/accessorSupport/decorators.js";import f from"../../../geometry/Point.js";import p from"../../../popup/ElementExpressionInfo.js";import m from"../../../popup/content/FieldsContent.js";import h from"../../../popup/content/MediaContent.js";import g from"../../../popup/content/TextContent.js";import{compileExpression as _}from"../../../popup/support/arcadeFeatureUtils.js";import v from"../FeatureContent/FeatureContentViewModel.js";import y from"../FeatureFields/FeatureFieldsViewModel.js";import b from"../FeatureMedia/FeatureMediaViewModel.js";let x=class extends n{constructor(e){super(e),this._compileTask=null,this._evaluateTask=null,this.expressionInfo=null,this.graphic=null,this.contentElementViewModel=null,this.interceptor=null,this.location=null,this.view=null,this._createVM=()=>{let e=this.contentElement?.type;this.contentElementViewModel?.destroy();let t=e===`fields`?new y:e===`media`?new b:e===`text`?new v:null;this._set(`contentElementViewModel`,t)},this._compileThrottled=l(this._startCompile,()=>this.notifyChange(`state`),1,this),this._evaluateThrottled=l(this._startEvaluate,()=>this.notifyChange(`state`),1,this),this.addHandles([o(()=>[this.expressionInfo,this.graphic],()=>this._compileThrottled(),s),o(()=>[this.contentElement],()=>this._createVM(),s),c(()=>{if(!this._compileTask?.finished)return null;let e=this._compileTask.value,t=e?.dependencies;return[e,this.spatialReference,this.map,this.view,t?.has(`view-scale`)?this.view?.scale:null,t?.has(`view-time-extent`)?this.view?.timeExtent?.start:null,t?.has(`view-time-extent`)?this.view?.timeExtent?.end:null]},([e])=>this._evaluateThrottled(e))])}initialize(){this.addHandles([this._compileThrottled,this._evaluateThrottled])}destroy(){this._compileTask=i(this._compileTask),this._evaluateTask=i(this._evaluateTask),this.contentElementViewModel?.destroy(),this._set(`contentElementViewModel`,null)}get contentElement(){return this._evaluateTask?.value}get spatialReference(){return this.view?.spatialReference??null}set spatialReference(e){this._override(`spatialReference`,e)}get state(){let{contentElement:e,contentElementViewModel:t}=this;return this._compileThrottled.hasPendingUpdates()||this._evaluateThrottled.hasPendingUpdates()||!this._compileTask?.finished||!this._evaluateTask?.finished?`loading`:!e&&!t?`disabled`:`ready`}get map(){return this.view?.map??null}set map(e){this._override(`map`,e)}_startCompile(){this._evaluateTask=i(this._evaluateTask),this._compileTask=i(this._compileTask),this._compileTask=r(async e=>{let{expressionInfo:t,graphic:n}=this,r=t?.expression;if(!r||!n)return null;let i=await _({expression:r,graphic:n});return a(e),i})}_startEvaluate(e){this._evaluateTask=i(this._evaluateTask),this._evaluateTask=r(async t=>{let{graphic:n}=this;if(!e||!n)return null;let{interceptor:r,spatialReference:i,map:o,location:s,view:c}=this,l=await e.evaluate({graphic:n,interceptor:r,location:s,map:o,options:{signal:t},spatialReference:i,view:c});a(t);let u=l;if(!u||u.declaredClass!==`esri.arcade.Dictionary`)return null;let d=await u.castAsJsonAsync(t);a(t);let f=d?.type,p=f===`media`?h.fromJSON(d):f===`text`?g.fromJSON(d):f===`fields`?m.fromJSON(d):null;return p.type===`media`&&!p.mediaInfos||p.type===`fields`&&!p.fieldInfos||p.type===`text`&&!p.text?null:p})}};e([u()],x.prototype,`_compileTask`,void 0),e([u()],x.prototype,`_evaluateTask`,void 0),e([u({type:p})],x.prototype,`expressionInfo`,void 0),e([u({type:t})],x.prototype,`graphic`,void 0),e([u({readOnly:!0})],x.prototype,`contentElement`,null),e([u({readOnly:!0})],x.prototype,`contentElementViewModel`,void 0),e([u()],x.prototype,`interceptor`,void 0),e([u({type:f})],x.prototype,`location`,void 0),e([u()],x.prototype,`spatialReference`,null),e([u({readOnly:!0})],x.prototype,`state`,null),e([u()],x.prototype,`map`,null),e([u()],x.prototype,`view`,void 0),x=e([d(`esri.widgets.Feature.FeatureExpression.FeatureExpressionViewModel`)],x);export{x as default};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
import{__decorate as e}from"tslib";import t from"../../core/Accessor.js";import{createTask as n}from"../../core/asyncUtils.js";import r from"../../core/Collection.js";import i from"../../core/Error.js";import a from"../../core/Logger.js";import{throwIfAborted as o}from"../../core/promiseUtils.js";import{watch as s,initial as c,syncAndInitial as l}from"../../core/reactiveUtils.js";import{Milliseconds as u}from"../../core/time.js";import{isBlobProtocol as d}from"../../core/urlUtils.js";import{property as f,subclass as p}from"../../core/accessorSupport/decorators.js";import m from"../../geometry/Polygon.js";import h from"../../webdoc/Widgets.js";import g from"../../webdoc/widgets/FloorFilter.js";import{isWebMap as _}from"../../webmap/utils.js";import{GoTo as v}from"../support/GoTo.js";function y(e){return e.declaredClass===`esri.WebScene`}let b=class extends v(t){constructor(e){super(e),this.filterMenuOpen=!1,this.filterMenuType=`site`,this.filterMode=`base-floors`,this.levelsExpanded=!0,this.searchTerm=null,this.view=null,this._updateFloorFilterTask=null,this._viewHeightBreakpoint=null,this._viewWidthBreakpoint=null}initialize(){this.addHandles([s(()=>this.view?.map,e=>{this._updateFloorFilterTask!=null&&(this._updateFloorFilterTask.abort(),this._updateFloorFilterTask=null),this._updateFloorFilterTask=n(async t=>{await this._updateFloorFilterFromMap(e),o(t),this._setInitialViewState(e)}),this._watchMapLayers(e)},c),s(()=>this.view,(e,t)=>{this._unregisterWidget(t),this._registerWidget(e),this._watchSearchResults(e)},l),s(()=>this.mediaLayer,e=>{this._watchLayerVisibility(e)},l),s(()=>this.view?.widthBreakpoint??null,e=>{this._viewWidthBreakpoint=e}),s(()=>this.view?.heightBreakpoint??null,e=>{this._viewHeightBreakpoint=e}),s(()=>this.facility,()=>void this.getOverlays()),s(()=>this.level,e=>this._updateMediaLayer(e))])}destroy(){if(this._unregisterWidget(this.view),this.mediaLayer&&this.view?.map.remove(this.mediaLayer),this.overlaysByLevel){for(let e of this.overlaysByLevel.values()){let t=e.image.image;d(t)&&URL.revokeObjectURL(t)}this.overlaysByFacility?.clear(),this.overlaysByLevel.clear()}this.view=null,this._updateFloorFilterTask!=null&&(this._updateFloorFilterTask.abort(),this._updateFloorFilterTask=null)}set enabled(e){this._callOverride(`enabled`,e)}set facility(e){if(e&&this._isOverridden(`facility`)){let t=this.getFacility(e);this.hasMultipleSites&&(this.site=t?.siteId||null)}this._callOverride(`facility`,e)}set filterFeatures(e){this._callOverride(`filterFeatures`,e)}set filterLayers(e){this._callOverride(`filterLayers`,e)}get floorVisibilityMode(){return this.view&&y(this.view?.map)?this.view.map.widgets?.floorFilter?.floorVisibilityMode??`belowSelected`:`belowSelected`}get hasFacilities(){return this.filterLayers?.facilityLayer!=null&&this.filterFeatures?.facilities?.facilitiesInfo?.length>0}get hasLevels(){return this.filterLayers?.levelLayer!=null&&this.filterFeatures?.levels?.levelsInfo?.length>0}get hasMultipleSites(){return this.filterLayers?.siteLayer!=null&&this.filterFeatures?.sites?.sitesInfo?.length>1}get isNormalMode(){let e=!0,t=this._viewWidthBreakpoint;return(this._viewHeightBreakpoint===`xsmall`||t===`xsmall`)&&(e=!1),e}set level(e){if(!e){this._callOverride(`level`,e),this.facility=null,this.site=null,this.setFloors(null);return}let t=null,n=null,r=e?.split(`--`);r?.length>1&&r[0]===`all`?(n=r[1],t={id:e,facilityId:n,shortName:null,longName:null,levelNumber:null,verticalOrder:null}):(t=this.getLevel(e),n=t?.facilityId??null),this.level===e&&!this.isNormalMode&&!this.levelsExpanded?this.getFacilityLevels(n)?.length>1&&(this.levelsExpanded=!0):(t&&this.hasFacilities&&this.hasLevels?(this.facility=n,this.hasMultipleSites&&(this.site=this.getFacility(n)?.siteId||null),this.setFloors(t)):this._isOverridden(`level`)&&(this.facility=null,this.site=null,this.hasMultipleSites&&(this.filterMenuType=`site`),this.setFloors(null)),this._callOverride(`level`,e))}set longNames(e){this._callOverride(`longNames`,e)}set minimized(e){this._callOverride(`minimized`,e)}set pinnedLevels(e){this._callOverride(`pinnedLevels`,e)}get selectedVerticalOrder(){return _(this.view?.map)?this.view.map.resourceInfo?.widgets?.floorFilter?.selectedVerticalOrder??null:null}set site(e){this._callOverride(`site`,e)}get state(){return this.view&&this.filterFeatures&&this.hasFacilities&&this.hasLevels?`ready`:this.view&&!this.filterFeatures?`loading`:`disabled`}get useVerticalOrder(){return this.view?.map==null?!1:_(this.view?.map)||y(this.view.map)?this.view.map.widgets?.floorFilter?.useVerticalOrder??!1:!1}filterFacilities(e){let t=e;return this.searchTerm&&(this.searchTerm=this.searchTerm.trim(),t=e.filter(e=>{let{name:t}=e;return t.toLowerCase().includes(this.searchTerm?.toLowerCase())})),this.site&&(t=t.filter(e=>e.siteId===this.site)),t.sort((e,t)=>{let n=e.name,r=t.name;return n.localeCompare(r,void 0,{sensitivity:`base`})})}filterSites(e){let t=e;return this.searchTerm&&(this.searchTerm=this.searchTerm.trim(),t=e.filter(e=>{let{name:t}=e;return t.toLowerCase().includes(this.searchTerm?.toLowerCase())})),t.sort((e,t)=>{let n=e.name,r=t.name;return n.localeCompare(r,void 0,{sensitivity:`base`})})}getBaseLevel(e){let t=this.filterFeatures?.levels?.levelsInfo,n=null;if(e){let{id:r}=e;if(t&&t.length>0&&(t.forEach(e=>{e.verticalOrder===0&&e.facilityId===r&&(n=e)}),!n)){let e=null;t.forEach(t=>{t.facilityId===r&&(e?(t.verticalOrder??0)>=0?e.verticalOrder!=null&&(e.verticalOrder<0||(t.verticalOrder??0)<e.verticalOrder)&&(e=t):e.verticalOrder!=null&&t.verticalOrder!=null&&e.verticalOrder<0&&t.verticalOrder>e.verticalOrder&&(e=t):e=t)}),e&&(n=e)}}return n}getFacility(e){return this.filterFeatures?.facilities?.facilitiesInfo?.find(t=>t.id===e)??null}getFacilityLevels(e){return!e||!this.filterFeatures?.levels?.levelsInfo?[]:this.filterFeatures.levels.levelsInfo.filter(t=>t.facilityId===e).sort((e,t)=>{let n=e.verticalOrder??0,r=t.verticalOrder??0;return n>r?-1:n===r?0:1})}getLevel(e){return this.filterFeatures?.levels?.levelsInfo?.find(t=>t.id===e)??null}async getOverlays(e=!1){let{facility:t,level:n,mediaLayer:i,overlaysByFacility:a,overlaysByLevel:o,view:s}=this;if(_(s?.map)&&i){if((i?.source).elements.removeAll(),t?.length&&(!a?.has(t)||e)){a?.set(t,new r);let e=s.map.floorInfo?.levelLayer?.layerId,n=s.map.findLayerById(e??``);if(!n||s.type!==`2d`)return;let i=await this._getAttachments(n,t),{default:c}=await import(`../../request.js`),l=Object.keys(i).map(async e=>{let r=i[e],s=r.find(e=>e.contentType===`application/json`);if(!s?.url)return;let l=new URL(s.url);n.gdbVersion?.length&&l.searchParams.set(`gdbVersion`,n.gdbVersion);let{data:u}=await c(l.toString(),{responseType:`json`}),d=r.find(e=>e.name===u.name),f=d?.url??``;if(f?.length>0){let e=new URL(f);e.searchParams.delete(`token`),n.gdbVersion?.length&&e.searchParams.set(`gdbVersion`,n.gdbVersion);let{default:r}=await import(`../../layers/support/ControlPointsGeoreference.js`),i=r.fromJSON(u.georeference),c=await this.toImageElement(e.toString(),i,u.opacity,u.clipImage,u.geometry);await c.load();let l={...u,attachments:[s,d],facilityId:t,image:c,source:JSON.stringify(u),url:e.toString()};o?.set(l.levelId,l),a?.get(t)?.push(l)}});await Promise.all(l)}this._updateMediaLayer(n)}}getSite(e){return this.filterFeatures?.sites?.sitesInfo?.find(t=>t.id===e)??null}async goTo(e){let{view:t}=this;if(!t||!e)return;let{geometry:n}=e;if(n?.extent){let e=e=>{this.callGoTo({target:e,options:{duration:u(1e3),easing:`quad-in-out-coast`}})};if(n.hasZ&&n.spatialReference?.vcsWkid!==t.spatialReference?.vcsWkid){let{projectIsLoaded:r,projectLoad:i,projectExecute:a}=await import(`../../geometry/operators/projectOperator.js`);r()||await i();let o=a(n.extent,t.spatialReference.clone(),{zConversionDisabled:!0});o&&e(o)}else e(n.extent)}}setFloors(e){let{view:t}=this;t&&(t?.map?.allLayers?.forEach(e=>{e.type===`feature`&&this._computeViewAllModeFloors(e)}),t.floors=new r(this._computeFloors(e)))}async toImageElement(e,t,n,r,i){let{default:o}=await import(`../../layers/support/ImageElement.js`),{facility:s}=this,c=()=>new o({image:e,georeference:t,opacity:n});if(r)try{let r=i?m.fromJSON(i):this.getFacility(s)?.geometry;if(r==null)return c();let{pixelRings:a,width:l,height:u}=await this._polygonToImagePixels(t,r),d=await this._imagePolygonToBlob(e,a,l,u);return new o({image:URL.createObjectURL(d),georeference:t,opacity:n})}catch(e){return a.getLogger(this).warn(`Unable to clip image; using full image instead: ${e.message}`,e),c()}return c()}updateWebDocument(e){if(_(e)||y(e)){let t={enabled:this.enabled,longNames:this.longNames,minimized:this.minimized,pinnedLevels:this.pinnedLevels,site:this.site??null,facility:this.facility??null,level:this.level??null,useVerticalOrder:this.useVerticalOrder,selectedVerticalOrder:this.selectedVerticalOrder};y(e)&&(t.floorVisibilityMode=this.floorVisibilityMode);let n=new g(t);e.widgets??=new h,e.widgets.floorFilter=n}}_computeFloors(e){if(this.filterMode===`single-floor`)this._computeSingleFloor(e);else if(this.filterMode===`base-floors`)return this.view?.type===`3d`?this._computeBaseFloors3D(e):this._computeBaseFloors(e);return this._computeEmptyFloors()}_computeSingleFloor(e){if(!e)return this._computeEmptyFloors();let t=[];return e?.id===`all`?this.getFacilityLevels(e.facilityId).forEach(e=>{e.id&&t.push(e.id)}):e&&t.push(e.id),t}_computeBaseFloors(e){let t=this.filterFeatures?.levels?.levelsInfo;if(!t?.length)return this._computeEmptyFloors();let n=[];e?.id===`all`?this.getFacilityLevels(e.facilityId).forEach(e=>{e.id&&n.push(e.id)}):e&&n.push(e.id);let r=e?.facilityId,i=e?.verticalOrder,a=(e,t)=>{e===0&&n.push(t)};return t.forEach(e=>{let{id:t,facilityId:o,verticalOrder:s}=e;!r&&!n.includes(t)?a(s,t):o!==r&&!n.includes(t)&&(this.useVerticalOrder?s===i&&n.push(t):a(s,t))}),n}_computeBaseFloors3D(e){let t=this.filterFeatures?.levels?.levelsInfo;if(!t?.length)return this._computeEmptyFloors();let n=[],r=e?.id.split(`--`)??[],i=r?.length>1&&r[0]===`all`;i?this.getFacilityLevels(e?.facilityId).forEach(e=>{e.id&&n.push(e.id)}):e&&n.push(e.id);let a=e?.facilityId,o=e?.verticalOrder;return t.forEach(e=>{let{id:t,facilityId:r,verticalOrder:s}=e;if(!a&&!n.includes(t))n.push(t);else if(!n.includes(t)){let{floorVisibilityMode:e,useVerticalOrder:c}=this,l=s<=o;r===a?e===`belowSelected`&&l&&n.push(t):(i||!c||e===`selectedOnly`&&s===o||e===`belowSelected`&&l)&&n.push(t)}}),n}_computeEmptyFloors(){return[]}async _setFilterLayers(){let{view:e}=this;if(e&&!this._isOverridden(`filterLayers`)){if(!_(e.map)&&!y(e.map))throw new i(`floorfilter:unsupported-map`,`Map must be a webmap or webscene`);{let t=e.map,n=t?.allLayers;if(n?.items?.length>0){let e={siteLayer:null,facilityLayer:null,levelLayer:null},r=t.floorInfo?.siteLayer?.layerId,i=t.floorInfo?.facilityLayer?.layerId,a=t.floorInfo?.levelLayer?.layerId,o=t.floorInfo?.siteLayer?.sublayerId||t.floorInfo?.facilityLayer?.sublayerId||t.floorInfo?.levelLayer?.sublayerId;if(!i||!a)return;let s=n.items.filter(e=>e.type===`feature`||e.type===`scene`),c=n.items.filter(e=>e.type===`map-image`);if(c?.length>0&&o){await Promise.all(c.map(e=>e.load()));let n=t.floorInfo?.siteLayer?.sublayerId,o=t.floorInfo?.facilityLayer?.sublayerId,s=t.floorInfo?.levelLayer?.sublayerId;c.forEach(t=>{let c=t.id,l=t?.allSublayers,u=l?.items;(c===r||c===i||c===a)&&u?.length>0&&l.items.forEach(t=>{let i=t.id;c===r&&i===n?e.siteLayer=t:i===o?e.facilityLayer=t:i===s&&(e.levelLayer=t)})})}s?.length>0&&s.forEach(t=>{let n=t.id;n===r?e.siteLayer=t:n===i?e.facilityLayer=t:n===a&&(e.levelLayer=t)}),this.filterLayers=e}}}}async _getAttachments(e,t){let{view:n}=this;if(_(n?.map)){let{facilityIdField:r}=n.map.floorInfo?.levelLayer??{};if(e&&n.type===`2d`&&t?.length>0&&e.capabilities.data.supportsAttachment)return e.queryAttachments({returnMetadata:!0,where:`${r} = '${t}'`})}return{}}async _getFilterFeatures(){if(this._isOverridden(`filterFeatures`))return this.filterFeatures;let[e,t,n]=await Promise.all([this._getSites(),this._getFacilities(),this._getLevels()]);return{sites:e,facilities:t,levels:n}}async _getSites(){let e={sitesInfo:[]},{filterLayers:t,view:n}=this,r=n?.map,{siteLayer:i}=t;if(!i||!r?.floorInfo?.siteLayer)return e;let a=i.createQuery();a.returnGeometry=!0,a.outFields=[`*`],a.returnZ=!0,`type`in i&&i.type===`scene`&&(a.multipatchOption=`xyFootprint`);let{siteIdField:o,nameField:s}=r.floorInfo.siteLayer,c=await i.queryFeatures(a);if(c?.features?.length>0){let t=c.features,n=i?.fieldsIndex.get(o)?.name||o,r=i?.fieldsIndex.get(s)?.name||s;n!=null&&r!=null&&t.forEach(t=>{let i=t.attributes,a=t.geometry,o=i[n],s=i[r];o&&s&&e.sitesInfo.push({id:o,name:s,geometry:a})})}return e}async _getFacilities(){let{filterLayers:e,view:t}=this,n=t?.map,{facilityLayer:r}=e,i={facilitiesInfo:[]};if(!r||!n?.floorInfo?.facilityLayer)return i;let a=r.createQuery();a.returnGeometry=!0,a.outFields=[`*`],a.returnZ=!0,`type`in r&&r.type===`scene`&&(a.multipatchOption=`xyFootprint`);let{facilityIdField:o,siteIdField:s,nameField:c}=n.floorInfo.facilityLayer,l=await r.queryFeatures(a);if(l?.features?.length>0){let e=l.features,t=r?.fieldsIndex.get(o)?.name||o,n=r?.fieldsIndex.get(s)?.name||s,a=r?.fieldsIndex.get(c)?.name||c;t&&n&&a&&e.forEach(e=>{let r=e.attributes,o=e.geometry,s=r[t],c=r[n],l=r[a];s&&l&&i.facilitiesInfo.push({id:s,siteId:c,name:l,geometry:o})})}return i}async _getLevels(){let{filterLayers:e,view:t}=this,n=t?.map,{levelLayer:r}=e,i={levelsInfo:[]};if(!r||!n?.floorInfo?.levelLayer)return i;let a=r.createQuery();a.returnGeometry=!0,a.outFields=[`*`],a.returnZ=!0;let{levelIdField:o,facilityIdField:s,longNameField:c,shortNameField:l,levelNumberField:u,verticalOrderField:d}=n.floorInfo.levelLayer,f=await r.queryFeatures(a);if(f?.features?.length>0){let e=f.features,t=r?.fieldsIndex.get(o)?.name||o,n=r?.fieldsIndex.get(s)?.name||s,a=r?.fieldsIndex.get(c)?.name||c,p=r?.fieldsIndex.get(l)?.name||l,m=r?.fieldsIndex.get(u)?.name||u,h=r?.fieldsIndex.get(d)?.name||d;t&&n&&a&&p&&m&&h&&e.forEach(e=>{let r=e.attributes,o=r[t],s=r[n],c=r[a],l=r[p],u=r[m],d=r[h];o&&s&&c&&l&&typeof u==`number`&&typeof d==`number`&&i.levelsInfo.push({id:o,facilityId:s,longName:c,shortName:l,levelNumber:u,verticalOrder:d})})}return i}async _imagePolygonToBlob(e,t,n,r){let{getImageData:a}=await import(`../../core/imageUtils.js`),o=await a(e),s=new OffscreenCanvas(n,r),c=s.getContext(`2d`);if(!c)throw new i(`floorfilter:floor-plan-overlay`,`Unable to obtain a rendering context from the canvas.`);let l=new Path2D;for(let e of t)if(!(e.length<3)){l.moveTo(e[0].x,e[0].y);for(let t=1;t<e.length;t++)l.lineTo(e[t].x,e[t].y);l.closePath()}return c.save(),c.clip(l,`evenodd`),c.drawImage(o,0,0,n,r),c.restore(),await s.convertToBlob({type:`image/png`})}async _polygonToImagePixels(e,t){if(e?.type!==`control-points`)throw new i(`floorfilter:floor-plan-overlay`,"Expected a `ControlPointsGeoreference`.");let{default:n}=await import(`../../geometry/Point.js`);return{pixelRings:t.rings.map(r=>r.map(([r,a])=>{let o=new n({x:r,y:a,spatialReference:t.spatialReference}),s=e.toSource(o);if(!s)throw new i(`floorfilter:floor-plan-overlay`,`toSource() returned null; check spatial references and projectOperator.`);return{x:s.x,y:s.y}})),width:e.width,height:e.height}}_registerWidget(e){e?.registerComponent(this)}_unregisterWidget(e){e?.unregisterComponent(this)}_watchLayerVisibility(e){if(this.filterLayers?.levelLayer?.type===`feature`&&e){let t=this.filterLayers?.levelLayer;this.addHandles(s(()=>t.visible,t=>{e.visible=t},l))}}_watchMapLayers(e){this.removeHandles(`layers-handle`),e&&this.addHandles(e.allLayers.on(`after-remove`,t=>{if(t.item){let r=e.floorInfo,i=r?.siteLayer?.layerId??``,a=r?.facilityLayer?.layerId??``,s=r?.levelLayer?.layerId??``;(t.item.id===a||t.item.id===s||t.item.id===i)&&(this._updateFloorFilterTask!=null&&(this._updateFloorFilterTask.abort(),this._updateFloorFilterTask=null),this._updateFloorFilterTask=n(async t=>{o(t),this.level=null,this.filterMenuOpen=!1,this._clearOverride(`filterLayers`),this._clearOverride(`filterFeatures`),this._setInitialViewState(e)}))}}),`layers-handle`)}_watchSearchResults(e){e?.on(`select-result-floor`,e=>{let t=this.getLevel(e);t&&this.level!==e&&(this.level=e,this.setFloors(t))})}async _setInitialViewState(e){if(this.view)try{await this.view.when(),await this._setFilterLayers();let t=await this._getFilterFeatures();if(!t)return;if(this.filterFeatures=t,!this.hasFacilities||!this.hasLevels){a.getLogger(this).error(`Facilities and Levels are required for the Floor Filter widget`);return}if(this.hasMultipleSites||(this.filterMenuType=`facility`),this.facility&&this.level){this.filterMenuType=`facility`;let e=this.getFacility(this.facility),t=this.getLevel(this.level);this.site||=e?.siteId||void 0,this.setFloors(t)}else if(this.facility&&!this.level){this.filterMenuType=`facility`;let e=this.getFacility(this.facility),t=this.getBaseLevel(e);this.site||=e?.siteId||void 0,this.level=t?.id||void 0,this.setFloors(t)}else if(!this.facility&&this.level){this.filterMenuType=`facility`;let e=this.getLevel(this.level),t=this.getFacility(e?.facilityId);this.facility=t?.id||void 0,this.site||=t?.siteId||void 0,this.setFloors(e)}else if(this.site&&!this.facility&&!this.level)this.filterMenuType=`site`,this.setFloors(null);else{if(!e||!_(e)){this.setFloors(null);return}let t=e?.widgets?.floorFilter;if(!t){this.setFloors(null);return}t.site&&!this.site&&(this.site=t.site,this.filterMenuType=`facility`),this.setFloors(null)}if(this.filterLayers?.levelLayer?.type===`feature`&&this.filterLayers.levelLayer.capabilities.data.supportsAttachment&&this.mediaLayer==null){let{levelLayer:e}=this.filterLayers,{default:t}=await import(`../../layers/MediaLayer.js`);this.mediaLayer=new t({blendMode:`normal`,listMode:`hide`,maxScale:e.maxScale,minScale:e.minScale,spatialReference:this.view.spatialReference.clone(),title:`floor-filter-media-layer`,visible:e.visible}),this.overlaysByFacility=new Map,this.overlaysByLevel=new Map,this.view.map.add(this.mediaLayer),this.getOverlays(!0)}}catch(e){a.getLogger(this).error(`Couldn't retrieve sites, facilities, and levels`,e)}}_callOverride(e,t){this._override(e,t)}async _updateFloorFilterFromMap(e){if(!e||!_(e))return;await this.view?.when();let t=e?.widgets?.floorFilter;t&&(this._isOverridden(`enabled`)||(this.enabled=t.enabled),this._isOverridden(`longNames`)||(this.longNames=t.longNames),this._isOverridden(`minimized`)||(this.minimized=t.minimized),this._isOverridden(`pinnedLevels`)||(this.pinnedLevels=t.pinnedLevels),this._isOverridden(`site`)||(this.site=t.site),this._isOverridden(`facility`)||(this.facility=t.facility),this._isOverridden(`level`)||(this.level=t.level))}_updateMediaLayer(e){let{mediaLayer:t,overlaysByLevel:n}=this;if(t&&n&&e?.length){let r=t.source;r.elements.removeAll(),n.get(e)?.visible===!0&&r.elements.push(n.get(e)?.image)}}_computeViewAllModeFloors(e){let{filterFeatures:t}=this;if(e.floorInfo?.viewAllMode&&this.hasLevels&&this.hasFacilities&&this.filterMode===`base-floors`){let{level:n,facility:i}=this,a=[];t.levels.levelsInfo.forEach(e=>{let{id:t,facilityId:r}=e;i&&r===i?n&&t===n&&a.push(t):a.push(t)}),e.floorInfo.viewAllLevelIds=new r(a)}}};e([f({value:!1})],b.prototype,`enabled`,null),e([f({value:void 0})],b.prototype,`facility`,null),e([f({value:null})],b.prototype,`filterFeatures`,null),e([f({value:null})],b.prototype,`filterLayers`,null),e([f()],b.prototype,`filterMenuOpen`,void 0),e([f()],b.prototype,`filterMenuType`,void 0),e([f()],b.prototype,`filterMode`,void 0),e([f({readOnly:!0,value:`belowSelected`})],b.prototype,`floorVisibilityMode`,null),e([f()],b.prototype,`hasFacilities`,null),e([f()],b.prototype,`hasLevels`,null),e([f()],b.prototype,`hasMultipleSites`,null),e([f({readOnly:!0})],b.prototype,`isNormalMode`,null),e([f({value:void 0})],b.prototype,`level`,null),e([f({value:!1})],b.prototype,`longNames`,null),e([f()],b.prototype,`levelsExpanded`,void 0),e([f()],b.prototype,`mediaLayer`,void 0),e([f({value:!1})],b.prototype,`minimized`,null),e([f()],b.prototype,`overlaysByFacility`,void 0),e([f()],b.prototype,`overlaysByLevel`,void 0),e([f({value:!1})],b.prototype,`pinnedLevels`,null),e([f()],b.prototype,`searchTerm`,void 0),e([f({readOnly:!0})],b.prototype,`selectedVerticalOrder`,null),e([f({value:void 0})],b.prototype,`site`,null),e([f({readOnly:!0})],b.prototype,`state`,null),e([f({readOnly:!0,value:!1})],b.prototype,`useVerticalOrder`,null),e([f()],b.prototype,`view`,void 0),e([f()],b.prototype,`_viewHeightBreakpoint`,void 0),e([f()],b.prototype,`_viewWidthBreakpoint`,void 0),e([f()],b.prototype,`updateWebDocument`,null),b=e([p(`esri.widgets.FloorFilter.FloorFilterViewModel`)],b);const x=b;export{x as default};
|
|
2
|
+
import{__decorate as e}from"tslib";import t from"../../core/Accessor.js";import{createTask as n}from"../../core/asyncUtils.js";import r from"../../core/Collection.js";import i from"../../core/Error.js";import a from"../../core/Logger.js";import{throwIfAborted as o}from"../../core/promiseUtils.js";import{watch as s,initial as c,syncAndInitial as l}from"../../core/reactiveUtils.js";import{Milliseconds as u}from"../../core/time.js";import{isBlobProtocol as d}from"../../core/urlUtils.js";import{property as f,subclass as p}from"../../core/accessorSupport/decorators.js";import m from"../../geometry/Polygon.js";import h from"../../webdoc/Widgets.js";import g from"../../webdoc/widgets/FloorFilter.js";import{isWebMap as _}from"../../webmap/utils.js";import{GoTo as v}from"../support/GoTo.js";function y(e){return e.declaredClass===`esri.WebScene`}let b=class extends v(t){constructor(e){super(e),this.filterMenuOpen=!1,this.filterMenuType=`site`,this.filterMode=`base-floors`,this.levelsExpanded=!0,this.searchTerm=null,this.view=null,this._updateFloorFilterTask=null,this._viewHeightBreakpoint=null,this._viewWidthBreakpoint=null}initialize(){this.addHandles([s(()=>this.view?.map,e=>{this._updateFloorFilterTask!=null&&(this._updateFloorFilterTask.abort(),this._updateFloorFilterTask=null),this._updateFloorFilterTask=n(async t=>{await this._updateFloorFilterFromMap(e),o(t),this._setInitialViewState(e)}),this._watchMapLayers(e)},c),s(()=>this.view,(e,t)=>{this._unregisterWidget(t),this._registerWidget(e),this._watchSearchResults(e)},l),s(()=>this.mediaLayer,e=>{this._watchLayerVisibility(e)},l),s(()=>this.view?.widthBreakpoint??null,e=>{this._viewWidthBreakpoint=e}),s(()=>this.view?.heightBreakpoint??null,e=>{this._viewHeightBreakpoint=e}),s(()=>this.facility,()=>void this.getOverlays()),s(()=>this.level,e=>this._updateMediaLayer(e))])}destroy(){if(this._unregisterWidget(this.view),this.mediaLayer&&this.view?.map.remove(this.mediaLayer),this.overlaysByLevel){for(let e of this.overlaysByLevel.values()){let t=e.image.image;d(t)&&URL.revokeObjectURL(t)}this.overlaysByFacility?.clear(),this.overlaysByLevel.clear()}this.view=null,this._updateFloorFilterTask!=null&&(this._updateFloorFilterTask.abort(),this._updateFloorFilterTask=null)}set enabled(e){this._callOverride(`enabled`,e)}set facility(e){if(e&&this._isOverridden(`facility`)){let t=this.getFacility(e);this.hasMultipleSites&&(this.site=t?.siteId||null)}this._callOverride(`facility`,e)}set filterFeatures(e){this._callOverride(`filterFeatures`,e)}set filterLayers(e){this._callOverride(`filterLayers`,e)}get floorVisibilityMode(){return this.view&&y(this.view?.map)?this.view.map.widgets?.floorFilter?.floorVisibilityMode??`belowSelected`:`belowSelected`}get hasFacilities(){return this.filterLayers?.facilityLayer!=null&&this.filterFeatures?.facilities?.facilitiesInfo?.length>0}get hasLevels(){return this.filterLayers?.levelLayer!=null&&this.filterFeatures?.levels?.levelsInfo?.length>0}get hasMultipleSites(){return this.filterLayers?.siteLayer!=null&&this.filterFeatures?.sites?.sitesInfo?.length>1}get isNormalMode(){let e=!0,t=this._viewWidthBreakpoint;return(this._viewHeightBreakpoint===`xsmall`||t===`xsmall`)&&(e=!1),e}set level(e){if(!e){this._callOverride(`level`,e),this.facility=null,this.site=null,this.setFloors(null);return}let t=null,n=null,r=e?.split(`--`);r?.length>1&&r[0]===`all`?(n=r[1],t={id:e,facilityId:n,shortName:null,longName:null,levelNumber:null,verticalOrder:null}):(t=this.getLevel(e),n=t?.facilityId??null),this.level===e&&!this.isNormalMode&&!this.levelsExpanded?this.getFacilityLevels(n)?.length>1&&(this.levelsExpanded=!0):(t&&this.hasFacilities&&this.hasLevels?(this.facility=n,this.hasMultipleSites&&(this.site=this.getFacility(n)?.siteId||null),this.setFloors(t)):this._isOverridden(`level`)&&(this.facility=null,this.site=null,this.hasMultipleSites&&(this.filterMenuType=`site`),this.setFloors(null)),this._callOverride(`level`,e))}set longNames(e){this._callOverride(`longNames`,e)}set minimized(e){this._callOverride(`minimized`,e)}set pinnedLevels(e){this._callOverride(`pinnedLevels`,e)}get selectedVerticalOrder(){return _(this.view?.map)?this.view.map.resourceInfo?.widgets?.floorFilter?.selectedVerticalOrder??null:null}set site(e){this._callOverride(`site`,e)}get state(){return this.view&&this.filterFeatures&&this.hasFacilities&&this.hasLevels?`ready`:this.view&&!this.filterFeatures?`loading`:`disabled`}get useVerticalOrder(){return this.view?.map==null?!1:_(this.view?.map)||y(this.view.map)?this.view.map.widgets?.floorFilter?.useVerticalOrder??!1:!1}filterFacilities(e){let t=e;return this.searchTerm&&(this.searchTerm=this.searchTerm.trim(),t=e.filter(e=>{let{name:t}=e;return t.toLowerCase().includes(this.searchTerm?.toLowerCase())})),this.site&&(t=t.filter(e=>e.siteId===this.site)),t.sort((e,t)=>{let n=e.name,r=t.name;return n.localeCompare(r,void 0,{sensitivity:`base`})})}filterSites(e){let t=e;return this.searchTerm&&(this.searchTerm=this.searchTerm.trim(),t=e.filter(e=>{let{name:t}=e;return t.toLowerCase().includes(this.searchTerm?.toLowerCase())})),t.sort((e,t)=>{let n=e.name,r=t.name;return n.localeCompare(r,void 0,{sensitivity:`base`})})}getBaseLevel(e){let t=this.filterFeatures?.levels?.levelsInfo,n=null;if(e){let{id:r}=e;if(t&&t.length>0&&(t.forEach(e=>{e.verticalOrder===0&&e.facilityId===r&&(n=e)}),!n)){let e=null;t.forEach(t=>{t.facilityId===r&&(e?(t.verticalOrder??0)>=0?e.verticalOrder!=null&&(e.verticalOrder<0||(t.verticalOrder??0)<e.verticalOrder)&&(e=t):e.verticalOrder!=null&&t.verticalOrder!=null&&e.verticalOrder<0&&t.verticalOrder>e.verticalOrder&&(e=t):e=t)}),e&&(n=e)}}return n}getFacility(e){return this.filterFeatures?.facilities?.facilitiesInfo?.find(t=>t.id===e)??null}getFacilityLevels(e){return!e||!this.filterFeatures?.levels?.levelsInfo?[]:this.filterFeatures.levels.levelsInfo.filter(t=>t.facilityId===e).sort((e,t)=>{let n=e.verticalOrder??0,r=t.verticalOrder??0;return n>r?-1:n===r?0:1})}getLevel(e){return this.filterFeatures?.levels?.levelsInfo?.find(t=>t.id===e)??null}async getOverlays(e=!1){let{facility:t,level:n,mediaLayer:i,overlaysByFacility:a,overlaysByLevel:o,view:s}=this;if(_(s?.map)&&i){if((i?.source).elements.removeAll(),t?.length&&(!a?.has(t)||e)){a?.set(t,new r);let e=s.map.floorInfo?.levelLayer?.layerId,n=s.map.findLayerById(e??``);if(!n||s.type!==`2d`)return;let i=await this._getAttachments(n,t),{default:c}=await import(`../../request.js`),l=Object.keys(i).map(async e=>{let r=i[e],s=r.find(e=>e.contentType===`application/json`);if(!s?.url)return;let l=new URL(s.url);n.gdbVersion?.length&&l.searchParams.set(`gdbVersion`,n.gdbVersion);let{data:u}=await c(l.toString(),{responseType:`json`}),d=r.find(e=>e.name===u.name),f=d?.url??``;if(f?.length>0){let e=new URL(f);e.searchParams.delete(`token`),n.gdbVersion?.length&&e.searchParams.set(`gdbVersion`,n.gdbVersion);let{default:r}=await import(`../../layers/support/ControlPointsGeoreference.js`),i=r.fromJSON(u.georeference),c=await this.toImageElement(e.toString(),i,u.opacity,u.clipImage,u.geometry);await c.load();let l={...u,attachments:[s,d],facilityId:t,image:c,source:JSON.stringify(u),url:e.toString()};o?.set(l.levelId,l),a?.get(t)?.push(l)}});await Promise.all(l)}this._updateMediaLayer(n)}}getSite(e){return this.filterFeatures?.sites?.sitesInfo?.find(t=>t.id===e)??null}async goTo(e){let{view:t}=this;if(!t||!e)return;let{geometry:n}=e;if(n?.extent){let e=e=>{this.callGoTo({target:e,options:{duration:u(1e3),easing:`quad-in-out-coast`}})};if(n.hasZ&&n.spatialReference?.vcsWkid!==t.spatialReference?.vcsWkid){let{projectIsLoaded:r,projectLoad:i,projectExecute:a}=await import(`../../geometry/operators/projectOperator.js`);r()||await i();let o=a(n.extent,t.spatialReference.clone(),{zConversionDisabled:!0});o&&e(o)}else e(n.extent)}}setFloors(e){let{view:t}=this;t&&(t?.map?.allLayers?.forEach(e=>{e.type===`feature`&&this._computeViewAllModeFloors(e)}),t.floors=new r(this._computeFloors(e)))}async toImageElement(e,t,n,r,i){let{default:o}=await import(`../../layers/support/ImageElement.js`),{facility:s}=this,c=()=>new o({image:e,georeference:t,opacity:n});if(r)try{let r=i?m.fromJSON(i):this.getFacility(s)?.geometry;if(r==null)return c();let{pixelRings:a,width:l,height:u}=await this._polygonToImagePixels(t,r),d=await this._imagePolygonToBlob(e,a,l,u);return new o({image:URL.createObjectURL(d),georeference:t,opacity:n})}catch(e){return a.getLogger(this).warn(`Unable to clip image; using full image instead: ${e.message}`,e),c()}return c()}updateWebDocument(e){if(_(e)||y(e)){let t={enabled:this.enabled,longNames:this.longNames,minimized:this.minimized,pinnedLevels:this.pinnedLevels,site:this.site??null,facility:this.facility??null,level:this.level??null,useVerticalOrder:this.useVerticalOrder,selectedVerticalOrder:this.selectedVerticalOrder};y(e)&&(t.floorVisibilityMode=this.floorVisibilityMode);let n=new g(t);e.widgets??=new h,e.widgets.floorFilter=n}}_computeFloors(e){if(this.filterMode===`single-floor`)this._computeSingleFloor(e);else if(this.filterMode===`base-floors`)return this.view?.type===`3d`?this._computeBaseFloors3D(e):this._computeBaseFloors(e);return this._computeEmptyFloors()}_computeSingleFloor(e){if(!e)return this._computeEmptyFloors();let t=[];return e?.id===`all`?this.getFacilityLevels(e.facilityId).forEach(e=>{e.id&&t.push(e.id)}):e&&t.push(e.id),t}_computeBaseFloors(e){let t=this.filterFeatures?.levels?.levelsInfo;if(!t?.length)return this._computeEmptyFloors();let n=[];e?.id===`all`?this.getFacilityLevels(e.facilityId).forEach(e=>{e.id&&n.push(e.id)}):e&&n.push(e.id);let r=e?.facilityId,i=e?.verticalOrder,a=(e,t)=>{e===0&&n.push(t)};return t.forEach(e=>{let{id:t,facilityId:o,verticalOrder:s}=e;!r&&!n.includes(t)?a(s,t):o!==r&&!n.includes(t)&&(this.useVerticalOrder?s===i&&n.push(t):a(s,t))}),n}_computeBaseFloors3D(e){let t=this.filterFeatures?.levels?.levelsInfo;if(!t?.length)return this._computeEmptyFloors();let n=[],r=e?.id.split(`--`)??[],i=r?.length>1&&r[0]===`all`;i?this.getFacilityLevels(e?.facilityId).forEach(e=>{e.id&&n.push(e.id)}):e&&n.push(e.id);let a=e?.facilityId,o=e?.verticalOrder;return t.forEach(e=>{let{id:t,facilityId:r,verticalOrder:s}=e;if(!a&&!n.includes(t))n.push(t);else if(!n.includes(t)){let{floorVisibilityMode:e,useVerticalOrder:c}=this,l=s<=o;r===a?e===`belowSelected`&&l&&n.push(t):(i||!c||e===`selectedOnly`&&s===o||e===`belowSelected`&&l)&&n.push(t)}}),n}_computeEmptyFloors(){return[]}async _setFilterLayers(){let{view:e}=this;if(e&&!this._isOverridden(`filterLayers`)){if(!_(e.map)&&!y(e.map))throw new i(`floorfilter:unsupported-map`,`Map must be a webmap or webscene`);{let t=e.map,n=t?.allLayers;if(n?.items?.length>0){let e={siteLayer:null,facilityLayer:null,levelLayer:null},r=t.floorInfo?.siteLayer?.layerId,i=t.floorInfo?.facilityLayer?.layerId,a=t.floorInfo?.levelLayer?.layerId,o=t.floorInfo?.siteLayer?.sublayerId||t.floorInfo?.facilityLayer?.sublayerId||t.floorInfo?.levelLayer?.sublayerId;if(!i||!a)return;let s=n.items.filter(e=>e.type===`feature`||e.type===`scene`),c=n.items.filter(e=>e.type===`map-image`);if(c?.length>0&&o){await Promise.all(c.map(e=>e.load()));let n=t.floorInfo?.siteLayer?.sublayerId,o=t.floorInfo?.facilityLayer?.sublayerId,s=t.floorInfo?.levelLayer?.sublayerId;c.forEach(t=>{let c=t.id,l=t?.allSublayers,u=l?.items;(c===r||c===i||c===a)&&u?.length>0&&l.items.forEach(t=>{let i=t.id;c===r&&i===n?e.siteLayer=t:i===o?e.facilityLayer=t:i===s&&(e.levelLayer=t)})})}s?.length>0&&s.forEach(t=>{let n=t.id;n===r?e.siteLayer=t:n===i?e.facilityLayer=t:n===a&&(e.levelLayer=t)}),this.filterLayers=e}}}}async _getAttachments(e,t){let{view:n}=this;if(_(n?.map)){let{facilityIdField:r}=n.map.floorInfo?.levelLayer??{};if(e&&n.type===`2d`&&t?.length>0&&e.capabilities.data.supportsAttachment)return e.queryAttachments({returnMetadata:!0,where:`${r} = '${t}'`})}return{}}async _getFilterFeatures(){if(this._isOverridden(`filterFeatures`))return this.filterFeatures;let[e,t,n]=await Promise.all([this._getSites(),this._getFacilities(),this._getLevels()]);return{sites:e,facilities:t,levels:n}}async _getSites(){let e={sitesInfo:[]},{filterLayers:t,view:n}=this,r=n?.map,{siteLayer:i}=t;if(!i||!r?.floorInfo?.siteLayer)return e;let a=i.createQuery();a.returnGeometry=!0,a.outFields=[`*`],a.returnZ=!0,`type`in i&&i.type===`scene`&&(a.multipatchOption=`xyFootprint`);let{siteIdField:o,nameField:s}=r.floorInfo.siteLayer,c=await x(i,a);if(c.features.length>0){let t=c.features,n=i?.fieldsIndex.get(o)?.name||o,r=i?.fieldsIndex.get(s)?.name||s;n!=null&&r!=null&&t.forEach(t=>{let i=t.attributes,a=t.geometry,o=i[n],s=i[r];o&&s&&e.sitesInfo.push({id:o,name:s,geometry:a})})}return e}async _getFacilities(){let{filterLayers:e,view:t}=this,n=t?.map,{facilityLayer:r}=e,i={facilitiesInfo:[]};if(!r||!n?.floorInfo?.facilityLayer)return i;let a=r.createQuery();a.returnGeometry=!0,a.outFields=[`*`],a.returnZ=!0,`type`in r&&r.type===`scene`&&(a.multipatchOption=`xyFootprint`);let{facilityIdField:o,siteIdField:s,nameField:c}=n.floorInfo.facilityLayer,l=await x(r,a);if(l.features.length>0){let e=l.features,t=r?.fieldsIndex.get(o)?.name||o,n=r?.fieldsIndex.get(s)?.name||s,a=r?.fieldsIndex.get(c)?.name||c;t&&n&&a&&e.forEach(e=>{let r=e.attributes,o=e.geometry,s=r[t],c=r[n],l=r[a];s&&l&&i.facilitiesInfo.push({id:s,siteId:c,name:l,geometry:o})})}return i}async _getLevels(){let{filterLayers:e,view:t}=this,n=t?.map,{levelLayer:r}=e,i={levelsInfo:[]};if(!r||!n?.floorInfo?.levelLayer)return i;let a=r.createQuery();a.returnGeometry=!0,a.outFields=[`*`],a.returnZ=!0;let{levelIdField:o,facilityIdField:s,longNameField:c,shortNameField:l,levelNumberField:u,verticalOrderField:d}=n.floorInfo.levelLayer,f=await x(r,a);if(f.features.length>0){let e=f.features,t=r?.fieldsIndex.get(o)?.name||o,n=r?.fieldsIndex.get(s)?.name||s,a=r?.fieldsIndex.get(c)?.name||c,p=r?.fieldsIndex.get(l)?.name||l,m=r?.fieldsIndex.get(u)?.name||u,h=r?.fieldsIndex.get(d)?.name||d;t&&n&&a&&p&&m&&h&&e.forEach(e=>{let r=e.attributes,o=r[t],s=r[n],c=r[a],l=r[p],u=r[m],d=r[h];o&&s&&c&&l&&typeof u==`number`&&typeof d==`number`&&i.levelsInfo.push({id:o,facilityId:s,longName:c,shortName:l,levelNumber:u,verticalOrder:d})})}return i}async _imagePolygonToBlob(e,t,n,r){let{getImageData:a}=await import(`../../core/imageUtils.js`),o=await a(e),s=new OffscreenCanvas(n,r),c=s.getContext(`2d`);if(!c)throw new i(`floorfilter:floor-plan-overlay`,`Unable to obtain a rendering context from the canvas.`);let l=new Path2D;for(let e of t)if(!(e.length<3)){l.moveTo(e[0].x,e[0].y);for(let t=1;t<e.length;t++)l.lineTo(e[t].x,e[t].y);l.closePath()}return c.save(),c.clip(l,`evenodd`),c.drawImage(o,0,0,n,r),c.restore(),await s.convertToBlob({type:`image/png`})}async _polygonToImagePixels(e,t){if(e?.type!==`control-points`)throw new i(`floorfilter:floor-plan-overlay`,"Expected a `ControlPointsGeoreference`.");let{default:n}=await import(`../../geometry/Point.js`);return{pixelRings:t.rings.map(r=>r.map(([r,a])=>{let o=new n({x:r,y:a,spatialReference:t.spatialReference}),s=e.toSource(o);if(!s)throw new i(`floorfilter:floor-plan-overlay`,`toSource() returned null; check spatial references and projectOperator.`);return{x:s.x,y:s.y}})),width:e.width,height:e.height}}_registerWidget(e){e?.registerComponent(this)}_unregisterWidget(e){e?.unregisterComponent(this)}_watchLayerVisibility(e){if(this.filterLayers?.levelLayer?.type===`feature`&&e){let t=this.filterLayers?.levelLayer;this.addHandles(s(()=>t.visible,t=>{e.visible=t},l))}}_watchMapLayers(e){this.removeHandles(`layers-handle`),e&&this.addHandles(e.allLayers.on(`after-remove`,t=>{if(t.item){let r=e.floorInfo,i=r?.siteLayer?.layerId??``,a=r?.facilityLayer?.layerId??``,s=r?.levelLayer?.layerId??``;(t.item.id===a||t.item.id===s||t.item.id===i)&&(this._updateFloorFilterTask!=null&&(this._updateFloorFilterTask.abort(),this._updateFloorFilterTask=null),this._updateFloorFilterTask=n(async t=>{o(t),this.level=null,this.filterMenuOpen=!1,this._clearOverride(`filterLayers`),this._clearOverride(`filterFeatures`),this._setInitialViewState(e)}))}}),`layers-handle`)}_watchSearchResults(e){e?.on(`select-result-floor`,e=>{let t=this.getLevel(e);t&&this.level!==e&&(this.level=e,this.setFloors(t))})}async _setInitialViewState(e){if(this.view)try{await this.view.when(),await this._setFilterLayers();let t=await this._getFilterFeatures();if(!t)return;if(this.filterFeatures=t,!this.hasFacilities||!this.hasLevels){a.getLogger(this).error(`Facilities and Levels are required for the Floor Filter widget`);return}if(this.hasMultipleSites||(this.filterMenuType=`facility`),this.facility&&this.level){this.filterMenuType=`facility`;let e=this.getFacility(this.facility),t=this.getLevel(this.level);this.site||=e?.siteId||void 0,this.setFloors(t)}else if(this.facility&&!this.level){this.filterMenuType=`facility`;let e=this.getFacility(this.facility),t=this.getBaseLevel(e);this.site||=e?.siteId||void 0,this.level=t?.id||void 0,this.setFloors(t)}else if(!this.facility&&this.level){this.filterMenuType=`facility`;let e=this.getLevel(this.level),t=this.getFacility(e?.facilityId);this.facility=t?.id||void 0,this.site||=t?.siteId||void 0,this.setFloors(e)}else if(this.site&&!this.facility&&!this.level)this.filterMenuType=`site`,this.setFloors(null);else{if(!e||!_(e)){this.setFloors(null);return}let t=e?.widgets?.floorFilter;if(!t){this.setFloors(null);return}t.site&&!this.site&&(this.site=t.site,this.filterMenuType=`facility`),this.setFloors(null)}if(this.filterLayers?.levelLayer?.type===`feature`&&this.filterLayers.levelLayer.capabilities.data.supportsAttachment&&this.mediaLayer==null){let{levelLayer:e}=this.filterLayers,{default:t}=await import(`../../layers/MediaLayer.js`);this.mediaLayer=new t({blendMode:`normal`,listMode:`hide`,maxScale:e.maxScale,minScale:e.minScale,spatialReference:this.view.spatialReference.clone(),title:`floor-filter-media-layer`,visible:e.visible}),this.mediaLayer.persistenceEnabled=!1,this.overlaysByFacility=new Map,this.overlaysByLevel=new Map;let n=e.parent?.type===`group`,r=e.parent,i=(n?r.layers:this.view.map.layers).indexOf(e);n?i>-1?r.add(this.mediaLayer,i+1):r.add(this.mediaLayer):i>-1?this.view.map.add(this.mediaLayer,i+1):this.view.map.add(this.mediaLayer),this.getOverlays(!0)}}catch(e){a.getLogger(this).error(`Couldn't retrieve sites, facilities, and levels`,e)}}_callOverride(e,t){this._override(e,t)}async _updateFloorFilterFromMap(e){if(!e||!_(e))return;await this.view?.when();let t=e?.widgets?.floorFilter;t&&(this._isOverridden(`enabled`)||(this.enabled=t.enabled),this._isOverridden(`longNames`)||(this.longNames=t.longNames),this._isOverridden(`minimized`)||(this.minimized=t.minimized),this._isOverridden(`pinnedLevels`)||(this.pinnedLevels=t.pinnedLevels),this._isOverridden(`site`)||(this.site=t.site),this._isOverridden(`facility`)||(this.facility=t.facility),this._isOverridden(`level`)||(this.level=t.level))}_updateMediaLayer(e){let{mediaLayer:t,overlaysByLevel:n}=this;if(t&&n&&e?.length){let r=t.source;r.elements.removeAll(),n.get(e)?.visible===!0&&r.elements.push(n.get(e)?.image)}}_computeViewAllModeFloors(e){let{filterFeatures:t}=this;if(e.floorInfo?.viewAllMode&&this.hasLevels&&this.hasFacilities&&this.filterMode===`base-floors`){let{level:n,facility:i}=this,a=[];t.levels.levelsInfo.forEach(e=>{let{id:t,facilityId:r}=e;i&&r===i?n&&t===n&&a.push(t):a.push(t)}),e.floorInfo.viewAllLevelIds=new r(a)}}};e([f({value:!1})],b.prototype,`enabled`,null),e([f({value:void 0})],b.prototype,`facility`,null),e([f({value:null})],b.prototype,`filterFeatures`,null),e([f({value:null})],b.prototype,`filterLayers`,null),e([f()],b.prototype,`filterMenuOpen`,void 0),e([f()],b.prototype,`filterMenuType`,void 0),e([f()],b.prototype,`filterMode`,void 0),e([f({readOnly:!0,value:`belowSelected`})],b.prototype,`floorVisibilityMode`,null),e([f()],b.prototype,`hasFacilities`,null),e([f()],b.prototype,`hasLevels`,null),e([f()],b.prototype,`hasMultipleSites`,null),e([f({readOnly:!0})],b.prototype,`isNormalMode`,null),e([f({value:void 0})],b.prototype,`level`,null),e([f({value:!1})],b.prototype,`longNames`,null),e([f()],b.prototype,`levelsExpanded`,void 0),e([f()],b.prototype,`mediaLayer`,void 0),e([f({value:!1})],b.prototype,`minimized`,null),e([f()],b.prototype,`overlaysByFacility`,void 0),e([f()],b.prototype,`overlaysByLevel`,void 0),e([f({value:!1})],b.prototype,`pinnedLevels`,null),e([f()],b.prototype,`searchTerm`,void 0),e([f({readOnly:!0})],b.prototype,`selectedVerticalOrder`,null),e([f({value:void 0})],b.prototype,`site`,null),e([f({readOnly:!0})],b.prototype,`state`,null),e([f({readOnly:!0,value:!1})],b.prototype,`useVerticalOrder`,null),e([f()],b.prototype,`view`,void 0),e([f()],b.prototype,`_viewHeightBreakpoint`,void 0),e([f()],b.prototype,`_viewWidthBreakpoint`,void 0),e([f()],b.prototype,`updateWebDocument`,null),b=e([p(`esri.widgets.FloorFilter.FloorFilterViewModel`)],b);async function x(e,t,n){let r={features:[]};await e.load();let i=(e.type===`sublayer`?e.sourceJSON?.maxRecordCount:e.capabilities.query.maxRecordCount)||2e3,a=async()=>{let n=t.clone();return await e.queryObjectIds(n,void 0)},o=async n=>{let r=t.clone();r.where=null,r.objectIds=n.objectIds,n.features=(await e.queryFeatures(r,void 0))?.features??null},s=await a(),c=i,l=[],u=[];for(let e=0,t=s.length;e<t;e+=c){let t=s.slice(e,e+c);t.length>0&&l.push({objectIds:t,features:null})}for(let e=0,t=l.length;e<t;e+=3){let t=l.slice(e,e+3);t.length>0&&u.push({pages:t})}for await(let e of u){let t=[];for(let n of e.pages)t.push(o(n));t.length>0&&await Promise.all(t)}for(let e of l)e.features?.length&&r.features.push(...e.features);return r}const S=b;export{S as default};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
import{generateCombinationsPanoramic as e,generateCombinations as t}from"./imageMeasurementUtils.js";function n(e){return t(e.imageToWorldProps,e.accuracyParameters)}function r(t){return e(t.imageToWorldProps,t.accuracyParameters)}export{r as generateCombinationsPanoramicWorker,n as generateCombinationsWorker};
|
|
2
|
+
import{generateCombinationsPanoramic as e,generateCombinations as t}from"./imageMeasurementUtils.js";function n(e){return t(e.imageToWorldProps,e.accuracyParameters,e.cameraHeading)}function r(t){return e(t.imageToWorldProps,t.accuracyParameters)}export{r as generateCombinationsPanoramicWorker,n as generateCombinationsWorker};
|