@arcgis/core 4.34.0-next.54 → 4.34.0-next.56
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/WebScene.js +1 -1
- package/analysis/ElevationProfile/ElevationProfileGroundLine.d.ts +4 -0
- package/analysis/ElevationProfile/ElevationProfileGroundLine.js +5 -0
- package/analysis/ElevationProfile/ElevationProfileInputLine.d.ts +4 -0
- package/analysis/ElevationProfile/ElevationProfileInputLine.js +5 -0
- package/analysis/ElevationProfile/ElevationProfileLine.d.ts +4 -0
- package/analysis/ElevationProfile/ElevationProfileLine.js +5 -0
- package/analysis/ElevationProfile/ElevationProfileLineChartOptions.d.ts +4 -0
- package/analysis/ElevationProfile/{LineChartOptions.js → ElevationProfileLineChartOptions.js} +1 -1
- package/analysis/ElevationProfile/ElevationProfileLineViewOptions.d.ts +4 -0
- package/analysis/ElevationProfile/{LineViewOptions.js → ElevationProfileLineViewOptions.js} +1 -1
- package/analysis/ElevationProfile/ElevationProfileQueryLine.d.ts +4 -0
- package/analysis/ElevationProfile/ElevationProfileQueryLine.js +5 -0
- package/analysis/ElevationProfile/ElevationProfileSceneLine.d.ts +4 -0
- package/analysis/ElevationProfile/ElevationProfileSceneLine.js +5 -0
- package/analysis/ElevationProfile/ElevationProfileUnits.d.ts +4 -0
- package/analysis/ElevationProfile/{Units.js → ElevationProfileUnits.js} +1 -1
- package/analysis/ElevationProfile/ElevationProfileViewOptions.d.ts +4 -0
- package/analysis/ElevationProfile/{ViewOptions.js → ElevationProfileViewOptions.js} +1 -1
- package/analysis/ElevationProfile/elevationProfileLineTypes.js +1 -1
- package/analysis/ElevationProfileAnalysis.js +1 -1
- package/applications/KnowledgeStudio/resourceSerializationUtils.js +1 -1
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/01e8b9dc77a57d1c2a52.js +1 -0
- package/assets/esri/core/workers/chunks/027cfcde29fe87aa2ffe.js +1 -0
- package/assets/esri/core/workers/chunks/0a4586e596413ef7a4b5.js +1 -0
- package/assets/esri/core/workers/chunks/10b46438885916d18425.js +1 -0
- package/assets/esri/core/workers/chunks/1166ed298cf5ca7ad444.js +1 -0
- package/assets/esri/core/workers/chunks/13797036850dcc3671c3.js +1 -0
- package/assets/esri/core/workers/chunks/18ceea59e469a0f2721b.js +1 -0
- package/assets/esri/core/workers/chunks/199a17b0a0f75cbaed16.js +1 -0
- package/assets/esri/core/workers/chunks/1eee7cf11df01a52c1bf.js +1 -0
- package/assets/esri/core/workers/chunks/{ac41b882f9cbf8d56f0c.js → 222f981e876f60ae282f.js} +1 -1
- package/assets/esri/core/workers/chunks/22334a464f798b5279b2.js +1 -0
- package/assets/esri/core/workers/chunks/{99b9392946d776a62997.js → 23e600e368ac829680b5.js} +1 -1
- package/assets/esri/core/workers/chunks/24ac204d8a045aa821be.js +1 -0
- package/assets/esri/core/workers/chunks/27197b0a2ffb2b6104ea.js +1 -0
- package/assets/esri/core/workers/chunks/{93af38d29d066f27ed28.js → 2cb14d040e67a261b31c.js} +1 -1
- package/assets/esri/core/workers/chunks/{0021118bafefd1e47ff7.js → 31c088966ccfff2ea1db.js} +1 -1
- package/assets/esri/core/workers/chunks/{c9c109d43a1e5160955d.js → 3490d47cac7c8dec70cd.js} +2 -2
- package/assets/esri/core/workers/chunks/3d800fbc449bea18b1cd.js +1 -0
- package/assets/esri/core/workers/chunks/43a56c8fa4e5be18c12a.js +1 -0
- package/assets/esri/core/workers/chunks/4874aabdb5c60ca66216.js +1 -0
- package/assets/esri/core/workers/chunks/4b58da6cb91f7bf6af8b.js +1 -0
- package/assets/esri/core/workers/chunks/{cac060a187f3a27a19ba.js → 4d5abcf57a6ded4750ba.js} +1 -1
- package/assets/esri/core/workers/chunks/527557b603400189d49a.js +1 -0
- package/assets/esri/core/workers/chunks/{d0bf1fc6e3c198bc565d.js → 57486b18421a3c9690d0.js} +1 -1
- package/assets/esri/core/workers/chunks/{4bd92232928b832dea76.js → 5900dde7a201a7d47469.js} +1 -1
- package/assets/esri/core/workers/chunks/5f518931a660b3c4f519.js +1 -0
- package/assets/esri/core/workers/chunks/63f3e46bfa820436161c.js +1 -0
- package/assets/esri/core/workers/chunks/66f3659ba18f92cd623e.js +1 -0
- package/assets/esri/core/workers/chunks/67355372ac5fd8a15d18.js +1 -0
- package/assets/esri/core/workers/chunks/{b0ee061747bef6729bb9.js → 6801b92bce7a918fda6f.js} +1 -1
- package/assets/esri/core/workers/chunks/6940bb6524938894a246.js +1 -0
- package/assets/esri/core/workers/chunks/6b11476b2004b4db576e.js +1 -0
- package/assets/esri/core/workers/chunks/{5691d504ffe5592bc40f.js → 6dc0009889f2b7cc8cff.js} +1 -1
- package/assets/esri/core/workers/chunks/71cac356874b36f9a383.js +1 -0
- package/assets/esri/core/workers/chunks/{69dc5a7abc1fda2474ad.js → 722931d1a60be461e521.js} +1 -1
- package/assets/esri/core/workers/chunks/79ab06fb4c91ac8da323.js +1 -0
- package/assets/esri/core/workers/chunks/{0a4357af5b8c0532b439.js → 7bdfc7c7ce1d94c00745.js} +1 -1
- package/assets/esri/core/workers/chunks/{0ce671588de2858516d2.js → 83737d86584bf1b32368.js} +1 -1
- package/assets/esri/core/workers/chunks/853b9f29b4d62fa621b9.js +1 -0
- package/assets/esri/core/workers/chunks/855f25ce748aaef44b1a.js +1 -0
- package/assets/esri/core/workers/chunks/{71acded1b3c0057917a1.js → 862fe2f96d4b777ff5b8.js} +1 -1
- package/assets/esri/core/workers/chunks/{98ea12c7a000a30f3dc0.js → 87f68c2b9361bd3f8cac.js} +1 -1
- package/assets/esri/core/workers/chunks/8fa50cac57b6e1ecec76.js +1 -0
- package/assets/esri/core/workers/chunks/9307108821d82c131654.js +1 -0
- package/assets/esri/core/workers/chunks/97ae2fdb6cb98249f5fa.js +1 -0
- package/assets/esri/core/workers/chunks/9a20390602126995f831.js +1 -0
- package/assets/esri/core/workers/chunks/9b10e70f28873cff44f5.js +1 -0
- package/assets/esri/core/workers/chunks/9cdeead9d444e8d95477.js +1 -0
- package/assets/esri/core/workers/chunks/a778a72456fefdf40115.js +1 -0
- package/assets/esri/core/workers/chunks/a999f804fc2f00b2e7ae.js +1 -0
- package/assets/esri/core/workers/chunks/adf11d31f95481f89a55.js +1 -0
- package/assets/esri/core/workers/chunks/ae73ac81bd10614c2b53.js +1 -0
- package/assets/esri/core/workers/chunks/af4412e79275c5a87539.js +1 -0
- package/assets/esri/core/workers/chunks/{7a8d740d1226719a578a.js → b457b7dd907f06278bee.js} +1 -1
- package/assets/esri/core/workers/chunks/{81e518dd62bd95611d00.js → b47688e3263099540873.js} +1 -1
- package/assets/esri/core/workers/chunks/c7d4c296011c5393bcaa.js +1 -0
- package/assets/esri/core/workers/chunks/c86e339e45900c54c9f5.js +1 -0
- package/assets/esri/core/workers/chunks/c91217d977a6baaee74a.js +1 -0
- package/assets/esri/core/workers/chunks/{a1d3f1c221389eb6090c.js → c95e6bef8c97cf647869.js} +1 -1
- package/assets/esri/core/workers/chunks/{e1b25b1ce3bd4f0f2cda.js → cb57cdff976d2d4b0b41.js} +1 -1
- package/assets/esri/core/workers/chunks/cbec768cd98caff212f2.js +1 -0
- package/assets/esri/core/workers/chunks/{9fef330b241f958b55df.js → d0124b0dd62b331afe58.js} +1 -1
- package/assets/esri/core/workers/chunks/d3a7747f23e91d1f1b5e.js +1 -0
- package/assets/esri/core/workers/chunks/d3ae88fcde2d7fb3e2e2.js +1 -0
- package/assets/esri/core/workers/chunks/{b6a201e86f9caef45ff0.js → d42fd0effc560eefb14b.js} +1 -1
- package/assets/esri/core/workers/chunks/d81c4afad4abe2d1d0b9.js +1 -0
- package/assets/esri/core/workers/chunks/{2da12a64d3baef4aaaa1.js → d87fdc64a5cc6be4bd69.js} +1 -1
- package/assets/esri/core/workers/chunks/db5d3feeb61ccb5ede98.js +1 -0
- package/assets/esri/core/workers/chunks/dfb12f42b8d319ffa5fc.js +1 -0
- package/assets/esri/core/workers/chunks/{aab349d4624b78ef429f.js → e6bf4f3f6868dc9028e3.js} +1 -1
- package/assets/esri/core/workers/chunks/e982cf44906eb26164f2.js +1 -0
- package/assets/esri/core/workers/chunks/{081b22fa73ef7b696409.js → ead1acf95c3385630da8.js} +2 -2
- package/assets/esri/core/workers/chunks/f1c50f37a81c672263a1.js +1 -0
- package/assets/esri/core/workers/chunks/f74b0cdc1c2b56bac5f0.js +1 -0
- package/assets/esri/core/workers/chunks/f807e7fc90e0e7ce6b67.js +1 -0
- package/assets/esri/core/workers/chunks/{fae6030a81cb91a91b69.js → faf4002f9547a0cc4e33.js} +1 -1
- package/assets/esri/core/workers/chunks/ff323db554c9e09749e8.js +1 -0
- package/assets/esri/core/workers/chunks/{fe55833c80cf59df9c2b.js → ff42b24b48019a03d841.js} +1 -1
- package/assets/esri/core/workers/chunks/{e10c5405f956b2cc59e4.js → ff4e15a872de94d2b438.js} +1 -1
- package/assets/esri/core/workers/chunks/{ff7962063d132c1ec814.js → ff8a4bf1bceb362d67ab.js} +1 -1
- package/assets/esri/libs/parquet/pkg/bundle_bg.wasm +0 -0
- package/chunks/Laserlines.glsl.js +1 -1
- package/chunks/LineSeries.js +1 -1
- package/chunks/Theme.js +1 -1
- package/chunks/boundedPlane.js +1 -1
- package/chunks/bundle.js +1 -1
- package/chunks/chartUtilsAm5.js +1 -1
- package/chunks/sphere.js +1 -1
- package/chunks/vec42.js +1 -1
- package/config.js +1 -1
- package/core/ArrayPool.js +1 -1
- package/core/Collection.js +1 -1
- package/core/ObjectPool.js +1 -1
- package/core/accessorSupport/Properties.js +1 -1
- package/core/accessorSupport/watch.js +1 -1
- package/core/arrayUtils.js +1 -1
- package/core/has.js +1 -1
- package/core/libs/gl-matrix-2/math/quat.js +1 -1
- package/core/libs/gl-matrix-2/math/vec4.js +1 -1
- package/core/pbf.js +1 -1
- package/core/typedArrayUtil.js +1 -1
- package/geohash/GeohashCell.js +1 -1
- package/geohash/GeohashTree.js +1 -1
- package/geometry/Multipoint.js +1 -1
- package/geometry/support/DoubleArray.js +1 -1
- package/geometry/support/boundedPlane.js +1 -1
- package/geometry/support/coordsUtils.js +1 -1
- package/geometry/support/extentUtils.js +1 -1
- package/geometry/support/meshUtils/exporters/gltf/gltf.js +1 -1
- package/geometry/support/sphere.js +1 -1
- package/graphic/KMLGraphicOrigin.js +5 -0
- package/graphic/isKMLGraphicOrigin.js +5 -0
- package/interfaces.d.ts +147 -142
- package/kernel.js +1 -1
- package/layers/KMLLayer.js +1 -1
- package/layers/SceneLayer.js +1 -1
- package/layers/graphics/controllers/I3SOnDemandController.js +1 -1
- package/layers/graphics/sources/ParquetSource.js +1 -1
- package/layers/graphics/sources/support/ParquetSourceWorker.js +1 -1
- package/layers/orientedImagery/core/coverageUtils.js +1 -1
- package/layers/support/ElevationQuery.js +1 -1
- package/layers/support/KMLSublayer.js +1 -1
- package/layers/support/featureReductionUtils.js +1 -1
- package/layers/support/kmlUtils.js +1 -1
- package/package.json +1 -1
- package/renderers/support/colorRampUtils.js +1 -1
- package/rest/knowledgeGraphService.js +1 -1
- package/support/requestUtils.js +1 -1
- package/support/revision.js +1 -1
- package/symbols/cim/CIMSymbolDrawHelper.js +1 -1
- package/views/2d/engine/Container.js +1 -1
- package/views/2d/engine/DisplayObject.js +1 -1
- package/views/2d/engine/flow/dataUtils.js +1 -1
- package/views/2d/engine/webgl/AttributeStoreView.js +1 -1
- package/views/2d/engine/webgl/DisplayEntity.js +1 -1
- package/views/2d/engine/webgl/DisplayRecord.js +1 -1
- package/views/2d/engine/webgl/FeatureDisplayList.js +1 -1
- package/views/2d/engine/webgl/FeatureTile.js +1 -1
- package/views/2d/engine/webgl/PooledUint32Array.js +1 -1
- package/views/2d/engine/webgl/cpuMapped/Buffer.js +1 -1
- package/views/2d/engine/webgl/cpuMapped/MappedMesh.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/labels/LabelMeshWriter.js +1 -1
- package/views/2d/interactive/editingTools/TransformTool.js +1 -1
- package/views/2d/interactive/editingTools/manipulations/ScaleManipulation.js +1 -1
- package/views/2d/layers/FeatureLayerView2D.js +1 -1
- package/views/2d/layers/KMLLayerView2D.js +1 -1
- package/views/2d/layers/features/FeatureContainer.js +1 -1
- package/views/2d/layers/features/FeaturePipelineWorker.js +1 -1
- package/views/2d/layers/features/FeatureSourceEventLog.js +1 -1
- package/views/2d/layers/features/FeatureSpatialIndex.js +1 -1
- package/views/2d/layers/features/Processor.js +1 -1
- package/views/2d/layers/features/RenderState.js +1 -1
- package/views/2d/layers/features/aggregation/AccumulatedStatistics.js +1 -1
- package/views/2d/layers/features/aggregation/GeohashSpatialIndex.js +1 -1
- package/views/2d/layers/features/aggregation/GridCell.js +1 -1
- package/views/2d/layers/features/aggregation/GridSpatialIndex.js +1 -1
- package/views/2d/layers/features/processor/AProcessorStrategy.js +1 -1
- package/views/2d/layers/features/schema/processor/LabelMatcherSchema.js +1 -1
- package/views/2d/layers/features/schema/processor/symbols/ComplexSymbolSchema.js +1 -1
- package/views/2d/layers/features/schema/processor/symbols/SymbolSchema.js +1 -1
- package/views/2d/layers/features/sources/FeatureSource.js +1 -1
- package/views/2d/layers/features/sources/strategies/chunks/ASourceChunk.js +1 -1
- package/views/2d/layers/features/sources/strategies/chunks/SourceChunkStore.js +1 -1
- package/views/2d/layers/features/support/AttributeStore.js +1 -1
- package/views/2d/layers/features/support/DisplayIdGenerator.js +1 -1
- package/views/2d/layers/features/support/FeatureSetCache.js +1 -1
- package/views/2d/layers/features/support/FeatureSetReader.js +1 -1
- package/views/2d/layers/features/support/FeatureSetReaderPBF.js +1 -1
- package/views/2d/layers/features/support/FeatureSetReaderPBFHeader.js +1 -1
- package/views/2d/layers/features/support/StaticBitSet.js +1 -1
- package/views/2d/tiling/TileCoverage.js +1 -1
- package/views/2d/tiling/TileKey.js +1 -1
- package/views/3d/FocusAreasView.js +1 -1
- package/views/3d/analysis/AreaMeasurement/support/AreaMeasurementPathHelper.js +1 -1
- package/views/3d/analysis/ElevationProfile/{HoveredPointVisualization.js → ElevationProfileHoveredPointVisualization.js} +1 -1
- package/views/3d/analysis/ElevationProfile/ElevationProfileHoveredPointsVisualization.js +5 -0
- package/views/3d/analysis/ElevationProfile/ElevationProfileInputVisualization.js +5 -0
- package/views/3d/analysis/ElevationProfile/ElevationProfileLinesVisualization.js +5 -0
- package/views/3d/analysis/ElevationProfile/ElevationProfileSceneLineComputation.js +5 -0
- package/views/3d/analysis/ElevationProfile/ElevationProfileVisualization.js +5 -0
- package/views/3d/analysis/ElevationProfileAnalysisView3D.js +1 -1
- package/views/3d/analysis/Slice/SliceController.js +1 -1
- package/views/3d/analysis/Slice/SliceTool.js +1 -1
- package/views/3d/analysis/Slice/sliceToolUtils.js +1 -1
- package/views/3d/analysis/Viewshed/{ArrowManipulator.js → ViewshedArrowManipulator.js} +1 -1
- package/views/3d/analysis/Viewshed/{FieldOfViewManipulation.js → ViewshedFieldOfViewManipulation.js} +1 -1
- package/views/3d/analysis/Viewshed/ViewshedScaleOrientManipulation.js +5 -0
- package/views/3d/analysis/Viewshed/ViewshedShapeVisualElement.js +5 -0
- package/views/3d/analysis/Viewshed/ViewshedSubTool.js +1 -1
- package/views/3d/analysis/Viewshed/ViewshedSubVisualization.js +5 -0
- package/views/3d/analysis/Viewshed/ViewshedVisualization.js +1 -1
- package/views/3d/analysis/ViewshedAnalysisView3D.js +1 -1
- package/views/3d/camera/constraintUtils/distance.js +1 -1
- package/views/3d/interactive/editingTools/transform/extentTransform/ExtentRotate.js +1 -1
- package/views/3d/interactive/editingTools/transform/extentTransform/ExtentScale.js +1 -1
- package/views/3d/interactive/editingTools/transform/extentTransform/extentUtils.js +1 -1
- package/views/3d/layers/I3SMeshView3D.js +1 -1
- package/views/3d/layers/IntegratedMesh3DTilesLayerView3D.js +1 -1
- package/views/3d/layers/graphics/Deconflictor.js +1 -1
- package/views/3d/layers/graphics/Graphics3DCore.js +1 -1
- package/views/3d/layers/graphics/Graphics3DExtrudeSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/Graphics3DGraphic.js +1 -1
- package/views/3d/layers/graphics/Graphics3DPolygonFillSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/objectResourceUtils.js +1 -1
- package/views/3d/layers/i3s/I3SClientMaterialUtil.js +1 -1
- package/views/3d/layers/i3s/I3SClientNodeLoader.js +1 -1
- package/views/3d/layers/i3s/I3SIndex.js +1 -1
- package/views/3d/layers/i3s/I3SNode.js +1 -1
- package/views/3d/layers/i3s/I3SViewportQueries.js +1 -1
- package/views/3d/state/ViewState.js +1 -1
- package/views/3d/state/ViewStateManager.js +1 -1
- package/views/3d/state/controllers/PinchAndPanControllerGlobal.js +1 -1
- package/views/3d/support/ViewSlice.js +1 -1
- package/views/3d/support/orientedBoundingBox.js +1 -1
- package/views/3d/support/pointsOfInterest/CameraOnSurface.js +1 -1
- package/views/3d/support/pointsOfInterest/CenterOnSurface.js +1 -1
- package/views/3d/support/pointsOfInterest/Focus.js +1 -1
- package/views/3d/support/pointsOfInterest/PointsOfInterest.js +1 -1
- package/views/3d/terrain/ScaleRangeQueries.js +1 -1
- package/views/3d/terrain/SphericalPatch.js +1 -1
- package/views/3d/terrain/TerrainRenderer.js +1 -1
- package/views/3d/terrain/TerrainSurface.js +1 -1
- package/views/3d/terrain/Tile.js +1 -1
- package/views/3d/terrain/TilePerLayerInfo.js +1 -1
- package/views/3d/webgl-engine/core/material/MaterialBase.js +1 -1
- package/views/3d/webgl-engine/lib/Object3D.js +1 -1
- package/views/3d/webgl-engine/lib/Octree.js +1 -1
- package/views/3d/webgl-engine/lib/RenderGeometry.js +1 -1
- package/views/3d/webgl-engine/lib/SliceHelper.js +1 -1
- package/views/3d/webgl-engine/lib/Viewshed.js +1 -1
- package/views/3d/webgl-engine/lib/depthRangeUtils.js +1 -1
- package/views/3d/webgl-engine/lib/edgeRendering/EdgeView.js +1 -1
- package/views/3d/webgl-engine/lib/lodRendering/InstanceOctree.js +1 -1
- package/views/3d/webgl-engine/lib/octreeUtils.js +1 -1
- package/views/3d/webgl-engine/materials/internal/MaterialUtil.js +1 -1
- package/views/analysis/ElevationProfile/ElevationProfileController.js +5 -0
- package/views/analysis/ElevationProfile/{ProfileGenerationError.js → ElevationProfileGenerationError.js} +1 -1
- package/views/analysis/ElevationProfile/ElevationProfileGroundLineComputation.js +5 -0
- package/views/analysis/ElevationProfile/ElevationProfileInputLineComputation.js +5 -0
- package/views/analysis/ElevationProfile/ElevationProfileLineComputation.js +5 -0
- package/views/analysis/ElevationProfile/ElevationProfileQueryLineComputation.js +5 -0
- package/views/analysis/ElevationProfile/ElevationProfileResult.d.ts +4 -0
- package/views/analysis/ElevationProfile/ElevationProfileResult.js +5 -0
- package/views/analysis/ElevationProfile/elevationProfileGenerationUtils.js +5 -0
- package/views/analysis/ElevationProfile/elevationProfileGeometryUtils.js +5 -0
- package/views/draw/DrawOperation.js +1 -1
- package/views/draw/MultipointDrawAction.js +1 -1
- package/views/draw/PointDrawAction.js +1 -1
- package/views/draw/PolygonDrawAction.js +1 -1
- package/views/draw/PolylineDrawAction.js +1 -1
- package/views/draw/SegmentDrawAction.js +1 -1
- package/views/draw/support/Box.js +1 -1
- package/views/draw/support/GraphicMover.js +1 -1
- package/views/draw/support/Reshape.js +1 -1
- package/views/draw/support/drawUtils.js +1 -1
- package/views/draw/support/reshapeTooltipUtils.js +1 -1
- package/views/input/InputManager.js +1 -1
- package/views/interactive/editGeometry/EditGeometry.js +1 -1
- package/views/interactive/editGeometry/EditGeometryOperations.js +1 -1
- package/views/interactive/editGeometry/operations/AppendVertex.js +1 -1
- package/views/interactive/editGeometry/support/editPlaneUtils.js +1 -1
- package/views/interactive/sketch/constraints.js +1 -1
- package/views/interactive/snapping/featureSources/featureServiceSource/tileUtils.js +1 -1
- package/views/interactive/snapping/featureSources/sceneLayerSource/SceneLayerSnappingSourceWorker.js +1 -1
- package/views/interactive/snapping/featureSources/sceneLayerSource/sceneLayerSnappingUtils.js +1 -1
- package/views/interactive/tooltip/infos/SelectedVertexTooltipInfo.js +1 -1
- package/views/layers/FeatureLayerView.js +1 -1
- package/views/support/PropertiesPool.js +1 -1
- package/webscene/spec-certification/api.js +1 -1
- package/webscene/spec-certification/compare.js +1 -1
- package/webscene/spec-certification/spec.js +1 -1
- package/widgets/ElevationProfile/ElevationProfileLine.d.ts +2 -2
- package/widgets/ElevationProfile/support/profileUtils.js +1 -1
- package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
- package/widgets/OrientedImageryViewer/imageMeasurementUtils.js +1 -1
- package/widgets/OrientedImageryViewer.js +1 -1
- package/widgets/Sketch/SketchViewModel.js +1 -1
- package/widgets/Sketch/support/sketchUtils.js +1 -1
- package/analysis/ElevationProfile/GroundLine.d.ts +0 -4
- package/analysis/ElevationProfile/GroundLine.js +0 -5
- package/analysis/ElevationProfile/InputLine.d.ts +0 -4
- package/analysis/ElevationProfile/InputLine.js +0 -5
- package/analysis/ElevationProfile/Line.d.ts +0 -4
- package/analysis/ElevationProfile/Line.js +0 -5
- package/analysis/ElevationProfile/LineChartOptions.d.ts +0 -4
- package/analysis/ElevationProfile/LineViewOptions.d.ts +0 -4
- package/analysis/ElevationProfile/QueryLine.d.ts +0 -4
- package/analysis/ElevationProfile/QueryLine.js +0 -5
- package/analysis/ElevationProfile/SceneLine.d.ts +0 -4
- package/analysis/ElevationProfile/SceneLine.js +0 -5
- package/analysis/ElevationProfile/Units.d.ts +0 -4
- package/analysis/ElevationProfile/ViewOptions.d.ts +0 -4
- package/assets/esri/core/workers/chunks/02902303e5585a16ebea.js +0 -1
- package/assets/esri/core/workers/chunks/0445de3a8968c0734c91.js +0 -1
- package/assets/esri/core/workers/chunks/09268dc856c3d5ce178f.js +0 -1
- package/assets/esri/core/workers/chunks/0f51e51db83f303ce5a6.js +0 -1
- package/assets/esri/core/workers/chunks/14c6ae4feb4859cfa7c5.js +0 -1
- package/assets/esri/core/workers/chunks/17776d9d3558d45ea7b5.js +0 -1
- package/assets/esri/core/workers/chunks/1cbd59918c60a1a21494.js +0 -1
- package/assets/esri/core/workers/chunks/20a2b3d1f826e9059884.js +0 -1
- package/assets/esri/core/workers/chunks/250b1629becca0410f2a.js +0 -1
- package/assets/esri/core/workers/chunks/2efa4d8fe5454f8b2a05.js +0 -1
- package/assets/esri/core/workers/chunks/3149a86cd25684dcb0b3.js +0 -1
- package/assets/esri/core/workers/chunks/3800764932a1c32cb29f.js +0 -1
- package/assets/esri/core/workers/chunks/38f84294fb2fb4663ba5.js +0 -1
- package/assets/esri/core/workers/chunks/3c57b2e13628b5c1f6de.js +0 -1
- package/assets/esri/core/workers/chunks/3eb3af0b6cf3c2f28131.js +0 -1
- package/assets/esri/core/workers/chunks/43bd338bb0de375b9bb7.js +0 -1
- package/assets/esri/core/workers/chunks/4622a3e64d3c4aafa56b.js +0 -1
- package/assets/esri/core/workers/chunks/47f2e905ef42e36897aa.js +0 -1
- package/assets/esri/core/workers/chunks/50e9eafb118d2a221f10.js +0 -1
- package/assets/esri/core/workers/chunks/55588e668b6acb6aa390.js +0 -1
- package/assets/esri/core/workers/chunks/5b112471dca94b2e8462.js +0 -1
- package/assets/esri/core/workers/chunks/5dfe1aed10095385c066.js +0 -1
- package/assets/esri/core/workers/chunks/5fc414fc2cfc68828c5b.js +0 -1
- package/assets/esri/core/workers/chunks/7389841fabe0f319f1e5.js +0 -1
- package/assets/esri/core/workers/chunks/772e81e9162e2240a7a6.js +0 -1
- package/assets/esri/core/workers/chunks/8c81156b1605a16acc29.js +0 -1
- package/assets/esri/core/workers/chunks/8e0559cc6295008fcdf7.js +0 -1
- package/assets/esri/core/workers/chunks/8f6ff09e7d2f01b79faf.js +0 -1
- package/assets/esri/core/workers/chunks/944fa8261aad94ae0542.js +0 -1
- package/assets/esri/core/workers/chunks/9639a6f6fab52a501bf7.js +0 -1
- package/assets/esri/core/workers/chunks/998c38974372720b1c52.js +0 -1
- package/assets/esri/core/workers/chunks/9e479e7e2e51476c3d27.js +0 -1
- package/assets/esri/core/workers/chunks/a1e179dd6de9c8769b02.js +0 -1
- package/assets/esri/core/workers/chunks/a6493607b98783bf1ef2.js +0 -1
- package/assets/esri/core/workers/chunks/a7530dcb08b43e37bbb2.js +0 -1
- package/assets/esri/core/workers/chunks/a829969ed44cdb814f27.js +0 -1
- package/assets/esri/core/workers/chunks/b2a035befeeff1a55ad8.js +0 -1
- package/assets/esri/core/workers/chunks/b4251e10621fb3ad03a3.js +0 -1
- package/assets/esri/core/workers/chunks/b9f5672093727c6f92c9.js +0 -1
- package/assets/esri/core/workers/chunks/ba45dccb4dab5a74d224.js +0 -1
- package/assets/esri/core/workers/chunks/c51e2a048df152abd901.js +0 -1
- package/assets/esri/core/workers/chunks/cda27c0fafd687dfa72e.js +0 -1
- package/assets/esri/core/workers/chunks/d1842745a7699879a1e1.js +0 -1
- package/assets/esri/core/workers/chunks/d578c3880eaf2dd62324.js +0 -1
- package/assets/esri/core/workers/chunks/ddd6597a66ec6b972f9c.js +0 -1
- package/assets/esri/core/workers/chunks/de499e33035b56b6697d.js +0 -1
- package/assets/esri/core/workers/chunks/e28d3ed65c3a76a044c8.js +0 -1
- package/assets/esri/core/workers/chunks/e3f68f7b408a08d7cd5d.js +0 -1
- package/assets/esri/core/workers/chunks/e9716995ce0c3683eafc.js +0 -1
- package/assets/esri/core/workers/chunks/ed25bf087f52e5d3e71b.js +0 -1
- package/assets/esri/core/workers/chunks/ee0286b5f5475f2d853f.js +0 -1
- package/assets/esri/core/workers/chunks/f8505bf69795f5293a79.js +0 -1
- package/assets/esri/core/workers/chunks/f92e608931b1c168cb45.js +0 -1
- package/views/3d/analysis/ElevationProfile/HoveredPointsVisualization.js +0 -5
- package/views/3d/analysis/ElevationProfile/InputVisualization.js +0 -5
- package/views/3d/analysis/ElevationProfile/ProfileLinesVisualization.js +0 -5
- package/views/3d/analysis/ElevationProfile/SceneLineComputation.js +0 -5
- package/views/3d/analysis/ElevationProfile/Visualization.js +0 -5
- package/views/3d/analysis/Viewshed/ScaleOrientManipulation.js +0 -5
- package/views/3d/analysis/Viewshed/ViewshedAnalysisVisualization.js +0 -5
- package/views/3d/interactive/visualElements/ViewshedShapeVisualElement.js +0 -5
- package/views/analysis/ElevationProfile/Controller.js +0 -5
- package/views/analysis/ElevationProfile/GroundLineComputation.js +0 -5
- package/views/analysis/ElevationProfile/InputLineComputation.js +0 -5
- package/views/analysis/ElevationProfile/LineComputation.js +0 -5
- package/views/analysis/ElevationProfile/QueryLineComputation.js +0 -5
- package/views/analysis/ElevationProfile/Result.d.ts +0 -4
- package/views/analysis/ElevationProfile/Result.js +0 -5
- package/views/analysis/ElevationProfile/geometryUtils.js +0 -5
- package/views/analysis/ElevationProfile/profileGenerationUtils.js +0 -5
- /package/assets/esri/core/workers/chunks/{c9c109d43a1e5160955d.js.LICENSE.txt → 3490d47cac7c8dec70cd.js.LICENSE.txt} +0 -0
- /package/views/analysis/ElevationProfile/{elevationQuerySourceUtils.js → elevationProfileQuerySourceUtils.js} +0 -0
- /package/views/analysis/ElevationProfile/{statisticsUtils.js → elevationProfileStatisticsUtils.js} +0 -0
- /package/views/analysis/ElevationProfile/{traversalUtils.js → elevationProfileTraversalUtils.js} +0 -0
- /package/views/analysis/ElevationProfile/{unitUtils.js → elevationProfileUnitUtils.js} +0 -0
- /package/views/analysis/ElevationProfile/{visualizationUtils.js → elevationProfileVisualizationUtils.js} +0 -0
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{toHSV as o,toLAB as r,toLCH as t,toRGB as l}from"../../core/colorUtils.js";import{JSONMap as e}from"../../core/jsonMap.js";import{isSerializable as i}from"../../core/support/jsonUtils.js";const n=["random","ndvi","ndvi2","ndvi3","elevation","gray","hillshade"],C=[{id:"aspect",type:"multipart",colorRamps:[{fromColor:[190,190,190],toColor:[255,45,8]},{fromColor:[255,45,8],toColor:[255,181,61]},{fromColor:[255,181,61],toColor:[255,254,52]},{fromColor:[255,254,52],toColor:[0,251,50]},{fromColor:[0,251,50],toColor:[255,254,52]},{fromColor:[0,253,255],toColor:[0,181,255]},{fromColor:[0,181,255],toColor:[26,35,253]},{fromColor:[26,35,253],toColor:[255,57,251]},{fromColor:[255,57,251],toColor:[255,45,8]}]},{id:"black-to-white",fromColor:[0,0,0],toColor:[255,255,255]},{id:"blue-bright",fromColor:[204,204,255],toColor:[0,0,224]},{id:"blue-light-to-dark",fromColor:[211,229,232],toColor:[46,100,140]},{id:"blue-green-bright",fromColor:[203,245,234],toColor:[48,207,146]},{id:"blue-green-light-to-dark",fromColor:[216,242,237],toColor:[21,79,74]},{id:"brown-light-to-dark",fromColor:[240,236,170],toColor:[102,72,48]},{id:"brown-to-blue-green-diverging-right",type:"multipart",colorRamps:[{fromColor:[156,85,31],toColor:[255,255,191]},{fromColor:[255,255,191],toColor:[33,130,145]}]},{id:"brown-to-blue-green-diverging-dark",type:"multipart",colorRamps:[{fromColor:[110,70,45],toColor:[204,204,102]},{fromColor:[204,204,102],toColor:[48,100,102]}]},{id:"coefficient-bias",fromColor:[214,214,255],toColor:[0,57,148]},{id:"cold-to-hot-diverging",type:"multipart",colorRamps:[{fromColor:[69,117,181],toColor:[255,255,191]},{fromColor:[255,255,191],toColor:[214,47,39]}]},{id:"condition-number",type:"multipart",colorRamps:[{fromColor:[0,97,0],toColor:[255,255,0]},{fromColor:[255,255,0],toColor:[255,34,0]}]},{id:"cyan-to-purple",type:"multipart",colorRamps:[{fromColor:[0,245,245],toColor:[0,0,245]},{fromColor:[0,0,245],toColor:[245,0,245]}]},{id:"cyan-light-to-blue-dark",type:"multipart",colorRamps:[{fromColor:[182,237,240],toColor:[31,131,224]},{fromColor:[31,131,224],toColor:[9,9,145]}]},{id:"distance",fromColor:[255,200,0],toColor:[0,0,255]},{id:"elevation1",type:"multipart",colorRamps:[{fromColor:[175,240,233],toColor:[255,255,179]},{fromColor:[255,255,179],toColor:[0,128,64]},{fromColor:[0,128,64],toColor:[252,186,3]},{fromColor:[252,186,3],toColor:[128,0,0]},{fromColor:[120,0,0],toColor:[105,48,13]},{fromColor:[105,48,13],toColor:[171,171,171]},{fromColor:[171,171,171],toColor:[255,252,255]}]},{id:"elevation2",type:"multipart",colorRamps:[{fromColor:[118,219,211],toColor:[255,255,199]},{fromColor:[255,255,199],toColor:[255,255,128]},{fromColor:[255,255,128],toColor:[217,194,121]},{fromColor:[217,194,121],toColor:[135,96,38]},{fromColor:[135,96,38],toColor:[150,150,181]},{fromColor:[150,150,181],toColor:[181,150,181]},{fromColor:[181,150,181],toColor:[255,252,255]}]},{id:"errors",fromColor:[255,235,214],toColor:[196,10,10]},{id:"gray-light-to-dark",fromColor:[219,219,219],toColor:[69,69,69]},{id:"green-bright",fromColor:[204,255,204],toColor:[14,204,14]},{id:"green-light-to-dark",fromColor:[220,245,233],toColor:[34,102,51]},{id:"green-to-blue",type:"multipart",colorRamps:[{fromColor:[32,204,16],toColor:[0,242,242]},{fromColor:[0,242,242],toColor:[2,33,227]}]},{id:"orange-bright",fromColor:[255,235,204],toColor:[240,118,5]},{id:"orange-light-to-dark",fromColor:[250,233,212],toColor:[171,65,36]},{id:"partial-spectrum",type:"multipart",colorRamps:[{fromColor:[242,241,162],toColor:[255,255,0]},{fromColor:[255,255,0],toColor:[255,0,0]},{fromColor:[252,3,69],toColor:[176,7,237]},{fromColor:[176,7,237],toColor:[2,29,173]}]},{id:"partial-spectrum-1-diverging",type:"multipart",colorRamps:[{fromColor:[135,38,38],toColor:[240,149,12]},{fromColor:[240,149,12],toColor:[255,255,191]},{fromColor:[255,255,191],toColor:[74,80,181]},{fromColor:[74,80,181],toColor:[39,32,122]}]},{id:"partial-spectrum-2-diverging",type:"multipart",colorRamps:[{fromColor:[115,77,42],toColor:[201,137,52]},{fromColor:[201,137,52],toColor:[255,255,191]},{fromColor:[255,255,191],toColor:[91,63,176]},{fromColor:[91,63,176],toColor:[81,13,97]}]},{id:"pink-to-yellow-green-diverging-bright",type:"multipart",colorRamps:[{fromColor:[158,30,113],toColor:[255,255,191]},{fromColor:[255,255,191],toColor:[99,110,45]}]},{id:"pink-to-yellow-green-diverging-dark",type:"multipart",colorRamps:[{fromColor:[97,47,73],toColor:[204,204,102]},{fromColor:[204,204,102],toColor:[22,59,15]}]},{id:"precipitation",type:"multipart",colorRamps:[{fromColor:[194,82,60],toColor:[237,161,19]},{fromColor:[237,161,19],toColor:[255,255,0]},{fromColor:[255,255,0],toColor:[0,219,0]},{fromColor:[0,219,0],toColor:[32,153,143]},{fromColor:[32,153,143],toColor:[11,44,122]}]},{id:"prediction",type:"multipart",colorRamps:[{fromColor:[40,146,199],toColor:[250,250,100]},{fromColor:[250,250,100],toColor:[232,16,20]}]},{id:"purple-bright",fromColor:[255,204,255],toColor:[199,0,199]},{id:"purple-to-green-diverging-bright",type:"multipart",colorRamps:[{fromColor:[77,32,150],toColor:[255,255,191]},{fromColor:[255,255,191],toColor:[20,122,11]}]},{id:"purple-to-green-diverging-dark",type:"multipart",colorRamps:[{fromColor:[67,14,89],toColor:[204,204,102]},{fromColor:[204,204,102],toColor:[24,79,15]}]},{id:"purple-blue-bright",fromColor:[223,184,230],toColor:[112,12,242]},{id:"purple-blue-light-to-dark",fromColor:[229,213,242],toColor:[93,44,112]},{id:"purple-red-bright",fromColor:[255,204,225],toColor:[199,0,99]},{id:"purple-red-light-to-dark",fromColor:[250,215,246],toColor:[143,17,57]},{id:"red-bright",fromColor:[255,204,204],toColor:[219,0,0]},{id:"red-light-to-dark",fromColor:[255,224,224],toColor:[143,10,10]},{id:"red-to-blue-diverging-bright",type:"multipart",colorRamps:[{fromColor:[196,69,57],toColor:[255,255,191]},{fromColor:[255,255,191],toColor:[48,95,207]}]},{id:"red-to-blue-diverging-dark",type:"multipart",colorRamps:[{fromColor:[107,13,13],toColor:[204,204,102]},{fromColor:[204,204,102],toColor:[13,53,97]}]},{id:"red-to-green",type:"multipart",colorRamps:[{fromColor:[245,0,0],toColor:[245,245,0]},{fromColor:[245,245,0],toColor:[0,245,0]}]},{id:"red-to-green-diverging-bright",type:"multipart",colorRamps:[{fromColor:[186,20,20],toColor:[255,255,191]},{fromColor:[255,255,191],toColor:[54,145,33]}]},{id:"red-to-green-diverging-dark",type:"multipart",colorRamps:[{fromColor:[97,21,13],toColor:[204,204,102]},{fromColor:[204,204,102],toColor:[16,69,16]}]},{id:"slope",type:"multipart",colorRamps:[{fromColor:[56,168,0],toColor:[255,255,0]},{fromColor:[255,255,0],toColor:[255,0,0]}]},{id:"spectrum-full-bright",type:"multipart",colorRamps:[{fromColor:[255,0,0],toColor:[255,255,0]},{fromColor:[255,255,0],toColor:[0,255,255]},{fromColor:[0,255,255],toColor:[0,0,255]}]},{id:"spectrum-full-dark",type:"multipart",colorRamps:[{fromColor:[153,0,0],toColor:[153,153,0]},{fromColor:[153,153,0],toColor:[0,153,153]},{fromColor:[0,153,153],toColor:[0,0,153]}]},{id:"spectrum-full-light",type:"multipart",colorRamps:[{fromColor:[255,153,153],toColor:[255,255,153]},{fromColor:[255,255,153],toColor:[153,255,255]},{fromColor:[153,255,255],toColor:[153,153,255]}]},{id:"surface",type:"multipart",colorRamps:[{fromColor:[112,153,89],toColor:[242,238,162]},{fromColor:[242,238,162],toColor:[242,206,133]},{fromColor:[242,206,133],toColor:[194,140,124]},{fromColor:[194,140,124],toColor:[255,242,255]}]},{id:"temperature",type:"multipart",colorRamps:[{fromColor:[255,252,255],toColor:[255,0,255]},{fromColor:[255,0,255],toColor:[0,0,255]},{fromColor:[0,0,255],toColor:[0,255,255]},{fromColor:[0,255,255],toColor:[0,255,0]},{fromColor:[0,255,0],toColor:[255,255,0]},{fromColor:[255,255,0],toColor:[255,128,0]},{fromColor:[255,128,0],toColor:[128,0,0]}]},{id:"white-to-black",fromColor:[255,255,255],toColor:[0,0,0]},{id:"yellow-to-dark-red",type:"multipart",colorRamps:[{fromColor:[255,255,128],toColor:[242,167,46]},{fromColor:[242,167,46],toColor:[107,0,0]}]},{id:"yellow-to-green-to-dark-blue",type:"multipart",colorRamps:[{fromColor:[255,255,128],toColor:[56,224,9]},{fromColor:[56,224,9],toColor:[26,147,171]},{fromColor:[26,147,171],toColor:[12,16,120]}]},{id:"yellow-to-red",fromColor:[245,245,0],toColor:[255,0,0]},{id:"yellow-green-bright",fromColor:[236,252,204],toColor:[157,204,16]},{id:"yellow-green-light-to-dark",fromColor:[215,240,175],toColor:[96,107,45]}],m=new e({Aspect:"aspect","Black to White":"black-to-white","Blue Bright":"blue-bright","Blue Light to Dark":"blue-light-to-dark","Blue-Green Bright":"blue-green-bright","Blue-Green Light to Dark":"blue-green-light-to-dark","Brown Light to Dark":"brown-light-to-dark","Brown to Blue Green Diverging, Bright":"brown-to-blue-green-diverging-right","Brown to Blue Green Diverging, Dark":"brown-to-blue-green-diverging-dark","Coefficient Bias":"coefficient-bias","Cold to Hot Diverging":"cold-to-hot-diverging","Condition Number":"condition-number","Cyan to Purple":"cyan-to-purple","Cyan-Light to Blue-Dark":"cyan-light-to-blue-dark",Distance:"distance","Elevation #1":"elevation1","Elevation #2":"elevation2",Errors:"errors","Gray Light to Dark":"gray-light-to-dark","Green Bright":"green-bright","Green Light to Dark":"green-light-to-dark","Green to Blue":"green-to-blue","Orange Bright":"orange-bright","Orange Light to Dark":"orange-light-to-dark","Partial Spectrum":"partial-spectrum","Partial Spectrum 1 Diverging":"partial-spectrum-1-diverging","Partial Spectrum 2 Diverging":"partial-spectrum-2-diverging","Pink to YellowGreen Diverging, Bright":"pink-to-yellow-green-diverging-bright","Pink to YellowGreen Diverging, Dark":"pink-to-yellow-green-diverging-dark",Precipitation:"precipitation",Prediction:"prediction","Purple Bright":"purple-bright","Purple to Green Diverging, Bright":"purple-to-green-diverging-bright","Purple to Green Diverging, Dark":"purple-to-green-diverging-dark","Purple-Blue Bright":"purple-blue-bright","Purple-Blue Light to Dark":"purple-blue-light-to-dark","Purple-Red Bright":"purple-red-bright","Purple-Red Light to Dark":"purple-red-light-to-dark","Red Bright":"red-bright","Red Light to Dark":"red-light-to-dark","Red to Blue Diverging, Bright":"red-to-blue-diverging-bright","Red to Blue Diverging, Dark":"red-to-blue-diverging-dark","Red to Green":"red-to-green","Red to Green Diverging, Bright":"red-to-green-diverging-bright","Red to Green Diverging, Dark":"red-to-green-diverging-dark",Slope:"slope","Spectrum-Full Bright":"spectrum-full-bright","Spectrum-Full Dark":"spectrum-full-dark","Spectrum-Full Light":"spectrum-full-light",Surface:"surface",Temperature:"temperature","White to Black":"white-to-black","Yellow to Dark Red":"yellow-to-dark-red","Yellow to Green to Dark Blue":"yellow-to-green-to-dark-blue","Yellow to Red":"yellow-to-red","Yellow-Green Bright":"yellow-green-bright","Yellow-Green Light to Dark":"yellow-green-light-to-dark"});function a(o,r){if(!o||!r||o.length!==r.length)return!1;for(let t=0;t<o.length;t++)if(o[t]>r[t]+2||o[t]<r[t]-2)return!1;return!0}function g(o){const r=o.clone();return r.fromColor=o.toColor,r.toColor=o.fromColor,r}function p(o){if("multipart"===o.type){const r=o.clone();return r.colorRamps?.length?(r.colorRamps=r.colorRamps.reverse().map(o=>g(o)),r):r}return g(o)}function u(o,r){const t=r??C;if("algorithmic"===o.type){const r=o.fromColor.toRgb(),l=o.toColor.toRgb();return t.find(o=>a(r,o.fromColor)&&a(l,o.toColor))?.id}const l=o.colorRamps?.map(o=>({fromColor:o.fromColor.toRgb(),toColor:o.toColor.toRgb()}));return t.find(o=>{const r=o.colorRamps;return!(!l||!r||l.length!==r.length)&&r.every((o,r)=>a(l[r].fromColor,o.fromColor)&&a(l[r].toColor,o.toColor))})?.id}function f(o,r,t=!1){if(!o)return;let l=!1,e=u(o,r);return null!=e||t||(l=!0,e=u(o=p(o),r)),e?{id:e,inverted:l}:void 0}function s(o,r=!1){const t="string"==typeof o?o:f(o,void 0,r)?.id;return t?m.toJSON(t):null}function d(o,r="esriCIELabAlgorithm"){const t=C.find(({id:r})=>r===o);return t?t.colorRamps?{type:"multipart",colorRamps:t.colorRamps.map(o=>({type:"algorithmic",algorithm:r,fromColor:[...o.fromColor],toColor:[...o.toColor]}))}:{type:"algorithmic",algorithm:r,fromColor:[...t.fromColor],toColor:[...t.toColor]}:null}function c(o){o??={};const r=o.numColors||256,t=o.distanceOffset||0,l=null!=o.isCustomInterval?o.isCustomInterval:null!==o.distanceInterval&&o.distanceInterval!==1/(r-1),e=o.distanceInterval||1/(r-1);return{...o,numColors:r,distanceOffset:t,interpolateAlpha:!!o.interpolateAlpha,distanceInterval:e,isCustomInterval:l,weights:o.weights}}function h(o,r,t){const{numColors:l,distanceOffset:e,distanceInterval:i,isCustomInterval:n}=t,C=0===o.s,m=0===r.s;let a=o.h,g=r.h;C&&!m?a=g:m&&!C&&(r={...r,h:a},g=a);let p=Math.abs(g-a),u=0;const f=360;p<f/2?u=(g-a)*i:(p=f-p,u=a>g?p*i:-p*i);const s=(r.s-o.s)*i,d=(r.v-o.v)*i;let{s:c,v:h}=o,b=a;if(e){const o=e/i;b=(b+o*u+f)%f,c+=o*s,h+=o*d}const v=[];for(let y=0;y<l-1;y++)v.push({h:b,s:c,v:h}),b=(b+u+f)%f,c+=s,h+=d;return v.push(n?{h:b,s:c,v:h}:r),v}function b(o,r,t){const{numColors:l,distanceOffset:e,distanceInterval:i,isCustomInterval:n}=t;let{l:C,a:m,b:a}=o;const g=(r.l-C)*i,p=(r.a-m)*i,u=(r.b-a)*i,f=[];if(e){const o=e/i;C+=o*g,m+=o*p,a+=o*u}for(let s=0;s<l-1;s++)f.push({l:C,a:m,b:a}),C+=g,m+=p,a+=u;return f.push(n?{l:C,a:m,b:a}:r),f}function v(o,r,t){const{numColors:l,distanceOffset:e,distanceInterval:i,isCustomInterval:n}=t,C=o.h,m=r.h,a=2*Math.PI;let g=0;if(C<=m){const o=m-C,r=m-C-a;g=Math.abs(r)<Math.abs(o)?r:o}else{const o=m+a-C,r=m-C;g=Math.abs(r)<Math.abs(o)?r:o}const p=g*i,u=(r.l-o.l)*i,f=(r.c-o.c)*i;let{l:s,c:d,h:c}=o;if(e){const o=e/i;s+=o*u,d+=o*f,c=(c+o*p+a)%a}const h=[];for(let b=0;b<l-1;b++)h.push({l:s,c:d,h:c}),s+=u,d+=f,c=(c+p+a)%a;return h.push(n?{l:s,c:d,h:c}:r),h}function y(e,i){const{fromColor:n,toColor:C}=e,m=3===n.length?[...n,255]:[...n],a=3===C.length?[...C,255]:[...C],g=e.algorithm||"esriCIELabAlgorithm",p=c(i),{numColors:u,distanceOffset:f,isCustomInterval:s,interpolateAlpha:d}=p;if(1===u&&0===f)return[m];if(2===u&&0===f&&!s)return[m,a];const y={r:m[0],g:m[1],b:m[2]},k={r:a[0],g:a[1],b:a[2]},R="esriCIELabAlgorithm"===g?b(r(y),r(k),p):"esriHSVAlgorithm"===g?h(o(y),o(k),p):v(t(y),t(k),p),w=[],B=m[3]??255,D=((a[3]??255)-B)/(u-1);for(let o=0;o<u;o++){const{r,g:t,b:e}=l(R[o]),i=d?Math.round(B+D*o):255;w.push([r,t,e,i])}return w}function k(o,r){const{colorRamps:t}=o;if(!r?.length)return Array.from({length:t.length},()=>1/t.length);const l=r.reduce((o,r)=>o+r);return r.map(o=>o/l)}function R(o,r){const{numColors:t,interpolateAlpha:l}=c(r),e=k(o,r?.weights),{colorRamps:i}=o,n=[],C=1/(t-1);let m=0,a=!1;for(let p=0;p<i.length;p++){const o=n.length,r=a?0:o*C-m;m+=e[p];let g=p===i.length-1?t-1-o:(e[p]-r)/C;if(a=Math.ceil(g)===g,g=Math.ceil(g),0===g)continue;const u=y(i[p],{numColors:g,interpolateAlpha:l,distanceOffset:r/e[p],distanceInterval:C/e[p]});n.push(...u)}const g=[...i[i.length-1].toColor];return 3===g.length&&g.push(255),n.push(g),n}function w(o,r){const t=i(o)?o.toJSON():o;return"multipart"===t.type?R(t,r):y(t,r)}function B(o,r){const t=w(o,r),l=r?.interpolateAlpha;return t.forEach((o,r)=>{o.unshift(r),l||o.pop()}),t}function D(r){const t=[];for(let l=0;l<r.length;l+=4){const e=o({r:r[l],g:r[l+1],b:r[l+2]});t.push([e.h/60,e.s/100,255*e.v/100])}return t}function I(r){const t=o(r);return{type:"HsvColor",Hue:t.h,Saturation:t.s,Value:t.v,AlphaValue:255}}function A(o){const r=o.toJSON();return{Algorithm:r?.Algorithm||"esriHSVAlgorithm",type:"AlgorithmicColorRamp",FromColor:I(o.fromColor),ToColor:I(o.toColor)}}function G(o){const r=s(o);if(!r)return null;if("algorithmic"===o.type)return{...A(o),Name:r};if(o.colorRamps){const t=o.colorRamps.map(A);return{type:"MultiPartColorRamp",NumColorRamps:t.length,ArrayOfColorRamp:t,Name:r}}return null}function P(o){const r=[...o].reverse().map(o=>{const r=o.toString(16);return r.length<2?"0"+r:r});return 4294967295&Number.parseInt(r.join(""),16)}export{m as colorRampDict,B as convertColorRampToColormap,w as convertColorRampToColors,P as convertRGBATo32Bit,D as createHsvMap,f as getColorRampId,d as getColorRampJSON,s as getColorRampName,G as getRFxArgColorRampValue,C as predefinedJsonColorRamps,n as rasterColormapNames};
|
|
5
|
+
import{toHSV as o,toLAB as r,toLCH as t,toRGB as l}from"../../core/colorUtils.js";import{JSONMap as e}from"../../core/jsonMap.js";import{isSerializable as i}from"../../core/support/jsonUtils.js";const n=["random","ndvi","ndvi2","ndvi3","elevation","gray","hillshade"],C=[{id:"aspect",type:"multipart",colorRamps:[{fromColor:[190,190,190],toColor:[255,45,8]},{fromColor:[255,45,8],toColor:[255,181,61]},{fromColor:[255,181,61],toColor:[255,254,52]},{fromColor:[255,254,52],toColor:[0,251,50]},{fromColor:[0,251,50],toColor:[255,254,52]},{fromColor:[0,253,255],toColor:[0,181,255]},{fromColor:[0,181,255],toColor:[26,35,253]},{fromColor:[26,35,253],toColor:[255,57,251]},{fromColor:[255,57,251],toColor:[255,45,8]}]},{id:"black-to-white",fromColor:[0,0,0],toColor:[255,255,255]},{id:"blue-bright",fromColor:[204,204,255],toColor:[0,0,224]},{id:"blue-light-to-dark",fromColor:[211,229,232],toColor:[46,100,140]},{id:"blue-green-bright",fromColor:[203,245,234],toColor:[48,207,146]},{id:"blue-green-light-to-dark",fromColor:[216,242,237],toColor:[21,79,74]},{id:"brown-light-to-dark",fromColor:[240,236,170],toColor:[102,72,48]},{id:"brown-to-blue-green-diverging-right",type:"multipart",colorRamps:[{fromColor:[156,85,31],toColor:[255,255,191]},{fromColor:[255,255,191],toColor:[33,130,145]}]},{id:"brown-to-blue-green-diverging-dark",type:"multipart",colorRamps:[{fromColor:[110,70,45],toColor:[204,204,102]},{fromColor:[204,204,102],toColor:[48,100,102]}]},{id:"coefficient-bias",fromColor:[214,214,255],toColor:[0,57,148]},{id:"cold-to-hot-diverging",type:"multipart",colorRamps:[{fromColor:[69,117,181],toColor:[255,255,191]},{fromColor:[255,255,191],toColor:[214,47,39]}]},{id:"condition-number",type:"multipart",colorRamps:[{fromColor:[0,97,0],toColor:[255,255,0]},{fromColor:[255,255,0],toColor:[255,34,0]}]},{id:"cyan-to-purple",type:"multipart",colorRamps:[{fromColor:[0,245,245],toColor:[0,0,245]},{fromColor:[0,0,245],toColor:[245,0,245]}]},{id:"cyan-light-to-blue-dark",type:"multipart",colorRamps:[{fromColor:[182,237,240],toColor:[31,131,224]},{fromColor:[31,131,224],toColor:[9,9,145]}]},{id:"distance",fromColor:[255,200,0],toColor:[0,0,255]},{id:"elevation1",type:"multipart",colorRamps:[{fromColor:[175,240,233],toColor:[255,255,179]},{fromColor:[255,255,179],toColor:[0,128,64]},{fromColor:[0,128,64],toColor:[252,186,3]},{fromColor:[252,186,3],toColor:[128,0,0]},{fromColor:[120,0,0],toColor:[105,48,13]},{fromColor:[105,48,13],toColor:[171,171,171]},{fromColor:[171,171,171],toColor:[255,252,255]}]},{id:"elevation2",type:"multipart",colorRamps:[{fromColor:[118,219,211],toColor:[255,255,199]},{fromColor:[255,255,199],toColor:[255,255,128]},{fromColor:[255,255,128],toColor:[217,194,121]},{fromColor:[217,194,121],toColor:[135,96,38]},{fromColor:[135,96,38],toColor:[150,150,181]},{fromColor:[150,150,181],toColor:[181,150,181]},{fromColor:[181,150,181],toColor:[255,252,255]}]},{id:"errors",fromColor:[255,235,214],toColor:[196,10,10]},{id:"gray-light-to-dark",fromColor:[219,219,219],toColor:[69,69,69]},{id:"green-bright",fromColor:[204,255,204],toColor:[14,204,14]},{id:"green-light-to-dark",fromColor:[220,245,233],toColor:[34,102,51]},{id:"green-to-blue",type:"multipart",colorRamps:[{fromColor:[32,204,16],toColor:[0,242,242]},{fromColor:[0,242,242],toColor:[2,33,227]}]},{id:"orange-bright",fromColor:[255,235,204],toColor:[240,118,5]},{id:"orange-light-to-dark",fromColor:[250,233,212],toColor:[171,65,36]},{id:"partial-spectrum",type:"multipart",colorRamps:[{fromColor:[242,241,162],toColor:[255,255,0]},{fromColor:[255,255,0],toColor:[255,0,0]},{fromColor:[252,3,69],toColor:[176,7,237]},{fromColor:[176,7,237],toColor:[2,29,173]}]},{id:"partial-spectrum-1-diverging",type:"multipart",colorRamps:[{fromColor:[135,38,38],toColor:[240,149,12]},{fromColor:[240,149,12],toColor:[255,255,191]},{fromColor:[255,255,191],toColor:[74,80,181]},{fromColor:[74,80,181],toColor:[39,32,122]}]},{id:"partial-spectrum-2-diverging",type:"multipart",colorRamps:[{fromColor:[115,77,42],toColor:[201,137,52]},{fromColor:[201,137,52],toColor:[255,255,191]},{fromColor:[255,255,191],toColor:[91,63,176]},{fromColor:[91,63,176],toColor:[81,13,97]}]},{id:"pink-to-yellow-green-diverging-bright",type:"multipart",colorRamps:[{fromColor:[158,30,113],toColor:[255,255,191]},{fromColor:[255,255,191],toColor:[99,110,45]}]},{id:"pink-to-yellow-green-diverging-dark",type:"multipart",colorRamps:[{fromColor:[97,47,73],toColor:[204,204,102]},{fromColor:[204,204,102],toColor:[22,59,15]}]},{id:"precipitation",type:"multipart",colorRamps:[{fromColor:[194,82,60],toColor:[237,161,19]},{fromColor:[237,161,19],toColor:[255,255,0]},{fromColor:[255,255,0],toColor:[0,219,0]},{fromColor:[0,219,0],toColor:[32,153,143]},{fromColor:[32,153,143],toColor:[11,44,122]}]},{id:"prediction",type:"multipart",colorRamps:[{fromColor:[40,146,199],toColor:[250,250,100]},{fromColor:[250,250,100],toColor:[232,16,20]}]},{id:"purple-bright",fromColor:[255,204,255],toColor:[199,0,199]},{id:"purple-to-green-diverging-bright",type:"multipart",colorRamps:[{fromColor:[77,32,150],toColor:[255,255,191]},{fromColor:[255,255,191],toColor:[20,122,11]}]},{id:"purple-to-green-diverging-dark",type:"multipart",colorRamps:[{fromColor:[67,14,89],toColor:[204,204,102]},{fromColor:[204,204,102],toColor:[24,79,15]}]},{id:"purple-blue-bright",fromColor:[223,184,230],toColor:[112,12,242]},{id:"purple-blue-light-to-dark",fromColor:[229,213,242],toColor:[93,44,112]},{id:"purple-red-bright",fromColor:[255,204,225],toColor:[199,0,99]},{id:"purple-red-light-to-dark",fromColor:[250,215,246],toColor:[143,17,57]},{id:"red-bright",fromColor:[255,204,204],toColor:[219,0,0]},{id:"red-light-to-dark",fromColor:[255,224,224],toColor:[143,10,10]},{id:"red-to-blue-diverging-bright",type:"multipart",colorRamps:[{fromColor:[196,69,57],toColor:[255,255,191]},{fromColor:[255,255,191],toColor:[48,95,207]}]},{id:"red-to-blue-diverging-dark",type:"multipart",colorRamps:[{fromColor:[107,13,13],toColor:[204,204,102]},{fromColor:[204,204,102],toColor:[13,53,97]}]},{id:"red-to-green",type:"multipart",colorRamps:[{fromColor:[245,0,0],toColor:[245,245,0]},{fromColor:[245,245,0],toColor:[0,245,0]}]},{id:"red-to-green-diverging-bright",type:"multipart",colorRamps:[{fromColor:[186,20,20],toColor:[255,255,191]},{fromColor:[255,255,191],toColor:[54,145,33]}]},{id:"red-to-green-diverging-dark",type:"multipart",colorRamps:[{fromColor:[97,21,13],toColor:[204,204,102]},{fromColor:[204,204,102],toColor:[16,69,16]}]},{id:"slope",type:"multipart",colorRamps:[{fromColor:[56,168,0],toColor:[255,255,0]},{fromColor:[255,255,0],toColor:[255,0,0]}]},{id:"spectrum-full-bright",type:"multipart",colorRamps:[{fromColor:[255,0,0],toColor:[255,255,0]},{fromColor:[255,255,0],toColor:[0,255,255]},{fromColor:[0,255,255],toColor:[0,0,255]}]},{id:"spectrum-full-dark",type:"multipart",colorRamps:[{fromColor:[153,0,0],toColor:[153,153,0]},{fromColor:[153,153,0],toColor:[0,153,153]},{fromColor:[0,153,153],toColor:[0,0,153]}]},{id:"spectrum-full-light",type:"multipart",colorRamps:[{fromColor:[255,153,153],toColor:[255,255,153]},{fromColor:[255,255,153],toColor:[153,255,255]},{fromColor:[153,255,255],toColor:[153,153,255]}]},{id:"surface",type:"multipart",colorRamps:[{fromColor:[112,153,89],toColor:[242,238,162]},{fromColor:[242,238,162],toColor:[242,206,133]},{fromColor:[242,206,133],toColor:[194,140,124]},{fromColor:[194,140,124],toColor:[255,242,255]}]},{id:"temperature",type:"multipart",colorRamps:[{fromColor:[255,252,255],toColor:[255,0,255]},{fromColor:[255,0,255],toColor:[0,0,255]},{fromColor:[0,0,255],toColor:[0,255,255]},{fromColor:[0,255,255],toColor:[0,255,0]},{fromColor:[0,255,0],toColor:[255,255,0]},{fromColor:[255,255,0],toColor:[255,128,0]},{fromColor:[255,128,0],toColor:[128,0,0]}]},{id:"white-to-black",fromColor:[255,255,255],toColor:[0,0,0]},{id:"yellow-to-dark-red",type:"multipart",colorRamps:[{fromColor:[255,255,128],toColor:[242,167,46]},{fromColor:[242,167,46],toColor:[107,0,0]}]},{id:"yellow-to-green-to-dark-blue",type:"multipart",colorRamps:[{fromColor:[255,255,128],toColor:[56,224,9]},{fromColor:[56,224,9],toColor:[26,147,171]},{fromColor:[26,147,171],toColor:[12,16,120]}]},{id:"yellow-to-red",fromColor:[245,245,0],toColor:[255,0,0]},{id:"yellow-green-bright",fromColor:[236,252,204],toColor:[157,204,16]},{id:"yellow-green-light-to-dark",fromColor:[215,240,175],toColor:[96,107,45]}],m=new e({Aspect:"aspect","Black to White":"black-to-white","Blue Bright":"blue-bright","Blue Light to Dark":"blue-light-to-dark","Blue-Green Bright":"blue-green-bright","Blue-Green Light to Dark":"blue-green-light-to-dark","Brown Light to Dark":"brown-light-to-dark","Brown to Blue Green Diverging, Bright":"brown-to-blue-green-diverging-right","Brown to Blue Green Diverging, Dark":"brown-to-blue-green-diverging-dark","Coefficient Bias":"coefficient-bias","Cold to Hot Diverging":"cold-to-hot-diverging","Condition Number":"condition-number","Cyan to Purple":"cyan-to-purple","Cyan-Light to Blue-Dark":"cyan-light-to-blue-dark",Distance:"distance","Elevation #1":"elevation1","Elevation #2":"elevation2",Errors:"errors","Gray Light to Dark":"gray-light-to-dark","Green Bright":"green-bright","Green Light to Dark":"green-light-to-dark","Green to Blue":"green-to-blue","Orange Bright":"orange-bright","Orange Light to Dark":"orange-light-to-dark","Partial Spectrum":"partial-spectrum","Partial Spectrum 1 Diverging":"partial-spectrum-1-diverging","Partial Spectrum 2 Diverging":"partial-spectrum-2-diverging","Pink to YellowGreen Diverging, Bright":"pink-to-yellow-green-diverging-bright","Pink to YellowGreen Diverging, Dark":"pink-to-yellow-green-diverging-dark",Precipitation:"precipitation",Prediction:"prediction","Purple Bright":"purple-bright","Purple to Green Diverging, Bright":"purple-to-green-diverging-bright","Purple to Green Diverging, Dark":"purple-to-green-diverging-dark","Purple-Blue Bright":"purple-blue-bright","Purple-Blue Light to Dark":"purple-blue-light-to-dark","Purple-Red Bright":"purple-red-bright","Purple-Red Light to Dark":"purple-red-light-to-dark","Red Bright":"red-bright","Red Light to Dark":"red-light-to-dark","Red to Blue Diverging, Bright":"red-to-blue-diverging-bright","Red to Blue Diverging, Dark":"red-to-blue-diverging-dark","Red to Green":"red-to-green","Red to Green Diverging, Bright":"red-to-green-diverging-bright","Red to Green Diverging, Dark":"red-to-green-diverging-dark",Slope:"slope","Spectrum-Full Bright":"spectrum-full-bright","Spectrum-Full Dark":"spectrum-full-dark","Spectrum-Full Light":"spectrum-full-light",Surface:"surface",Temperature:"temperature","White to Black":"white-to-black","Yellow to Dark Red":"yellow-to-dark-red","Yellow to Green to Dark Blue":"yellow-to-green-to-dark-blue","Yellow to Red":"yellow-to-red","Yellow-Green Bright":"yellow-green-bright","Yellow-Green Light to Dark":"yellow-green-light-to-dark"});function a(o,r){if(!o||!r||o.length!==r.length)return!1;for(let t=0;t<o.length;t++)if(o[t]>r[t]+2||o[t]<r[t]-2)return!1;return!0}function g(o){const r=o.clone();return r.fromColor=o.toColor,r.toColor=o.fromColor,r}function p(o){if("multipart"===o.type){const r=o.clone();return r.colorRamps?.length?(r.colorRamps=r.colorRamps.reverse().map(o=>g(o)),r):r}return g(o)}function u(o,r){const t=r??C;if("algorithmic"===o.type){const r=o.fromColor.toRgb(),l=o.toColor.toRgb();return t.find(o=>a(r,o.fromColor)&&a(l,o.toColor))?.id}if(o.weights?.length)return;const l=o.colorRamps?.map(o=>({fromColor:o.fromColor.toRgb(),toColor:o.toColor.toRgb()}));return t.find(o=>{const r=o.colorRamps;return!(!l||!r||l.length!==r.length)&&r.every((o,r)=>a(l[r].fromColor,o.fromColor)&&a(l[r].toColor,o.toColor))})?.id}function f(o,r,t=!1){if(!o)return;let l=!1,e=u(o,r);return null!=e||t||(l=!0,e=u(o=p(o),r)),e?{id:e,inverted:l}:void 0}function s(o,r=!1){const t="string"==typeof o?o:f(o,void 0,r)?.id;return t?m.toJSON(t):null}function d(o,r="esriCIELabAlgorithm"){const t=C.find(({id:r})=>r===o);return t?t.colorRamps?{type:"multipart",colorRamps:t.colorRamps.map(o=>({type:"algorithmic",algorithm:r,fromColor:[...o.fromColor],toColor:[...o.toColor]}))}:{type:"algorithmic",algorithm:r,fromColor:[...t.fromColor],toColor:[...t.toColor]}:null}function c(o){o??={};const r=o.numColors||256,t=o.distanceOffset||0,l=null!=o.isCustomInterval?o.isCustomInterval:null!==o.distanceInterval&&o.distanceInterval!==1/(r-1),e=o.distanceInterval||1/(r-1);return{...o,numColors:r,distanceOffset:t,interpolateAlpha:!!o.interpolateAlpha,distanceInterval:e,isCustomInterval:l,weights:o.weights}}function h(o,r,t){const{numColors:l,distanceOffset:e,distanceInterval:i,isCustomInterval:n}=t,C=0===o.s,m=0===r.s;let a=o.h,g=r.h;C&&!m?a=g:m&&!C&&(r={...r,h:a},g=a);let p=Math.abs(g-a),u=0;const f=360;p<f/2?u=(g-a)*i:(p=f-p,u=a>g?p*i:-p*i);const s=(r.s-o.s)*i,d=(r.v-o.v)*i;let{s:c,v:h}=o,b=a;if(e){const o=e/i;b=(b+o*u+f)%f,c+=o*s,h+=o*d}const v=[];for(let y=0;y<l-1;y++)v.push({h:b,s:c,v:h}),b=(b+u+f)%f,c+=s,h+=d;return v.push(n?{h:b,s:c,v:h}:r),v}function b(o,r,t){const{numColors:l,distanceOffset:e,distanceInterval:i,isCustomInterval:n}=t;let{l:C,a:m,b:a}=o;const g=(r.l-C)*i,p=(r.a-m)*i,u=(r.b-a)*i,f=[];if(e){const o=e/i;C+=o*g,m+=o*p,a+=o*u}for(let s=0;s<l-1;s++)f.push({l:C,a:m,b:a}),C+=g,m+=p,a+=u;return f.push(n?{l:C,a:m,b:a}:r),f}function v(o,r,t){const{numColors:l,distanceOffset:e,distanceInterval:i,isCustomInterval:n}=t,C=o.h,m=r.h,a=2*Math.PI;let g=0;if(C<=m){const o=m-C,r=m-C-a;g=Math.abs(r)<Math.abs(o)?r:o}else{const o=m+a-C,r=m-C;g=Math.abs(r)<Math.abs(o)?r:o}const p=g*i,u=(r.l-o.l)*i,f=(r.c-o.c)*i;let{l:s,c:d,h:c}=o;if(e){const o=e/i;s+=o*u,d+=o*f,c=(c+o*p+a)%a}const h=[];for(let b=0;b<l-1;b++)h.push({l:s,c:d,h:c}),s+=u,d+=f,c=(c+p+a)%a;return h.push(n?{l:s,c:d,h:c}:r),h}function y(e,i){const{fromColor:n,toColor:C}=e,m=3===n.length?[...n,255]:[...n],a=3===C.length?[...C,255]:[...C],g=e.algorithm||"esriCIELabAlgorithm",p=c(i),{numColors:u,distanceOffset:f,isCustomInterval:s,interpolateAlpha:d}=p;if(1===u&&0===f)return[m];if(2===u&&0===f&&!s)return[m,a];const y={r:m[0],g:m[1],b:m[2]},k={r:a[0],g:a[1],b:a[2]},R="esriCIELabAlgorithm"===g?b(r(y),r(k),p):"esriHSVAlgorithm"===g?h(o(y),o(k),p):v(t(y),t(k),p),w=[],B=m[3]??255,D=((a[3]??255)-B)/(u-1);for(let o=0;o<u;o++){const{r,g:t,b:e}=l(R[o]),i=d?Math.round(B+D*o):255;w.push([r,t,e,i])}return w}function k(o,r){const{colorRamps:t}=o;if(r??=t.map(({start:o,stop:r})=>null==o||null==r?-1:r-o),r.length!==t.length||r.some(o=>o<0))return Array.from({length:t.length},()=>1/t.length);const l=r.reduce((o,r)=>o+r);return r.map(o=>o/l)}function R(o,r){const{numColors:t,interpolateAlpha:l}=c(r),e=k(o,r?.weights),{colorRamps:i}=o,n=[],C=1/(t-1);let m=0,a=!1;for(let p=0;p<i.length;p++){const o=n.length,r=a?0:o*C-m;m+=e[p];let g=p===i.length-1?t-1-o:(e[p]-r)/C;if(a=Math.ceil(g)===g,g=Math.ceil(g),0===g)continue;const u=y(i[p],{numColors:g,interpolateAlpha:l,distanceOffset:r/e[p],distanceInterval:C/e[p]});n.push(...u)}const g=[...i[i.length-1].toColor];return 3===g.length&&g.push(255),n.push(g),n}function w(o,r){const t=i(o)?o.toJSON():o;return"multipart"===t.type?R(t,r):y(t,r)}function B(o,r){const t=w(o,r),l=r?.interpolateAlpha;return t.forEach((o,r)=>{o.unshift(r),l||o.pop()}),t}function D(r){const t=[];for(let l=0;l<r.length;l+=4){const e=o({r:r[l],g:r[l+1],b:r[l+2]});t.push([e.h/60,e.s/100,255*e.v/100])}return t}function I(r){const t=o(r);return{type:"HsvColor",Hue:t.h,Saturation:t.s,Value:t.v,AlphaValue:255}}function A(o){const r=o.toJSON();return{Algorithm:r?.Algorithm||"esriHSVAlgorithm",type:"AlgorithmicColorRamp",FromColor:I(o.fromColor),ToColor:I(o.toColor)}}function G(o){const r=s(o);if(!r)return null;if("algorithmic"===o.type)return{...A(o),Name:r};if(o.colorRamps){const t=o.colorRamps.map(A);return{type:"MultiPartColorRamp",NumColorRamps:t.length,ArrayOfColorRamp:t,Name:r}}return null}function P(o){const r=[...o].reverse().map(o=>{const r=o.toString(16);return r.length<2?"0"+r:r});return 4294967295&Number.parseInt(r.join(""),16)}export{m as colorRampDict,B as convertColorRampToColormap,w as convertColorRampToColors,P as convertRGBATo32Bit,D as createHsvMap,f as getColorRampId,d as getColorRampJSON,s as getColorRampName,G as getRFxArgColorRampValue,C as predefinedJsonColorRamps,n as rasterColormapNames};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{id as e}from"../kernel.js";import t from"../request.js";import r from"../core/Error.js";import a from"../core/Logger.js";import{isAbortError as n}from"../core/promiseUtils.js";import o from"../geometry/Geometry.js";import d from"../geometry/SpatialReference.js";import{submitJob as i}from"./geoprocessor/submitJob.js";import s from"./knowledgeGraph/GraphQueryResult.js";import p from"./knowledgeGraph/GraphQueryResultHeader.js";import c from"./knowledgeGraph/GraphQueryStreamingResult.js";import l from"./knowledgeGraph/KnowledgeGraph.js";import u from"./knowledgeGraph/ServiceDefinition.js";import{encodeClientDataAtKeysRequest as h}from"./knowledgeGraph/wasmInterface/clientDataToWasmEncodedFactories.js";import{getWasmInterface as w}from"./knowledgeGraph/wasmInterface/knowledgeWasmAccess.js";import{bindParamArrayToWasm as g,setInputQuantizationParametersOnEncoder as y,setOutputQuantizationParametersOnEncoder as f,setProvenanceBehaviorOnEncoder as m,geometryToWasm as _,bindParamObjectToWasm as k}from"./knowledgeGraph/wasmInterface/queryToWasmEncodedFactories.js";import{updateSearchPropertiesToWasm as G,fieldIndexToWasm as b,updateGraphPropertyToWasm as x,graphPropertyToWasm as T,updateEntityTypeToWasm as v,updateRelationshipTypeToWasm as A,entityTypeToWasm as S,relationshipTypeToWasm as P,inputQuantizationParametersToWasmFormat as D,namedObjectToWasm as R}from"./knowledgeGraph/wasmInterface/updateToWasmEncodedFactories.js";import{wasmClientDataAllKeysResponseToClientDataKeys as E,wasmClientDataFetchResponseToClientData as I}from"./knowledgeGraph/wasmInterface/wasmToClientDataFactories.js";import{decoderToAddNamedTypesResult as q,decoderToDeleteNamedTypeResult as C,decoderToUpdateNamedTypesResult as F,decoderToAddGraphPropertiesResult as M,decoderToDeleteGraphPropertiesResult as j,decoderToUpdateGraphPropertiesResult as U,decoderToGraphAddIndexResult as N,decoderToGraphDeleteIndexResult as K,decoderToGraphUpdateSearchIndexResult as Q}from"./knowledgeGraph/wasmInterface/wasmToDataModelChangeResponseFactories.js";import{wasmToDataModel as $}from"./knowledgeGraph/wasmInterface/wasmToDataModelFactories.js";import{wasmToGraphQueryResponseHeader as L,decodedWasmObjToQueryResponseObj as O}from"./knowledgeGraph/wasmInterface/wasmToQueryResponseObjFactories.js";import{decoderToApplyEditsResponse as W}from"./knowledgeGraph/wasmInterface/wasmToUpdateResponseFactories.js";import{checkWasmError as H}from"./knowledgeGraph/wasmInterface/wasmUtils.js";const z=new Map,B=()=>new Map(z.entries()),J={fetchKnowledgeGraph:async e=>{const t=new l({url:e}),r=[];return r.push(he(t)),r.push(we(t)),await Promise.all(r),t},refreshDataModel:async e=>{e.dataModel=await Ye(e)},refreshServiceDefinition:async e=>{const r=(await t(e.url,{query:{f:"json"}})).data;return r.capabilities=r?.capabilities?.split(","),r.supportedQueryFormats=r?.supportedQueryFormats?.split(","),e.serviceDefinition=new u(r),e.serviceDefinition},executeFindPathsAsynchronous:async(e,t)=>{const a=e.inKnowledgeGraphUrl.split("/rest/services");if(a.length<2)throw new r("knowledge-graph:invalid-tool-url","The URL for the KG Service was not correctly formatted. It should contain /rest/services/");const n=a[0],o=(await Ge(`${n}/rest/info`,{query:{f:"json"}})).data.currentVersion,d=`/rest/services/${o&&o<12?"System":"Utilities"}/KnowledgeGraphServerToolsAsync/GPServer/ServerFilteredFindPaths`;return await ke(`${n}${d}`,{in_knowledge_graph_url:e.inKnowledgeGraphUrl,config_type:"STRING",config_string:e.config.toJSON(),result_type:"STRING"},{},t)},executeFindPaths:async(e,t)=>{const a=e.inKnowledgeGraphUrl.split("/rest/services");if(a.length<2)throw new r("knowledge-graph:invalid-tool-url","The URL for the KG Service was not correctly formatted. It should contain /rest/services/");const n=a[0],o=(await Ge(`${n}/rest/info`,{query:{f:"json"}})).data.currentVersion,d=`/rest/services/${o&&o<12?"System":"Utilities"}/KnowledgeGraphServerTools/GPServer/ServerFilteredFindPaths/execute`,i=await Ge(`${n}${d}`,{method:"post",query:{f:"pjson",in_knowledge_graph_url:e.inKnowledgeGraphUrl,config_type:"STRING",config_string:JSON.stringify(e.config),result_type:"STRING"},...t});if(i.data.results.length<1)throw new r("knowledge-graph:no-results","No results were returned from the FindPaths tool - no results returned",i);let s;for(const r of i.data.results)if("out_results_string"===r.paramName){s=r.value;break}if(!s)throw new r("knowledge-graph:no-results","No results were returned from the FindPaths tool - no results were returned on the expected paramater out_results_string",i);return s},fetchAsynchronousFindPathsResultData:async(e,t)=>(await e.fetchResultData("out_results_string",null,t)).value,executeQueryStreaming:async(e,t,a)=>{const n="include",o=`${e.url}/graph/query`;await be(e);const d=await Fe(o,a);if(!e.serviceDefinition?.supportsProvenance&&t.provenanceBehavior===n)throw new r("knowledge-graph:provenance-not-supported","The Knowledge Graph Service definition indicated that provenance is not supported");d.data.body=await qe(t,e);const i=await _e(d.data.url,d.data);if(e.dataModel){const t=await Ve(i,e.dataModel);return new c({resultRowsStream:t.readableStream,resultHeader:t.resultHeader})}throw new r("knowledge-graph:undefined-data-model","The KnowledgeGraph supplied did not have a data model")},executeApplyEdits:async(e,t,a)=>{if(e.serviceDefinition?.dataEditingNotSupported)throw new r("knowledge-graph:data-editing-not-supported","The Knowledge Graph Service definition indicated that data editing is not supported");const n=`${e.url}/graph/applyEdits`;await be(e);const o=await Fe(n,a);o.data.body=await Te(t,e);return je(await _e(o.data.url,o.data))},executeAddNamedTypes:async(e,t,a)=>{if(!t.newEntityTypes?.length&&!t.newRelationshipTypes?.length)throw new r("knowledge-graph:no-arguments","The operation to add types to the data model contained no values");const n=`${e.url}/dataModel/edit/namedTypes/add`;await be(e);const o=await Fe(n,a);o.data.body=await ve(t);const d=await _e(o.data.url,o.data),i=await Ue(d);return i.updatedKnowledgeGraph=await ue(e.url),i},executeDeleteNamedType:async(e,t,a)=>{if(!t)throw new r("knowledge-graph:no-arguments","The operation to delete a named type from the data model contained no value");const n=`${e.url}/dataModel/edit/namedTypes/${t}/delete`;await be(e);const o=await Fe(n,a);o.data.body="";const d=await _e(o.data.url,o.data),i=await Ne(d);return i.updatedKnowledgeGraph=await ue(e.url),i},executeUpdateNamedType:async(e,t,a,n)=>{if(!t&&!Object.keys(a).length)throw new r("knowledge-graph:no-arguments","The operation to update types in the data model contained missing or empty values");const o=`${e.url}/dataModel/edit/namedTypes/${t}/update`;await be(e);const d=await Fe(o,n);d.data.body=await Ae(a,t,e.dataModel);const i=await _e(d.data.url,d.data),s=await Ke(i);return s.updatedKnowledgeGraph=await ue(e.url),s},executeAddGraphProperties:async(e,t,a,n)=>{if(!t&&!a.length)throw new r("knowledge-graph:no-arguments","The operation to add properties to the data model contained missing or empty values");const o=`${e.url}/dataModel/edit/namedTypes/${t}/fields/add`;await be(e);const d=await Fe(o,n);d.data.body=await Se(a);const i=await _e(d.data.url,d.data),s=await Qe(i);return s.updatedKnowledgeGraph=await ue(e.url),s},executeDeleteGraphProperty:async(e,t,a,n)=>{if(!t&&!a)throw new r("knowledge-graph:no-arguments","The operation to delete property contained missing or empty values");const o=`${e.url}/dataModel/edit/namedTypes/${t}/fields/delete`;await be(e);const d=await Fe(o,n);d.data.body=await Pe(a);const i=await _e(d.data.url,d.data),s=await $e(i);return s.updatedKnowledgeGraph=await ue(e.url),s},executeUpdateGraphProperty:async(e,t,a,n,o)=>{if(!t&&!a&&!Object.keys(n).length)throw new r("knowledge-graph:no-arguments","The operation to update properties in the data model contained missing or empty values");const d=`${e.url}/dataModel/edit/namedTypes/${t}/fields/update`;await be(e);const i=await Fe(d,o);i.data.body=await De(a,n);const s=await _e(i.data.url,i.data),p=await Le(s);return p.updatedKnowledgeGraph=await ue(e.url),p},executeAddGraphFieldIndex:async(e,t,a,n)=>{if(!t)throw new r("knowledge-graph:no-arguments","The operation to update search index in the data model contained missing named type");if(!a?.length)throw new r("knowledge-graph:no-arguments","The operation to update search index in the data model contained missing or empty field index values");const o=`${e.url}/dataModel/edit/namedTypes/${t}/indexes/add`;await be(e);const d=await Fe(o,n);d.data.body=await Re(a);const i=await _e(d.data.url,d.data),s=await Oe(i);return s.updatedKnowledgeGraph=await ue(e.url),s},executeDeleteGraphFieldIndex:async(e,t,a,n)=>{if(!t)throw new r("knowledge-graph:no-arguments","The operation to update search index in the data model contained missing named type");if(!a?.length)throw new r("knowledge-graph:no-arguments","The operation to update search index in the data model contained missing or empty field index values");const o=`${e.url}/dataModel/edit/namedTypes/${t}/indexes/delete`;await be(e);const d=await Fe(o,n);d.data.body=await Ee(a);const i=await _e(d.data.url,d.data),s=await We(i);return s.updatedKnowledgeGraph=await ue(e.url),s},executeUpdateSearchIndex:async(e,t,a,n)=>{if(!t)throw new r("knowledge-graph:no-arguments","The operation to update search index in the data model contained missing named type");if(!Object.keys(a.addSearchProperties??{}).length&&!Object.keys(a.removeSearchProperties??{}).length)throw new r("knowledge-graph:no-arguments","The operation to update search index in the data model contained missing or empty properties values");const o=`${e.url}/dataModel/searchIndex/update`;await be(e);const d=await Fe(o,n);d.data.body=await Ie(t,a);const i=await _e(d.data.url,d.data),s=await He(i);return s.updatedKnowledgeGraph=await ue(e.url),s},executeQuery:async(e,a,n)=>{const o=`${e.url}/graph/query`,d=await t(o,{responseType:"array-buffer",query:{f:"pbf",openCypherQuery:a.openCypherQuery,...n?.query},signal:n?.signal,timeout:n?.timeout}),i=d.getHeader?.("content-type"),p=d.data;if(i?.includes("application/x-protobuf")){const t=new((await w()).GraphQueryDecoder);if(t.deleteLater(),e.dataModel){const r=Je({wasmQueryDecoder:t,newArrayBufferToParse:p,dataModel:e.dataModel});return new s({resultRows:r.resultRows,resultHeader:r.resultHeader})}throw new r("knowledge-graph:undefined-data-model","The KnowledgeGraph supplied did not have a data model")}throw new r("knowledge-graph:unexpected-server-response","server returned an unexpected response",{responseType:i,data:d.data})},executeSearch:async(e,a,n)=>{const o=a.typeCategoryFilter,d=`${e.url}/graph/search`,i=await t(d,{responseType:"array-buffer",query:{f:"pbf",searchQuery:`"${a.searchQuery}"`,typeCategoryFilter:o,...n?.query},signal:n?.signal,timeout:n?.timeout}),p=i.getHeader?.("content-type"),c=i.data;if(p?.includes("application/x-protobuf")){const t=new((await w()).GraphQueryDecoder);if(t.deleteLater(),e.dataModel){const r=Je({wasmQueryDecoder:t,newArrayBufferToParse:c,dataModel:e.dataModel});return new s({resultRows:r.resultRows,resultHeader:r.resultHeader})}throw new r("knowledge-graph:undefined-data-model","The KnowledgeGraph supplied did not have a data model")}throw new r("knowledge-graph:unexpected-server-response","server returned an unexpected response",{responseType:p,data:i.data})},executeSearchStreaming:async(e,t,a)=>{const n=`${e.url}/graph/search`;await be(e);const o=await Fe(n,a);o.data.body=await Ce(t);const d=await _e(o.data.url,o.data);if(e.dataModel){const t=await Ve(d,e.dataModel);return new c({resultRowsStream:t.readableStream,resultHeader:t.resultHeader})}throw new r("knowledge-graph:undefined-data-model","The KnowledgeGraph supplied did not have a data model")},fetchClientDataAtKeys:async(e,t,a={ignoreCache:!1})=>{if(!t.length)return new Map;let n=z.get(e.url||"");n||(n=new Map,z.set(e.url||"",n));const o=new Map(n.entries()),d=`${e.url}/clientData/fetch`;t=Array.from(new Set(t));const i=await w(),s=h(t,n,i,a.ignoreCache),p=await Fe(d,a.requestOptions);p.data.body=s;const c=await _e(p.data.url,p.data),l=c.headers.get("content-type");if(l?.includes("application/x-protobuf")){const e=new i.ClientDataFetchResponseDecoder;e.deleteLater();const t=await c.arrayBuffer();return e.decode(new Uint8Array(t)),e.has_error()&&H(e.error,"knowledge-graph:fetchClientDataAtKeys-decoding-error","An error occurred while decoding the client data keys response"),I(e,n,o,a.ignoreCache)}throw new r("knowledge-graph:unexpected-server-response","server returned an unexpected response when fetching client data",{responseType:l,data:c})},fetchAllClientDataKeys:async(e,a)=>{const n=`${e.url}/clientData`,o=await t(n,{responseType:"array-buffer",query:{f:"pbf"},signal:a?.signal,timeout:a?.timeout}),d=o.getHeader?.("content-type"),i=o.data;if(d?.includes("application/x-protobuf")){const e=new((await w()).ClientDataKeysResponseDecoder);return e.deleteLater(),e.decode(new Uint8Array(i)),e.has_error()&&H(e.error,"knowledge-graph:fetchAllClientDataKeys-decoding-error","An error occurred while decoding the client data keys response"),E(e)}throw new r("knowledge-graph:unexpected-server-response","server returned an unexpected response",{responseType:d,data:o.data})},clearClientDataCache:()=>z.clear(),_fetchWrapper:async(e,t)=>fetch(e,t),_submitJobWrapper:async(e,t,r,a)=>i(e,t,r,a),_esriRequestWrapper:async(e,r)=>t(e,r)};async function V(e,t,r){return J.executeApplyEdits(e,t,r)}async function Y(e,t,r){return J.executeAddNamedTypes(e,t,r)}async function X(e,t,r){return J.executeDeleteNamedType(e,t,r)}async function Z(e,t,r,a){return J.executeUpdateNamedType(e,t,r,a)}async function ee(e,t,r,a){return J.executeAddGraphProperties(e,t,r,a)}async function te(e,t,r,a){return J.executeDeleteGraphProperty(e,t,r,a)}async function re(e,t,r,a,n){return J.executeUpdateGraphProperty(e,t,r,a,n)}async function ae(e,t,r,a){return J.executeAddGraphFieldIndex(e,t,r,a)}async function ne(e,t,r,a){return J.executeDeleteGraphFieldIndex(e,t,r,a)}async function oe(e,t,r,a){return J.executeUpdateSearchIndex(e,t,r,a)}async function de(e,t,r){return J.executeQuery(e,t,r)}async function ie(e,t,r){return J.executeQueryStreaming(e,t,r)}async function se(e,t,r){return J.executeSearch(e,t,r)}async function pe(e,t,r){return J.executeSearchStreaming(e,t,r)}function ce(e,t){return J.fetchAllClientDataKeys(e,t)}function le(e,t,r){return J.fetchClientDataAtKeys(e,t,r)}async function ue(e){return J.fetchKnowledgeGraph(e)}async function he(e){return J.refreshDataModel(e)}async function we(e){return J.refreshServiceDefinition(e)}async function ge(e,t){return J.executeFindPathsAsynchronous(e,t)}async function ye(e,t){return J.executeFindPaths(e,t)}async function fe(e,t){return J.fetchAsynchronousFindPathsResultData(e,t)}function me(){return J.clearClientDataCache()}async function _e(e,t){return J._fetchWrapper(e,t)}async function ke(e,t,r,a){return J._submitJobWrapper(e,t,r,a)}async function Ge(e,t){return J._esriRequestWrapper(e,t)}async function be(t){const r=e?.findCredential(t.url);r||(t.dataModel?await Ye(t):await he(t))}function xe(e,t,r,a){null==t?r.set_param_key_value(e,""):"object"!=typeof t||t instanceof Date?r.set_param_key_value(e,t):t instanceof o?r.set_param_key_value(e,_(t,a)):Array.isArray(t)?r.set_param_key_value(e,g(t,a)):r.set_param_key_value(e,k(t,a))}async function Te(e,t){if(t.dataModel||await he(t),!t.dataModel)throw new r("knowledge-graph:data-model-undefined","Encoding could not proceed because a data model was not provided and it could not be determined from the service");const a=await w(),n=!!e.options?.cascadeDelete,o=new a.GraphApplyEditsEncoder(a.SpatialReferenceUtil.WGS84(),e.options?.inputQuantizationParameters?D(e.options?.inputQuantizationParameters):a.InputQuantizationUtil.WGS84_lossless());o.deleteLater(),o.cascade_delete=n;try{let t;e.entityAdds?.forEach(e=>{t=o.add_entity(R(e,a)),H(t,"knowledge-graph:applyEdits-encoding-failed","Attempting to encode the applyEdits - an entity failed to be added to the encoder")}),e.relationshipAdds?.forEach(e=>{if(!e.originId||!e.destinationId)throw new r("knowledge-graph:relationship-origin-destination-missing","When adding a new relationship, you must provide both an origin and destination id on the appropriate class property");t=o.add_relationship(R(e,a)),H(t,"knowledge-graph:applyEdits-encoding-failed","Attempting to encode the applyEdits - a relationship failed to be added to the encoder")}),e.entityUpdates?.forEach(e=>{if(!e.id)throw new r("knowledge-graph:entity-id-missing","When updating an entity or relationship, you must specify the id on the class level property");t=o.update_entity(R(e,a)),H(t,"knowledge-graph:applyEdits-encoding-failed","Attempting to encode the applyEdits - an entity failed to be added to the encoder")}),e.relationshipUpdates?.forEach(e=>{if(!e.id)throw new r("knowledge-graph:relationship-id-missing","When updating an entity or relationship, you must specify the id on the class level property");t=o.update_relationship(R(e,a)),H(t,"knowledge-graph:applyEdits-encoding-failed","Attempting to encode the applyEdits - a relationship failed to be added to the encoder")}),e.entityDeletes?.forEach(e=>{if(!e.typeName)throw new r("knowledge-graph:no-type-name","You must indicate the entity/relationship named object type to apply edits - delete");const t=o.make_delete_helper(e.typeName,!0);t.deleteLater(),e.ids?.forEach(e=>{t.delete_by_id(e)})}),e.relationshipDeletes?.forEach(e=>{if(!e.typeName)throw new r("knowledge-graph:no-type-name","You must indicate the entity/relationship named object type to apply edits - delete");const t=o.make_delete_helper(e.typeName,!1);e.ids?.forEach(e=>{t.delete_by_id(e)})}),o.encode()}catch(i){throw new r("knowledge-graph:applyEdits-encoding-failed","Attempting to encode the applyEdits failed",{error:i})}const d=o.get_encoding_result();return H(d.error,"knowledge-graph:applyEdits-encoding-failed","Attempting to encode the applyEdits failed"),structuredClone(d.get_byte_buffer())}async function ve(e){const t=await w(),a=new t.GraphNamedObjectTypeAddsRequestEncoder;a.deleteLater(),e.newEntityTypes?.forEach(e=>{a.add_entity_type(S(e,t))}),e.newRelationshipTypes?.forEach(e=>{a.add_relationship_type(P(e,t))});try{a.encode()}catch(o){throw new r("knowledge-graph:addNamedTypes-encoding-failed","Attempting to encode the addNamedTypes failed",{error:o})}const n=a.get_encoding_result();return H(n.error,"knowledge-graph:addNamedTypes-encoding-failed","Attempting to encode the addNamedTypes failed"),structuredClone(n.get_byte_buffer())}async function Ae(e,t,a){const n=await w(),o=new n.GraphNamedObjectTypeUpdateRequestEncoder;o.deleteLater();if(a.entityTypes.some(e=>e.name===t))o.update_entity_type(v(e,n));else{if(!a.relationshipTypes.some(e=>e.name===t))throw new r("knowledge-graph:updateNamedType-encoding-failed","The named type you are trying to update does not exist in the data model");o.update_relationship_type(A(e,n))}o.update_alias=e.hasOwnProperty("alias");try{o.encode()}catch(i){throw new r("knowledge-graph:updateNamedType-encoding-failed","Attempting to encode the updateNamedType failed",{error:i})}const d=o.get_encoding_result();return H(d.error,"knowledge-graph:updateNamedType-encoding-failed","Attempting to encode the updateNamedType failed"),structuredClone(d.get_byte_buffer())}async function Se(e){const t=await w(),a=new t.GraphPropertyAddsRequestEncoder;a.deleteLater(),e.forEach(e=>{a.add_graph_property(T(e,t))});try{a.encode()}catch(o){throw new r("knowledge-graph:addGraphProperties-encoding-failed","Attempting to encode the addGraphProperties failed",{error:o})}const n=a.get_encoding_result();return H(n.error,"knowledge-graph:addGraphProperties-encoding-failed","Attempting to encode the addGraphProperties failed"),structuredClone(n.get_byte_buffer())}async function Pe(e){const t=new((await w()).GraphPropertyDeleteRequestEncoder);t.deleteLater(),t.field_name=e;try{t.encode()}catch(n){throw new r("knowledge-graph:deleteGraphProperty-encoding-failed","Attempting to encode the deleteGraphProperty failed",{error:n})}const a=t.get_encoding_result();return H(a.error,"knowledge-graph:deleteGraphProperty-encoding-failed","Attempting to encode the deleteGraphProperty failed"),structuredClone(a.get_byte_buffer())}async function De(e,t){const a=await w(),n=new a.GraphPropertyUpdateRequestEncoder;n.deleteLater(),n.update_graph_property(x(t,a)),n.set_property_name(e),n.update_alias=t.hasOwnProperty("alias"),n.update_editable=t.hasOwnProperty("editable"),n.update_required=t.hasOwnProperty("required"),n.update_visible=t.hasOwnProperty("defaultVisibility"),n.update_default_value=t.hasOwnProperty("defaultValue");try{n.encode()}catch(d){throw new r("knowledge-graph:updateGraphProperty-encoding-failed","Attempting to encode the updateGraphProperty failed",{error:d})}const o=n.get_encoding_result();return H(o.error,"knowledge-graph:updateGraphProperty-encoding-failed","Attempting to encode the updateGraphProperty failed"),structuredClone(o.get_byte_buffer())}async function Re(e){const t=await w(),a=new t.GraphIndexAddsRequestEncoder;a.deleteLater(),e.forEach(e=>{a.add_field_index(b(e,t))});try{a.encode()}catch(o){throw new r("knowledge-graph:addGraphFieldIndex-encoding-failed","Attempting to encode the addGraphFieldIndex failed",{error:o})}const n=a.get_encoding_result();return H(n.error,"knowledge-graph:addGraphFieldIndex-encoding-failed","Attempting to encode the addGraphFieldIndex failed"),structuredClone(n.get_byte_buffer())}async function Ee(e){const t=new((await w()).GraphIndexDeleteRequestEncoder);t.deleteLater(),e.forEach(e=>{t.add_index_name(e)});try{t.encode()}catch(n){throw new r("knowledge-graph:deleteGraphFieldIndex-encoding-failed","Attempting to encode the deleteGraphFieldIndex failed",{error:n})}const a=t.get_encoding_result();return H(a.error,"knowledge-graph:deleteGraphFieldIndex-encoding-failed","Attempting to encode the deleteGraphFieldIndex failed"),structuredClone(a.get_byte_buffer())}async function Ie(e,t){const a=await w(),n=new a.GraphUpdateSearchIndexRequestEncoder;n.deleteLater(),t.hasOwnProperty("addSearchProperties")&&n.insert_add_search_property(e,G(t.addSearchProperties,a)),t.hasOwnProperty("removeSearchProperties")&&n.insert_delete_search_property(e,G(t.removeSearchProperties,a));try{n.encode()}catch(d){throw new r("knowledge-graph:updateSearchIndex-encoding-failed","Attempting to encode the updateSearchIndex failed",{error:d})}const o=n.get_encoding_result();return H(o.error,"knowledge-graph:updateSearchIndex-encoding-failed","Attempting to encode the updateSearchIndex failed"),structuredClone(o.get_byte_buffer())}async function qe(e,t){const a=await w(),n=new a.GraphQueryRequestEncoder;if(n.deleteLater(),e.outputSpatialReference?n.output_spatial_reference={wkid:e.outputSpatialReference.wkid,latestWkid:e.outputSpatialReference.latestWkid,vcsWkid:e.outputSpatialReference.vcsWkid,latestVcsWkid:e.outputSpatialReference.latestVcsWkid,wkt:e.outputSpatialReference.wkt??""}:n.output_spatial_reference=a.SpatialReferenceUtil.WGS84(),n.open_cypher_query=e.openCypherQuery,e.bindParameters)for(const[r,i]of Object.entries(e.bindParameters))xe(r,i,n,a);if(e.bindGeometryQuantizationParameters)y(e.bindGeometryQuantizationParameters,n);else{if(t.dataModel||await he(t),4326!==t.dataModel?.spatialReference?.wkid)throw new r("knowledge-graph:SR-quantization-mismatch","If the DataModel indicates a coordinate system other than WGS84, inputQuantizationParameters must be provided to the query encoder");n.input_quantization_parameters=a.InputQuantizationUtil.WGS84_lossless()}e.outputQuantizationParameters&&f(e.outputQuantizationParameters,n,a),e.provenanceBehavior&&m(e.provenanceBehavior,n);try{n.encode()}catch(d){throw new r("knowledge-graph:query-encoding-failed","Attempting to encode the query failed",{error:d})}const o=n.get_encoding_result();if(0!==o.error.error_code)throw new r("knowledge-graph:query-encoding-failed","Attempting to encode the query failed",{errorCode:o.error.error_code,errorMessage:o.error.error_message});return structuredClone(o.get_byte_buffer())}async function Ce(e){const t=await w(),a=new t.GraphSearchRequestEncoder;if(a.deleteLater(),a.search_query=e.searchQuery,a.type_category_filter=t.esriNamedTypeCategory[e.typeCategoryFilter],!0===e.returnSearchContext&&(a.return_search_context=e.returnSearchContext),null!=e.start&&e.start>0&&(a.start_index=e.start),null!=e.num&&(a.max_num_results=e.num),null!=e.idsFilter&&Array.isArray(e.idsFilter)&&e.idsFilter.length>0)try{a.set_ids_filter(g(e.idsFilter,t))}catch(o){throw new r("knowledge-graph:ids-format-error","Attempting to set ids filter failed. This is usually caused by an incorrectly formatted UUID string",{error:o})}e.namedTypesFilter?.forEach(e=>{a.add_named_type_filter(e)});try{a.encode()}catch(o){throw new r("knowledge-graph:search-encoding-failed","Attempting to encode the search failed",{error:o})}const n=a.get_encoding_result();if(0!==n.error.error_code)throw new r("knowledge-graph:search-encoding-failed","Attempting to get encoding result from the query failed",{errorCode:n.error.error_code,errorMessage:n.error.error_message});return structuredClone(n.get_byte_buffer())}async function Fe(e,r){return t(e,{responseType:"native-request-init",method:"post",query:{f:"pbf",...r?.query},body:"x",headers:{"Content-Type":"application/octet-stream"},signal:r?.signal,timeout:r?.timeout})}async function Me(e,t,a){const n=e.headers.get("content-type");if(n?.includes("application/x-protobuf")){const r=await e.arrayBuffer(),n=new t;try{return n.decode(new Uint8Array(r)),a(n)}finally{n.deleteLater()}}throw new r("knowledge-graph:unexpected-server-response","server returned an unexpected response",{responseType:n,data:await e.text()})}async function je(e){return Me(e,(await w()).GraphApplyEditsDecoder,W)}async function Ue(e){return Me(e,(await w()).GraphNamedObjectTypeAddsResponseDecoder,q)}async function Ne(e){return Me(e,(await w()).GraphNamedObjectTypeDeleteResponseDecoder,C)}async function Ke(e){return Me(e,(await w()).GraphNamedObjectTypeUpdateResponseDecoder,F)}async function Qe(e){return Me(e,(await w()).GraphPropertyAddsResponseDecoder,M)}async function $e(e){return Me(e,(await w()).GraphPropertyDeleteResponseDecoder,j)}async function Le(e){return Me(e,(await w()).GraphPropertyUpdateResponseDecoder,U)}async function Oe(e){return Me(e,(await w()).GraphIndexAddsResponseDecoder,N)}async function We(e){return Me(e,(await w()).GraphIndexDeleteResponseDecoder,K)}async function He(e){return Me(e,(await w()).GraphUpdateSearchIndexResponseDecoder,Q)}let ze=50;function Be(e){ze=e}function Je({wasmQueryDecoder:e,newArrayBufferToParse:t,dataModel:a,decodedHeader:n,limitMaxProcessingTime:o=!1}){t&&e.push_buffer(new Uint8Array(t));const i=[];let s,p,c=0;const l=Date.now();let u=!0;for(;e.next_row();){s&&p||(s=n??L(e),p=s.outSpatialReference??new d({wkid:4326})),c||(c=e.get_header_keys().size());const t=new Array(c);for(let r=0;r<c;r++){const n=e.get_value(r);t[r]=O(n,a,p)}if(i.push(t),o&&Date.now()-l>ze){u=!1;break}}if(e.has_error())throw new r("knowledge-graph:stream-decoding-error","One or more result rows were not successfully decoded - inner row decoding",{errorCode:e.error.error_code,errorMessage:e.error.error_message});return{resultHeader:s,resultRows:i,parsedAllResultsFromBuffer:u}}async function Ve(e,t){const o=e.headers.get("content-type");if(e.headers.get("content-length")&&a.getLogger("esri.rest.knowledgeGraph.knowledgeGraphService").warnOnce("Found `Content-Length` header when expecting a streaming HTTP response! Please investigate whether all intermediate HTTP proxies and/or load balancers are configured such that they don't forcefully buffer the entire response before returning it to the client. A valid HTTP streaming response should use Chunked Transfer Encoding and not have a Content Length defined."),o?.includes("application/x-protobuf")){const o=e.body?.getReader(),d=new((await w()).GraphQueryDecoder);let i,s,c;d.deleteLater();const l=new Promise((e,t)=>{s=e,c=t});let u=!1,h=null;const g=new ReadableStream({pull:async function e(l){if(!o){const e=new r("knowledge-graph:stream-decoding-error","Error reading from stream - reader is undefined");throw c(e),e}const{done:w,value:g}=h?{done:!1,value:null}:await o.read().catch(e=>{throw c(e),o.releaseLock(),e});g&&(h=g);try{if(w){let e;if(d.has_error()?e=new r("knowledge-graph:stream-decoding-error","One or more result rows were not successfully decoded - query stream done",{errorCode:d.error.error_code,errorMessage:d.error.error_message}):u||s(new p),o.releaseLock(),e)throw l.error(e),c(e),e;return void l.close()}const{resultHeader:a,resultRows:n,parsedAllResultsFromBuffer:y}=Je({wasmQueryDecoder:d,newArrayBufferToParse:g,dataModel:t,decodedHeader:i,limitMaxProcessingTime:!0});return y&&(h=null),!i&&a&&(i=a,s(a),u=!0),n.length>0?void l.enqueue(n):await e(l)}catch(y){throw a.getLogger("esri.rest.knowledgeGraph.knowledgeGraphService").error(y),c(y),o.releaseLock(),n(y)?y:new r("knowledge-graph:unexpected-server-response","Error inside streaming data return parsing",{error:y})}}});return{readableStream:g,resultHeader:await l}}throw new r("knowledge-graph:unexpected-server-response","server returned an unexpected response",{responseType:o,data:e.text()})}async function Ye(e){const a=`${e.url}/dataModel/queryDataModel`,n=await t(a,{responseType:"array-buffer",query:{f:"pbf"}}),o=n.getHeader?.("content-type"),d=n.data;if(o?.includes("application/x-protobuf")){const e=(await w()).decode_data_model_from_protocol_buffer(new Uint8Array(d));if(!e)throw new r("knowledge-graph:data-model-decode-failure","The server responded to the data model query, but the response failed to be decoded. This typically occurs when the Knowledge JS API (4.26 or later) is used with an unsupported backend (11.0 or earlier)");return $(e)}throw new r("knowledge-graph:unexpected-server-response","server returned an unexpected response",{responseType:o,data:n.data})}export{be as _checkAuthentication,Ge as _esriRequestWrapper,_e as _fetchWrapper,B as _getClientDataCacheCopy,Be as _setMaxQueryParsingDurationForTesting,ke as _submitJobWrapper,me as clearClientDataCache,z as clientDataCache,ae as executeAddGraphFieldIndex,ee as executeAddGraphProperties,Y as executeAddNamedTypes,V as executeApplyEdits,ne as executeDeleteGraphFieldIndex,te as executeDeleteGraphProperty,X as executeDeleteNamedType,ye as executeFindPaths,ge as executeFindPathsAsynchronous,de as executeQuery,ie as executeQueryStreaming,se as executeSearch,pe as executeSearchStreaming,re as executeUpdateGraphProperty,Z as executeUpdateNamedType,oe as executeUpdateSearchIndex,ce as fetchAllClientDataKeys,fe as fetchAsynchronousFindPathsResultData,le as fetchClientDataAtKeys,ue as fetchKnowledgeGraph,J as kgRestServices,he as refreshDataModel,we as refreshServiceDefinition};
|
|
5
|
+
import{id as e}from"../kernel.js";import t from"../request.js";import r from"../core/Error.js";import a from"../core/Logger.js";import{isAbortError as n}from"../core/promiseUtils.js";import{asArrayBuffer as o}from"../core/typedArrayUtil.js";import d from"../geometry/Geometry.js";import i from"../geometry/SpatialReference.js";import{submitJob as s}from"./geoprocessor/submitJob.js";import p from"./knowledgeGraph/GraphQueryResult.js";import c from"./knowledgeGraph/GraphQueryResultHeader.js";import l from"./knowledgeGraph/GraphQueryStreamingResult.js";import u from"./knowledgeGraph/KnowledgeGraph.js";import h from"./knowledgeGraph/ServiceDefinition.js";import{encodeClientDataAtKeysRequest as w}from"./knowledgeGraph/wasmInterface/clientDataToWasmEncodedFactories.js";import{getWasmInterface as g}from"./knowledgeGraph/wasmInterface/knowledgeWasmAccess.js";import{bindParamArrayToWasm as y,setInputQuantizationParametersOnEncoder as f,setOutputQuantizationParametersOnEncoder as m,setProvenanceBehaviorOnEncoder as _,geometryToWasm as k,bindParamObjectToWasm as G}from"./knowledgeGraph/wasmInterface/queryToWasmEncodedFactories.js";import{updateSearchPropertiesToWasm as b,fieldIndexToWasm as x,updateGraphPropertyToWasm as T,graphPropertyToWasm as v,updateEntityTypeToWasm as A,updateRelationshipTypeToWasm as S,entityTypeToWasm as P,relationshipTypeToWasm as D,inputQuantizationParametersToWasmFormat as R,namedObjectToWasm as E}from"./knowledgeGraph/wasmInterface/updateToWasmEncodedFactories.js";import{wasmClientDataAllKeysResponseToClientDataKeys as I,wasmClientDataFetchResponseToClientData as q}from"./knowledgeGraph/wasmInterface/wasmToClientDataFactories.js";import{decoderToAddNamedTypesResult as C,decoderToDeleteNamedTypeResult as F,decoderToUpdateNamedTypesResult as M,decoderToAddGraphPropertiesResult as j,decoderToDeleteGraphPropertiesResult as U,decoderToUpdateGraphPropertiesResult as N,decoderToGraphAddIndexResult as K,decoderToGraphDeleteIndexResult as Q,decoderToGraphUpdateSearchIndexResult as $}from"./knowledgeGraph/wasmInterface/wasmToDataModelChangeResponseFactories.js";import{wasmToDataModel as L}from"./knowledgeGraph/wasmInterface/wasmToDataModelFactories.js";import{wasmToGraphQueryResponseHeader as O,decodedWasmObjToQueryResponseObj as W}from"./knowledgeGraph/wasmInterface/wasmToQueryResponseObjFactories.js";import{decoderToApplyEditsResponse as H}from"./knowledgeGraph/wasmInterface/wasmToUpdateResponseFactories.js";import{checkWasmError as z}from"./knowledgeGraph/wasmInterface/wasmUtils.js";const B=new Map,J=()=>new Map(B.entries()),V={fetchKnowledgeGraph:async e=>{const t=new u({url:e}),r=[];return r.push(we(t)),r.push(ge(t)),await Promise.all(r),t},refreshDataModel:async e=>{e.dataModel=await Xe(e)},refreshServiceDefinition:async e=>{const r=(await t(e.url,{query:{f:"json"}})).data;return r.capabilities=r?.capabilities?.split(","),r.supportedQueryFormats=r?.supportedQueryFormats?.split(","),e.serviceDefinition=new h(r),e.serviceDefinition},executeFindPathsAsynchronous:async(e,t)=>{const a=e.inKnowledgeGraphUrl.split("/rest/services");if(a.length<2)throw new r("knowledge-graph:invalid-tool-url","The URL for the KG Service was not correctly formatted. It should contain /rest/services/");const n=a[0],o=(await be(`${n}/rest/info`,{query:{f:"json"}})).data.currentVersion,d=`/rest/services/${o&&o<12?"System":"Utilities"}/KnowledgeGraphServerToolsAsync/GPServer/ServerFilteredFindPaths`;return await Ge(`${n}${d}`,{in_knowledge_graph_url:e.inKnowledgeGraphUrl,config_type:"STRING",config_string:e.config.toJSON(),result_type:"STRING"},{},t)},executeFindPaths:async(e,t)=>{const a=e.inKnowledgeGraphUrl.split("/rest/services");if(a.length<2)throw new r("knowledge-graph:invalid-tool-url","The URL for the KG Service was not correctly formatted. It should contain /rest/services/");const n=a[0],o=(await be(`${n}/rest/info`,{query:{f:"json"}})).data.currentVersion,d=`/rest/services/${o&&o<12?"System":"Utilities"}/KnowledgeGraphServerTools/GPServer/ServerFilteredFindPaths/execute`,i=await be(`${n}${d}`,{method:"post",query:{f:"pjson",in_knowledge_graph_url:e.inKnowledgeGraphUrl,config_type:"STRING",config_string:JSON.stringify(e.config),result_type:"STRING"},...t});if(i.data.results.length<1)throw new r("knowledge-graph:no-results","No results were returned from the FindPaths tool - no results returned",i);let s;for(const r of i.data.results)if("out_results_string"===r.paramName){s=r.value;break}if(!s)throw new r("knowledge-graph:no-results","No results were returned from the FindPaths tool - no results were returned on the expected paramater out_results_string",i);return s},fetchAsynchronousFindPathsResultData:async(e,t)=>(await e.fetchResultData("out_results_string",null,t)).value,executeQueryStreaming:async(e,t,a)=>{const n="include",o=`${e.url}/graph/query`;await xe(e);const d=await Me(o,a);if(!e.serviceDefinition?.supportsProvenance&&t.provenanceBehavior===n)throw new r("knowledge-graph:provenance-not-supported","The Knowledge Graph Service definition indicated that provenance is not supported");d.data.body=await Ce(t,e);const i=await ke(d.data.url,d.data);if(e.dataModel){const t=await Ye(i,e.dataModel);return new l({resultRowsStream:t.readableStream,resultHeader:t.resultHeader})}throw new r("knowledge-graph:undefined-data-model","The KnowledgeGraph supplied did not have a data model")},executeApplyEdits:async(e,t,a)=>{if(e.serviceDefinition?.dataEditingNotSupported)throw new r("knowledge-graph:data-editing-not-supported","The Knowledge Graph Service definition indicated that data editing is not supported");const n=`${e.url}/graph/applyEdits`;await xe(e);const o=await Me(n,a);o.data.body=await ve(t,e);return Ue(await ke(o.data.url,o.data))},executeAddNamedTypes:async(e,t,a)=>{if(!t.newEntityTypes?.length&&!t.newRelationshipTypes?.length)throw new r("knowledge-graph:no-arguments","The operation to add types to the data model contained no values");const n=`${e.url}/dataModel/edit/namedTypes/add`;await xe(e);const o=await Me(n,a);o.data.body=await Ae(t);const d=await ke(o.data.url,o.data),i=await Ne(d);return i.updatedKnowledgeGraph=await he(e.url),i},executeDeleteNamedType:async(e,t,a)=>{if(!t)throw new r("knowledge-graph:no-arguments","The operation to delete a named type from the data model contained no value");const n=`${e.url}/dataModel/edit/namedTypes/${t}/delete`;await xe(e);const o=await Me(n,a);o.data.body="";const d=await ke(o.data.url,o.data),i=await Ke(d);return i.updatedKnowledgeGraph=await he(e.url),i},executeUpdateNamedType:async(e,t,a,n)=>{if(!t&&!Object.keys(a).length)throw new r("knowledge-graph:no-arguments","The operation to update types in the data model contained missing or empty values");const o=`${e.url}/dataModel/edit/namedTypes/${t}/update`;await xe(e);const d=await Me(o,n);d.data.body=await Se(a,t,e.dataModel);const i=await ke(d.data.url,d.data),s=await Qe(i);return s.updatedKnowledgeGraph=await he(e.url),s},executeAddGraphProperties:async(e,t,a,n)=>{if(!t&&!a.length)throw new r("knowledge-graph:no-arguments","The operation to add properties to the data model contained missing or empty values");const o=`${e.url}/dataModel/edit/namedTypes/${t}/fields/add`;await xe(e);const d=await Me(o,n);d.data.body=await Pe(a);const i=await ke(d.data.url,d.data),s=await $e(i);return s.updatedKnowledgeGraph=await he(e.url),s},executeDeleteGraphProperty:async(e,t,a,n)=>{if(!t&&!a)throw new r("knowledge-graph:no-arguments","The operation to delete property contained missing or empty values");const o=`${e.url}/dataModel/edit/namedTypes/${t}/fields/delete`;await xe(e);const d=await Me(o,n);d.data.body=await De(a);const i=await ke(d.data.url,d.data),s=await Le(i);return s.updatedKnowledgeGraph=await he(e.url),s},executeUpdateGraphProperty:async(e,t,a,n,o)=>{if(!t&&!a&&!Object.keys(n).length)throw new r("knowledge-graph:no-arguments","The operation to update properties in the data model contained missing or empty values");const d=`${e.url}/dataModel/edit/namedTypes/${t}/fields/update`;await xe(e);const i=await Me(d,o);i.data.body=await Re(a,n);const s=await ke(i.data.url,i.data),p=await Oe(s);return p.updatedKnowledgeGraph=await he(e.url),p},executeAddGraphFieldIndex:async(e,t,a,n)=>{if(!t)throw new r("knowledge-graph:no-arguments","The operation to update search index in the data model contained missing named type");if(!a?.length)throw new r("knowledge-graph:no-arguments","The operation to update search index in the data model contained missing or empty field index values");const o=`${e.url}/dataModel/edit/namedTypes/${t}/indexes/add`;await xe(e);const d=await Me(o,n);d.data.body=await Ee(a);const i=await ke(d.data.url,d.data),s=await We(i);return s.updatedKnowledgeGraph=await he(e.url),s},executeDeleteGraphFieldIndex:async(e,t,a,n)=>{if(!t)throw new r("knowledge-graph:no-arguments","The operation to update search index in the data model contained missing named type");if(!a?.length)throw new r("knowledge-graph:no-arguments","The operation to update search index in the data model contained missing or empty field index values");const o=`${e.url}/dataModel/edit/namedTypes/${t}/indexes/delete`;await xe(e);const d=await Me(o,n);d.data.body=await Ie(a);const i=await ke(d.data.url,d.data),s=await He(i);return s.updatedKnowledgeGraph=await he(e.url),s},executeUpdateSearchIndex:async(e,t,a,n)=>{if(!t)throw new r("knowledge-graph:no-arguments","The operation to update search index in the data model contained missing named type");if(!Object.keys(a.addSearchProperties??{}).length&&!Object.keys(a.removeSearchProperties??{}).length)throw new r("knowledge-graph:no-arguments","The operation to update search index in the data model contained missing or empty properties values");const o=`${e.url}/dataModel/searchIndex/update`;await xe(e);const d=await Me(o,n);d.data.body=await qe(t,a);const i=await ke(d.data.url,d.data),s=await ze(i);return s.updatedKnowledgeGraph=await he(e.url),s},executeQuery:async(e,a,n)=>{const o=`${e.url}/graph/query`,d=await t(o,{responseType:"array-buffer",query:{f:"pbf",openCypherQuery:a.openCypherQuery,...n?.query},signal:n?.signal,timeout:n?.timeout}),i=d.getHeader?.("content-type"),s=d.data;if(i?.includes("application/x-protobuf")){const t=new((await g()).GraphQueryDecoder);if(t.deleteLater(),e.dataModel){const r=Ve({wasmQueryDecoder:t,newArrayBufferToParse:s,dataModel:e.dataModel});return new p({resultRows:r.resultRows,resultHeader:r.resultHeader})}throw new r("knowledge-graph:undefined-data-model","The KnowledgeGraph supplied did not have a data model")}throw new r("knowledge-graph:unexpected-server-response","server returned an unexpected response",{responseType:i,data:d.data})},executeSearch:async(e,a,n)=>{const o=a.typeCategoryFilter,d=`${e.url}/graph/search`,i=await t(d,{responseType:"array-buffer",query:{f:"pbf",searchQuery:`"${a.searchQuery}"`,typeCategoryFilter:o,...n?.query},signal:n?.signal,timeout:n?.timeout}),s=i.getHeader?.("content-type"),c=i.data;if(s?.includes("application/x-protobuf")){const t=new((await g()).GraphQueryDecoder);if(t.deleteLater(),e.dataModel){const r=Ve({wasmQueryDecoder:t,newArrayBufferToParse:c,dataModel:e.dataModel});return new p({resultRows:r.resultRows,resultHeader:r.resultHeader})}throw new r("knowledge-graph:undefined-data-model","The KnowledgeGraph supplied did not have a data model")}throw new r("knowledge-graph:unexpected-server-response","server returned an unexpected response",{responseType:s,data:i.data})},executeSearchStreaming:async(e,t,a)=>{const n=`${e.url}/graph/search`;await xe(e);const o=await Me(n,a);o.data.body=await Fe(t);const d=await ke(o.data.url,o.data);if(e.dataModel){const t=await Ye(d,e.dataModel);return new l({resultRowsStream:t.readableStream,resultHeader:t.resultHeader})}throw new r("knowledge-graph:undefined-data-model","The KnowledgeGraph supplied did not have a data model")},fetchClientDataAtKeys:async(e,t,a={ignoreCache:!1})=>{if(!t.length)return new Map;let n=B.get(e.url||"");n||(n=new Map,B.set(e.url||"",n));const o=new Map(n.entries()),d=`${e.url}/clientData/fetch`;t=Array.from(new Set(t));const i=await g(),s=w(t,n,i,a.ignoreCache),p=await Me(d,a.requestOptions);p.data.body=s;const c=await ke(p.data.url,p.data),l=c.headers.get("content-type");if(l?.includes("application/x-protobuf")){const e=new i.ClientDataFetchResponseDecoder;e.deleteLater();const t=await c.arrayBuffer();return e.decode(new Uint8Array(t)),e.has_error()&&z(e.error,"knowledge-graph:fetchClientDataAtKeys-decoding-error","An error occurred while decoding the client data keys response"),q(e,n,o,a.ignoreCache)}throw new r("knowledge-graph:unexpected-server-response","server returned an unexpected response when fetching client data",{responseType:l,data:c})},fetchAllClientDataKeys:async(e,a)=>{const n=`${e.url}/clientData`,o=await t(n,{responseType:"array-buffer",query:{f:"pbf"},signal:a?.signal,timeout:a?.timeout}),d=o.getHeader?.("content-type"),i=o.data;if(d?.includes("application/x-protobuf")){const e=new((await g()).ClientDataKeysResponseDecoder);return e.deleteLater(),e.decode(new Uint8Array(i)),e.has_error()&&z(e.error,"knowledge-graph:fetchAllClientDataKeys-decoding-error","An error occurred while decoding the client data keys response"),I(e)}throw new r("knowledge-graph:unexpected-server-response","server returned an unexpected response",{responseType:d,data:o.data})},clearClientDataCache:()=>B.clear(),_fetchWrapper:async(e,t)=>fetch(e,t),_submitJobWrapper:async(e,t,r,a)=>s(e,t,r,a),_esriRequestWrapper:async(e,r)=>t(e,r)};async function Y(e,t,r){return V.executeApplyEdits(e,t,r)}async function X(e,t,r){return V.executeAddNamedTypes(e,t,r)}async function Z(e,t,r){return V.executeDeleteNamedType(e,t,r)}async function ee(e,t,r,a){return V.executeUpdateNamedType(e,t,r,a)}async function te(e,t,r,a){return V.executeAddGraphProperties(e,t,r,a)}async function re(e,t,r,a){return V.executeDeleteGraphProperty(e,t,r,a)}async function ae(e,t,r,a,n){return V.executeUpdateGraphProperty(e,t,r,a,n)}async function ne(e,t,r,a){return V.executeAddGraphFieldIndex(e,t,r,a)}async function oe(e,t,r,a){return V.executeDeleteGraphFieldIndex(e,t,r,a)}async function de(e,t,r,a){return V.executeUpdateSearchIndex(e,t,r,a)}async function ie(e,t,r){return V.executeQuery(e,t,r)}async function se(e,t,r){return V.executeQueryStreaming(e,t,r)}async function pe(e,t,r){return V.executeSearch(e,t,r)}async function ce(e,t,r){return V.executeSearchStreaming(e,t,r)}function le(e,t){return V.fetchAllClientDataKeys(e,t)}function ue(e,t,r){return V.fetchClientDataAtKeys(e,t,r)}async function he(e){return V.fetchKnowledgeGraph(e)}async function we(e){return V.refreshDataModel(e)}async function ge(e){return V.refreshServiceDefinition(e)}async function ye(e,t){return V.executeFindPathsAsynchronous(e,t)}async function fe(e,t){return V.executeFindPaths(e,t)}async function me(e,t){return V.fetchAsynchronousFindPathsResultData(e,t)}function _e(){return V.clearClientDataCache()}async function ke(e,t){return V._fetchWrapper(e,t)}async function Ge(e,t,r,a){return V._submitJobWrapper(e,t,r,a)}async function be(e,t){return V._esriRequestWrapper(e,t)}async function xe(t){const r=e?.findCredential(t.url);r||(t.dataModel?await Xe(t):await we(t))}function Te(e,t,r,a){null==t?r.set_param_key_value(e,""):"object"!=typeof t||t instanceof Date?r.set_param_key_value(e,t):t instanceof d?r.set_param_key_value(e,k(t,a)):Array.isArray(t)?r.set_param_key_value(e,y(t,a)):r.set_param_key_value(e,G(t,a))}async function ve(e,t){if(t.dataModel||await we(t),!t.dataModel)throw new r("knowledge-graph:data-model-undefined","Encoding could not proceed because a data model was not provided and it could not be determined from the service");const a=await g(),n=!!e.options?.cascadeDelete,d=new a.GraphApplyEditsEncoder(a.SpatialReferenceUtil.WGS84(),e.options?.inputQuantizationParameters?R(e.options?.inputQuantizationParameters):a.InputQuantizationUtil.WGS84_lossless());d.deleteLater(),d.cascade_delete=n;try{let t;e.entityAdds?.forEach(e=>{t=d.add_entity(E(e,a)),z(t,"knowledge-graph:applyEdits-encoding-failed","Attempting to encode the applyEdits - an entity failed to be added to the encoder")}),e.relationshipAdds?.forEach(e=>{if(!e.originId||!e.destinationId)throw new r("knowledge-graph:relationship-origin-destination-missing","When adding a new relationship, you must provide both an origin and destination id on the appropriate class property");t=d.add_relationship(E(e,a)),z(t,"knowledge-graph:applyEdits-encoding-failed","Attempting to encode the applyEdits - a relationship failed to be added to the encoder")}),e.entityUpdates?.forEach(e=>{if(!e.id)throw new r("knowledge-graph:entity-id-missing","When updating an entity or relationship, you must specify the id on the class level property");t=d.update_entity(E(e,a)),z(t,"knowledge-graph:applyEdits-encoding-failed","Attempting to encode the applyEdits - an entity failed to be added to the encoder")}),e.relationshipUpdates?.forEach(e=>{if(!e.id)throw new r("knowledge-graph:relationship-id-missing","When updating an entity or relationship, you must specify the id on the class level property");t=d.update_relationship(E(e,a)),z(t,"knowledge-graph:applyEdits-encoding-failed","Attempting to encode the applyEdits - a relationship failed to be added to the encoder")}),e.entityDeletes?.forEach(e=>{if(!e.typeName)throw new r("knowledge-graph:no-type-name","You must indicate the entity/relationship named object type to apply edits - delete");const t=d.make_delete_helper(e.typeName,!0);t.deleteLater(),e.ids?.forEach(e=>{t.delete_by_id(e)})}),e.relationshipDeletes?.forEach(e=>{if(!e.typeName)throw new r("knowledge-graph:no-type-name","You must indicate the entity/relationship named object type to apply edits - delete");const t=d.make_delete_helper(e.typeName,!1);e.ids?.forEach(e=>{t.delete_by_id(e)})}),d.encode()}catch(s){throw new r("knowledge-graph:applyEdits-encoding-failed","Attempting to encode the applyEdits failed",{error:s})}const i=d.get_encoding_result();return z(i.error,"knowledge-graph:applyEdits-encoding-failed","Attempting to encode the applyEdits failed"),o(structuredClone(i.get_byte_buffer()))}async function Ae(e){const t=await g(),a=new t.GraphNamedObjectTypeAddsRequestEncoder;a.deleteLater(),e.newEntityTypes?.forEach(e=>{a.add_entity_type(P(e,t))}),e.newRelationshipTypes?.forEach(e=>{a.add_relationship_type(D(e,t))});try{a.encode()}catch(d){throw new r("knowledge-graph:addNamedTypes-encoding-failed","Attempting to encode the addNamedTypes failed",{error:d})}const n=a.get_encoding_result();return z(n.error,"knowledge-graph:addNamedTypes-encoding-failed","Attempting to encode the addNamedTypes failed"),o(structuredClone(n.get_byte_buffer()))}async function Se(e,t,a){const n=await g(),d=new n.GraphNamedObjectTypeUpdateRequestEncoder;d.deleteLater();if(a.entityTypes.some(e=>e.name===t))d.update_entity_type(A(e,n));else{if(!a.relationshipTypes.some(e=>e.name===t))throw new r("knowledge-graph:updateNamedType-encoding-failed","The named type you are trying to update does not exist in the data model");d.update_relationship_type(S(e,n))}d.update_alias=e.hasOwnProperty("alias");try{d.encode()}catch(s){throw new r("knowledge-graph:updateNamedType-encoding-failed","Attempting to encode the updateNamedType failed",{error:s})}const i=d.get_encoding_result();return z(i.error,"knowledge-graph:updateNamedType-encoding-failed","Attempting to encode the updateNamedType failed"),o(structuredClone(i.get_byte_buffer()))}async function Pe(e){const t=await g(),a=new t.GraphPropertyAddsRequestEncoder;a.deleteLater(),e.forEach(e=>{a.add_graph_property(v(e,t))});try{a.encode()}catch(d){throw new r("knowledge-graph:addGraphProperties-encoding-failed","Attempting to encode the addGraphProperties failed",{error:d})}const n=a.get_encoding_result();return z(n.error,"knowledge-graph:addGraphProperties-encoding-failed","Attempting to encode the addGraphProperties failed"),o(structuredClone(n.get_byte_buffer()))}async function De(e){const t=new((await g()).GraphPropertyDeleteRequestEncoder);t.deleteLater(),t.field_name=e;try{t.encode()}catch(n){throw new r("knowledge-graph:deleteGraphProperty-encoding-failed","Attempting to encode the deleteGraphProperty failed",{error:n})}const a=t.get_encoding_result();return z(a.error,"knowledge-graph:deleteGraphProperty-encoding-failed","Attempting to encode the deleteGraphProperty failed"),o(structuredClone(a.get_byte_buffer()))}async function Re(e,t){const a=await g(),n=new a.GraphPropertyUpdateRequestEncoder;n.deleteLater(),n.update_graph_property(T(t,a)),n.set_property_name(e),n.update_alias=t.hasOwnProperty("alias"),n.update_editable=t.hasOwnProperty("editable"),n.update_required=t.hasOwnProperty("required"),n.update_visible=t.hasOwnProperty("defaultVisibility"),n.update_default_value=t.hasOwnProperty("defaultValue");try{n.encode()}catch(i){throw new r("knowledge-graph:updateGraphProperty-encoding-failed","Attempting to encode the updateGraphProperty failed",{error:i})}const d=n.get_encoding_result();return z(d.error,"knowledge-graph:updateGraphProperty-encoding-failed","Attempting to encode the updateGraphProperty failed"),o(structuredClone(d.get_byte_buffer()))}async function Ee(e){const t=await g(),a=new t.GraphIndexAddsRequestEncoder;a.deleteLater(),e.forEach(e=>{a.add_field_index(x(e,t))});try{a.encode()}catch(d){throw new r("knowledge-graph:addGraphFieldIndex-encoding-failed","Attempting to encode the addGraphFieldIndex failed",{error:d})}const n=a.get_encoding_result();return z(n.error,"knowledge-graph:addGraphFieldIndex-encoding-failed","Attempting to encode the addGraphFieldIndex failed"),o(structuredClone(n.get_byte_buffer()))}async function Ie(e){const t=new((await g()).GraphIndexDeleteRequestEncoder);t.deleteLater(),e.forEach(e=>{t.add_index_name(e)});try{t.encode()}catch(n){throw new r("knowledge-graph:deleteGraphFieldIndex-encoding-failed","Attempting to encode the deleteGraphFieldIndex failed",{error:n})}const a=t.get_encoding_result();return z(a.error,"knowledge-graph:deleteGraphFieldIndex-encoding-failed","Attempting to encode the deleteGraphFieldIndex failed"),o(structuredClone(a.get_byte_buffer()))}async function qe(e,t){const a=await g(),n=new a.GraphUpdateSearchIndexRequestEncoder;n.deleteLater(),t.hasOwnProperty("addSearchProperties")&&n.insert_add_search_property(e,b(t.addSearchProperties,a)),t.hasOwnProperty("removeSearchProperties")&&n.insert_delete_search_property(e,b(t.removeSearchProperties,a));try{n.encode()}catch(i){throw new r("knowledge-graph:updateSearchIndex-encoding-failed","Attempting to encode the updateSearchIndex failed",{error:i})}const d=n.get_encoding_result();return z(d.error,"knowledge-graph:updateSearchIndex-encoding-failed","Attempting to encode the updateSearchIndex failed"),o(structuredClone(d.get_byte_buffer()))}async function Ce(e,t){const a=await g(),n=new a.GraphQueryRequestEncoder;if(n.deleteLater(),e.outputSpatialReference?n.output_spatial_reference={wkid:e.outputSpatialReference.wkid,latestWkid:e.outputSpatialReference.latestWkid,vcsWkid:e.outputSpatialReference.vcsWkid,latestVcsWkid:e.outputSpatialReference.latestVcsWkid,wkt:e.outputSpatialReference.wkt??""}:n.output_spatial_reference=a.SpatialReferenceUtil.WGS84(),n.open_cypher_query=e.openCypherQuery,e.bindParameters)for(const[r,o]of Object.entries(e.bindParameters))Te(r,o,n,a);if(e.bindGeometryQuantizationParameters)f(e.bindGeometryQuantizationParameters,n);else{if(t.dataModel||await we(t),4326!==t.dataModel?.spatialReference?.wkid)throw new r("knowledge-graph:SR-quantization-mismatch","If the DataModel indicates a coordinate system other than WGS84, inputQuantizationParameters must be provided to the query encoder");n.input_quantization_parameters=a.InputQuantizationUtil.WGS84_lossless()}e.outputQuantizationParameters&&m(e.outputQuantizationParameters,n,a),e.provenanceBehavior&&_(e.provenanceBehavior,n);try{n.encode()}catch(i){throw new r("knowledge-graph:query-encoding-failed","Attempting to encode the query failed",{error:i})}const d=n.get_encoding_result();if(0!==d.error.error_code)throw new r("knowledge-graph:query-encoding-failed","Attempting to encode the query failed",{errorCode:d.error.error_code,errorMessage:d.error.error_message});return o(structuredClone(d.get_byte_buffer()))}async function Fe(e){const t=await g(),a=new t.GraphSearchRequestEncoder;if(a.deleteLater(),a.search_query=e.searchQuery,a.type_category_filter=t.esriNamedTypeCategory[e.typeCategoryFilter],!0===e.returnSearchContext&&(a.return_search_context=e.returnSearchContext),null!=e.start&&e.start>0&&(a.start_index=e.start),null!=e.num&&(a.max_num_results=e.num),null!=e.idsFilter&&Array.isArray(e.idsFilter)&&e.idsFilter.length>0)try{a.set_ids_filter(y(e.idsFilter,t))}catch(d){throw new r("knowledge-graph:ids-format-error","Attempting to set ids filter failed. This is usually caused by an incorrectly formatted UUID string",{error:d})}e.namedTypesFilter?.forEach(e=>{a.add_named_type_filter(e)});try{a.encode()}catch(d){throw new r("knowledge-graph:search-encoding-failed","Attempting to encode the search failed",{error:d})}const n=a.get_encoding_result();if(0!==n.error.error_code)throw new r("knowledge-graph:search-encoding-failed","Attempting to get encoding result from the query failed",{errorCode:n.error.error_code,errorMessage:n.error.error_message});return o(structuredClone(n.get_byte_buffer()))}async function Me(e,r){return t(e,{responseType:"native-request-init",method:"post",query:{f:"pbf",...r?.query},body:"x",headers:{"Content-Type":"application/octet-stream"},signal:r?.signal,timeout:r?.timeout})}async function je(e,t,a){const n=e.headers.get("content-type");if(n?.includes("application/x-protobuf")){const r=await e.arrayBuffer(),n=new t;try{return n.decode(new Uint8Array(r)),a(n)}finally{n.deleteLater()}}throw new r("knowledge-graph:unexpected-server-response","server returned an unexpected response",{responseType:n,data:await e.text()})}async function Ue(e){return je(e,(await g()).GraphApplyEditsDecoder,H)}async function Ne(e){return je(e,(await g()).GraphNamedObjectTypeAddsResponseDecoder,C)}async function Ke(e){return je(e,(await g()).GraphNamedObjectTypeDeleteResponseDecoder,F)}async function Qe(e){return je(e,(await g()).GraphNamedObjectTypeUpdateResponseDecoder,M)}async function $e(e){return je(e,(await g()).GraphPropertyAddsResponseDecoder,j)}async function Le(e){return je(e,(await g()).GraphPropertyDeleteResponseDecoder,U)}async function Oe(e){return je(e,(await g()).GraphPropertyUpdateResponseDecoder,N)}async function We(e){return je(e,(await g()).GraphIndexAddsResponseDecoder,K)}async function He(e){return je(e,(await g()).GraphIndexDeleteResponseDecoder,Q)}async function ze(e){return je(e,(await g()).GraphUpdateSearchIndexResponseDecoder,$)}let Be=50;function Je(e){Be=e}function Ve({wasmQueryDecoder:e,newArrayBufferToParse:t,dataModel:a,decodedHeader:n,limitMaxProcessingTime:o=!1}){t&&e.push_buffer(new Uint8Array(t));const d=[];let s,p,c=0;const l=Date.now();let u=!0;for(;e.next_row();){s&&p||(s=n??O(e),p=s.outSpatialReference??new i({wkid:4326})),c||(c=e.get_header_keys().size());const t=new Array(c);for(let r=0;r<c;r++){const n=e.get_value(r);t[r]=W(n,a,p)}if(d.push(t),o&&Date.now()-l>Be){u=!1;break}}if(e.has_error())throw new r("knowledge-graph:stream-decoding-error","One or more result rows were not successfully decoded - inner row decoding",{errorCode:e.error.error_code,errorMessage:e.error.error_message});return{resultHeader:s,resultRows:d,parsedAllResultsFromBuffer:u}}async function Ye(e,t){const o=e.headers.get("content-type");if(e.headers.get("content-length")&&a.getLogger("esri.rest.knowledgeGraph.knowledgeGraphService").warnOnce("Found `Content-Length` header when expecting a streaming HTTP response! Please investigate whether all intermediate HTTP proxies and/or load balancers are configured such that they don't forcefully buffer the entire response before returning it to the client. A valid HTTP streaming response should use Chunked Transfer Encoding and not have a Content Length defined."),o?.includes("application/x-protobuf")){const o=e.body?.getReader(),d=new((await g()).GraphQueryDecoder);let i,s,p;d.deleteLater();const l=new Promise((e,t)=>{s=e,p=t});let u=!1,h=null;const w=new ReadableStream({pull:async function e(l){if(!o){const e=new r("knowledge-graph:stream-decoding-error","Error reading from stream - reader is undefined");throw p(e),e}const{done:w,value:g}=h?{done:!1,value:null}:await o.read().catch(e=>{throw p(e),o.releaseLock(),e});g&&(h=g);try{if(w){let e;if(d.has_error()?e=new r("knowledge-graph:stream-decoding-error","One or more result rows were not successfully decoded - query stream done",{errorCode:d.error.error_code,errorMessage:d.error.error_message}):u||s(new c),o.releaseLock(),e)throw l.error(e),p(e),e;return void l.close()}const{resultHeader:a,resultRows:n,parsedAllResultsFromBuffer:y}=Ve({wasmQueryDecoder:d,newArrayBufferToParse:g,dataModel:t,decodedHeader:i,limitMaxProcessingTime:!0});return y&&(h=null),!i&&a&&(i=a,s(a),u=!0),n.length>0?void l.enqueue(n):await e(l)}catch(y){throw a.getLogger("esri.rest.knowledgeGraph.knowledgeGraphService").error(y),p(y),o.releaseLock(),n(y)?y:new r("knowledge-graph:unexpected-server-response","Error inside streaming data return parsing",{error:y})}}});return{readableStream:w,resultHeader:await l}}throw new r("knowledge-graph:unexpected-server-response","server returned an unexpected response",{responseType:o,data:e.text()})}async function Xe(e){const a=`${e.url}/dataModel/queryDataModel`,n=await t(a,{responseType:"array-buffer",query:{f:"pbf"}}),o=n.getHeader?.("content-type"),d=n.data;if(o?.includes("application/x-protobuf")){const e=(await g()).decode_data_model_from_protocol_buffer(new Uint8Array(d));if(!e)throw new r("knowledge-graph:data-model-decode-failure","The server responded to the data model query, but the response failed to be decoded. This typically occurs when the Knowledge JS API (4.26 or later) is used with an unsupported backend (11.0 or earlier)");return L(e)}throw new r("knowledge-graph:unexpected-server-response","server returned an unexpected response",{responseType:o,data:n.data})}export{xe as _checkAuthentication,be as _esriRequestWrapper,ke as _fetchWrapper,J as _getClientDataCacheCopy,Je as _setMaxQueryParsingDurationForTesting,Ge as _submitJobWrapper,_e as clearClientDataCache,B as clientDataCache,ne as executeAddGraphFieldIndex,te as executeAddGraphProperties,X as executeAddNamedTypes,Y as executeApplyEdits,oe as executeDeleteGraphFieldIndex,re as executeDeleteGraphProperty,Z as executeDeleteNamedType,fe as executeFindPaths,ye as executeFindPathsAsynchronous,ie as executeQuery,se as executeQueryStreaming,pe as executeSearch,ce as executeSearchStreaming,ae as executeUpdateGraphProperty,ee as executeUpdateNamedType,de as executeUpdateSearchIndex,le as fetchAllClientDataKeys,me as fetchAsynchronousFindPathsResultData,ue as fetchClientDataAtKeys,he as fetchKnowledgeGraph,V as kgRestServices,we as refreshDataModel,ge as refreshServiceDefinition};
|
package/support/requestUtils.js
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import r from"../config.js";import
|
|
5
|
+
import r from"../config.js";import{isAborted as e}from"../core/promiseUtils.js";import{getOrigin as t,hasSameOrigin as o,changeHost as n,getAppUrl as s,urlToObject as i}from"../core/urlUtils.js";import{parse as c}from"../layers/support/arcgisLayerUrl.js";import{isSecureProxyService as a}from"../portal/support/urlUtils.js";function u(r,t,o=!1,n){return new Promise((s,i)=>{if(e(n))return void i(f());let c=()=>{l(),i(new Error(`Unable to load ${t}`))},a=async()=>{const e=r;try{await e.decode()}catch{}l(),s(e)},u=()=>{if(!r)return;const e=r;l(),e.src="",i(f())};const l=()=>{r&&(r.removeEventListener("error",c),r.removeEventListener("load",a),c=null,a=null,r=null,n?.removeEventListener("abort",u),u=null,o&&URL.revokeObjectURL(t))};n?.addEventListener("abort",u),r.addEventListener("error",c),r.addEventListener("load",a)})}function f(){try{return new DOMException("Aborted","AbortError")}catch{const r=new Error;return r.name="AbortError",r}}const l="Timeout exceeded";function m(){return new Error(l)}function p(r){return"object"==typeof r&&!!r&&"message"in r&&r.message===l}function d(e){r.request.crossOriginNoCorsDomains||(r.request.crossOriginNoCorsDomains={});const o=r.request.crossOriginNoCorsDomains;for(let r of e)r=r.toLowerCase(),/^https?:\/\//.test(r)?o[t(r)??""]=0:(o[t("http://"+r)??""]=0,o[t("https://"+r)??""]=0)}function w(e){const n=r.request.crossOriginNoCorsDomains;if(n){let r=t(e);if(r)return r=r.toLowerCase(),!o(r,s())&&n[r]<Date.now()-36e5}return!1}async function L(e){const o=i(e);e=o.path,"json"===o.query?.f&&(e+="?f=json");try{await fetch(e,{mode:"no-cors",credentials:"include"})}catch{}const n=r.request.crossOriginNoCorsDomains,s=t(e);n&&s&&(n[s.toLowerCase()]=Date.now())}const v=new Map;function h(r,e){const t=e?.preferredHost;if(!t||o(r,`https://${t}`,!0))return;const n=c(r);if(!n||"FeatureServer"!==n.serverType||a(r))return;const s=n.url.path.toLowerCase();v.has(s)||v.set(s,t)}function E(r){const e=c(r)?.url.path.toLowerCase();if(!e)return r;const t=v.get(e);return t?n(r,t):r}export{m as createTimeoutError,E as getPreferredUrl,w as isNoCorsRequestRequired,p as isTimeoutError,u as loadImageAsync,v as preferredHosts,d as registerNoCorsDomains,L as sendNoCorsRequest,h as setPreferredHost};
|
package/support/revision.js
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
const
|
|
5
|
+
const a="20250808",b="2a9f3b0219ac36efb1436ca51ab549875e257209";export{a as buildDate,b as commitHash};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{defaultFontFamily as t}from"../../core/fontUtils.js";import has from"../../core/has.js";import{clone as e}from"../../core/lang.js";import r from"../../core/Logger.js";import{deg2rad as i}from"../../core/mathUtils.js";import s from"../../core/ObjectPool.js";import{px2pt as o,pt2px as n}from"../../core/screenUtils.js";import{GeometryCursor as a}from"../../geometry/GeometryCursor.js";import{create as l,fromValues as h,empty as c,expandPointInPlace as m,center as f,width as u,height as d,diagonal as g}from"../../geometry/support/aaBoundingRect.js";import{getBoundsXY as p}from"../../geometry/support/boundsUtils.js";import{polygonCentroid as _}from"../../geometry/support/centroid.js";import{isExtent as y,isPolygon as P,isPolyline as S,isMultipoint as w,isPoint as x}from"../../geometry/support/jsonUtils.js";import{SimpleEffectCursor as M}from"./CIMEffects.js";import b from"./CIMImageColorSubstitutionHelper.js";import{getEffectOperator as k,getPlacementOperator as C}from"./CIMOperators.js";import{Placement as v}from"./CIMPlacements.js";import{defaultCIMValues as I}from"./defaultCIMValues.js";import{getFirstFrame as T}from"./imageUtils.js";import{rotate as R}from"./mathUtils.js";import{addColorStops as z}from"./rasterizingUtils.js";import L from"./Rect.js";import F from"./TextRasterizer.js";import{isCIMFill as U,getSize as A,getNumericValue as j,isSVGImage as G,getRelativeGradientSize as D,fromCIMFontDecoration as H,fromCIMFontStyle as B,fromCIMHorizontalAlignment as E,fromCIMVerticalAlignment as X,getFillColor as J,getStrokeColor as N,getStrokeWidth as O,getFontWeight as q,getFontStyle as V}from"./utils.js";import{destroyHiddenSvg as W,createHiddenSvg as Y,createSvgElement as $}from"../../views/2d/engine/svgUtils.js";import{magicLabelLineHeight as K,glyphSize as Q,hittestToleranceSmallSymbol as Z,hittestSmallSymbolThreshold as tt}from"../../views/2d/engine/webgl/definitions.js";import{shapeGlyphs as et}from"../../views/2d/engine/webgl/mesh/templates/shapingUtils.js";import{roundPtToWholePixel as rt,getLineWidth as it}from"../../views/2d/layers/graphics/graphicsUtils.js";const st=Math.PI/180,ot=.5,nt=()=>r.getLogger("esri.symbols.cim.CIMSymbolDrawHelper");class at{constructor(t){this._t=t}static createIdentity(){return new at([1,0,0,0,1,0])}clone(){const t=this._t;return new at(t.slice())}transform(t){const e=this._t;return[e[0]*t[0]+e[1]*t[1]+e[2],e[3]*t[0]+e[4]*t[1]+e[5]]}static createScale(t,e){return new at([t,0,0,0,e,0])}scale(t,e){const r=this._t;return r[0]*=t,r[1]*=t,r[2]*=t,r[3]*=e,r[4]*=e,r[5]*=e,this}scaleRatio(){return Math.sqrt(this._t[0]*this._t[0]+this._t[1]*this._t[1])}static createTranslate(t,e){return new at([0,0,t,0,0,e])}translate(t,e){const r=this._t;return r[2]+=t,r[5]+=e,this}static createRotate(t){const e=Math.cos(t),r=Math.sin(t);return new at([e,-r,0,r,e,0])}rotate(t){return at.multiply(this,at.createRotate(t),this)}angle(){const t=this._t[0],e=this._t[3],r=Math.sqrt(t*t+e*e);return[t/r,e/r]}static multiply(t,e,r){const i=t._t,s=e._t,o=i[0]*s[0]+i[3]*s[1],n=i[1]*s[0]+i[4]*s[1],a=i[2]*s[0]+i[5]*s[1]+s[2],l=i[0]*s[3]+i[3]*s[4],h=i[1]*s[3]+i[4]*s[4],c=i[2]*s[3]+i[5]*s[4]+s[5],m=r._t;return m[0]=o,m[1]=n,m[2]=a,m[3]=l,m[4]=h,m[5]=c,r}invert(){const t=this._t;let e=t[0]*t[4]-t[1]*t[3];if(0===e)return new at([0,0,0,0,0,0]);e=1/e;const r=(t[1]*t[5]-t[2]*t[4])*e,i=(t[2]*t[3]-t[0]*t[5])*e,s=t[4]*e,o=-t[1]*e,n=-t[3]*e,a=t[0]*e;return new at([s,o,r,n,a,i])}}class lt{constructor(t,e){this._resourceManager=t,this._transfos=[],this._sizeTransfos=[],this._geomUnitsPerPoint=1,this._placementPool=new s(v,void 0,void 0,100),this._earlyReturn=!1,this._mapRotation=0,this._transfos.push(e||at.createIdentity()),this._sizeTransfos.push(e?e.scaleRatio():1)}setTransform(t,e){this._transfos=[t||at.createIdentity()],this._sizeTransfos=[e||(t?t.scaleRatio():1)]}setGeomUnitsPerPoint(t){this._geomUnitsPerPoint=t}transformPt(t){return this._transfos[this._transfos.length-1].transform(t)}transformSize(t){return t*this._sizeTransfos[this._sizeTransfos.length-1]}reverseTransformPt(t){return this._transfos[this._transfos.length-1].invert().transform(t)}reverseTransformSize(t){return t/this._sizeTransfos[this._sizeTransfos.length-1]}reverseTransformScalar(t){return t/this._transfos[this._transfos.length-1].scaleRatio()}getTransformAngle(){return this._transfos[this._transfos.length-1].angle()}geomUnitsPerPoint(){return this.isEmbedded()?1:this._geomUnitsPerPoint}prevGeomUnitsPerPoint(){return this._transfos.length>2?1:this._geomUnitsPerPoint}isEmbedded(){return this._transfos.length>1}back(){return this._transfos[this._transfos.length-1]}push(t,e){const r=e?t.scaleRatio():1;at.multiply(t,this.back(),t),this._transfos.push(t),this._sizeTransfos.push(this._sizeTransfos[this._sizeTransfos.length-1]*r)}pop(){this._transfos.splice(-1,1),this._sizeTransfos.splice(-1,1)}drawSymbol(t,e,r){if(t)switch(t.type){case"CIMPointSymbol":case"CIMLineSymbol":case"CIMPolygonSymbol":this.drawMultiLayerSymbol(t,e);break;case"CIMTextSymbol":this.drawTextSymbol(t,e,r)}}drawMultiLayerSymbol(t,e){if(!t||!e)return;const r=t.symbolLayers;if(!r)return;const i=t.effects;if(i&&i.length>0){const t=this.executeEffects(i,e);if(t){let e=t.next();for(;e;)this.drawSymbolLayers(r,e.asJSON()),e=t.next()}}else this.drawSymbolLayers(r,e)}executeEffects(t,e){let r=new M(a.fromJSONCIM(e));for(const i of t){const t=k(i);t&&(r=t.execute(r,i,this.geomUnitsPerPoint(),null))}return r}drawSymbolLayers(t,e){let r=t.length;for(;r--;){const i=t[r];if(!i||!1===i.enable)continue;const s=i.effects;if(s&&s.length>0){const t=this.executeEffects(s,e);if(t){let e=null;for(;(e=t.next())&&(this.drawSymbolLayer(i,e.asJSON()),!this._earlyReturn););}}else this.drawSymbolLayer(i,e);if(this._earlyReturn)return}}drawSymbolLayer(t,e){switch(t.type){case"CIMSolidFill":this.drawSolidFill(e,t.color,t.path);break;case"CIMHatchFill":this.drawHatchFill(e,t);break;case"CIMPictureFill":this.drawPictureFill(e,t);break;case"CIMGradientFill":this.drawGradientFill(e,t);break;case"CIMSolidStroke":this.drawSolidStroke(e,t.color,t.width,t.capStyle,t.joinStyle,t.miterLimit,t.path);break;case"CIMPictureStroke":this.drawPictureStroke(e,t);break;case"CIMGradientStroke":this.drawGradientStroke(e,t);break;case"CIMCharacterMarker":case"CIMPictureMarker":case"CIMVectorMarker":this.drawMarkerLayer(t,e)}}drawHatchFill(t,e){const r=ft(e,t,this.geomUnitsPerPoint());r&&(this.pushClipPath(t),this.drawMultiLayerSymbol(e.lineSymbol,r),this.popClipPath())}drawPictureFill(t,e){}drawGradientFill(t,e){}drawPictureStroke(t,e){}drawGradientStroke(t,e){}drawMarkerLayer(t,e){const r=t.markerPlacement;if(r){const i=C(r);if(i){const s="CIMMarkerPlacementInsidePolygon"===r.type||"CIMMarkerPlacementPolygonCenter"===r.type&&r.clipAtBoundary;s&&this.pushClipPath(e);const o=i.execute(a.fromJSONCIM(e),r,this.geomUnitsPerPoint(),null);if(o){let e=null;for(;(e=o.next())&&(this.drawMarker(t,e),!this._earlyReturn););}s&&this.popClipPath()}}else{const r=this._placementPool.acquire();if(x(e))r.tx=e.x,r.ty=e.y,this.drawMarker(t,r);else if(P(e)){const i=_(e);i&&([r.tx,r.ty]=i,this.drawMarker(t,r))}else if(S(e)){for(const i of e.paths)for(const e of i)if(r.tx=e[0],r.ty=e[1],this.drawMarker(t,r),this._earlyReturn)break}else for(const i of e.points)if(r.tx=i[0],r.ty=i[1],this.drawMarker(t,r),this._earlyReturn)break;this._placementPool.release(r)}}drawMarker(t,e){switch(t.type){case"CIMCharacterMarker":case"CIMPictureMarker":this.drawPictureMarker(t,e);break;case"CIMVectorMarker":this.drawVectorMarker(t,e)}}drawPictureMarker(t,e){if(!t)return;const r=this._resourceManager.getResource(t.url),i=j(t.size,I.CIMPictureMarker.size);if(null==r||i<=0)return;const s=r.width,o=r.height;if(!s||!o)return;const n=s/o,a=j(t.scaleX,1),l=at.createIdentity(),h=t.anchorPoint;if(h){let e=h.x,r=h.y;"Absolute"!==t.anchorPointUnits&&(e*=i*n*a,r*=i),l.translate(-e,-r)}let c=j(t.rotation);t.rotateClockwise&&(c=-c),this._mapRotation&&(c+=this._mapRotation),c&&l.rotate(c*st);let m=j(t.offsetX),f=j(t.offsetY);if(m||f){if(this._mapRotation){const t=st*this._mapRotation,e=Math.cos(t),r=Math.sin(t),i=m*r+f*e;m=m*e-f*r,f=i}l.translate(m,f)}const u=this.geomUnitsPerPoint();1!==u&&l.scale(u,u);const d=e.getAngle();d&&l.rotate(d),l.translate(e.tx,e.ty),this.push(l,!1),this.drawImage(t,i),this.pop()}drawVectorMarker(t,e){if(!t)return;const r=t.markerGraphics;if(!r)return;const i=j(t.size,I.CIMVectorMarker.size),s=t.frame,o=s?s.ymax-s.ymin:0,n=i&&o?i/o:1,a=at.createIdentity();s&&a.translate(.5*-(s.xmax+s.xmin),.5*-(s.ymax+s.ymin));const l=t.anchorPoint;if(l){let e=l.x,r=l.y;"Absolute"!==t.anchorPointUnits?s&&(e*=s.xmax-s.xmin,r*=s.ymax-s.ymin):(e/=n,r/=n),a.translate(-e,-r)}1!==n&&a.scale(n,n);let h=j(t.rotation);t.rotateClockwise&&(h=-h),this._mapRotation&&(h+=this._mapRotation),h&&a.rotate(h*st);let c=j(t.offsetX),m=j(t.offsetY);if(c||m){if(this._mapRotation){const t=st*this._mapRotation,e=Math.cos(t),r=Math.sin(t),i=c*r+m*e;c=c*e-m*r,m=i}a.translate(c,m)}const f=this.geomUnitsPerPoint();1!==f&&a.scale(f,f);const u=e.getAngle();u&&a.rotate(u),a.translate(e.tx,e.ty),this.push(a,t.scaleSymbolsProportionally);for(const d of r){d?.symbol&&d.geometry||nt().error("Invalid marker graphic",d);let t=d.textString;if("number"==typeof t&&(t=t.toString()),this.drawSymbol(d.symbol,d.geometry,t),this._earlyReturn)break}this.pop()}drawTextSymbol(t,e,r){if(!t)return;if(!x(e))return;if(j(t.height,I.CIMTextSymbol.height)<=0)return;const i=at.createIdentity();let s=j(t.angle);s=-s,s&&i.rotate(s*st);const o=j(t.offsetX),n=j(t.offsetY);(o||n)&&i.translate(o,n);const a=this.geomUnitsPerPoint();1!==a&&i.scale(a,a),i.translate(e.x,e.y),this.push(i,!1),this.drawText(t,r),this.pop()}}class ht extends lt{constructor(t,e){super(t,e),this.reset()}reset(){this._xmin=this._ymin=1/0,this._xmax=this._ymax=-1/0,this._clipCount=0}envelope(){return new L(this._xmin,this._ymin,this._xmax-this._xmin,this._ymax-this._ymin)}bounds(){return h(this._xmin,this._ymin,this._xmax,this._ymax)}drawSolidFill(t){if(t&&!(this._clipCount>0))if(P(t))this._processPath(t.rings,0);else if(S(t))this._processPath(t.paths,0);else if(y(t)){const e=pt(t);e&&this._processPath(e.rings,0)}else console.error("drawSolidFill Unexpected geometry type!")}drawSolidStroke(t,e,r){if(!t||this._clipCount>0||null==r||r<=0)return;const i=Math.max(.5*this.transformSize(j(r,I.CIMSolidStroke.width)),.5*ot);if(P(t))this._processPath(t.rings,i);else if(S(t))this._processPath(t.paths,i);else if(y(t)){const e=pt(t);e&&this._processPath(e.rings,i)}else console.error("drawSolidStroke unexpected geometry type!")}drawMarkerLayer(t,e){P(e)&&t.markerPlacement&&("CIMMarkerPlacementInsidePolygon"===t.markerPlacement.type||"CIMMarkerPlacementPolygonCenter"===t.markerPlacement.type&&t.markerPlacement.clipAtBoundary)?this._processPath(e.rings,0):super.drawMarkerLayer(t,e)}drawHatchFill(t,e){this.drawSolidFill(t)}drawPictureFill(t,e){this.drawSolidFill(t)}drawGradientFill(t,e){this.drawSolidFill(t)}drawPictureStroke(t,e){this.drawSolidStroke(t,null,e.width)}drawGradientStroke(t,e){this.drawSolidStroke(t,null,e.width)}pushClipPath(t){this.drawSolidFill(t),this._clipCount++}popClipPath(){this._clipCount--}drawImage(t,e){const{url:r}=t,i=j(t.scaleX,1);let s=i*e,o=e;const n=this._resourceManager.getResource(r);if(null!=n){const t=n.height/n.width;s=i*(e?t>1?e:e/t:n.width),o=e?t>1?e*t:e:n.height}this._merge(this.transformPt([-s/2,-o/2]),0),this._merge(this.transformPt([-s/2,o/2]),0),this._merge(this.transformPt([s/2,-o/2]),0),this._merge(this.transformPt([s/2,o/2]),0)}drawText(t,e){if(!e||0===e.length)return;this._textRasterizer||(this._textRasterizer=new F);const r=yt(t);let[i,s]=this._textRasterizer.computeTextSize(e,r);i=o(i),s=o(s);const n=this.transformSize(1)*this.reverseTransformScalar(1);i*=n,s*=n;let a=0;switch(t.horizontalAlignment){case"Left":a=i/2;break;case"Right":a=-i/2}let l=0;switch(t.verticalAlignment){case"Bottom":l=s/2;break;case"Top":l=-s/2;break;case"Baseline":l=s/6}this._merge(this.transformPt([-i/2+a,-s/2+l]),0),this._merge(this.transformPt([-i/2+a,s/2+l]),0),this._merge(this.transformPt([i/2+a,-s/2+l]),0),this._merge(this.transformPt([i/2+a,s/2+l]),0)}_processPath(t,e){if(t)for(const r of t){const t=r?r.length:0;if(t>1){this._merge(this.transformPt(r[0]),e);for(let i=1;i<t;i++)this._merge(this.transformPt(r[i]),e)}}}_merge(t,e){t[0]-e<this._xmin&&(this._xmin=t[0]-e),t[0]+e>this._xmax&&(this._xmax=t[0]+e),t[1]-e<this._ymin&&(this._ymin=t[1]-e),t[1]+e>this._ymax&&(this._ymax=t[1]+e)}}class ct extends lt{constructor(){super(...arguments),this._searchPoint=[0,0],this._searchDistPoint=0,this._textInfo=null,this._svg=null,this._path=null,this._canvas=null}destroy(){this._svg=W(this._svg),this._path=null,this._canvas=null}hitTest(t,e,r,i,s,a){const l=a*n(1);this.setTransform(),this.setGeomUnitsPerPoint(l),this._searchPoint=[(t[0]+t[2])/2,(t[1]+t[3])/2],this._searchDistPoint=(t[2]-t[0])/2/l,this._textInfo=i;const h=e&&("CIMPointSymbol"===e.type&&"Map"!==e.angleAlignment||"CIMTextSymbol"===e.type);if(this._mapRotation=h?s:0,!has("esri-mobile")){const t=o(Z*window.devicePixelRatio),r=o(tt);!(("CIMLineSymbol"===e?.type||"CIMPolygonSymbol"===e?.type)&&e.symbolLayers?.some(U))&&"CIMMeshSymbol"!==e?.type&&(A(e)??0)<r&&(this._searchDistPoint=t)}return this._earlyReturn=!1,this.drawSymbol(e,r),this._earlyReturn}executeEffects(t,e){return"CIMGeometricEffectDashes"===t.at(-1)?.type&&(t=t.slice(0,-1)),super.executeEffects(t,e)}drawSolidFill(t,e,r){null!=r?this._hittestSvgPath(t,r,!0):this._hitTestFill(t)}drawHatchFill(t,e){this._hitTestFill(t)}drawPictureFill(t,e){this._hitTestFill(t)}drawGradientFill(t,e){this._hitTestFill(t)}drawSolidStroke(t,e,r,i,s,o,n){null!=n?this._hittestSvgPath(t,n,!1,r):this._hitTestStroke(t,r)}drawPictureStroke(t,e){this._hitTestStroke(t,e.width)}drawGradientStroke(t,e){this._hitTestStroke(t,e.width)}drawMarkerLayer(t,e){t.markerPlacement&&("CIMMarkerPlacementInsidePolygon"===t.markerPlacement.type||"CIMMarkerPlacementPolygonCenter"===t.markerPlacement.type&&t.markerPlacement.clipAtBoundary)?this._hitTestFill(e):super.drawMarkerLayer(t,e)}pushClipPath(t){}popClipPath(){}drawImage(t,e){const{url:r}=t,i=j(t.scaleX,1),s=this._resourceManager.getResource(r);if(null==s||0===s.height||0===e)return;const o=e*this.geomUnitsPerPoint(),n=o*i*(s.width/s.height),a=this.reverseTransformPt(this._searchPoint),l=this._searchDistPoint;Math.abs(a[0])<n/2+l&&Math.abs(a[1])<o/2+l&&(this._earlyReturn=!0)}drawText(t,e){const r=this._textInfo;if(!r)return;const i=r.get(t);if(!i)return;if(!i.glyphMosaicItems.glyphs.length)return;const s=rt(j(t.height,I.CIMTextSymbol.height)),{lineGapType:o,lineGap:n}=t,a=o?_t(o,j(n),s):0,l="CIMBackgroundCallout"===t.callout?.type,h=et(i.glyphMosaicItems,{scale:s/Q,angle:0,xOffset:0,yOffset:0,horizontalAlignment:t.horizontalAlignment,verticalAlignment:t.verticalAlignment,maxLineWidth:it(t.lineWidth),lineHeight:K*Math.max(.25,Math.min(a||1,4)),decoration:t.font.decoration||"none",useCIMAngleBehavior:!0,hasBackground:l}),c=this.reverseTransformPt(this._searchPoint),m=c[0],f=c[1];for(const u of h.glyphs)if(m>u.xTopLeft&&m<u.xBottomRight&&f>-u.yBottomRight&&f<-u.yTopLeft){this._earlyReturn=!0;break}}_hitTestFill(t){let e=null;if(y(t)){const r=t;e=[[[r.xmin,r.ymin],[r.xmin,r.ymax],[r.xmax,r.ymax],[r.xmax,r.ymin],[r.xmin,r.ymin]]]}else if(P(t))e=t.rings;else{if(!S(t))return;e=t.paths}const r=this.reverseTransformPt(this._searchPoint);if(ut(r,e)&&(this._earlyReturn=!0),!this._earlyReturn){dt(r,e,this.reverseTransformScalar(this._searchDistPoint)*this.prevGeomUnitsPerPoint())&&(this._earlyReturn=!0)}}_getSvgPath(){return null!=this._svg&&null!=this._path||(this._svg??=Y(),this._path??=$("path"),this._svg.appendChild(this._path)),this._path}_getCanvasContext(t,e){return this._canvas??=document.createElement("canvas"),this._canvas.width=t,this._canvas.height=e,this._canvas.getContext("2d",{willReadFrequently:!0})}_hittestSvgPath(t,e,r,i=0){const s=this.reverseTransformScalar(this._searchDistPoint)*this.prevGeomUnitsPerPoint(),o=this.reverseTransformPt(this._searchPoint),n=l();p(n,t);const a={x:n[0],y:n[1],width:n[2]-n[0],height:n[3]-n[1]},h=this._getSvgPath();h.setAttribute("d",e);const c=h.getBBox();let m=Math.max(c.width/a.width,c.height/a.height),f=1;const u=2*s*m;u<1&&(f=2/u,m*=f,c.x*=f,c.y*=f,c.width*=f,c.height*=f);const d=1+i*m/2,g=this._getCanvasContext(c.width+2*d,c.height+2*d);g.setTransform(f,0,0,f,-c.x+d,-c.y+d);const _=new Path2D(e);r?g.fill(_):(g.lineWidth=i*(m/f),g.stroke(_));const y=(a.width*m-c.width)/2,P=(a.height*m-c.height)/2,S=Math.floor((o[0]-a.x-s)*m-y+d),w=Math.floor((a.height-(o[1]-a.y)-s)*m+P+d),x=Math.ceil(2*s*m),M=Math.ceil(2*s*m),b=g.getImageData(S,w,x,M).data;for(let l=3;l<b.length;l+=4)if(b[l]>127.5)return void(this._earlyReturn=!0)}_hitTestStroke(t,e){let r=null;if(y(t)){const e=t;r=[[[e.xmin,e.ymin],[e.xmin,e.ymax],[e.xmax,e.ymax],[e.xmax,e.ymin],[e.xmin,e.ymin]]]}else if(P(t))r=t.rings;else{if(!S(t))return;r=t.paths}dt(this.reverseTransformPt(this._searchPoint),r,j(e,I.CIMSolidStroke.width)*this.geomUnitsPerPoint()/2+this.reverseTransformScalar(this._searchDistPoint)*this.prevGeomUnitsPerPoint())&&(this._earlyReturn=!0)}}class mt extends lt{constructor(t,e,r,i){super(e,r),this._applyAdditionalRenderProps=i,this._colorSubstitutionHelper=new b,this._ctx=t}drawSolidFill(t,e){if(!t)return;if(P(t))this._buildPath(t.rings,!0);else if(S(t))this._buildPath(t.paths,!0);else if(y(t))this._buildPath(pt(t).rings,!0);else{if(!w(t))return;console.log("CanvasDrawHelper.drawSolidFill - No implementation!")}const r=this._ctx;r.fillStyle="string"==typeof e?e:"rgba("+Math.round(e[0])+","+Math.round(e[1])+","+Math.round(e[2])+","+(e[3]??255)/255+")",r.fill("evenodd")}drawSolidStroke(t,e,r,i,s,o){if(!t||!e||0===r)return;if(P(t))this._buildPath(t.rings,!0);else if(S(t))this._buildPath(t.paths,!1);else{if(!y(t))return void console.log("CanvasDrawHelper.drawSolidStroke isn't implemented!");this._buildPath(pt(t).rings,!0)}const n=this._ctx;n.strokeStyle="string"==typeof e?e:"rgba("+Math.round(e[0])+","+Math.round(e[1])+","+Math.round(e[2])+","+(e[3]??255)/255+")",n.lineWidth=Math.max(this.transformSize(r),ot),this._setCapStyle(i),this._setJoinStyle(s),n.miterLimit=o,n.stroke()}pushClipPath(t){if(this._ctx.save(),P(t))this._buildPath(t.rings,!0);else if(S(t))this._buildPath(t.paths,!0);else{if(!y(t))return;this._buildPath(pt(t).rings,!0)}this._ctx.clip("evenodd")}popClipPath(){this._ctx.restore()}drawImage(t,e){const{colorSubstitutions:r,url:i,tintColor:s}=t,o=j(t.scaleX,1),n=this._resourceManager.getResource(i);if(null==n)return;let a=e*(n.width/n.height),l=e;e||(a=n.width,l=n.height);const h=G(i)||"src"in n&&G(n.src);let c="getFrame"in n?T(n):n;r&&(c=this._colorSubstitutionHelper.applyColorSubstitution(c,r)),this._applyAdditionalRenderProps&&!h&&s&&(c=this._colorSubstitutionHelper.tintImageData(c,s));const m=this.transformPt([0,0]),[f,u]=this.getTransformAngle(),d=this.transformSize(1),g=this._ctx;g.save(),g.setTransform({m11:o*d*f,m12:o*d*u,m21:-d*u,m22:d*f,m41:m[0],m42:m[1]}),g.drawImage(c,-a/2,-l/2,a,l),g.restore()}drawText(t,e){if(!e||0===e.length)return;this._textRasterizer||(this._textRasterizer=new F);const r=yt(t,this.transformSize(o(1))),i=this._textRasterizer.rasterizeText(e,r);if(!i)return;const{size:s,anchorX:n,anchorY:a,canvas:l}=i,h=s[0]*(n+.5),c=s[1]*(a-.5),m=this._ctx,f=this.transformPt([0,0]),[u,d]=this.getTransformAngle(),g=1;m.save(),m.setTransform({m11:g*u,m12:g*d,m21:-g*d,m22:g*u,m41:f[0]-g*h,m42:f[1]+g*c}),m.drawImage(l,0,0),m.restore()}drawPictureFill(t,e){if(!t)return;let{colorSubstitutions:r,height:i,offsetX:s,offsetY:o,rotation:n,scaleX:a,tintColor:l,url:h}=e;const c=this._resourceManager.getResource(h);if(null==c)return;if(P(t))this._buildPath(t.rings,!0);else if(S(t))this._buildPath(t.paths,!0);else if(y(t))this._buildPath(pt(t).rings,!0);else{if(!w(t))return;console.log("CanvasDrawHelper.drawPictureFill - No implementation!")}const m=this._ctx,f=G(h)||"src"in c&&G(c.src);let u,d="getFrame"in c?T(c):c;if(r&&(d=this._colorSubstitutionHelper.applyColorSubstitution(d,r)),this._applyAdditionalRenderProps){f||l&&(d=this._colorSubstitutionHelper.tintImageData(d,l)),u=m.createPattern(d,"repeat");const t=this.transformSize(1);n||(n=0),s?s*=t:s=0,o?o*=t:o=0,i&&(i*=t);const e=i?i/c.height:1,r=a&&i?a*i/c.width:1;if(0!==n||1!==e||1!==r||0!==s||0!==o){const t=new DOMMatrix;t.rotateSelf(0,0,-n).translateSelf(s,o).scaleSelf(r,e,1),u.setTransform(t)}}else u=m.createPattern(d,"repeat");m.save(),m.fillStyle=u,m.fill("evenodd"),m.restore()}drawPictureStroke(t,r){if(!t)return;let{colorSubstitutions:i,capStyle:s,joinStyle:o,miterLimit:a,tintColor:l,url:h,width:c}=r;const m=this._resourceManager.getResource(h);if(null==m)return;let f;if(P(t))f=t.rings;else if(S(t))f=t.paths;else{if(!y(t))return w(t)?void console.log("CanvasDrawHelper.drawPictureStroke - No implementation!"):void 0;f=pt(t).rings}c||(c=m.width);const u=G(h)||"src"in m&&G(m.src);let d="getFrame"in m?T(m):m;i&&(d=this._colorSubstitutionHelper.applyColorSubstitution(d,i)),this._applyAdditionalRenderProps&&(u||l&&(d=this._colorSubstitutionHelper.tintImageData(d,l)));const g=Math.max(this.transformSize(n(c)),.5),p=g/d.width,_=this._ctx,x=_.createPattern(d,"repeat-y");let M,b;_.save(),this._setCapStyle(s),this._setJoinStyle(o),void 0!==a&&(_.miterLimit=a),_.lineWidth=g;for(let n of f)if(n=e(n),St(n),n&&!(n.length<=1)){M=this.transformPt(n[0]);for(let t=1;t<n.length;t++){b=this.transformPt(n[t]);const e=gt(M,b),r=new DOMMatrix;r.translateSelf(0,M[1]-g/2).scaleSelf(p,p,1).rotateSelf(0,0,90-e),x.setTransform(r),_.strokeStyle=x,_.beginPath(),_.moveTo(M[0],M[1]),_.lineTo(b[0],b[1]),_.stroke(),M=b}}_.restore()}drawGradientFill(t,e){if(!t)return;let r;if(P(t))r=t.rings;else if(S(t))r=t.paths;else{if(!y(t))return void nt().error("Unable to draw gradient fill");r=pt(t).rings}this._buildPath(r,!0);const{angle:s,gradientMethod:o,gradientSize:a,gradientSizeUnits:l}=e,h=I.CIMGradientFill,p=e.gradientType??h.gradientType,_=-i(s??0),w=c();for(const i of r){const t=i?i.length:0;if(t>1)for(let e=0;e<t;e++){let t=this.transformPt(i[e]);"Linear"!==o&&"Rectangular"!==o||(t=R(t,-_)),m(w,t)}}const[x,M,b,k]=w,C=this._ctx;switch(C.save(),o){case"Buffered":nt().error(`Gradient method "${o}" currently unsupported.`);break;case"Linear":{const t=(M+k)/2,r="Absolute"===l?this.transformSize(n(a)):D(a,h.gradientSize)*(b-x),[i,s]="Discrete"===p?[b,b-r]:[x+r,x],o=R([i,t],_),c=R([s,t],_),m=C.createLinearGradient(o[0],o[1],c[0],c[1]);z(m,e),C.fillStyle=m,C.fill("evenodd");break}case"Circular":{const t=f(w),r=g(w)/2,i="Absolute"===l?this.transformSize(n(a)):D(a,h.gradientSize)*r,[s,o]="Discrete"===p?[r,r-i]:[i,0],c=C.createRadialGradient(t[0],t[1],s,t[0],t[1],o);z(c,e),C.fillStyle=c,C.fill("evenodd");break}case"Rectangular":{const r=f(w),i=r[0],s=r[1],o=R(r,_),c=(r,i,s,n,a,l,h,c)=>{C.save(),this.pushClipPath(t);const m=R([a,l],_),f=R([h,c],_);C.beginPath(),C.moveTo(o[0],o[1]),C.lineTo(m[0],m[1]),C.lineTo(f[0],f[1]),C.lineTo(o[0],o[1]),C.clip();const u=R([r,i],_),d=R([s,n],_),g=C.createLinearGradient(u[0],u[1],d[0],d[1]);z(g,e),C.fillStyle=g,C.fill("evenodd"),C.restore()};let m="Absolute"===l?this.transformSize(n(a)):D(a,h.gradientSize)*(u(w)/2),[g,y]="Discrete"===p?[b,b-m]:[i+m,i];c(g,s,y,s,b,M,b,k),[g,y]="Discrete"===p?[x,x+m]:[i-m,i],c(g,s,y,s,x,k,x,M),m="Absolute"===l?this.transformSize(n(a)):D(a,h.gradientSize)*(d(w)/2);let[P,S]="Discrete"===p?[k,k-m]:[s+m,s];c(i,P,i,S,b,k,x,k),[P,S]="Discrete"===p?[M,M+m]:[s-m,s],c(i,P,i,S,x,M,b,M);break}}C.restore()}drawGradientStroke(t,r){const{capStyle:i,gradientMethod:s,gradientSize:o,gradientSizeUnits:a,joinStyle:l,miterLimit:h,width:c}=r;if(!t||0===c)return;let m;if(P(t))m=t.rings;else if(S(t))m=t.paths;else{if(!y(t))return void nt().error("Unable to draw gradient stroke");m=pt(t).rings}const f=r.gradientType??I.CIMGradientStroke.gradientType,u=Math.max(this.transformSize(n(c)),.5),d=this._ctx;let g,p;d.save(),this._setCapStyle(i),this._setJoinStyle(l),void 0!==h&&(d.miterLimit=h),d.lineWidth=u;for(let _ of m){if(_=e(_),St(_),!_||_.length<=1)continue;let t=0;g=this.transformPt(_[0]);for(let e=1;e<_.length;e++){p=this.transformPt(_[e]);const r=p[0]-g[0],i=p[1]-g[1];t+=Math.sqrt(r*r+i*i),g=p}const i="Absolute"===a?this.transformSize(n(o)):D(o,I.CIMGradientStroke.gradientSize)*("AcrossLine"===s?u:t);let l=0;g=this.transformPt(_[0]);for(let e=1;e<_.length;e++){p=this.transformPt(_[e]);const o=p[0]-g[0],n=p[1]-g[1],a=Math.sqrt(o*o+n*n);let h,c,m,y;switch(s){case"AcrossLine":{const[t,e]=R([o/a,n/a],-Math.PI/2),r=u/2,s="Discrete"===f?r:i-r;h=(g[0]+p[0])/2+t*s,c=(g[1]+p[1])/2+e*s,m=h-t*i,y=c-e*i;break}case"AlongLine":{const e=o/a,r=n/a;"Discrete"===f?(h=g[0]-e*l,c=g[1]-r*l,m=h+e*i,y=c+r*i):(m=g[0]+e*(t-l),y=g[1]+r*(t-l),h=m-e*i,c=y-r*i);break}default:return nt().error("Unrecognized gradient method:",s),void d.restore()}const P=d.createLinearGradient(h,c,m,y);z(P,r),d.strokeStyle=P,d.beginPath(),d.moveTo(g[0],g[1]),d.lineTo(p[0],p[1]),d.stroke(),l+=a,g=p}}d.restore()}_buildPath(t,e){const r=this._ctx;if(r.beginPath(),t)for(const i of t){const t=i?i.length:0;if(t>1){let s=this.transformPt(i[0]);r.moveTo(s[0],s[1]);for(let e=1;e<t;e++)s=this.transformPt(i[e]),r.lineTo(s[0],s[1]);e&&r.closePath()}}}_setCapStyle(t){switch(t){case"Butt":this._ctx.lineCap="butt";break;case"Round":this._ctx.lineCap="round";break;case"Square":this._ctx.lineCap="square"}}_setJoinStyle(t){switch(t){case"Bevel":this._ctx.lineJoin="bevel";break;case"Round":this._ctx.lineJoin="round";break;case"Miter":this._ctx.lineJoin="miter"}}}function ft(t,e,r){let i=j(t.separation,I.CIMHatchFill.separation)*r,s=j(t.rotation);if(0===i)return null;i<0&&(i=-i);let o=0;const n=.5*i;for(;o>n;)o-=i;for(;o<-n;)o+=i;const a=l();p(a,e),a[0]-=n,a[1]-=n,a[2]+=n,a[3]+=n;const h=[[a[0],a[1]],[a[0],a[3]],[a[2],a[3]],[a[2],a[1]]];for(;s>180;)s-=180;for(;s<0;)s+=180;const c=Math.cos(s*st),m=Math.sin(s*st),f=-i*m,u=i*c;let d,g,_,y;o=j(t.offsetX)*r*m-j(t.offsetY)*r*c,d=_=Number.MAX_VALUE,g=y=-Number.MAX_VALUE;for(const l of h){const t=l[0],e=l[1],r=c*t+m*e,i=-m*t+c*e;d=Math.min(d,r),_=Math.min(_,i),g=Math.max(g,r),y=Math.max(y,i)}_=Math.floor(_/i)*i;let P=c*d-m*_-f*o/i,S=m*d+c*_-u*o/i,w=c*g-m*_-f*o/i,x=m*g+c*_-u*o/i;const M=1+Math.round((y-_)/i),b=[];for(let l=0;l<M;l++)P+=f,S+=u,w+=f,x+=u,b.push([[P,S],[w,x]]);return{paths:b}}function ut(t,e){let r=0;for(const i of e){const e=i.length;for(let s=1;s<e;s++){const e=i[s-1],o=i[s];if(e[1]>t[1]==o[1]>t[1])continue;(o[0]-e[0])*(t[1]-e[1])-(o[1]-e[1])*(t[0]-e[0])>0?r++:r--}}return 0!==r}function dt(t,e,r){for(const i of e){const e=i.length;for(let s=1;s<e;s++){const e=i[s-1],o=i[s];let n=(o[0]-e[0])*(o[0]-e[0])+(o[1]-e[1])*(o[1]-e[1]);if(0===n)continue;n=Math.sqrt(n);const a=((o[0]-e[0])*(t[1]-e[1])-(o[1]-e[1])*(t[0]-e[0]))/n;if(Math.abs(a)<r){const i=((o[0]-e[0])*(t[0]-e[0])+(o[1]-e[1])*(t[1]-e[1]))/n;if(i>-r&&i<n+r)return!0}}}return!1}function gt(t,e){const r=e[0]-t[0],i=e[1]-t[1];return 180/Math.PI*Math.atan2(i,r)}const pt=t=>t?{spatialReference:t.spatialReference,rings:[[[t.xmin,t.ymin],[t.xmin,t.ymax],[t.xmax,t.ymax],[t.xmax,t.ymin],[t.xmin,t.ymin]]]}:null,_t=(t,e,r)=>{switch(t){case"ExtraLeading":return 1+e/r;case"Multiple":return e;case"Exact":return e/r}};function yt(e,r=1){const i=H(e),s=B(e.fontStyleName),o=e.fontFamilyName??t,{weight:n,style:a}=s,l=r*(e.height||5),h=E(e.horizontalAlignment),c=X(e.verticalAlignment),m=J(e),f=J(e.haloSymbol),u=null!=f?r*(e.haloSize??0):0,d=N(e.symbol),g=r*(O(e.symbol)||0),p="CIMBackgroundCallout"===e.callout?.type?e.callout.backgroundSymbol:null,_=J(p),y=O(p),P=N(p);return{color:m,size:l,horizontalAlignment:h,verticalAlignment:c,font:{family:o,style:V(a),weight:q(n),decoration:i},outline:{size:g||0,color:d},halo:{size:u||0,color:f,style:a},backgroundColor:_,borderLine:null!=y&&null!=P?{size:y,color:P}:null,pixelRatio:1,premultiplyColors:!0}}const Pt=1e-4;function St(t){let e,r,i,s,o,n=t[0],a=1;for(;a<t.length;)e=t[a][0]-n[0],r=t[a][1]-n[1],s=0!==e?r/e:Math.PI/2,void 0!==i&&Math.abs(s-i)<=Pt?(t.splice(a-1,1),n=o):(o=n,n=t[a],a++),i=s}export{lt as CIMSymbolDrawHelper,mt as CanvasDrawHelper,ht as EnvDrawHelper,ct as HittestDrawHelper,at as Transformation,st as cDegToRad,_t as lineGapType2LineHeight};
|
|
5
|
+
import{defaultFontFamily as t}from"../../core/fontUtils.js";import has from"../../core/has.js";import{clone as e}from"../../core/lang.js";import r from"../../core/Logger.js";import{deg2rad as i}from"../../core/mathUtils.js";import s from"../../core/ObjectPool.js";import{px2pt as o,pt2px as n}from"../../core/screenUtils.js";import{GeometryCursor as a}from"../../geometry/GeometryCursor.js";import{create as l,fromValues as h,empty as c,expandPointInPlace as m,center as f,width as u,height as d,diagonal as g}from"../../geometry/support/aaBoundingRect.js";import{getBoundsXY as p}from"../../geometry/support/boundsUtils.js";import{polygonCentroid as _}from"../../geometry/support/centroid.js";import{isExtent as y,isPolygon as P,isPolyline as S,isMultipoint as w,isPoint as x}from"../../geometry/support/jsonUtils.js";import{SimpleEffectCursor as M}from"./CIMEffects.js";import b from"./CIMImageColorSubstitutionHelper.js";import{getEffectOperator as k,getPlacementOperator as C}from"./CIMOperators.js";import{Placement as v}from"./CIMPlacements.js";import{defaultCIMValues as I}from"./defaultCIMValues.js";import{getFirstFrame as T}from"./imageUtils.js";import{rotate as R}from"./mathUtils.js";import{addColorStops as z}from"./rasterizingUtils.js";import L from"./Rect.js";import F from"./TextRasterizer.js";import{isCIMFill as U,getSize as A,getNumericValue as j,isSVGImage as G,getRelativeGradientSize as D,fromCIMFontDecoration as H,fromCIMFontStyle as B,fromCIMHorizontalAlignment as E,fromCIMVerticalAlignment as X,getFillColor as J,getStrokeColor as N,getStrokeWidth as O,getFontWeight as q,getFontStyle as V}from"./utils.js";import{destroyHiddenSvg as W,createHiddenSvg as Y,createSvgElement as $}from"../../views/2d/engine/svgUtils.js";import{magicLabelLineHeight as K,glyphSize as Q,hittestToleranceSmallSymbol as Z,hittestSmallSymbolThreshold as tt}from"../../views/2d/engine/webgl/definitions.js";import{shapeGlyphs as et}from"../../views/2d/engine/webgl/mesh/templates/shapingUtils.js";import{roundPtToWholePixel as rt,getLineWidth as it}from"../../views/2d/layers/graphics/graphicsUtils.js";const st=Math.PI/180,ot=.5,nt=()=>r.getLogger("esri.symbols.cim.CIMSymbolDrawHelper");class at{constructor(t){this._t=t}static createIdentity(){return new at([1,0,0,0,1,0])}clone(){const t=this._t;return new at(t.slice())}transform(t){const e=this._t;return[e[0]*t[0]+e[1]*t[1]+e[2],e[3]*t[0]+e[4]*t[1]+e[5]]}static createScale(t,e){return new at([t,0,0,0,e,0])}scale(t,e){const r=this._t;return r[0]*=t,r[1]*=t,r[2]*=t,r[3]*=e,r[4]*=e,r[5]*=e,this}scaleRatio(){return Math.sqrt(this._t[0]*this._t[0]+this._t[1]*this._t[1])}static createTranslate(t,e){return new at([0,0,t,0,0,e])}translate(t,e){const r=this._t;return r[2]+=t,r[5]+=e,this}static createRotate(t){const e=Math.cos(t),r=Math.sin(t);return new at([e,-r,0,r,e,0])}rotate(t){return at.multiply(this,at.createRotate(t),this)}angle(){const t=this._t[0],e=this._t[3],r=Math.sqrt(t*t+e*e);return[t/r,e/r]}static multiply(t,e,r){const i=t._t,s=e._t,o=i[0]*s[0]+i[3]*s[1],n=i[1]*s[0]+i[4]*s[1],a=i[2]*s[0]+i[5]*s[1]+s[2],l=i[0]*s[3]+i[3]*s[4],h=i[1]*s[3]+i[4]*s[4],c=i[2]*s[3]+i[5]*s[4]+s[5],m=r._t;return m[0]=o,m[1]=n,m[2]=a,m[3]=l,m[4]=h,m[5]=c,r}invert(){const t=this._t;let e=t[0]*t[4]-t[1]*t[3];if(0===e)return new at([0,0,0,0,0,0]);e=1/e;const r=(t[1]*t[5]-t[2]*t[4])*e,i=(t[2]*t[3]-t[0]*t[5])*e,s=t[4]*e,o=-t[1]*e,n=-t[3]*e,a=t[0]*e;return new at([s,o,r,n,a,i])}}class lt{constructor(t,e){this._resourceManager=t,this._transfos=[],this._sizeTransfos=[],this._geomUnitsPerPoint=1,this._placementPool=new s(()=>new v,void 0,void 0,100),this._earlyReturn=!1,this._mapRotation=0,this._transfos.push(e||at.createIdentity()),this._sizeTransfos.push(e?e.scaleRatio():1)}setTransform(t,e){this._transfos=[t||at.createIdentity()],this._sizeTransfos=[e||(t?t.scaleRatio():1)]}setGeomUnitsPerPoint(t){this._geomUnitsPerPoint=t}transformPt(t){return this._transfos[this._transfos.length-1].transform(t)}transformSize(t){return t*this._sizeTransfos[this._sizeTransfos.length-1]}reverseTransformPt(t){return this._transfos[this._transfos.length-1].invert().transform(t)}reverseTransformSize(t){return t/this._sizeTransfos[this._sizeTransfos.length-1]}reverseTransformScalar(t){return t/this._transfos[this._transfos.length-1].scaleRatio()}getTransformAngle(){return this._transfos[this._transfos.length-1].angle()}geomUnitsPerPoint(){return this.isEmbedded()?1:this._geomUnitsPerPoint}prevGeomUnitsPerPoint(){return this._transfos.length>2?1:this._geomUnitsPerPoint}isEmbedded(){return this._transfos.length>1}back(){return this._transfos[this._transfos.length-1]}push(t,e){const r=e?t.scaleRatio():1;at.multiply(t,this.back(),t),this._transfos.push(t),this._sizeTransfos.push(this._sizeTransfos[this._sizeTransfos.length-1]*r)}pop(){this._transfos.splice(-1,1),this._sizeTransfos.splice(-1,1)}drawSymbol(t,e,r){if(t)switch(t.type){case"CIMPointSymbol":case"CIMLineSymbol":case"CIMPolygonSymbol":this.drawMultiLayerSymbol(t,e);break;case"CIMTextSymbol":this.drawTextSymbol(t,e,r)}}drawMultiLayerSymbol(t,e){if(!t||!e)return;const r=t.symbolLayers;if(!r)return;const i=t.effects;if(i&&i.length>0){const t=this.executeEffects(i,e);if(t){let e=t.next();for(;e;)this.drawSymbolLayers(r,e.asJSON()),e=t.next()}}else this.drawSymbolLayers(r,e)}executeEffects(t,e){let r=new M(a.fromJSONCIM(e));for(const i of t){const t=k(i);t&&(r=t.execute(r,i,this.geomUnitsPerPoint(),null))}return r}drawSymbolLayers(t,e){let r=t.length;for(;r--;){const i=t[r];if(!i||!1===i.enable)continue;const s=i.effects;if(s&&s.length>0){const t=this.executeEffects(s,e);if(t){let e=null;for(;(e=t.next())&&(this.drawSymbolLayer(i,e.asJSON()),!this._earlyReturn););}}else this.drawSymbolLayer(i,e);if(this._earlyReturn)return}}drawSymbolLayer(t,e){switch(t.type){case"CIMSolidFill":this.drawSolidFill(e,t.color,t.path);break;case"CIMHatchFill":this.drawHatchFill(e,t);break;case"CIMPictureFill":this.drawPictureFill(e,t);break;case"CIMGradientFill":this.drawGradientFill(e,t);break;case"CIMSolidStroke":this.drawSolidStroke(e,t.color,t.width,t.capStyle,t.joinStyle,t.miterLimit,t.path);break;case"CIMPictureStroke":this.drawPictureStroke(e,t);break;case"CIMGradientStroke":this.drawGradientStroke(e,t);break;case"CIMCharacterMarker":case"CIMPictureMarker":case"CIMVectorMarker":this.drawMarkerLayer(t,e)}}drawHatchFill(t,e){const r=ft(e,t,this.geomUnitsPerPoint());r&&(this.pushClipPath(t),this.drawMultiLayerSymbol(e.lineSymbol,r),this.popClipPath())}drawPictureFill(t,e){}drawGradientFill(t,e){}drawPictureStroke(t,e){}drawGradientStroke(t,e){}drawMarkerLayer(t,e){const r=t.markerPlacement;if(r){const i=C(r);if(i){const s="CIMMarkerPlacementInsidePolygon"===r.type||"CIMMarkerPlacementPolygonCenter"===r.type&&r.clipAtBoundary;s&&this.pushClipPath(e);const o=i.execute(a.fromJSONCIM(e),r,this.geomUnitsPerPoint(),null);if(o){let e=null;for(;(e=o.next())&&(this.drawMarker(t,e),!this._earlyReturn););}s&&this.popClipPath()}}else{const r=this._placementPool.acquire();if(x(e))r.tx=e.x,r.ty=e.y,this.drawMarker(t,r);else if(P(e)){const i=_(e);i&&([r.tx,r.ty]=i,this.drawMarker(t,r))}else if(S(e)){for(const i of e.paths)for(const e of i)if(r.tx=e[0],r.ty=e[1],this.drawMarker(t,r),this._earlyReturn)break}else for(const i of e.points)if(r.tx=i[0],r.ty=i[1],this.drawMarker(t,r),this._earlyReturn)break;this._placementPool.release(r)}}drawMarker(t,e){switch(t.type){case"CIMCharacterMarker":case"CIMPictureMarker":this.drawPictureMarker(t,e);break;case"CIMVectorMarker":this.drawVectorMarker(t,e)}}drawPictureMarker(t,e){if(!t)return;const r=this._resourceManager.getResource(t.url),i=j(t.size,I.CIMPictureMarker.size);if(null==r||i<=0)return;const s=r.width,o=r.height;if(!s||!o)return;const n=s/o,a=j(t.scaleX,1),l=at.createIdentity(),h=t.anchorPoint;if(h){let e=h.x,r=h.y;"Absolute"!==t.anchorPointUnits&&(e*=i*n*a,r*=i),l.translate(-e,-r)}let c=j(t.rotation);t.rotateClockwise&&(c=-c),this._mapRotation&&(c+=this._mapRotation),c&&l.rotate(c*st);let m=j(t.offsetX),f=j(t.offsetY);if(m||f){if(this._mapRotation){const t=st*this._mapRotation,e=Math.cos(t),r=Math.sin(t),i=m*r+f*e;m=m*e-f*r,f=i}l.translate(m,f)}const u=this.geomUnitsPerPoint();1!==u&&l.scale(u,u);const d=e.getAngle();d&&l.rotate(d),l.translate(e.tx,e.ty),this.push(l,!1),this.drawImage(t,i),this.pop()}drawVectorMarker(t,e){if(!t)return;const r=t.markerGraphics;if(!r)return;const i=j(t.size,I.CIMVectorMarker.size),s=t.frame,o=s?s.ymax-s.ymin:0,n=i&&o?i/o:1,a=at.createIdentity();s&&a.translate(.5*-(s.xmax+s.xmin),.5*-(s.ymax+s.ymin));const l=t.anchorPoint;if(l){let e=l.x,r=l.y;"Absolute"!==t.anchorPointUnits?s&&(e*=s.xmax-s.xmin,r*=s.ymax-s.ymin):(e/=n,r/=n),a.translate(-e,-r)}1!==n&&a.scale(n,n);let h=j(t.rotation);t.rotateClockwise&&(h=-h),this._mapRotation&&(h+=this._mapRotation),h&&a.rotate(h*st);let c=j(t.offsetX),m=j(t.offsetY);if(c||m){if(this._mapRotation){const t=st*this._mapRotation,e=Math.cos(t),r=Math.sin(t),i=c*r+m*e;c=c*e-m*r,m=i}a.translate(c,m)}const f=this.geomUnitsPerPoint();1!==f&&a.scale(f,f);const u=e.getAngle();u&&a.rotate(u),a.translate(e.tx,e.ty),this.push(a,t.scaleSymbolsProportionally);for(const d of r){d?.symbol&&d.geometry||nt().error("Invalid marker graphic",d);let t=d.textString;if("number"==typeof t&&(t=t.toString()),this.drawSymbol(d.symbol,d.geometry,t),this._earlyReturn)break}this.pop()}drawTextSymbol(t,e,r){if(!t)return;if(!x(e))return;if(j(t.height,I.CIMTextSymbol.height)<=0)return;const i=at.createIdentity();let s=j(t.angle);s=-s,s&&i.rotate(s*st);const o=j(t.offsetX),n=j(t.offsetY);(o||n)&&i.translate(o,n);const a=this.geomUnitsPerPoint();1!==a&&i.scale(a,a),i.translate(e.x,e.y),this.push(i,!1),this.drawText(t,r),this.pop()}}class ht extends lt{constructor(t,e){super(t,e),this.reset()}reset(){this._xmin=this._ymin=1/0,this._xmax=this._ymax=-1/0,this._clipCount=0}envelope(){return new L(this._xmin,this._ymin,this._xmax-this._xmin,this._ymax-this._ymin)}bounds(){return h(this._xmin,this._ymin,this._xmax,this._ymax)}drawSolidFill(t){if(t&&!(this._clipCount>0))if(P(t))this._processPath(t.rings,0);else if(S(t))this._processPath(t.paths,0);else if(y(t)){const e=pt(t);e&&this._processPath(e.rings,0)}else console.error("drawSolidFill Unexpected geometry type!")}drawSolidStroke(t,e,r){if(!t||this._clipCount>0||null==r||r<=0)return;const i=Math.max(.5*this.transformSize(j(r,I.CIMSolidStroke.width)),.5*ot);if(P(t))this._processPath(t.rings,i);else if(S(t))this._processPath(t.paths,i);else if(y(t)){const e=pt(t);e&&this._processPath(e.rings,i)}else console.error("drawSolidStroke unexpected geometry type!")}drawMarkerLayer(t,e){P(e)&&t.markerPlacement&&("CIMMarkerPlacementInsidePolygon"===t.markerPlacement.type||"CIMMarkerPlacementPolygonCenter"===t.markerPlacement.type&&t.markerPlacement.clipAtBoundary)?this._processPath(e.rings,0):super.drawMarkerLayer(t,e)}drawHatchFill(t,e){this.drawSolidFill(t)}drawPictureFill(t,e){this.drawSolidFill(t)}drawGradientFill(t,e){this.drawSolidFill(t)}drawPictureStroke(t,e){this.drawSolidStroke(t,null,e.width)}drawGradientStroke(t,e){this.drawSolidStroke(t,null,e.width)}pushClipPath(t){this.drawSolidFill(t),this._clipCount++}popClipPath(){this._clipCount--}drawImage(t,e){const{url:r}=t,i=j(t.scaleX,1);let s=i*e,o=e;const n=this._resourceManager.getResource(r);if(null!=n){const t=n.height/n.width;s=i*(e?t>1?e:e/t:n.width),o=e?t>1?e*t:e:n.height}this._merge(this.transformPt([-s/2,-o/2]),0),this._merge(this.transformPt([-s/2,o/2]),0),this._merge(this.transformPt([s/2,-o/2]),0),this._merge(this.transformPt([s/2,o/2]),0)}drawText(t,e){if(!e||0===e.length)return;this._textRasterizer||(this._textRasterizer=new F);const r=yt(t);let[i,s]=this._textRasterizer.computeTextSize(e,r);i=o(i),s=o(s);const n=this.transformSize(1)*this.reverseTransformScalar(1);i*=n,s*=n;let a=0;switch(t.horizontalAlignment){case"Left":a=i/2;break;case"Right":a=-i/2}let l=0;switch(t.verticalAlignment){case"Bottom":l=s/2;break;case"Top":l=-s/2;break;case"Baseline":l=s/6}this._merge(this.transformPt([-i/2+a,-s/2+l]),0),this._merge(this.transformPt([-i/2+a,s/2+l]),0),this._merge(this.transformPt([i/2+a,-s/2+l]),0),this._merge(this.transformPt([i/2+a,s/2+l]),0)}_processPath(t,e){if(t)for(const r of t){const t=r?r.length:0;if(t>1){this._merge(this.transformPt(r[0]),e);for(let i=1;i<t;i++)this._merge(this.transformPt(r[i]),e)}}}_merge(t,e){t[0]-e<this._xmin&&(this._xmin=t[0]-e),t[0]+e>this._xmax&&(this._xmax=t[0]+e),t[1]-e<this._ymin&&(this._ymin=t[1]-e),t[1]+e>this._ymax&&(this._ymax=t[1]+e)}}class ct extends lt{constructor(){super(...arguments),this._searchPoint=[0,0],this._searchDistPoint=0,this._textInfo=null,this._svg=null,this._path=null,this._canvas=null}destroy(){this._svg=W(this._svg),this._path=null,this._canvas=null}hitTest(t,e,r,i,s,a){const l=a*n(1);this.setTransform(),this.setGeomUnitsPerPoint(l),this._searchPoint=[(t[0]+t[2])/2,(t[1]+t[3])/2],this._searchDistPoint=(t[2]-t[0])/2/l,this._textInfo=i;const h=e&&("CIMPointSymbol"===e.type&&"Map"!==e.angleAlignment||"CIMTextSymbol"===e.type);if(this._mapRotation=h?s:0,!has("esri-mobile")){const t=o(Z*window.devicePixelRatio),r=o(tt);!(("CIMLineSymbol"===e?.type||"CIMPolygonSymbol"===e?.type)&&e.symbolLayers?.some(U))&&"CIMMeshSymbol"!==e?.type&&(A(e)??0)<r&&(this._searchDistPoint=t)}return this._earlyReturn=!1,this.drawSymbol(e,r),this._earlyReturn}executeEffects(t,e){return"CIMGeometricEffectDashes"===t.at(-1)?.type&&(t=t.slice(0,-1)),super.executeEffects(t,e)}drawSolidFill(t,e,r){null!=r?this._hittestSvgPath(t,r,!0):this._hitTestFill(t)}drawHatchFill(t,e){this._hitTestFill(t)}drawPictureFill(t,e){this._hitTestFill(t)}drawGradientFill(t,e){this._hitTestFill(t)}drawSolidStroke(t,e,r,i,s,o,n){null!=n?this._hittestSvgPath(t,n,!1,r):this._hitTestStroke(t,r)}drawPictureStroke(t,e){this._hitTestStroke(t,e.width)}drawGradientStroke(t,e){this._hitTestStroke(t,e.width)}drawMarkerLayer(t,e){t.markerPlacement&&("CIMMarkerPlacementInsidePolygon"===t.markerPlacement.type||"CIMMarkerPlacementPolygonCenter"===t.markerPlacement.type&&t.markerPlacement.clipAtBoundary)?this._hitTestFill(e):super.drawMarkerLayer(t,e)}pushClipPath(t){}popClipPath(){}drawImage(t,e){const{url:r}=t,i=j(t.scaleX,1),s=this._resourceManager.getResource(r);if(null==s||0===s.height||0===e)return;const o=e*this.geomUnitsPerPoint(),n=o*i*(s.width/s.height),a=this.reverseTransformPt(this._searchPoint),l=this._searchDistPoint;Math.abs(a[0])<n/2+l&&Math.abs(a[1])<o/2+l&&(this._earlyReturn=!0)}drawText(t,e){const r=this._textInfo;if(!r)return;const i=r.get(t);if(!i)return;if(!i.glyphMosaicItems.glyphs.length)return;const s=rt(j(t.height,I.CIMTextSymbol.height)),{lineGapType:o,lineGap:n}=t,a=o?_t(o,j(n),s):0,l="CIMBackgroundCallout"===t.callout?.type,h=et(i.glyphMosaicItems,{scale:s/Q,angle:0,xOffset:0,yOffset:0,horizontalAlignment:t.horizontalAlignment,verticalAlignment:t.verticalAlignment,maxLineWidth:it(t.lineWidth),lineHeight:K*Math.max(.25,Math.min(a||1,4)),decoration:t.font.decoration||"none",useCIMAngleBehavior:!0,hasBackground:l}),c=this.reverseTransformPt(this._searchPoint),m=c[0],f=c[1];for(const u of h.glyphs)if(m>u.xTopLeft&&m<u.xBottomRight&&f>-u.yBottomRight&&f<-u.yTopLeft){this._earlyReturn=!0;break}}_hitTestFill(t){let e=null;if(y(t)){const r=t;e=[[[r.xmin,r.ymin],[r.xmin,r.ymax],[r.xmax,r.ymax],[r.xmax,r.ymin],[r.xmin,r.ymin]]]}else if(P(t))e=t.rings;else{if(!S(t))return;e=t.paths}const r=this.reverseTransformPt(this._searchPoint);if(ut(r,e)&&(this._earlyReturn=!0),!this._earlyReturn){dt(r,e,this.reverseTransformScalar(this._searchDistPoint)*this.prevGeomUnitsPerPoint())&&(this._earlyReturn=!0)}}_getSvgPath(){return null!=this._svg&&null!=this._path||(this._svg??=Y(),this._path??=$("path"),this._svg.appendChild(this._path)),this._path}_getCanvasContext(t,e){return this._canvas??=document.createElement("canvas"),this._canvas.width=t,this._canvas.height=e,this._canvas.getContext("2d",{willReadFrequently:!0})}_hittestSvgPath(t,e,r,i=0){const s=this.reverseTransformScalar(this._searchDistPoint)*this.prevGeomUnitsPerPoint(),o=this.reverseTransformPt(this._searchPoint),n=l();p(n,t);const a={x:n[0],y:n[1],width:n[2]-n[0],height:n[3]-n[1]},h=this._getSvgPath();h.setAttribute("d",e);const c=h.getBBox();let m=Math.max(c.width/a.width,c.height/a.height),f=1;const u=2*s*m;u<1&&(f=2/u,m*=f,c.x*=f,c.y*=f,c.width*=f,c.height*=f);const d=1+i*m/2,g=this._getCanvasContext(c.width+2*d,c.height+2*d);g.setTransform(f,0,0,f,-c.x+d,-c.y+d);const _=new Path2D(e);r?g.fill(_):(g.lineWidth=i*(m/f),g.stroke(_));const y=(a.width*m-c.width)/2,P=(a.height*m-c.height)/2,S=Math.floor((o[0]-a.x-s)*m-y+d),w=Math.floor((a.height-(o[1]-a.y)-s)*m+P+d),x=Math.ceil(2*s*m),M=Math.ceil(2*s*m),b=g.getImageData(S,w,x,M).data;for(let l=3;l<b.length;l+=4)if(b[l]>127.5)return void(this._earlyReturn=!0)}_hitTestStroke(t,e){let r=null;if(y(t)){const e=t;r=[[[e.xmin,e.ymin],[e.xmin,e.ymax],[e.xmax,e.ymax],[e.xmax,e.ymin],[e.xmin,e.ymin]]]}else if(P(t))r=t.rings;else{if(!S(t))return;r=t.paths}dt(this.reverseTransformPt(this._searchPoint),r,j(e,I.CIMSolidStroke.width)*this.geomUnitsPerPoint()/2+this.reverseTransformScalar(this._searchDistPoint)*this.prevGeomUnitsPerPoint())&&(this._earlyReturn=!0)}}class mt extends lt{constructor(t,e,r,i){super(e,r),this._applyAdditionalRenderProps=i,this._colorSubstitutionHelper=new b,this._ctx=t}drawSolidFill(t,e){if(!t)return;if(P(t))this._buildPath(t.rings,!0);else if(S(t))this._buildPath(t.paths,!0);else if(y(t))this._buildPath(pt(t).rings,!0);else{if(!w(t))return;console.log("CanvasDrawHelper.drawSolidFill - No implementation!")}const r=this._ctx;r.fillStyle="string"==typeof e?e:"rgba("+Math.round(e[0])+","+Math.round(e[1])+","+Math.round(e[2])+","+(e[3]??255)/255+")",r.fill("evenodd")}drawSolidStroke(t,e,r,i,s,o){if(!t||!e||0===r)return;if(P(t))this._buildPath(t.rings,!0);else if(S(t))this._buildPath(t.paths,!1);else{if(!y(t))return void console.log("CanvasDrawHelper.drawSolidStroke isn't implemented!");this._buildPath(pt(t).rings,!0)}const n=this._ctx;n.strokeStyle="string"==typeof e?e:"rgba("+Math.round(e[0])+","+Math.round(e[1])+","+Math.round(e[2])+","+(e[3]??255)/255+")",n.lineWidth=Math.max(this.transformSize(r),ot),this._setCapStyle(i),this._setJoinStyle(s),n.miterLimit=o,n.stroke()}pushClipPath(t){if(this._ctx.save(),P(t))this._buildPath(t.rings,!0);else if(S(t))this._buildPath(t.paths,!0);else{if(!y(t))return;this._buildPath(pt(t).rings,!0)}this._ctx.clip("evenodd")}popClipPath(){this._ctx.restore()}drawImage(t,e){const{colorSubstitutions:r,url:i,tintColor:s}=t,o=j(t.scaleX,1),n=this._resourceManager.getResource(i);if(null==n)return;let a=e*(n.width/n.height),l=e;e||(a=n.width,l=n.height);const h=G(i)||"src"in n&&G(n.src);let c="getFrame"in n?T(n):n;r&&(c=this._colorSubstitutionHelper.applyColorSubstitution(c,r)),this._applyAdditionalRenderProps&&!h&&s&&(c=this._colorSubstitutionHelper.tintImageData(c,s));const m=this.transformPt([0,0]),[f,u]=this.getTransformAngle(),d=this.transformSize(1),g=this._ctx;g.save(),g.setTransform({m11:o*d*f,m12:o*d*u,m21:-d*u,m22:d*f,m41:m[0],m42:m[1]}),g.drawImage(c,-a/2,-l/2,a,l),g.restore()}drawText(t,e){if(!e||0===e.length)return;this._textRasterizer||(this._textRasterizer=new F);const r=yt(t,this.transformSize(o(1))),i=this._textRasterizer.rasterizeText(e,r);if(!i)return;const{size:s,anchorX:n,anchorY:a,canvas:l}=i,h=s[0]*(n+.5),c=s[1]*(a-.5),m=this._ctx,f=this.transformPt([0,0]),[u,d]=this.getTransformAngle(),g=1;m.save(),m.setTransform({m11:g*u,m12:g*d,m21:-g*d,m22:g*u,m41:f[0]-g*h,m42:f[1]+g*c}),m.drawImage(l,0,0),m.restore()}drawPictureFill(t,e){if(!t)return;let{colorSubstitutions:r,height:i,offsetX:s,offsetY:o,rotation:n,scaleX:a,tintColor:l,url:h}=e;const c=this._resourceManager.getResource(h);if(null==c)return;if(P(t))this._buildPath(t.rings,!0);else if(S(t))this._buildPath(t.paths,!0);else if(y(t))this._buildPath(pt(t).rings,!0);else{if(!w(t))return;console.log("CanvasDrawHelper.drawPictureFill - No implementation!")}const m=this._ctx,f=G(h)||"src"in c&&G(c.src);let u,d="getFrame"in c?T(c):c;if(r&&(d=this._colorSubstitutionHelper.applyColorSubstitution(d,r)),this._applyAdditionalRenderProps){f||l&&(d=this._colorSubstitutionHelper.tintImageData(d,l)),u=m.createPattern(d,"repeat");const t=this.transformSize(1);n||(n=0),s?s*=t:s=0,o?o*=t:o=0,i&&(i*=t);const e=i?i/c.height:1,r=a&&i?a*i/c.width:1;if(0!==n||1!==e||1!==r||0!==s||0!==o){const t=new DOMMatrix;t.rotateSelf(0,0,-n).translateSelf(s,o).scaleSelf(r,e,1),u.setTransform(t)}}else u=m.createPattern(d,"repeat");m.save(),m.fillStyle=u,m.fill("evenodd"),m.restore()}drawPictureStroke(t,r){if(!t)return;let{colorSubstitutions:i,capStyle:s,joinStyle:o,miterLimit:a,tintColor:l,url:h,width:c}=r;const m=this._resourceManager.getResource(h);if(null==m)return;let f;if(P(t))f=t.rings;else if(S(t))f=t.paths;else{if(!y(t))return w(t)?void console.log("CanvasDrawHelper.drawPictureStroke - No implementation!"):void 0;f=pt(t).rings}c||(c=m.width);const u=G(h)||"src"in m&&G(m.src);let d="getFrame"in m?T(m):m;i&&(d=this._colorSubstitutionHelper.applyColorSubstitution(d,i)),this._applyAdditionalRenderProps&&(u||l&&(d=this._colorSubstitutionHelper.tintImageData(d,l)));const g=Math.max(this.transformSize(n(c)),.5),p=g/d.width,_=this._ctx,x=_.createPattern(d,"repeat-y");let M,b;_.save(),this._setCapStyle(s),this._setJoinStyle(o),void 0!==a&&(_.miterLimit=a),_.lineWidth=g;for(let n of f)if(n=e(n),St(n),n&&!(n.length<=1)){M=this.transformPt(n[0]);for(let t=1;t<n.length;t++){b=this.transformPt(n[t]);const e=gt(M,b),r=new DOMMatrix;r.translateSelf(0,M[1]-g/2).scaleSelf(p,p,1).rotateSelf(0,0,90-e),x.setTransform(r),_.strokeStyle=x,_.beginPath(),_.moveTo(M[0],M[1]),_.lineTo(b[0],b[1]),_.stroke(),M=b}}_.restore()}drawGradientFill(t,e){if(!t)return;let r;if(P(t))r=t.rings;else if(S(t))r=t.paths;else{if(!y(t))return void nt().error("Unable to draw gradient fill");r=pt(t).rings}this._buildPath(r,!0);const{angle:s,gradientMethod:o,gradientSize:a,gradientSizeUnits:l}=e,h=I.CIMGradientFill,p=e.gradientType??h.gradientType,_=-i(s??0),w=c();for(const i of r){const t=i?i.length:0;if(t>1)for(let e=0;e<t;e++){let t=this.transformPt(i[e]);"Linear"!==o&&"Rectangular"!==o||(t=R(t,-_)),m(w,t)}}const[x,M,b,k]=w,C=this._ctx;switch(C.save(),o){case"Buffered":nt().error(`Gradient method "${o}" currently unsupported.`);break;case"Linear":{const t=(M+k)/2,r="Absolute"===l?this.transformSize(n(a)):D(a,h.gradientSize)*(b-x),[i,s]="Discrete"===p?[b,b-r]:[x+r,x],o=R([i,t],_),c=R([s,t],_),m=C.createLinearGradient(o[0],o[1],c[0],c[1]);z(m,e),C.fillStyle=m,C.fill("evenodd");break}case"Circular":{const t=f(w),r=g(w)/2,i="Absolute"===l?this.transformSize(n(a)):D(a,h.gradientSize)*r,[s,o]="Discrete"===p?[r,r-i]:[i,0],c=C.createRadialGradient(t[0],t[1],s,t[0],t[1],o);z(c,e),C.fillStyle=c,C.fill("evenodd");break}case"Rectangular":{const r=f(w),i=r[0],s=r[1],o=R(r,_),c=(r,i,s,n,a,l,h,c)=>{C.save(),this.pushClipPath(t);const m=R([a,l],_),f=R([h,c],_);C.beginPath(),C.moveTo(o[0],o[1]),C.lineTo(m[0],m[1]),C.lineTo(f[0],f[1]),C.lineTo(o[0],o[1]),C.clip();const u=R([r,i],_),d=R([s,n],_),g=C.createLinearGradient(u[0],u[1],d[0],d[1]);z(g,e),C.fillStyle=g,C.fill("evenodd"),C.restore()};let m="Absolute"===l?this.transformSize(n(a)):D(a,h.gradientSize)*(u(w)/2),[g,y]="Discrete"===p?[b,b-m]:[i+m,i];c(g,s,y,s,b,M,b,k),[g,y]="Discrete"===p?[x,x+m]:[i-m,i],c(g,s,y,s,x,k,x,M),m="Absolute"===l?this.transformSize(n(a)):D(a,h.gradientSize)*(d(w)/2);let[P,S]="Discrete"===p?[k,k-m]:[s+m,s];c(i,P,i,S,b,k,x,k),[P,S]="Discrete"===p?[M,M+m]:[s-m,s],c(i,P,i,S,x,M,b,M);break}}C.restore()}drawGradientStroke(t,r){const{capStyle:i,gradientMethod:s,gradientSize:o,gradientSizeUnits:a,joinStyle:l,miterLimit:h,width:c}=r;if(!t||0===c)return;let m;if(P(t))m=t.rings;else if(S(t))m=t.paths;else{if(!y(t))return void nt().error("Unable to draw gradient stroke");m=pt(t).rings}const f=r.gradientType??I.CIMGradientStroke.gradientType,u=Math.max(this.transformSize(n(c)),.5),d=this._ctx;let g,p;d.save(),this._setCapStyle(i),this._setJoinStyle(l),void 0!==h&&(d.miterLimit=h),d.lineWidth=u;for(let _ of m){if(_=e(_),St(_),!_||_.length<=1)continue;let t=0;g=this.transformPt(_[0]);for(let e=1;e<_.length;e++){p=this.transformPt(_[e]);const r=p[0]-g[0],i=p[1]-g[1];t+=Math.sqrt(r*r+i*i),g=p}const i="Absolute"===a?this.transformSize(n(o)):D(o,I.CIMGradientStroke.gradientSize)*("AcrossLine"===s?u:t);let l=0;g=this.transformPt(_[0]);for(let e=1;e<_.length;e++){p=this.transformPt(_[e]);const o=p[0]-g[0],n=p[1]-g[1],a=Math.sqrt(o*o+n*n);let h,c,m,y;switch(s){case"AcrossLine":{const[t,e]=R([o/a,n/a],-Math.PI/2),r=u/2,s="Discrete"===f?r:i-r;h=(g[0]+p[0])/2+t*s,c=(g[1]+p[1])/2+e*s,m=h-t*i,y=c-e*i;break}case"AlongLine":{const e=o/a,r=n/a;"Discrete"===f?(h=g[0]-e*l,c=g[1]-r*l,m=h+e*i,y=c+r*i):(m=g[0]+e*(t-l),y=g[1]+r*(t-l),h=m-e*i,c=y-r*i);break}default:return nt().error("Unrecognized gradient method:",s),void d.restore()}const P=d.createLinearGradient(h,c,m,y);z(P,r),d.strokeStyle=P,d.beginPath(),d.moveTo(g[0],g[1]),d.lineTo(p[0],p[1]),d.stroke(),l+=a,g=p}}d.restore()}_buildPath(t,e){const r=this._ctx;if(r.beginPath(),t)for(const i of t){const t=i?i.length:0;if(t>1){let s=this.transformPt(i[0]);r.moveTo(s[0],s[1]);for(let e=1;e<t;e++)s=this.transformPt(i[e]),r.lineTo(s[0],s[1]);e&&r.closePath()}}}_setCapStyle(t){switch(t){case"Butt":this._ctx.lineCap="butt";break;case"Round":this._ctx.lineCap="round";break;case"Square":this._ctx.lineCap="square"}}_setJoinStyle(t){switch(t){case"Bevel":this._ctx.lineJoin="bevel";break;case"Round":this._ctx.lineJoin="round";break;case"Miter":this._ctx.lineJoin="miter"}}}function ft(t,e,r){let i=j(t.separation,I.CIMHatchFill.separation)*r,s=j(t.rotation);if(0===i)return null;i<0&&(i=-i);let o=0;const n=.5*i;for(;o>n;)o-=i;for(;o<-n;)o+=i;const a=l();p(a,e),a[0]-=n,a[1]-=n,a[2]+=n,a[3]+=n;const h=[[a[0],a[1]],[a[0],a[3]],[a[2],a[3]],[a[2],a[1]]];for(;s>180;)s-=180;for(;s<0;)s+=180;const c=Math.cos(s*st),m=Math.sin(s*st),f=-i*m,u=i*c;let d,g,_,y;o=j(t.offsetX)*r*m-j(t.offsetY)*r*c,d=_=Number.MAX_VALUE,g=y=-Number.MAX_VALUE;for(const l of h){const t=l[0],e=l[1],r=c*t+m*e,i=-m*t+c*e;d=Math.min(d,r),_=Math.min(_,i),g=Math.max(g,r),y=Math.max(y,i)}_=Math.floor(_/i)*i;let P=c*d-m*_-f*o/i,S=m*d+c*_-u*o/i,w=c*g-m*_-f*o/i,x=m*g+c*_-u*o/i;const M=1+Math.round((y-_)/i),b=[];for(let l=0;l<M;l++)P+=f,S+=u,w+=f,x+=u,b.push([[P,S],[w,x]]);return{paths:b}}function ut(t,e){let r=0;for(const i of e){const e=i.length;for(let s=1;s<e;s++){const e=i[s-1],o=i[s];if(e[1]>t[1]==o[1]>t[1])continue;(o[0]-e[0])*(t[1]-e[1])-(o[1]-e[1])*(t[0]-e[0])>0?r++:r--}}return 0!==r}function dt(t,e,r){for(const i of e){const e=i.length;for(let s=1;s<e;s++){const e=i[s-1],o=i[s];let n=(o[0]-e[0])*(o[0]-e[0])+(o[1]-e[1])*(o[1]-e[1]);if(0===n)continue;n=Math.sqrt(n);const a=((o[0]-e[0])*(t[1]-e[1])-(o[1]-e[1])*(t[0]-e[0]))/n;if(Math.abs(a)<r){const i=((o[0]-e[0])*(t[0]-e[0])+(o[1]-e[1])*(t[1]-e[1]))/n;if(i>-r&&i<n+r)return!0}}}return!1}function gt(t,e){const r=e[0]-t[0],i=e[1]-t[1];return 180/Math.PI*Math.atan2(i,r)}const pt=t=>t?{spatialReference:t.spatialReference,rings:[[[t.xmin,t.ymin],[t.xmin,t.ymax],[t.xmax,t.ymax],[t.xmax,t.ymin],[t.xmin,t.ymin]]]}:null,_t=(t,e,r)=>{switch(t){case"ExtraLeading":return 1+e/r;case"Multiple":return e;case"Exact":return e/r}};function yt(e,r=1){const i=H(e),s=B(e.fontStyleName),o=e.fontFamilyName??t,{weight:n,style:a}=s,l=r*(e.height||5),h=E(e.horizontalAlignment),c=X(e.verticalAlignment),m=J(e),f=J(e.haloSymbol),u=null!=f?r*(e.haloSize??0):0,d=N(e.symbol),g=r*(O(e.symbol)||0),p="CIMBackgroundCallout"===e.callout?.type?e.callout.backgroundSymbol:null,_=J(p),y=O(p),P=N(p);return{color:m,size:l,horizontalAlignment:h,verticalAlignment:c,font:{family:o,style:V(a),weight:q(n),decoration:i},outline:{size:g||0,color:d},halo:{size:u||0,color:f,style:a},backgroundColor:_,borderLine:null!=y&&null!=P?{size:y,color:P}:null,pixelRatio:1,premultiplyColors:!0}}const Pt=1e-4;function St(t){let e,r,i,s,o,n=t[0],a=1;for(;a<t.length;)e=t[a][0]-n[0],r=t[a][1]-n[1],s=0!==e?r/e:Math.PI/2,void 0!==i&&Math.abs(s-i)<=Pt?(t.splice(a-1,1),n=o):(o=n,n=t[a],a++),i=s}export{lt as CIMSymbolDrawHelper,mt as CanvasDrawHelper,ht as EnvDrawHelper,ct as HittestDrawHelper,at as Transformation,st as cDegToRad,_t as lineGapType2LineHeight};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{trackAccess as e}from"../../../core/accessorSupport/tracking.js";import{SimpleObservable as t}from"../../../core/accessorSupport/tracking/SimpleObservable.js";import{create as i}from"../../../core/libs/gl-matrix-2/factories/mat3f32.js";import{EffectView as r}from"../../../layers/effects/EffectView.js";import{DisplayObject as s}from"./DisplayObject.js";class n extends s{constructor(){super(...arguments),this._childrenSet=new Set,this._needsSort=!1,this._children=[],this._childrenObservable=new t,this._effectView=null,this._highlightGradient=null}get blendMode(){return this._blendMode}set blendMode(e){this._blendMode=e,this.requestRender()}get children(){return e(this._childrenObservable),this._children}get clips(){return this._clips}set clips(e){this._clips=e,this.children.forEach(t=>t.clips=e)}get computedEffects(){return this._effectView?.effects??null}get effect(){return this._effectView?.effect??""}set effect(e){(this._effectView||e)&&(this._effectView||(this._effectView=new r,this.addTransitionable(this._effectView)),this._effectView.effect=e,this.requestRender())}get highlightGradient(){return this._highlightGradient}set highlightGradient(e){this._highlightGradient=e,this.requestRender()}get hasBlending(){return!!this.blendMode}get hasHighlight(){return this.children.some(e=>e.hasHighlight)}get hasLabels(){return this.children.some(e=>e.hasLabels)}get requiresDedicatedFBO(){return this.children.some(e=>"blendMode"in e&&e.blendMode&&"normal"!==e.blendMode)}get isReady(){return this.children.every(e=>e.isReady)}get sortFunction(){return this._sortFunction}set sortFunction(e){this._sortFunction=e,e&&(this._needsSort=!0)}doRender(e){const t=this.createRenderParams(e),{painter:i}=t;i.beforeRenderLayer(t,this._clips?.length?255:0,this.computedOpacity),this.renderChildren(t),i.afterRenderLayer(t,this.computedOpacity)}addChild(e){return this.addChildAt(e,this.children.length)}addChildAt(e,t=this.children.length){if(!e)return e;if(this.contains(e))return e;this._needsSort=!0;const i=e.parent;return i&&i!==this&&i.removeChild(e),t>=this.children.length?this.children.push(e):this.children.splice(t,0,e),this._childrenSet.add(e),e.parent=this,e.stage=this.stage,this!==this.stage&&(e.clips=this.clips),this.requestRender(),this._childrenObservable.notify(),e}contains(t){return e(this._childrenObservable),this._childrenSet.has(t)}removeAllChildren(){this._childrenSet.clear(),this._needsSort=!0;for(const e of this.children)this!==this.stage&&(e.clips=null),e.stage=null,e.parent=null;this.children.length=0,this._childrenObservable.notify()}removeChild(e){return this.contains(e)?this.removeChildAt(this.children.indexOf(e)):e}removeChildAt(e){if(e<0||e>=this.children.length)return null;this._needsSort=!0;const t=this.children.splice(e,1)[0];return this._childrenSet.delete(t),this!==this.stage&&(t.clips=null),t.stage=null,t.parent=null,this._childrenObservable.notify(),t}beforeRender(e){super.beforeRender(e),this.sortFunction&&this._needsSort&&(this.children.sort(this.sortFunction),this._needsSort=!1,this._childrenObservable.notify());for(const t of this.children)t.beforeRender(e)}afterRender(e){super.afterRender(e);for(const t of this.children)t.afterRender(e)}_createTransforms(){return{displayViewScreenMat3:i()}}onAttach(){super.onAttach();const e=this.stage;for(const t of this.children)t.stage=e}onDetach(){super.onDetach();for(const e of this.children)e.stage=null}renderChildren(e){for(const t of this.children)t.processRender(e)}createRenderParams(e){return{...e,requireFBO:this.requiresDedicatedFBO,blendMode:this.blendMode,effects:this.computedEffects,globalOpacity:e.globalOpacity*this.computedOpacity,inFadeTransition:this.inFadeTransition,highlightGradient:this._highlightGradient||e.highlightGradient}}isTransitioning(){return super.isTransitioning()||this.children.some(e=>e.transitioning)}}export{n as Container};
|
|
5
|
+
import{trackAccess as e}from"../../../core/accessorSupport/tracking.js";import{SimpleObservable as t}from"../../../core/accessorSupport/tracking/SimpleObservable.js";import{create as i}from"../../../core/libs/gl-matrix-2/factories/mat3f32.js";import{EffectView as r}from"../../../layers/effects/EffectView.js";import{DisplayObject as s}from"./DisplayObject.js";class n extends s{constructor(){super(...arguments),this._childrenSet=new Set,this._needsSort=!1,this._children=[],this._childrenObservable=new t,this._effectView=null,this._highlightGradient=null}get blendMode(){return this._blendMode}set blendMode(e){this._blendMode=e,this.requestRender()}get children(){return e(this._childrenObservable),this._children}get clips(){return this._clips}set clips(e){this._clips=e,this.children.forEach(t=>t.clips=e)}get computedEffects(){return this._effectView?.effects??null}get effect(){return this._effectView?.effect??""}set effect(e){(this._effectView||e)&&(this._effectView||(this._effectView=new r,this.addTransitionable(this._effectView)),this._effectView.effect=e,this.requestRender())}get highlightGradient(){return this._highlightGradient}set highlightGradient(e){this._highlightGradient=e,this.requestRender()}get hasBlending(){return!!this.blendMode}get hasHighlight(){return this.children.some(e=>e.hasHighlight)}get hasLabels(){return this.children.some(e=>e.hasLabels)}get requiresDedicatedFBO(){return this.children.some(e=>"blendMode"in e&&e.blendMode&&"normal"!==e.blendMode)}get isReady(){return this.children.every(e=>e.isReady)}get sortFunction(){return this._sortFunction}set sortFunction(e){this._sortFunction=e,e&&(this._needsSort=!0)}get usedMemory(){return this.children.reduce((e,t)=>e+t.usedMemory,0)}doRender(e){const t=this.createRenderParams(e),{painter:i}=t;i.beforeRenderLayer(t,this._clips?.length?255:0,this.computedOpacity),this.renderChildren(t),i.afterRenderLayer(t,this.computedOpacity)}addChild(e){return this.addChildAt(e,this.children.length)}addChildAt(e,t=this.children.length){if(!e)return e;if(this.contains(e))return e;this._needsSort=!0;const i=e.parent;return i&&i!==this&&i.removeChild(e),t>=this.children.length?this.children.push(e):this.children.splice(t,0,e),this._childrenSet.add(e),e.parent=this,e.stage=this.stage,this!==this.stage&&(e.clips=this.clips),this.requestRender(),this._childrenObservable.notify(),e}contains(t){return e(this._childrenObservable),this._childrenSet.has(t)}removeAllChildren(){this._childrenSet.clear(),this._needsSort=!0;for(const e of this.children)this!==this.stage&&(e.clips=null),e.stage=null,e.parent=null;this.children.length=0,this._childrenObservable.notify()}removeChild(e){return this.contains(e)?this.removeChildAt(this.children.indexOf(e)):e}removeChildAt(e){if(e<0||e>=this.children.length)return null;this._needsSort=!0;const t=this.children.splice(e,1)[0];return this._childrenSet.delete(t),this!==this.stage&&(t.clips=null),t.stage=null,t.parent=null,this._childrenObservable.notify(),t}beforeRender(e){super.beforeRender(e),this.sortFunction&&this._needsSort&&(this.children.sort(this.sortFunction),this._needsSort=!1,this._childrenObservable.notify());for(const t of this.children)t.beforeRender(e)}afterRender(e){super.afterRender(e);for(const t of this.children)t.afterRender(e)}_createTransforms(){return{displayViewScreenMat3:i()}}onAttach(){super.onAttach();const e=this.stage;for(const t of this.children)t.stage=e}onDetach(){super.onDetach();for(const e of this.children)e.stage=null}renderChildren(e){for(const t of this.children)t.processRender(e)}createRenderParams(e){return{...e,requireFBO:this.requiresDedicatedFBO,blendMode:this.blendMode,effects:this.computedEffects,globalOpacity:e.globalOpacity*this.computedOpacity,inFadeTransition:this.inFadeTransition,highlightGradient:this._highlightGradient||e.highlightGradient}}isTransitioning(){return super.isTransitioning()||this.children.some(e=>e.transitioning)}}export{n as Container};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{remove as t}from"../../../core/arrayUtils.js";import{Evented as i}from"../../../core/Evented.js";import{FadeTransition as s}from"./transitions/FadeTransition.js";class e extends i{constructor(){super(...arguments),this._transitionables=null,this._clips=null,this._fadeTransition=null,this._isReady=!1,this._opacity=1,this.parent=null,this._stage=null,this._visible=!0}get computedOpacity(){return this._fadeTransition?.computedOpacity??this.opacity}get clips(){return this._clips}set clips(t){this._clips=t,this.requestRender()}get fadeTransitionEnabled(){return null!==this._fadeTransition}set fadeTransitionEnabled(t){!this._fadeTransition&&t?(this._fadeTransition=new s({opacity:this.opacity,visible:this.visible}),this.addTransitionable(this._fadeTransition)):this._fadeTransition&&!t&&(this.removeTransitionable(this._fadeTransition),this._fadeTransition=null)}get inFadeTransition(){return this._fadeTransition?.transitioning??!1}get isReady(){return this._isReady}get opacity(){return this._opacity}set opacity(t){this._opacity!==t&&(this._opacity=Math.min(1,Math.max(t,0)),this._fadeTransition&&(this._fadeTransition.opacity=this._opacity),this.requestRender())}get stage(){return this._stage}set stage(t){if(this._stage===t)return;const i=this._stage;this._stage=t,t?this._stage?.untrashDisplayObject(this)||(this.onAttach(),this.emit("attach")):i?.trashDisplayObject(this)}get transforms(){return null==this._transforms&&(this._transforms=this._createTransforms()),this._transforms}get transitioning(){return this.isTransitioning()}get visible(){return this._visible}set visible(t){this._visible!==t&&(this._visible=t,this._fadeTransition&&(this._fadeTransition.visible=this._visible),this.requestRender())}get hasLabels(){return!1}get hasHighlight(){return!1}get hasBlending(){return!1}addTransitionable(t){this._transitionables??=[],this._transitionables.push(t),this.requestRender()}removeTransitionable(i){i.endTransition(),this._transitionables&&t(this._transitionables,i),this.requestRender()}fadeIn(){this.fadeTransitionEnabled=!0;const t=this._fadeTransition.fadeIn();return this.opacity=1,this.requestRender(),t}fadeOut(){this.fadeTransitionEnabled=!0;const t=this._fadeTransition.fadeOut();return this.opacity=0,this.requestRender(),t}endTransitions(){if(this._transitionables){for(const t of this._transitionables)t.endTransition();this.requestRender()}}beforeRender(t){this.transitionStep(t.deltaTime,t.state.scale),this.setTransform(t.state)}afterRender(t){this.transitioning&&this.requestRender()}remove(){this.parent?.removeChild(this)}setTransform(t){}processRender(t){this.stage&&(this._fadeTransition?.computedVisible??this.visible)&&this.doRender(t)}requestRender(){this.stage&&this.stage.requestRender()}processDetach(){this.endTransitions(),this.onDetach(),this.emit("detach")}isTransitioning(){return this._transitionables?.some(t=>t.transitioning)??!1}transitionStep(t,i){if(this._transitionables)for(const s of this._transitionables)s.transitionStep(t,i)}onAttach(){}onDetach(){}doRender(t){}ready(){this._isReady||(this._isReady=!0,this.emit("isReady"),this.requestRender())}}export{e as DisplayObject};
|
|
5
|
+
import{remove as t}from"../../../core/arrayUtils.js";import{Evented as i}from"../../../core/Evented.js";import{FadeTransition as s}from"./transitions/FadeTransition.js";class e extends i{constructor(){super(...arguments),this._transitionables=null,this._clips=null,this._fadeTransition=null,this._isReady=!1,this._opacity=1,this.parent=null,this._stage=null,this._visible=!0}get computedOpacity(){return this._fadeTransition?.computedOpacity??this.opacity}get clips(){return this._clips}set clips(t){this._clips=t,this.requestRender()}get fadeTransitionEnabled(){return null!==this._fadeTransition}set fadeTransitionEnabled(t){!this._fadeTransition&&t?(this._fadeTransition=new s({opacity:this.opacity,visible:this.visible}),this.addTransitionable(this._fadeTransition)):this._fadeTransition&&!t&&(this.removeTransitionable(this._fadeTransition),this._fadeTransition=null)}get inFadeTransition(){return this._fadeTransition?.transitioning??!1}get isReady(){return this._isReady}get opacity(){return this._opacity}set opacity(t){this._opacity!==t&&(this._opacity=Math.min(1,Math.max(t,0)),this._fadeTransition&&(this._fadeTransition.opacity=this._opacity),this.requestRender())}get stage(){return this._stage}set stage(t){if(this._stage===t)return;const i=this._stage;this._stage=t,t?this._stage?.untrashDisplayObject(this)||(this.onAttach(),this.emit("attach")):i?.trashDisplayObject(this)}get transforms(){return null==this._transforms&&(this._transforms=this._createTransforms()),this._transforms}get transitioning(){return this.isTransitioning()}get usedMemory(){return 0}get visible(){return this._visible}set visible(t){this._visible!==t&&(this._visible=t,this._fadeTransition&&(this._fadeTransition.visible=this._visible),this.requestRender())}get hasLabels(){return!1}get hasHighlight(){return!1}get hasBlending(){return!1}addTransitionable(t){this._transitionables??=[],this._transitionables.push(t),this.requestRender()}removeTransitionable(i){i.endTransition(),this._transitionables&&t(this._transitionables,i),this.requestRender()}fadeIn(){this.fadeTransitionEnabled=!0;const t=this._fadeTransition.fadeIn();return this.opacity=1,this.requestRender(),t}fadeOut(){this.fadeTransitionEnabled=!0;const t=this._fadeTransition.fadeOut();return this.opacity=0,this.requestRender(),t}endTransitions(){if(this._transitionables){for(const t of this._transitionables)t.endTransition();this.requestRender()}}beforeRender(t){this.transitionStep(t.deltaTime,t.state.scale),this.setTransform(t.state)}afterRender(t){this.transitioning&&this.requestRender()}remove(){this.parent?.removeChild(this)}setTransform(t){}processRender(t){this.stage&&(this._fadeTransition?.computedVisible??this.visible)&&this.doRender(t)}requestRender(){this.stage&&this.stage.requestRender()}processDetach(){this.endTransitions(),this.onDetach(),this.emit("detach")}isTransitioning(){return this._transitionables?.some(t=>t.transitioning)??!1}transitionStep(t,i){if(this._transitionables)for(const s of this._transitionables)s.transitionStep(t,i)}onAttach(){}onDetach(){}doRender(t){}ready(){this._isReady||(this._isReady=!0,this.emit("isReady"),this.requestRender())}}export{e as DisplayObject};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import has from"../../../../core/has.js";import t from"../../../../core/Logger.js";import{deg2rad as e}from"../../../../core/mathUtils.js";import{throwIfAborted as n}from"../../../../core/promiseUtils.js";import r from"../../../../core/RandomLCG.js";import o from"../../../../geometry/Extent.js";import{getInfo as l}from"../../../../geometry/support/spatialReferenceUtils.js";const i=()=>t.getLogger("esri.views.2d.engine.flow.dataUtils"),a=10;async function s(t,e,r,o){const l=performance.now(),s=c(e,r),f=performance.now(),h=u(e,s,r.width,r.height),p=performance.now(),g=m(h,!0),y=performance.now(),x="Streamlines"===t?d(g,a):w(g),M=performance.now();return has("esri-2d-profiler")&&(i().info("I.1","_createFlowFieldFromData (ms)",Math.round(f-l)),i().info("I.2","_getStreamlines (ms)",Math.round(p-f)),i().info("I.3","createAnimatedLinesData (ms)",Math.round(y-p)),i().info("I.4","create{Streamlines|Particles}Mesh (ms)",Math.round(M-y)),i().info("I.5","createFlowMesh (ms)",Math.round(M-l)),i().info("I.6","Mesh size (bytes)",x.vertexData.buffer.byteLength+x.indexData.buffer.byteLength)),await Promise.resolve(),n(o),x}function c(t,e){const n=h(e.data,e.width,e.height,t.smoothing);if(t.interpolate){return(t,r)=>{const o=Math.floor(t),l=Math.floor(r);if(o<0||o>=e.width)return[0,0];if(l<0||l>=e.height)return[0,0];const i=t-o,a=r-l,s=o,c=l,f=o<e.width-1?o+1:o,u=l<e.height-1?l+1:l,h=n[2*(c*e.width+s)],m=n[2*(c*e.width+f)],d=n[2*(u*e.width+s)],w=n[2*(u*e.width+f)],p=n[2*(c*e.width+s)+1],g=n[2*(c*e.width+f)+1];return[(h*(1-a)+d*a)*(1-i)+(m*(1-a)+w*a)*i,(p*(1-a)+n[2*(u*e.width+s)+1]*a)*(1-i)+(g*(1-a)+n[2*(u*e.width+f)+1]*a)*i]}}return(t,r)=>{const o=Math.round(t),l=Math.round(r);return o<0||o>=e.width||l<0||l>=e.height?[0,0]:[n[2*(l*e.width+o)],n[2*(l*e.width+o)+1]]}}function f(t,e,n,r,o,l,i,a,s){const c=[];let f=n,u=r,h=0,[m,d]=e(f,u);m*=t.velocityScale,d*=t.velocityScale;const w=Math.sqrt(m*m+d*d);let p,g;c.push({x:f,y:u,t:h,speed:w});for(let y=0;y<t.verticesPerLine;y++){let[n,r]=e(f,u);n*=t.velocityScale,r*=t.velocityScale;const m=Math.sqrt(n*n+r*r);if(m<t.minSpeedThreshold)return c;const d=n/m,w=r/m;f+=d*t.segmentLength,u+=w*t.segmentLength;if(h+=t.segmentLength/m,Math.acos(d*p+w*g)>t.maxTurnAngle)return c;if(t.collisions){const t=Math.round(f*s),e=Math.round(u*s);if(t<0||t>i-1||e<0||e>a-1)return c;const n=l[e*i+t];if(-1!==n&&n!==o)return c;l[e*i+t]=o}c.push({x:f,y:u,t:h,speed:m}),p=d,g=w}return c}function u(t,e,n,o){const l=[],i=new r,a=1/Math.max(t.lineCollisionWidth,1),s=Math.round(n*a),c=Math.round(o*a),u=new Int32Array(s*c);for(let r=0;r<u.length;r++)u[r]=-1;const h=[];for(let r=0;r<o;r+=t.lineSpacing)for(let e=0;e<n;e+=t.lineSpacing)h.push({x:e,y:r,sort:i.getFloat()});h.sort((t,e)=>t.sort-e.sort);for(const{x:r,y:m}of h)if(i.getFloat()<t.density){const n=f(t,e,r,m,l.length,u,s,c,a);if(n.length<2)continue;l.push(n)}return l}function h(t,e,n,r){if(0===r)return t;const o=Math.round(3*r),l=new Array(2*o+1);let i=0;for(let c=-o;c<=o;c++){const t=Math.exp(-c*c/(r*r));l[c+o]=t,i+=t}for(let c=-o;c<=o;c++)l[c+o]/=i;const a=new Float32Array(t.length);for(let c=0;c<n;c++)for(let n=0;n<e;n++){let r=0,i=0;for(let a=-o;a<=o;a++){if(n+a<0||n+a>=e)continue;const s=l[a+o];r+=s*t[2*(c*e+(n+a))],i+=s*t[2*(c*e+(n+a))+1]}a[2*(c*e+n)]=r,a[2*(c*e+n)+1]=i}const s=new Float32Array(t.length);for(let c=0;c<e;c++)for(let t=0;t<n;t++){let r=0,i=0;for(let s=-o;s<=o;s++){if(t+s<0||t+s>=n)continue;const f=l[s+o];r+=f*a[2*((t+s)*e+c)],i+=f*a[2*((t+s)*e+c)+1]}s[2*(t*e+c)]=r,s[2*(t*e+c)+1]=i}return s}function m(t,e){const n=new r,o=t.reduce((t,e)=>t+e.length,0),l=new Float32Array(4*o),i=new Array(t.length);let a=0,s=0;for(const r of t){const t=a;for(const e of r)l[4*a]=e.x,l[4*a+1]=e.y,l[4*a+2]=e.t,l[4*a+3]=e.speed,a++;i[s++]={startVertex:t,numberOfVertices:r.length,totalTime:r[r.length-1].t,timeSeed:e?n.getFloat():0}}return{lineVertices:l,lineDescriptors:i}}function d(t,e){const n=9,{lineVertices:r,lineDescriptors:o}=t;let l=0,i=0;for(const m of o){l+=2*m.numberOfVertices;i+=6*(m.numberOfVertices-1)}const a=new Float32Array(l*n),s=new Uint32Array(i);let c=0,f=0;function u(){s[f++]=c-2,s[f++]=c,s[f++]=c-1,s[f++]=c,s[f++]=c+1,s[f++]=c-1}function h(t,e,r,o,l,i,s,f){const u=c*n;let h=0;a[u+h++]=t,a[u+h++]=e,a[u+h++]=1,a[u+h++]=r,a[u+h++]=i,a[u+h++]=s,a[u+h++]=o/2,a[u+h++]=l/2,a[u+h++]=f,c++,a[u+h++]=t,a[u+h++]=e,a[u+h++]=-1,a[u+h++]=r,a[u+h++]=i,a[u+h++]=s,a[u+h++]=-o/2,a[u+h++]=-l/2,a[u+h++]=f,c++}for(const m of o){const{totalTime:t,timeSeed:n}=m;let o=null,l=null,i=null,a=null,s=null,c=null;for(let f=0;f<m.numberOfVertices;f++){const d=r[4*(m.startVertex+f)],w=r[4*(m.startVertex+f)+1],p=r[4*(m.startVertex+f)+2],g=r[4*(m.startVertex+f)+3];let y=null,x=null,M=null,A=null;if(f>0){y=d-o,x=w-l;const r=Math.sqrt(y*y+x*x);if(y/=r,x/=r,f>1){let t=y+s,n=x+c;const r=Math.sqrt(t*t+n*n);t/=r,n/=r;const o=Math.min(1/(t*y+n*x),e);t*=o,n*=o,M=-n,A=t}else M=-x,A=y;null!==M&&null!==A&&(h(o,l,i,M,A,t,n,g),u())}o=d,l=w,i=p,s=y,c=x,a=g}h(o,l,i,-c,s,t,n,a)}return{vertexData:a,indexData:s}}function w(t){const e=16,n=1,r=2,{lineVertices:o,lineDescriptors:l}=t;let i=0,a=0;for(const U of l){const t=U.numberOfVertices-1;i+=4*t*2,a+=6*t*2}const s=new Float32Array(i*e),c=new Uint32Array(a);let f,u,h,m,d,w,p,g,y,x,M,A,I,V,F=0,v=0;function D(){c[v++]=F-8,c[v++]=F-7,c[v++]=F-6,c[v++]=F-7,c[v++]=F-5,c[v++]=F-6,c[v++]=F-4,c[v++]=F-3,c[v++]=F-2,c[v++]=F-3,c[v++]=F-1,c[v++]=F-2}function b(t,o,l,i,a,c,f,u,h,m,d,w,p,g){const y=F*e;let x=0;for(const e of[n,r])for(const n of[1,2,3,4])s[y+x++]=t,s[y+x++]=o,s[y+x++]=l,s[y+x++]=i,s[y+x++]=f,s[y+x++]=u,s[y+x++]=h,s[y+x++]=m,s[y+x++]=e,s[y+x++]=n,s[y+x++]=p,s[y+x++]=g,s[y+x++]=a/2,s[y+x++]=c/2,s[y+x++]=d/2,s[y+x++]=w/2,F++}function S(t,e){let n=y+M,r=x+A;const o=Math.sqrt(n*n+r*r);n/=o,r/=o;const l=y*n+x*r;n/=l,r/=l;let i=M+I,a=A+V;const s=Math.sqrt(i*i+a*a);i/=s,a/=s;const c=M*i+A*a;i/=c,a/=c,b(f,u,h,m,-r,n,d,w,p,g,-a,i,t,e),D()}function k(t,e,n,r,o,l){if(y=M,x=A,M=I,A=V,null==y&&null==x&&(y=M,x=A),null!=d&&null!=w){I=t-d,V=e-w;const n=Math.sqrt(I*I+V*V);I/=n,V/=n}null!=y&&null!=x&&S(o,l),f=d,u=w,h=p,m=g,d=t,w=e,p=n,g=r}function L(t,e){y=M,x=A,M=I,A=V,null==y&&null==x&&(y=M,x=A),null!=y&&null!=x&&S(t,e)}for(const U of l){f=null,u=null,h=null,m=null,d=null,w=null,p=null,g=null,y=null,x=null,M=null,A=null,I=null,V=null;const{totalTime:t,timeSeed:e}=U;for(let n=0;n<U.numberOfVertices;n++){k(o[4*(U.startVertex+n)],o[4*(U.startVertex+n)+1],o[4*(U.startVertex+n)+2],o[4*(U.startVertex+n)+3],t,e)}L(t,e)}return{vertexData:s,indexData:c}}function p(t,n){const r=n.pixels,{width:o,height:l}=n,i=new Float32Array(o*l*2),a=n.mask
|
|
5
|
+
import has from"../../../../core/has.js";import t from"../../../../core/Logger.js";import{deg2rad as e}from"../../../../core/mathUtils.js";import{throwIfAborted as n}from"../../../../core/promiseUtils.js";import r from"../../../../core/RandomLCG.js";import o from"../../../../geometry/Extent.js";import{getInfo as l}from"../../../../geometry/support/spatialReferenceUtils.js";const i=()=>t.getLogger("esri.views.2d.engine.flow.dataUtils"),a=10;async function s(t,e,r,o){const l=performance.now(),s=c(e,r),f=performance.now(),h=u(e,s,r.width,r.height),p=performance.now(),g=m(h,!0),y=performance.now(),x="Streamlines"===t?d(g,a):w(g),M=performance.now();return has("esri-2d-profiler")&&(i().info("I.1","_createFlowFieldFromData (ms)",Math.round(f-l)),i().info("I.2","_getStreamlines (ms)",Math.round(p-f)),i().info("I.3","createAnimatedLinesData (ms)",Math.round(y-p)),i().info("I.4","create{Streamlines|Particles}Mesh (ms)",Math.round(M-y)),i().info("I.5","createFlowMesh (ms)",Math.round(M-l)),i().info("I.6","Mesh size (bytes)",x.vertexData.buffer.byteLength+x.indexData.buffer.byteLength)),await Promise.resolve(),n(o),x}function c(t,e){const n=h(e.data,e.width,e.height,t.smoothing);if(t.interpolate){return(t,r)=>{const o=Math.floor(t),l=Math.floor(r);if(o<0||o>=e.width)return[0,0];if(l<0||l>=e.height)return[0,0];const i=t-o,a=r-l,s=o,c=l,f=o<e.width-1?o+1:o,u=l<e.height-1?l+1:l,h=n[2*(c*e.width+s)],m=n[2*(c*e.width+f)],d=n[2*(u*e.width+s)],w=n[2*(u*e.width+f)],p=n[2*(c*e.width+s)+1],g=n[2*(c*e.width+f)+1];return[(h*(1-a)+d*a)*(1-i)+(m*(1-a)+w*a)*i,(p*(1-a)+n[2*(u*e.width+s)+1]*a)*(1-i)+(g*(1-a)+n[2*(u*e.width+f)+1]*a)*i]}}return(t,r)=>{const o=Math.round(t),l=Math.round(r);return o<0||o>=e.width||l<0||l>=e.height?[0,0]:[n[2*(l*e.width+o)],n[2*(l*e.width+o)+1]]}}function f(t,e,n,r,o,l,i,a,s){const c=[];let f=n,u=r,h=0,[m,d]=e(f,u);m*=t.velocityScale,d*=t.velocityScale;const w=Math.sqrt(m*m+d*d);let p,g;c.push({x:f,y:u,t:h,speed:w});for(let y=0;y<t.verticesPerLine;y++){let[n,r]=e(f,u);n*=t.velocityScale,r*=t.velocityScale;const m=Math.sqrt(n*n+r*r);if(m<t.minSpeedThreshold)return c;const d=n/m,w=r/m;f+=d*t.segmentLength,u+=w*t.segmentLength;if(h+=t.segmentLength/m,Math.acos(d*p+w*g)>t.maxTurnAngle)return c;if(t.collisions){const t=Math.round(f*s),e=Math.round(u*s);if(t<0||t>i-1||e<0||e>a-1)return c;const n=l[e*i+t];if(-1!==n&&n!==o)return c;l[e*i+t]=o}c.push({x:f,y:u,t:h,speed:m}),p=d,g=w}return c}function u(t,e,n,o){const l=[],i=new r,a=1/Math.max(t.lineCollisionWidth,1),s=Math.round(n*a),c=Math.round(o*a),u=new Int32Array(s*c);for(let r=0;r<u.length;r++)u[r]=-1;const h=[];for(let r=0;r<o;r+=t.lineSpacing)for(let e=0;e<n;e+=t.lineSpacing)h.push({x:e,y:r,sort:i.getFloat()});h.sort((t,e)=>t.sort-e.sort);for(const{x:r,y:m}of h)if(i.getFloat()<t.density){const n=f(t,e,r,m,l.length,u,s,c,a);if(n.length<2)continue;l.push(n)}return l}function h(t,e,n,r){if(0===r)return t;const o=Math.round(3*r),l=new Array(2*o+1);let i=0;for(let c=-o;c<=o;c++){const t=Math.exp(-c*c/(r*r));l[c+o]=t,i+=t}for(let c=-o;c<=o;c++)l[c+o]/=i;const a=new Float32Array(t.length);for(let c=0;c<n;c++)for(let n=0;n<e;n++){let r=0,i=0;for(let a=-o;a<=o;a++){if(n+a<0||n+a>=e)continue;const s=l[a+o];r+=s*t[2*(c*e+(n+a))],i+=s*t[2*(c*e+(n+a))+1]}a[2*(c*e+n)]=r,a[2*(c*e+n)+1]=i}const s=new Float32Array(t.length);for(let c=0;c<e;c++)for(let t=0;t<n;t++){let r=0,i=0;for(let s=-o;s<=o;s++){if(t+s<0||t+s>=n)continue;const f=l[s+o];r+=f*a[2*((t+s)*e+c)],i+=f*a[2*((t+s)*e+c)+1]}s[2*(t*e+c)]=r,s[2*(t*e+c)+1]=i}return s}function m(t,e){const n=new r,o=t.reduce((t,e)=>t+e.length,0),l=new Float32Array(4*o),i=new Array(t.length);let a=0,s=0;for(const r of t){const t=a;for(const e of r)l[4*a]=e.x,l[4*a+1]=e.y,l[4*a+2]=e.t,l[4*a+3]=e.speed,a++;i[s++]={startVertex:t,numberOfVertices:r.length,totalTime:r[r.length-1].t,timeSeed:e?n.getFloat():0}}return{lineVertices:l,lineDescriptors:i}}function d(t,e){const n=9,{lineVertices:r,lineDescriptors:o}=t;let l=0,i=0;for(const m of o){l+=2*m.numberOfVertices;i+=6*(m.numberOfVertices-1)}const a=new Float32Array(l*n),s=new Uint32Array(i);let c=0,f=0;function u(){s[f++]=c-2,s[f++]=c,s[f++]=c-1,s[f++]=c,s[f++]=c+1,s[f++]=c-1}function h(t,e,r,o,l,i,s,f){const u=c*n;let h=0;a[u+h++]=t,a[u+h++]=e,a[u+h++]=1,a[u+h++]=r,a[u+h++]=i,a[u+h++]=s,a[u+h++]=o/2,a[u+h++]=l/2,a[u+h++]=f,c++,a[u+h++]=t,a[u+h++]=e,a[u+h++]=-1,a[u+h++]=r,a[u+h++]=i,a[u+h++]=s,a[u+h++]=-o/2,a[u+h++]=-l/2,a[u+h++]=f,c++}for(const m of o){const{totalTime:t,timeSeed:n}=m;let o=null,l=null,i=null,a=null,s=null,c=null;for(let f=0;f<m.numberOfVertices;f++){const d=r[4*(m.startVertex+f)],w=r[4*(m.startVertex+f)+1],p=r[4*(m.startVertex+f)+2],g=r[4*(m.startVertex+f)+3];let y=null,x=null,M=null,A=null;if(f>0){y=d-o,x=w-l;const r=Math.sqrt(y*y+x*x);if(y/=r,x/=r,f>1){let t=y+s,n=x+c;const r=Math.sqrt(t*t+n*n);t/=r,n/=r;const o=Math.min(1/(t*y+n*x),e);t*=o,n*=o,M=-n,A=t}else M=-x,A=y;null!==M&&null!==A&&(h(o,l,i,M,A,t,n,g),u())}o=d,l=w,i=p,s=y,c=x,a=g}h(o,l,i,-c,s,t,n,a)}return{vertexData:a,indexData:s}}function w(t){const e=16,n=1,r=2,{lineVertices:o,lineDescriptors:l}=t;let i=0,a=0;for(const U of l){const t=U.numberOfVertices-1;i+=4*t*2,a+=6*t*2}const s=new Float32Array(i*e),c=new Uint32Array(a);let f,u,h,m,d,w,p,g,y,x,M,A,I,V,F=0,v=0;function D(){c[v++]=F-8,c[v++]=F-7,c[v++]=F-6,c[v++]=F-7,c[v++]=F-5,c[v++]=F-6,c[v++]=F-4,c[v++]=F-3,c[v++]=F-2,c[v++]=F-3,c[v++]=F-1,c[v++]=F-2}function b(t,o,l,i,a,c,f,u,h,m,d,w,p,g){const y=F*e;let x=0;for(const e of[n,r])for(const n of[1,2,3,4])s[y+x++]=t,s[y+x++]=o,s[y+x++]=l,s[y+x++]=i,s[y+x++]=f,s[y+x++]=u,s[y+x++]=h,s[y+x++]=m,s[y+x++]=e,s[y+x++]=n,s[y+x++]=p,s[y+x++]=g,s[y+x++]=a/2,s[y+x++]=c/2,s[y+x++]=d/2,s[y+x++]=w/2,F++}function S(t,e){let n=y+M,r=x+A;const o=Math.sqrt(n*n+r*r);n/=o,r/=o;const l=y*n+x*r;n/=l,r/=l;let i=M+I,a=A+V;const s=Math.sqrt(i*i+a*a);i/=s,a/=s;const c=M*i+A*a;i/=c,a/=c,b(f,u,h,m,-r,n,d,w,p,g,-a,i,t,e),D()}function k(t,e,n,r,o,l){if(y=M,x=A,M=I,A=V,null==y&&null==x&&(y=M,x=A),null!=d&&null!=w){I=t-d,V=e-w;const n=Math.sqrt(I*I+V*V);I/=n,V/=n}null!=y&&null!=x&&S(o,l),f=d,u=w,h=p,m=g,d=t,w=e,p=n,g=r}function L(t,e){y=M,x=A,M=I,A=V,null==y&&null==x&&(y=M,x=A),null!=y&&null!=x&&S(t,e)}for(const U of l){f=null,u=null,h=null,m=null,d=null,w=null,p=null,g=null,y=null,x=null,M=null,A=null,I=null,V=null;const{totalTime:t,timeSeed:e}=U;for(let n=0;n<U.numberOfVertices;n++){k(o[4*(U.startVertex+n)],o[4*(U.startVertex+n)+1],o[4*(U.startVertex+n)+2],o[4*(U.startVertex+n)+3],t,e)}L(t,e)}return{vertexData:s,indexData:c}}function p(t,n){const r=n.pixels,{width:o,height:l}=n,i=new Float32Array(o*l*2),a=n.mask??new Uint8Array(o*l*2);if(n.mask||a.fill(255),"vector-uv"===t)for(let e=0;e<o*l;e++)i[2*e]=r[0][e],i[2*e+1]=-r[1][e];else if("vector-magdir"===t)for(let s=0;s<o*l;s++){const t=r[0][s],n=e(r[1][s]),o=Math.cos(n-Math.PI/2),l=Math.sin(n-Math.PI/2);i[2*s]=o*t,i[2*s+1]=l*t}return{data:i,mask:a,width:o,height:l}}async function g(t,e,n,r,a,s){const c=performance.now(),f=l(e.spatialReference);if(!f){const o=await y(t,e,n,r,a,s);return has("esri-2d-profiler")&&i().info("I.7","loadImagery, early exit (ms)",Math.round(performance.now()-c)),has("esri-2d-profiler")&&i().info("I.9","Number of parts",1),o}const[u,h]=f.valid,m=h-u,d=Math.ceil(e.width/m),w=e.width/d,p=Math.round(n/d);let g=e.xmin;const x=[],M=performance.now();for(let l=0;l<d;l++){const n=new o({xmin:g,xmax:g+w,ymin:e.ymin,ymax:e.ymax,spatialReference:e.spatialReference});x.push(y(t,n,p,r,a,s)),g+=w}const A=await Promise.all(x);has("esri-2d-profiler")&&i().info("I.8","All calls to _fetchPart (ms)",Math.round(performance.now()-M)),has("esri-2d-profiler")&&i().info("I.9","Number of parts",A.length);const I={data:new Float32Array(n*r*2),mask:new Uint8Array(n*r),width:n,height:r};let V=0;for(const o of A){for(let t=0;t<o.height;t++)for(let e=0;e<o.width;e++)V+e>=n||(I.data[2*(t*n+V+e)]=o.data[2*(t*o.width+e)],I.data[2*(t*n+V+e)+1]=o.data[2*(t*o.width+e)+1],I.mask[t*n+V+e]=o.mask[t*o.width+e]);V+=o.width}return has("esri-2d-profiler")&&i().info("I.10","loadImagery, general exit (ms)",Math.round(performance.now()-c)),I}async function y(t,e,n,r,o,l){const i={requestProjectedLocalDirections:!0,signal:l};if(null!=o&&(i.timeExtent=o),"imagery"===t.type){await t.load({signal:l});const o=await t.internalFetchImage(e,n,r,i);if(null==o?.pixelData?.pixelBlock)return{data:new Float32Array(n*r*2),mask:new Uint8Array(n*r),width:n,height:r};return p(t.rasterInfo.dataType,o.pixelData.pixelBlock)}await t.load({signal:l});const a=await t.fetchPixels(e,n,r,i);if(null==a?.pixelBlock)return{data:new Float32Array(n*r*2),mask:new Uint8Array(n*r),width:n,height:r};return p(t.serviceRasterInfo.dataType,a.pixelBlock)}export{m as createAnimatedLinesData,c as createFlowFieldFromData,s as createFlowMesh,w as createParticlesMesh,d as createStreamlinesMesh,u as getStreamlines,g as loadImagery,p as toFlowData};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import t from"../../../../core/Error.js";import has from"../../../../core/has.js";import e from"../../../../core/Logger.js";import{dataDrivenUnit2 as
|
|
5
|
+
import t from"../../../../core/Error.js";import has from"../../../../core/has.js";import e from"../../../../core/Logger.js";import{estimateNumberArrayMemory as i}from"../../../../core/memoryEstimations.js";import{dataDrivenUnit2 as s,dataDrivenUnit1 as r,dataDrivenUnit0 as a,visualVariableUnit as n,localTimeOriginUnit as u,gpgpuUnit as h,animationUnit as o,filterFlagsUnit as d}from"./definitions.js";import{getDisplayIdTexel as l}from"./DisplayId.js";import{getPixelArrayCtor as p,getPixelBytes as g}from"./Utils.js";import{FramebufferObject as _}from"../../../webgl/FramebufferObject.js";import{Texture as c}from"../../../webgl/Texture.js";import{TextureDescriptor as x}from"../../../webgl/TextureDescriptor.js";const f=()=>e.getLogger("esri.views.2d.engine.webgl.AttributeStoreView");class b{constructor(t,e,i){this._texture=null,this._lastTexture=null,this._fbos={},this.texelSize=4;const{buffer:s,pixelType:r,textureOnly:a}=t,n=p(r);this.blockIndex=i,this.pixelType=r,this.size=e,this.textureOnly=a,a||(this.data=new n(s)),this._resetRange()}destroy(){this._texture?.dispose();for(const t in this._fbos){const e=this._fbos[t];e&&("0"===t&&e.detachColorTexture(),e.dispose()),this._fbos[t]=null}this._texture=null}get _textureDesc(){const t=new x(this.size);return t.wrapMode=33071,t.samplingMode=9728,t.dataType=this.pixelType,t}get usedMemory(){return null!=this.data?i(this.data):0}setData(t,e,i){const s=l(t),r=this.data,a=s*this.texelSize+e;!r||a>=r.length||(r[a]=i,this.dirtyStart=Math.min(this.dirtyStart,s),this.dirtyEnd=Math.max(this.dirtyEnd,s))}getData(t,e){if(null==this.data)return null;const i=l(t)*this.texelSize+e;return!this.data||i>=this.data.length?null:this.data[i]}getTexture(t){return this._texture??this._initTexture(t)}getFBO(t,e=0){if(!this._fbos[e]){const i=0===e?this.getTexture(t):this._textureDesc;this._fbos[e]=new _(t,i)}return this._fbos[e]}get hasDirty(){const t=this.dirtyStart;return this.dirtyEnd>=t}updateTexture(e,i){try{const s=this.dirtyStart,r=this.dirtyEnd;if(!this.hasDirty)return;has("esri-2d-update-debug")&&console.debug(`Version[${i}] AttributeStoreView.updateTexture`,{start:s,end:r,firstBytes:new Uint8Array(this.data.buffer.slice(0,16)),block:this}),this._resetRange();const a=this.data.buffer,n=this.getTexture(e),u=4,h=(s-s%this.size)/this.size,o=(r-r%this.size)/this.size,d=h,l=this.size,g=o,_=h*this.size*u,c=(l+g*this.size)*u-_,x=p(this.pixelType),b=new x(a,_*x.BYTES_PER_ELEMENT,c),m=this.size,T=g-d+1;if(T>this.size)return void f().error(new t("mapview-webgl","Out-of-bounds index when updating AttributeData"));n.updateData(0,0,d,m,T,b)}catch(s){}}update(t){const{data:e,start:i,end:s}=t;if(null!=e&&null!=this.data){const s=this.data,r=i*this.texelSize;for(let i=0;i<e.length;i++){const a=1<<i%this.texelSize;t.layout&a&&(s[r+i]=e[i])}}this.dirtyStart=Math.min(this.dirtyStart,i),this.dirtyEnd=Math.max(this.dirtyEnd,s)}resize(t,e){const i=this.size;if(this.size=e,this.textureOnly)return void(i!==this.size&&(this._lastTexture=this._texture,this._texture=null));const s=p(this.pixelType);this.destroy(),this.data=new s(t.buffer)}_resetRange(){this.dirtyStart=2147483647,this.dirtyEnd=0}_initTexture(t){const e=new c(t,this._textureDesc,this.data??void 0);if(null!=this._lastTexture&&this._fbos[0]){const i=this._lastTexture.descriptor.width,s=this._lastTexture.descriptor.height,r=this._lastTexture.descriptor.dataType,a=this._lastTexture.descriptor.pixelFormat,n=this.getFBO(t),u=g(r),h=new(p(r))(new ArrayBuffer(i*s*u*this.texelSize)),o=t.getBoundFramebufferObject(),{x:d,y:l,width:_,height:c}=t.getViewport();t.bindFramebuffer(n),n.readPixels(0,0,i,s,a,r,h),e.updateData(0,0,0,2*i,s/2,h),t.setViewport(d,l,_,c),t.bindFramebuffer(o)}return this.destroy(),this._texture=e,this._texture}}class m{constructor(){this.size=0,this._pendingAttributeUpdates=[],this._version=0,this._epoch=0,this._locked=!1}get locked(){return this._locked}get usedMemory(){let t=0;for(const e of this._data??[])null!=e&&(t+=e.usedMemory);return t}_initialize(t){if(!t)throw new Error("InternalError: initArgs must be defined");const e=t.blockDescriptors;if(this.size=t.blockSize,has("esri-2d-update-debug")&&console.debug("AttributeStoreView.initialize",{message:t}),null==this._data)this._data=e.map((t,e)=>null!=t?new b(t,this.size,e):null);else for(let i=0;i<this._data.length;i++){const t=this._data[i],s=e[i];null!=s&&(null==t?this._data[i]=new b(s,this.size,i):t.resize(s,this.size))}}destroy(){for(const t of this._data??[])t?.destroy();this._defaultTexture?.dispose(),this._defaultTexture=null,this._pendingAttributeUpdates=[]}isEmpty(){return null==this._data}getBlock(t){if(null==this._data)return null;return this._data[t]}setLabelMinZoom(t,e){this.setData(t,0,1,e)}setLocalTimeOrigin(t,e){this.setData(t,7,0,e)}getLabelMinZoom(t){return this.getData(t,0,1,255)}getFilterFlags(t){return this.getData(t,0,0,0)}getVisualVariableData(t,e){return this.getData(t,3,e,0)}getData(t,e,i,s){if(!this._data)return 0;const r=this._data[e];if(null==r)return 0;const a=r.getData(t,i);return null!=a?a:s}setData(t,e,i,s){this._data[e].setData(t,i,s)}lockTextureUploads(){this._locked=!0}unlockTextureUploads(){this._locked=!1,this.update()}requestUpdate(t){this._version=t.version,this._pendingAttributeUpdates.push(t),has("esri-2d-update-debug")&&console.debug(`Version[${this._version}] AttributeStoreView.requestUpdate`,{message:t})}get currentEpoch(){return this._epoch}get hasPendingUpdates(){return this._pendingAttributeUpdates.length>0}update(){if(this._locked)return;const t=this._pendingAttributeUpdates;this._pendingAttributeUpdates=[];for(const e of t){const{blockData:t,initArgs:i,sendUpdateEpoch:s,version:r}=e;has("esri-2d-update-debug")&&console.debug(`Version[${this._version}] Epoch[${s}] AttributeStoreView.applyUpdate`),this._version=r,this._epoch=s,null!=i&&this._initialize(i);const a=this._data;for(let e=0;e<t.length;e++){const i=t[e],s=a[e];null!=s&&null!=i&&(has("esri-2d-update-debug")&&console.debug(`Version[${this._version}] CpuBlock[${e}] AttributeStoreView.update`,{block:i}),s.update(i))}}}getUniforms(t){return{filterFlags:{texture:this._getTexture(t,0),unit:d},animation:{texture:this._getTexture(t,1),unit:o},gpgpu:{texture:this._getTexture(t,2),unit:h},localTimeOrigin:{texture:this._getTexture(t,7),unit:u},visualVariableData:{texture:this._getTexture(t,3),unit:n},dataDriven0:{texture:this._getTexture(t,4),unit:a},dataDriven1:{texture:this._getTexture(t,5),unit:r},dataDriven2:{texture:this._getTexture(t,6),unit:s},size:this.size}}_getTexture(t,e){const i=this._data?.[e];return i?(i.updateTexture(t,this._version),i.getTexture(t)):this._getDefaultTexture(t)}_getDefaultTexture(t){if(null==this._defaultTexture){const e=new x(1);e.wrapMode=33071,e.samplingMode=9728,this._defaultTexture=new c(t,e,new Uint8Array(4))}return this._defaultTexture}}export{m as AttributeStoreView};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import t from"./DisplayRecord.js";import{serializeList as i,deserializeList as r}from"./util/serializationUtils.js";class
|
|
5
|
+
import t from"./DisplayRecord.js";import{serializeList as i,deserializeList as r}from"./util/serializationUtils.js";class e{static{this.byteSizeHint=2*Uint32Array.BYTES_PER_ELEMENT+t.byteSizeHint}static estimateMemory(i){return 24+t.estimatedMemory*i}constructor(t,i){this.id=t,this.sortKey=i,this.records=[]}serialize(t){return t.push(this.id),t.writeF32(this.sortKey),i(t,this.records),t}static deserialize(i){const s=i.readInt32(),o=i.readF32(),a=new e(s,o);return a.records=r(i,t)??[],a}}export{e as default};
|