@arcgis/core 5.0.0-next.128 → 5.0.0-next.129
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/analysis/VolumeMeasurement/VolumeMeasurementCutFillOptions.d.ts +1 -1
- package/analysis/VolumeMeasurementAnalysis.d.ts +1 -1
- package/applications/WebEditor/geometryUtils.d.ts +26 -0
- package/applications/WebEditor/geometryUtils.js +2 -0
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/{982e709d2cef971ecd82.js → 0d9d33f29124d464a4cb.js} +1 -1
- package/assets/esri/core/workers/chunks/{2762149a922275136171.js → 112227b862b935123ddf.js} +2 -2
- package/assets/esri/core/workers/chunks/1336f685bae5f1251558.js +1 -0
- package/assets/esri/core/workers/chunks/{b71e4f48377fefe2537d.js → 15d46482ec096e3ce161.js} +1 -1
- package/assets/esri/core/workers/chunks/{d0d1378e714ff0e43e26.js → 1cfa8d404d42b9eccf78.js} +1 -1
- package/assets/esri/core/workers/chunks/{1e29a114c1cfe21121c4.js → 203ef5459fc5dde12851.js} +1 -1
- package/assets/esri/core/workers/chunks/{b4203e488bb928ff8032.js → 25d34552bfb255af9467.js} +1 -1
- package/assets/esri/core/workers/chunks/{d8adab2d55b39241b232.js → 27e14277128446e76b45.js} +1 -1
- package/assets/esri/core/workers/chunks/3d3b1ce112be6ea31d93.js +1 -0
- package/assets/esri/core/workers/chunks/{fd47dc60646260c5633c.js → 415957a42e45eb21aa84.js} +1 -1
- package/assets/esri/core/workers/chunks/4ac09b066c696476e532.js +1 -0
- package/assets/esri/core/workers/chunks/{72acfb74fd9ab9bae923.js → 53e348f5585fa8c53fe8.js} +2 -2
- package/assets/esri/core/workers/chunks/{323f6077a659416c4cee.js → 6a9a96aa811c1d3b6edb.js} +1 -1
- package/assets/esri/core/workers/chunks/{25c189e894927099c239.js → 6c85396c90941a042c33.js} +1 -1
- package/assets/esri/core/workers/chunks/{89274b81a2a8b7cd5c49.js → 6f337c3ccd84d90a35e5.js} +1 -1
- package/assets/esri/core/workers/chunks/{84905581a3782e95ec34.js → 72c31f3313dfe87dd1aa.js} +1 -1
- package/assets/esri/core/workers/chunks/{a3e8b7185d63a0f85931.js → 79c69ae86a1f4a56f7c7.js} +1 -1
- package/assets/esri/core/workers/chunks/{1ce46085095679386580.js → 8cade3af17a8bb6d4e37.js} +1 -1
- package/assets/esri/core/workers/chunks/{6af14a0217077d9ab47f.js → aaf3ed508d30ed583915.js} +1 -1
- package/assets/esri/core/workers/chunks/{91858b02da40ff251ab2.js → b397a9f87082705301a4.js} +2 -2
- package/assets/esri/core/workers/chunks/baad696d84ab78b3d00e.js +2 -0
- package/assets/esri/core/workers/chunks/{f104823f3b31a204bacb.js → bc2dcbdc414d157ab727.js} +1 -1
- package/assets/esri/core/workers/chunks/{6bd910e0480451a8d6aa.js → bde2c3199f667b63dbe8.js} +1 -1
- package/assets/esri/core/workers/chunks/{4214f46bee613dea72f3.js → c66aa57b6360963bd938.js} +1 -1
- package/assets/esri/core/workers/chunks/{c409b8d39c0a40dafa06.js → cb5f4820277f3fc7ff2f.js} +1 -1
- package/assets/esri/core/workers/chunks/cbcb3530375e280bfeac.js +1 -0
- package/assets/esri/core/workers/chunks/{5c12a9b0db317620dce2.js → d39f5d57f7e35c00ca16.js} +1 -1
- package/assets/esri/core/workers/chunks/{a82587f69c4bbcac7e0b.js → dc7df2072c0ebed5602c.js} +1 -1
- package/assets/esri/core/workers/chunks/dd3789e71270a4640551.js +1 -0
- package/assets/esri/core/workers/chunks/de5719ef663224860af5.js +1 -0
- package/assets/esri/core/workers/chunks/de6438fdbe38d32c4ad5.js +1 -0
- package/assets/esri/core/workers/chunks/{b705f837caa76cee81fc.js → e09722903e63f6cc2540.js} +1 -1
- package/assets/esri/core/workers/chunks/{6cd370c716e4fe87b684.js → e2e03622936d2b35afc0.js} +1 -1
- package/assets/esri/core/workers/chunks/{9531f17cecd50431cce2.js → e8ae71e482b8d5f54a72.js} +1 -1
- package/assets/esri/core/workers/chunks/{7477a4d08414b561d03b.js → e97b29b026a734bbcff8.js} +1 -1
- package/assets/esri/core/workers/chunks/edaae0fc63d16b0f675d.js +2 -0
- package/assets/esri/core/workers/chunks/{214323c62d6d3b603a00.js → f7506c9d57b2ae0c5fd3.js} +1 -1
- package/assets/esri/themes/base/widgets/_Editor.scss +1 -0
- package/assets/esri/themes/dark/main.css +1 -1
- package/assets/esri/themes/light/main.css +1 -1
- package/assets/esri/themes/light/view.css +1 -1
- package/chunks/Envelope.js +1 -1
- package/chunks/GeodeticDistanceCalculator-Ce-woMPw.js +1 -1
- package/chunks/GeodeticUtils.js +1 -1
- package/chunks/Geometry.js +1 -1
- package/chunks/MultiPathImpl.js +1 -1
- package/chunks/OperatorGeodesicBuffer.js +1 -1
- package/chunks/OperatorGeodeticArea.js +1 -1
- package/chunks/OperatorGeodeticDensifyByLength.js +1 -1
- package/chunks/OperatorGeodeticLength.js +1 -1
- package/chunks/OperatorIntegrate.js +2 -0
- package/chunks/OperatorMultiPartToSinglePart.js +1 -1
- package/chunks/OperatorProximityGeodesic.js +1 -1
- package/chunks/OperatorShapePreservingLength.js +1 -1
- package/chunks/OperatorShapePreservingProject.js +1 -1
- package/chunks/Point2D.js +1 -1
- package/chunks/SpatialReference.js +1 -1
- package/chunks/relateOperator.js +1 -1
- package/config.js +1 -1
- package/geometry/operators/extendOperator.js +1 -1
- package/geometry/operators/gx/operatorAlphaShape.js +1 -1
- package/geometry/operators/gx/operatorAutoComplete.js +1 -1
- package/geometry/operators/gx/operatorConvexHull.js +1 -1
- package/geometry/operators/gx/operatorIntegrate.js +1 -1
- package/geometry/operators/gx/operatorLabelPoint.js +1 -1
- package/geometry/operators/gx/operatorMinimumBoundingCircle.js +1 -1
- package/geometry/operators/gx/operatorPolygonOverlay.js +1 -1
- package/geometry/operators/gx/operatorSymmetricDifference.js +1 -1
- package/geometry/operators/reshapeOperator.js +1 -1
- package/geometry/operators/support/jsonConverter.js +1 -1
- package/geometry/operators/support/projectionTransformation.js +1 -1
- package/kernel.js +1 -1
- package/layers/OrientedImageryLayer.js +1 -1
- package/layers/SubtypeGroupLayer.d.ts +0 -1
- package/layers/graphics/data/QueryEngineResult.js +1 -1
- package/layers/orientedImagery/core/ExposurePoint.js +1 -1
- package/layers/orientedImagery/transformations/utils.js +1 -1
- package/layers/raster/datasets/ImageServerRaster.js +1 -1
- package/networks/support/TraceConfiguration.d.ts +5 -4
- package/networks/support/UNTraceConfiguration.d.ts +6 -5
- package/networks/support/jsonTypes.d.ts +305 -0
- package/package.json +3 -3
- package/portal/schemas/definitions.js +1 -1
- package/smartMapping/support/adapters/FeatureLayerAdapter.js +1 -1
- package/smartMapping/support/adapters/InMemoryLayerAdapter.js +1 -1
- package/smartMapping/support/utils.js +1 -1
- package/support/revision.js +1 -1
- package/symbols/PolygonSymbol3D.d.ts +3 -21
- package/symbols/PolygonSymbol3D.js +1 -1
- package/symbols/support/Symbol3DEmissive.d.ts +1 -0
- package/symbols/support/previewSymbol3D.js +1 -1
- package/views/2d/engine/webgl/shaders/sources/shaderRepository.js +1 -1
- package/views/2d/layers/imagery/BaseImageryTileSubView2D.js +1 -1
- package/views/3d/layers/graphics/Deconflictor.js +1 -1
- package/views/3d/layers/i3s/I3SViewportQueries.js +1 -1
- package/views/3d/webgl/RenderNode.d.ts +45 -56
- package/views/3d/webgl.d.ts +7 -4
- package/views/analysis/ElevationProfile/ElevationProfileChart.js +1 -1
- package/views/interactive/snapping/RightAngleSnapper.js +1 -1
- package/views/interactive/snapping/RightAngleTriangleSnapper.js +1 -1
- package/webscene/Glow.d.ts +1 -0
- package/webscene/spec-certification/spec.js +1 -1
- package/widgets/FloorFilter/FloorFilterViewModel.js +1 -1
- package/widgets/OrientedImageryViewer/adapters/sketch/TriangulatedMeasurementAdapter.js +1 -1
- package/widgets/OrientedImageryViewer/imageMeasurementUtils.js +1 -1
- package/widgets/OrientedImageryViewer/navigation/queries.js +1 -1
- package/widgets/OrientedImageryViewer/services/ImageMeasurementService.js +1 -1
- package/widgets/OrientedImageryViewer/services/TransformationService.js +1 -1
- package/widgets/OrientedImageryViewer.js +1 -1
- package/assets/esri/core/workers/chunks/3b0cfe3db8d90e02d6c6.js +0 -1
- package/assets/esri/core/workers/chunks/754e4d0b8c1ad392bd83.js +0 -1
- package/assets/esri/core/workers/chunks/7e6309bfed6692e8d2d7.js +0 -2
- package/assets/esri/core/workers/chunks/9bb04d5f2e6f6e4585a0.js +0 -1
- package/assets/esri/core/workers/chunks/bdd246cc50ccd5c10987.js +0 -1
- package/assets/esri/core/workers/chunks/c941b716ea3c13cabc80.js +0 -1
- package/assets/esri/core/workers/chunks/c9babe86c00ae69e63ee.js +0 -2
- package/assets/esri/core/workers/chunks/d47ca631e109144b6ba9.js +0 -1
- package/assets/esri/core/workers/chunks/fd5a5b05a1551cdb8c87.js +0 -1
- /package/assets/esri/core/workers/chunks/{2762149a922275136171.js.LICENSE.txt → 112227b862b935123ddf.js.LICENSE.txt} +0 -0
- /package/assets/esri/core/workers/chunks/{72acfb74fd9ab9bae923.js.LICENSE.txt → 53e348f5585fa8c53fe8.js.LICENSE.txt} +0 -0
- /package/assets/esri/core/workers/chunks/{7e6309bfed6692e8d2d7.js.LICENSE.txt → b397a9f87082705301a4.js.LICENSE.txt} +0 -0
- /package/assets/esri/core/workers/chunks/{91858b02da40ff251ab2.js.LICENSE.txt → baad696d84ab78b3d00e.js.LICENSE.txt} +0 -0
- /package/assets/esri/core/workers/chunks/{c9babe86c00ae69e63ee.js.LICENSE.txt → edaae0fc63d16b0f675d.js.LICENSE.txt} +0 -0
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.0/LICENSE.txt */
|
|
2
|
-
import{normalize as e,sub as t,dot as i,scaleAndAdd as s,set as n,equals as r,subtract as o,len as a,sqrDist as c,copy as u,scale as l,dist as d,distance as h,length as m,squaredLength as _,squaredDistance as p,add as f}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as v}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{getReferenceEllipsoid as R}from"../../../../geometry/ellipsoidUtils.js";import{getSphericalPCPF as S}from"../../../../geometry/spatialReferenceEllipsoidUtils.js";import{projectBoundingSphere as b}from"../../../../geometry/projection/projectBoundingSphere.js";import{getProjector as g}from"../../../../geometry/projection/projectors.js";import{create as M,fromMatrix as x,intersectsSphere as I,createPoints as C}from"../../../../geometry/support/frustum.js";import{signedDistance as E,getNormal as D}from"../../../../geometry/support/plane.js";import{isPlateCarree as P}from"../../../../geometry/support/spatialReferenceUtils.js";import{Sphere as A}from"../../../../geometry/support/sphere.js";import{evaluateElevationAlignmentAtPoint as O}from"../graphics/elevationAlignmentUtils.js";import{ElevationContext as F}from"../graphics/ElevationContext.js";import{createContextWithoutExpressionSupport as V,extractExpressionInfo as j}from"../graphics/featureExpressionInfoUtils.js";import{intersectBoundingRectWithMbs as B}from"./I3SUtil.js";import{SphereCylinderLocal as L,SphereConeGlobal as w}from"./SphereCone.js";import{Obb as y,computeOffsetObb as U}from"../../support/orientedBoundingBox.js";const q=1e5;class G{get _frustumMbsCenter(){return this._frustumMbs.center}get _frustumMbsRadius(){return this._frustumMbs.radius}get _frustumPlanes(){return this._frustum}constructor(e,t,i,s,n,r,o,a,c={}){this._indexSR=e,this._renderCoordsHelper=t,this._clippingArea=n,this._elevationProvider=r,this._viewingMode=o,this._options=c,this._frustum=M(),this._frustumMbs=new A,this._viewDirection=v(),this._useFrustumCulling=!1,this._poi=v(),this._cameraPOIDirection=v(),this._elevationContext=null,this.minDistance=1/0,this.maxDistance=0,this.maxLodLevel=2,this._screenspaceErrorBias=c.screenspaceErrorBias||1,this._progressiveLoadFactor=c.progressiveLoadFactor||1,this.updateCamera(i,s);const u=this._renderCoordsHelper.spatialReference;this._renderSR=u,this._renderSRSphericalPCPF=S(u),this._isGlobalMode=u===this._renderSRSphericalPCPF,this.updateElevationInfo(a),this._isECEFOBBInLocalMode=this._indexSR.isWGS84&&(u.isWebMercator||P(u)),this._indexSREllipsoidRadius=R(this._indexSR).radius,this._indexSRSphericalPCPF=S(e),this._projectorIndexSRToIndexSRSphericalPCPF=g(this._indexSR,this._indexSRSphericalPCPF)}updateElevationInfo(e){null!=e?(this._elevationContext=F.fromElevationInfo(e),this._elevationContext.setFeatureExpressionInfoContext(V(j(e,!1)))):this._elevationContext=null}updateCamera(n,r){if(this._useFrustumCulling=r,e(this._viewDirection,n.viewForward),r){x(n.viewMatrix,n.projectionMatrix,this._frustum,T);{const e=n.eye,r=z;t(r,T[4],e);const o=.5*i(r,r)/i(this._viewDirection,r),a=this._frustumMbs,c=a.center;s(c,e,this._viewDirection,o);const u=1+o;a.radius=u}}this._screenSizeFactor=1/(n.perScreenPixelRatio/2),this._camPos=n.eye,this._updateCameraPOIDirection(),this.minDistance=1/0,this.maxDistance=0}setPointOfInterest(e){this._poi=e,this._updateCameraPOIDirection()}updateScreenSpaceErrorBias(e){const t=this._screenspaceErrorBias;return this._screenspaceErrorBias=e,t}updateClippingArea(e){this._clippingArea=e}expandElevationRange(e,t,i){if(null==this._elevationContext)return;const s=e.serviceMbsInIndexSR;if(!s)return;const n="relative-to-scene"===this._elevationContext.mode?"scene":"ground",r=this._elevationProvider;if(r.getSphereElevationRange){const e=r.getSphereElevationRange(s,this._indexSR,n);if(e)return void i.expandElevationRange(e)}const[o,a,c]=s.center,u=r.getElevation(o,a,c,this._indexSR,n);u&&i.expandElevationRangeValues(u,u);const l=t?null:r.getRootElevationRange?.();l&&i.expandElevationRange(l)}calculateServiceMbsInRenderSR(e){const{serviceMbsInRenderSR:t}=e;if(t.isValid)return t;const{serviceMbsInIndexSR:i}=e;if(!i?.isValid)return t;const s=ie;return b(i,this._indexSR,s,this._renderSR),e.updateServiceMbsInRenderSR(s)}calculateServiceMbsInRenderSRElevationAdjusted(e){const{serviceMbsInRenderSRElevationAdjusted:t}=e;if(t.isValid)return t;const{serviceMbsInIndexSR:i}=e,s=this.calculateServiceMbsInRenderSR(e);if(!s.isValid||!i?.isValid)return t;const n=ie;n.copyFrom(s);const{_elevationContext:r}=this;if(r){const{minElevation:t}=e,{_renderCoordsHelper:s}=this,o=i.center;let a=0;if(Number.isFinite(t)){let i=0,c=0;const{maxElevation:u}=e,l=o[2];switch(r.mode){case"relative-to-ground":case"relative-to-scene":i=r.geometryZWithOffset(l,s)+t-l,c=u-t;break;case"on-the-ground":i=t-l,c=u-t}a=i+.5*c,n.radius+=.5*c}else n.radius<q&&(a=O(o,this._elevationProvider,r,s)-o[2]);a&&ae(n,a,this._viewingMode)}return e.updateServiceMbsInRenderSRElevationAdjusted(n)}calculateMbsConeInRenderSR(e){const{mbsConeInRenderSR:t}=e;if(t)return t;if(!e.elevationRangeValid)return null;const{minElevation:i,maxElevation:s}=e;if(!(Number.isFinite(i)&&i<s))return null;const n=this.calculateServiceMbsInRenderSR(e);if(!n.isValid)return null;const r=this._renderCoordsHelper.referenceEllipsoid.radius,o=2===this._viewingMode?new L(n,i,s):new w(n,r+i,r+s);return e.updateMbsConeInRenderSR(o)}getAndUpdateVisibilityObbInRenderSR(e){{const t=e.visibilityObbInRenderSR;if(t)return t}const t=.01*this._indexSREllipsoidRadius,{serviceMbsInIndexSR:i,serviceObbInIndexSR:s}=e;if(null==s||!i||!s.isValid||this._isECEFOBBInLocalMode&&(s.halfSizeX>t||s.halfSizeY>t||s.halfSizeZ>t))return null;{let t=e.serviceObbInRenderSR;if(null==t)t=new y,e.serviceObbInRenderSR=t;else if(t.isValid)return t;const r=i.radius;let o=0,a=0;const c=s.centerZ,u=this._renderCoordsHelper,l=this._elevationContext;if(l&&e.elevationRangeValid){const{minElevation:t,maxElevation:i}=e;switch(l.mode){case"relative-to-ground":case"relative-to-scene":o=l.geometryZWithOffset(c,u)+t-c,a=i-t;break;case"on-the-ground":o=t-c,a=i-t}}else if(l&&r<q){const e=n(Y,s.centerX,s.centerY,c);o=O(e,this._elevationProvider,l,u)-c}const d=a>0,h=d?X:t;return s.transform(h,this._indexSR,this._renderSR,o,this._renderSRSphericalPCPF,this._indexSRSphericalPCPF,this._projectorIndexSRToIndexSRSphericalPCPF),d&&U(h,0,a,this._viewingMode,t),t}}getNodeObbInRenderSRIndependentOfElevationOffset(e){{const t=e.visibilityObbInRenderSR??e.serviceObbInRenderSR??null;if(t?.isValid)return t}const t=e.serviceObbInIndexSR;return t?(t.transform(X,this._indexSR,this._renderSR,void 0,this._renderSRSphericalPCPF,this._indexSRSphericalPCPF,this._projectorIndexSRToIndexSRSphericalPCPF),X):null}ensureElevationAgnosticBoundingVolume(e){return!e.elevationAgnosticBoundingVolume.valid&&e.level>0&&(1===this._viewingMode?this._updateElevationAgnosticBoundingVolumeGlobal(e):this._updateElevationAgnosticBoundingVolumeLocal(e)),e.elevationAgnosticBoundingVolume}_updateCameraPOIDirection(){r(this._poi,this._camPos)?this._cameraPOIDirection=this._viewDirection:(o(this._cameraPOIDirection,this._camPos,this._poi),e(this._cameraPOIDirection,this._cameraPOIDirection))}_updateElevationAgnosticBoundingVolumeGlobal(t){const s=this.getNodeObbInRenderSRIndependentOfElevationOffset(t),n=t.elevationAgnosticBoundingVolume;let r,o=-1;if(s){const t=Y;s.getCenter(t),e(t,t),r=t,s.getCorners(J);for(const s of J){e(s,s);const r=i(s,t);if(r<=0)return void n.invalidate();const a=Math.sqrt(1-r*r);o=Math.max(o,a)}}else{const i=t.serviceMbsInRenderSR;if(!i.isValid)return void n.invalidate();const{center:s,radius:c}=i,u=a(s);if(u<c)return void n.invalidate();o=c/u,r=e(te,s)}n.set(r,o+ce)}_updateElevationAgnosticBoundingVolumeLocal(e){const t=e.elevationAgnosticBoundingVolume,i=this.getNodeObbInRenderSRIndependentOfElevationOffset(e);if(i){const e=i.getCenter(Y);e[2]=0;let s=0;const n=K;i.getCorners(J);for(const t of J){t[2]=0;const e=c(n,t);s=Math.max(s,e)}t.set(e,Math.sqrt(s))}else{const i=e.serviceMbsInRenderSR;if(i.isValid){const e=u(Y,i.center);e[2]=0,t.set(e,i.radius)}}}isNodeVisible(e){if(!this._isMBSinClippingArea(this.calculateServiceMbsInRenderSR(e)))return!1;if(!this._useFrustumCulling)return!0;const t=this.getAndUpdateVisibilityObbInRenderSR(e);return t?t.intersectsFrustumConservativeApproximation(this._frustum):I(this._frustum,this.calculateServiceMbsInRenderSRElevationAdjusted(e))}isElevationAgnosticBoundingVolumeVisible(e){return!this._useFrustumCulling||(!e.valid||(1===this._viewingMode?this._isConeVisibleInFrustum(e):this._isCylinderVisibleInFrustum(e)))}_isConeVisibleInFrustum(n){if(!this._isConeVisibleInFrustumMbs(n)||!n.valid)return!1;const r=n.radius;if(r>.9)return!0;const o=this._frustumPlanes,a=this._frustumMbsCenter,c=n.getAxis(te),u=i(c,a),d=this._frustumMbsRadius,h=u-d,m=u+d;if(h<=0)return!0;const _=l(k,c,h),p=l(H,c,m),f=r/Math.sqrt(1-r*r);for(const v of o){const n=D(v),r=e(Z,n),o=i(r,c);if(Math.abs(1-o)<.01)continue;const a=Q;l(a,c,o),t(a,a,r),e(a,a);const u=$;s(u,_,a,h*f);if(E(v,u)<=0)continue;s(u,p,a,m*f);if(E(v,u)<=0)continue;return!1}return!0}_isConeVisibleInFrustumMbs(e){const t=e.radius;if(t>.9)return!0;const s=this._frustumMbsRadius,n=this._frustumMbsCenter,r=a(n);if(r<=s)return!0;const o=e.getAxis(te),c=i(o,n);{const e=l(W,o,c);if(d(e,n)<s)return!0}const u=c/r;if(c<=0){return-u<s}const h=Math.sqrt(1-u*u);if(h<t)return!0;const m=s/r;return h*Math.sqrt(1-m*m)-m*u<t}isObbVisibleIndependentOfElevation(e,t){if(!this._useFrustumCulling)return!0;if(!e.valid)return!0;const s=this._frustumMbsRadius,n=this._frustumMbsCenter,r=this._frustumPlanes,o=J;if(t.getCorners(o),1===this._viewingMode){const t=e.getAxis(te),a=i(t,n),c=a-s,u=a+s;if(c<=0)return!0;for(const e of r){let s=!0;for(const n of o){const r=i(n,t),o=ee;if(l(o,n,c/r),E(e,o)<=0){s=!1;break}const a=ee;if(l(a,n,u/r),E(e,a)<=0){s=!1;break}}if(s)return!1}}else{const e=n[2]-s,t=n[2]+s;for(const i of r){let s=!0;const n=D(i),r=n[0],a=n[1],c=n[2],u=i[3];for(const i of o){const n=r*i[0]+a*i[1]+u;if(n+c*e<=0||n+c*t<=0){s=!1;break}}if(s)return!1}}return!0}_isCylinderVisibleInFrustum(e){const t=this._frustumMbsCenter,i=this._frustumMbsRadius,s=u(W,t);s[2]=0;const n=e.radius,r=e.getAxis(te);return d(s,r)<=n+i}isGeometryVisible(e){if(!this._useFrustumCulling)return!0;const t=e.geometryObbInRenderSR;return t?.intersectsFrustumConservativeApproximation(this._frustum)??this.isNodeVisible(e)}_isMBSinClippingArea(e){return null==this._clippingArea||0!==B(this._clippingArea,e)}_screenSpaceDiameterMbs(e,t){const i=this.calcCameraDistanceAndUpdateMinmaxWithCone(e);return i<0?.5*Number.MAX_VALUE:t/i*this._screenSizeFactor}calcCameraDistanceAndUpdateMinmaxWithCone(e){const t=this.calculateMbsConeInRenderSR(e),i=t?.calculateSurfaceDistanceFromPoint(this._camPos)??this.calcCameraDistanceAndUpdateMinmax(e);return t&&this._updateMinMaxDistance(i),i}calcCameraDistanceAndUpdateMinmax(e){return this.calcCameraDistanceToCenterAndUpdateMinmax(e)-this.calculateServiceMbsInRenderSRElevationAdjusted(e).radius}calcCameraDistanceToCenterAndUpdateMinmax(e){const t=this.calculateServiceMbsInRenderSRElevationAdjusted(e),i=h(t.center,this._camPos);return this._updateMinMaxDistance(i),i}calcAngleDependentLoD(e){const{center:s,radius:n}=this.calculateServiceMbsInRenderSRElevationAdjusted(e),r=t(K,s,this._camPos),o=(Math.abs(i(s,r))/m(s)+n)/m(r);return Math.min(1,o)}hasLOD(e){return 0!==e.lodMetric}_getDistanceGlobeMode(e,t){const s=m(t.center),n=m(e)-s;l(se,e,i(e,t.center)/_(e));const r=p(t.center,se),a=t.radius;if(r<=a*a)return Math.abs(n);{const r=l(se,t.center,1/s),c=l(ne,r,s-a*a/2/s),u=e,d=o(re,u,c),_=o(re,d,l(oe,r,i(r,d))),p=f(re,c,l(re,_,a/m(_)));let v=h(u,p);if(n>=2e5){const e=o(ne,u,p);let t=i(e,r)/m(e);t<.08&&(t=1e-4),v/=t}return v}}_getDistance(e,t){return this._isGlobalMode?this._getDistanceGlobeMode(e,t):N(e,t)}_updateMinMaxDistance(e){e>0?(this.minDistance=Math.min(this.minDistance,e),this.maxDistance=Math.max(this.maxDistance,e)):(this.minDistance=0,this.maxDistance=Math.max(this.maxDistance,-e))}getLodLevel(e){if(0===e.lodMetric)return 0;if(0===e.childCount)return this.maxLodLevel;if(this._useFrustumCulling&&this._progressiveLoadFactor<1){const t=this._progressiveLoadFactor*this._screenspaceErrorBias,i=this._screenspaceErrorBias;return this.evaluateLODmetric(e,t)?this.evaluateLODmetric(e,i)?2:1:0}return this.evaluateLODmetric(e,this._screenspaceErrorBias)?this.maxLodLevel:0}evaluateLODmetric(e,t){switch(e.lodMetric){case 1:{let i=this._screenSpaceDiameterMbs(e,(e.serviceMbsInIndexSR?.radius??0)*t);return this._options.angleDependentLoD&&(i*=this.calcAngleDependentLoD(e)),i<e.maxError}case 2:{const i=this.calculateServiceMbsInRenderSRElevationAdjusted(e),s=this._getDistance(this._camPos,i),n=2*s/this._screenSizeFactor,r=s+i.radius;return this._updateMinMaxDistance(r),e.maxError*t<=n}case 3:return this._screenSpaceDiameterMbs(e,e.maxError)*t<10;case 4:return this.calcCameraDistanceAndUpdateMinmax(e)>e.maxError*t}return!1}distToCameraPOIRay(e){if(null==e)return 0;const t=this.calculateServiceMbsInRenderSRElevationAdjusted(e),s=t.center,n=i(s,this._cameraPOIDirection),r=n*n,o=_(s)-r;return Math.sqrt(o)-t.radius}distCameraToPOI(){return h(this._camPos,this._poi)}}function N(e,t){const i=e[0]-t.center[0],s=e[1]-t.center[1],n=e[2]-t.center[2],r=i*i+s*s,o=t.radius;if(r<=o*o)return Math.abs(n);const a=Math.sqrt(r)-o;return Math.sqrt(n*n+a*a)}const T=C(),z=v(),W=v(),k=v(),H=v(),Z=v(),X=new y,Y=v(),J=[v(),v(),v(),v(),v(),v(),v(),v()],K=v(),Q=v(),$=v(),ee=v(),te=v(),ie=new A,se=v(),ne=v(),re=v(),oe=v();function ae(e,t,i){if(2===i)e.center[2]+=t;else{const i=m(e.center);l(e.center,e.center,1+t/i)}}const ce=.001;export{G as default};
|
|
2
|
+
import{normalize as e,sub as t,dot as i,scaleAndAdd as s,set as n,equals as r,subtract as o,len as a,sqrDist as c,copy as u,scale as l,dist as d,distance as h,length as m,squaredLength as _,squaredDistance as p,add as f}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as v}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{getReferenceEllipsoid as R}from"../../../../geometry/ellipsoidUtils.js";import{getSphericalPCPF as S}from"../../../../geometry/spatialReferenceEllipsoidUtils.js";import{projectBoundingSphere as b}from"../../../../geometry/projection/projectBoundingSphere.js";import{getProjector as g}from"../../../../geometry/projection/projectors.js";import{create as M,fromMatrix as x,intersectsSphere as I,createPoints as C}from"../../../../geometry/support/frustum.js";import{signedDistance as E,getNormal as D}from"../../../../geometry/support/plane.js";import{isPlateCarree as P}from"../../../../geometry/support/spatialReferenceUtils.js";import{Sphere as A}from"../../../../geometry/support/sphere.js";import{evaluateElevationAlignmentAtPoint as O}from"../graphics/elevationAlignmentUtils.js";import{ElevationContext as F}from"../graphics/ElevationContext.js";import{createContextWithoutExpressionSupport as V,extractExpressionInfo as j}from"../graphics/featureExpressionInfoUtils.js";import{intersectBoundingRectWithMbs as B}from"./I3SUtil.js";import{SphereCylinderLocal as w,SphereConeGlobal as L}from"./SphereCone.js";import{Obb as y,computeOffsetObb as U}from"../../support/orientedBoundingBox.js";const q=1e5;class G{get _frustumMbsCenter(){return this._frustumMbs.center}get _frustumMbsRadius(){return this._frustumMbs.radius}get _frustumPlanes(){return this._frustum}constructor(e,t,i,s,n,r,o,a,c={}){this._indexSR=e,this._renderCoordsHelper=t,this._clippingArea=n,this._elevationProvider=r,this._viewingMode=o,this._options=c,this._frustum=M(),this._frustumMbs=new A,this._viewDirection=v(),this._useFrustumCulling=!1,this._poi=v(),this._cameraPOIDirection=v(),this._elevationContext=null,this.minDistance=1/0,this.maxDistance=0,this.maxLodLevel=2,this._screenspaceErrorBias=c.screenspaceErrorBias||1,this._progressiveLoadFactor=c.progressiveLoadFactor||1,this.updateCamera(i,s);const u=this._renderCoordsHelper.spatialReference;this._renderSR=u,this._renderSRSphericalPCPF=S(u),this._isGlobalMode=u===this._renderSRSphericalPCPF,this.updateElevationInfo(a),this._isECEFOBBInLocalMode=this._indexSR.isWGS84&&(u.isWebMercator||P(u)),this._indexSREllipsoidRadius=R(this._indexSR).radius,this._indexSRSphericalPCPF=S(e),this._projectorIndexSRToIndexSRSphericalPCPF=g(this._indexSR,this._indexSRSphericalPCPF)}updateElevationInfo(e){null!=e?(this._elevationContext=F.fromElevationInfo(e),this._elevationContext.setFeatureExpressionInfoContext(V(j(e,!1)))):this._elevationContext=null}updateCamera(n,r){if(this._useFrustumCulling=r,e(this._viewDirection,n.viewForward),r){x(n.viewMatrix,n.projectionMatrix,this._frustum,z);{const e=n.eye,r=T;t(r,z[4],e);const o=.5*i(r,r)/i(this._viewDirection,r),a=this._frustumMbs,c=a.center;s(c,e,this._viewDirection,o);const u=1+o;a.radius=u}}this._screenSizeFactor=1/(n.perScreenPixelRatio/2),this._camPos=n.eye,this._updateCameraPOIDirection(),this.minDistance=1/0,this.maxDistance=0}setPointOfInterest(e){this._poi=e,this._updateCameraPOIDirection()}updateScreenSpaceErrorBias(e){const t=this._screenspaceErrorBias;return this._screenspaceErrorBias=e,t}updateClippingArea(e){this._clippingArea=e}expandElevationRange(e,t,i){if(null==this._elevationContext)return;const s=e.serviceMbsInIndexSR;if(!s)return;const n="relative-to-scene"===this._elevationContext.mode?"scene":"ground",r=this._elevationProvider;if(r.getSphereElevationRange){const e=r.getSphereElevationRange(s,this._indexSR,n);if(e)return void i.expandElevationRange(e)}const[o,a,c]=s.center,u=r.getElevation(o,a,c,this._indexSR,n);u&&i.expandElevationRangeValues(u,u);const l=t?null:r.getRootElevationRange?.();l&&i.expandElevationRange(l)}calculateServiceMbsInRenderSR(e){const{serviceMbsInRenderSR:t}=e;if(t.isValid)return t;const{serviceMbsInIndexSR:i}=e;if(!i?.isValid)return t;const s=ie;return b(i,this._indexSR,s,this._renderSR),e.updateServiceMbsInRenderSR(s)}calculateServiceMbsInRenderSRElevationAdjusted(e){const{serviceMbsInRenderSRElevationAdjusted:t}=e;if(t.isValid)return t;const{serviceMbsInIndexSR:i}=e,s=this.calculateServiceMbsInRenderSR(e);if(!s.isValid||!i?.isValid)return t;const n=ie;n.copyFrom(s);const{_elevationContext:r}=this;if(r){const{minElevation:t}=e,{_renderCoordsHelper:s}=this,o=i.center;let a=0;if(Number.isFinite(t)){let i=0,c=0;const{maxElevation:u}=e,l=o[2];switch(r.mode){case"relative-to-ground":case"relative-to-scene":i=r.geometryZWithOffset(l,s)+t-l,c=u-t;break;case"on-the-ground":i=t-l,c=u-t}a=i+.5*c,n.radius+=.5*c}else n.radius<q&&(a=O(o,this._elevationProvider,r,s)-o[2]);a&&ae(n,a,this._viewingMode)}return e.updateServiceMbsInRenderSRElevationAdjusted(n)}calculateMbsConeInRenderSR(e){const{mbsConeInRenderSR:t}=e;if(t)return t;if(!e.elevationRangeValid)return null;const{minElevation:i,maxElevation:s}=e;if(!(Number.isFinite(i)&&i<s))return null;const n=this.calculateServiceMbsInRenderSR(e);if(!n.isValid)return null;const r=this._renderCoordsHelper.referenceEllipsoid.radius,o=2===this._viewingMode?new w(n,i,s):new L(n,r+i,r+s);return e.updateMbsConeInRenderSR(o)}getAndUpdateVisibilityObbInRenderSR(e){{const t=e.visibilityObbInRenderSR;if(t)return t}const t=.01*this._indexSREllipsoidRadius,{serviceMbsInIndexSR:i,serviceObbInIndexSR:s}=e;if(null==s||!i||!s.isValid||this._isECEFOBBInLocalMode&&(s.halfSizeX>t||s.halfSizeY>t||s.halfSizeZ>t))return null;{let t=e.serviceObbInRenderSR;if(null==t)t=new y,e.serviceObbInRenderSR=t;else if(t.isValid)return t;const r=i.radius;let o=0,a=0;const c=s.centerZ,u=this._renderCoordsHelper,l=this._elevationContext;if(l&&e.elevationRangeValid){const{minElevation:t,maxElevation:i}=e;switch(l.mode){case"relative-to-ground":case"relative-to-scene":o=l.geometryZWithOffset(c,u)+t-c,a=i-t;break;case"on-the-ground":o=t-c,a=i-t}}else if(l&&r<q){const e=n(Y,s.centerX,s.centerY,c);o=O(e,this._elevationProvider,l,u)-c}const d=a>0,h=d?X:t;return s.transform(h,this._indexSR,this._renderSR,o,this._renderSRSphericalPCPF,this._indexSRSphericalPCPF,this._projectorIndexSRToIndexSRSphericalPCPF),d&&U(h,0,a,this._viewingMode,t),t}}getNodeObbInRenderSRIndependentOfElevationOffset(e){{const t=e.visibilityObbInRenderSR??e.serviceObbInRenderSR??null;if(t?.isValid)return t}const t=e.serviceObbInIndexSR;if(!t)return null;const i=.2;return 2===this._viewingMode&&Math.max(...t.halfSize)>i*this._indexSREllipsoidRadius?null:(t.transform(X,this._indexSR,this._renderSR,void 0,this._renderSRSphericalPCPF,this._indexSRSphericalPCPF,this._projectorIndexSRToIndexSRSphericalPCPF),X)}ensureElevationAgnosticBoundingVolume(e){return!e.elevationAgnosticBoundingVolume.valid&&e.level>0&&(1===this._viewingMode?this._updateElevationAgnosticBoundingVolumeGlobal(e):this._updateElevationAgnosticBoundingVolumeLocal(e)),e.elevationAgnosticBoundingVolume}_updateCameraPOIDirection(){r(this._poi,this._camPos)?this._cameraPOIDirection=this._viewDirection:(o(this._cameraPOIDirection,this._camPos,this._poi),e(this._cameraPOIDirection,this._cameraPOIDirection))}_updateElevationAgnosticBoundingVolumeGlobal(t){const s=this.getNodeObbInRenderSRIndependentOfElevationOffset(t),n=t.elevationAgnosticBoundingVolume;let r,o=-1;if(s){const t=Y;s.getCenter(t),e(t,t),r=t,s.getCorners(J);for(const s of J){e(s,s);const r=i(s,t);if(r<=0)return void n.invalidate();const a=Math.sqrt(1-r*r);o=Math.max(o,a)}}else{const i=t.serviceMbsInRenderSR;if(!i.isValid)return void n.invalidate();const{center:s,radius:c}=i,u=a(s);if(u<c)return void n.invalidate();o=c/u,r=e(te,s)}n.set(r,o+ce)}_updateElevationAgnosticBoundingVolumeLocal(e){const t=e.elevationAgnosticBoundingVolume,i=this.getNodeObbInRenderSRIndependentOfElevationOffset(e);if(i){const e=i.getCenter(Y);e[2]=0;let s=0;const n=K;i.getCorners(J);for(const t of J){t[2]=0;const e=c(n,t);s=Math.max(s,e)}t.set(e,Math.sqrt(s))}else{const i=e.serviceMbsInRenderSR;if(i.isValid){const e=u(Y,i.center);e[2]=0,t.set(e,i.radius)}}}isNodeVisible(e){if(!this._isMBSinClippingArea(this.calculateServiceMbsInRenderSR(e)))return!1;if(!this._useFrustumCulling)return!0;const t=this.getAndUpdateVisibilityObbInRenderSR(e);return t?t.intersectsFrustumConservativeApproximation(this._frustum):I(this._frustum,this.calculateServiceMbsInRenderSRElevationAdjusted(e))}isElevationAgnosticBoundingVolumeVisible(e){return!this._useFrustumCulling||(!e.valid||(1===this._viewingMode?this._isConeVisibleInFrustum(e):this._isCylinderVisibleInFrustum(e)))}_isConeVisibleInFrustum(n){if(!this._isConeVisibleInFrustumMbs(n)||!n.valid)return!1;const r=n.radius;if(r>.9)return!0;const o=this._frustumPlanes,a=this._frustumMbsCenter,c=n.getAxis(te),u=i(c,a),d=this._frustumMbsRadius,h=u-d,m=u+d;if(h<=0)return!0;const _=l(k,c,h),p=l(H,c,m),f=r/Math.sqrt(1-r*r);for(const v of o){const n=D(v),r=e(Z,n),o=i(r,c);if(Math.abs(1-o)<.01)continue;const a=Q;l(a,c,o),t(a,a,r),e(a,a);const u=$;s(u,_,a,h*f);if(E(v,u)<=0)continue;s(u,p,a,m*f);if(E(v,u)<=0)continue;return!1}return!0}_isConeVisibleInFrustumMbs(e){const t=e.radius;if(t>.9)return!0;const s=this._frustumMbsRadius,n=this._frustumMbsCenter,r=a(n);if(r<=s)return!0;const o=e.getAxis(te),c=i(o,n);{const e=l(W,o,c);if(d(e,n)<s)return!0}const u=c/r;if(c<=0){return-u<s}const h=Math.sqrt(1-u*u);if(h<t)return!0;const m=s/r;return h*Math.sqrt(1-m*m)-m*u<t}isObbVisibleIndependentOfElevation(e,t){if(!this._useFrustumCulling)return!0;if(!e.valid)return!0;const s=this._frustumMbsRadius,n=this._frustumMbsCenter,r=this._frustumPlanes,o=J;if(t.getCorners(o),1===this._viewingMode){const t=e.getAxis(te),a=i(t,n),c=a-s,u=a+s;if(c<=0)return!0;for(const e of r){let s=!0;for(const n of o){const r=i(n,t),o=ee;if(l(o,n,c/r),E(e,o)<=0){s=!1;break}const a=ee;if(l(a,n,u/r),E(e,a)<=0){s=!1;break}}if(s)return!1}}else{const e=n[2]-s,t=n[2]+s;for(const i of r){let s=!0;const n=D(i),r=n[0],a=n[1],c=n[2],u=i[3];for(const i of o){const n=r*i[0]+a*i[1]+u;if(n+c*e<=0||n+c*t<=0){s=!1;break}}if(s)return!1}}return!0}_isCylinderVisibleInFrustum(e){const t=this._frustumMbsCenter,i=this._frustumMbsRadius,s=u(W,t);s[2]=0;const n=e.radius,r=e.getAxis(te);return d(s,r)<=n+i}isGeometryVisible(e){if(!this._useFrustumCulling)return!0;const t=e.geometryObbInRenderSR;return t?.intersectsFrustumConservativeApproximation(this._frustum)??this.isNodeVisible(e)}_isMBSinClippingArea(e){return null==this._clippingArea||0!==B(this._clippingArea,e)}_screenSpaceDiameterMbs(e,t){const i=this.calcCameraDistanceAndUpdateMinmaxWithCone(e);return i<0?.5*Number.MAX_VALUE:t/i*this._screenSizeFactor}calcCameraDistanceAndUpdateMinmaxWithCone(e){const t=this.calculateMbsConeInRenderSR(e),i=t?.calculateSurfaceDistanceFromPoint(this._camPos)??this.calcCameraDistanceAndUpdateMinmax(e);return t&&this._updateMinMaxDistance(i),i}calcCameraDistanceAndUpdateMinmax(e){return this.calcCameraDistanceToCenterAndUpdateMinmax(e)-this.calculateServiceMbsInRenderSRElevationAdjusted(e).radius}calcCameraDistanceToCenterAndUpdateMinmax(e){const t=this.calculateServiceMbsInRenderSRElevationAdjusted(e),i=h(t.center,this._camPos);return this._updateMinMaxDistance(i),i}calcAngleDependentLoD(e){const{center:s,radius:n}=this.calculateServiceMbsInRenderSRElevationAdjusted(e),r=t(K,s,this._camPos),o=(Math.abs(i(s,r))/m(s)+n)/m(r);return Math.min(1,o)}hasLOD(e){return 0!==e.lodMetric}_getDistanceGlobeMode(e,t){const s=m(t.center),n=m(e)-s;l(se,e,i(e,t.center)/_(e));const r=p(t.center,se),a=t.radius;if(r<=a*a)return Math.abs(n);{const r=l(se,t.center,1/s),c=l(ne,r,s-a*a/2/s),u=e,d=o(re,u,c),_=o(re,d,l(oe,r,i(r,d))),p=f(re,c,l(re,_,a/m(_)));let v=h(u,p);if(n>=2e5){const e=o(ne,u,p);let t=i(e,r)/m(e);t<.08&&(t=1e-4),v/=t}return v}}_getDistance(e,t){return this._isGlobalMode?this._getDistanceGlobeMode(e,t):N(e,t)}_updateMinMaxDistance(e){e>0?(this.minDistance=Math.min(this.minDistance,e),this.maxDistance=Math.max(this.maxDistance,e)):(this.minDistance=0,this.maxDistance=Math.max(this.maxDistance,-e))}getLodLevel(e){if(0===e.lodMetric)return 0;if(0===e.childCount)return this.maxLodLevel;if(this._useFrustumCulling&&this._progressiveLoadFactor<1){const t=this._progressiveLoadFactor*this._screenspaceErrorBias,i=this._screenspaceErrorBias;return this.evaluateLODmetric(e,t)?this.evaluateLODmetric(e,i)?2:1:0}return this.evaluateLODmetric(e,this._screenspaceErrorBias)?this.maxLodLevel:0}evaluateLODmetric(e,t){switch(e.lodMetric){case 1:{let i=this._screenSpaceDiameterMbs(e,(e.serviceMbsInIndexSR?.radius??0)*t);return this._options.angleDependentLoD&&(i*=this.calcAngleDependentLoD(e)),i<e.maxError}case 2:{const i=this.calculateServiceMbsInRenderSRElevationAdjusted(e),s=this._getDistance(this._camPos,i),n=2*s/this._screenSizeFactor,r=s+i.radius;return this._updateMinMaxDistance(r),e.maxError*t<=n}case 3:return this._screenSpaceDiameterMbs(e,e.maxError)*t<10;case 4:return this.calcCameraDistanceAndUpdateMinmax(e)>e.maxError*t}return!1}distToCameraPOIRay(e){if(null==e)return 0;const t=this.calculateServiceMbsInRenderSRElevationAdjusted(e),s=t.center,n=i(s,this._cameraPOIDirection),r=n*n,o=_(s)-r;return Math.sqrt(o)-t.radius}distCameraToPOI(){return h(this._camPos,this._poi)}}function N(e,t){const i=e[0]-t.center[0],s=e[1]-t.center[1],n=e[2]-t.center[2],r=i*i+s*s,o=t.radius;if(r<=o*o)return Math.abs(n);const a=Math.sqrt(r)-o;return Math.sqrt(n*n+a*a)}const z=C(),T=v(),W=v(),k=v(),H=v(),Z=v(),X=new y,Y=v(),J=[v(),v(),v(),v(),v(),v(),v(),v()],K=v(),Q=v(),$=v(),ee=v(),te=v(),ie=new A,se=v(),ne=v(),re=v(),oe=v();function ae(e,t,i){if(2===i)e.center[2]+=t;else{const i=m(e.center);l(e.center,e.center,1+t/i)}}const ce=.001;export{G as default};
|
|
@@ -48,8 +48,8 @@ export interface RenderNodeProperties extends Partial<Pick<RenderNode, "produces
|
|
|
48
48
|
* ```js
|
|
49
49
|
* new LuminanceRenderNode({ view });
|
|
50
50
|
* ```
|
|
51
|
-
* A RenderNode subclass is created using [Accessor.createSubclass()](https://developers.arcgis.com/javascript/latest/references/core/core/Accessor/#createSubclass). This example
|
|
52
|
-
*
|
|
51
|
+
* A RenderNode subclass is created using [Accessor.createSubclass()](https://developers.arcgis.com/javascript/latest/references/core/core/Accessor/#createSubclass). This example node modifies the "composite-color"
|
|
52
|
+
* output of the render pipeline:
|
|
53
53
|
* ```js
|
|
54
54
|
* const LuminanceRenderNode = RenderNode.createSubclass({
|
|
55
55
|
* consumes: { required: ["composite-color"] }
|
|
@@ -67,9 +67,9 @@ export interface RenderNodeProperties extends Partial<Pick<RenderNode, "produces
|
|
|
67
67
|
* [SceneView](https://developers.arcgis.com/javascript/latest/references/core/views/SceneView/). Every time a node is traversed, the render engine will modify or create
|
|
68
68
|
* framebuffers.
|
|
69
69
|
* For example, the render graph in the images shown
|
|
70
|
-
* [below](https://developers.arcgis.com/javascript/latest/references/core/views/3d/webgl/RenderNode/#render-node-input-images)
|
|
71
|
-
* one transparent cube, the terrain with textures, atmosphere effects, and post
|
|
72
|
-
* antialiasing.
|
|
70
|
+
* [below](https://developers.arcgis.com/javascript/latest/references/core/views/3d/webgl/RenderNode/#render-node-input-images)
|
|
71
|
+
* contains nodes which render buildings, one transparent cube, the terrain with textures, atmosphere effects, and post
|
|
72
|
+
* processing effects such as antialiasing.
|
|
73
73
|
*
|
|
74
74
|
* Depending on the [SceneView](https://developers.arcgis.com/javascript/latest/references/core/views/SceneView/) properties and layer configuration, the rendering engine
|
|
75
75
|
* modifies the render graph to traverse the nodes which are required to produce the configured rendering. The
|
|
@@ -78,13 +78,13 @@ export interface RenderNodeProperties extends Partial<Pick<RenderNode, "produces
|
|
|
78
78
|
*
|
|
79
79
|
* The [RenderNode](https://developers.arcgis.com/javascript/latest/references/core/views/3d/webgl/RenderNode/) class offers a way to inject custom render code to this render
|
|
80
80
|
* pipeline. Currently the following outputs can be modified by custom render nodes:
|
|
81
|
-
* * **opaque-color**
|
|
82
|
-
* * **transparent-color**
|
|
83
|
-
* * **composite-color**
|
|
84
|
-
* * **final-color**
|
|
85
81
|
*
|
|
86
|
-
*
|
|
87
|
-
*
|
|
82
|
+
* | [RenderNodeOutput](https://developers.arcgis.com/javascript/latest/references/core/views/3d/webgl/#RenderNodeOutput) | Description |
|
|
83
|
+
* |---------- | ----------- |
|
|
84
|
+
* | opaque-color | Contains the rendered image after all opaque geometries have been drawn. |
|
|
85
|
+
* | transparent-color | Contains the rendered image after all opaque and transparent geometries have been drawn |
|
|
86
|
+
* | composite-color | Contains the rendered image without any post processes applied. |
|
|
87
|
+
* | final-color | Contains the rendered image including post processes. |
|
|
88
88
|
*
|
|
89
89
|
* Important to note is that the chronological order for traversing the render graph does not correspond to the
|
|
90
90
|
* object location in the frame. For example, all opaque objects are rendered first even if they are behind transparent
|
|
@@ -92,58 +92,49 @@ export interface RenderNodeProperties extends Partial<Pick<RenderNode, "produces
|
|
|
92
92
|
* [alpha blending](https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/blendFunc) will
|
|
93
93
|
* create the correct visibility.
|
|
94
94
|
*
|
|
95
|
-
* Once the injection point is declared with [produces](https://developers.arcgis.com/javascript/latest/references/core/views/3d/webgl/RenderNode/#produces), the
|
|
96
|
-
* [
|
|
97
|
-
*
|
|
98
|
-
*
|
|
99
|
-
* output.
|
|
95
|
+
* Once the injection point is declared with [produces](https://developers.arcgis.com/javascript/latest/references/core/views/3d/webgl/RenderNode/#produces), the [render()](https://developers.arcgis.com/javascript/latest/references/core/views/3d/webgl/RenderNode/#render)
|
|
96
|
+
* function needs to return this output in a [ManagedFBO](https://developers.arcgis.com/javascript/latest/references/core/views/3d/webgl/ManagedFBO/) for the RenderNode to be correctly
|
|
97
|
+
* traversed. The output is also provided as an input, and typically this input is read as a texture or bound as the
|
|
98
|
+
* framebuffer to create the output.
|
|
100
99
|
*
|
|
101
|
-
* See [produces](https://developers.arcgis.com/javascript/latest/references/core/views/3d/webgl/RenderNode/#produces) and
|
|
102
|
-
* [RenderNodeOutput](https://developers.arcgis.com/javascript/latest/references/core/views/3d/webgl/#RenderNodeOutput) for details.
|
|
100
|
+
* See [produces](https://developers.arcgis.com/javascript/latest/references/core/views/3d/webgl/RenderNode/#produces) and [RenderNodeOutput](https://developers.arcgis.com/javascript/latest/references/core/views/3d/webgl/#RenderNodeOutput) for details.
|
|
103
101
|
*
|
|
104
102
|
* #### RenderNode inputs
|
|
105
103
|
*
|
|
106
|
-
* Every [RenderNode](https://developers.arcgis.com/javascript/latest/references/core/views/3d/webgl/RenderNode/) requires some input
|
|
107
|
-
* [framebuffer objects](https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/createFramebuffer).
|
|
104
|
+
* Every [RenderNode](https://developers.arcgis.com/javascript/latest/references/core/views/3d/webgl/RenderNode/) requires some input [framebuffer objects](https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/createFramebuffer).
|
|
108
105
|
* Typically a node will modify the state of a framebuffer, using its output also as a required input. The
|
|
109
|
-
* [RenderNode](https://developers.arcgis.com/javascript/latest/references/core/views/3d/webgl/RenderNode/) offers additional input targets to be used as inputs for a rendering
|
|
110
|
-
*
|
|
106
|
+
* [RenderNode](https://developers.arcgis.com/javascript/latest/references/core/views/3d/webgl/RenderNode/) offers additional input targets to be used as inputs for a rendering code. These are
|
|
107
|
+
* used for advanced graphics effects. The following additional inputs are available:
|
|
111
108
|
*
|
|
112
109
|
* <span id="render-node-input-images"></span>
|
|
113
|
-
* |
|
|
114
|
-
* |
|
|
115
|
-
* |
|
|
110
|
+
* | <img src="https://developers.arcgis.com/javascript/latest/assets/references/core/views/3d/rendernodeCompositeColor.png" style="width:200px;"/> | <img src="https://developers.arcgis.com/javascript/latest/assets/references/core/views/3d/rendernodeCompositeColorDepth.png" style="width:200px;"/> | <img src="https://developers.arcgis.com/javascript/latest/assets/references/core/views/3d/rendernodeCompositeEmissive.png" style="width:200px;"/> | <img src="https://developers.arcgis.com/javascript/latest/assets/references/core/views/3d/rendernodeHighlight.png" style="width:200px;"/> | <img src="https://developers.arcgis.com/javascript/latest/assets/references/core/views/3d/rendernodeNormals.png" style="width:200px;"/> |
|
|
111
|
+
* | ---------- | ---------- | ---------- | ---------- | ---------- |
|
|
112
|
+
* | composite-color | composite-color depth attachment | composite-color emissive attachment | highlights | normals |
|
|
116
113
|
*
|
|
117
|
-
* If one of the required inputs is not available then this [RenderNode](https://developers.arcgis.com/javascript/latest/references/core/views/3d/webgl/RenderNode/) will be
|
|
118
|
-
*
|
|
119
|
-
*
|
|
120
|
-
*
|
|
121
|
-
* of the render function.
|
|
114
|
+
* If one of the required inputs is not available then this [RenderNode](https://developers.arcgis.com/javascript/latest/references/core/views/3d/webgl/RenderNode/) will be skipped during the
|
|
115
|
+
* frame. For example, a custom [RenderNode](https://developers.arcgis.com/javascript/latest/references/core/views/3d/webgl/RenderNode/) using highlights as required input will only render if
|
|
116
|
+
* highlights are present in the scene. Optional inputs do not cause the render node to be skipped while rendering. If
|
|
117
|
+
* optional inputs are not available they will not be present in the input parameter of the render function.
|
|
122
118
|
*
|
|
123
|
-
* Note that there are restrictions in availability due to the implicit ordering of the render graph as well. For
|
|
124
|
-
*
|
|
125
|
-
* [RenderNodeInput](https://developers.arcgis.com/javascript/latest/references/core/views/3d/webgl/#RenderNodeInput).
|
|
119
|
+
* Note that there are restrictions in availability due to the implicit ordering of the render graph as well. For example,
|
|
120
|
+
* opaque-color cannot require composite-color. See details in [RenderNodeInput](https://developers.arcgis.com/javascript/latest/references/core/views/3d/webgl/#RenderNodeInput).
|
|
126
121
|
*
|
|
127
122
|
* #### Managed framebuffer objects and attachments
|
|
128
123
|
*
|
|
129
|
-
* All render nodes have in common that they alter the state of a
|
|
130
|
-
*
|
|
131
|
-
*
|
|
132
|
-
*
|
|
133
|
-
* with the concept of
|
|
134
|
-
* [framebuffer objects](https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/createFramebuffer).
|
|
124
|
+
* All render nodes have in common that they alter the state of a [framebuffer object](https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/createFramebuffer).
|
|
125
|
+
* This happens either by simply drawing additional geometry "on top" of the input framebuffer, or by using the input as
|
|
126
|
+
* a Texture, e.g. to apply a post processing effect. See WebGL tutorials or the WebGL documentation to get familiar with
|
|
127
|
+
* the concept of [framebuffer objects](https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/createFramebuffer).
|
|
135
128
|
*
|
|
136
|
-
* The [ManagedFBO](https://developers.arcgis.com/javascript/latest/references/core/views/3d/webgl/ManagedFBO/) is a wrapper interface to request and provide framebuffer content
|
|
137
|
-
*
|
|
138
|
-
*
|
|
139
|
-
* See [ManagedFBO](https://developers.arcgis.com/javascript/latest/references/core/views/3d/webgl/ManagedFBO/) for details.
|
|
129
|
+
* The [ManagedFBO](https://developers.arcgis.com/javascript/latest/references/core/views/3d/webgl/ManagedFBO/) is a wrapper interface to request and provide framebuffer content to the render
|
|
130
|
+
* engine of the [SceneView](https://developers.arcgis.com/javascript/latest/references/core/views/SceneView/).The ManagedFBO exposes the necessary interface to reference count these
|
|
131
|
+
* framebuffer and attached textures to render nodes. See [ManagedFBO](https://developers.arcgis.com/javascript/latest/references/core/views/3d/webgl/ManagedFBO/) for details.
|
|
140
132
|
*
|
|
141
133
|
* <span id="coordinate-systems"></span>
|
|
142
134
|
* #### Coordinate systems
|
|
143
135
|
*
|
|
144
136
|
* When working with custom render nodes, coordinates have to be specified in the internal rendering coordinate system
|
|
145
|
-
* of SceneView. This coordinate system depends on the [SceneView.viewingMode](https://developers.arcgis.com/javascript/latest/references/core/views/SceneView/#viewingMode) of
|
|
146
|
-
* the view:
|
|
137
|
+
* of SceneView. This coordinate system depends on the [SceneView.viewingMode](https://developers.arcgis.com/javascript/latest/references/core/views/SceneView/#viewingMode) of the view:
|
|
147
138
|
*
|
|
148
139
|
* * In `local` viewing mode, it is equal to the coordinate system defined by the spatial reference of the view.
|
|
149
140
|
* * In `global` viewing mode, it is an [ECEF](https://en.wikipedia.org/wiki/ECEF) coordinate system where the X-axis
|
|
@@ -153,10 +144,9 @@ export interface RenderNodeProperties extends Partial<Pick<RenderNode, "produces
|
|
|
153
144
|
*
|
|
154
145
|
* 
|
|
155
146
|
*
|
|
156
|
-
* You can use [toRenderCoordinates()](https://developers.arcgis.com/javascript/latest/references/core/views/3d/webgl/#toRenderCoordinates)
|
|
157
|
-
* and
|
|
158
|
-
*
|
|
159
|
-
* system definition.
|
|
147
|
+
* You can use [toRenderCoordinates()](https://developers.arcgis.com/javascript/latest/references/core/views/3d/webgl/#toRenderCoordinates) and [fromRenderCoordinates()](https://developers.arcgis.com/javascript/latest/references/core/views/3d/webgl/#fromRenderCoordinates) to transform to
|
|
148
|
+
* and from the rendering coordinate system without having to worry about viewingMode and the exact coordinate system
|
|
149
|
+
* definition.
|
|
160
150
|
*
|
|
161
151
|
* #### Precision and local origins
|
|
162
152
|
*
|
|
@@ -235,10 +225,8 @@ export default abstract class RenderNode extends Accessor {
|
|
|
235
225
|
*
|
|
236
226
|
* The returned FBO has only a color0 attachment. The render function is however expected to return a ManagedFBO
|
|
237
227
|
* with the same attachments as the input framebuffer. Any additionally needed attachments can be allocated using
|
|
238
|
-
* [ManagedFBO.acquireDepth()](https://developers.arcgis.com/javascript/latest/references/core/views/3d/webgl/ManagedFBO/#acquireDepth) and
|
|
239
|
-
* [ManagedFBO.
|
|
240
|
-
* using [ManagedFBO.attachDepth()](https://developers.arcgis.com/javascript/latest/references/core/views/3d/webgl/ManagedFBO/#attachDepth) and
|
|
241
|
-
* [ManagedFBO.attachColor()](https://developers.arcgis.com/javascript/latest/references/core/views/3d/webgl/ManagedFBO/#attachColor).
|
|
228
|
+
* [ManagedFBO.acquireDepth()](https://developers.arcgis.com/javascript/latest/references/core/views/3d/webgl/ManagedFBO/#acquireDepth) and [ManagedFBO.acquireColor()](https://developers.arcgis.com/javascript/latest/references/core/views/3d/webgl/ManagedFBO/#acquireColor), or reused from
|
|
229
|
+
* an input framebuffer using [ManagedFBO.attachDepth()](https://developers.arcgis.com/javascript/latest/references/core/views/3d/webgl/ManagedFBO/#attachDepth) and [ManagedFBO.attachColor()](https://developers.arcgis.com/javascript/latest/references/core/views/3d/webgl/ManagedFBO/#attachColor).
|
|
242
230
|
*
|
|
243
231
|
* @returns The requested framebuffer object.
|
|
244
232
|
* @example
|
|
@@ -273,9 +261,10 @@ export default abstract class RenderNode extends Accessor {
|
|
|
273
261
|
/**
|
|
274
262
|
* The render function is called whenever a frame is rendered.
|
|
275
263
|
*
|
|
276
|
-
* It has to return a framebuffer with the same attachments as the input "produces" framebuffer.
|
|
277
|
-
*
|
|
278
|
-
*
|
|
264
|
+
* It has to return a framebuffer with the same attachments as the input "produces" framebuffer. A render node producing
|
|
265
|
+
* "composite-color" is expected to produce a "composite-color" framebuffer with one color and depth attachment. If the
|
|
266
|
+
* "composite-color" framebuffer contains an additional color attachment, e.g. for emissive rendering, the render node
|
|
267
|
+
* is expected to return a framebuffer with two attachments and a depth attachment.
|
|
279
268
|
*
|
|
280
269
|
* Typically the render function either uses bindRenderTarget() to render into this framebuffer, or
|
|
281
270
|
* acquireOutputFramebuffer() to get a new output framebuffer.
|
package/views/3d/webgl.d.ts
CHANGED
|
@@ -14,10 +14,13 @@ import type RenderCamera from "./webgl/RenderCamera.js";
|
|
|
14
14
|
*
|
|
15
15
|
* RenderNodeOutput | Description | Available RenderNodeInput FBOs | FBO attachments
|
|
16
16
|
* ---------------- | ----------- | ------------------------------ | --------------- |
|
|
17
|
-
* opaque-color | Contains the rendered image after all opaque geometries have been drawn. | opaque-color, normals | color0, depth
|
|
18
|
-
* transparent-color| Contains the rendered image after all opaque and transparent geometries have been drawn. | transparent-color, normals | color0, depth
|
|
19
|
-
* composite-color | Contains the rendered image without any post processes applied. | composite-color, normals, highlights (if scene has highlights) | color0, depth
|
|
20
|
-
* final-color | Contains the rendered image including post processes. | final-color, normals, highlights (if scene has highlights) | color0, depth
|
|
17
|
+
* opaque-color | Contains the rendered image after all opaque geometries have been drawn. | opaque-color, normals | color0, depth, color1(emissive)
|
|
18
|
+
* transparent-color| Contains the rendered image after all opaque and transparent geometries have been drawn. | transparent-color, normals | color0, depth, color1(emissive)
|
|
19
|
+
* composite-color | Contains the rendered image without any post processes applied. | composite-color, normals, highlights (if scene has highlights) | color0, depth, color1(emissive)
|
|
20
|
+
* final-color | Contains the rendered image including post processes. | final-color, normals, highlights (if scene has highlights) | color0, depth, color1(emissive)
|
|
21
|
+
*
|
|
22
|
+
* Emissive attachments are only available when at least one object with [Symbol3DEmissive](https://developers.arcgis.com/javascript/latest/references/core/symbols/support/Symbol3DEmissive/) is
|
|
23
|
+
* added to the [SceneView](https://developers.arcgis.com/javascript/latest/references/core/views/SceneView/).
|
|
21
24
|
*
|
|
22
25
|
* @since 5.0
|
|
23
26
|
*/
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.0/LICENSE.txt */
|
|
2
|
-
import{__decorate as t}from"tslib";import*as e from"@amcharts/amcharts5/index.js";import{XYChart as i,ValueAxis as s,AxisRendererX as o,AxisRendererY as n,XYCursor as r,LineSeries as a}from"@amcharts/amcharts5/xy.js";import l from"@amcharts/amcharts5/themes/Dark.js";import p from"@amcharts/amcharts5/themes/Responsive.js";import{fetchMessageBundle as c,substitute as d,formatNumber as h}from"../../../intl.js";import u from"../../../core/Accessor.js";import{createTask as m}from"../../../core/asyncUtils.js";import{makeHandle as f,handlesGroup as g}from"../../../core/handleUtils.js";import"../../../core/has.js";import{throwIfAborted as x}from"../../../core/promiseUtils.js";import{watch as _,initial as y}from"../../../core/reactiveUtils.js";import{throttle as v}from"../../../core/throttle.js";import{formatDecimal as A,unitName as T}from"../../../core/unitFormatUtils.js";import{property as b,subclass as M}from"../../../core/accessorSupport/decorators.js";import{getEpsilon as P}from"../../../core/libs/gl-matrix-2/math/common.js";import{isDarkMode as S}from"../../../support/modeUtils.js";import{getConfig as w,notAvailable as F}from"./constants.js";import{getAdjustedBounds as C}from"./elevationProfileChartBoundsUtils.js";import{themeLight as L,themeDark as z}from"./elevationProfileChartTheme.js";import{binaryFindClosest as I}from"./elevationProfileGenerationUtils.js";import{createRoot as k}from"../../../widgets/support/chartUtilsAm5.js";let j=class extends u{get chartVisible(){const t=this._chartData;if(null==t)return!1;let e=0;for(const{samples:i}of t.lines)e+=i?.length??0;return t.refined||e<=w().largeChartSamples}get spinnerVisible(){return null!=this._chartData&&(this.analysisView?.progress??0)<1}get _updateParameters(){const{messages:t,_unitsMessages:e}=this;if(t&&e)return{data:this._chartData,messages:t,unitsMessages:e}}get _chartData(){const{analysisView:t,uniformScaling:e}=this;if(!this._hasGeometry||!t)return;const{analysis:i,effectiveDisplayUnits:s,progress:o,statistics:n}=t;return{lines:this._lineData,statistics:n,effectiveUnits:s,refined:1===o,uniformScaling:e,dynamicElevationRange:i.profiles.some(t=>"scene"===t.type)}}get _hasGeometry(){return null!=this.analysisView?.analysis.geometry}get _lineData(){const{analysisView:t}=this;if(!t)return[];const{analysis:e,results:i}=t,{profiles:s}=e;if(i.length!==s.length)return[];const o=[];for(let n=0;n<s.length;n++){const t=s.at(n),e=i.at(n);if(!e.available||!e.rawResult?.hasZ||!t.chartOptions.lineVisible)continue;const r="input"!==t.type;o.push({id:t.id,type:t.type,title:t.title,color:t.color,samples:e.samples,fillEnabled:r,strokeOffsetY:r?-1:0,strokeWidth:1.5})}return o}constructor(t){super(t),this.view=null,this.analysisView=null,this.messages=null,this.uniformScaling=!1,this._theme=L,this._data=null,this._seriesInfos=new Map,this._pointerIsOver=!1,this._rtl=!1,this._chartInfo=null,this._unitsMessages=null,this._throttledUpdate=v(t=>{this._update(t)},w().updateThrottleMillis),this._onCursorMove=()=>{const t=this._chartInfo;if(!t||!this._pointerIsOver)return;const{chart:e,xAxis:i,yAxis:s}=t;this._updateTooltips();const o=e.get("cursor");let n=o?.getPrivate("positionX")??0,r=o?.getPrivate("positionY")??0;const a=this._data;if(null!=a?.statistics){const{maxDistance:t,minElevation:e,maxElevation:o}=a.statistics;let l,p;if(null!=t){1===Y(i)?(l=0,p=t):(l=O(i),p=R(i)),n=V(n,l,p,0,t)}if(null!=e&&null!=o){1===Y(s)?(l=e,p=o):(l=O(s),p=R(s)),r=V(r,l,p,e,o)}}this.onCursorPositionChange?.(n,r)}}initialize(){this.addHandles(m(t=>this._initializeChart(t)))}destroy(){this._chartInfo=null,this._seriesInfos.clear(),this._data=null}zoomOut(){this._chartInfo?.xAxis.zoom(0,1),this._chartInfo?.yAxis.zoom(0,1)}async _initializeChart(t){const[e,s]=await Promise.all([k(this.container),c("esri/core/t9n/Units")]);x(t);const o=E(this.container),n=S(this.container),r=n?z:L;e.setThemes(n?[p.new(e),l.new(e)]:[p.new(e)]),this._rtl=o,this._theme=r,this._unitsMessages=s;const a=e.container.children.push(i.new(e,{panX:!0,panY:!0,paddingTop:r.paddingTop,paddingBottom:r.paddingBottom,paddingLeft:o?r.paddingRight:r.paddingLeft,paddingRight:o?r.paddingLeft:r.paddingRight,maxTooltipDistance:-1}));a.zoomOutButton.set("forceHidden",!0);const d=a.xAxes.push(this._createXAxis(e)),h=a.yAxes.push(this._createYAxis(e));this._chartInfo={chart:a,xAxis:d,yAxis:h},this._initializeTest(a),this.addHandles([this._setupZoomHandling(),this._setupCursorHandling(),W(e),_(()=>this._updateParameters,t=>this._throttledUpdate(t),y),this._throttledUpdate])}_initializeTest(t){}_update(t){if(!t||this.destroyed)return;const e=this._data,i=t.data;if(i===e&&t.messages===this.messages&&t.unitsMessages===this._unitsMessages)return;const s=e!==i,o=e?.effectiveUnits!==i?.effectiveUnits,n=e?.uniformScaling!==i?.uniformScaling;this._data=i,(s||o)&&(this._updateAxes(),this._updateSeries()),n&&this.zoomOut(),this._updateTooltips()}_createXAxis(t){const i=this._theme,n=s.new(t,{renderer:o.new(t,{})});n.setAll({extraMax:0,extraMin:0,maxDeviation:0,numberFormatter:this._makeFormatter(t,"distance"),strictMinMax:!0,strictMinMaxSelection:!0}),n.axisHeader.set("forceHidden",!0);const r=n.get("renderer");r.setAll({inside:!1,minGridDistance:i.xAxisMinGridDistance}),r.labels.template.setAll({centerX:e.p0,centerY:e.p0,fill:e.color(i.axisLabelsColor),fontFamily:i.fontFamily,fontSize:i.axisLabelsFontSize,fontWeight:i.axisLabelsFontWeight,maxPosition:i.xAxisMaxLabelPosition,minPosition:i.xAxisMinLabelPosition,paddingLeft:0,paddingRight:0,paddingTop:i.xAxisLabelsSpacing});const a=n.set("tooltip",e.Tooltip.new(t,{paddingBottom:0,paddingLeft:0,paddingRight:0,paddingTop:0}));return a.get("background")?.setAll({fill:e.color(i.axisTooltipBackgroundColor),stroke:void 0}),a.label.setAll({fill:e.color(i.axisTooltipLabelColor),fontFamily:i.fontFamily,fontSize:i.axisTooltipFontSize,paddingBottom:i.axisTooltipPaddingBottom,paddingLeft:i.axisTooltipPaddingHorizontal,paddingRight:i.axisTooltipPaddingHorizontal,paddingTop:i.axisTooltipPaddingTop,direction:this._rtl?"rtl":"ltr"}),r.grid.template.setAll({strokeOpacity:1,stroke:e.color(i.axisGridStroke)}),n}_createYAxis(t){const i=this._theme,o=this._rtl,r=s.new(t,{renderer:n.new(t,{})});r.setAll({baseValue:w().noDataValue,extraMax:0,extraMin:0,maxDeviation:0,numberFormatter:this._makeFormatter(t,"elevation"),strictMinMax:!0,strictMinMaxSelection:!0,tooltip:void 0}),r.axisHeader.set("visible",!1);const a=r.get("renderer");return a.setAll({minGridDistance:i.yAxisMinGridDistance,opposite:o,inside:!0}),a.labels.template.setAll({centerX:e.p0,centerY:e.p100,fill:e.color(i.axisLabelsColor),fontFamily:i.fontFamily,fontSize:i.axisLabelsFontSize,fontWeight:i.axisLabelsFontWeight,maxPosition:i.yAxisMaxLabelPosition,minPosition:i.yAxisMinLabelPosition,paddingBottom:0,paddingLeft:o?0:i.yAxisLabelSpacing,paddingRight:o?i.yAxisLabelSpacing:0,paddingTop:0,textAlign:"start"}),a.grid.template.setAll({strokeOpacity:1,stroke:e.color(i.axisGridStroke)}),r}_setupZoomHandling(){const t=this._chartInfo;if(!t)return f();const{xAxis:e,yAxis:i}=t,s=()=>{this.onRangeChange?.(Y(e),Y(i))},o=t=>[t.on("start",s),t.on("end",s)];return G([...o(e),...o(i)])}_setupCursorHandling(){const t=this._chartInfo?.chart;if(!t)return f();const e=t.plotContainer.events,i=t=>{this._pointerIsOver=t,this._updateTooltips()},s=()=>{i(!1),this.onCursorPositionChange?.(null,null)};return G([e.on("pointerover",()=>i(!0)),e.on("pointerout",s),e.on("blur",s)])}_updateAxes(){const t=this._chartInfo;if(!t)return;const{chart:e,xAxis:i,yAxis:s}=t,o=this._data,{minX:n,maxX:r,minY:a,maxY:l}=C({data:o,pixelWidth:i.width(),pixelHeight:s.height()}),p=!!o?.uniformScaling,c=!!o?.refined;e.setAll({panX:!0,panY:p,pinchZoomX:c,pinchZoomY:c&&p,wheelX:"panX",wheelY:c?p?"zoomXY":"zoomX":"none"}),i.setAll({max:r,min:n,panX:!0,panY:!1,zoomX:!0,zoomY:p}),s.setAll({max:l,min:a,panX:!1,panY:p,zoomX:p,zoomY:p})}_updateSeries(){const t=this._seriesInfos,e=this._chartInfo;if(!e)return;const{chart:i,xAxis:s,yAxis:o}=e,n=this._data;if(!n||0===n.lines.length)return this._seriesInfos.clear(),void i.series.clear();const r=new Map,a=new Set(i.series.values),l=n.lines.length;for(let p=0;p<l;p++){const s=n.lines[p];let o=t.get(s.id);o?(o.fill&&a.delete(o.fill),a.delete(o.line)):(o=D(e,s),o.fill&&i.series.push(o.fill),i.series.push(o.line)),r.set(o.id,o);const c=l-p-1;o.fill?.set("layer",c),o.line.set("layer",l+c),this._updateLineSeries(o,s)}this._seriesInfos=r;for(const p of a)i.series.removeValue(p);s.set("layer",l+1),o.set("layer",l+2)}_updateLineSeries(t,i){const s=e.color(i.color.toCss()),o=i.samples??[],n=o.length>0,{line:r,fill:a}=t;r.set("visible",n),r.set("stroke",s),a?.set("visible",n),a?.set("fill",e.Color.lighten(s,this._theme.seriesFillLighten)),r.data.setAll(o),a?.data.setAll(o)}_updateTooltips(){const t=this._chartInfo;if(!t)return;const{chart:e,xAxis:i,yAxis:s}=t,o=e.get("cursor");if(!this._data?.refined)return o?.events.removeType("cursormoved"),o?.dispose(),void e.set("cursor",void 0);if(!o){const t=r.new(e.root,{behavior:"none",xAxis:i,yAxis:s,snapToSeriesBy:"y"});t.lineY.set("visible",!1),t.events.on("cursormoved",this._onCursorMove),e.set("cursor",t)}const n=this._getSeriesTooltipText();n?this._seriesInfos.forEach(e=>{const i=e.line.get("tooltip")??X(t,this._theme,this._rtl);i.label.set("text",n),e.line.set("tooltip",i)}):this._seriesInfos.forEach(t=>{t.line.get("tooltip")?.dispose(),t.line.set("tooltip",void 0)}),this._chartInfo?.xAxis.getTooltip()?.setAll({tooltipText:this._getAxisTooltipText()})}_getSeriesTooltipText(){const t=this._data?.lines.map(t=>({line:t,y:this._getPointNearestToCursor(t)?.elevation})).sort(H);return t&&0!==t.length&&null!=t[0].y?t.map(({y:t,line:e})=>this._getTooltipTextForLine(e,t)).join("\n"):null}_getPointNearestToCursor(t){const e=t.samples??[];if(0===e.length)return null;const i=this._chartInfo;if(!i)return null;const{chart:s,xAxis:o}=i,n=s.get("cursor"),r=n?.getPrivate("positionX")??0,a=o.toAxisPosition(r),l=o.positionToValue(a);return I(e,l,t=>t.distance)}_getTooltipTextForLine(t,e){const i=this._data,s=this.messages,o=this._unitsMessages;if(!i||!s||!o)return"";const n=`[${t.color.toHex()}]●[/]`,r=" ",a=w().formatPrecision,l=d(s.chartTooltip,{name:B(t,s),elevation:null!=e?A(o,e,i.effectiveUnits.elevation,a):F});return this._rtl?l+r+n:n+r+l}_getAxisTooltipText(){const t=this._data,e=this._unitsMessages;if(!t||!e)return"";const i=t.lines[0],s=i?this._getPointNearestToCursor(i):null,o=w().formatPrecision;return null!=s?A(e,s.distance,t.effectiveUnits.distance,o):"-"}_makeFormatter(t,i){const s=e.NumberFormatter.new(t,{});return s.format=(t,e,s)=>{const o=this._data,n=this._unitsMessages;if(!o||!n||"string"==typeof t)return"";return`${h(t,{maximumFractionDigits:s})} ${T(n,o.effectiveUnits[i],"abbr")}`},s}};function D(t,e){const{id:i}=e,s=U(t,`line-${i}`);s.setAll({dy:e.strokeOffsetY,tooltip:void 0}),s.strokes.template.setAll({strokeWidth:e.strokeWidth});let o=null;return e.fillEnabled&&(o=U(t,`fill-${i}`),o.fills.template.setAll({fillOpacity:1,visible:!0})),{id:i,line:s,fill:o}}function U({chart:t,xAxis:e,yAxis:i},s){return a.new(t.root,{connect:!1,excludeFromTotal:!0,fill:void 0,id:s,stroke:void 0,valueXField:"distance",valueYField:"elevation",xAxis:e,yAxis:i})}function X({chart:t},i,s){const o=e.Tooltip.new(t.root,{autoTextColor:!1,getFillFromSprite:!1,getLabelFillFromSprite:!1,pointerOrientation:"vertical",visible:!1}),n=i.seriesTooltipPaddingHorizontal,r=i.seriesTooltipPaddingVertical;return o.label.setAll({fill:e.color(i.seriesTooltipLabelColor),fontFamily:i.fontFamily,fontSize:i.seriesTooltipFontSize,paddingBottom:r,paddingLeft:n,paddingRight:n,paddingTop:r,textAlign:s?"end":"start",direction:"ltr"}),o.get("background")?.setAll({stroke:void 0,fill:e.color(i.seriesTooltipBackgroundColor)}),o.adapters.add("dy",t=>{const e=i.seriesTooltipSpacing,s=o.get("pointTo")?.y??0;return(t??0)+(o.y()>s?e:-e)}),o}function Y(t){const e=Math.abs((t.get("end")??0)-(t.get("start")??0)),i=0!==e?1/e:1;return Math.abs(1-i)<P()?1:i}function V(t,e,i,s,o){return(e+t*(i-e)-s)/(o-s)}function H({y:t},{y:e}){return null==t?1:null==e?-1:e-t}function O(t){return t.positionToValue(t.get("start")??0)}function R(t){return t.positionToValue(t.get("end")??1)}function B(t,e){const i=t.title;if(null!=i)return i;switch(t.type){case"ground":return e.profiles.ground;case"input":return e.profiles.input;case"query":return e.profiles.query;case"scene":return e.profiles.scene;default:return""}}function E(t){const e=t?.closest("[dir]");return null!==e&&e instanceof HTMLElement&&"rtl"===e.dir||"rtl"===document.dir}function G(t){return g(t.map(W))}function W(t){return f(()=>t?.dispose())}t([b()],j.prototype,"view",void 0),t([b()],j.prototype,"analysisView",void 0),t([b()],j.prototype,"container",void 0),t([b()],j.prototype,"messages",void 0),t([b()],j.prototype,"onRangeChange",void 0),t([b()],j.prototype,"onCursorPositionChange",void 0),t([b()],j.prototype,"uniformScaling",void 0),t([b()],j.prototype,"chartVisible",null),t([b()],j.prototype,"spinnerVisible",null),t([b()],j.prototype,"test",void 0),t([b()],j.prototype,"_theme",void 0),t([b()],j.prototype,"_data",void 0),t([b()],j.prototype,"_seriesInfos",void 0),t([b()],j.prototype,"_pointerIsOver",void 0),t([b()],j.prototype,"_rtl",void 0),t([b()],j.prototype,"_chartInfo",void 0),t([b()],j.prototype,"_unitsMessages",void 0),t([b()],j.prototype,"_updateParameters",null),t([b()],j.prototype,"_chartData",null),t([b()],j.prototype,"_hasGeometry",null),t([b()],j.prototype,"_lineData",null),j=t([M("esri.views.analysis.ElevationProfile.ElevationProfileChart")],j);export{j as ElevationProfileChart};
|
|
2
|
+
import{__decorate as t}from"tslib";import*as e from"@amcharts/amcharts5/index.js";import{XYChart as i,ValueAxis as s,AxisRendererX as o,AxisRendererY as n,XYCursor as r,LineSeries as a}from"@amcharts/amcharts5/xy.js";import l from"@amcharts/amcharts5/themes/Dark.js";import p from"@amcharts/amcharts5/themes/Responsive.js";import{fetchMessageBundle as c,substitute as d,formatNumber as h}from"../../../intl.js";import u from"../../../core/Accessor.js";import{createTask as m}from"../../../core/asyncUtils.js";import{makeHandle as f,handlesGroup as g}from"../../../core/handleUtils.js";import"../../../core/has.js";import{throwIfAborted as x}from"../../../core/promiseUtils.js";import{watch as _,initial as y}from"../../../core/reactiveUtils.js";import{throttle as v}from"../../../core/throttle.js";import{formatDecimal as A,unitName as T}from"../../../core/unitFormatUtils.js";import{property as b,subclass as M}from"../../../core/accessorSupport/decorators.js";import{getEpsilon as S}from"../../../core/libs/gl-matrix-2/math/common.js";import{isDarkMode as P}from"../../../support/modeUtils.js";import{getConfig as w,notAvailable as F}from"./constants.js";import{getAdjustedBounds as C}from"./elevationProfileChartBoundsUtils.js";import{themeLight as L,themeDark as z}from"./elevationProfileChartTheme.js";import{binaryFindClosest as I}from"./elevationProfileGenerationUtils.js";import{createRoot as k}from"../../../widgets/support/chartUtilsAm5.js";let j=class extends u{get chartVisible(){const t=this._chartData;if(null==t)return!1;let e=0;for(const{samples:i}of t.lines)e+=i?.length??0;return t.refined||e<=w().largeChartSamples}get spinnerVisible(){return null!=this._chartData&&(this.analysisView?.progress??0)<1}get _updateParameters(){const{messages:t,_unitsMessages:e}=this;if(t&&e)return{data:this._chartData,messages:t,unitsMessages:e}}get _chartData(){const{analysisView:t,uniformScaling:e}=this;if(!this._hasGeometry||!t)return;const{analysis:i,effectiveDisplayUnits:s,progress:o,statistics:n}=t;return{lines:this._lineData,statistics:n,effectiveUnits:s,refined:1===o,uniformScaling:e,dynamicElevationRange:i.profiles.some(t=>"scene"===t.type)}}get _hasGeometry(){return null!=this.analysisView?.analysis.geometry}get _lineData(){const{analysisView:t}=this;if(!t)return[];const{analysis:e,results:i}=t,{profiles:s}=e;if(i.length!==s.length)return[];const o=[];for(let n=0;n<s.length;n++){const t=s.at(n),e=i.at(n);if(!e.available||!e.rawResult?.hasZ||!t.chartOptions.lineVisible)continue;const r="input"!==t.type;o.push({id:t.id,type:t.type,title:t.title,color:t.color,samples:e.samples,fillEnabled:r,strokeOffsetY:r?-1:0,strokeWidth:1.5})}return o}constructor(t){super(t),this.view=null,this.analysisView=null,this.messages=null,this.uniformScaling=!1,this._theme=L,this._data=null,this._seriesInfos=new Map,this._pointerIsOver=!1,this._rtl=!1,this._chartInfo=null,this._unitsMessages=null,this._throttledUpdate=v(t=>{this._update(t)},w().updateThrottleMillis),this._onCursorMove=()=>{const t=this._chartInfo;if(!t||!this._pointerIsOver)return;const{chart:e,xAxis:i,yAxis:s}=t;this._updateTooltips();const o=e.get("cursor");let n=o?.getPrivate("positionX")??0,r=o?.getPrivate("positionY")??0;const a=this._data;if(null!=a?.statistics){const{maxDistance:t,minElevation:e,maxElevation:o}=a.statistics;let l,p;if(null!=t){1===Y(i)?(l=0,p=t):(l=O(i),p=R(i)),n=V(n,l,p,0,t)}if(null!=e&&null!=o){1===Y(s)?(l=e,p=o):(l=O(s),p=R(s)),r=V(r,l,p,e,o)}}this.onCursorPositionChange?.(n,r)}}initialize(){this.addHandles(m(t=>this._initializeChart(t)))}destroy(){this._chartInfo=null,this._seriesInfos.clear(),this._data=null}zoomOut(){this._chartInfo?.xAxis.zoom(0,1),this._chartInfo?.yAxis.zoom(0,1)}async _initializeChart(t){const[e,s]=await Promise.all([k(this.container),c("esri/core/t9n/Units")]);x(t);const o=E(this.container),n=P(this.container),r=n?z:L;e.setThemes(n?[p.new(e),l.new(e)]:[p.new(e)]),this._rtl=o,this._theme=r,this._unitsMessages=s;const a=e.container.children.push(i.new(e,{panX:!0,panY:!0,paddingTop:r.paddingTop,paddingBottom:r.paddingBottom,paddingLeft:o?r.paddingRight:r.paddingLeft,paddingRight:o?r.paddingLeft:r.paddingRight,maxTooltipDistance:-1}));a.zoomOutButton.set("forceHidden",!0);const d=a.xAxes.push(this._createXAxis(e)),h=a.yAxes.push(this._createYAxis(e));this._chartInfo={chart:a,xAxis:d,yAxis:h},this._initializeTest(a),this.addHandles([this._setupZoomHandling(),this._setupCursorHandling(),W(e),_(()=>this._updateParameters,t=>this._throttledUpdate(t),y),this._throttledUpdate])}_initializeTest(t){}_update(t){if(!t||this.destroyed)return;const e=this._data,i=t.data;if(i===e&&t.messages===this.messages&&t.unitsMessages===this._unitsMessages)return;const s=e!==i,o=e?.effectiveUnits!==i?.effectiveUnits,n=e?.uniformScaling!==i?.uniformScaling;this._data=i,(s||o)&&(this._updateAxes(),this._updateSeries()),n&&this.zoomOut(),this._updateTooltips()}_createXAxis(t){const i=this._theme,n=s.new(t,{renderer:o.new(t,{})});n.setAll({extraMax:0,extraMin:0,maxDeviation:0,numberFormatter:this._makeFormatter(t,"distance"),strictMinMax:!0,strictMinMaxSelection:!0}),n.axisHeader.set("forceHidden",!0);const r=n.get("renderer");r.setAll({inside:!1,minGridDistance:i.xAxisMinGridDistance}),r.labels.template.setAll({centerX:e.p0,centerY:e.p0,fill:e.color(i.axisLabelsColor),fontFamily:i.fontFamily,fontSize:i.axisLabelsFontSize,fontWeight:i.axisLabelsFontWeight,maxPosition:i.xAxisMaxLabelPosition,minPosition:i.xAxisMinLabelPosition,paddingLeft:0,paddingRight:0,paddingTop:i.xAxisLabelsSpacing});const a=n.set("tooltip",e.Tooltip.new(t,{paddingBottom:0,paddingLeft:0,paddingRight:0,paddingTop:0}));return a.get("background")?.setAll({fill:e.color(i.axisTooltipBackgroundColor),stroke:void 0}),a.label.setAll({fill:e.color(i.axisTooltipLabelColor),fontFamily:i.fontFamily,fontSize:i.axisTooltipFontSize,paddingBottom:i.axisTooltipPaddingBottom,paddingLeft:i.axisTooltipPaddingHorizontal,paddingRight:i.axisTooltipPaddingHorizontal,paddingTop:i.axisTooltipPaddingTop,direction:this._rtl?"rtl":"ltr"}),r.grid.template.setAll({strokeOpacity:1,stroke:e.color(i.axisGridStroke)}),n}_createYAxis(t){const i=this._theme,o=this._rtl,r=s.new(t,{renderer:n.new(t,{})});r.setAll({baseValue:w().noDataValue,extraMax:0,extraMin:0,maxDeviation:0,numberFormatter:this._makeFormatter(t,"elevation"),strictMinMax:!0,strictMinMaxSelection:!0,tooltip:void 0}),r.axisHeader.set("visible",!1);const a=r.get("renderer");return a.setAll({minGridDistance:i.yAxisMinGridDistance,opposite:o,inside:!0}),a.labels.template.setAll({centerX:e.p0,centerY:e.p100,fill:e.color(i.axisLabelsColor),fontFamily:i.fontFamily,fontSize:i.axisLabelsFontSize,fontWeight:i.axisLabelsFontWeight,maxPosition:i.yAxisMaxLabelPosition,minPosition:i.yAxisMinLabelPosition,paddingBottom:0,paddingLeft:o?0:i.yAxisLabelSpacing,paddingRight:o?i.yAxisLabelSpacing:0,paddingTop:0,textAlign:"start"}),a.grid.template.setAll({strokeOpacity:1,stroke:e.color(i.axisGridStroke)}),r}_setupZoomHandling(){const t=this._chartInfo;if(!t)return f();const{xAxis:e,yAxis:i}=t,s=()=>{this.onRangeChange?.(Y(e),Y(i))},o=t=>[t.on("start",s),t.on("end",s)];return G([...o(e),...o(i)])}_setupCursorHandling(){const t=this._chartInfo?.chart;if(!t)return f();const e=t.plotContainer.events,i=t=>{this._pointerIsOver=t,this._updateTooltips()},s=()=>{i(!1),this.onCursorPositionChange?.(null,null)};return G([e.on("pointerover",()=>i(!0)),e.on("pointerout",s),e.on("blur",s)])}_updateAxes(){const t=this._chartInfo;if(!t)return;const{chart:e,xAxis:i,yAxis:s}=t,o=this._data,{minX:n,maxX:r,minY:a,maxY:l}=C({data:o,pixelWidth:i.width(),pixelHeight:s.height()}),p=!!o?.uniformScaling,c=!!o?.refined;e.setAll({panX:!0,panY:p,pinchZoomX:c,pinchZoomY:c&&p,wheelX:"panX",wheelY:c?p?"zoomXY":"zoomX":"none"}),i.setAll({max:r,min:n,panX:!0,panY:!1,zoomX:!0,zoomY:p}),s.setAll({max:l,min:a,panX:!1,panY:p,zoomX:p,zoomY:p})}_updateSeries(){const t=this._seriesInfos,e=this._chartInfo;if(!e)return;const{chart:i,xAxis:s,yAxis:o}=e,n=this._data;if(!n||0===n.lines.length)return this._seriesInfos.clear(),void i.series.clear();const r=new Map,a=new Set(i.series.values),l=n.lines.length;for(let p=0;p<l;p++){const s=n.lines[p];let o=t.get(s.id);o?(o.fill&&a.delete(o.fill),a.delete(o.line)):(o=D(e,s),o.fill&&i.series.push(o.fill),i.series.push(o.line)),r.set(o.id,o);const c=l-p-1;o.fill?.set("layer",c),o.line.set("layer",l+c),this._updateLineSeries(o,s)}this._seriesInfos=r;for(const p of a)i.series.removeValue(p);s.set("layer",l+1),o.set("layer",l+2)}_updateLineSeries(t,i){const s=e.color(i.color.toCss()),o=i.samples??[],n=o.length>0,{line:r,fill:a}=t;r.set("visible",n),r.set("stroke",s),a?.set("visible",n),a?.set("fill",e.Color.lighten(s,this._theme.seriesFillLighten)),r.data.setAll(o),a?.data.setAll(o)}_updateTooltips(){const t=this._chartInfo;if(!t)return;const{chart:e,xAxis:i,yAxis:s}=t,o=e.get("cursor");if(!this._data?.refined)return o?.events.removeType("cursormoved"),o?.dispose(),void e.set("cursor",void 0);if(!o){const t=r.new(e.root,{behavior:"none",xAxis:i,yAxis:s,snapToSeriesBy:"y"});t.lineY.set("visible",!1),t.events.on("cursormoved",this._onCursorMove),e.set("cursor",t)}const n=this._getSeriesTooltipText();n?this._seriesInfos.forEach(e=>{const i=e.line.get("tooltip")??X(t,this._theme,this._rtl);i.label.set("text",n),e.line.set("tooltip",i)}):this._seriesInfos.forEach(t=>{t.line.get("tooltip")?.dispose(),t.line.set("tooltip",void 0)}),this._chartInfo?.xAxis.getTooltip()?.setAll({tooltipText:this._getAxisTooltipText()})}_getSeriesTooltipText(){const t=this._data?.lines.map(t=>({line:t,y:this._getPointNearestToCursor(t)?.elevation})).sort(H);return t&&0!==t.length&&null!=t[0].y?t.map(({y:t,line:e})=>this._getTooltipTextForLine(e,t)).join("\n"):null}_getPointNearestToCursor(t){const e=t.samples??[];if(0===e.length)return null;const i=this._chartInfo;if(!i)return null;const{chart:s,xAxis:o}=i,n=s.get("cursor"),r=n?.getPrivate("positionX")??0,a=o.toAxisPosition(r),l=o.positionToValue(a);return I(e,l,t=>t.distance)}_getTooltipTextForLine(t,e){const i=this._data,s=this.messages,o=this._unitsMessages;if(!i||!s||!o)return"";const n=`[${t.color.toHex()}]●[/]`,r=" ",a=w().formatPrecision,l=d(s.chartTooltip,{name:B(t,s),elevation:null!=e?A(o,e,i.effectiveUnits.elevation,a):F});return this._rtl?l+r+n:n+r+l}_getAxisTooltipText(){const t=this._data,e=this._unitsMessages;if(!t||!e)return"";const i=t.lines[0],s=i?this._getPointNearestToCursor(i):null,o=w().formatPrecision;return null!=s?A(e,s.distance,t.effectiveUnits.distance,o):"-"}_makeFormatter(t,i){const s=e.NumberFormatter.new(t,{}),o=1e6,n="distance"===i?new Intl.NumberFormat(void 0,{notation:"compact",compactDisplay:"short",maximumSignificantDigits:3}):null;return s.format=(t,e,s)=>{const r=this._data,a=this._unitsMessages;if(!r||!a||"string"==typeof t)return"";let l;return l=n&&Math.abs(t)>=o?n.format(t):h(t,{maximumFractionDigits:s}),`${l} ${T(a,r.effectiveUnits[i],"abbr")}`},s}};function D(t,e){const{id:i}=e,s=U(t,`line-${i}`);s.setAll({dy:e.strokeOffsetY,tooltip:void 0}),s.strokes.template.setAll({strokeWidth:e.strokeWidth});let o=null;return e.fillEnabled&&(o=U(t,`fill-${i}`),o.fills.template.setAll({fillOpacity:1,visible:!0})),{id:i,line:s,fill:o}}function U({chart:t,xAxis:e,yAxis:i},s){return a.new(t.root,{connect:!1,excludeFromTotal:!0,fill:void 0,id:s,stroke:void 0,valueXField:"distance",valueYField:"elevation",xAxis:e,yAxis:i})}function X({chart:t},i,s){const o=e.Tooltip.new(t.root,{autoTextColor:!1,getFillFromSprite:!1,getLabelFillFromSprite:!1,pointerOrientation:"vertical",visible:!1}),n=i.seriesTooltipPaddingHorizontal,r=i.seriesTooltipPaddingVertical;return o.label.setAll({fill:e.color(i.seriesTooltipLabelColor),fontFamily:i.fontFamily,fontSize:i.seriesTooltipFontSize,paddingBottom:r,paddingLeft:n,paddingRight:n,paddingTop:r,textAlign:s?"end":"start",direction:"ltr"}),o.get("background")?.setAll({stroke:void 0,fill:e.color(i.seriesTooltipBackgroundColor)}),o.adapters.add("dy",t=>{const e=i.seriesTooltipSpacing,s=o.get("pointTo")?.y??0;return(t??0)+(o.y()>s?e:-e)}),o}function Y(t){const e=Math.abs((t.get("end")??0)-(t.get("start")??0)),i=0!==e?1/e:1;return Math.abs(1-i)<S()?1:i}function V(t,e,i,s,o){return(e+t*(i-e)-s)/(o-s)}function H({y:t},{y:e}){return null==t?1:null==e?-1:e-t}function O(t){return t.positionToValue(t.get("start")??0)}function R(t){return t.positionToValue(t.get("end")??1)}function B(t,e){const i=t.title;if(null!=i)return i;switch(t.type){case"ground":return e.profiles.ground;case"input":return e.profiles.input;case"query":return e.profiles.query;case"scene":return e.profiles.scene;default:return""}}function E(t){const e=t?.closest("[dir]");return null!==e&&e instanceof HTMLElement&&"rtl"===e.dir||"rtl"===document.dir}function G(t){return g(t.map(W))}function W(t){return f(()=>t?.dispose())}t([b()],j.prototype,"view",void 0),t([b()],j.prototype,"analysisView",void 0),t([b()],j.prototype,"container",void 0),t([b()],j.prototype,"messages",void 0),t([b()],j.prototype,"onRangeChange",void 0),t([b()],j.prototype,"onCursorPositionChange",void 0),t([b()],j.prototype,"uniformScaling",void 0),t([b()],j.prototype,"chartVisible",null),t([b()],j.prototype,"spinnerVisible",null),t([b()],j.prototype,"test",void 0),t([b()],j.prototype,"_theme",void 0),t([b()],j.prototype,"_data",void 0),t([b()],j.prototype,"_seriesInfos",void 0),t([b()],j.prototype,"_pointerIsOver",void 0),t([b()],j.prototype,"_rtl",void 0),t([b()],j.prototype,"_chartInfo",void 0),t([b()],j.prototype,"_unitsMessages",void 0),t([b()],j.prototype,"_updateParameters",null),t([b()],j.prototype,"_chartData",null),t([b()],j.prototype,"_hasGeometry",null),t([b()],j.prototype,"_lineData",null),j=t([M("esri.views.analysis.ElevationProfile.ElevationProfileChart")],j);export{j as ElevationProfileChart};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.0/LICENSE.txt */
|
|
2
|
-
import{cyclical2PI as e}from"../../../core/Cyclical.js";import{createAngle as t,valueInUnit as r}from"../../../core/quantity.js";import{subtract as i,dot as n,squaredLength as s,scaleAndAdd as o}from"../../../core/libs/gl-matrix-2/math/vec2.js";import{create as a}from"../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{scaleAndAdd as c,subtract as
|
|
2
|
+
import{cyclical2PI as e}from"../../../core/Cyclical.js";import{createAngle as t,valueInUnit as r}from"../../../core/quantity.js";import{subtract as i,dot as n,squaredLength as s,scaleAndAdd as o}from"../../../core/libs/gl-matrix-2/math/vec2.js";import{create as a}from"../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{scaleAndAdd as c,subtract as g,set as p}from"../../../core/libs/gl-matrix-2/math/vec3.js";import{create as h}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{absoluteHeightElevationInfo as l}from"../../../support/elevationInfoUtils.js";import{VerticalHalfPlaneConstraint as m}from"../sketch/constraints.js";import{fromAnyMapPoint as f,asVec2 as d,markAsTarget as u,fromValues as x,fromVec3 as S}from"../sketch/normalizedPoint.js";import{SnappingAlgorithm as V}from"./SnappingAlgorithm.js";import{isLine as v,squaredScreenDistance as j}from"./snappingUtils.js";import{RightAngleSnappingCandidate as k}from"./candidates/RightAngleSnappingCandidate.js";import{vectorToScreenPoint as C}from"../support/viewUtils.js";import{radiansGeographicBetweenVec as _,pointFromDistanceAlongAzimuth as F}from"../../support/angularMeasurementUtils.js";class w extends V{constructor(e,t,r){super(e,t),this._geodesicLengthMeasurementUtils=r}snapNewVertex(e,t){const r=t.editGeometryOperations.data.parts.at(-1),i=[];if(!r||r.vertices.length<2)return i;const{view:n}=this,s=C(e,t.spatialReference,l,n),o=r.vertices.at(-1);v(o.leftSegment)&&this._checkForSnappingCandidate(1,i,o.leftSegment,o,o.leftSegment.leftVertex,e,s,t);const a=r.vertices[0];return v(a.rightSegment)&&this._checkForSnappingCandidate(2,i,a.rightSegment,a,a.rightSegment.rightVertex,e,s,t),i}snapExistingVertex(e,t){const r=[],i=t.vertexHandle,{part:n}=i;if(n.vertices.length<3)return r;const{view:s}=this,o=C(e,t.spatialReference,l,s),a=i.leftSegment,c=i.rightSegment;if(v(a?.leftVertex.leftSegment)){const i=a.leftVertex.leftSegment;this._checkForSnappingCandidate(3,r,i,i.rightVertex,i.leftVertex,e,o,t)}if(v(c)&&v(c.rightVertex.rightSegment)){const i=c.rightVertex.rightSegment;this._checkForSnappingCandidate(3,r,i,i.leftVertex,i.rightVertex,e,o,t)}const g=n.getFirstVertex()?.rightSegment;return!c&&v(g)&&this._checkForSnappingCandidate(3,r,g,g.leftVertex,g.rightVertex,e,o,t),r}_checkForSnappingCandidate(e,t,r,i,n,s,o,a){if(!v(r)||!this.edgeExceedsShortLineThreshold(r,a))return;const c=this.view,g=f(i.pos,c,a),p=f(n.pos,c,a);y(P,p,g,s,a,this._geodesicLengthMeasurementUtils),this._checkForSnappingCandidateAlongProjectedRay(e,t,p,g,P,s,o,a)}_checkForSnappingCandidateAlongProjectedRay(e,t,r,a,g,p,f,V){const{spatialReference:v,pointer:_}=V,F=i(M,d(p),d(a)),w=n(g,F)/s(g),y=o(M,d(a),g,w),R=u(x(y[0],y[1],p[2]));if(j(f,C(R,v,l,this.view))>this.squaredProximityThreshold(_)||this.isVertical(R,a,V)||this.isVertical(a,r,V))return;const A=c(h(),a,g,Math.sign(w));t.push(new k({targetPoint:R,constraint:new m(a,S(A)),previousVertex:r,otherVertex:a,otherVertexType:1,selfSnappingType:e,isDraped:"on-the-ground"===V.elevationInfo?.mode}))}}function y(e,t,r,i,n,s){R(e,t,r,i,n,s)||A(e,t,r)}function R(i,n,s,o,{spatialReference:a},c){const p=_(n,s,a,a);if(null==p)return!1;const l=_(s,o,a,a);if(null==l)return!1;const m=Math.sign(e.shortestSignedDiff(p,l))*Math.PI*.5,f=t(p+m,"radians","geographic"),d=h(),u=c.geodesicDistance(s,o,a);return null!=u&&(F(d,s,a,r(u,"meters"),f,"geodesic"),g(i,d,s),!0)}function A(e,t,r){const n=i(M,d(r),d(t));p(e,n[1],-n[0],0)}const M=a(),P=h();export{w as RightAngleSnapper};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.0/LICENSE.txt */
|
|
2
|
-
import{lerp as e,distance as t}from"../../../core/libs/gl-matrix-2/math/vec2.js";import{create as i}from"../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{absoluteHeightElevationInfo as r}from"../../../support/elevationInfoUtils.js";import{fromAnyMapPoint as s,asVec2 as
|
|
2
|
+
import{lerp as e,distance as t}from"../../../core/libs/gl-matrix-2/math/vec2.js";import{create as i}from"../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{absoluteHeightElevationInfo as r}from"../../../support/elevationInfoUtils.js";import{fromAnyMapPoint as s,asVec2 as o,markAsTarget as n,fromValues as p}from"../sketch/normalizedPoint.js";import{SnappingAlgorithm as a}from"./SnappingAlgorithm.js";import{squaredScreenDistance as l}from"./snappingUtils.js";import{RightAngleTriangleSnappingCandidate as m}from"./candidates/RightAngleTriangleSnappingCandidate.js";import{vectorToScreenPoint as d}from"../support/viewUtils.js";import{projectPointToCircle as g}from"../../support/geometry2dUtils.js";class c extends a{snapNewVertex(e,t){const i=t.editGeometryOperations.data.parts.at(-1),r=[];if(!i)return r;const o=i.vertices.length;if("polygon"!==t.editGeometryOperations.data.type||o<2)return r;const{view:n}=this,p=i.vertices[0],a=i.vertices[o-1];if(a.leftSegment&&"line"!==a.leftSegment.type||a.rightSegment&&"line"!==a.rightSegment.type)return r;const l=s(p.pos,n,t),m=s(a.pos,n,t);return this._processCandidateProposal(l,m,e,t,r),r}snapExistingVertex(e,t){const i=[],r=t.vertexHandle,{part:o,rightSegment:n,leftSegment:p}=r;if(o.segments.length<2)return i;if("polyline"===t.editGeometryOperations.data.type&&(0===r.index||r.index===o.vertices.length-1))return i;if("line"!==p?.type||n&&"line"!==n.type)return i;const a=n?.rightVertex??(o.autoClose?o.getFirstVertex():null);if(!a)return i;const{view:l}=this,m=s(p.leftVertex.pos,l,t),d=s(a.pos,l,t);return this._processCandidateProposal(m,d,e,t,i),i}_processCandidateProposal(i,s,a,c,h){if(!this.exceedsShortLineThreshold(i,s,c))return;const u=e(f,o(i),o(s),.5),x=.5*t(o(i),o(s)),v=g(f,o(a),u,x),y=n(p(v[0],v[1],a[2])),{spatialReference:j,pointer:S}=c,w=d(a,j,r,this.view);if(l(w,d(y,j,r,this.view))<this.squaredProximityThreshold(S)){if(this.isVertical(i,y,c)||this.isVertical(y,s,c))return;h.push(new m({targetPoint:y,point1:i,point2:s,isDraped:"on-the-ground"===c.elevationInfo?.mode}))}}}const f=i();export{c as RightAngleTriangleSnapper};
|
package/webscene/Glow.d.ts
CHANGED
|
@@ -43,6 +43,7 @@ export interface GlowProperties extends Partial<Pick<Glow, "intensity">> {}
|
|
|
43
43
|
* });
|
|
44
44
|
* ```
|
|
45
45
|
*
|
|
46
|
+
* @see [Visualization with light-emitting symbols](https://developers.arcgis.com/javascript/latest/light-emitting-symbols/)
|
|
46
47
|
* @since 5.0
|
|
47
48
|
*/
|
|
48
49
|
export default class Glow extends GlowSuperclass {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.0/LICENSE.txt */
|
|
2
|
-
import e from"../../core/Error.js";import{json as
|
|
2
|
+
import e from"../../WebScene.js";import t from"../../core/Error.js";import{getPropertiesMetadata as r}from"../../core/accessorSupport/metadata.js";import{json as n}from"../../portal/schemas/webScene.js";import{ScanContext as s,sorted as i}from"./utils.js";function a(e,t){if(t.properties){if("layerType"in t.properties)return t.properties.layerType.enum[0];if("type"in t.properties&&t.properties.type.enum)return t.properties.type.enum[0]}switch(e){case"multipoint_geometry_schema.json":return"multipoint";case"point_geometry_schema.json":return"point";case"polyline_geometry_schema.json":return"polyline";case"polygon_geometry_schema.json":return"polygon";case"extent_schema.json":return"extent"}}function o(e){return"array"===e.type?`${o(e.items)}[]`:e.type}function c(e){const t={count:e.length,refsCount:0,typesCount:0,distinctTypes:[],type:null},r=new Set;for(const n in e){const s=e[n];s.$ref?t.refsCount++:s.type&&(t.typesCount++,r.add(o(s)))}return r.forEach(e=>t.distinctTypes.push(e)),t.distinctTypes.sort(),t.refsCount===t.count?t.type="refs":2===t.count&&t.refsCount>0&&1===t.distinctTypes.length&&"null"===t.distinctTypes[0]?t.type="refsAndNull":t.typesCount===t.count?(t.type="types",t.distinctTypes=t.distinctTypes):t.type="mix",t}function l(e,t){const r=t.stack[t.stack.length-1],n=1===t.stack.length?t.schemaRoot:t.definitions[r.klass.name];return n?.required&&n.required.includes(e.replace("[]",""))}function u(e){return"array"===e.type||!("properties"in e)}function p(e,t,r){if(!r.hasFilteredProperties)return`${e}--${t}`;return`${e}--${t}--${r.filteredPropertiesArray.join("/")}`}async function f(t,n,s,i,o,c){if("version_schema.json"===t){const t=r(e.prototype),n=t.sourceVersion.json?.type;n&&(s={...s,enum:n})}o.schemaStack.push(t);const f=a(t,s),m=i?i.replace("<?TYPE?>",f?`<${f}>`:""):"";if(u(s)){const e=o.currentClass?null:{type:t,name:t,id:`${t}--${n}`,typeValue:n,properties:[]};return e&&o.push(null,e),await E(s,m,o,c),o.schemaStack.pop(),e}const h=p(t,n,o),y="drawingInfo_schema.json"!==t&&"layer_schema.json"!==t&&o.seen.get(h);if(y&&m)return o.addProperty({name:m,type:y,required:l(m,o),nullable:c?.nullable}),o.schemaStack.pop(),y;const d={type:t,name:t,id:h,typeValue:n,properties:[]};return m&&o.addProperty({name:m,type:d,required:l(m,o),nullable:c?.nullable}),o.push(m,d),await E(s,"",o),o.schemaStack.pop(),o.pop()}async function m(e,t,r,n){const s=await r.requestSchema(e.$ref),i=O(s.schema);if(i){for(const e of i){const i={...s.schema};i.properties={...i.properties,type:{type:"string",enum:[e]}};const a=t&&!t.includes("<?TYPE?>")?`${t}<?TYPE?>`:t;await f(s.schemaId,e,i,a,r,n)}return}const a="layer_schema.json"===s.schemaId&&r.schemaStack.length?r.schemaStack[r.schemaStack.length-1].replace(/_schema\.json/,""):null;await f(s.schemaId,a,s.schema,t,r,n)}function h(e,t){if(!d(e))return!1;const r=e.stack.map(e=>e.klass.type).join("/");return/.*pointCloudLayer_schema\.json\/layerDefinition_schema\.json\/drawingInfo_schema\.json$/.test(r)&&"renderer"===t}function y(e,t){if(!_(e)&&!j(e))return!1;const r=e.stack.map(e=>e.klass.type).join("/");return(/.*(imageServiceLayer|tiledImageServiceLayer|wcsLayer)_schema\.json\/(layerDefinition|rasterLayerDefinition)_schema\.json\/rasterDrawingInfo_schema\.json$/.test(r)||/.*rasterPresetRenderer_schema\.json$/.test(r))&&"renderer"===t}function d(e){return!!e.currentClass&&"drawingInfo_schema.json"===e.currentClass.name}function _(e){return!!e.currentClass&&"rasterDrawingInfo_schema.json"===e.currentClass.name}function j(e){return!!e.currentClass&&"rasterPresetRenderer_schema.json"===e.currentClass.name}function w(e){switch(e.schemaStack[e.schemaStack.length-1]){case"operationalLayers_schema.json":case"elevationLayers_schema.json":case"baseMapLayer_schema.json":return!0}return!1}const $=/raster.*Renderer|vectorFieldRenderer/,g=/(uniqueValueRenderer|classBreaksRenderer|raster.*Renderer|vectorFieldRenderer)/,P=/(rasterUniqueValueRenderer|rasterClassBreaksRenderer)/;function S(e,t,r){if(d(r)||_(r)||j(r)){const n=h(r,t),s=y(r,t);return e.filter(e=>{if(e.$ref.endsWith("uniqueValueFromStyleRenderer_schema.json"))return!1;if(s)return g.test(e.$ref)&&!P.test(e.$ref);if($.test(e.$ref))return!1;const t=/pointCloud.*Renderer/.test(e.$ref);return n===t})}if(w(r)){const t=["kmlLayer","rasterDataElevationLayer","rasterDataLayer","object3DTilesLayer"];return e.filter(e=>!t.some(t=>e.$ref.replace(/.*\//,"")===`${t}_schema.json`))}return e}async function b(e,t,r){await E(e.items,`${t}[]`,r)}async function k(e,t,r){for(const n in e.properties)if(!("webscene_schema.json"===r.currentClass?.name&&"mapRangeInfo"===n||"baseMap_schema.json"===r.currentClass?.name&&"elevationLayers"===n)){if(d(r)){const e=r.stack.map(e=>e.klass.type).join("/");if(/imageServiceLayer|tiledImageServiceLayer/.test(e)&&"transparency"===n)continue}await r.withFilter(n,async()=>{const s=t?`${t}.${n}`:n;await E(e.properties[n],s,r)})}}function R(e,t="",r=new Set){for(const n of e)if("properties"in n)for(const e in n.properties){const s=n.properties[e],i=t?`${t}.${e}`:e,a=Object.keys(s);if(0===a.length||1===a.length&&"$ref"===a[0])r.add(i);else{if(1!==a.length||"allOf"!==a[0])throw new Error(`unexpected allOf filter construct: ${JSON.stringify(s)}`);r.add(i),R(s.allOf,i,r)}}return r}async function C(e,t,r){let n=null;for(const i of e.allOf)if("$ref"in i){if(n)throw new Error("Cannot process more than 1 ref in an allOf construct");n=i}else if(!("properties"in i))throw new Error("allOf construct only allows simple top-level property filters");const s=R(e.allOf);await r.addFilter(s,()=>m(n,t,r))}async function L(e,t,r){const n=c(e.oneOf),s="refsAndNull"===n.type;if("refs"===n.type||s){const n=S(e.oneOf,t,r);for(const e of n)if(s&&"null"===e.type);else{const i=`${t||""}`+(1!==n.length?"<?TYPE?>":"");await E(e,i,r,{nullable:s})}return}if("types"===n.type){const{types:e,nullable:s}=q(n.distinctTypes);return void r.addProperty({name:t,type:i(e).join("|"),required:l(t,r),nullable:s})}for(const i in e.oneOf){const n=`.oneOf[${i}]`;await E(e.oneOf[i],`${t}${n}`,r)}}function q(e){const t=e.indexOf("null");if(-1===t)return{types:e};const r=e.slice();return r.splice(t,1),{types:r,nullable:!0}}function O(e){if("layerDefinition"===e.title)return null;const t=e.properties?.type;return t?.enum?t.enum:null}async function T(e,t,r,n){await m(e,t,r,n)}async function v(e,t,r){let n,s="unknown";if(e.type){const{types:t,nullable:r}=q(Array.isArray(e.type)?e.type:e.type.replaceAll(" ","").split(","));s=i(t).join("|"),n=r}const a={name:t,type:s,default:e.default,required:l(t,r),nullable:n};e.enum&&(a.enum=i(e.enum).map(e=>"string"==typeof e?`"${e}"`:`${e}`).join("|")),r.addProperty(a)}async function E(e,t,r,n){return"array"===e.type?b(e,t,r):"properties"in e?k(e,t,r):"allOf"in e?C(e,t,r):"oneOf"in e?L(e,t,r):"$ref"in e?T(e,t,r,n):v(e,t,r)}const I="#/definitions/";function F(e){return e.startsWith(I)?e.slice(I.length):e}async function D(e,t){const r=await x.create(e,t);return f(`${e||"webscene"}_schema.json`,null,r.schemaRoot,null,r)}class x extends s{constructor(e,t,r){super(),this.definitions=e,this.schemaRoot=t,this.requestSchema=r,this._filteredProperties=null,this.schemaStack=[],this.requestSchema.bind(this)}get hasFilteredProperties(){return(this._filteredProperties?.size??0)>0}get filteredPropertiesArray(){const e=[];return this._filteredProperties?.forEach(t=>e.push(t)),e}async withFilter(e,t){if(!this.hasFilteredProperties)return t();if(!this._filteredProperties?.has(e))return;const r=this._filteredProperties;this._filteredProperties=null;const n=e=>{this._filteredProperties||(this._filteredProperties=new Set),this._filteredProperties.add(e)};r.forEach(t=>{const r=t.split(".",2);r.length>1&&r[0]===e&&n(r[1])}),await t(),this._filteredProperties=r}async addFilter(e,t){const r=this._filteredProperties;this._filteredProperties=null;const n=e=>{this._filteredProperties||(this._filteredProperties=new Set),this._filteredProperties.add(e)};r&&r.forEach(n),e&&e.forEach(n);const s=await t();return this._filteredProperties=r,s}static async create(e,t){return t?.useRemoteSchema?x.createRemote(e,t?.baseUrl):x.createLocal(e)}static createLocal(e){const t=e&&"webscene"!==e?n.definitions[`${e}_schema.json`]:n;return new x(n.definitions,t,x._getLocalSchemaRequest())}static async createRemote(e,t){const r=await x._getRemoteSchemaRequest(t),n=new x({},null,r),s=(await n.requestSchema(`${e||"webscene"}_schema.json`)).schema;return new x(n.definitions,s,r)}static _getLocalSchemaRequest(){return function(e){const r=F(e),n=this.definitions[r];return n?Promise.resolve({schemaId:r,schema:n}):Promise.reject(new t("spec-certification:spec-invalid-local-schema","Schema reference is not a local reference"))}}static async _getRemoteSchemaRequest(e){if(!e)return Promise.reject(new t("spec-certification:spec-missing-base-url","The base url of the remote schema directory must be specified when using a remote schema"));const r=x._getLocalSchemaRequest(),n=(await import("../../request.js")).default;return function(t){return r.call(this,t).catch(()=>n(`${e}/${t}`,{responseType:"json"}).then(e=>(this.definitions[F(t)]=e.data,{schemaId:t,schema:e.data})))}}}const A=Object.keys(n.definitions).map(e=>e.replace(/_schema\.json$/,""));export{D as scan,A as schemaDefinitions};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.0/LICENSE.txt */
|
|
2
|
-
import{__decorate as e}from"tslib";import t from"../../core/Accessor.js";import{createTask as i}from"../../core/asyncUtils.js";import l from"../../core/Collection.js";import s from"../../core/Error.js";import{throwIfAborted as r}from"../../core/promiseUtils.js";import{watch as o,initial as a,syncAndInitial as n}from"../../core/reactiveUtils.js";import{Milliseconds as h}from"../../core/time.js";import{property as d,subclass as c}from"../../core/accessorSupport/decorators.js";import u from"../../webdoc/Widgets.js";import f from"../../webdoc/widgets/FloorFilter.js";import{isWebMap as p}from"../../webmap/utils.js";import{GoTo as y}from"../support/GoTo.js";function v(e){return"esri.WebScene"===e.declaredClass}let m=class extends(y(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([o(()=>this.view?.map,e=>{null!=this._updateFloorFilterTask&&(this._updateFloorFilterTask.abort(),this._updateFloorFilterTask=null),this._updateFloorFilterTask=i(async t=>{await this._updateFloorFilterFromMap(e),r(t),this._setInitialViewState(e)})},a),o(()=>this.view,(e,t)=>{this._unregisterWidget(t),this._registerWidget(e),this._watchSearchResults(e)},n),o(()=>this.view?.widthBreakpoint??null,e=>{this._viewWidthBreakpoint=e}),o(()=>this.view?.heightBreakpoint??null,e=>{this._viewHeightBreakpoint=e})])}destroy(){this._unregisterWidget(this.view),this.view=null,null!=this._updateFloorFilterTask&&(this._updateFloorFilterTask.abort(),this._updateFloorFilterTask=null)}set enabled(e){this._callOverride("enabled",e)}set facility(e){if(e&&this._isOverridden("facility")){const 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 hasFacilities(){return null!=this.filterLayers?.facilityLayer&&this.filterFeatures?.facilities?.facilitiesInfo?.length>0}get hasLevels(){return null!=this.filterLayers?.levelLayer&&this.filterFeatures?.levels?.levelsInfo?.length>0}get hasMultipleSites(){return null!=this.filterLayers?.siteLayer&&this.filterFeatures?.sites?.sitesInfo?.length>1}get isNormalMode(){let e=!0;const t=this._viewWidthBreakpoint;return"xsmall"!==this._viewHeightBreakpoint&&"xsmall"!==t||(e=!1),e}set level(e){if(!e)return this._callOverride("level",e),this.facility=null,this.site=null,void this.setFloors(null);let t=null,i=null;const l=e?.split("--");if(l?.length>1&&"all"===l[0]?(i=l[1],t={id:e,facilityId:i,shortName:null,longName:null,levelNumber:null,verticalOrder:null}):(t=this.getLevel(e),i=t?.facilityId??null),this.level!==e||this.isNormalMode||this.levelsExpanded)t&&this.hasFacilities&&this.hasLevels?(this.facility=i,this.hasMultipleSites&&(this.site=this.getFacility(i)?.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);else{const e=this.getFacilityLevels(i);e?.length>1&&(this.levelsExpanded=!0)}}set longNames(e){this._callOverride("longNames",e)}set minimized(e){this._callOverride("minimized",e)}set pinnedLevels(e){this._callOverride("pinnedLevels",e)}get selectedVerticalOrder(){if(p(this.view?.map)){const e=this.view.map.resourceInfo;return e?.widgets?.floorFilter?.selectedVerticalOrder??null}return 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(){if(p(this.view?.map)){const e=this.view.map.resourceInfo;return e?.widgets?.floorFilter?.useVerticalOrder??!1}return!1}filterFacilities(e){let t=e;this.searchTerm&&(this.searchTerm=this.searchTerm.trim(),t=e.filter(e=>{const{name:t}=e;return t.toLowerCase().includes(this.searchTerm?.toLowerCase())})),this.site&&(t=t.filter(e=>e.siteId===this.site));return t.sort((e,t)=>{const i=e.name,l=t.name;return i.localeCompare(l,void 0,{sensitivity:"base"})})}filterSites(e){let t=e;this.searchTerm&&(this.searchTerm=this.searchTerm.trim(),t=e.filter(e=>{const{name:t}=e;return t.toLowerCase().includes(this.searchTerm?.toLowerCase())}));return t.sort((e,t)=>{const i=e.name,l=t.name;return i.localeCompare(l,void 0,{sensitivity:"base"})})}getBaseLevel(e){const t=this.filterFeatures?.levels?.levelsInfo;let i=null;if(e){const{id:l}=e;if(t&&t.length>0&&(t.forEach(e=>{0===e.verticalOrder&&e.facilityId===l&&(i=e)}),!i)){let e=null;t.forEach(t=>{t.facilityId===l&&(e?(t.verticalOrder??0)>=0?null!=e.verticalOrder&&(e.verticalOrder<0||(t.verticalOrder??0)<e.verticalOrder)&&(e=t):null!=e.verticalOrder&&null!=t.verticalOrder&&e.verticalOrder<0&&t.verticalOrder>e.verticalOrder&&(e=t):e=t)}),e&&(i=e)}}return i}getFacility(e){return this.filterFeatures?.facilities?.facilitiesInfo?.find(t=>t.id===e)??null}getFacilityLevels(e){if(!e||!this.filterFeatures?.levels?.levelsInfo)return[];return this.filterFeatures.levels.levelsInfo.filter(t=>t.facilityId===e).sort((e,t)=>{const i=e.verticalOrder??0,l=t.verticalOrder??0;return i>l?-1:i===l?0:1})}getLevel(e){return this.filterFeatures?.levels?.levelsInfo?.find(t=>t.id===e)??null}getSite(e){return this.filterFeatures?.sites?.sitesInfo?.find(t=>t.id===e)??null}goTo(e){const{view:t}=this;if(!t||!e)return;const{geometry:i}=e;i&&i.extent&&this.callGoTo({target:i.extent,options:{duration:h(1e3),easing:"quad-in-out-coast"}})}setFloors(e){const{view:t}=this;t&&(t?.map?.allLayers?.forEach(e=>{"feature"===e.type&&this._computeViewAllModeFloors(e)}),t.floors=new l(this._computeFloors(e)))}updateWebDocument(e){if(p(e)){const t=new f({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});e.widgets?e.widgets.floorFilter=t:e.widgets=new u({floorFilter:t})}}_computeFloors(e){if("single-floor"===this.filterMode)this._computeSingleFloor(e);else if("base-floors"===this.filterMode)return"3d"===this.view?.type?this._computeBaseFloors3D(e):this._computeBaseFloors(e);return this._computeEmptyFloors()}_computeSingleFloor(e){if(!e)return this._computeEmptyFloors();const t=[];if("all"===e?.id){this.getFacilityLevels(e.facilityId).forEach(e=>{e.id&&t.push(e.id)})}else e&&t.push(e.id);return t}_computeBaseFloors(e){const t=this.filterFeatures?.levels?.levelsInfo;if(!t?.length)return this._computeEmptyFloors();const i=[];if("all"===e?.id){this.getFacilityLevels(e.facilityId).forEach(e=>{e.id&&i.push(e.id)})}else e&&i.push(e.id);const l=e?.facilityId,s=e?.verticalOrder,r=(e,t)=>{0===e&&i.push(t)};return t.forEach(e=>{const{id:t,facilityId:o,verticalOrder:a}=e;l||i.includes(t)?o===l||i.includes(t)||(this.useVerticalOrder?a===s&&i.push(t):r(a,t)):r(a,t)}),i}_computeBaseFloors3D(e){const t=this.filterFeatures?.levels?.levelsInfo;if(!t?.length)return this._computeEmptyFloors();const i=[],l=e?.id.split("--")??[];if(l?.length>1&&"all"===l[0]){this.getFacilityLevels(e?.facilityId).forEach(e=>{e.id&&i.push(e.id)})}else e&&i.push(e.id);const s=e?.facilityId;return t.forEach(e=>{const{id:t,facilityId:l}=e;(s||i.includes(t))&&(l===s||i.includes(t))||i.push(t)}),i}_computeEmptyFloors(){return[]}async _setFilterLayers(){const{view:e}=this;if(e&&!this._isOverridden("filterLayers")){if(!p(e.map)&&!v(e.map))throw new s("floorfilter:unsupported-map","Map must be a webmap or webscene");{const t=e.map,i=t?.allLayers;if(i?.items?.length>0){const e={siteLayer:null,facilityLayer:null,levelLayer:null},l=t.floorInfo?.siteLayer?.layerId,s=t.floorInfo?.facilityLayer?.layerId,r=t.floorInfo?.levelLayer?.layerId,o=t.floorInfo?.siteLayer?.sublayerId||t.floorInfo?.facilityLayer?.sublayerId||t.floorInfo?.levelLayer?.sublayerId;if(!s||!r)return;const a=i.items.filter(e=>"feature"===e.type||"scene"===e.type),n=i.items.filter(e=>"map-image"===e.type);if(n?.length>0&&o){await Promise.all(n.map(e=>e.load()));const i=t.floorInfo?.siteLayer?.sublayerId,o=t.floorInfo?.facilityLayer?.sublayerId,a=t.floorInfo?.levelLayer?.sublayerId;n.forEach(t=>{const n=t.id,h=t?.allSublayers,d=h?.items;(n===l||n===s||n===r)&&d?.length>0&&h.items.forEach(t=>{const s=t.id;n===l&&s===i?e.siteLayer=t:s===o?e.facilityLayer=t:s===a&&(e.levelLayer=t)})})}a?.length>0&&a.forEach(t=>{const i=t.id;i===l?e.siteLayer=t:i===s?e.facilityLayer=t:i===r&&(e.levelLayer=t)}),this.filterLayers=e}}}}async _getFilterFeatures(){if(this._isOverridden("filterFeatures"))return this.filterFeatures;const[e,t,i]=await Promise.all([this._getSites(),this._getFacilities(),this._getLevels()]);return{sites:e,facilities:t,levels:i}}async _getSites(){const e={sitesInfo:[]},{filterLayers:t,view:i}=this,l=i?.map,{siteLayer:s}=t;if(!s||!l?.floorInfo?.siteLayer)return e;const r=s.createQuery();r.returnGeometry=!0,r.outFields=["*"],r.returnZ=!0,"type"in s&&"scene"===s.type&&(r.multipatchOption="xyFootprint");const{siteIdField:o,nameField:a}=l.floorInfo.siteLayer,n=await s.queryFeatures(r);if(n?.features?.length>0){const t=n.features,i=s?.fieldsIndex.get(o)?.name||o,l=s?.fieldsIndex.get(a)?.name||a;null!=i&&null!=l&&t.forEach(t=>{const s=t.attributes,r=t.geometry,o=s[i],a=s[l];o&&a&&e.sitesInfo.push({id:o,name:a,geometry:r})})}return e}async _getFacilities(){const{filterLayers:e,view:t}=this,i=t?.map,{facilityLayer:l}=e,s={facilitiesInfo:[]};if(!l||!i?.floorInfo?.facilityLayer)return s;const r=l.createQuery();r.returnGeometry=!0,r.outFields=["*"],r.returnZ=!0,"type"in l&&"scene"===l.type&&(r.multipatchOption="xyFootprint");const{facilityIdField:o,siteIdField:a,nameField:n}=i.floorInfo.facilityLayer,h=await l.queryFeatures(r);if(h?.features?.length>0){const e=h.features,t=l?.fieldsIndex.get(o)?.name||o,i=l?.fieldsIndex.get(a)?.name||a,r=l?.fieldsIndex.get(n)?.name||n;t&&i&&r&&e.forEach(e=>{const l=e.attributes,o=e.geometry,a=l[t],n=l[i],h=l[r];a&&h&&s.facilitiesInfo.push({id:a,siteId:n,name:h,geometry:o})})}return s}async _getLevels(){const{filterLayers:e,view:t}=this,i=t?.map,{levelLayer:l}=e,s={levelsInfo:[]};if(!l||!i?.floorInfo?.levelLayer)return s;const r=l.createQuery();r.returnGeometry=!0,r.outFields=["*"],r.returnZ=!0;const{levelIdField:o,facilityIdField:a,longNameField:n,shortNameField:h,levelNumberField:d,verticalOrderField:c}=i.floorInfo.levelLayer,u=await l.queryFeatures(r);if(u?.features?.length>0){const e=u.features,t=l?.fieldsIndex.get(o)?.name||o,i=l?.fieldsIndex.get(a)?.name||a,r=l?.fieldsIndex.get(n)?.name||n,f=l?.fieldsIndex.get(h)?.name||h,p=l?.fieldsIndex.get(d)?.name||d,y=l?.fieldsIndex.get(c)?.name||c;t&&i&&r&&f&&p&&y&&e.forEach(e=>{const l=e.attributes,o=l[t],a=l[i],n=l[r],h=l[f],d=l[p],c=l[y];o&&a&&n&&h&&"number"==typeof d&&"number"==typeof c&&s.levelsInfo.push({id:o,facilityId:a,longName:n,shortName:h,levelNumber:d,verticalOrder:c})})}return s}_registerWidget(e){const t=e?.persistableViewModels.includes(this);t||e?.persistableViewModels.add(this)}_unregisterWidget(e){e?.persistableViewModels.remove(this)}_watchSearchResults(e){e?.on("select-result-floor",e=>{const 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();const t=await this._getFilterFeatures();if(!t)return;if(this.filterFeatures=t,!this.hasFacilities||!this.hasLevels)return void console.error("Facilities and Levels are required for the Floor Filter widget");if(this.hasMultipleSites||(this.filterMenuType="facility"),this.facility&&this.level){this.filterMenuType="facility";const e=this.getFacility(this.facility),t=this.getLevel(this.level);this.site||(this.site=e?.siteId||void 0),this.setFloors(t)}else if(this.facility&&!this.level){this.filterMenuType="facility";const e=this.getFacility(this.facility),t=this.getBaseLevel(e);this.site||(this.site=e?.siteId||void 0),this.level=t?.id||void 0,this.setFloors(t)}else if(!this.facility&&this.level){this.filterMenuType="facility";const e=this.getLevel(this.level),t=this.getFacility(e?.facilityId);this.facility=t?.id||void 0,this.site||(this.site=t?.siteId||void 0),this.setFloors(e)}else if(!this.site||this.facility||this.level){if(!e||!p(e))return void this.setFloors(null);const t=e?.widgets?.floorFilter;if(!t)return void this.setFloors(null);t.site&&!this.site&&(this.site=t.site,this.filterMenuType="facility"),this.setFloors(null)}else this.filterMenuType="site",this.setFloors(null)}catch(t){console.error("Couldn't retrieve sites, facilities, and levels",t)}}_callOverride(e,t){this._override(e,t)}async _updateFloorFilterFromMap(e){if(!e||!p(e))return;const 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))}_computeViewAllModeFloors(e){const{filterFeatures:t}=this;if(e.floorInfo?.viewAllMode&&this.hasLevels&&this.hasFacilities&&"base-floors"===this.filterMode){const{level:i,facility:s}=this,r=[];t.levels.levelsInfo.forEach(e=>{const{id:t,facilityId:l}=e;s&&l===s?i&&t===i&&r.push(t):r.push(t)}),e.floorInfo.viewAllLevelIds=new l(r)}}};e([d({value:!1})],m.prototype,"enabled",null),e([d({value:void 0})],m.prototype,"facility",null),e([d({value:null})],m.prototype,"filterFeatures",null),e([d({value:null})],m.prototype,"filterLayers",null),e([d()],m.prototype,"filterMenuOpen",void 0),e([d()],m.prototype,"filterMenuType",void 0),e([d()],m.prototype,"filterMode",void 0),e([d()],m.prototype,"hasFacilities",null),e([d()],m.prototype,"hasLevels",null),e([d()],m.prototype,"hasMultipleSites",null),e([d({readOnly:!0})],m.prototype,"isNormalMode",null),e([d({value:void 0})],m.prototype,"level",null),e([d({value:!1})],m.prototype,"longNames",null),e([d()],m.prototype,"levelsExpanded",void 0),e([d({value:!1})],m.prototype,"minimized",null),e([d({value:!1})],m.prototype,"pinnedLevels",null),e([d()],m.prototype,"searchTerm",void 0),e([d({readOnly:!0})],m.prototype,"selectedVerticalOrder",null),e([d({value:void 0})],m.prototype,"site",null),e([d({readOnly:!0})],m.prototype,"state",null),e([d({readOnly:!0,value:!1})],m.prototype,"useVerticalOrder",null),e([d()],m.prototype,"view",void 0),e([d()],m.prototype,"_viewHeightBreakpoint",void 0),e([d()],m.prototype,"_viewWidthBreakpoint",void 0),e([d()],m.prototype,"updateWebDocument",null),m=e([c("esri.widgets.FloorFilter.FloorFilterViewModel")],m);const F=m;export{F as default};
|
|
2
|
+
import{__decorate as e}from"tslib";import t from"../../core/Accessor.js";import{createTask as i}from"../../core/asyncUtils.js";import l from"../../core/Collection.js";import s from"../../core/Error.js";import{throwIfAborted as r}from"../../core/promiseUtils.js";import{watch as o,initial as a,syncAndInitial as n}from"../../core/reactiveUtils.js";import{Milliseconds as h}from"../../core/time.js";import{property as d,subclass as c}from"../../core/accessorSupport/decorators.js";import u from"../../webdoc/Widgets.js";import f from"../../webdoc/widgets/FloorFilter.js";import{isWebMap as p}from"../../webmap/utils.js";import{GoTo as y}from"../support/GoTo.js";function v(e){return"esri.WebScene"===e.declaredClass}let m=class extends(y(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([o(()=>this.view?.map,e=>{null!=this._updateFloorFilterTask&&(this._updateFloorFilterTask.abort(),this._updateFloorFilterTask=null),this._updateFloorFilterTask=i(async t=>{await this._updateFloorFilterFromMap(e),r(t),this._setInitialViewState(e)})},a),o(()=>this.view,(e,t)=>{this._unregisterWidget(t),this._registerWidget(e),this._watchSearchResults(e)},n),o(()=>this.view?.widthBreakpoint??null,e=>{this._viewWidthBreakpoint=e}),o(()=>this.view?.heightBreakpoint??null,e=>{this._viewHeightBreakpoint=e})])}destroy(){this._unregisterWidget(this.view),this.view=null,null!=this._updateFloorFilterTask&&(this._updateFloorFilterTask.abort(),this._updateFloorFilterTask=null)}set enabled(e){this._callOverride("enabled",e)}set facility(e){if(e&&this._isOverridden("facility")){const 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 hasFacilities(){return null!=this.filterLayers?.facilityLayer&&this.filterFeatures?.facilities?.facilitiesInfo?.length>0}get hasLevels(){return null!=this.filterLayers?.levelLayer&&this.filterFeatures?.levels?.levelsInfo?.length>0}get hasMultipleSites(){return null!=this.filterLayers?.siteLayer&&this.filterFeatures?.sites?.sitesInfo?.length>1}get isNormalMode(){let e=!0;const t=this._viewWidthBreakpoint;return"xsmall"!==this._viewHeightBreakpoint&&"xsmall"!==t||(e=!1),e}set level(e){if(!e)return this._callOverride("level",e),this.facility=null,this.site=null,void this.setFloors(null);let t=null,i=null;const l=e?.split("--");if(l?.length>1&&"all"===l[0]?(i=l[1],t={id:e,facilityId:i,shortName:null,longName:null,levelNumber:null,verticalOrder:null}):(t=this.getLevel(e),i=t?.facilityId??null),this.level!==e||this.isNormalMode||this.levelsExpanded)t&&this.hasFacilities&&this.hasLevels?(this.facility=i,this.hasMultipleSites&&(this.site=this.getFacility(i)?.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);else{const e=this.getFacilityLevels(i);e?.length>1&&(this.levelsExpanded=!0)}}set longNames(e){this._callOverride("longNames",e)}set minimized(e){this._callOverride("minimized",e)}set pinnedLevels(e){this._callOverride("pinnedLevels",e)}get selectedVerticalOrder(){if(p(this.view?.map)){const e=this.view.map.resourceInfo;return e?.widgets?.floorFilter?.selectedVerticalOrder??null}return 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(){if(p(this.view?.map)){const e=this.view.map.resourceInfo;return e?.widgets?.floorFilter?.useVerticalOrder??!1}return!1}filterFacilities(e){let t=e;this.searchTerm&&(this.searchTerm=this.searchTerm.trim(),t=e.filter(e=>{const{name:t}=e;return t.toLowerCase().includes(this.searchTerm?.toLowerCase())})),this.site&&(t=t.filter(e=>e.siteId===this.site));return t.sort((e,t)=>{const i=e.name,l=t.name;return i.localeCompare(l,void 0,{sensitivity:"base"})})}filterSites(e){let t=e;this.searchTerm&&(this.searchTerm=this.searchTerm.trim(),t=e.filter(e=>{const{name:t}=e;return t.toLowerCase().includes(this.searchTerm?.toLowerCase())}));return t.sort((e,t)=>{const i=e.name,l=t.name;return i.localeCompare(l,void 0,{sensitivity:"base"})})}getBaseLevel(e){const t=this.filterFeatures?.levels?.levelsInfo;let i=null;if(e){const{id:l}=e;if(t&&t.length>0&&(t.forEach(e=>{0===e.verticalOrder&&e.facilityId===l&&(i=e)}),!i)){let e=null;t.forEach(t=>{t.facilityId===l&&(e?(t.verticalOrder??0)>=0?null!=e.verticalOrder&&(e.verticalOrder<0||(t.verticalOrder??0)<e.verticalOrder)&&(e=t):null!=e.verticalOrder&&null!=t.verticalOrder&&e.verticalOrder<0&&t.verticalOrder>e.verticalOrder&&(e=t):e=t)}),e&&(i=e)}}return i}getFacility(e){return this.filterFeatures?.facilities?.facilitiesInfo?.find(t=>t.id===e)??null}getFacilityLevels(e){if(!e||!this.filterFeatures?.levels?.levelsInfo)return[];return this.filterFeatures.levels.levelsInfo.filter(t=>t.facilityId===e).sort((e,t)=>{const i=e.verticalOrder??0,l=t.verticalOrder??0;return i>l?-1:i===l?0:1})}getLevel(e){return this.filterFeatures?.levels?.levelsInfo?.find(t=>t.id===e)??null}getSite(e){return this.filterFeatures?.sites?.sitesInfo?.find(t=>t.id===e)??null}goTo(e){const{view:t}=this;if(!t||!e)return;const{geometry:i}=e;i&&i.extent&&this.callGoTo({target:i.extent,options:{duration:h(1e3),easing:"quad-in-out-coast"}})}setFloors(e){const{view:t}=this;t&&(t?.map?.allLayers?.forEach(e=>{"feature"===e.type&&this._computeViewAllModeFloors(e)}),t.floors=new l(this._computeFloors(e)))}updateWebDocument(e){if(p(e)){const t=new f({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});e.widgets?e.widgets.floorFilter=t:e.widgets=new u({floorFilter:t})}}_computeFloors(e){if("single-floor"===this.filterMode)this._computeSingleFloor(e);else if("base-floors"===this.filterMode)return"3d"===this.view?.type?this._computeBaseFloors3D(e):this._computeBaseFloors(e);return this._computeEmptyFloors()}_computeSingleFloor(e){if(!e)return this._computeEmptyFloors();const t=[];if("all"===e?.id){this.getFacilityLevels(e.facilityId).forEach(e=>{e.id&&t.push(e.id)})}else e&&t.push(e.id);return t}_computeBaseFloors(e){const t=this.filterFeatures?.levels?.levelsInfo;if(!t?.length)return this._computeEmptyFloors();const i=[];if("all"===e?.id){this.getFacilityLevels(e.facilityId).forEach(e=>{e.id&&i.push(e.id)})}else e&&i.push(e.id);const l=e?.facilityId,s=e?.verticalOrder,r=(e,t)=>{0===e&&i.push(t)};return t.forEach(e=>{const{id:t,facilityId:o,verticalOrder:a}=e;l||i.includes(t)?o===l||i.includes(t)||(this.useVerticalOrder?a===s&&i.push(t):r(a,t)):r(a,t)}),i}_computeBaseFloors3D(e){const t=this.filterFeatures?.levels?.levelsInfo;if(!t?.length)return this._computeEmptyFloors();const i=[],l=e?.id.split("--")??[];if(l?.length>1&&"all"===l[0]){this.getFacilityLevels(e?.facilityId).forEach(e=>{e.id&&i.push(e.id)})}else e&&i.push(e.id);const s=e?.facilityId;return t.forEach(e=>{const{id:t,facilityId:l}=e;(s||i.includes(t))&&(l===s||i.includes(t))||i.push(t)}),i}_computeEmptyFloors(){return[]}async _setFilterLayers(){const{view:e}=this;if(e&&!this._isOverridden("filterLayers")){if(!p(e.map)&&!v(e.map))throw new s("floorfilter:unsupported-map","Map must be a webmap or webscene");{const t=e.map,i=t?.allLayers;if(i?.items?.length>0){const e={siteLayer:null,facilityLayer:null,levelLayer:null},l=t.floorInfo?.siteLayer?.layerId,s=t.floorInfo?.facilityLayer?.layerId,r=t.floorInfo?.levelLayer?.layerId,o=t.floorInfo?.siteLayer?.sublayerId||t.floorInfo?.facilityLayer?.sublayerId||t.floorInfo?.levelLayer?.sublayerId;if(!s||!r)return;const a=i.items.filter(e=>"feature"===e.type||"scene"===e.type),n=i.items.filter(e=>"map-image"===e.type);if(n?.length>0&&o){await Promise.all(n.map(e=>e.load()));const i=t.floorInfo?.siteLayer?.sublayerId,o=t.floorInfo?.facilityLayer?.sublayerId,a=t.floorInfo?.levelLayer?.sublayerId;n.forEach(t=>{const n=t.id,h=t?.allSublayers,d=h?.items;(n===l||n===s||n===r)&&d?.length>0&&h.items.forEach(t=>{const s=t.id;n===l&&s===i?e.siteLayer=t:s===o?e.facilityLayer=t:s===a&&(e.levelLayer=t)})})}a?.length>0&&a.forEach(t=>{const i=t.id;i===l?e.siteLayer=t:i===s?e.facilityLayer=t:i===r&&(e.levelLayer=t)}),this.filterLayers=e}}}}async _getFilterFeatures(){if(this._isOverridden("filterFeatures"))return this.filterFeatures;const[e,t,i]=await Promise.all([this._getSites(),this._getFacilities(),this._getLevels()]);return{sites:e,facilities:t,levels:i}}async _getSites(){const e={sitesInfo:[]},{filterLayers:t,view:i}=this,l=i?.map,{siteLayer:s}=t;if(!s||!l?.floorInfo?.siteLayer)return e;const r=s.createQuery();r.returnGeometry=!0,r.outFields=["*"],r.returnZ=!0,"type"in s&&"scene"===s.type&&(r.multipatchOption="xyFootprint");const{siteIdField:o,nameField:a}=l.floorInfo.siteLayer,n=await s.queryFeatures(r);if(n?.features?.length>0){const t=n.features,i=s?.fieldsIndex.get(o)?.name||o,l=s?.fieldsIndex.get(a)?.name||a;null!=i&&null!=l&&t.forEach(t=>{const s=t.attributes,r=t.geometry,o=s[i],a=s[l];o&&a&&e.sitesInfo.push({id:o,name:a,geometry:r})})}return e}async _getFacilities(){const{filterLayers:e,view:t}=this,i=t?.map,{facilityLayer:l}=e,s={facilitiesInfo:[]};if(!l||!i?.floorInfo?.facilityLayer)return s;const r=l.createQuery();r.returnGeometry=!0,r.outFields=["*"],r.returnZ=!0,"type"in l&&"scene"===l.type&&(r.multipatchOption="xyFootprint");const{facilityIdField:o,siteIdField:a,nameField:n}=i.floorInfo.facilityLayer,h=await l.queryFeatures(r);if(h?.features?.length>0){const e=h.features,t=l?.fieldsIndex.get(o)?.name||o,i=l?.fieldsIndex.get(a)?.name||a,r=l?.fieldsIndex.get(n)?.name||n;t&&i&&r&&e.forEach(e=>{const l=e.attributes,o=e.geometry,a=l[t],n=l[i],h=l[r];a&&h&&s.facilitiesInfo.push({id:a,siteId:n,name:h,geometry:o})})}return s}async _getLevels(){const{filterLayers:e,view:t}=this,i=t?.map,{levelLayer:l}=e,s={levelsInfo:[]};if(!l||!i?.floorInfo?.levelLayer)return s;const r=l.createQuery();r.returnGeometry=!0,r.outFields=["*"],r.returnZ=!0;const{levelIdField:o,facilityIdField:a,longNameField:n,shortNameField:h,levelNumberField:d,verticalOrderField:c}=i.floorInfo.levelLayer,u=await l.queryFeatures(r);if(u?.features?.length>0){const e=u.features,t=l?.fieldsIndex.get(o)?.name||o,i=l?.fieldsIndex.get(a)?.name||a,r=l?.fieldsIndex.get(n)?.name||n,f=l?.fieldsIndex.get(h)?.name||h,p=l?.fieldsIndex.get(d)?.name||d,y=l?.fieldsIndex.get(c)?.name||c;t&&i&&r&&f&&p&&y&&e.forEach(e=>{const l=e.attributes,o=l[t],a=l[i],n=l[r],h=l[f],d=l[p],c=l[y];o&&a&&n&&h&&"number"==typeof d&&"number"==typeof c&&s.levelsInfo.push({id:o,facilityId:a,longName:n,shortName:h,levelNumber:d,verticalOrder:c})})}return s}_registerWidget(e){const t=e?.persistableViewModels.includes(this);t||e?.persistableViewModels.add(this)}_unregisterWidget(e){e?.persistableViewModels.remove(this)}_watchSearchResults(e){e?.on("select-result-floor",e=>{const 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();const t=await this._getFilterFeatures();if(!t)return;if(this.filterFeatures=t,!this.hasFacilities||!this.hasLevels)return void console.error("Facilities and Levels are required for the Floor Filter widget");if(this.hasMultipleSites||(this.filterMenuType="facility"),this.facility&&this.level){this.filterMenuType="facility";const e=this.getFacility(this.facility),t=this.getLevel(this.level);this.site||(this.site=e?.siteId||void 0),this.setFloors(t)}else if(this.facility&&!this.level){this.filterMenuType="facility";const e=this.getFacility(this.facility),t=this.getBaseLevel(e);this.site||(this.site=e?.siteId||void 0),this.level=t?.id||void 0,this.setFloors(t)}else if(!this.facility&&this.level){this.filterMenuType="facility";const e=this.getLevel(this.level),t=this.getFacility(e?.facilityId);this.facility=t?.id||void 0,this.site||(this.site=t?.siteId||void 0),this.setFloors(e)}else if(!this.site||this.facility||this.level){if(!e||!p(e))return void this.setFloors(null);const t=e?.widgets?.floorFilter;if(!t)return void this.setFloors(null);t.site&&!this.site&&(this.site=t.site,this.filterMenuType="facility"),this.setFloors(null)}else this.filterMenuType="site",this.setFloors(null)}catch(t){console.error("Couldn't retrieve sites, facilities, and levels",t)}}_callOverride(e,t){this._override(e,t)}async _updateFloorFilterFromMap(e){if(!e||!p(e))return;await(this.view?.when());const 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))}_computeViewAllModeFloors(e){const{filterFeatures:t}=this;if(e.floorInfo?.viewAllMode&&this.hasLevels&&this.hasFacilities&&"base-floors"===this.filterMode){const{level:i,facility:s}=this,r=[];t.levels.levelsInfo.forEach(e=>{const{id:t,facilityId:l}=e;s&&l===s?i&&t===i&&r.push(t):r.push(t)}),e.floorInfo.viewAllLevelIds=new l(r)}}};e([d({value:!1})],m.prototype,"enabled",null),e([d({value:void 0})],m.prototype,"facility",null),e([d({value:null})],m.prototype,"filterFeatures",null),e([d({value:null})],m.prototype,"filterLayers",null),e([d()],m.prototype,"filterMenuOpen",void 0),e([d()],m.prototype,"filterMenuType",void 0),e([d()],m.prototype,"filterMode",void 0),e([d()],m.prototype,"hasFacilities",null),e([d()],m.prototype,"hasLevels",null),e([d()],m.prototype,"hasMultipleSites",null),e([d({readOnly:!0})],m.prototype,"isNormalMode",null),e([d({value:void 0})],m.prototype,"level",null),e([d({value:!1})],m.prototype,"longNames",null),e([d()],m.prototype,"levelsExpanded",void 0),e([d({value:!1})],m.prototype,"minimized",null),e([d({value:!1})],m.prototype,"pinnedLevels",null),e([d()],m.prototype,"searchTerm",void 0),e([d({readOnly:!0})],m.prototype,"selectedVerticalOrder",null),e([d({value:void 0})],m.prototype,"site",null),e([d({readOnly:!0})],m.prototype,"state",null),e([d({readOnly:!0,value:!1})],m.prototype,"useVerticalOrder",null),e([d()],m.prototype,"view",void 0),e([d()],m.prototype,"_viewHeightBreakpoint",void 0),e([d()],m.prototype,"_viewWidthBreakpoint",void 0),e([d()],m.prototype,"updateWebDocument",null),m=e([c("esri.widgets.FloorFilter.FloorFilterViewModel")],m);const F=m;export{F as default};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.0/LICENSE.txt */
|
|
2
|
-
import{__decorate as e}from"tslib";import{EsriPromise as t}from"../../../../core/Promise.js";import{throwIfAborted as a}from"../../../../core/promiseUtils.js";import{property as r,subclass as i}from"../../../../core/accessorSupport/decorators.js";import{projectAsync as s}from"../../../../geometry/projectionUtils.js";import{convertSphereVertexToPixelLocation as n}from"../../../../layers/orientedImagery/transformations/utils.js";import{getModeCorrectedPoints as c,computeTriangulatedVector as u,computeTriangulatedAreaMeasurement as m,computeTriangulatedDistanceMeasurement as o}from"../../imageMeasurementUtils.js";import{
|
|
2
|
+
import{__decorate as e}from"tslib";import{EsriPromise as t}from"../../../../core/Promise.js";import{throwIfAborted as a}from"../../../../core/promiseUtils.js";import{property as r,subclass as i}from"../../../../core/accessorSupport/decorators.js";import{projectAsync as s}from"../../../../geometry/projectionUtils.js";import{convertSphereVertexToPixelLocation as n}from"../../../../layers/orientedImagery/transformations/utils.js";import{getModeCorrectedPoints as c,computeTriangulatedVector as u,computeTriangulatedAreaMeasurement as m,computeTriangulatedDistanceMeasurement as o}from"../../imageMeasurementUtils.js";import{extractHorizonAnglesFromMedia as l}from"../../utils.js";import{TriangulatedSketchHandlerMixin as d}from"../../mixins/TriangulatedSketchHandlerMixin.js";let p=[],g=class extends(d(t)){constructor(e){super(e),this.type="measurement"}async handleUpdate(e){const{measureType:t,updatingTriangularMeasurementState:a,currentBestFeature:r,currentBestFeatureMeasurementImage:i,activeTriangulatedViewer:s,activeViewer:n,layer:c,imageMeasurementViewer:u,mode:m,footprintExtent:o,view:l}=this.viewModel;if(i&&r&&t){if(this._preventLeftMouseDrag(),"distance"===t){const t=e.graphics[0].geometry;p=t.paths[0]}else if("area"===t){const t=e.graphics[0].geometry;p=t.rings[0]}if("complete"===e.state)if(this.viewModel.triangulatedMeasurementGraphic=e.graphics.at(-1),a)await this._updateTriangularMeasurements(p);else{const e={pixels:p,activeFeature:i,activeViewer:s,mode:m,spatialReference:l?.spatialReference};await(this.measurementService?.updateMeasurementVectorsArray(e));const a={pixels:p,measureType:t,currentBestFeature:r,currentBestFeatureMeasurementImage:i,activeViewer:n,activeTriangulatedViewer:s,mode:m,imageSize:u?.imageSize,layer:c,footprintExtent:o},d=await(this.measurementService?.calculateTriangulatedMeasurements(a));d&&("distance"===t?(this.viewModel.triangulatedDistanceMeasurement=d.distance,this.viewModel.triangulatedDistanceAccuracy=d.accuracy):"area"===t&&(this.viewModel.triangulatedAreaMeasurement=d.area,this.viewModel.triangulatedAreaAccuracy=d.accuracy??this.viewModel.triangulatedAreaAccuracy))}}}async _computeMeasurementVector(e,t){const{activeViewer:a,activeTriangulatedViewer:r,mode:i,view:n}=this.viewModel,m=a?.imageSize,o=l(r?.media);if(!e||!t||!m)return;const d=c(e,i,m,o),p=n?.spatialReference,g=[];for(let c=0;c<d.length;c++){const e={x:d[c][0],y:d[c][1]};let t=await(this.measurementService?.referenceTransformationService?.pixelToMapPoint(e));if(!t)return;p&&!t.spatialReference.equals(p)&&(t=await s(t,p)),g.push(t)}return u(g,t)}async _updateTriangularMeasurements(e,t){const{measureType:r,mode:i,activeTriangulatedViewer:s,activeViewer:c,layer:u,footprintExtent:l,triangularMeasurementActive:d,currentBestFeature:p,currentBestFeatureMeasurementImage:g,updatingTriangularMeasurementState:v}=this.viewModel,w=s?.imageSize;if(!(d&&g&&v&&s?.imageSize&&2===this.measurementService?.measurementVectors?.length&&w))return;const[M,h]=s.imageSize;this.measurementService.measurementVectors.splice(-1);const f=await this._computeMeasurementVector(e,g);if(a(t),f&&this.measurementService.measurementVectors.push(f),2===this.measurementService.measurementVectors.length){switch(r){case"distance":{this.viewModel.triangulatedDistanceMeasurement=await o(this.measurementService.measurementVectors),a(t);const r=e.map(([e,t,a])=>{const{x:r,y:i}=n({x:e,y:t,z:a},M,h);return[r,i]}),m={measurementArray:e,measurementType:"distance",currentBestFeature:p,currentBestFeatureMeasurementImage:g,activeViewer:c,imageSize:w,layer:u,triangularMeasurementActive:!0,footprintExtent:l,options:t},d={measurementArray:r,measurementType:"distance",secondaryViewer:!0,currentBestFeature:p,currentBestFeatureMeasurementImage:g,activeViewer:c,activeTriangulatedViewer:s,layer:u,footprintExtent:l,options:t},v="default"===i?await this.measurementService.calculateAccuracy(m):await this.measurementService.calculateAccuracyPanoramic(d);if(a(t),v&&this.viewModel.triangulatedDistanceMeasurement?.distance){const e=Math.atan(v/this.viewModel.triangulatedDistanceMeasurement.distance);this.viewModel.triangulatedDistanceAccuracy={distanceAccuracy:v,angleAccuracy:e}}break}case"area":if(g?.geometry.spatialReference){const e=await m(this.measurementService.measurementVectors,g.geometry.spatialReference);a(t),this.viewModel.triangulatedAreaMeasurement=e}}if(this.viewModel.updatingTriangularMeasurementState=!1,"panoramic"===this.viewModel.mode){this.viewModel.activeTriangulatedViewer.viewModel.restoreNavigationHandles()}}}_preventLeftMouseDrag(){const{mode:e,activeTriangulatedViewer:t}=this.viewModel;if("panoramic"!==e||!t)return;let a=null;t.imageRenderer.on("pointer-down",e=>{a=e.button}),t.imageRenderer.on("drag",e=>{0===a&&e.stopPropagation()})}};e([r()],g.prototype,"type",void 0),g=e([i("esri.widgets.OrientedImageryViewer.adapters.sketch.TriangulatedMeasurementAdapter")],g);const v=g;export{v as default};
|