@arcgis/core 5.1.0-next.76 → 5.1.0-next.78
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/ElevationProfile/ElevationProfileGroup.d.ts +74 -0
- package/analysis/ElevationProfile/ElevationProfileGroup.js +2 -0
- package/analysis/ElevationProfileAnalysis.d.ts +29 -14
- package/analysis/ElevationProfileAnalysis.js +1 -1
- package/applications/Components/OrientedImageryViewer/ImageViewer/utils.d.ts +34 -0
- package/applications/Components/OrientedImageryViewer/ImageViewer/utils.js +2 -0
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/{537fe2522dff1e6ce03b.js → 11ea4be441a26134ce1f.js} +1 -1
- package/assets/esri/core/workers/chunks/17acbf40e7c1cb42d9bd.js +1 -0
- package/assets/esri/core/workers/chunks/1c7fd0a229a8112b0539.js +596 -0
- package/assets/esri/core/workers/chunks/{baeb96aef03d4c566af7.js → 1f53620f82cc7c3daabe.js} +1 -1
- package/assets/esri/core/workers/chunks/2387613b855771a3e537.js +1 -0
- package/assets/esri/core/workers/chunks/283d39dfb1625b5a74db.js +1 -0
- package/assets/esri/core/workers/chunks/{5e1b847b116d21908a54.js → 322c54081b25f1c53661.js} +1 -1
- package/assets/esri/core/workers/chunks/{330b47ac0759c3c35cc5.js → 34fe97bcacc0dfc5bce6.js} +1 -1
- package/assets/esri/core/workers/chunks/{14eb2cc8e2ad6d8d03fd.js → 3d9fcbe95dd22dbe730e.js} +1 -1
- package/assets/esri/core/workers/chunks/{e262c4864dc06c43b380.js → 3df8493b91aa3bce824d.js} +1 -1
- package/assets/esri/core/workers/chunks/{bf8f603848bad4a7deb4.js → 4ccb56333de0247dcb6f.js} +1 -1
- package/assets/esri/core/workers/chunks/5b6f2bfdcdd207d8ae42.js +1 -0
- package/assets/esri/core/workers/chunks/{88b480a1d1fb01778798.js → 5ee4b630ad39c21d11db.js} +21 -26
- package/assets/esri/core/workers/chunks/{6b66fc32451433129a88.js → 8508f238d99021e87f71.js} +1 -1
- package/assets/esri/core/workers/chunks/{bc75ab48f4c7609ef09d.js → 85d3475667c503ec4fc6.js} +1 -1
- package/assets/esri/core/workers/chunks/{9d6491f996eeb0c646ed.js → 85d8c7cc7f8decbe975d.js} +1 -1
- package/assets/esri/core/workers/chunks/9b9916864b6575c42c8a.js +1 -0
- package/assets/esri/core/workers/chunks/{75d5ea0da181f9e7425f.js → a8ca5d8740cc7e39197b.js} +6 -6
- package/assets/esri/core/workers/chunks/{8d75f6f27c1c17c33992.js → b7bb7072dbee978f3ca3.js} +1 -1
- package/assets/esri/core/workers/chunks/bf7e019437a3b6036300.js +2 -0
- package/assets/esri/core/workers/chunks/{99c161fecae710b53b40.js → d304343a781acfa3ff96.js} +1 -1
- package/assets/esri/core/workers/chunks/dbb9bb28696ff9536678.js +2 -0
- package/assets/esri/core/workers/chunks/{34ea3ed78041437a8fc8.js → f81c6f6ccc201f584970.js} +1 -1
- package/assets/esri/themes/base/_core.scss +2 -0
- package/assets/esri/themes/base/widgets/_PluginSettingsControls.scss +29 -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/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer.json +1 -1
- package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_en.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_ar.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_bg.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_bs.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_ca.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_cs.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_da.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_de.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_el.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_en.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_es.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_et.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_fi.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_fr.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_he.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_hr.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_hu.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_id.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_it.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_ja.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_ko.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_lt.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_lv.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_nl.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_no.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_pl.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_pt-BR.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_pt-PT.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_ro.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_ru.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_sk.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_sl.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_sr.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_sv.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_th.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_tr.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_uk.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_vi.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_zh-CN.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_zh-HK.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_zh-TW.json +1 -1
- package/config.js +1 -1
- package/core/types.d.ts +28 -0
- package/form/elements/inputs/MultipleChoiceInput.d.ts +2 -2
- package/form/elements/inputs/MultipleChoiceInput.js +1 -1
- package/geometry/operators/types.d.ts +2 -2
- package/interfaces.d.ts +4 -7
- package/kernel.js +1 -1
- package/layers/ImageryLayer.d.ts +7 -1
- package/layers/ImageryLayer.js +1 -1
- package/layers/ImageryTileLayer.d.ts +7 -1
- package/layers/ImageryTileLayer.js +1 -1
- package/layers/WCSLayer.d.ts +7 -1
- package/layers/WCSLayer.js +1 -1
- package/layers/save/imageryUtils.js +1 -1
- package/layers/video/VideoController.js +1 -1
- package/networks/UnitIdentifierManager.d.ts +15 -15
- package/networks/UnitIdentifierManager.js +1 -1
- package/networks/support/jsonTypes.d.ts +125 -13
- package/package.json +3 -3
- package/popup/Features.d.ts +0 -1
- package/popup/Features.js +1 -1
- package/rest/networks/unitIdentifiers/reserve.js +2 -0
- package/rest/networks/unitIdentifiers/support/ReserveParameters.js +2 -0
- package/rest/networks/unitIdentifiers/support/ResizeParameters.js +1 -1
- package/rest/networks/unitIdentifiers/support/UnitQueryResult.js +1 -1
- package/support/revision.js +1 -1
- package/views/2d/analysis/ElevationProfile/ElevationProfileVisualization2D.js +1 -1
- package/views/2d/analysis/ElevationProfileAnalysisView2D.d.ts +5 -1
- package/views/2d/analysis/ElevationProfileAnalysisView2D.js +1 -1
- package/views/2d/engine/webgl/AFeatureTile.js +1 -1
- package/views/2d/engine/webgl/effects/HittestEffect.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/featureTechniqueUtils.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/markers/MarkerShader.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/shaders/AFeatureShader.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/shaders/LineShader.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/shaders/ShaderHittest.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/shaders/hittestUtils.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/text/TextShader.js +1 -1
- package/views/2d/engine/webgl/shaders/sources/shaderRepository.js +1 -1
- package/views/2d/layers/BaseLayerView2D.d.ts +3 -3
- package/views/2d/layers/BaseLayerViewGL2D.d.ts +3 -3
- package/views/2d/layers/FeatureLikeLayerView2D.js +1 -1
- package/views/2d/layers/TileLayerView2D.js +1 -1
- package/views/2d/layers/VectorTileLayerView2D.js +1 -1
- package/views/2d/layers/features/FeatureContainer.js +1 -1
- package/views/2d/support/clippingUtils.js +1 -1
- package/views/2d/support/hitTestUtils.js +1 -1
- package/views/3d/analysis/ElevationProfile/ElevationProfileVisualization3D.js +1 -1
- package/views/3d/analysis/ElevationProfileAnalysisView3D.d.ts +5 -1
- package/views/3d/analysis/ElevationProfileAnalysisView3D.js +1 -1
- package/views/3d/layers/IntegratedMesh3DTilesLayerView3D.js +1 -1
- package/views/3d/layers/IntegratedMeshNormals.js +1 -1
- package/views/3d/terrain/ElevationData.js +1 -1
- package/views/3d/terrain/PatchGeometryFactory.js +1 -1
- package/views/3d/webgl-engine/collections/Component/Renderable.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/shading/ReadBaseColorTexture.glsl.js +1 -5
- package/views/3d/webgl-engine/core/shaderLibrary/util/DiscardOrAdjustAlpha.glsl.js +1 -5
- package/views/3d/webgl-engine/core/shaderLibrary/util/MixExternalColor.glsl.js +16 -21
- package/views/3d/webgl-engine/effects/highlight/Highlight.js +1 -1
- package/views/3d/webgl-engine/effects/highlight/ShadowHighlight.js +1 -1
- package/views/3d/webgl-engine/effects/magnifier/Magnifier.js +1 -1
- package/views/3d/webgl-engine/lib/ShadowCastRenderer.js +1 -1
- package/views/3d/webgl-engine/shaders/BlackLevelLightSoftCompression.glsl.js +5 -1
- package/views/3d/webgl-engine/shaders/OutputColorHighlightOLID.glsl.js +2 -2
- package/views/VideoView.js +1 -1
- package/views/View2D.js +1 -1
- package/views/analysis/ElevationProfile/ElevationProfileChart.js +1 -1
- package/views/analysis/ElevationProfile/ElevationProfileController.js +1 -1
- package/views/analysis/ElevationProfile/ElevationProfileIndicatorPointVisualization.js +1 -1
- package/views/analysis/ElevationProfile/ElevationProfileResult.d.ts +6 -4
- package/views/draw/DrawTool.js +1 -1
- package/views/draw/plugins/BezierSegmentPlugin.js +1 -1
- package/views/draw/plugins/FreehandSegmentPlugin.js +1 -1
- package/views/draw/support/PluginContext.js +1 -1
- package/views/draw/support/types.d.ts +21 -0
- package/views/draw/support/types.js +1 -1
- package/views/types.d.ts +2 -2
- package/widgets/BatchAttributeForm/inputs/FieldInput.js +1 -1
- package/widgets/BatchAttributeForm/templates/support/hashElementTemplate.js +1 -1
- package/widgets/Daylight/DaylightViewModel.js +1 -1
- package/widgets/Daylight/support/SliderWithDropdown.js +1 -1
- package/widgets/Editor/components/Settings.js +1 -1
- package/widgets/ElevationProfile/ElevationProfileController.js +1 -1
- package/widgets/ElevationProfile/ElevationProfileViewModel.js +1 -1
- package/widgets/ElevationProfile/support/ElevationProfileView.js +1 -1
- package/widgets/ElevationProfile/support/ElevationProfileView2D.js +1 -1
- package/widgets/ElevationProfile/support/ElevationProfileView3D.js +1 -1
- package/widgets/ElevationProfile/support/InputRepresentation2D.js +1 -1
- package/widgets/ElevationProfile/support/InputRepresentation3D.js +1 -1
- package/widgets/ElevationProfile/support/ProfileLine2D.js +1 -1
- package/widgets/ElevationProfile/support/ProfileLines3D.js +1 -1
- package/widgets/FeatureForm/FieldInput.js +1 -1
- package/widgets/HistogramRangeSlider/HistogramRangeSliderViewModel.js +1 -1
- package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
- package/widgets/OrientedImageryViewer/OrientedImageryViewerVisibleElements.d.ts +5 -5
- package/widgets/OrientedImageryViewer/OrientedImageryViewerVisibleElements.js +1 -1
- package/widgets/OrientedImageryViewer/adapters/view/SceneViewAdapter.js +1 -1
- package/widgets/OrientedImageryViewer/constants.js +1 -1
- package/widgets/OrientedImageryViewer/imageMeasurementUtils.js +1 -1
- package/widgets/OrientedImageryViewer/services/SuperimposeService.js +2 -0
- package/widgets/OrientedImageryViewer/support/superimposeUtils.js +2 -0
- package/widgets/OrientedImageryViewer/types.d.ts +10 -0
- package/widgets/OrientedImageryViewer.d.ts +17 -2
- package/widgets/OrientedImageryViewer.js +1 -1
- package/widgets/ScaleRangeSlider/ScaleRangeSliderViewModel.js +1 -1
- package/widgets/Sketch/SketchViewModel.js +1 -1
- package/widgets/Sketch/support/PluginManager.js +1 -1
- package/widgets/Sketch/support/SettingsManager.js +2 -0
- package/widgets/Sketch.js +1 -1
- package/widgets/Slider/SliderViewModel.d.ts +2 -1
- package/widgets/Slider/SliderViewModel.js +1 -1
- package/widgets/Slider.js +1 -1
- package/widgets/smartMapping/ColorSlider/ColorSliderViewModel.js +1 -1
- package/widgets/smartMapping/OpacitySlider/OpacitySliderViewModel.js +1 -1
- package/widgets/smartMapping/SizeSlider/SizeSliderViewModel.js +1 -1
- package/widgets/smartMapping/SmartMappingSliderViewModel.js +1 -1
- package/widgets/support/PluginSettingsControls.js +2 -0
- package/widgets/support/SnappingControls.js +1 -1
- package/widgets/support/forms/formUtils.js +1 -1
- package/analysis/ElevationProfile/elevationProfileLineTypes.js +0 -2
- package/assets/esri/core/workers/chunks/003476e950bd27a2f884.js +0 -596
- package/assets/esri/core/workers/chunks/07aca5ecad659d55e795.js +0 -2
- package/assets/esri/core/workers/chunks/7540f7df86620f067b5a.js +0 -1
- package/assets/esri/core/workers/chunks/76e34f81bb4a7b0e694c.js +0 -1
- package/assets/esri/core/workers/chunks/bfe575da727ce7c8d331.js +0 -2
- package/assets/esri/core/workers/chunks/cb45e5d4a4ef82cda583.js +0 -1
- package/assets/esri/core/workers/chunks/ea59b81299acaf0d85ee.js +0 -1
- package/assets/esri/core/workers/chunks/ef0eae13408cbf83a64f.js +0 -1
- package/rest/networks/unitIdentifiers/insertGap.js +0 -2
- package/rest/networks/unitIdentifiers/support/InsertGapParameters.js +0 -2
- /package/assets/esri/core/workers/chunks/{07aca5ecad659d55e795.js.LICENSE.txt → bf7e019437a3b6036300.js.LICENSE.txt} +0 -0
- /package/assets/esri/core/workers/chunks/{bfe575da727ce7c8d331.js.LICENSE.txt → dbb9bb28696ff9536678.js.LICENSE.txt} +0 -0
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
-
import{isColor as o,isOITColor as l,isOITFrontFace as r}from"../core/shaderLibrary/ShaderOutput.js";import{Emissions as
|
|
2
|
+
import{isColor as o,isOITColor as l,isOITFrontFace as r}from"../core/shaderLibrary/ShaderOutput.js";import{Emissions as a}from"../core/shaderLibrary/output/Emissions.glsl.js";import{OutputHighlight as i}from"../core/shaderLibrary/output/OutputHighlight.glsl.js";import{ColorConversion as s}from"../core/shaderLibrary/util/ColorConversion.glsl.js";import{If as e,glsl as t}from"../core/shaderModules/glsl.js";import{alphaCutoff as n}from"./alphaCutoff.glsl.js";import{ditherNoise as f}from"./ditherNoise.glsl.js";import{oitResolution as u}from"./oitResolution.glsl.js";function d(d,p){d.include(i,p),d.include(a,p);const{fragment:g,outputs:m}=d;g.include(s);const{output:c,hasEmission:C,discardInvisibleFragments:h,oitPremultipliedAlpha:v,snowCover:b,useFloatBlend:A}=p,$=11===c,j=l(c),y=r(c),E=o(c)&&!j;let O=0;(E||j)&&m.add("fragColor","vec4",O++),C&&m.add("fragEmission","vec4",O++),j&&m.add("fragAlpha","float",O++),g.include(n),g.include(u,p),g.include(f,p),g.code.add(t`
|
|
3
3
|
void outputColorHighlightOLID(vec4 finalColor, vec3 emissiveSymbolColor ${e(b,", float snow")}) {
|
|
4
4
|
${e($,"finalColor.a = 1.0;")}
|
|
5
5
|
${e(h,"if (finalColor.a < alphaCutoff) { discard; }")}
|
|
6
6
|
${e(j||C,"float noise = ditherNoise(finalColor);")}
|
|
7
7
|
|
|
8
|
-
${e(j,`fragColor = ${e(v,"finalColor","premultiplyAlpha(finalColor)")};\n fragColor = vec4(fragColor.rgb * floatBlendOutputScale + noise, fragColor.a);\n
|
|
8
|
+
${e(j,`fragColor = ${e(v,"finalColor","premultiplyAlpha(finalColor)")};\n fragColor = vec4(fragColor.rgb * floatBlendOutputScale + noise, fragColor.a);\n float scaledAlpha = finalColor.a * floatBlendOutputScale;\n fragAlpha = scaledAlpha + noise;\n ${e(!A,"fragAlpha = fragAlpha < alphaCutoff ? scaledAlpha : fragAlpha;")}`)}
|
|
9
9
|
${e(y&&v&&h,"finalColor.rgb /= finalColor.a;")}
|
|
10
10
|
${e(E,"fragColor = finalColor;")}
|
|
11
11
|
${e(C,`fragEmission = ${e(b,"mix(finalColor.a * getEmissions(emissiveSymbolColor), vec4(0.0), snow);","finalColor.a * getEmissions(emissiveSymbolColor);")}\n fragEmission = vec4(fragEmission.rgb * floatBlendOutputScale + noise, fragEmission.a);`)}
|
package/views/VideoView.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
-
import{__decorate as e}from"tslib";import t from"../Color.js";import i from"../Viewpoint.js";import s from"../core/Accessor.js";import{EventedMixin as r}from"../core/Evented.js";import{destroyMaybe as o}from"../core/maybe.js";import{EsriPromiseMixin as a}from"../core/Promise.js";import{watch as n,syncAndInitial as l,whenOnce as p,when as m}from"../core/reactiveUtils.js";import{property as h,cast as d,subclass as c}from"../core/accessorSupport/decorators.js";import{ensureClass as g}from"../core/accessorSupport/ensureType.js";import{create as f,fromValues as y}from"../core/libs/gl-matrix-2/factories/vec2f64.js";import u from"../geometry/Extent.js";import j from"../geometry/Point.js";import w from"../geometry/SpatialReference.js";import{load as b,execute as v}from"../geometry/operators/projectOperator.js";import _ from"../layers/support/ExtentAndRotationGeoreference.js";import{MediaElementView as M}from"../layers/support/MediaElementView.js";import S from"../layers/support/TileInfo.js";import C from"../layers/support/VideoElement.js";import{DOMContainer as V}from"./DOMContainer.js";import{Viewport2DBaseMixin as x}from"./Viewport2DBaseMixin.js";import{Viewport2DMixin as E}from"./Viewport2DMixin.js";import P from"./2d/AnimationManager.js";import G from"./2d/MapViewConstraints.js";import"../core/RandomLCG.js";import"../core/Logger.js";import"../core/has.js";import"../core/scheduling.js";import"../core/mathUtils.js";import"../config.js";import"../symbols/cim/defaultCIMValues.js";import"../core/floatRGBA.js";import"../geometry/Geometry.js";import"../geometry/Multipoint.js";import"../geometry/Polygon.js";import"../geometry/Polyline.js";import"../symbols/Font.js";import"../geometry/support/spatialReferenceUtils.js";import"../symbols/cim/effects/EffectAddControlPoints.js";import"../symbols/cim/effects/EffectArrow.js";import"../symbols/cim/effects/EffectBuffer.js";import"../symbols/cim/effects/EffectControlMeasureLine.js";import"../symbols/cim/effects/EffectCut.js";import"../symbols/cim/effects/EffectDashes.js";import"../symbols/cim/effects/EffectDonut.js";import"../symbols/cim/effects/EffectEnclosingPolygon.js";import"../symbols/cim/effects/EffectJog.js";import"../symbols/cim/effects/EffectMove.js";import"../symbols/cim/effects/EffectOffset.js";import"../symbols/cim/effects/EffectRadial.js";import"../symbols/cim/effects/EffectReverse.js";import"../symbols/cim/effects/EffectRotate.js";import"../symbols/cim/effects/EffectScale.js";import"../symbols/cim/effects/EffectSuppress.js";import"../symbols/cim/effects/EffectTaperedPolygon.js";import"../symbols/cim/effects/EffectWave.js";import"../symbols/cim/placements/PlacementAlongLineSameSize.js";import"../symbols/cim/placements/PlacementAtExtremities.js";import"../symbols/cim/placements/PlacementAtMeasuredUnits.js";import"../symbols/cim/placements/PlacementAtRatioPositions.js";import"../symbols/cim/placements/PlacementInsidePolygon.js";import"../symbols/cim/placements/PlacementOnLine.js";import"../symbols/cim/placements/PlacementOnVertices.js";import"../symbols/cim/placements/PlacementPolygonCenter.js";import"../symbols/dimensions/effects/LinearDimensionArrowEffect.js";import"../symbols/dimensions/effects/LinearDimensionExtensionLineEffect.js";import"../symbols/dimensions/effects/LinearDimensionLeaderLineEffect.js";import"../symbols/dimensions/effects/LinearDimensionLineEffect.js";import"../symbols/dimensions/effects/LinearDimensionPointEffect.js";import"../symbols/dimensions/effects/LinearDimensionTextEffect.js";import"../symbols/cim/constants.js";import"../core/libs/gl-matrix-2/factories/vec2f32.js";import"../symbols/support/defaults.js";import"../symbols/cim/OverrideHelper.js";import{Container as D}from"./2d/engine/Container.js";import"./2d/engine/webgl/shaders/BitBlitPrograms.js";import"./webgl/enums.js";import"./webgl/Program.js";import"./webgl/Util.js";import"./webgl/VertexAttributeLayouts.js";import"./webgl/BufferObject.js";import"../request.js";import"../core/urlUtils.js";import"./webgl/Texture.js";import"../core/pbf.js";import"./2d/engine/webgl/shaders/StencilPrograms.js";import"./2d/engine/webgl/shaderGraph/techniques/shaders/BlendShader.js";import"./2d/engine/webgl/shaderGraph/techniques/shaders/OpacityShader.js";import"./2d/engine/webgl/shaders/HighlightPrograms.js";import"./webgl/FramebufferObject.js";import"./2d/engine/webgl/shaderGraph/techniques/shaders/BlitShader.js";import"./2d/engine/webgl/shaderGraph/techniques/shaders/BloomShader.js";import"./2d/engine/webgl/shaderGraph/techniques/shaders/BlurShader.js";import"./2d/engine/webgl/shaderGraph/techniques/shaders/ColorizeShader.js";import"./2d/engine/webgl/shaderGraph/techniques/shaders/DropShadowShader.js";import"./2d/engine/webgl/meshing/SimpleMesh.js";import"./webgl/Renderbuffer.js";import"./2d/engine/webgl/PooledUint32Array.js";import"./2d/engine/webgl/Profiler.js";import"./2d/engine/webgl/shaderGraph/techniques/TechniqueRegistry.js";import"./2d/engine/webgl/number.js";import"./2d/engine/webgl/shaderGraph/techniques/animated/attributes.js";import"./2d/engine/webgl/mesh/templates/templateUtils.js";import"./2d/engine/webgl/shaderGraph/techniques/line/LineMeshWriter.js";import"./2d/engine/webgl/shaderGraph/techniques/dotDensity/DotDensityMeshWriter.js";import"./2d/engine/webgl/shaderGraph/techniques/fill/ComplexFillMeshWriter.js";import"./2d/engine/webgl/shaderGraph/techniques/fill/ComplexOutlineFillMeshWriter.js";import"./2d/engine/webgl/shaderGraph/techniques/fill/FillMeshWriter.js";import"./2d/engine/webgl/shaderGraph/techniques/fill/GradientFillMeshWriter.js";import"./2d/engine/webgl/shaderGraph/techniques/fill/OutlineFillMeshWriter.js";import"./2d/engine/webgl/shaderGraph/techniques/fill/PatternFillMeshWriter.js";import"./2d/engine/webgl/shaderGraph/techniques/fill/PatternOutlineFillMeshWriter.js";import"./2d/engine/webgl/shaderGraph/techniques/heatmap/HeatmapMeshWriter.js";import"../geometry/support/aaBoundingBox.js";import"./2d/engine/webgl/shaderGraph/techniques/text/TextMeshWriter.js";import"./2d/engine/webgl/shaderGraph/techniques/line/GradientStrokeMeshWriter.js";import"./2d/engine/webgl/shaderGraph/techniques/line/TexturedLineMeshWriter.js";import"./2d/engine/webgl/shaderGraph/techniques/markers/MarkerMeshWriter.js";import"../core/sql/UnknownTimeZone.js";import"luxon";import"../intl/locale.js";import"../layers/support/fieldUtils.js";import"../time/constants.js";import"./2d/engine/webgl/animations/instructions.js";import"./2d/engine/webgl/shaderGraph/techniques/pieChart/PieChartMeshWriter.js";import"./webgl/checkWebGLError.js";import"./webgl/renderState.js";import"./webgl/testSVGPremultipliedAlpha.js";import{ManagedCanvas as R}from"./2d/engine/ManagedCanvas.js";import"../core/libs/gl-matrix-2/factories/vec4f32.js";import"./2d/engine/transitions/FadeTransition.js";import"./2d/engine/webgl/meshing/definitions.js";import"./2d/engine/webgl/shaderGraph/techniques/shaders/VideoScreenShader.js";import"./2d/LabelManager.js";import"./2d/layers/graphics/GraphicsView2D.js";import"./2d/engine/webgl/shaderGraph/techniques/clip/ClipTechnique.js";import"./2d/engine/webgl/AFeatureTile.js";import"./2d/engine/webgl/DisplayEntity.js";import"./2d/engine/webgl/shaderGraph/techniques/featureTechniqueUtils.js";import"./2d/engine/webgl/cpuMapped/MappedMesh.js";import"./2d/engine/webgl/shaderGraph/techniques/shaders/TileDebugInfoShader.js";import"./2d/engine/webgl/shaderGraph/techniques/shaders/TileStencilShader.js";import"../core/libs/gl-matrix-2/factories/vec3f32.js";import"../geometry/support/normalizeUtils.js";import"./2d/layers/support/util.js";import q from"./2d/navigation/MapViewNavigation.js";import"../core/asyncUtils.js";import"../core/support/UpdatingHandles.js";import"./2d/engine/webgl/shaderGraph/techniques/shaders/MagnifierShader.js";import"../core/units.js";import"../geometry/ellipsoidUtils.js";import"../geometry/spatialReferenceEllipsoidUtils.js";import"../geometry/operators/support/GeographicTransformation.js";import"../geometry/projection/projectors.js";import"./2d/engine/webgl/shaderGraph/techniques/shaders/GridShader.js";import"../geometry/support/geodesicConstants.js";import"../geometry/support/Ellipsoid.js";import{ViewStateManager as z}from"./2d/ViewStateManager.js";import T from"./2d/engine/webgl/Overlay.js";import O from"./2d/engine/webgl/OverlayContainer.js";import L from"./navigation/Navigation.js";import W from"./ui/DefaultUI.js";import A from"./ui/video/DefaultUIVideo.js";const U=new t("#000");let F;async function H(){const[,{ParentStage:e}]=await Promise.all([import("./2d/webglDeps.js"),import("./2d/mapViewDeps.js")]);F=e}const k=.01,B=["feature","geojson","csv","stream","ogc-feature","catalog","wfs","parquet","graphics","group"];let I=class extends(E(x(V(r(a(s)))))){constructor(e){super(e),this._isValid=!1,this._readyCycleForced=!1,this._prevZoomEnabled=!1,this._prevRotationEnabled=!1,this.stage=null,this.childStage=null,this._operationalDataView=null,this.operationalDataVisible=!1,this.map=null,this.navigation=new L,this.ready=!1,this.spatialReference=new w({wkid:0}),this.stateManager=new z({constraints:new G({view:this,minScale:1,maxScale:k})}),this.type="2d",this.ui=new A,this.view2dType="video",this.addHandles([n(()=>this.preconditionsReady,e=>e?this._startup():this._teardown()),n(()=>this.videoSize,([e,t])=>{this._extent&&e&&t&&(this._extent.xmax=e,this._extent.ymax=t)}),n(()=>this.size,e=>{this._operationalDataView&&this._operationalDataView.stateManager.resize(e[0],e[1])}),n(()=>[this.layer?.frameEffect,this._effectsContainer],()=>{this._effectsContainer&&(this._effectsContainer.effect=this.layer?.frameEffect??null)},l)])}initialize(){this._prevZoomEnabled="zoom"===this.navigation.actionMap.mouseWheel&&this.ui.components.includes("zoom"),this._prevRotationEnabled="rotate"===this.navigation.actionMap.dragSecondary&&this.ui.components.includes("compass"),this.addHandles([n(()=>[this.operationalDataVisible,this.childStage],()=>{this.childStage&&(this.childStage.videoScreenRenderer.visible=this.operationalDataVisible),this.operationalDataVisible&&(this.scale=1,this.rotation=0),this.navigation&&(this._prevZoomEnabled&&(this.navigation.actionMap.mouseWheel=this.operationalDataVisible?"none":"zoom",this.navigation.actionMap.dragPrimary=this.operationalDataVisible?"none":"pan",this.ui.components&&(this.ui.components=this.operationalDataVisible?this.ui.components.filter(e=>"zoom"!==e):[...new Set([...this.ui.components,"zoom"])])),this._prevRotationEnabled&&(this.navigation.actionMap.dragSecondary=this.operationalDataVisible?"none":"rotate",this.ui.components&&(this.ui.components=this.operationalDataVisible?this.ui.components.filter(e=>"compass"!==e):[...new Set([...this.ui.components,"compass"])])))},l)]),this.addResolvingPromise(H().then(()=>(this._isValid=!0,p(()=>this.ready))))}destroy(){this._teardown(),this.removeAllHandles(),this._set("preconditionsReady",!1),this.frameTask=o(this.frameTask),this.goToManager.destroy(),this.inputManager.destroy(),this._set("inputManager",null)}get constraintsInfo(){return{lods:null,spatialReference:this.spatialReference}}get layer(){return this._get("layer")}set layer(e){e!==this._get("layer")&&(this.constructed&&!this.destroyed&&(this._forceReadyCycle(),this.addResolvingPromise(p(()=>this.ready))),this._set("layer",e))}get preconditionsReady(){return!(!this._isValid||this._readyCycleForced||0===this.width||0===this.height||0===this.videoSize[0]||0===this.videoSize[1])}get rendering(){return this.stage?.renderRequested??!1}get scale(){return this.stateManager?.scale??0}set scale(e){this.stateManager&&(this.stateManager.scale=e)}get videoSize(){if(!this.layer?.videoWidth||!this.layer?.videoHeight)return[0,0];const[e,t]=this.size,i=(this.layer?.videoWidth||0)/(this.layer?.videoHeight||0),s=t*i,r=e/i;return e/t>=1?i>=1?s<=e?[s,t]:[e,r]:r<=t?[e,r]:[s,t]:i>=1?r<=t?[e,r]:[s,t]:s<=e?[s,t]:[e,r]}async hitTest(e,t){if(!this._operationalDataView||!this._operationalDataView.ready)return{screenPoint:e,results:[]};const i=this._operationalDataView.videoToMap(e);if(!i)return{screenPoint:e,results:[]};const s=this._operationalDataView.state.toScreen(f(),i);return this._operationalDataView.hitTest({x:s[0],y:s[1]},t)}_startup(){if(!this.layer)return;const e=this._getViewpoint();this.stateManager.startup(e,this.size,e.targetGeometry.spatialReference);const t={renderingOptions:this.renderingOptions,backgroundColor:U,groundControlPoints:()=>this._groundControlPoints(),getSize:()=>this.videoSize},i=new F(this.surface,t,new R(this.surface));this.stage=i,this._prepareStage(this.stage),this.childStage=i.childStage,this._prepareChildStage(this.childStage);const s=new P({view:this});this._set("animationManager",s);const r=new q({view:this,animationManager:s});this._set("mapViewNavigation",r),this._updateConstraints(),this.frameTask.start(),this._set("ready",!0)}_teardown(){this.frameTask?.stop(),this.stationaryManager?.clear(),this.stage?.destroy(),this.stage=null,this._videoElementView=null,this._overlayContainer?.removeAllChildren(),this._overlayContainer=null,this.removeHandles("video-view"),this._set("ready",!1),this.stateManager?.ready&&this.stateManager.teardown()}_getViewpoint(){return new i({targetGeometry:new j({x:this.videoSize[0]/2,y:this.videoSize[1]/2,spatialReference:this.spatialReference}),scale:1})}_prepareStage(e){this.addHandles([n(()=>this.stationary,t=>e.stationary=t,l),n(()=>this.state.id,()=>e.state=this.state,l),n(()=>this.renderingOptions,t=>e.renderingOptions=t,l)],"video-view"),this._extent=new u({xmin:0,ymin:0,xmax:this.videoSize[0],ymax:this.videoSize[1],spatialReference:{wkid:0}}),this._videoElementView=new M({element:new C({video:this.layer?.videoElement,georeference:new _({extent:this._extent}),autoplay:!1}),spatialReference:this.spatialReference});const t=new T(this._videoElementView);this._overlayContainer=new O,this._overlayContainer.addChild(t),this._effectsContainer=new D,this._effectsContainer.addChild(this._overlayContainer),this.stage.addChild(this._effectsContainer);const i=document.createElement("div");i.classList.add("esri-video-poster"),this.container?.classList.add("esri-video-view"),this.container?.appendChild(i)}_prepareChildStage(e){this.addHandles([n(()=>this.map,async t=>{if(!t)return;const{default:i}=await import("./video/VideoOperationalDataView.js");this._operationalDataView=new i({stage:e,layerViewFilter:e=>new Set(B).has(e.type),width:this.size[0],height:this.size[1],map:t,groundControlPoints:()=>this._groundControlPoints(),getVideoResolution:()=>y(this.layer?.videoWidth||0,this.layer?.videoHeight||0),getSize:()=>this.size}),p(()=>this._operationalDataView?.ready).then(()=>{e.videoScreenRenderer.visible=this.operationalDataVisible})},l),n(()=>this.layer?.groundControlPoints,async()=>{if(!this.layer?.groundControlPoints||!e.state)return;const t=this.layer.groundControlPoints,i=t?.length;if(!i)return;await b();const s=new Array(i),r=e.state.spatialReference;for(let e=0;e<i;e++){const{lat:i,lon:o}=t[e];s[e]=v(new j(o,i),r)}let o=1/0,a=1/0,n=-1/0,l=-1/0;for(const e of s)o=Math.min(o,e.x),a=Math.min(a,e.y),n=Math.max(n,e.x),l=Math.max(l,e.y);const p=u.fromJSON({xmin:o,ymin:a,xmax:n,ymax:l,spatialReference:r});await(this._operationalDataView?.goTo(p,{animate:!1}).catch(()=>{}))},l)])}_updateConstraints(){this._updateZoomConstraints(),this._updatePanConstraints()}_updateZoomConstraints(){const e=this.videoSize,t=Math.max(e[0]/this.size[0],e[1]/this.size[1]),i=[];for(let r=t;r>k;r/=2)i.push(r);i.push(k);const{lods:s}=S.create({scales:i});this.constraints.set({lods:s,minScale:t})}_updatePanConstraints(){const e=e=>{if(!e.targetGeometry)return e;const[t,i]=this.videoSize,s=t*e.scale/2,r=i*e.scale/2,o=e.targetGeometry.clone();return o.x=Math.max(s,Math.min(t-s,o.x)),o.y=Math.max(r,Math.min(i-r,o.y)),e.targetGeometry=o,e};this.constraints.customConstraints.add({constrain:e,applyPanConstraint:e})}_forceReadyCycle(){this.ready&&(m(()=>this.destroyed||!1===this.preconditionsReady,()=>this._readyCycleForced=!1,{once:!0}),this._readyCycleForced=!0)}_groundControlPoints(){return this.layer?.groundControlPoints}};e([h()],I.prototype,"_overlayContainer",void 0),e([h()],I.prototype,"_isValid",void 0),e([h()],I.prototype,"_readyCycleForced",void 0),e([h()],I.prototype,"_effectsContainer",void 0),e([h()],I.prototype,"constraintsInfo",null),e([h()],I.prototype,"operationalDataVisible",void 0),e([h()],I.prototype,"layer",null),e([h()],I.prototype,"map",void 0),e([h({type:L,nonNullable:!0})],I.prototype,"navigation",void 0),e([h({readOnly:!0})],I.prototype,"preconditionsReady",null),e([h({readOnly:!0})],I.prototype,"ready",void 0),e([h({readOnly:!0})],I.prototype,"rendering",null),e([h()],I.prototype,"scale",null),e([h()],I.prototype,"spatialReference",void 0),e([h()],I.prototype,"stateManager",void 0),e([h()],I.prototype,"type",void 0),e([h(),d(e=>e instanceof W?e:g(A,e))],I.prototype,"ui",void 0),e([h({readOnly:!0})],I.prototype,"videoSize",null),e([h({readOnly:!0})],I.prototype,"view2dType",void 0),I=e([c("esri.views.VideoView")],I);const Z=I;export{Z as default};
|
|
2
|
+
import{__decorate as e}from"tslib";import t from"../Color.js";import i from"../Viewpoint.js";import s from"../core/Accessor.js";import{EventedMixin as r}from"../core/Evented.js";import{destroyMaybe as o}from"../core/maybe.js";import{EsriPromiseMixin as a}from"../core/Promise.js";import{watch as n,syncAndInitial as l,whenOnce as p,when as m}from"../core/reactiveUtils.js";import{property as h,cast as d,subclass as c}from"../core/accessorSupport/decorators.js";import{ensureClass as g}from"../core/accessorSupport/ensureType.js";import{create as f,fromValues as y}from"../core/libs/gl-matrix-2/factories/vec2f64.js";import u from"../geometry/Extent.js";import j from"../geometry/Point.js";import w from"../geometry/SpatialReference.js";import{load as b,execute as v}from"../geometry/operators/projectOperator.js";import _ from"../layers/support/ExtentAndRotationGeoreference.js";import{MediaElementView as M}from"../layers/support/MediaElementView.js";import S from"../layers/support/TileInfo.js";import C from"../layers/support/VideoElement.js";import{DOMContainer as V}from"./DOMContainer.js";import{Viewport2DBaseMixin as x}from"./Viewport2DBaseMixin.js";import{Viewport2DMixin as E}from"./Viewport2DMixin.js";import G from"./2d/AnimationManager.js";import P from"./2d/MapViewConstraints.js";import"../core/RandomLCG.js";import"../core/Logger.js";import"../core/has.js";import"../core/scheduling.js";import"../core/mathUtils.js";import"../config.js";import"../symbols/cim/defaultCIMValues.js";import"../core/floatRGBA.js";import"../geometry/Geometry.js";import"../geometry/Multipoint.js";import"../geometry/Polygon.js";import"../geometry/Polyline.js";import"../symbols/Font.js";import"../geometry/support/spatialReferenceUtils.js";import"../symbols/cim/effects/EffectAddControlPoints.js";import"../symbols/cim/effects/EffectArrow.js";import"../symbols/cim/effects/EffectBuffer.js";import"../symbols/cim/effects/EffectControlMeasureLine.js";import"../symbols/cim/effects/EffectCut.js";import"../symbols/cim/effects/EffectDashes.js";import"../symbols/cim/effects/EffectDonut.js";import"../symbols/cim/effects/EffectEnclosingPolygon.js";import"../symbols/cim/effects/EffectJog.js";import"../symbols/cim/effects/EffectMove.js";import"../symbols/cim/effects/EffectOffset.js";import"../symbols/cim/effects/EffectRadial.js";import"../symbols/cim/effects/EffectReverse.js";import"../symbols/cim/effects/EffectRotate.js";import"../symbols/cim/effects/EffectScale.js";import"../symbols/cim/effects/EffectSuppress.js";import"../symbols/cim/effects/EffectTaperedPolygon.js";import"../symbols/cim/effects/EffectWave.js";import"../symbols/cim/placements/PlacementAlongLineSameSize.js";import"../symbols/cim/placements/PlacementAtExtremities.js";import"../symbols/cim/placements/PlacementAtMeasuredUnits.js";import"../symbols/cim/placements/PlacementAtRatioPositions.js";import"../symbols/cim/placements/PlacementInsidePolygon.js";import"../symbols/cim/placements/PlacementOnLine.js";import"../symbols/cim/placements/PlacementOnVertices.js";import"../symbols/cim/placements/PlacementPolygonCenter.js";import"../symbols/dimensions/effects/LinearDimensionArrowEffect.js";import"../symbols/dimensions/effects/LinearDimensionExtensionLineEffect.js";import"../symbols/dimensions/effects/LinearDimensionLeaderLineEffect.js";import"../symbols/dimensions/effects/LinearDimensionLineEffect.js";import"../symbols/dimensions/effects/LinearDimensionPointEffect.js";import"../symbols/dimensions/effects/LinearDimensionTextEffect.js";import"../symbols/cim/constants.js";import"../core/libs/gl-matrix-2/factories/vec2f32.js";import"../symbols/support/defaults.js";import"../symbols/cim/OverrideHelper.js";import{Container as D}from"./2d/engine/Container.js";import"./2d/engine/webgl/shaders/BitBlitPrograms.js";import"./webgl/enums.js";import"./webgl/Program.js";import"./webgl/Util.js";import"./webgl/VertexAttributeLayouts.js";import"./webgl/BufferObject.js";import"../request.js";import"../core/urlUtils.js";import"./webgl/Texture.js";import"../core/pbf.js";import"./2d/engine/webgl/shaders/StencilPrograms.js";import"./2d/engine/webgl/shaderGraph/techniques/shaders/BlendShader.js";import"./2d/engine/webgl/shaderGraph/techniques/shaders/OpacityShader.js";import"./2d/engine/webgl/shaders/HighlightPrograms.js";import"./webgl/FramebufferObject.js";import"../Graphic.js";import"./2d/engine/webgl/shaderGraph/techniques/shaders/BlitShader.js";import"./2d/engine/webgl/shaderGraph/techniques/shaders/BloomShader.js";import"./2d/engine/webgl/shaderGraph/techniques/shaders/BlurShader.js";import"./2d/engine/webgl/shaderGraph/techniques/shaders/ColorizeShader.js";import"./2d/engine/webgl/shaderGraph/techniques/shaders/DropShadowShader.js";import"./2d/engine/webgl/meshing/SimpleMesh.js";import"./webgl/Renderbuffer.js";import"./2d/engine/webgl/PooledUint32Array.js";import"./2d/engine/webgl/Profiler.js";import"./2d/engine/webgl/shaderGraph/techniques/TechniqueRegistry.js";import"./2d/engine/webgl/number.js";import"./2d/engine/webgl/shaderGraph/techniques/animated/attributes.js";import"./2d/engine/webgl/mesh/templates/templateUtils.js";import"./2d/engine/webgl/shaderGraph/techniques/line/LineMeshWriter.js";import"./2d/engine/webgl/shaderGraph/techniques/dotDensity/DotDensityMeshWriter.js";import"./2d/engine/webgl/shaderGraph/techniques/fill/ComplexFillMeshWriter.js";import"./2d/engine/webgl/shaderGraph/techniques/fill/ComplexOutlineFillMeshWriter.js";import"./2d/engine/webgl/shaderGraph/techniques/fill/FillMeshWriter.js";import"./2d/engine/webgl/shaderGraph/techniques/fill/GradientFillMeshWriter.js";import"./2d/engine/webgl/shaderGraph/techniques/fill/OutlineFillMeshWriter.js";import"./2d/engine/webgl/shaderGraph/techniques/fill/PatternFillMeshWriter.js";import"./2d/engine/webgl/shaderGraph/techniques/fill/PatternOutlineFillMeshWriter.js";import"./2d/engine/webgl/shaderGraph/techniques/heatmap/HeatmapMeshWriter.js";import"../geometry/support/aaBoundingBox.js";import"./2d/engine/webgl/shaderGraph/techniques/text/TextMeshWriter.js";import"./2d/engine/webgl/shaderGraph/techniques/line/GradientStrokeMeshWriter.js";import"./2d/engine/webgl/shaderGraph/techniques/line/TexturedLineMeshWriter.js";import"./2d/engine/webgl/shaderGraph/techniques/markers/MarkerMeshWriter.js";import"../core/sql/UnknownTimeZone.js";import"luxon";import"../intl/locale.js";import"../layers/support/fieldUtils.js";import"../time/constants.js";import"./2d/engine/webgl/animations/instructions.js";import"./2d/engine/webgl/shaderGraph/techniques/pieChart/PieChartMeshWriter.js";import"./webgl/checkWebGLError.js";import"./webgl/renderState.js";import"./webgl/testSVGPremultipliedAlpha.js";import{ManagedCanvas as R}from"./2d/engine/ManagedCanvas.js";import"../core/libs/gl-matrix-2/factories/vec4f32.js";import"./2d/engine/transitions/FadeTransition.js";import"./2d/engine/webgl/meshing/definitions.js";import"./2d/engine/webgl/shaderGraph/techniques/shaders/VideoScreenShader.js";import"./2d/LabelManager.js";import"./2d/layers/graphics/GraphicsView2D.js";import"./2d/engine/webgl/shaderGraph/techniques/clip/ClipTechnique.js";import"./2d/engine/webgl/AFeatureTile.js";import"./2d/engine/webgl/DisplayEntity.js";import"./2d/engine/webgl/shaderGraph/techniques/featureTechniqueUtils.js";import"./2d/engine/webgl/cpuMapped/MappedMesh.js";import"./2d/engine/webgl/shaderGraph/techniques/shaders/TileDebugInfoShader.js";import"./2d/engine/webgl/shaderGraph/techniques/shaders/TileStencilShader.js";import"../core/libs/gl-matrix-2/factories/vec3f32.js";import"../geometry/support/normalizeUtils.js";import"./2d/layers/support/util.js";import q from"./2d/navigation/MapViewNavigation.js";import"../core/asyncUtils.js";import"../core/support/UpdatingHandles.js";import"./2d/engine/webgl/shaderGraph/techniques/shaders/MagnifierShader.js";import"../core/units.js";import"../geometry/ellipsoidUtils.js";import"../geometry/spatialReferenceEllipsoidUtils.js";import"../geometry/operators/support/GeographicTransformation.js";import"../geometry/projection/projectors.js";import"./2d/engine/webgl/shaderGraph/techniques/shaders/GridShader.js";import"../geometry/support/geodesicConstants.js";import"../geometry/support/Ellipsoid.js";import{ViewStateManager as z}from"./2d/ViewStateManager.js";import T from"./2d/engine/webgl/Overlay.js";import O from"./2d/engine/webgl/OverlayContainer.js";import L from"./navigation/Navigation.js";import W from"./ui/DefaultUI.js";import A from"./ui/video/DefaultUIVideo.js";const U=new t("#000");let F;async function H(){const[,{ParentStage:e}]=await Promise.all([import("./2d/webglDeps.js"),import("./2d/mapViewDeps.js")]);F=e}const k=.01,B=["feature","geojson","csv","stream","ogc-feature","catalog","wfs","parquet","graphics","group"];let I=class extends(E(x(V(r(a(s)))))){constructor(e){super(e),this._isValid=!1,this._readyCycleForced=!1,this._prevZoomEnabled=!1,this._prevRotationEnabled=!1,this.stage=null,this.childStage=null,this._operationalDataView=null,this.operationalDataVisible=!1,this.map=null,this.navigation=new L,this.ready=!1,this.spatialReference=new w({wkid:0}),this.stateManager=new z({constraints:new P({view:this,minScale:1,maxScale:k})}),this.type="2d",this.ui=new A,this.view2dType="video",this.addHandles([n(()=>this.preconditionsReady,e=>e?this._startup():this._teardown()),n(()=>this.videoSize,([e,t])=>{this._extent&&e&&t&&(this._extent.xmax=e,this._extent.ymax=t)}),n(()=>this.size,e=>{this._operationalDataView&&this._operationalDataView.stateManager.resize(e[0],e[1])}),n(()=>[this.layer?.frameEffect,this._effectsContainer],()=>{this._effectsContainer&&(this._effectsContainer.effect=this.layer?.frameEffect??null)},l)])}initialize(){this._prevZoomEnabled="zoom"===this.navigation.actionMap.mouseWheel&&this.ui.components.includes("zoom"),this._prevRotationEnabled="rotate"===this.navigation.actionMap.dragSecondary&&this.ui.components.includes("compass"),this.addHandles([n(()=>[this.operationalDataVisible,this.childStage],()=>{this.childStage&&(this.childStage.videoScreenRenderer.visible=this.operationalDataVisible),this.operationalDataVisible&&(this.scale=1,this.rotation=0),this.navigation&&(this._prevZoomEnabled&&(this.navigation.actionMap.mouseWheel=this.operationalDataVisible?"none":"zoom",this.navigation.actionMap.dragPrimary=this.operationalDataVisible?"none":"pan",this.ui.components&&(this.ui.components=this.operationalDataVisible?this.ui.components.filter(e=>"zoom"!==e):[...new Set([...this.ui.components,"zoom"])])),this._prevRotationEnabled&&(this.navigation.actionMap.dragSecondary=this.operationalDataVisible?"none":"rotate",this.ui.components&&(this.ui.components=this.operationalDataVisible?this.ui.components.filter(e=>"compass"!==e):[...new Set([...this.ui.components,"compass"])])))},l)]),this.addResolvingPromise(H().then(()=>(this._isValid=!0,p(()=>this.ready))))}destroy(){this._teardown(),this.removeAllHandles(),this._set("preconditionsReady",!1),this.frameTask=o(this.frameTask),this.goToManager.destroy(),this.inputManager.destroy(),this._set("inputManager",null)}get constraintsInfo(){return{lods:null,spatialReference:this.spatialReference}}get layer(){return this._get("layer")}set layer(e){e!==this._get("layer")&&(this.constructed&&!this.destroyed&&(this._forceReadyCycle(),this.addResolvingPromise(p(()=>this.ready))),this._set("layer",e))}get preconditionsReady(){return!(!this._isValid||this._readyCycleForced||0===this.width||0===this.height||0===this.videoSize[0]||0===this.videoSize[1])}get rendering(){return this.stage?.renderRequested??!1}get scale(){return this.stateManager?.scale??0}set scale(e){this.stateManager&&(this.stateManager.scale=e)}get videoSize(){if(!this.layer?.videoWidth||!this.layer?.videoHeight)return[0,0];const[e,t]=this.size,i=(this.layer?.videoWidth||0)/(this.layer?.videoHeight||0),s=t*i,r=e/i;return e/t>=1?i>=1?s<=e?[s,t]:[e,r]:r<=t?[e,r]:[s,t]:i>=1?r<=t?[e,r]:[s,t]:s<=e?[s,t]:[e,r]}async hitTest(e,t){if(!this._operationalDataView||!this._operationalDataView.ready)return{screenPoint:e,results:[]};const i=this._operationalDataView.videoToMap(e);if(!i)return{screenPoint:e,results:[]};const s=this._operationalDataView.state.toScreen(f(),i);return this._operationalDataView.hitTest({x:s[0],y:s[1]},t)}_startup(){if(!this.layer)return;const e=this._getViewpoint();this.stateManager.startup(e,this.size,e.targetGeometry.spatialReference);const t={renderingOptions:this.renderingOptions,backgroundColor:U,groundControlPoints:()=>this._groundControlPoints(),getSize:()=>this.videoSize},i=new F(this.surface,t,new R(this.surface));this.stage=i,this._prepareStage(this.stage),this.childStage=i.childStage,this._prepareChildStage(this.childStage);const s=new G({view:this});this._set("animationManager",s);const r=new q({view:this,animationManager:s});this._set("mapViewNavigation",r),this._updateConstraints(),this.frameTask.start(),this._set("ready",!0)}_teardown(){this.frameTask?.stop(),this.stationaryManager?.clear(),this.stage?.destroy(),this.stage=null,this._videoElementView=null,this._overlayContainer?.removeAllChildren(),this._overlayContainer=null,this.removeHandles("video-view"),this._set("ready",!1),this.stateManager?.ready&&this.stateManager.teardown()}_getViewpoint(){return new i({targetGeometry:new j({x:this.videoSize[0]/2,y:this.videoSize[1]/2,spatialReference:this.spatialReference}),scale:1})}_prepareStage(e){this.addHandles([n(()=>this.stationary,t=>e.stationary=t,l),n(()=>this.state.id,()=>e.state=this.state,l),n(()=>this.renderingOptions,t=>e.renderingOptions=t,l)],"video-view"),this._extent=new u({xmin:0,ymin:0,xmax:this.videoSize[0],ymax:this.videoSize[1],spatialReference:{wkid:0}}),this._videoElementView=new M({element:new C({video:this.layer?.videoElement,georeference:new _({extent:this._extent}),autoplay:!1}),spatialReference:this.spatialReference});const t=new T(this._videoElementView);this._overlayContainer=new O,this._overlayContainer.addChild(t),this._effectsContainer=new D,this._effectsContainer.addChild(this._overlayContainer),this.stage.addChild(this._effectsContainer);const i=document.createElement("div");i.classList.add("esri-video-poster"),this.container?.classList.add("esri-video-view"),this.container?.appendChild(i)}_prepareChildStage(e){this.addHandles([n(()=>this.map,async t=>{if(!t)return;const{default:i}=await import("./video/VideoOperationalDataView.js");this._operationalDataView=new i({stage:e,layerViewFilter:e=>new Set(B).has(e.type),width:this.size[0],height:this.size[1],map:t,groundControlPoints:()=>this._groundControlPoints(),getVideoResolution:()=>y(this.layer?.videoWidth||0,this.layer?.videoHeight||0),getSize:()=>this.size}),p(()=>this._operationalDataView?.ready).then(()=>{e.videoScreenRenderer.visible=this.operationalDataVisible})},l),n(()=>this.layer?.groundControlPoints,async()=>{if(!this.layer?.groundControlPoints||!e.state)return;const t=this.layer.groundControlPoints,i=t?.length;if(!i)return;await b();const s=new Array(i),r=e.state.spatialReference;for(let e=0;e<i;e++){const{lat:i,lon:o}=t[e];s[e]=v(new j(o,i),r)}let o=1/0,a=1/0,n=-1/0,l=-1/0;for(const e of s)o=Math.min(o,e.x),a=Math.min(a,e.y),n=Math.max(n,e.x),l=Math.max(l,e.y);const p=u.fromJSON({xmin:o,ymin:a,xmax:n,ymax:l,spatialReference:r});await(this._operationalDataView?.goTo(p,{animate:!1}).catch(()=>{}))},l)])}_updateConstraints(){this._updateZoomConstraints(),this._updatePanConstraints()}_updateZoomConstraints(){const e=this.videoSize,t=Math.max(e[0]/this.size[0],e[1]/this.size[1]),i=[];for(let r=t;r>k;r/=2)i.push(r);i.push(k);const{lods:s}=S.create({scales:i});this.constraints.set({lods:s,minScale:t})}_updatePanConstraints(){const e=e=>{if(!e.targetGeometry)return e;const[t,i]=this.videoSize,s=t*e.scale/2,r=i*e.scale/2,o=e.targetGeometry.clone();return o.x=Math.max(s,Math.min(t-s,o.x)),o.y=Math.max(r,Math.min(i-r,o.y)),e.targetGeometry=o,e};this.constraints.customConstraints.add({constrain:e,applyPanConstraint:e})}_forceReadyCycle(){this.ready&&(m(()=>this.destroyed||!1===this.preconditionsReady,()=>this._readyCycleForced=!1,{once:!0}),this._readyCycleForced=!0)}_groundControlPoints(){return this.layer?.groundControlPoints}};e([h()],I.prototype,"_overlayContainer",void 0),e([h()],I.prototype,"_isValid",void 0),e([h()],I.prototype,"_readyCycleForced",void 0),e([h()],I.prototype,"_effectsContainer",void 0),e([h()],I.prototype,"constraintsInfo",null),e([h()],I.prototype,"operationalDataVisible",void 0),e([h()],I.prototype,"layer",null),e([h()],I.prototype,"map",void 0),e([h({type:L,nonNullable:!0})],I.prototype,"navigation",void 0),e([h({readOnly:!0})],I.prototype,"preconditionsReady",null),e([h({readOnly:!0})],I.prototype,"ready",void 0),e([h({readOnly:!0})],I.prototype,"rendering",null),e([h()],I.prototype,"scale",null),e([h()],I.prototype,"spatialReference",void 0),e([h()],I.prototype,"stateManager",void 0),e([h()],I.prototype,"type",void 0),e([h(),d(e=>e instanceof W?e:g(A,e))],I.prototype,"ui",void 0),e([h({readOnly:!0})],I.prototype,"videoSize",null),e([h({readOnly:!0})],I.prototype,"view2dType",void 0),I=e([c("esri.views.VideoView")],I);const Z=I;export{Z as default};
|
package/views/View2D.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
-
import{__decorate as e}from"tslib";import t from"../Viewpoint.js";import i from"../core/Collection.js";import r from"../core/CollectionFlattener.js";import s from"../core/Error.js";import has from"../core/has.js";import a from"../core/Logger.js";import{destroyMaybe as n}from"../core/maybe.js";import{watch as o,syncAndInitial as l}from"../core/reactiveUtils.js";import{property as p,cast as h,subclass as g}from"../core/accessorSupport/decorators.js";import{ensureClass as d}from"../core/accessorSupport/ensureType.js";import{initialize as u}from"../core/workers/workers.js";import c from"../geometry/Point.js";import m from"../geometry/Polygon.js";import{isLoadedOrLoadFor as y}from"../geometry/projectionUtils.js";import w from"../layers/support/TileInfo.js";import{BreakpointsOwner as f}from"./BreakpointsOwner.js";import{DOMContainer as V}from"./DOMContainer.js";import{PopupView as M}from"./PopupView.js";import v from"./View.js";import{Viewport2DBaseMixin as b}from"./Viewport2DBaseMixin.js";import{Viewport2DMixin as _}from"./Viewport2DMixin.js";import R from"./2d/AnimationManager.js";import{layerView2DImporter as j}from"./2d/layerViewModuleImportUtils.js";import S from"./2d/tiling/TileInfoView.js";import"./2d/tiling/TileKey.js";import"./2d/tiling/TileQueue.js";import"./2d/tiling/TileStrategy.js";import{extentToScale as L}from"./2d/viewpointUtils.js";import{importAnalysisViewModule as O}from"./2d/analysis/analysisViewModuleImportUtils.js";import{ManagedCanvas as T}from"./2d/engine/ManagedCanvas.js";import k from"./2d/layers/features/support/TileStore.js";import{createOrReuseHighlightGradient as C}from"./2d/layers/support/util.js";import{clipContainsPoint as x}from"./2d/support/clippingUtils.js";import{hitTest as D}from"./2d/support/hitTestUtils.js";import{takeRawScreenshot as P,takeScreenshot as z}from"./2d/support/screenshotUtils.js";import{Timeline as A}from"./2d/support/Timeline.js";import E from"./navigation/Navigation.js";import I from"./navigation/NavigationActionMap.js";import U from"./support/AnalysisViewManager.js";import G from"./ui/DefaultUI.js";import N from"./ui/2d/DefaultUI2D.js";import{RenderingContextOptions as q}from"./webgl/RenderingContextOptions.js";import{isWebMap as $}from"../webmap/utils.js";import W from"../webmap/background/ColorBackground.js";let F,B,Z,H,J,K,Q;async function X(){const[,{GraphicsView2D:e,GraphicContainer:t,LabelManager:i,MapViewNavigation:r,MagnifierView2D:s,GridView2D:a,Stage:n}]=await Promise.all([import("./2d/webglDeps.js"),import("./2d/mapViewDeps.js")]);B=e,Z=t,H=i,J=r,K=s,Q=a,F=n}let Y=class extends(_(b(f(M(V(v)))))){get timeZone(){return super.timeZone}set timeZone(e){super.timeZone=e}constructor(e){super(e),this._magnifierView=null,this._gridView=null,this.stage=null,this._resolveWhenReady=[],this.rootLayerViews=new r({getCollections:()=>[this.basemapView?.baseLayerViews,this.layerViews,this.basemapView?.referenceLayerViews],getChildrenFunction:()=>null}),this.featuresTilingScheme=null,this.graphicsView=null,this.labelManager=null,this.navigation=new E({actionMap:new I({dragTertiary:"none"})}),this.renderingOptions={samplingMode:"dynamic",edgeLabelsVisible:!0,labelsAnimationTime:125,labelCollisionsEnabled:!0},this.supersampleScreenshotsEnabled=!0,this.analysisViewManager=new U({importAnalysisViewModule:e=>O(e),view:this}),this.floors=new i,this.grid=null,this.map=null,this.timeline=new A,this.type="2d",this.view2dType=null,this.ui=new N,this.test={takeScreenshot:async e=>P(this._getScreenshotView(e),e)},this.padding={top:0,right:0,bottom:0,left:0},u()}destroy(){this.layerViewManager.clear(),this._set("preconditionsReady",!1),this.frameTask=n(this.frameTask),this.goToManager.destroy(),this.rootLayerViews.destroy(),this.inputManager.destroy(),this._set("inputManager",null)}get graphicsTileStore(){return new k(this.featuresTilingScheme)}get constraintsInfo(){const e=this.defaultsFromMap?.tileInfo,t=this.spatialReference;return{lods:e?.spatialReference?.equals(t)?e.lods:null,spatialReference:t}}get initialExtentRequired(){if(!this.stateManager)return!1;const{scale:e,constraints:t,center:i,viewpoint:r,extent:s}=this;let a=this.zoom;return!(this.map&&"initialViewProperties"in this.map&&this.map.initialViewProperties?.viewpoint)&&(!s&&(t?.effectiveLODs||(a=-1),(!i||0===e&&-1===a)&&(null==r?.targetGeometry||"extent"!==r.targetGeometry.type&&!r.scale)))}get defaultsFromMapSettings(){return{required:{extent:!1,heightModelInfo:!1,tileInfo:!0},requiresExtentInSpatialReference:this.spatialReferenceLocked}}get scheduler(){return this.frameTask.scheduler}get typeSpecificPreconditionsReady(){const e=this._getDefaultViewpoint();if(!e)return!1;const t=e.targetGeometry,i=this.spatialReference;return y(t.spatialReference,i)}get analyses(){return super.analyses}set analyses(e){super.analyses=e}get background(){return $(this.map)?this.map.initialViewProperties.background:null}set background(e){this._override("background",e)}get center(){return this.stateManager?.center??null}set center(e){this.stateManager.center=e}get constraints(){return super.constraints}set constraints(e){super.constraints=e}get extent(){return super.extent}set extent(e){super.extent=e}get padding(){return this.stateManager?.padding}set padding(e){this.stateManager&&(this.stateManager.padding=e)}get rendering(){return this.stage?.renderRequested??!1}get resizeAlign(){return super.resizeAlign}set resizeAlign(e){super.resizeAlign=e}get resolution(){return this.stateManager.resolution??0}get rotation(){return super.rotation}set rotation(e){super.rotation=e}get scale(){return this.stateManager?.scale??0}set scale(e){this.stateManager&&(this.stateManager.scale=e)}get spatialReference(){return super.spatialReference}set spatialReference(e){super.spatialReference=e}get spatialReferenceLocked(){return this._get("spatialReferenceLocked")}set spatialReferenceLocked(e){this.stage&&a.getLogger(this).warn("spatialReferenceLocked cannot be changed after the view has become ready"),this._set("spatialReferenceLocked",e)}get tileInfo(){return this.featuresTilingScheme?.tileInfo}get updating(){const e=!(!this.magnifier.visible||null===this.magnifier.position||!this._magnifierView?.updatingHandles.updating),t=!this.destroyed&&(!this.layerViewManager||!this.labelManager||!this.graphicsView||!0===this.analysisViewManager.updating||!0===this.layerViewManager.updating||!0===this.labelManager.updating||!0===this.graphicsView.updating||this.allLayerViews.some(e=>!e.destroyed&&!("layerViews"in e)&&!0===e.updating)||e);if(has("esri-2d-log-updating")){const i=this.allLayerViews.reduce((e,t)=>({...e,[`${t.layer.id}(${t.layer.type})`]:!t.destroyed&&!("layerViews"in t)&&t.updating}),{});console.log(`Updating MapView: ${t}\n-> Null LayerViewManager: ${!this.layerViewManager}\n-> Null LabelManager: ${!this.labelManager}\n-> Null GraphicsView: ${!this.graphicsView}\n-> layerViewManager.updating: ${this.layerViewManager?.updating}\n-> labelManager.updating: ${this.labelManager?.updating}\n-> graphicsView.updating: ${this.graphicsView?.updating}\n-> allLayerViews: ${JSON.stringify(i)}\n-> updatingMagnifier: ${e}\n`)}return t}get viewpoint(){return super.viewpoint}set viewpoint(e){super.viewpoint=e}get visibleArea(){const e=this.stateManager.visibleArea;return e?new m({rings:[e.map(e=>[e[0],e[1]])],spatialReference:this.spatialReference}):e}get zoom(){return this.stateManager.zoom??-1}set zoom(e){this.stateManager.zoom=e}get navigating(){return this.mapViewNavigation?.interacting??!1}async hitTest(e,t){return D(this,e,t)}async takeScreenshot(e){return z(this._getScreenshotView(e),e)}toScreen(e,t){return this.stateManager.toScreen(e,t)}async whenAnalysisView(e){if(null==e.parent)throw new s("view:no-analysisview-for-analysis","The analysis does not exist in view.analyses",{analysis:e});return this.analysisViewManager.whenAnalysisView(e)}whenLayerView(e){return super.whenLayerView(e)}graphicChanged(e){if(this.graphicsView){this.graphicsView.graphicUpdateHandler(e)}}whenReady(){return new Promise(e=>{this.ready?e(this):this._resolveWhenReady.push(e)})}zoomIn(){return super.zoomIn()}zoomOut(){return super.zoomOut()}forceDOMReadyCycle(){this.forceReadyCycle()}getDefaultSpatialReference(){return this.map&&"initialViewProperties"in this.map&&this.map.initialViewProperties.spatialReference||this.defaultsFromMap?.spatialReference||null}getDefaultTimeZone(){return $(this.map)?this.map.initialViewProperties.timeZone:null}getDefaultTimeExtent(){return $(this.map)?this.map.initialViewProperties.timeExtent:null}getSurface(){return this.surface}hasLayerViewModule(e){return j.hasLayerViewModule(e)}importLayerView(e){return j.importLayerView(e)}pixelSizeAt(){return this.ready?this.resolution:(a.getLogger(this).error("#pixelSizeAt()","Map view cannot be used before it is ready"),null)}async popupHitTest(e){const t=this.toMap(e),i=await this.hitTest(e),r=this.allLayerViews.toArray().filter(i=>i.clips.every(i=>x(this,i,e,t))).reverse(),s=new globalThis.Map(r.map(e=>[e.layer.uid,e])),a=[];let n=0,o=0;for(;n<i.results.length||o<r.length;){const e=i.results.at(n);if(e&&"graphic"!==e.type){++n;continue}const l=s.get((e?.layer??e?.graphic.layer)?.uid);if((!e||l)&&o<r.length&&r.at(o)!==l){const e=r.at(o);"fetchPopupFeaturesAtLocation"in e&&a.push({mapPoint:t,layerView:e}),++o}else e&&(a.push({graphic:e.graphic,layerView:l}),++n)}return{hits:a,location:t}}requestUpdate(){this.ready&&this.frameTask.requestUpdate()}loadAsyncDependencies(){return X()}_getDefaultViewpoint(){const{constraints:e,initialExtent:i,map:r,padding:s,size:a}=this;if(!e)return null;const n=r&&"initialViewProperties"in r?r.initialViewProperties:void 0,o=this.stateManager.getUserStartupOptions(this.size),l=n?.viewpoint,p=l?.targetGeometry?.extent??i,h=p?.center,g=l?.rotation??0,d=l?.scale||p&&L(p,[a[0]-s.left-s.right,a[1]-s.top-s.bottom]),u=o.center??h,c=o.rotation??g,m=o.scale??d;return u&&m?new t({targetGeometry:u,scale:m,rotation:c}):null}_startup(){this.timeline.begin("MapView Startup");const e=this._getDefaultViewpoint();this.stateManager.startup(e,this.size,this.spatialReference,this.defaultsFromMap.extent?.center),this.graphics.owner=this;const t=new T(this.surface),i=new F(this.surface,{canvas:this.renderCanvas,contextOptions:new q(this.deactivatedWebGLExtensions,this.debugWebGLExtensions),renderingOptions:this.renderingOptions,timeline:this.timeline},t);this.stage=i,this._magnifierView=new K,this._magnifierView.magnifier=this.magnifier,this._gridView=new Q;const r=new H({view:this});this._set("labelManager",r);const s=new R({view:this});this._set("animationManager",s);const a=new J({view:this,animationManager:s});this._set("mapViewNavigation",a),this._setupSpatialReferenceDependentProperties(),this.addHandles([this.rootLayerViews.on("change",()=>this._updateStageChildren()),i.on("webgl-error",e=>this.fatalError=e.error),o(()=>this.stationary,e=>i.stationary=e,l),o(()=>this.background,e=>{i.backgroundColor=e?.color,this._magnifierView.backgroundColor=e?.color},l),o(()=>this.magnifier,e=>this._magnifierView.magnifier=e,l),o(()=>this.grid,e=>this._gridView.grid=e,l),o(()=>this.renderingOptions,e=>i.renderingOptions=e,l),o(()=>this.highlights.items.map(e=>({name:e.name,options:{fillColor:e.color,haloColor:e.haloColor,fillOpacity:e.fillOpacity,haloOpacity:e.haloOpacity,haloWidth:e.haloWidth,haloBlur:e.haloBlur}})),()=>{i.highlightGradient=C(i.highlightGradient,this.highlights.items)},l),o(()=>this.state.id,()=>i.state=this.state,l),o(()=>this.animationsEnabled,e=>this.stage.animationsEnabled=e,l)],"map-view"),this._updateStageChildren();const n=this._resolveWhenReady;this._resolveWhenReady=[],n.forEach(e=>e(this)),this.timeline.end("MapView Startup"),this.frameTask.start(),this._set("ready",!0)}_teardown(){this._destroySpatialReferenceDependentProperties(),this.removeHandles("map-view"),this.mapViewNavigation.destroy(),this._set("mapViewNavigation",null),this.animation=null,this.animationManager.destroy(),this._set("animationManager",null),this.layerViewManager.clear(),this.labelManager.destroy(),this._magnifierView.destroy(),this._gridView.destroy(),this.stage.destroy(),this.stage=null,this._set("graphicsView",null),this._magnifierView=null,this._gridView=null,this._set("labelManager",null),this._set("mapViewNavigation",null),this.graphics.owner=null,this.frameTask.stop(),this.stationaryManager.clear(),this._set("ready",!1),this.stateManager.teardown()}_updateStageChildren(){this.stage.removeAllChildren(),this.rootLayerViews.forEach(e=>{this.stage.addChild(e.container)});const e=this.graphicsView;this.stage.addChild(e.container),this.stage.addChild(this._magnifierView),this.stage.addChild(this._gridView)}_setupSpatialReferenceDependentProperties(){const e=new S(w.create({spatialReference:this.spatialReference,size:512,numLODs:36}));this._set("featuresTilingScheme",e);const t=new B({view:this,graphics:this.graphics,requestUpdateCallback:()=>this.requestUpdate(),container:new Z(e,!0)});this._set("graphicsView",t)}_destroySpatialReferenceDependentProperties(){const e=this.graphicsView;this._set("graphicsView",null),e.destroy(),this._set("featuresTilingScheme",null)}_getScreenshotView(e){const{allLayerViews:t,padding:i,size:r,stage:s}=this;return{allLayerViews:t,backgroundColor:e?.ignoreBackground?null:this.background?.color,padding:i,size:r,stage:s}}_spatialReferenceChanged(e){if(this.ready){this.frameTask.stop();for(const e of this.allLayerViews)e.processDetach();this._destroySpatialReferenceDependentProperties(),this.stateManager.changeSpatialReference(e),this.stage.state=this.state,this._setupSpatialReferenceDependentProperties();for(const e of this.allLayerViews)e.processAttach();this.frameTask.requestFrame(),this.frameTask.start(),this._updateStageChildren()}}static{this.type="2d"}};e([p({constructOnly:!0})],Y.prototype,"deactivatedWebGLExtensions",void 0),e([p({constructOnly:!0})],Y.prototype,"debugWebGLExtensions",void 0),e([p({readOnly:!0})],Y.prototype,"featuresTilingScheme",void 0),e([p({readOnly:!0})],Y.prototype,"graphicsTileStore",null),e([p()],Y.prototype,"graphicsView",void 0),e([p()],Y.prototype,"constraintsInfo",null),e([p()],Y.prototype,"initialExtentRequired",null),e([p()],Y.prototype,"labelManager",void 0),e([p({type:E,nonNullable:!0})],Y.prototype,"navigation",void 0),e([p({constructOnly:!0})],Y.prototype,"renderCanvas",void 0),e([p()],Y.prototype,"renderingOptions",void 0),e([p({constructOnly:!0})],Y.prototype,"supersampleScreenshotsEnabled",void 0),e([p()],Y.prototype,"defaultsFromMapSettings",null),e([p({readOnly:!0})],Y.prototype,"typeSpecificPreconditionsReady",null),e([p()],Y.prototype,"analysisViewManager",void 0),e([p({type:W})],Y.prototype,"background",null),e([p({type:c})],Y.prototype,"center",null),e([p({type:i})],Y.prototype,"floors",void 0),e([p()],Y.prototype,"grid",void 0),e([p()],Y.prototype,"map",void 0),e([p()],Y.prototype,"padding",null),e([p({readOnly:!0})],Y.prototype,"rendering",null),e([p({readOnly:!0})],Y.prototype,"resolution",null),e([p()],Y.prototype,"scale",null),e([p({type:Boolean,value:!1})],Y.prototype,"spatialReferenceLocked",null),e([p({readOnly:!0})],Y.prototype,"tileInfo",null),e([p({type:A,readOnly:!0})],Y.prototype,"timeline",void 0),e([p({readOnly:!0})],Y.prototype,"type",void 0),e([p({readOnly:!0})],Y.prototype,"updating",null),e([p({readOnly:!0})],Y.prototype,"view2dType",void 0),e([p({readOnly:!0})],Y.prototype,"visibleArea",null),e([p()],Y.prototype,"zoom",null),e([p({readOnly:!0})],Y.prototype,"navigating",null),e([p(),h(e=>e instanceof G?e:d(N,e))],Y.prototype,"ui",void 0),Y=e([g("esri.views.View2D")],Y);const ee=Y;export{ee as default};
|
|
2
|
+
import{__decorate as e}from"tslib";import t from"../Viewpoint.js";import i from"../core/Collection.js";import r from"../core/CollectionFlattener.js";import s from"../core/Error.js";import has from"../core/has.js";import a from"../core/Logger.js";import{destroyMaybe as n}from"../core/maybe.js";import{watch as o,syncAndInitial as l}from"../core/reactiveUtils.js";import{property as p,cast as h,subclass as g}from"../core/accessorSupport/decorators.js";import{ensureClass as d}from"../core/accessorSupport/ensureType.js";import{initialize as u}from"../core/workers/workers.js";import c from"../geometry/Point.js";import m from"../geometry/Polygon.js";import{isLoadedOrLoadFor as y}from"../geometry/projectionUtils.js";import w from"../layers/support/TileInfo.js";import{BreakpointsOwner as f}from"./BreakpointsOwner.js";import{DOMContainer as V}from"./DOMContainer.js";import{PopupView as M}from"./PopupView.js";import v from"./View.js";import{Viewport2DBaseMixin as b}from"./Viewport2DBaseMixin.js";import{Viewport2DMixin as _}from"./Viewport2DMixin.js";import R from"./2d/AnimationManager.js";import{layerView2DImporter as j}from"./2d/layerViewModuleImportUtils.js";import S from"./2d/tiling/TileInfoView.js";import"./2d/tiling/TileKey.js";import"./2d/tiling/TileQueue.js";import"./2d/tiling/TileStrategy.js";import{extentToScale as L}from"./2d/viewpointUtils.js";import{importAnalysisViewModule as O}from"./2d/analysis/analysisViewModuleImportUtils.js";import{ManagedCanvas as T}from"./2d/engine/ManagedCanvas.js";import k from"./2d/layers/features/support/TileStore.js";import{createOrReuseHighlightGradient as C}from"./2d/layers/support/util.js";import{clipContainsPoint as x}from"./2d/support/clippingUtils.js";import{hitTest as D}from"./2d/support/hitTestUtils.js";import{takeRawScreenshot as P,takeScreenshot as z}from"./2d/support/screenshotUtils.js";import{Timeline as A}from"./2d/support/Timeline.js";import E from"./navigation/Navigation.js";import U from"./navigation/NavigationActionMap.js";import I from"./support/AnalysisViewManager.js";import G from"./ui/DefaultUI.js";import N from"./ui/2d/DefaultUI2D.js";import{RenderingContextOptions as q}from"./webgl/RenderingContextOptions.js";import{isWebMap as $}from"../webmap/utils.js";import W from"../webmap/background/ColorBackground.js";let F,B,H,Z,J,K,Q;async function X(){const[,{GraphicsView2D:e,GraphicContainer:t,LabelManager:i,MapViewNavigation:r,MagnifierView2D:s,GridView2D:a,Stage:n}]=await Promise.all([import("./2d/webglDeps.js"),import("./2d/mapViewDeps.js")]);B=e,H=t,Z=i,J=r,K=s,Q=a,F=n}let Y=class extends(_(b(f(M(V(v)))))){get timeZone(){return super.timeZone}set timeZone(e){super.timeZone=e}constructor(e){super(e),this._magnifierView=null,this._gridView=null,this.stage=null,this._resolveWhenReady=[],this.rootLayerViews=new r({getCollections:()=>[this.basemapView?.baseLayerViews,this.layerViews,this.basemapView?.referenceLayerViews],getChildrenFunction:()=>null}),this.featuresTilingScheme=null,this.graphicsView=null,this.labelManager=null,this.navigation=new E({actionMap:new U({dragTertiary:"none"})}),this.renderingOptions={samplingMode:"dynamic",edgeLabelsVisible:!0,labelsAnimationTime:125,labelCollisionsEnabled:!0},this.supersampleScreenshotsEnabled=!0,this.analysisViewManager=new I({importAnalysisViewModule:e=>O(e),view:this}),this.floors=new i,this.grid=null,this.map=null,this.timeline=new A,this.type="2d",this.view2dType=null,this.ui=new N,this.test={takeScreenshot:async e=>P(this._getScreenshotView(e),e)},this.padding={top:0,right:0,bottom:0,left:0},u()}destroy(){this.layerViewManager.clear(),this._set("preconditionsReady",!1),this.frameTask=n(this.frameTask),this.goToManager.destroy(),this.rootLayerViews.destroy(),this.inputManager.destroy(),this._set("inputManager",null)}get graphicsTileStore(){return new k(this.featuresTilingScheme)}get constraintsInfo(){const e=this.defaultsFromMap?.tileInfo,t=this.spatialReference;return{lods:e?.spatialReference?.equals(t)?e.lods:null,spatialReference:t}}get initialExtentRequired(){if(!this.stateManager)return!1;const{scale:e,constraints:t,center:i,viewpoint:r,extent:s}=this;let a=this.zoom;return!(this.map&&"initialViewProperties"in this.map&&this.map.initialViewProperties?.viewpoint)&&(!s&&(t?.effectiveLODs||(a=-1),(!i||0===e&&-1===a)&&(null==r?.targetGeometry||"extent"!==r.targetGeometry.type&&!r.scale)))}get defaultsFromMapSettings(){return{required:{extent:!1,heightModelInfo:!1,tileInfo:!0},requiresExtentInSpatialReference:this.spatialReferenceLocked}}get scheduler(){return this.frameTask.scheduler}get typeSpecificPreconditionsReady(){const e=this._getDefaultViewpoint();if(!e)return!1;const t=e.targetGeometry,i=this.spatialReference;return y(t.spatialReference,i)}get analyses(){return super.analyses}set analyses(e){super.analyses=e}get background(){return $(this.map)?this.map.initialViewProperties.background:null}set background(e){this._override("background",e)}get center(){return this.stateManager?.center??null}set center(e){this.stateManager.center=e}get constraints(){return super.constraints}set constraints(e){super.constraints=e}get extent(){return super.extent}set extent(e){super.extent=e}get padding(){return this.stateManager?.padding}set padding(e){this.stateManager&&(this.stateManager.padding=e)}get rendering(){return this.stage?.renderRequested??!1}get resizeAlign(){return super.resizeAlign}set resizeAlign(e){super.resizeAlign=e}get resolution(){return this.stateManager.resolution??0}get rotation(){return super.rotation}set rotation(e){super.rotation=e}get scale(){return this.stateManager?.scale??0}set scale(e){this.stateManager&&(this.stateManager.scale=e)}get spatialReference(){return super.spatialReference}set spatialReference(e){super.spatialReference=e}get spatialReferenceLocked(){return this._get("spatialReferenceLocked")}set spatialReferenceLocked(e){this.stage&&a.getLogger(this).warn("spatialReferenceLocked cannot be changed after the view has become ready"),this._set("spatialReferenceLocked",e)}get tileInfo(){return this.featuresTilingScheme?.tileInfo}get updating(){const e=!(!this.magnifier.visible||null===this.magnifier.position||!this._magnifierView?.updatingHandles.updating),t=!this.destroyed&&(!this.layerViewManager||!this.labelManager||!this.graphicsView||!0===this.analysisViewManager.updating||!0===this.layerViewManager.updating||!0===this.labelManager.updating||!0===this.graphicsView.updating||this.allLayerViews.some(e=>!e.destroyed&&!("layerViews"in e)&&!0===e.updating)||e);if(has("esri-2d-log-updating")){const i=this.allLayerViews.reduce((e,t)=>({...e,[`${t.layer.id}(${t.layer.type})`]:!t.destroyed&&!("layerViews"in t)&&t.updating}),{});console.log(`Updating MapView: ${t}\n-> Null LayerViewManager: ${!this.layerViewManager}\n-> Null LabelManager: ${!this.labelManager}\n-> Null GraphicsView: ${!this.graphicsView}\n-> layerViewManager.updating: ${this.layerViewManager?.updating}\n-> labelManager.updating: ${this.labelManager?.updating}\n-> graphicsView.updating: ${this.graphicsView?.updating}\n-> allLayerViews: ${JSON.stringify(i)}\n-> updatingMagnifier: ${e}\n`)}return t}get viewpoint(){return super.viewpoint}set viewpoint(e){super.viewpoint=e}get visibleArea(){const e=this.stateManager.visibleArea;return e?new m({rings:[e.map(e=>[e[0],e[1]])],spatialReference:this.spatialReference}):e}get zoom(){return this.stateManager.zoom??-1}set zoom(e){this.stateManager.zoom=e}get navigating(){return this.mapViewNavigation?.interacting??!1}async hitTest(e,t){return D(this,e,t)}async takeScreenshot(e){return z(this._getScreenshotView(e),e)}addUpdatingPromise(e){return this.updatingHandles.addPromise(e)}toScreen(e,t){return this.stateManager.toScreen(e,t)}async whenAnalysisView(e){if(null==e.parent)throw new s("view:no-analysisview-for-analysis","The analysis does not exist in view.analyses",{analysis:e});return this.analysisViewManager.whenAnalysisView(e)}whenLayerView(e){return super.whenLayerView(e)}graphicChanged(e){if(this.graphicsView){this.graphicsView.graphicUpdateHandler(e)}}whenReady(){return new Promise(e=>{this.ready?e(this):this._resolveWhenReady.push(e)})}zoomIn(){return super.zoomIn()}zoomOut(){return super.zoomOut()}forceDOMReadyCycle(){this.forceReadyCycle()}getDefaultSpatialReference(){return this.map&&"initialViewProperties"in this.map&&this.map.initialViewProperties.spatialReference||this.defaultsFromMap?.spatialReference||null}getDefaultTimeZone(){return $(this.map)?this.map.initialViewProperties.timeZone:null}getDefaultTimeExtent(){return $(this.map)?this.map.initialViewProperties.timeExtent:null}getSurface(){return this.surface}hasLayerViewModule(e){return j.hasLayerViewModule(e)}importLayerView(e){return j.importLayerView(e)}pixelSizeAt(){return this.ready?this.resolution:(a.getLogger(this).error("#pixelSizeAt()","Map view cannot be used before it is ready"),null)}async popupHitTest(e){const t=this.toMap(e),i=await this.hitTest(e),r=this.allLayerViews.toArray().filter(i=>i.clips.every(i=>x(this,i,e,t))).reverse(),s=new globalThis.Map(r.map(e=>[e.layer.uid,e])),a=[];let n=0,o=0;for(;n<i.results.length||o<r.length;){const e=i.results.at(n);if(e&&"graphic"!==e.type){++n;continue}const l=s.get((e?.layer??e?.graphic.layer)?.uid);if((!e||l)&&o<r.length&&r.at(o)!==l){const e=r.at(o);"fetchPopupFeaturesAtLocation"in e&&a.push({mapPoint:t,layerView:e}),++o}else e&&(a.push({graphic:e.graphic,layerView:l}),++n)}return{hits:a,location:t}}requestUpdate(){this.ready&&this.frameTask.requestUpdate()}loadAsyncDependencies(){return X()}_getDefaultViewpoint(){const{constraints:e,initialExtent:i,map:r,padding:s,size:a}=this;if(!e)return null;const n=r&&"initialViewProperties"in r?r.initialViewProperties:void 0,o=this.stateManager.getUserStartupOptions(this.size),l=n?.viewpoint,p=l?.targetGeometry?.extent??i,h=p?.center,g=l?.rotation??0,d=l?.scale||p&&L(p,[a[0]-s.left-s.right,a[1]-s.top-s.bottom]),u=o.center??h,c=o.rotation??g,m=o.scale??d;return u&&m?new t({targetGeometry:u,scale:m,rotation:c}):null}_startup(){this.timeline.begin("MapView Startup");const e=this._getDefaultViewpoint();this.stateManager.startup(e,this.size,this.spatialReference,this.defaultsFromMap.extent?.center),this.graphics.owner=this;const t=new T(this.surface),i=new F(this.surface,{canvas:this.renderCanvas,contextOptions:new q(this.deactivatedWebGLExtensions,this.debugWebGLExtensions),renderingOptions:this.renderingOptions,timeline:this.timeline},t);this.stage=i,this._magnifierView=new K,this._magnifierView.magnifier=this.magnifier,this._gridView=new Q;const r=new Z({view:this});this._set("labelManager",r);const s=new R({view:this});this._set("animationManager",s);const a=new J({view:this,animationManager:s});this._set("mapViewNavigation",a),this._setupSpatialReferenceDependentProperties(),this.addHandles([this.rootLayerViews.on("change",()=>this._updateStageChildren()),i.on("webgl-error",e=>this.fatalError=e.error),o(()=>this.stationary,e=>i.stationary=e,l),o(()=>this.background,e=>{i.backgroundColor=e?.color,this._magnifierView.backgroundColor=e?.color},l),o(()=>this.magnifier,e=>this._magnifierView.magnifier=e,l),o(()=>this.grid,e=>this._gridView.grid=e,l),o(()=>this.renderingOptions,e=>i.renderingOptions=e,l),o(()=>this.highlights.items.map(e=>({name:e.name,options:{fillColor:e.color,haloColor:e.haloColor,fillOpacity:e.fillOpacity,haloOpacity:e.haloOpacity,haloWidth:e.haloWidth,haloBlur:e.haloBlur}})),()=>{i.highlightGradient=C(i.highlightGradient,this.highlights.items)},l),o(()=>this.state.id,()=>i.state=this.state,l),o(()=>this.animationsEnabled,e=>this.stage.animationsEnabled=e,l)],"map-view"),this._updateStageChildren();const n=this._resolveWhenReady;this._resolveWhenReady=[],n.forEach(e=>e(this)),this.timeline.end("MapView Startup"),this.frameTask.start(),this._set("ready",!0)}_teardown(){this._destroySpatialReferenceDependentProperties(),this.removeHandles("map-view"),this.mapViewNavigation.destroy(),this._set("mapViewNavigation",null),this.animation=null,this.animationManager.destroy(),this._set("animationManager",null),this.layerViewManager.clear(),this.labelManager.destroy(),this._magnifierView.destroy(),this._gridView.destroy(),this.stage.destroy(),this.stage=null,this._set("graphicsView",null),this._magnifierView=null,this._gridView=null,this._set("labelManager",null),this._set("mapViewNavigation",null),this.graphics.owner=null,this.frameTask.stop(),this.stationaryManager.clear(),this._set("ready",!1),this.stateManager.teardown()}_updateStageChildren(){this.stage.removeAllChildren(),this.rootLayerViews.forEach(e=>{this.stage.addChild(e.container)});const e=this.graphicsView;this.stage.addChild(e.container),this.stage.addChild(this._magnifierView),this.stage.addChild(this._gridView)}_setupSpatialReferenceDependentProperties(){const e=new S(w.create({spatialReference:this.spatialReference,size:512,numLODs:36}));this._set("featuresTilingScheme",e);const t=new B({view:this,graphics:this.graphics,requestUpdateCallback:()=>this.requestUpdate(),container:new H(e,!0)});this._set("graphicsView",t)}_destroySpatialReferenceDependentProperties(){const e=this.graphicsView;this._set("graphicsView",null),e.destroy(),this._set("featuresTilingScheme",null)}_getScreenshotView(e){const{allLayerViews:t,padding:i,size:r,stage:s}=this;return{allLayerViews:t,backgroundColor:e?.ignoreBackground?null:this.background?.color,padding:i,size:r,stage:s}}_spatialReferenceChanged(e){if(this.ready){this.frameTask.stop();for(const e of this.allLayerViews)e.processDetach();this._destroySpatialReferenceDependentProperties(),this.stateManager.changeSpatialReference(e),this.stage.state=this.state,this._setupSpatialReferenceDependentProperties();for(const e of this.allLayerViews)e.processAttach();this.frameTask.requestFrame(),this.frameTask.start(),this._updateStageChildren()}}static{this.type="2d"}};e([p({constructOnly:!0})],Y.prototype,"deactivatedWebGLExtensions",void 0),e([p({constructOnly:!0})],Y.prototype,"debugWebGLExtensions",void 0),e([p({readOnly:!0})],Y.prototype,"featuresTilingScheme",void 0),e([p({readOnly:!0})],Y.prototype,"graphicsTileStore",null),e([p()],Y.prototype,"graphicsView",void 0),e([p()],Y.prototype,"constraintsInfo",null),e([p()],Y.prototype,"initialExtentRequired",null),e([p()],Y.prototype,"labelManager",void 0),e([p({type:E,nonNullable:!0})],Y.prototype,"navigation",void 0),e([p({constructOnly:!0})],Y.prototype,"renderCanvas",void 0),e([p()],Y.prototype,"renderingOptions",void 0),e([p({constructOnly:!0})],Y.prototype,"supersampleScreenshotsEnabled",void 0),e([p()],Y.prototype,"defaultsFromMapSettings",null),e([p({readOnly:!0})],Y.prototype,"typeSpecificPreconditionsReady",null),e([p()],Y.prototype,"analysisViewManager",void 0),e([p({type:W})],Y.prototype,"background",null),e([p({type:c})],Y.prototype,"center",null),e([p({type:i})],Y.prototype,"floors",void 0),e([p()],Y.prototype,"grid",void 0),e([p()],Y.prototype,"map",void 0),e([p()],Y.prototype,"padding",null),e([p({readOnly:!0})],Y.prototype,"rendering",null),e([p({readOnly:!0})],Y.prototype,"resolution",null),e([p()],Y.prototype,"scale",null),e([p({type:Boolean,value:!1})],Y.prototype,"spatialReferenceLocked",null),e([p({readOnly:!0})],Y.prototype,"tileInfo",null),e([p({type:A,readOnly:!0})],Y.prototype,"timeline",void 0),e([p({readOnly:!0})],Y.prototype,"type",void 0),e([p({readOnly:!0})],Y.prototype,"updating",null),e([p({readOnly:!0})],Y.prototype,"view2dType",void 0),e([p({readOnly:!0})],Y.prototype,"visibleArea",null),e([p()],Y.prototype,"zoom",null),e([p({readOnly:!0})],Y.prototype,"navigating",null),e([p(),h(e=>e instanceof G?e:d(N,e))],Y.prototype,"ui",void 0),Y=e([g("esri.views.View2D")],Y);const ee=Y;export{ee as default};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/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 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};
|
|
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{effectiveDisplayUnits:i,progress:s,results:o,statistics:n}=t;return{lines:this._lineData,statistics:n,effectiveUnits:i,refined:1===s,uniformScaling:e,dynamicElevationRange:o.some(({profile:t})=>"scene"===t.type)}}get _hasGeometry(){return null!=this.analysisView?.analysis.geometry}get _lineData(){const{analysisView:t}=this;if(!t)return[];const e=[];for(const i of t.results){const t=i.profile;if(!i.available||!i.rawResult?.hasZ||!t.chartOptions.lineVisible)continue;const s="input"!==t.type;e.push({id:t.id,type:t.type,title:t.title,color:t.color,samples:i.samples,fillEnabled:s,strokeOffsetY:s?-1:0,strokeWidth:1.5})}return e}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.1/LICENSE.txt */
|
|
2
|
-
import{__decorate as t}from"tslib";import e from"../../../core/Accessor.js";import{min as o}from"../../../core/arrayUtils.js";import{createTask as i}from"../../../core/asyncUtils.js";import{dedupeResult as
|
|
2
|
+
import{__decorate as t}from"tslib";import e from"../../../core/Accessor.js";import{min as o}from"../../../core/arrayUtils.js";import{createTask as i}from"../../../core/asyncUtils.js";import s from"../../../core/CollectionFlattener.js";import{dedupeResult as r}from"../../../core/dedupeResult.js";import{destroyHandle as a,makeHandle as n}from"../../../core/handleUtils.js";import{equalsShallow as l}from"../../../core/lang.js";import{LRUCache as p}from"../../../core/LRUCache.js";import{mapCollection as u}from"../../../core/mapCollectionUtils.js";import{destroyMaybe as c,abortMaybe as m,equalsMaybe as h}from"../../../core/maybe.js";import{throwIfAborted as _,throwIfAbortError as d}from"../../../core/promiseUtils.js";import{watch as f,syncAndInitial as y,on as v}from"../../../core/reactiveUtils.js";import{throttle as g}from"../../../core/throttle.js";import{adaptiveVerticalLengthUnit as C,adaptiveLengthUnit as P}from"../../../core/units.js";import{property as T,subclass as j}from"../../../core/accessorSupport/decorators.js";import{ElevationQueryTileCache as U}from"../../../layers/support/ElevationQueryTileCache.js";import{absoluteHeightElevationInfo as b}from"../../../support/elevationInfoUtils.js";import{getDefaultUnitForView as w}from"../../../support/getDefaultUnitForView.js";import R from"../../../symbols/support/ElevationInfo.js";import{getConfig as I}from"./constants.js";import S from"./ElevationProfileError.js";import{InvalidGeometryError as E,UnknownError as D}from"./elevationProfileErrors.js";import{createProfileQueue as q,sanitizeProgress as x,generateProfiles as F}from"./elevationProfileGenerationUtils.js";import{mergeStatistics as O,getBoundsInMeters as k}from"./elevationProfileStatisticsUtils.js";let V=class extends e{constructor(t){super(t),this.error=null,this._getStableEffectiveUnits=r(()=>{const t=k(this._activeComputations.map(t=>t.result.rawResult)),e=this.analysis.displayUnits,o=w(this.view);return{distance:P(t.maxDistance,"meters",e.distance??o),elevation:C(t.maxElevation,"meters",e.elevation??o)}},l),this._updateTask=null,this._queue=null,this._currentTileCache=null,this._parametersPerComputation=new Map,this._getStableUpdateParameters=r(()=>({stationary:this.view.stationary??!0,activeComputations:this._activeComputations,generationParameters:this._generationParameters}),l),this._getStableGenerationParameters=r(()=>{const{view:t,analysis:e}=this;return t?.ready&&this._queue?{view:t,geometry:e.geometry,geometryIsValid:e.valid,elevationInfo:this.elevationInfo,queue:this._queue,cache:this._tileCache,options:this._options,slicePlane:"3d"===t.type?t.slice.plane:null}:null},l),this._getStableElevationInfo=r(()=>this.analysis.elevationInfo??M,h),this._getStableOptions=r(()=>{const{densificationMaxSamples:t,defaultDemResolution:e,maxTotalSamples:o}=I();let i=this._minDemResolution??e;return i=parseFloat(i.toFixed(2)),{samplingDistance:i,densificationMaxSamples:Math.round(t/this._activeComputations.length),maxTotalSamples:o}},l),this._updateThrottled=g(t=>this._update(t),I().updateThrottleMillis)}initialize(){this._flatProfilesCollection=new s({getCollections:()=>[this.analysis.profiles],getChildrenFunction:t=>"group"===t.type?t.profiles:null,itemFilterFunction:t=>"group"!==t.type}),this._computationsCollection=u(()=>this._flatProfilesCollection,t=>this.computationFactory.create({controller:this,profile:t,onInvalidate:t=>this._invalidateComputation(t)}),{recycleItems:!0}),this.addHandles([a(this._flatProfilesCollection),this._computationsCollection.on("change",()=>{this._parametersPerComputation.clear(),this._updateThrottled(this._updateParameters)}),f(()=>this._updateParameters,t=>this._updateThrottled(t),y),this._updateThrottled]);const t="3d"===this.view.type?this.view.resourceController:void 0;this._queue=q(t?.scheduler),t?.addUpdatingObject(this)}destroy(){this._abortUpdate(),this._parametersPerComputation.clear(),this._computationsCollection?.destroy(),this._queue=c(this._queue),this._currentTileCache=c(this._currentTileCache)}get effectiveDisplayUnits(){return this._getStableEffectiveUnits()}get progress(){let t=0,e=0;for(const o of this._activeComputations)t++,e+=o.progress;return x(t>0?e/t:0)}get updating(){const{progress:t}=this,e=!!this._queue?.updating,o=this._updateThrottled.hasPendingUpdates(),i=null!=this._updateTask&&!this._updateTask.finished;return e||o||i||t>0&&t<1}get results(){return this._computations.map(t=>t.result)}get statistics(){return O(this._activeComputations.map(t=>t.result.statistics))}get indicatorPoints(){return this._computations.map(t=>t.indicatorPoint)}get flatProfiles(){return this._flatProfilesCollection}onElevationChange(t){const{view:e}=this;return"3d"===e?.type?v(()=>e.elevationProvider,"elevation-change",t,{onListenerAdd:t,onListenerRemove:t}):n()}get _tileCache(){this._currentTileCache=c(this._currentTileCache);const t=this.view;if("3d"===t?.type){const e=t.basemapTerrain?.elevationQueryCache;if(null!=e)return e}return null==this._currentTileCache&&(this._currentTileCache=new U(new p(20971520))),this._currentTileCache}get _computations(){return this._computationsCollection?.toArray()??[]}get _activeComputations(){return this._computations.filter(t=>t.profile.enabled&&t.available)}get _minDemResolution(){const t=this._minDemResolutions;return t.length>0?o(t):null}get _minDemResolutions(){const t=[];for(const{minDemResolution:e}of this._activeComputations)null!=e&&t.push(e);return t}get _updateParameters(){return this._getStableUpdateParameters()}get _generationParameters(){return this._getStableGenerationParameters()}get elevationInfo(){return this._getStableElevationInfo()}get _options(){return this._getStableOptions()}_update({stationary:t,activeComputations:e,generationParameters:o}){this._abortUpdate(),t&&(null!=o?this._updateTask=i(async t=>{this.error=null;const i=e.filter(t=>!this._isComputationValid(t,o));try{if(!o.geometryIsValid)throw new E;const e=F({...o,providers:i},{signal:t});let s=!1;for await(const r of e){_(t),s||(this._clearInvalidResults(o),s=!0);for(let t=0;t<i.length;t++)i[t].setResult(r[t])}for(const t of i)this._parametersPerComputation.set(t,o)}catch(s){d(s),this._abortUpdate(),this.error=s instanceof S?s:s instanceof E?null:new D,i.forEach(t=>t.clearResult())}}):this._clearResults())}_abortUpdate(){this._updateTask=m(this._updateTask)}_isComputationValid(t,e){return this._parametersPerComputation.has(t)&&this._parametersPerComputation.get(t)===e}_invalidateComputation(t){this._parametersPerComputation.delete(t),this._updateThrottled(this._updateParameters)}_clearInvalidResults(t){for(const e of this._computations)this._isComputationValid(e,t)||(e.clearResult(),this._parametersPerComputation.delete(e))}_clearResults(){for(const t of this._computations)t.clearResult(),this._parametersPerComputation.delete(t)}};t([T({constructOnly:!0})],V.prototype,"analysis",void 0),t([T({constructOnly:!0})],V.prototype,"analysisViewData",void 0),t([T({constructOnly:!0})],V.prototype,"computationFactory",void 0),t([T({constructOnly:!0})],V.prototype,"view",void 0),t([T()],V.prototype,"error",void 0),t([T({readOnly:!0})],V.prototype,"effectiveDisplayUnits",null),t([T()],V.prototype,"progress",null),t([T()],V.prototype,"updating",null),t([T()],V.prototype,"results",null),t([T()],V.prototype,"statistics",null),t([T()],V.prototype,"indicatorPoints",null),t([T()],V.prototype,"flatProfiles",null),t([T()],V.prototype,"_updateTask",void 0),t([T()],V.prototype,"_queue",void 0),t([T()],V.prototype,"_tileCache",null),t([T()],V.prototype,"_flatProfilesCollection",void 0),t([T()],V.prototype,"_computationsCollection",void 0),t([T()],V.prototype,"_computations",null),t([T()],V.prototype,"_activeComputations",null),t([T({readOnly:!0})],V.prototype,"_minDemResolution",null),t([T()],V.prototype,"_minDemResolutions",null),t([T()],V.prototype,"_updateParameters",null),t([T()],V.prototype,"_generationParameters",null),t([T()],V.prototype,"elevationInfo",null),t([T()],V.prototype,"_options",null),V=t([j("esri.views.analysis.ElevationProfile.ElevationProfileController")],V);const M=new R({...b});export{V as ElevationProfileController};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
-
import{__decorate as t}from"tslib";import e from"../../../core/Accessor.js";import{watch as o,syncAndInitial as i}from"../../../core/reactiveUtils.js";import{property as r,subclass as s}from"../../../core/accessorSupport/decorators.js";import{projectOrLoad as n}from"../../../geometry/projectionUtils.js";import{getConfig as l}from"./constants.js";let a=class extends e{constructor(t){super(t),this.visible=!1,this._element=p()}initialize(){this.view.surface?.appendChild(this._element),this.addHandles([o(()=>this.visible&&!!this._screenPoint,t=>{this._element.style.display=t?"block":"none"},i),o(()=>({color:this.line.color.toCss(),zIndex:this._zIndex}),({color:t,zIndex:e})=>{Object.assign(this._element.style,{background:t,zIndex:e.toString()})},i),o(()=>this._screenPoint,t=>{t&&(this._element.style.transform=`translate(${t.x}px, ${t.y}px)`)},i)])}destroy(){this._element.remove()}get updating(){return!1}get _result(){return this.analysisViewData.results.find(t=>t.computation.profile===this.line)}get _zIndex(){const{
|
|
2
|
+
import{__decorate as t}from"tslib";import e from"../../../core/Accessor.js";import{watch as o,syncAndInitial as i}from"../../../core/reactiveUtils.js";import{property as r,subclass as s}from"../../../core/accessorSupport/decorators.js";import{projectOrLoad as n}from"../../../geometry/projectionUtils.js";import{getConfig as l}from"./constants.js";let a=class extends e{constructor(t){super(t),this.visible=!1,this._element=p()}initialize(){this.view.surface?.appendChild(this._element),this.addHandles([o(()=>this.visible&&!!this._screenPoint,t=>{this._element.style.display=t?"block":"none"},i),o(()=>({color:this.line.color.toCss(),zIndex:this._zIndex}),({color:t,zIndex:e})=>{Object.assign(this._element.style,{background:t,zIndex:e.toString()})},i),o(()=>this._screenPoint,t=>{t&&(this._element.style.transform=`translate(${t.x}px, ${t.y}px)`)},i)])}destroy(){this._element.remove()}get updating(){return!1}get _result(){return this.analysisViewData.results.find(t=>t.computation.profile===this.line)}get _zIndex(){const{results:t}=this.analysisViewData,e=t.findIndex(t=>t.computation.profile===this.line);return t.length-(-1===e?0:e)}get _screenPoint(){const{view:t}=this;"3d"===t.type?(t.commitProperty("size"),t.commitProperty("camera")):t.commitProperty("center");const e=t?.spatialReference,o=e?n(this._result?.indicatorPoint,e).geometry:null;return o&&t?.ready?t.toScreen(o):null}};function p(){const t=document.createElement("div"),{size:e,borderStyle:o,borderColor:i,borderWidth:r,boxShadow:s}=l().indicatorPointStyle,{style:n}=t;return n.display="block",n.position="absolute",n.top="0",n.left="0",n.contain="strict",n.boxSizing="border-box",n.width=`${e}px`,n.height=`${e}px`,n.marginTop=`-${e/2}px`,n.marginLeft=`-${e/2}px`,n.border=`${o} ${r}px ${i}`,n.borderRadius=`${e}px`,n.boxShadow=s,t}t([r()],a.prototype,"view",void 0),t([r()],a.prototype,"analysisViewData",void 0),t([r()],a.prototype,"line",void 0),t([r()],a.prototype,"visible",void 0),t([r()],a.prototype,"updating",null),t([r()],a.prototype,"_result",null),t([r()],a.prototype,"_zIndex",null),t([r()],a.prototype,"_screenPoint",null),a=t([s("esri.views.analysis.ElevationProfile.ElevationProfileIndicatorPointVisualization")],a);export{a as ElevationProfileIndicatorPointVisualization};
|
|
@@ -5,10 +5,12 @@ import type { ElevationProfileSample, ElevationProfileStatistics } from "./types
|
|
|
5
5
|
export interface ElevationProfileResultProperties {}
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
|
-
* Represents the result for
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
8
|
+
* Represents the result for a computed [profile line](https://developers.arcgis.com/javascript/latest/references/core/analysis/ElevationProfile/ElevationProfileLine/).
|
|
9
|
+
* Result objects are initialized by the analysis view and dynamically updated as the elevation profile is generated.
|
|
10
|
+
*
|
|
11
|
+
* The [profile](https://developers.arcgis.com/javascript/latest/references/core/views/analysis/ElevationProfile/ElevationProfileResult/#profile) property identifies the computed
|
|
12
|
+
* line associated with the result. In some cases the results array may contain more entries than the top-level
|
|
13
|
+
* [ElevationProfileAnalysis.profiles](https://developers.arcgis.com/javascript/latest/references/core/analysis/ElevationProfileAnalysis/#profiles) collection.
|
|
12
14
|
*
|
|
13
15
|
* @since 4.34
|
|
14
16
|
* @see [ElevationProfileAnalysis](https://developers.arcgis.com/javascript/latest/references/core/analysis/ElevationProfileAnalysis/)
|
package/views/draw/DrawTool.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
-
import{__addDisposableResource as e,__disposeResources as t,__decorate as i}from"tslib";import{createTask as n}from"../../core/asyncUtils.js";import{makeHandle as a,disposable as s}from"../../core/handleUtils.js";import r from"../../core/Logger.js";import{getOrCreateMapValue as o}from"../../core/MapUtils.js";import{destroyMaybe as l,abortMaybe as d}from"../../core/maybe.js";import{when as p,initial as u,watch as c,syncAndInitial as h,on as g,sync as m}from"../../core/reactiveUtils.js";import{screenPointEqual as v,createScreenPoint as y}from"../../core/screenUtils.js";import{diff as f}from"../../core/accessorSupport/diffUtils.js";import{property as M}from"../../core/accessorSupport/decorators/property.js";import{subclass as _}from"../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as b}from"../../core/support/UpdatingHandles.js";import w from"../../geometry/Polygon.js";import{i as S,e as C}from"../../chunks/simplifyOperator.js";import{isPolygon as x}from"../../geometry/support/typeUtils.js";import{isCurvedGeometry as P}from"../../geometry/support/curves/curveUtils.js";import{densifyCurvedGeometry as H}from"../../geometry/support/curves/densifyCurvedGeometry.js";import{getEffectiveElevationInfo as L}from"../../support/elevationInfoUtils.js";import{getMaxDeviationInPixels as k,getMinSegmentsPerCurve as I}from"../2d/layers/graphics/densificationConstants.js";import{createSnappingVisualizer as O}from"./support/createSnappingVisualizer.js";import{multipointFromGeometry as G,markHandled as V,getPointerType as T}from"./support/drawToolUtils.js";import{PluginContext as j}from"./support/PluginContext.js";import{viewEventToCommand as E}from"./support/input/drawToolInput.js";import{EditSessionManager as D}from"./support/managers/EditSessionManager.js";import{GlobalStateManager as U}from"./support/managers/GlobalStateManager.js";import{InteractiveHandleManager as A}from"./support/managers/InteractiveHandleManager.js";import{MeasurementManager as F}from"./support/managers/MeasurementManager.js";import{PluginLifecycleManager as R}from"./support/managers/PluginLifecycleManager.js";import{SurfaceManager as Z}from"./support/managers/SurfaceManager.js";import{TooltipManager as B}from"./support/managers/TooltipManager.js";import{ViewEventPriorities as q}from"../input/InputManager.js";import{createCoordinateHelper as z}from"../interactive/coordinateHelper.js";import{InteractiveToolBase as K}from"../interactive/InteractiveToolBase.js";import{KeyBindings as N,mediaKeys as Q,sketchKeys as W,advancedSketchKeys as $,tooltipKeys as J}from"../interactive/keybindings.js";import{isInputModeAvailable as X}from"../interactive/tooltip/tooltipCommonUtils.js";const Y=Symbol();let ee=class extends K{constructor(e){super(e),this._shapeVisualId=Symbol(),this._vertexVisualId=Symbol(),this._pluginContexts=new Map,this._queuedFeedbackEvents=[],this._flushingQueuedFeedbackEvents=!1,this._commandsSuspended=!1,this._snappingVisualizer=null,this._segmentLabels=null,this._segmentLabelsImportTask=null,this._updatingHandles=new b,this._keybindings=this._makeKeyBindings(),this._pendingBeginRequest=null,this.type="draw-2.0",this.automaticManipulatorSelection=!0,this.snappingManager=null,this.sketchOptions=null,this.elevationInfo=null,this.hasZ=!1,this.defaultZ=0,this.lastScreenPosition=null,this.measurementManager=new F,this.globalStateManager=new U({getPluginStack:()=>this.pluginStack}),this.editSessionManager=new D({getContext:()=>this._editSessionManagerContext}),this.lifecycleManager=new R({getContext:this._getContextForPlugin.bind(this),editSessionManager:this.editSessionManager,afterAttach:this._afterAttach.bind(this),afterDetach:this._afterDetach.bind(this),beforeResume:this._beforeResume.bind(this)}),this.surfaceManager=null,this.interactiveHandleManager=null,this.renderer=null,this.enableVertexVisuals=!0}initialize(){const{view:e}=this;this.interactiveHandleManager=new A({view:e,renderer:this.renderer}),this._override("manipulators",this.interactiveHandleManager.manipulators),this.tooltipManager=new B({getDependencies:()=>this._tooltipDependencies,getLastScreenPosition:()=>this.lastScreenPosition}),this.addHandles(p(()=>this.renderer,t=>{t.addOrUpdateVisual(this._shapeVisualId,{role:"outputGeometry"}),t.addOrUpdateVisual(this._vertexVisualId,{role:"vertex"}),this._updatingHandles.addPromise(O(e,t).then(e=>this._snappingVisualizer=e))},u)),this.addHandles([c(()=>[this.view,this.coordinateHelper.spatialReference,this.defaultZ,this.hasZ,this.elevationInfo],([e,t,i,n,a])=>{this.surfaceManager?.destroy(),this.surfaceManager=new Z({spatialReference:t,excludedGraphicsLayer:null,defaultZ:i,hasZ:n,view:e,elevationInfo:a,getContext:()=>({drawAtFixedElevation:this.globalStateManager.drawAtFixedElevation,elevationConstraint:this.tooltipManager?.elevationConstraint,constraintsEnabled:this.tooltipManager?.constraintsEnabled??!1})})},h),p(()=>this.sketchOptions?.tooltips.effectiveEnabled,()=>this.measurementManager.preloadMeasurementUtils(),{once:!0,initial:!0}),c(()=>[this.editGeometryOperations,this.sketchOptions?.labels.enabled,this.globalStateManager.segmentLabelsDisabled],()=>{this._updatingHandles.addPromise(this._setupSegmentLabels())},u),g(()=>this.editSessionManager,"cancelPlugin",({plugin:e})=>{this._suspendPlugin(e)},m),g(()=>this.editSessionManager,"restartPlugin",({restartInfo:e})=>{this._resumePlugin(e)},m),c(()=>this.lifecycleManager.updating,e=>{e||this._emitQueuedFeedbackEvents()},m),g(()=>this.editGeometryOperations,["vertex-add","vertex-update","vertex-remove"],e=>{const t=e.vertices.map(e=>({componentIndex:0,vertexIndex:e.index,coordinates:this.coordinateHelper.vectorToArray(e.pos)})),i=t.map(e=>e.coordinates);switch(e.type){case"vertex-add":this._emitWhenReady(e.type,{...e,added:i,vertices:t});break;case"vertex-update":this._emitWhenReady(e.type,{...e,updated:i,vertices:t});break;case"vertex-remove":this._emitWhenReady(e.type,{...e,removed:i,vertices:t})}})])}destroy(){this.active&&this.onDeactivate(),this.editSessionManager.destroy(),this.lifecycleManager.destroy(),this.measurementManager.destroy(),this.globalStateManager.destroy();for(const e of this._pluginContexts.values())e.destroy();this._pluginContexts.clear(),this.surfaceManager=l(this.surfaceManager),this.interactiveHandleManager=l(this.interactiveHandleManager),this._segmentLabelsImportTask=d(this._segmentLabelsImportTask),this._segmentLabels=l(this._segmentLabels),this.tooltipManager=l(this.tooltipManager)}get _zOfLastUserInput(){const e=this.mostDownstreamPlugin&&this.editSessionManager.getSession(this.mostDownstreamPlugin),t=e?.firstPointAddedBySession?.point;return t?.hasZ?t.z:null}get _tooltipDependencies(){const{defaultZ:e,editGeometryOperations:t,sketchOptions:i,directionOptions:n,elevationInfo:a,view:s}=this;return t&&i&&s?{defaultZ:e,directionOptions:n,elevationInfo:a,editGeometryOperations:t,sketchOptions:i,view:s,getActiveHandle:()=>this.interactiveHandleManager?.focusedHandle,getAllHandles:()=>this.interactiveHandleManager?.allhandles,getHelpMessageKey:()=>this.helpMessageKey,notifyTooltipsChanged:()=>{const{interactiveHandleManager:e,movementCommandContext:t}=this;e&&t&&e.reapplyPositions(t)}}:null}get _editSessionManagerContext(){const{coordinateHelper:e,view:t}=this;if(!t)return null;return{coordinateHelper:e,viewingMode:"3d"===t.type&&"global"===t.viewingMode?1:2}}get _densificationParameters(){const{view:e,coordinateHelper:t}=this,i=t.spatialReference,n=e?.spatialReference,a=e.resolution;if(!(i&&n&&a&&Number.isFinite(a)))return null;const s=n.metersPerUnit/i.metersPerUnit;return{maxDeviation:2**Math.round(Math.log2(a))*k()*s,minSegmentsPerCurve:I()}}get test(){return{densificationParameters:this._densificationParameters,segmentLabels:this._segmentLabels}}get updating(){return this._updatingHandles.updating||this.lifecycleManager.updating||!!this._segmentLabels?.updating}get coordinateHelper(){return z(this.hasZ,!1,this.view.spatialReference)}get editGeometry(){return this.editGeometryOperations?.data}get editGeometryOperations(){return this.editSessionManager.editGeometryOperations}get unprocessedGeometry(){return this.editSessionManager.outputGeometry}get simplifiedGeometryPreview(){const e=this.editSessionManager.outputGeometry;if(e&&x(e))try{const t=this._densificationParameters,i=P(e)&&t?new w({...H(e,t)}):e;if(!S(i))return C(i)}catch(t){return e}return e}get _suppressCoincidentPointOverlaysIn3D(){return"3d"===this.view.type&&"point"===this.unprocessedGeometry?.type&&!!this.interactiveHandleManager?.allhandles?.find(e=>"primary"===e.role)?.outputMapPosition}get _shapeVisualGeometry(){return this._suppressCoincidentPointOverlaysIn3D?null:this.simplifiedGeometryPreview}get _vertexVisualGeometry(){return this._suppressCoincidentPointOverlaysIn3D?null:this.unprocessedGeometry}get canUndo(){return this.editSessionManager.canUndo}get canRedo(){return this.editSessionManager.canRedo}get pluginStack(){return this.lifecycleManager.pluginStack}get mostDownstreamPlugin(){return this.pluginStack.at(-1)}get mostUpstreamPlugin(){return this.pluginStack.at(0)}get positionOfLastUserInput(){const e=this.lastScreenPosition;return e?this.surfaceManager?.screenToMap(e,{firstPointZ:this._zOfLastUserInput})??this.view.toMap(e):this.view.center}get movementCommandContext(){const{editGeometryOperations:e,tooltipManager:t,surfaceManager:i,snappingManager:n,interactiveHandleManager:a,_snappingVisualizer:s,defaultZ:r,hasZ:o,globalStateManager:{drawAtFixedElevation:l},view:d}=this;return{tooltipManager:t,editGeometryOperations:e,surfaceManager:i,interactiveHandleManager:a,snappingManager:n,snappingVisualizer:s,pointerType:"mouse",hasZ:o,defaultZ:r,view:d,drawAtFixedElevation:l}}get tooltip(){return this.tooltipManager?.tooltip}get activeTooltipInfo(){return this.tooltipManager?.tooltipInfo}get helpMessageKey(){return this.pluginStack.items.findLast(e=>e.helpMessageKey)?.helpMessageKey??"noTool"}begin(e){this.active?(this.lifecycleManager.begin(e),this._pendingBeginRequest=null):this._pendingBeginRequest=e}complete(e){const t=this.lifecycleManager;if(e&&t.complete(e),0===t.pluginStack.length){const e=this.unprocessedGeometry,t=!e||"mesh"===e.type||S(e);this.emit("complete",{geometry:e,isSimple:t,aborted:!1,type:"complete",vertices:[]}),this.view?.activeTool===this&&(this.view.activeTool=null)}}cancelFirstUserLeafPlugin(){const e=this.pluginStack.toArray().findLast(e=>!0!==e.configuration?.hidden);e&&this.lifecycleManager.cancel(e)}getVertexSnappingCandidates(){return"secondary"===this.interactiveHandleManager?.capturingHandle?.role?[]:this.snappingManager?.getVertexCandidates()??[]}replaceLeaf(e){const t=this.lifecycleManager;t.updating?r.getLogger(this).info("Ignoring command; arrived while updating:","replaceLeaf"):t.replaceLeaf(e)}finishPart(){const e=this.mostUpstreamPlugin,t=e?.configuration;if(this.editGeometryOperations&&t&&t.kind?.includes("multipart")){const e=this.pluginStack.at(1);e&&this.complete(e)}}undo(){this._handleCommand({action:"undo"})}redo(){this._handleCommand({action:"redo"})}executeCommand(e){return this._handleCommand(e)}suspendCommands(){return this._commandsSuspended=!0,a(()=>{this._commandsSuspended=!1;const e=this.view?.inputManager.latestPointerInfo;if(e){const{x:t,y:i}=e.location;this._handleCommand({action:"manipulator-move-to",x:t,y:i})}})}addPromise(e){return this._updatingHandles.addPromise(e)}getGeometryIfCompleted(){const e=this.lifecycleManager.gatherCompletablePlugins();return this.editSessionManager?.generatePreviewGeometryForPlugins(e)}onActivate(){super.onActivate();const{view:e}=this;this.lastScreenPosition=e?.inputManager.latestPointerInfo?.location,this.renderer?.activate(),this._pendingBeginRequest&&(this.begin(this._pendingBeginRequest),this._pendingBeginRequest=null),this.enableVertexVisuals&&this.addHandles(c(()=>this._vertexVisualGeometry,e=>{this.renderer?.addOrUpdateVisual(this._vertexVisualId,{geometry:e?G(e):null})},u)),this.addHandles([c(()=>this._shapeVisualGeometry,e=>{this.renderer?.addOrUpdateVisual(this._shapeVisualId,{geometry:e})},u),p(()=>this.interactiveHandleManager?.capturingHandle?.screenPosition,e=>this.lastScreenPosition=e,{initial:!0,equals:v}),c(()=>this.interactiveHandleManager?.capturingHandle?.outputMapPosition,(e,t)=>{const i=this.interactiveHandleManager?.capturingHandle?.editSession?.endVertex;e&&t&&i&&this._emitWhenReady("cursor-update",{updated:i.pos,type:"vertex-update",operation:"apply",vertices:[{componentIndex:i.part.index,vertexIndex:i.index,coordinates:i.pos}]})},m),this._keybindings.register(e,q.TOOL),c(()=>e.viewpoint,(e,t)=>{e&&t&&f(e,t)&&this._handleCommand({action:"viewpoint-moved"})})],Y)}onDeactivate(){super.onDeactivate(),this.removeHandles(Y),this.renderer?.deactivate(),this.snappingManager?.doneSnapping(),this.lifecycleManager.cancelAll(),this._pendingBeginRequest=null}onInputEvent(e){const t=E(e);t&&this._handleCommand(t)}forceAddVertex(){this._commitNext()}_emitWhenReady(e,t){if(this.destroyed)return;const i=()=>{this.emit(e,t)};this.lifecycleManager.updating||this._flushingQueuedFeedbackEvents?this._queuedFeedbackEvents.push(i):i()}_emitQueuedFeedbackEvents(){if(!(this.destroyed||this._flushingQueuedFeedbackEvents||this.lifecycleManager.updating||0===this._queuedFeedbackEvents.length)){this._flushingQueuedFeedbackEvents=!0;try{for(;!this.destroyed&&!this.lifecycleManager.updating&&this._queuedFeedbackEvents.length>0;)this._queuedFeedbackEvents.shift()?.()}finally{this._flushingQueuedFeedbackEvents=!1}}}async _handleCommand(e){if(!this._commandsSuspended)if(this.lifecycleManager.updating)r.getLogger(this).info("Ignoring command; arrived while updating:",e.action);else switch(e.action){case"view-drag":return await this._handleViewDragCommand(e);case"vertex-add":return this._guardCommand(e,()=>{V(e),this._commitNext()});case"vertex-add-and-finish-part":return this._handleVertexAddAndFinishPartCommand(e);case"cancel":return this._guardCommand(e,()=>this.cancel());case"complete":return this._guardCommand(e,()=>{this.mostUpstreamPlugin&&(V(e),this.complete(this.mostUpstreamPlugin))});case"finish-part":return this._guardCommand(e,()=>this.finishPart());case"undo":return this._guardCommand(e,()=>this.editSessionManager.undo());case"redo":return this._guardCommand(e,()=>this.editSessionManager.redo());case"next-manipulator":return this._guardCommand(e,()=>this.interactiveHandleManager?.cycleManipulator("forward"));case"previous-manipulator":return this._guardCommand(e,()=>this.interactiveHandleManager?.cycleManipulator("backward"));case"toggle-manipulator-follow":this.interactiveHandleManager?.toggleFollow()&&V(e);break;case"viewpoint-moved":return await this._handleViewpointMovedCommand(e);case"manipulator-move-to":return await this._handleManipulatorMoveToCommand(e);case"manipulator-drag-to":return await this._handleManipulatorDragToCommand(e);case"vertex-add-at-point":return await this._handleVertexAddAtPointCommand(e);case"show-tooltip":return this._guardCommand(e,async()=>{const t=this.tooltipManager?.tooltip;t&&X(t.info)&&(await t.enterInputMode(),V(e))});case"constraint-center":this.globalStateManager.setCentered(e.enabled);break;case"constraint-aspect":this.globalStateManager.setPreserveAspectRatio(e.enabled)}}async _handleViewDragCommand(e){if(!this.editable)return;const t=e.originalEvent,i=this.interactiveHandleManager?.capturingHandle;(!t||!("pointerType"in t)||"touch"!==t.pointerType||"capture-always"!==i?.captureMode&&"capture-when-engaged"!==i?.captureMode)&&"capture-when-engaged"!==this.interactiveHandleManager?.capturingHandle?.captureMode?this._before(e)&&V(e):V(e)}_handleVertexAddAndFinishPartCommand(e){this._before(e)||(V(e),this._commitNext(),this.finishPart())}async _handleViewpointMovedCommand(e){this.editable&&(await this._updatingHandles.addPromise(this.interactiveHandleManager?.capturingHandle?.moveTo(null,{...this.movementCommandContext,pointerType:T(e.originalEvent)})),this.interactiveHandleManager?.updateAllScreenPositions(this.movementCommandContext.surfaceManager))}async _handleManipulatorMoveToCommand(e){if(!this.editable)return;const t=this._updateLastScreenPosition(e);this.interactiveHandleManager?.capturingHandle&&V(e),await this._updatingHandles.addPromise(this.interactiveHandleManager?.capturingHandle?.moveTo(t,{...this.movementCommandContext,pointerType:T(e.originalEvent)}))}async _handleManipulatorDragToCommand(e){if(!this.editable)return;const t=T(e.originalEvent),i=this._updateLastScreenPosition(e),n=this.interactiveHandleManager?.findHandleByManipulator(i,t);"touch"===t&&n&&"start"===e.state&&this.interactiveHandleManager?.releaseHandle();const a=this.interactiveHandleManager?.findHandleDragging(),s=this.interactiveHandleManager?.capturingHandle,r=a??s??n;r&&!n&&V(e),"capture-when-engaged"===r?.captureMode||"capture-always"===r?.captureMode&&"touch"===t?"end"===e.state?await this._updatingHandles.addPromise(r.noteDragEnd(i,{...this.movementCommandContext,pointerType:t}).then(()=>{r&&"touch"===T(e.originalEvent)&&"grabbable-object"!==r.captureMode&&"capture-when-engaged"!==r.defaultCaptureMode&&"primary"===r.role&&(1===this.interactiveHandleManager?.handleCount?this._handleCommand({action:"vertex-add"}):this.interactiveHandleManager?.releaseHandle())})):"start"===e.state?await this._updatingHandles.addPromise(r.noteDragStart(i,{...this.movementCommandContext,pointerType:t}).then(()=>{r&&"touch"===T(e.originalEvent)&&"grabbable-object"!==r.captureMode&&"capture-when-engaged"!==r.defaultCaptureMode&&!r.editSession?.lastPointAddedBySession&&this._handleCommand({action:"vertex-add"})})):await this._updatingHandles.addPromise(r?.moveTo(i,{...this.movementCommandContext,pointerType:T(e.originalEvent)})):"grabbable-object"===r?.captureMode&&(this.interactiveHandleManager?.releaseHandle(s),await this._updatingHandles.addPromise(r.moveTo(i,{...this.movementCommandContext,pointerType:t})))}async _handleVertexAddAtPointCommand(e){const t=this._updateLastScreenPosition(e),i=T(e.originalEvent),n=this.interactiveHandleManager?.capturingHandle??this.interactiveHandleManager?.findHandleByManipulator(t,i);this.editable&&n&&(this._before(e)||(V(e),await this._updatingHandles.addPromise(n.moveTo(t,{...this.movementCommandContext,skipSnapping:!0,pointerType:i}).finally(()=>this._commitNext()))))}_makeKeyBindings(){const e=new N,t=(t,i)=>{e.addToggle(t,e=>this._handleCommand({action:i,originalEvent:e,enabled:"key-down"===e.type}))},i=(t,i)=>{e.add(t,e=>this._handleCommand({action:i,originalEvent:e}))};return t(Q.preserveAspectRatio,"constraint-aspect"),t(W.center,"constraint-center"),i($.toggleFollowManipulator,"toggle-manipulator-follow"),i(W.undo,"undo"),i(W.redo,"redo"),i(W.complete,"complete"),i(W.vertexAdd,"vertex-add"),i({key:J.enterInputMode,continuePropagation:!0,repeats:!0},"show-tooltip"),e}_afterAttach(){}_afterDetach(e){this.interactiveHandleManager?.unregisterCustomConstraint(e),this.interactiveHandleManager?.unregisterHandle(e),this.tooltipManager?.unregisterPluginFields(e),this.globalStateManager.clearPluginOverrides(e);const t=this._pluginContexts.get(e);t&&(t.destroy(),this._pluginContexts.delete(e))}_beforeResume(e,t){this.interactiveHandleManager?.replaceEditSessions(e,t)}_commitNext(){const i={stack:[],error:void 0,hasError:!1};try{const t=this.mostDownstreamPlugin;if(!t)return;this.tooltipManager?.storeConstraintSnapshot();let n=!1;const a=this.editGeometryOperations;e(i,a?s(a.on("vertex-add",()=>n=!0)):null,!1);t.completeStep?t.completeStep():this.complete(t),n&&this.tooltipManager?.unlockOnVertexPlacement()}catch(n){i.error=n,i.hasError=!0}finally{t(i)}}_suspendPlugin(e){this.lifecycleManager.suspend(e),this.measurementManager.suspendPlugin(e)}_resumePlugin(e){this.lifecycleManager.resume(e)}_updateLastScreenPosition(e){const t=y(e.x,e.y);return this.lastScreenPosition=t,t}_getContextForPlugin(e,t){const i=o(this._pluginContexts,e,()=>new j({drawTool:this,plugin:e,session:t}));return i.session=t,i}_before(e){if(!this.hasEventListener(`before-${e.action}`))return!1;const t=new CustomEvent(`before-${e.action}`,{detail:e,cancelable:!0});return this.emit(`before-${e.action}`,t),t.defaultPrevented}_guardCommand(e,t,i){return this._before(e)?i?.():t()}async _setupSegmentLabels(){const e=this.editGeometryOperations,t=this.sketchOptions?.labels,i=!!t?.enabled,n=this.globalStateManager.segmentLabelsDisabled;if(!e||!t||!i)return void(this._segmentLabels=l(this._segmentLabels));if(n)return void(this._segmentLabels&&(this._segmentLabels.visible=!1));if(this._segmentLabels?.context?.editGeometryOperations===e&&this._segmentLabels.context.labelOptions===t)return void(this._segmentLabels.visible=!0);const a=await this._createSegmentLabels(e,t);a&&(this._segmentLabels=l(this._segmentLabels),this._segmentLabels=a)}async _createSegmentLabels(e,t){return(this._segmentLabelsImportTask??=n(async i=>{if("3d"===this.view.type){const n=import("../3d/interactive/SegmentLabels3D.js"),{SegmentLabels3D:a}=await this._updatingHandles.addPromise(n);return this._isSegmentLabelsSetupStale(i,e,t)?null:new a({context:{view:this.view,editGeometryOperations:e,elevationInfo:L(this.hasZ,this.elevationInfo),labelOptions:t},visible:!0})}const n=import("../2d/interactive/SegmentLabels2D.js"),{SegmentLabels2D:a}=await this._updatingHandles.addPromise(n);return this._isSegmentLabelsSetupStale(i,e,t)?null:new a({context:{view:this.view,editGeometryOperations:e,elevationInfo:L(this.hasZ,this.elevationInfo),labelOptions:t},visible:!0})})).promise}_isSegmentLabelsSetupStale(e,t,i){return e.aborted||this.editGeometryOperations!==t||this.sketchOptions?.labels!==i||!i.enabled||this.globalStateManager.segmentLabelsDisabled}};i([M()],ee.prototype,"_commandsSuspended",void 0),i([M()],ee.prototype,"_zOfLastUserInput",null),i([M()],ee.prototype,"_snappingVisualizer",void 0),i([M()],ee.prototype,"_segmentLabels",void 0),i([M()],ee.prototype,"_segmentLabelsImportTask",void 0),i([M()],ee.prototype,"_tooltipDependencies",null),i([M()],ee.prototype,"_editSessionManagerContext",null),i([M()],ee.prototype,"_densificationParameters",null),i([M({constructOnly:!0,nonNullable:!0})],ee.prototype,"view",void 0),i([M()],ee.prototype,"automaticManipulatorSelection",void 0),i([M()],ee.prototype,"updating",null),i([M()],ee.prototype,"coordinateHelper",null),i([M()],ee.prototype,"editGeometry",null),i([M()],ee.prototype,"editGeometryOperations",null),i([M()],ee.prototype,"unprocessedGeometry",null),i([M()],ee.prototype,"simplifiedGeometryPreview",null),i([M()],ee.prototype,"_suppressCoincidentPointOverlaysIn3D",null),i([M()],ee.prototype,"_shapeVisualGeometry",null),i([M()],ee.prototype,"_vertexVisualGeometry",null),i([M()],ee.prototype,"snappingManager",void 0),i([M()],ee.prototype,"sketchOptions",void 0),i([M()],ee.prototype,"elevationInfo",void 0),i([M()],ee.prototype,"hasZ",void 0),i([M()],ee.prototype,"defaultZ",void 0),i([M()],ee.prototype,"directionOptions",void 0),i([M()],ee.prototype,"canUndo",null),i([M()],ee.prototype,"canRedo",null),i([M()],ee.prototype,"pluginStack",null),i([M()],ee.prototype,"mostDownstreamPlugin",null),i([M()],ee.prototype,"mostUpstreamPlugin",null),i([M()],ee.prototype,"lastScreenPosition",void 0),i([M()],ee.prototype,"positionOfLastUserInput",null),i([M()],ee.prototype,"tooltipManager",void 0),i([M()],ee.prototype,"measurementManager",void 0),i([M()],ee.prototype,"globalStateManager",void 0),i([M()],ee.prototype,"editSessionManager",void 0),i([M()],ee.prototype,"lifecycleManager",void 0),i([M()],ee.prototype,"surfaceManager",void 0),i([M()],ee.prototype,"interactiveHandleManager",void 0),i([M()],ee.prototype,"renderer",void 0),i([M()],ee.prototype,"movementCommandContext",null),i([M()],ee.prototype,"tooltip",null),i([M()],ee.prototype,"activeTooltipInfo",null),i([M()],ee.prototype,"helpMessageKey",null),i([M({constructOnly:!0})],ee.prototype,"enableVertexVisuals",void 0),ee=i([_("esri.views.draw.DrawTool")],ee);export{ee as DrawTool};
|
|
2
|
+
import{__addDisposableResource as e,__disposeResources as t,__decorate as i}from"tslib";import{createTask as n}from"../../core/asyncUtils.js";import{makeHandle as a,disposable as s}from"../../core/handleUtils.js";import r from"../../core/Logger.js";import{getOrCreateMapValue as o}from"../../core/MapUtils.js";import{destroyMaybe as l,abortMaybe as d}from"../../core/maybe.js";import{when as p,initial as u,watch as c,syncAndInitial as h,on as g,sync as m}from"../../core/reactiveUtils.js";import{screenPointEqual as v,createScreenPoint as y}from"../../core/screenUtils.js";import{diff as f}from"../../core/accessorSupport/diffUtils.js";import{property as M}from"../../core/accessorSupport/decorators/property.js";import{subclass as _}from"../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as b}from"../../core/support/UpdatingHandles.js";import S from"../../geometry/Polygon.js";import{i as w,e as C}from"../../chunks/simplifyOperator.js";import{isPolygon as P}from"../../geometry/support/typeUtils.js";import{isCurvedGeometry as x}from"../../geometry/support/curves/curveUtils.js";import{densifyCurvedGeometry as H}from"../../geometry/support/curves/densifyCurvedGeometry.js";import{getEffectiveElevationInfo as L}from"../../support/elevationInfoUtils.js";import{getMaxDeviationInPixels as k,getMinSegmentsPerCurve as I}from"../2d/layers/graphics/densificationConstants.js";import{createSnappingVisualizer as O}from"./support/createSnappingVisualizer.js";import{multipointFromGeometry as V,markHandled as G,getPointerType as T}from"./support/drawToolUtils.js";import{PluginContext as j}from"./support/PluginContext.js";import{viewEventToCommand as E}from"./support/input/drawToolInput.js";import{EditSessionManager as D}from"./support/managers/EditSessionManager.js";import{GlobalStateManager as U}from"./support/managers/GlobalStateManager.js";import{InteractiveHandleManager as A}from"./support/managers/InteractiveHandleManager.js";import{MeasurementManager as F}from"./support/managers/MeasurementManager.js";import{PluginLifecycleManager as R}from"./support/managers/PluginLifecycleManager.js";import{SurfaceManager as Z}from"./support/managers/SurfaceManager.js";import{TooltipManager as B}from"./support/managers/TooltipManager.js";import{ViewEventPriorities as q}from"../input/InputManager.js";import{createCoordinateHelper as z}from"../interactive/coordinateHelper.js";import{InteractiveToolBase as K}from"../interactive/InteractiveToolBase.js";import{KeyBindings as N,mediaKeys as Q,sketchKeys as W,advancedSketchKeys as $,tooltipKeys as J}from"../interactive/keybindings.js";import{isInputModeAvailable as X}from"../interactive/tooltip/tooltipCommonUtils.js";const Y=Symbol();let ee=class extends K{constructor(e){super(e),this._shapeVisualId=Symbol(),this._vertexVisualId=Symbol(),this._pluginContexts=new Map,this._queuedFeedbackEvents=[],this._flushingQueuedFeedbackEvents=!1,this._commandsSuspended=!1,this._snappingVisualizer=null,this._segmentLabels=null,this._segmentLabelsImportTask=null,this._updatingHandles=new b,this._keybindings=this._makeKeyBindings(),this._pendingBeginRequest=null,this.type="draw-2.0",this.automaticManipulatorSelection=!0,this.snappingManager=null,this.sketchOptions=null,this.elevationInfo=null,this.hasZ=!1,this.defaultZ=0,this.lastScreenPosition=null,this.measurementManager=new F,this.globalStateManager=new U({getPluginStack:()=>this.pluginStack}),this.editSessionManager=new D({getContext:()=>this._editSessionManagerContext}),this.lifecycleManager=new R({getContext:this._getContextForPlugin.bind(this),editSessionManager:this.editSessionManager,afterAttach:this._afterAttach.bind(this),afterDetach:this._afterDetach.bind(this),beforeResume:this._beforeResume.bind(this)}),this.surfaceManager=null,this.interactiveHandleManager=null,this.renderer=null,this.readPluginSetting=null,this.enableVertexVisuals=!0}initialize(){const{view:e}=this;this.interactiveHandleManager=new A({view:e,renderer:this.renderer}),this._override("manipulators",this.interactiveHandleManager.manipulators),this.tooltipManager=new B({getDependencies:()=>this._tooltipDependencies,getLastScreenPosition:()=>this.lastScreenPosition}),this.addHandles(p(()=>this.renderer,t=>{t.addOrUpdateVisual(this._shapeVisualId,{role:"outputGeometry"}),t.addOrUpdateVisual(this._vertexVisualId,{role:"vertex"}),this._updatingHandles.addPromise(O(e,t).then(e=>this._snappingVisualizer=e))},u)),this.addHandles([c(()=>[this.view,this.coordinateHelper.spatialReference,this.defaultZ,this.hasZ,this.elevationInfo],([e,t,i,n,a])=>{this.surfaceManager?.destroy(),this.surfaceManager=new Z({spatialReference:t,excludedGraphicsLayer:null,defaultZ:i,hasZ:n,view:e,elevationInfo:a,getContext:()=>({drawAtFixedElevation:this.globalStateManager.drawAtFixedElevation,elevationConstraint:this.tooltipManager?.elevationConstraint,constraintsEnabled:this.tooltipManager?.constraintsEnabled??!1})})},h),p(()=>this.sketchOptions?.tooltips.effectiveEnabled,()=>this.measurementManager.preloadMeasurementUtils(),{once:!0,initial:!0}),c(()=>[this.editGeometryOperations,this.sketchOptions?.labels.enabled,this.globalStateManager.segmentLabelsDisabled],()=>{this._updatingHandles.addPromise(this._setupSegmentLabels())},u),g(()=>this.editSessionManager,"cancelPlugin",({plugin:e})=>{this._suspendPlugin(e)},m),g(()=>this.editSessionManager,"restartPlugin",({restartInfo:e})=>{this._resumePlugin(e)},m),c(()=>this.lifecycleManager.updating,e=>{e||this._emitQueuedFeedbackEvents()},m),g(()=>this.editGeometryOperations,["vertex-add","vertex-update","vertex-remove"],e=>{const t=e.vertices.map(e=>({componentIndex:0,vertexIndex:e.index,coordinates:this.coordinateHelper.vectorToArray(e.pos)})),i=t.map(e=>e.coordinates);switch(e.type){case"vertex-add":this._emitWhenReady(e.type,{...e,added:i,vertices:t});break;case"vertex-update":this._emitWhenReady(e.type,{...e,updated:i,vertices:t});break;case"vertex-remove":this._emitWhenReady(e.type,{...e,removed:i,vertices:t})}})])}destroy(){this.active&&this.onDeactivate(),this.editSessionManager.destroy(),this.lifecycleManager.destroy(),this.measurementManager.destroy(),this.globalStateManager.destroy();for(const e of this._pluginContexts.values())e.destroy();this._pluginContexts.clear(),this.surfaceManager=l(this.surfaceManager),this.interactiveHandleManager=l(this.interactiveHandleManager),this._segmentLabelsImportTask=d(this._segmentLabelsImportTask),this._segmentLabels=l(this._segmentLabels),this.tooltipManager=l(this.tooltipManager)}get _zOfLastUserInput(){const e=this.mostDownstreamPlugin&&this.editSessionManager.getSession(this.mostDownstreamPlugin),t=e?.firstPointAddedBySession?.point;return t?.hasZ?t.z:null}get _tooltipDependencies(){const{defaultZ:e,editGeometryOperations:t,sketchOptions:i,directionOptions:n,elevationInfo:a,view:s}=this;return t&&i&&s?{defaultZ:e,directionOptions:n,elevationInfo:a,editGeometryOperations:t,sketchOptions:i,view:s,getActiveHandle:()=>this.interactiveHandleManager?.focusedHandle,getAllHandles:()=>this.interactiveHandleManager?.allhandles,getHelpMessageKey:()=>this.helpMessageKey,notifyTooltipsChanged:()=>{const{interactiveHandleManager:e,movementCommandContext:t}=this;e&&t&&e.reapplyPositions(t)}}:null}get _editSessionManagerContext(){const{coordinateHelper:e,view:t}=this;if(!t)return null;return{coordinateHelper:e,viewingMode:"3d"===t.type&&"global"===t.viewingMode?1:2}}get _densificationParameters(){const{view:e,coordinateHelper:t}=this,i=t.spatialReference,n=e?.spatialReference,a=e.resolution;if(!(i&&n&&a&&Number.isFinite(a)))return null;const s=n.metersPerUnit/i.metersPerUnit;return{maxDeviation:2**Math.round(Math.log2(a))*k()*s,minSegmentsPerCurve:I()}}get test(){return{densificationParameters:this._densificationParameters,segmentLabels:this._segmentLabels}}get updating(){return this._updatingHandles.updating||this.lifecycleManager.updating||!!this._segmentLabels?.updating}get coordinateHelper(){return z(this.hasZ,!1,this.view.spatialReference)}get editGeometry(){return this.editGeometryOperations?.data}get editGeometryOperations(){return this.editSessionManager.editGeometryOperations}get unprocessedGeometry(){return this.editSessionManager.outputGeometry}get simplifiedGeometryPreview(){const e=this.editSessionManager.outputGeometry;if(e&&P(e))try{const t=this._densificationParameters,i=x(e)&&t?new S({...H(e,t)}):e;if(!w(i))return C(i)}catch(t){return e}return e}get _suppressCoincidentPointOverlaysIn3D(){return"3d"===this.view.type&&"point"===this.unprocessedGeometry?.type&&!!this.interactiveHandleManager?.allhandles?.find(e=>"primary"===e.role)?.outputMapPosition}get _shapeVisualGeometry(){return this._suppressCoincidentPointOverlaysIn3D?null:this.simplifiedGeometryPreview}get _vertexVisualGeometry(){return this._suppressCoincidentPointOverlaysIn3D?null:this.unprocessedGeometry}get canUndo(){return this.editSessionManager.canUndo}get canRedo(){return this.editSessionManager.canRedo}get pluginStack(){return this.lifecycleManager.pluginStack}get mostDownstreamPlugin(){return this.pluginStack.at(-1)}get mostUpstreamPlugin(){return this.pluginStack.at(0)}get positionOfLastUserInput(){const e=this.lastScreenPosition;return e?this.surfaceManager?.screenToMap(e,{firstPointZ:this._zOfLastUserInput})??this.view.toMap(e):this.view.center}get movementCommandContext(){const{editGeometryOperations:e,tooltipManager:t,surfaceManager:i,snappingManager:n,interactiveHandleManager:a,_snappingVisualizer:s,defaultZ:r,hasZ:o,globalStateManager:{drawAtFixedElevation:l},view:d}=this;return{tooltipManager:t,editGeometryOperations:e,surfaceManager:i,interactiveHandleManager:a,snappingManager:n,snappingVisualizer:s,pointerType:"mouse",hasZ:o,defaultZ:r,view:d,drawAtFixedElevation:l}}get tooltip(){return this.tooltipManager?.tooltip}get activeTooltipInfo(){return this.tooltipManager?.tooltipInfo}get helpMessageKey(){return this.pluginStack.items.findLast(e=>e.helpMessageKey)?.helpMessageKey??"noTool"}begin(e){this.active?(this.lifecycleManager.begin(e),this._pendingBeginRequest=null):this._pendingBeginRequest=e}complete(e){const t=this.lifecycleManager;if(e&&t.complete(e),0===t.pluginStack.length){const e=this.unprocessedGeometry,t=!e||"mesh"===e.type||w(e);this.emit("complete",{geometry:e,isSimple:t,aborted:!1,type:"complete",vertices:[]}),this.view?.activeTool===this&&(this.view.activeTool=null)}}cancelFirstUserLeafPlugin(){const e=this.pluginStack.toArray().findLast(e=>!0!==e.configuration?.hidden);e&&this.lifecycleManager.cancel(e)}getVertexSnappingCandidates(){return"secondary"===this.interactiveHandleManager?.capturingHandle?.role?[]:this.snappingManager?.getVertexCandidates()??[]}replaceLeaf(e){const t=this.lifecycleManager;t.updating?r.getLogger(this).info("Ignoring command; arrived while updating:","replaceLeaf"):t.replaceLeaf(e)}finishPart(){const e=this.mostUpstreamPlugin,t=e?.configuration;if(this.editGeometryOperations&&t&&t.kind?.includes("multipart")){const e=this.pluginStack.at(1);e&&this.complete(e)}}undo(){this._handleCommand({action:"undo"})}redo(){this._handleCommand({action:"redo"})}executeCommand(e){return this._handleCommand(e)}suspendCommands(){return this._commandsSuspended=!0,a(()=>{this._commandsSuspended=!1;const e=this.view?.inputManager.latestPointerInfo;if(e){const{x:t,y:i}=e.location;this._handleCommand({action:"manipulator-move-to",x:t,y:i})}})}addPromise(e){return this._updatingHandles.addPromise(e)}readPluginSettingValue(e,t){return this.readPluginSetting?.(e,t)}getGeometryIfCompleted(){const e=this.lifecycleManager.gatherCompletablePlugins();return this.editSessionManager?.generatePreviewGeometryForPlugins(e)}onActivate(){super.onActivate();const{view:e}=this;this.lastScreenPosition=e?.inputManager.latestPointerInfo?.location,this.renderer?.activate(),this._pendingBeginRequest&&(this.begin(this._pendingBeginRequest),this._pendingBeginRequest=null),this.enableVertexVisuals&&this.addHandles(c(()=>this._vertexVisualGeometry,e=>{this.renderer?.addOrUpdateVisual(this._vertexVisualId,{geometry:e?V(e):null})},u)),this.addHandles([c(()=>this._shapeVisualGeometry,e=>{this.renderer?.addOrUpdateVisual(this._shapeVisualId,{geometry:e})},u),p(()=>this.interactiveHandleManager?.capturingHandle?.screenPosition,e=>this.lastScreenPosition=e,{initial:!0,equals:v}),c(()=>this.interactiveHandleManager?.capturingHandle?.outputMapPosition,(e,t)=>{const i=this.interactiveHandleManager?.capturingHandle?.editSession?.endVertex;e&&t&&i&&this._emitWhenReady("cursor-update",{updated:i.pos,type:"vertex-update",operation:"apply",vertices:[{componentIndex:i.part.index,vertexIndex:i.index,coordinates:i.pos}]})},m),this._keybindings.register(e,q.TOOL),c(()=>e.viewpoint,(e,t)=>{e&&t&&f(e,t)&&this._handleCommand({action:"viewpoint-moved"})})],Y)}onDeactivate(){super.onDeactivate(),this.removeHandles(Y),this.renderer?.deactivate(),this.snappingManager?.doneSnapping(),this.lifecycleManager.cancelAll(),this._pendingBeginRequest=null}onInputEvent(e){const t=E(e);t&&this._handleCommand(t)}forceAddVertex(){this._commitNext()}_emitWhenReady(e,t){if(this.destroyed)return;const i=()=>{this.emit(e,t)};this.lifecycleManager.updating||this._flushingQueuedFeedbackEvents?this._queuedFeedbackEvents.push(i):i()}_emitQueuedFeedbackEvents(){if(!(this.destroyed||this._flushingQueuedFeedbackEvents||this.lifecycleManager.updating||0===this._queuedFeedbackEvents.length)){this._flushingQueuedFeedbackEvents=!0;try{for(;!this.destroyed&&!this.lifecycleManager.updating&&this._queuedFeedbackEvents.length>0;)this._queuedFeedbackEvents.shift()?.()}finally{this._flushingQueuedFeedbackEvents=!1}}}async _handleCommand(e){if(!this._commandsSuspended)if(this.lifecycleManager.updating)r.getLogger(this).info("Ignoring command; arrived while updating:",e.action);else switch(e.action){case"view-drag":return await this._handleViewDragCommand(e);case"vertex-add":return this._guardCommand(e,()=>{G(e),this._commitNext()});case"vertex-add-and-finish-part":return this._handleVertexAddAndFinishPartCommand(e);case"cancel":return this._guardCommand(e,()=>this.cancel());case"complete":return this._guardCommand(e,()=>{this.mostUpstreamPlugin&&(G(e),this.complete(this.mostUpstreamPlugin))});case"finish-part":return this._guardCommand(e,()=>this.finishPart());case"undo":return this._guardCommand(e,()=>this.editSessionManager.undo());case"redo":return this._guardCommand(e,()=>this.editSessionManager.redo());case"next-manipulator":return this._guardCommand(e,()=>this.interactiveHandleManager?.cycleManipulator("forward"));case"previous-manipulator":return this._guardCommand(e,()=>this.interactiveHandleManager?.cycleManipulator("backward"));case"toggle-manipulator-follow":this.interactiveHandleManager?.toggleFollow()&&G(e);break;case"viewpoint-moved":return await this._handleViewpointMovedCommand(e);case"manipulator-move-to":return await this._handleManipulatorMoveToCommand(e);case"manipulator-drag-to":return await this._handleManipulatorDragToCommand(e);case"vertex-add-at-point":return await this._handleVertexAddAtPointCommand(e);case"show-tooltip":return this._guardCommand(e,async()=>{const t=this.tooltipManager?.tooltip;t&&X(t.info)&&(await t.enterInputMode(),G(e))});case"constraint-center":this.globalStateManager.setCentered(e.enabled);break;case"constraint-aspect":this.globalStateManager.setPreserveAspectRatio(e.enabled)}}async _handleViewDragCommand(e){if(!this.editable)return;const t=e.originalEvent,i=this.interactiveHandleManager?.capturingHandle;(!t||!("pointerType"in t)||"touch"!==t.pointerType||"capture-always"!==i?.captureMode&&"capture-when-engaged"!==i?.captureMode)&&"capture-when-engaged"!==this.interactiveHandleManager?.capturingHandle?.captureMode?this._before(e)&&G(e):G(e)}_handleVertexAddAndFinishPartCommand(e){this._before(e)||(G(e),this._commitNext(),this.finishPart())}async _handleViewpointMovedCommand(e){this.editable&&(await this._updatingHandles.addPromise(this.interactiveHandleManager?.capturingHandle?.moveTo(null,{...this.movementCommandContext,pointerType:T(e.originalEvent)})),this.interactiveHandleManager?.updateAllScreenPositions(this.movementCommandContext.surfaceManager))}async _handleManipulatorMoveToCommand(e){if(!this.editable)return;const t=this._updateLastScreenPosition(e);this.interactiveHandleManager?.capturingHandle&&G(e),await this._updatingHandles.addPromise(this.interactiveHandleManager?.capturingHandle?.moveTo(t,{...this.movementCommandContext,pointerType:T(e.originalEvent)}))}async _handleManipulatorDragToCommand(e){if(!this.editable)return;const t=T(e.originalEvent),i=this._updateLastScreenPosition(e),n=this.interactiveHandleManager?.findHandleByManipulator(i,t);"touch"===t&&n&&"start"===e.state&&this.interactiveHandleManager?.releaseHandle();const a=this.interactiveHandleManager?.findHandleDragging(),s=this.interactiveHandleManager?.capturingHandle,r=a??s??n;r&&!n&&G(e),"capture-when-engaged"===r?.captureMode||"capture-always"===r?.captureMode&&"touch"===t?"end"===e.state?await this._updatingHandles.addPromise(r.noteDragEnd(i,{...this.movementCommandContext,pointerType:t}).then(()=>{r&&"touch"===T(e.originalEvent)&&"grabbable-object"!==r.captureMode&&"capture-when-engaged"!==r.defaultCaptureMode&&"primary"===r.role&&(1===this.interactiveHandleManager?.handleCount?this._handleCommand({action:"vertex-add"}):this.interactiveHandleManager?.releaseHandle())})):"start"===e.state?await this._updatingHandles.addPromise(r.noteDragStart(i,{...this.movementCommandContext,pointerType:t}).then(()=>{r&&"touch"===T(e.originalEvent)&&"grabbable-object"!==r.captureMode&&"capture-when-engaged"!==r.defaultCaptureMode&&!r.editSession?.lastPointAddedBySession&&this._handleCommand({action:"vertex-add"})})):await this._updatingHandles.addPromise(r?.moveTo(i,{...this.movementCommandContext,pointerType:T(e.originalEvent)})):"grabbable-object"===r?.captureMode&&(this.interactiveHandleManager?.releaseHandle(s),await this._updatingHandles.addPromise(r.moveTo(i,{...this.movementCommandContext,pointerType:t})))}async _handleVertexAddAtPointCommand(e){const t=this._updateLastScreenPosition(e),i=T(e.originalEvent),n=this.interactiveHandleManager?.capturingHandle??this.interactiveHandleManager?.findHandleByManipulator(t,i);this.editable&&n&&(this._before(e)||(G(e),await this._updatingHandles.addPromise(n.moveTo(t,{...this.movementCommandContext,skipSnapping:!0,pointerType:i}).finally(()=>this._commitNext()))))}_makeKeyBindings(){const e=new N,t=(t,i)=>{e.addToggle(t,e=>this._handleCommand({action:i,originalEvent:e,enabled:"key-down"===e.type}))},i=(t,i)=>{e.add(t,e=>this._handleCommand({action:i,originalEvent:e}))};return t(Q.preserveAspectRatio,"constraint-aspect"),t(W.center,"constraint-center"),i($.toggleFollowManipulator,"toggle-manipulator-follow"),i(W.undo,"undo"),i(W.redo,"redo"),i(W.complete,"complete"),i(W.vertexAdd,"vertex-add"),i({key:J.enterInputMode,continuePropagation:!0,repeats:!0},"show-tooltip"),e}_afterAttach(){}_afterDetach(e){this.interactiveHandleManager?.unregisterCustomConstraint(e),this.interactiveHandleManager?.unregisterHandle(e),this.tooltipManager?.unregisterPluginFields(e),this.globalStateManager.clearPluginOverrides(e);const t=this._pluginContexts.get(e);t&&(t.destroy(),this._pluginContexts.delete(e))}_beforeResume(e,t){this.interactiveHandleManager?.replaceEditSessions(e,t)}_commitNext(){const i={stack:[],error:void 0,hasError:!1};try{const t=this.mostDownstreamPlugin;if(!t)return;this.tooltipManager?.storeConstraintSnapshot();let n=!1;const a=this.editGeometryOperations;e(i,a?s(a.on("vertex-add",()=>n=!0)):null,!1);t.completeStep?t.completeStep():this.complete(t),n&&this.tooltipManager?.unlockOnVertexPlacement()}catch(n){i.error=n,i.hasError=!0}finally{t(i)}}_suspendPlugin(e){this.lifecycleManager.suspend(e),this.measurementManager.suspendPlugin(e)}_resumePlugin(e){this.lifecycleManager.resume(e)}_updateLastScreenPosition(e){const t=y(e.x,e.y);return this.lastScreenPosition=t,t}_getContextForPlugin(e,t){const i=o(this._pluginContexts,e,()=>new j({drawTool:this,plugin:e,session:t}));return i.session=t,i}_before(e){if(!this.hasEventListener(`before-${e.action}`))return!1;const t=new CustomEvent(`before-${e.action}`,{detail:e,cancelable:!0});return this.emit(`before-${e.action}`,t),t.defaultPrevented}_guardCommand(e,t,i){return this._before(e)?i?.():t()}async _setupSegmentLabels(){const e=this.editGeometryOperations,t=this.sketchOptions?.labels,i=!!t?.enabled,n=this.globalStateManager.segmentLabelsDisabled;if(!e||!t||!i)return void(this._segmentLabels=l(this._segmentLabels));if(n)return void(this._segmentLabels&&(this._segmentLabels.visible=!1));if(this._segmentLabels?.context?.editGeometryOperations===e&&this._segmentLabels.context.labelOptions===t)return void(this._segmentLabels.visible=!0);const a=await this._createSegmentLabels(e,t);a&&(this._segmentLabels=l(this._segmentLabels),this._segmentLabels=a)}async _createSegmentLabels(e,t){return(this._segmentLabelsImportTask??=n(async i=>{if("3d"===this.view.type){const n=import("../3d/interactive/SegmentLabels3D.js"),{SegmentLabels3D:a}=await this._updatingHandles.addPromise(n);return this._isSegmentLabelsSetupStale(i,e,t)?null:new a({context:{view:this.view,editGeometryOperations:e,elevationInfo:L(this.hasZ,this.elevationInfo),labelOptions:t},visible:!0})}const n=import("../2d/interactive/SegmentLabels2D.js"),{SegmentLabels2D:a}=await this._updatingHandles.addPromise(n);return this._isSegmentLabelsSetupStale(i,e,t)?null:new a({context:{view:this.view,editGeometryOperations:e,elevationInfo:L(this.hasZ,this.elevationInfo),labelOptions:t},visible:!0})})).promise}_isSegmentLabelsSetupStale(e,t,i){return e.aborted||this.editGeometryOperations!==t||this.sketchOptions?.labels!==i||!i.enabled||this.globalStateManager.segmentLabelsDisabled}};i([M()],ee.prototype,"_commandsSuspended",void 0),i([M()],ee.prototype,"_zOfLastUserInput",null),i([M()],ee.prototype,"_snappingVisualizer",void 0),i([M()],ee.prototype,"_segmentLabels",void 0),i([M()],ee.prototype,"_segmentLabelsImportTask",void 0),i([M()],ee.prototype,"_tooltipDependencies",null),i([M()],ee.prototype,"_editSessionManagerContext",null),i([M()],ee.prototype,"_densificationParameters",null),i([M({constructOnly:!0,nonNullable:!0})],ee.prototype,"view",void 0),i([M()],ee.prototype,"automaticManipulatorSelection",void 0),i([M()],ee.prototype,"updating",null),i([M()],ee.prototype,"coordinateHelper",null),i([M()],ee.prototype,"editGeometry",null),i([M()],ee.prototype,"editGeometryOperations",null),i([M()],ee.prototype,"unprocessedGeometry",null),i([M()],ee.prototype,"simplifiedGeometryPreview",null),i([M()],ee.prototype,"_suppressCoincidentPointOverlaysIn3D",null),i([M()],ee.prototype,"_shapeVisualGeometry",null),i([M()],ee.prototype,"_vertexVisualGeometry",null),i([M()],ee.prototype,"snappingManager",void 0),i([M()],ee.prototype,"sketchOptions",void 0),i([M()],ee.prototype,"elevationInfo",void 0),i([M()],ee.prototype,"hasZ",void 0),i([M()],ee.prototype,"defaultZ",void 0),i([M()],ee.prototype,"directionOptions",void 0),i([M()],ee.prototype,"canUndo",null),i([M()],ee.prototype,"canRedo",null),i([M()],ee.prototype,"pluginStack",null),i([M()],ee.prototype,"mostDownstreamPlugin",null),i([M()],ee.prototype,"mostUpstreamPlugin",null),i([M()],ee.prototype,"lastScreenPosition",void 0),i([M()],ee.prototype,"positionOfLastUserInput",null),i([M()],ee.prototype,"tooltipManager",void 0),i([M()],ee.prototype,"measurementManager",void 0),i([M()],ee.prototype,"globalStateManager",void 0),i([M()],ee.prototype,"editSessionManager",void 0),i([M()],ee.prototype,"lifecycleManager",void 0),i([M()],ee.prototype,"surfaceManager",void 0),i([M()],ee.prototype,"interactiveHandleManager",void 0),i([M()],ee.prototype,"renderer",void 0),i([M()],ee.prototype,"readPluginSetting",void 0),i([M()],ee.prototype,"movementCommandContext",null),i([M()],ee.prototype,"tooltip",null),i([M()],ee.prototype,"activeTooltipInfo",null),i([M()],ee.prototype,"helpMessageKey",null),i([M({constructOnly:!0})],ee.prototype,"enableVertexVisuals",void 0),ee=i([_("esri.views.draw.DrawTool")],ee);export{ee as DrawTool};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
-
import{__decorate as t}from"tslib";import{isSome as e}from"../../../core/arrayUtils.js";import o from"../../../core/Error.js";import{makeHandle as n}from"../../../core/handleUtils.js";import{watch as i,initial as
|
|
2
|
+
import{__decorate as t}from"tslib";import{isSome as e}from"../../../core/arrayUtils.js";import o from"../../../core/Error.js";import{makeHandle as n}from"../../../core/handleUtils.js";import{watch as i,syncAndInitial as r,initial as s}from"../../../core/reactiveUtils.js";import{property as a,subclass as p}from"../../../core/accessorSupport/decorators.js";import l from"../../../geometry/Point.js";import c from"../../../geometry/Polyline.js";import{isBezierCurve as h}from"../../../geometry/support/curves/curveUtils.js";import{PluginBase as d}from"./PluginBase.js";import{bezierEnableSplineBehaviorSettingKey as u}from"../support/types.js";const _=Symbol("left-vertex"),P=Symbol("right-vertex"),m=Symbol("cp1"),y=Symbol("cp2"),f=Symbol("endpoint"),g=Symbol("anchor");let C=class extends d{constructor(){super(...arguments),this._controlPoint1LineId=Symbol(),this._controlPoint2LineId=Symbol(),this._mirroredCp2VisualId=Symbol(),this.enableSplineBehavior=!0,this.state="placing-anchor"}get helpMessageKey(){switch(this.state){case"placing-control-point-1":return"curveBezierControlPoint1";case"placing-endpoint":return"curvePlaceEndPoint";case"placing-control-point-2":return"curveBezierControlPoint2";default:return"point"}}get test(){return{computeCurve:this._computeCurve.bind(this),recomputeAndApply:this._recomputeAndApply.bind(this),cp1LineSymbol:this._controlPoint1LineId,cp2LineSymbol:this._controlPoint2LineId,controlPointId:this._mirroredCp2VisualId}}start(t,e){super.start(t,e);const o=t.session,n=t.readBooleanSetting(u);null!=n&&(this.enableSplineBehavior=n),this.addHandles(i(()=>t.readBooleanSetting(u),t=>{null!=t&&(this.enableSplineBehavior=t)},r),this._ownHandlesKey),o.preserveSharedRedoAfterOperation=!0,this.ownPlacedLeftAnchor=e?.ownPlacedLeftAnchor,this.leftAnchor=o.getInformationAboutPoint(-1,-1)?.point;let s=e?.state;if(!this.leftAnchor&&this.ownPlacedLeftAnchor?(this.leftAnchor=this.ownPlacedLeftAnchor,o.appendOrReplacePoint(_,this.leftAnchor),o?.groupGeometryChanges()):this.leftAnchor&&"placing-anchor"===e?.state&&(s="placing-control-point-1",this.ownPlacedLeftAnchor=null),this.state=this.leftAnchor?s??"placing-control-point-1":"placing-anchor",this.controlPoint1=e?.controlPoint1,this.endPoint=e?.endPoint,this.controlPoint2=e?.controlPoint2,this.enableSplineBehavior&&"placing-control-point-1"===this.state&&!s){const t=o.getInformationAboutPoint(-1,-1);if(t?.curveInfo&&h(t.curveInfo)){const[e,n]=t.curveInfo.b[2],{spatialReference:i}=t.point,r=new l({x:e,y:n,spatialReference:i}),s=b(t.point,r);this.controlPoint1=s,o?.pushUndoStep(this._captureState()),this.state="placing-endpoint",o?.pushUndoStep(this._captureState())}}this.addHandles([i(()=>this._anchorCursor?.outputMapPosition,t=>{t&&(this.leftAnchor=this.ownPlacedLeftAnchor=t,this._session?.appendOrReplacePoint(_,t))}),i(()=>this._cp1Cursor?.outputMapPosition,t=>{t&&(this.controlPoint1=t,this._recomputeAndApply())}),i(()=>this._endpointCursor?.outputMapPosition,t=>{t&&(this.endPoint=t,this._recomputeAndApply())}),i(()=>this._cp2Cursor?.outputMapPosition,t=>{t&&(this.controlPoint2=t,this._recomputeAndApply())})],this._ownHandlesKey),this._applyState(this.state),this._setupRendering(t)}completeStep(){if(this._isComplete)return;const t=this._session?.peekUndoStep();if(t){const e=this._captureState();t&&t.state===e?.state&&(t.controlPoint1=e.controlPoint1,t.controlPoint2=e.controlPoint2,t.endPoint=e.endPoint,t.leftAnchor=e.leftAnchor)}else this._session?.pushUndoStep(this._captureState());try{switch(this._session.preserveSharedRedoAfterOperation=!1,this.state){case"placing-anchor":this._applyState(this.state="placing-control-point-1");break;case"placing-control-point-1":this._applyState(this.state="placing-endpoint");break;case"placing-endpoint":this._applyState(this.state="placing-control-point-2");break;case"placing-control-point-2":this._context?.requestComplete()}}finally{this._session.preserveSharedRedoAfterOperation=!0}this._session?.pushUndoStep(this._captureState())}beforeAttachPlugin(t){return{useStandaloneSession:!0}}suspend(){return this._captureState()}_applyState(t){const e=this._session;if(!e)throw new o("drawTool:invalid-state","Bezier: attempted to apply state while context invalid");switch(e.automaticRestart=!1,this.removeHandles(m),this.removeHandles(f),this.removeHandles(y),this.removeHandles(g),t){case"placing-anchor":e.automaticRestart=!0,this._setupAnchorCursor();break;case"placing-control-point-1":{const{ownPlacedLeftAnchor:t}=this;e.automaticRestart=!t,t&&e.groupGeometryChanges(),this._setupCP1Cursor();break}case"placing-endpoint":this._setupCP1Cursor(),this._setupEndpointCursor();break;case"placing-control-point-2":this._setupCP1Cursor(),this._setupEndpointCursor(),this._setupCP2Cursor()}}_setupAnchorCursor(){this._anchorCursor=this._context.createInteractiveHandle({defaultCaptureMode:"capture-always",inputMapPosition:this._context.positionOfLastUserInput,role:"primary",selfSnappingEnabled:!1,snappingEnabled:!0}),this.addHandles(n(()=>{this._anchorCursor&&(this._context?.removeInteractiveHandle(this._anchorCursor),this._anchorCursor=null)}),g)}_setupCP1Cursor(){const t="placing-control-point-1"===this.state?"capture-always":"grabbable-object";this._cp1Cursor=this._context.createInteractiveHandle({defaultCaptureMode:t,inputMapPosition:"capture-always"===t?void 0:this.controlPoint1,role:"secondary",selfSnappingEnabled:!1,snappingEnabled:!0}),this.addHandles(n(()=>{this._cp1Cursor&&(this._context?.removeInteractiveHandle(this._cp1Cursor),this._cp1Cursor=null)}),m)}_setupEndpointCursor(){const t="placing-endpoint"===this.state?"capture-always":"grabbable-object";this._endpointCursor=this._context.createInteractiveHandle({defaultCaptureMode:t,inputMapPosition:"capture-always"===t?void 0:this.endPoint??this.controlPoint1,role:"primary",selfSnappingEnabled:!0,snappingEnabled:!0}),this.addHandles(n(()=>{this._endpointCursor&&(this._context?.removeInteractiveHandle(this._endpointCursor),this._endpointCursor=null)}),f)}_setupCP2Cursor(){const t="placing-control-point-2"===this.state?"capture-always":"grabbable-object";this._cp2Cursor=this._context.createInteractiveHandle({defaultCaptureMode:t,inputMapPosition:"capture-always"===t?void 0:this.controlPoint2??this.endPoint??this._context.positionOfLastUserInput,role:"secondary",selfSnappingEnabled:!1,snappingEnabled:!0}),this.addHandles(n(()=>{this._cp2Cursor&&(this._context?.removeInteractiveHandle(this._cp2Cursor),this._cp2Cursor=null)}),y)}_computeCurve(){const{leftAnchor:t,controlPoint1:e,endPoint:o,controlPoint2:n,state:i}=this;return t?"placing-control-point-1"===i&&e?v(e,e,e):"placing-endpoint"===i&&e&&o?v(o,e,o):e&&o&&n?v(o,e,n,{flipControlPoint2:!0}):null:null}_recomputeAndApply(){const t=this._computeCurve();t&&this._session?.appendOrReplaceCurve(P,t)}_setupRendering(t){t.addOrUpdateVisual(this._controlPoint1LineId,{role:"constructionLine",state:"idle"}),t.addOrUpdateVisual(this._controlPoint2LineId,{role:"constructionLine",state:"idle"}),t.addOrUpdateVisual(this._mirroredCp2VisualId,{role:"controlPoint",state:"idle"}),this.addHandles([i(()=>[this.controlPoint1,this.controlPoint2,this.endPoint,this.leftAnchor],([e,o,n,i])=>{const{state:r}=this;if(i&&e&&"placing-control-point-1"!==r&&"placing-anchor"!==r){const o=new c({paths:[[[i.x,i.y],[e.x,e.y]]],spatialReference:i.spatialReference});t.addOrUpdateVisual(this._controlPoint1LineId,{geometry:o})}else t.addOrUpdateVisual(this._controlPoint1LineId,{geometry:null});if(o&&n&&i){const e=b(n,o),i=new c({paths:[[[o.x,o.y],[e.x,e.y]]],spatialReference:o.spatialReference});t.addOrUpdateVisual(this._controlPoint2LineId,{geometry:i}),t.addOrUpdateVisual(this._mirroredCp2VisualId,{geometry:e})}else t.addOrUpdateVisual(this._controlPoint2LineId,{geometry:null}),t.addOrUpdateVisual(this._mirroredCp2VisualId,{geometry:null})},s)],this._ownHandlesKey)}_captureState(){const{state:t,controlPoint1:e,controlPoint2:o,endPoint:n,leftAnchor:i,ownPlacedLeftAnchor:r}=this;return{state:t,controlPoint1:e,endPoint:n,controlPoint2:o,leftAnchor:i,ownPlacedLeftAnchor:r}}};function v(t,o,n,i){const r=[t.x,t.y,t.z,t.m].filter(e),s=i?.flipControlPoint2?b(t,n):n;return{b:[r,[o.x,o.y],[s.x,s.y]]}}function b(t,e){const{x:o,y:n,spatialReference:i}=t,{x:r,y:s}=e;return new l({x:o+(o-r),y:n+(n-s),spatialReference:i})}t([a()],C.prototype,"_anchorCursor",void 0),t([a()],C.prototype,"_cp1Cursor",void 0),t([a()],C.prototype,"_endpointCursor",void 0),t([a()],C.prototype,"_cp2Cursor",void 0),t([a()],C.prototype,"enableSplineBehavior",void 0),t([a()],C.prototype,"state",void 0),t([a()],C.prototype,"helpMessageKey",null),t([a()],C.prototype,"controlPoint1",void 0),t([a()],C.prototype,"controlPoint2",void 0),t([a()],C.prototype,"endPoint",void 0),t([a()],C.prototype,"leftAnchor",void 0),t([a()],C.prototype,"ownPlacedLeftAnchor",void 0),C=t([p("esri.views.draw.plugins.BezierSegmentPlugin")],C);export{C as BezierSegmentPlugin,v as createBezier,b as mirrorControlPoint};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
-
import{__decorate as e}from"tslib";import{watch as t,syncAndInitial as n,sync as i}from"../../../core/reactiveUtils.js";import{property as a,subclass as r}from"../../../core/accessorSupport/decorators.js";import{PluginBase as s}from"./PluginBase.js";const
|
|
2
|
+
import{__decorate as e}from"tslib";import{watch as t,syncAndInitial as n,sync as i}from"../../../core/reactiveUtils.js";import{property as a,subclass as r}from"../../../core/accessorSupport/decorators.js";import{PluginBase as s}from"./PluginBase.js";import{freehandSnappingEnabledSettingKey as p}from"../support/types.js";const o=Symbol("primary-vertex");let l=class extends s{constructor(){super(...arguments),this.completeOnDragEnd=!0,this.snappingBehavior="never"}get _effectiveSnappingEnabled(){return"when-not-capturing"===this.snappingBehavior&&!this._interactiveHandle?.dragging}get helpMessageKey(){return this._interactiveHandle?.dragging?"freehandEnd":"freehandStart"}start(e){super.start(e);const{session:a,positionOfLastUserInput:r}=e;if(r&&a.appendOrReplacePoint(o,r),!this._interactiveHandle){const a=this._effectiveSnappingEnabled;this._interactiveHandle=e.createInteractiveHandle({defaultCaptureMode:"capture-when-engaged",snappingEnabled:a,selfSnappingEnabled:a},{disableDefaultXYFields:!0}),this.addHandles([t(()=>this._context?.readBooleanSetting(p),e=>{null!=e&&(this.snappingBehavior=e?"when-not-capturing":"never")},n),t(()=>[!!this._interactiveHandle?.dragging,this._effectiveSnappingEnabled],([e,t],n)=>{const i=!!n?.[0],a=this._interactiveHandle;a&&(a.snappingEnabled=t,a.selfSnappingEnabled=t),this.completeOnDragEnd&&!e&&i&&this._context?.requestComplete()},n),t(()=>this._interactiveHandle?.outputMapPosition,e=>{e&&!this._isComplete&&this._session?.appendOrReplacePoint(o,e,{forceAppend:!!this._interactiveHandle?.dragging})},i)],this._ownHandlesKey)}}};e([a()],l.prototype,"_interactiveHandle",void 0),e([a()],l.prototype,"_effectiveSnappingEnabled",null),e([a()],l.prototype,"completeOnDragEnd",void 0),e([a()],l.prototype,"snappingBehavior",void 0),e([a()],l.prototype,"helpMessageKey",null),l=e([r("esri.views.draw.plugins.FreehandSegmentPlugin")],l);export{l as FreehandSegmentPlugin};
|