@arcgis/core 4.34.0-next.55 → 4.34.0-next.57
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/VolumeMeasurement/VolumeMeasurementCutFillOptions.d.ts +4 -0
- package/analysis/VolumeMeasurement/{CutFillOptions.js → VolumeMeasurementCutFillOptions.js} +1 -1
- package/analysis/VolumeMeasurementAnalysis.js +1 -1
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/02a31483e09652a1a1a2.js +1 -0
- package/assets/esri/core/workers/chunks/0390f3aa624e3f380ce2.js +1 -0
- package/assets/esri/core/workers/chunks/047d6f7b1677cc7ab271.js +1 -0
- package/assets/esri/core/workers/chunks/04e652df94790f5ca08a.js +1 -0
- package/assets/esri/core/workers/chunks/{9f178cf73c63caaea190.js → 06d2251d6f6b3e44800a.js} +1 -1
- package/assets/esri/core/workers/chunks/07d5e0633cc2f765037f.js +1 -0
- package/assets/esri/core/workers/chunks/{fe5c37c69da3ec1e56ac.js → 08393d9cc2ed846dd5b4.js} +1 -1
- package/assets/esri/core/workers/chunks/{18ceea59e469a0f2721b.js → 094c741fa8139c3f40cf.js} +1 -1
- package/assets/esri/core/workers/chunks/0d946a226b846b3c0849.js +1 -0
- package/assets/esri/core/workers/chunks/{6530449cd1975deb61f1.js → 184d3c88ac2fc1d7e2c3.js} +1 -1
- package/assets/esri/core/workers/chunks/2ded2446700f89155ccd.js +1 -0
- package/assets/esri/core/workers/chunks/{19391d60c76a1dc7c262.js → 2f7e192ee2066f863e1d.js} +1 -1
- package/assets/esri/core/workers/chunks/{6b11476b2004b4db576e.js → 3445ffd752262673fb13.js} +1 -1
- package/assets/esri/core/workers/chunks/38f09e36e174792646bd.js +1 -0
- package/assets/esri/core/workers/chunks/43a56c8fa4e5be18c12a.js +1 -0
- package/assets/esri/core/workers/chunks/{65e1f5b20a585e04655a.js → 44dc7ec52c4abb700783.js} +1 -1
- package/assets/esri/core/workers/chunks/4558f2e3e77831758fdc.js +1 -0
- package/assets/esri/core/workers/chunks/4753793daf0b7ff8b5ff.js +1 -0
- package/assets/esri/core/workers/chunks/52917b753c5ceab0c1f7.js +353 -0
- package/assets/esri/core/workers/chunks/{6940bb6524938894a246.js → 53873f26a2c24cd75e4a.js} +1 -1
- package/assets/esri/core/workers/chunks/561a2078458bc0339f83.js +1 -0
- package/assets/esri/core/workers/chunks/56b4dcd04c844eaacd60.js +1 -0
- package/assets/esri/core/workers/chunks/{d0bf1fc6e3c198bc565d.js → 57486b18421a3c9690d0.js} +1 -1
- package/assets/esri/core/workers/chunks/5f079be7f322768aef21.js +1 -0
- package/assets/esri/core/workers/chunks/61a294f9411bf884f2ab.js +1 -0
- package/assets/esri/core/workers/chunks/{ad93a2621f75270f06cb.js → 69fbe363bb130fdd8146.js} +1 -1
- package/assets/esri/core/workers/chunks/{722931d1a60be461e521.js → 70cf81ec5a901782d2db.js} +1 -1
- package/assets/esri/core/workers/chunks/{24ac204d8a045aa821be.js → 7388e8c905d93dea1c05.js} +1 -1
- package/assets/esri/core/workers/chunks/749c7159e0902388e828.js +1 -0
- package/assets/esri/core/workers/chunks/76ff7ccfe583927918f3.js +969 -0
- package/assets/esri/core/workers/chunks/{ae73ac81bd10614c2b53.js → 7714228825fb44d506df.js} +1 -1
- package/assets/esri/core/workers/chunks/{6130bc641aa7c1bcaaa8.js → 7c23be93d394f1bee941.js} +1 -1
- package/assets/esri/core/workers/chunks/7c86af4f60cea383ed96.js +1 -0
- package/assets/esri/core/workers/chunks/7eda1c400658b6a99be8.js +1 -0
- package/assets/esri/core/workers/chunks/{97ae2fdb6cb98249f5fa.js → 7f80bbbd0897082c1af3.js} +1 -1
- package/assets/esri/core/workers/chunks/80a69897fa3ce1eaa6e7.js +1 -0
- package/assets/esri/core/workers/chunks/80bd5988180f4618fd61.js +1 -0
- package/assets/esri/core/workers/chunks/{62ade6f18b375795ddfd.js → 8257352421f453a669e9.js} +1 -1
- package/assets/esri/core/workers/chunks/8762928d10c3821738ad.js +1 -0
- package/assets/esri/core/workers/chunks/88a5e7415f8858c454f7.js +1 -0
- package/assets/esri/core/workers/chunks/893e5eb5c028c4704317.js +1 -0
- package/assets/esri/core/workers/chunks/8ead467a5af0d9bba804.js +1 -0
- package/assets/esri/core/workers/chunks/91e04d03b0013bcaad82.js +1 -0
- package/assets/esri/core/workers/chunks/{c7d4c296011c5393bcaa.js → 9275313e0f1f521b2658.js} +1 -1
- package/assets/esri/core/workers/chunks/{e666ca4d14b6490485d6.js → 92b60d4fb09711919601.js} +1 -1
- package/assets/esri/core/workers/chunks/977582cb3c8f17a2cb4c.js +1 -0
- package/assets/esri/core/workers/chunks/{5c556468e2a598ab793a.js → 9940e59033a8a1eff2a9.js} +1 -1
- package/assets/esri/core/workers/chunks/9b10e70f28873cff44f5.js +1 -0
- package/assets/esri/core/workers/chunks/{9928e432b884c75c3436.js → 9d920f3488d59e7f276c.js} +1 -1
- package/assets/esri/core/workers/chunks/{a778a72456fefdf40115.js → a249e56a0be8cef33ba8.js} +1 -1
- package/assets/esri/core/workers/chunks/a3ee76b7e46d3fba7cf7.js +1 -0
- package/assets/esri/core/workers/chunks/{2cda605c302176905e84.js → a96ac5c68d84122e7751.js} +1 -1
- package/assets/esri/core/workers/chunks/acf13a64df2991a4cb6b.js +1 -0
- package/assets/esri/core/workers/chunks/{7a8d740d1226719a578a.js → b457b7dd907f06278bee.js} +1 -1
- package/assets/esri/core/workers/chunks/b5640f9623a9c9ded92a.js +1 -0
- package/assets/esri/core/workers/chunks/bb67d491f62a5cce96cd.js +1 -0
- package/assets/esri/core/workers/chunks/{71acded1b3c0057917a1.js → bbdbb618a18542f7a4a2.js} +1 -1
- package/assets/esri/core/workers/chunks/bc9f54a6b577c43189fd.js +1 -0
- package/assets/esri/core/workers/chunks/{6fe738748ce837811ff4.js → bd4125d163f372a7e978.js} +1 -1
- package/assets/esri/core/workers/chunks/bead38898c3f4d4d3569.js +1 -0
- package/assets/esri/core/workers/chunks/{22334a464f798b5279b2.js → c80c032c5b7a11db177a.js} +1 -1
- package/assets/esri/core/workers/chunks/cc748d4f4adb9c584aa4.js +1 -0
- package/assets/esri/core/workers/chunks/cf699b9bb530b87be14c.js +1 -0
- package/assets/esri/core/workers/chunks/{5d331f7628514a572f82.js → d6ab4d55f1023ee6ec6a.js} +1 -1
- package/assets/esri/core/workers/chunks/d71836cf70b9604832f1.js +1 -0
- package/assets/esri/core/workers/chunks/{4874aabdb5c60ca66216.js → db2b8d8cf7131554cf7e.js} +1 -1
- package/assets/esri/core/workers/chunks/de4da985c398c8bcf2e7.js +1 -0
- package/assets/esri/core/workers/chunks/ef85cd0e82d59db8a26f.js +33 -0
- package/assets/esri/core/workers/chunks/fd1fdb97a294a1b7041d.js +1 -0
- package/config.js +1 -1
- package/core/has.js +1 -1
- package/geometry/Multipoint.js +1 -1
- package/geometry/support/boundsUtils.js +1 -1
- package/geometry/support/contains.js +1 -1
- package/geometry/support/coordsUtils.js +1 -1
- package/geometry/support/curves/circleUtils.js +1 -1
- package/geometry/support/curves/circularArcUtils.js +1 -1
- package/geometry/support/curves/curveUtils.js +1 -1
- package/geometry/support/curves/ellipticArc7Utils.js +1 -1
- package/geometry/support/curves/rotate.js +5 -0
- package/geometry/support/extentUtils.js +1 -1
- package/geometry/support/rotate.js +1 -1
- package/graphic/ImageryGraphicOrigin.js +5 -0
- package/graphic/ImageryTileGraphicOrigin.js +5 -0
- package/graphic/KMLGraphicOrigin.js +5 -0
- package/graphic/WCSGraphicOrigin.js +5 -0
- package/graphic/isImageryGraphicOrigin.js +5 -0
- package/graphic/isImageryTileGraphicOrigin.js +5 -0
- package/graphic/isKMLGraphicOrigin.js +5 -0
- package/graphic/isWCSGraphicOrigin.js +5 -0
- package/interfaces.d.ts +10 -10
- package/kernel.js +1 -1
- package/layers/CatalogLayer.js +1 -1
- package/layers/FeatureLayer.js +1 -1
- package/layers/GroundLayer.js +5 -0
- package/layers/ImageryLayer.js +1 -1
- package/layers/ImageryTileLayer.js +1 -1
- package/layers/KMLLayer.js +1 -1
- package/layers/SceneLayer.js +1 -1
- package/layers/WCSLayer.js +1 -1
- package/layers/catalog/CatalogFootprintLayer.js +1 -1
- package/layers/mixins/ArcGISImageService.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/support/requestUtils.js +1 -1
- package/support/revision.js +1 -1
- package/views/2d/layers/ImageryLayerView2D.js +1 -1
- package/views/2d/layers/ImageryTileLayerView2D.js +1 -1
- package/views/2d/layers/KMLLayerView2D.js +1 -1
- package/views/2d/layers/features/layerAdapters/CatalogFootprintLayerAdapter.js +1 -1
- package/views/2d/layers/imagery/ImageryTileView2D.js +1 -1
- package/views/3d/analysis/AreaMeasurement/support/AreaMeasurementPathHelper.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/analysis/VolumeMeasurement/{CutFillVolumeMeasurementComputation.js → VolumeMeasurementCutFillComputation.js} +1 -1
- package/views/3d/analysis/VolumeMeasurement/{CutFillVolumeMeasurementController.js → VolumeMeasurementCutFillController.js} +1 -1
- package/views/3d/analysis/VolumeMeasurement/{CutFillVolumeMeasurementVisualization.js → VolumeMeasurementCutFillVisualization.js} +1 -1
- package/views/3d/analysis/VolumeMeasurementAnalysisView3D.js +1 -1
- package/views/3d/layers/CatalogFootprintLayerView3D.js +1 -1
- package/views/3d/layers/IntegratedMesh3DTilesLayerView3D.js +1 -1
- package/views/GroundView.js +1 -1
- package/views/analysis/ElevationProfile/elevationProfileGenerationUtils.js +1 -1
- 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/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/operations/RotateVertex.js +1 -1
- package/views/interactive/editGeometry/operations/curveOperationUtils.js +1 -1
- package/views/interactive/tooltip/infos/SelectedVertexTooltipInfo.js +1 -1
- package/views/layers/ImageryLayerView.js +1 -1
- package/views/layers/ImageryTileLayerView.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/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/VolumeMeasurement/CutFillOptions.d.ts +0 -4
- package/assets/esri/core/workers/chunks/01e8b9dc77a57d1c2a52.js +0 -1
- package/assets/esri/core/workers/chunks/027cfcde29fe87aa2ffe.js +0 -1
- package/assets/esri/core/workers/chunks/03ee4d63aa8de44958ab.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/0a6d33d013628f671aea.js +0 -1
- package/assets/esri/core/workers/chunks/17776d9d3558d45ea7b5.js +0 -1
- package/assets/esri/core/workers/chunks/1a2278b9fe9666342728.js +0 -1
- package/assets/esri/core/workers/chunks/1e01aaebdeffdfc0c6bd.js +0 -1
- package/assets/esri/core/workers/chunks/222f981e876f60ae282f.js +0 -1
- package/assets/esri/core/workers/chunks/252ee00fd6c4ae0ee7fa.js +0 -1
- package/assets/esri/core/workers/chunks/277941bec15525dbd3a0.js +0 -1
- package/assets/esri/core/workers/chunks/2cb14d040e67a261b31c.js +0 -1
- package/assets/esri/core/workers/chunks/31c088966ccfff2ea1db.js +0 -1
- package/assets/esri/core/workers/chunks/3245d20ea4bb779f87ef.js +0 -1
- package/assets/esri/core/workers/chunks/3800764932a1c32cb29f.js +0 -1
- package/assets/esri/core/workers/chunks/46a470bea2a3601182dc.js +0 -1
- package/assets/esri/core/workers/chunks/4f8dab492331c9a2d67a.js +0 -1
- package/assets/esri/core/workers/chunks/5900dde7a201a7d47469.js +0 -1
- package/assets/esri/core/workers/chunks/5b2ff220aebe464dac23.js +0 -1
- package/assets/esri/core/workers/chunks/6801b92bce7a918fda6f.js +0 -1
- package/assets/esri/core/workers/chunks/772e81e9162e2240a7a6.js +0 -1
- package/assets/esri/core/workers/chunks/7b560ac0be93c6aa9940.js +0 -1
- package/assets/esri/core/workers/chunks/7bdfc7c7ce1d94c00745.js +0 -353
- package/assets/esri/core/workers/chunks/83737d86584bf1b32368.js +0 -1
- package/assets/esri/core/workers/chunks/854bfda25bb406814929.js +0 -1
- package/assets/esri/core/workers/chunks/87f68c2b9361bd3f8cac.js +0 -1
- package/assets/esri/core/workers/chunks/8c81156b1605a16acc29.js +0 -1
- package/assets/esri/core/workers/chunks/8f6ff09e7d2f01b79faf.js +0 -1
- package/assets/esri/core/workers/chunks/97a38d700f2cb8807d51.js +0 -1
- package/assets/esri/core/workers/chunks/9e9be7f6ea32957f1088.js +0 -33
- package/assets/esri/core/workers/chunks/cbec768cd98caff212f2.js +0 -1
- package/assets/esri/core/workers/chunks/d1842745a7699879a1e1.js +0 -1
- package/assets/esri/core/workers/chunks/d81c4afad4abe2d1d0b9.js +0 -1
- package/assets/esri/core/workers/chunks/de499e33035b56b6697d.js +0 -1
- package/assets/esri/core/workers/chunks/dfb12f42b8d319ffa5fc.js +0 -1
- package/assets/esri/core/workers/chunks/e04951ee32f041faaeca.js +0 -1
- package/assets/esri/core/workers/chunks/e10c5405f956b2cc59e4.js +0 -1
- package/assets/esri/core/workers/chunks/ead1acf95c3385630da8.js +0 -1001
- package/assets/esri/core/workers/chunks/f3e3c2340452c1d60c95.js +0 -1
- package/assets/esri/core/workers/chunks/f4d7cbd33ef8710d7316.js +0 -1
- 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
|
@@ -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{__decorate as e}from"tslib";import t from"../../Graphic.js";import i from"../../request.js";import{deprecatedFunction as r}from"../../core/deprecate.js";import s from"../../core/Error.js";import{clone as n}from"../../core/lang.js";import a from"../../core/Logger.js";import{watch as o}from"../../core/reactiveUtils.js";import{urlToObject as l}from"../../core/urlUtils.js";import{property as u}from"../../core/accessorSupport/decorators/property.js";import{Integer as p,ensureRange as m,ensureClass as c,ensureNumber as h}from"../../core/accessorSupport/ensureType.js";import{reader as d}from"../../core/accessorSupport/decorators/reader.js";import{subclass as f}from"../../core/accessorSupport/decorators/subclass.js";import{writer as g}from"../../core/accessorSupport/decorators/writer.js";import y from"../../geometry/Extent.js";import R from"../../geometry/Polygon.js";import I from"../../geometry/SpatialReference.js";import{srToRESTValue as v}from"../../geometry/support/spatialReferenceUtils.js";import{opacity as w,url as b}from"../support/commonProperties.js";import S from"../support/DimensionalDefinition.js";import{ExportImageServiceParameters as x}from"../support/ExportImageServiceParameters.js";import _ from"../support/Field.js";import F from"../support/FieldsIndex.js";import{createBitmap as D}from"../support/imageBitmapUtils.js";import{isSupportedRendererType as O}from"../support/imageryRendererUtils.js";import T from"../support/MosaicRule.js";import C from"../support/MultidimensionalSubset.js";import M from"../support/PixelBlock.js";import{interpolationKebab as P,noDataInterpretationKebab as N,pixelTypeKebabDict as q}from"../support/rasterEnums.js";import{getServicePixelValueField as j,getItemPixelValueField as A,getRawServicePixelValueField as E,getProcessedServicePixelValueField as V,getMagnitudeField as Q,getDirectionField as J,getMultidimensionalFields as U,getRasterAttributeTableFields as B,commonRasterFieldNames as L,addMultidimensionalFieldValues as z,rasterFieldPrefix as H}from"../support/rasterFieldUtils.js";import G from"../support/RasterFunction.js";import k from"../support/RasterInfo.js";import{intersectMultimensionalSubset as W,getEffectiveMultidimensionalDefinition as $,getSubsetVariablesFromMdInfo as X,getDefaultMultidimensionalDefinition as K}from"../support/rasterDatasets/multidimensionalUtils.js";import{decode as Y,getFormat as Z}from"../support/rasterFormats/RasterCodec.js";import{highlightPixels as ee}from"../support/rasterFunctions/pixelUtils.js";import{uvComponentToVector as te}from"../support/rasterFunctions/vectorFieldUtils.js";import{createDefaultRenderer as ie,getSupportedRendererTypes as re,matchPresetRenderer as se,getDefaultBandCombination as ne,normalizeRendererJSON as ae}from"../../renderers/support/rasterRendererHelper.js";import oe from"../../renderers/support/RasterSymbolizer.js";import{websceneRasterRendererTypes as le,rasterRendererTypes as ue,read as pe}from"../../renderers/support/rasterTypeUtils.js";import{calculateVolume as me,computeAngles as ce,computePixelSpaceLocations as he,computeHistograms as de,computeStatisticsHistograms as fe,measureHeight as ge,measureAreaAndPerimeter as ye,measureDistanceAndAngle as Re,measurePointOrCentroid as Ie,measureLengthFromImage as ve,measureAreaFromImage as we,getImageSpatialReferenceQueryParameter as be,getSamples as Se,identify as xe,imageToMap as _e,imageToMapMultiray as Fe,mapToImage as De,findImages as Oe,getImageUrl as Te,queryBoundary as Ce,queryGPSInfo as Me}from"../../rest/imageService.js";import{fetchServiceRasterInfo as Pe,generateRasterInfo as Ne,patchServiceInfo as qe}from"../../rest/imageService/fetchRasterInfo.js";import{getCatalogItemRasterInfo as je}from"../../rest/imageService/getCatalogItemRasterInfo.js";import{executeForCount as Ae}from"../../rest/query/executeForCount.js";import{executeForIds as Ee}from"../../rest/query/executeForIds.js";import{executeQueryJSON as Ve}from"../../rest/query/executeQueryJSON.js";import Qe from"../../rest/support/FeatureSet.js";import Je from"../../rest/support/ImageIdentifyParameters.js";import Ue from"../../rest/support/Query.js";const Be=new Set(["png","png8","png24","png32","jpg","bmp","gif","jpgpng","lerc","tiff"]),Le=m(h,{min:0,max:255});function ze(e){const t=JSON.stringify(e),i=t.includes('"rasterFunctionDefinition":{'),r=i?t.match(/"type":"(.*?FunctionArguments")/gi):t.match(/"rasterFunction":"(.*?")/gi),s=r?.map(e=>i?e.slice(8,-18):e.slice(18,-1));return s?s.join("/"):null}const He=m=>{const h=m;let He=class extends h{constructor(){super(...arguments),this._functionRasterInfos={},this._serviceSupportsMosaicRule=null,this.adjustAspectRatio=null,this.bandIds=void 0,this.capabilities=null,this.compressionQuality=void 0,this.compressionTolerance=.01,this.copyright=null,this.defaultMosaicRule=null,this.definitionExpression=null,this.exportImageServiceParameters=null,this.rasterInfo=null,this.fields=null,this.fullExtent=null,this.hasMultidimensions=!1,this.imageMaxHeight=4100,this.imageMaxWidth=4100,this.interpolation=void 0,this.minScale=0,this.maxScale=0,this.multidimensionalInfo=null,this.multidimensionalSubset=null,this.noData=null,this.noDataInterpretation=void 0,this.objectIdField=null,this.geometryType="polygon",this.typeIdField=null,this.types=[],this.pixelFilter=null,this.raster=void 0,this.sourceType=null,this.viewId=void 0,this.symbolizer=null,this.rasterFunctionInfos=null,this.serviceDataType=null,this.spatialReference=null,this.pixelType=null,this.serviceRasterInfo=null,this.sourceJSON=null,this.url=null,this.version=void 0}initialize(){this._set("exportImageServiceParameters",new x({layer:this}))}readServiceSupportsMosaicRule(e,t){return this._isMosaicRuleSupported(t)}get _rasterFunctionNamesIndex(){const e=new Map;return!this.rasterFunctionInfos||null!=this.rasterFunctionInfos&&this.rasterFunctionInfos.length<1||null!=this.rasterFunctionInfos&&this.rasterFunctionInfos.forEach(t=>{e.set(t.name.toLowerCase().replaceAll(/ /gi,"_"),t.name)}),e}readBandIds(e,t){if(Array.isArray(e)&&e.length>0&&e.every(e=>"number"==typeof e))return e}readCapabilities(e,t){return this._readCapabilities(t)}writeCompressionQuality(e,t,i){null!=e&&"lerc"!==this.format&&(t[i]=e)}writeCompressionTolerance(e,t,i){"lerc"===this.format&&null!=e&&(t[i]=e)}readDefaultMosaicRule(e,t){return this._serviceSupportsMosaicRule?T.fromJSON(t):null}get fieldsIndex(){return this.fields?new F(this.fields):null}set format(e){e&&Be.has(e.toLowerCase())&&this._set("format",e.toLowerCase())}readFormat(e,t){return"esriImageServiceDataTypeVector-UV"===t.serviceDataType||"esriImageServiceDataTypeVector-MagDir"===t.serviceDataType||null!=this.pixelFilter?"lerc":"jpgpng"}readMinScale(e,t){return null!=t.minLOD&&null!=t.maxLOD?e:0}readMaxScale(e,t){return null!=t.minLOD&&null!=t.maxLOD?e:0}set mosaicRule(e){let t=e;t?.mosaicMethod&&(t=T.fromJSON({...t.toJSON(),mosaicMethod:t.mosaicMethod,mosaicOperation:t.mosaicOperation})),this._set("mosaicRule",t)}readMosaicRule(e,t){const i=e||t.mosaicRule;return i?T.fromJSON(i):this._isMosaicRuleSupported(t)?T.fromJSON(t):null}writeMosaicRule(e,t,i){const{mosaicRule:r}=this;this._isValidCustomizedMosaicRule(r)&&(t[i]=r.toJSON())}writeNoData(e,t,i){null!=e&&"number"==typeof e&&(t[i]=Le(e))}readObjectIdField(e,t){if(!e){const i=t.fields.find(e=>"esriFieldTypeOID"===e.type||"oid"===e.type);e=i?.name}return e}get parsedUrl(){return l(this.url)}readSourceType(e,t){return this._isMosaicDataset(t)?"mosaic-dataset":"raster-dataset"}get renderer(){const{activePresetRendererName:e,presetRenderers:t}=this;if(e){const i=t?.find(({name:t})=>t===e);return i?.renderer.clone()}return this.internalRenderer}set renderer(e){this.activePresetRendererName=null,this.internalRenderer=e}set internalRenderer(e){this.loaded&&(e=this._configRenderer(e)),this._set("internalRenderer",e)}readRenderer(e,t,i){const r=t?.layerDefinition?.drawingInfo?.renderer,s=pe(r,i);return null==s?null:("vector-field"===s.type&&t.symbolTileSize&&!r.symbolTileSize&&(s.symbolTileSize=t.symbolTileSize),O(s)||a.getLogger(this).warn("ArcGISImageService","Imagery layer doesn't support given renderer type."),s)}writeRenderer(e,t,i){t.layerDefinition=t.layerDefinition||{},t.layerDefinition.drawingInfo=t.layerDefinition.drawingInfo||{},t.layerDefinition.drawingInfo.renderer=e.toJSON(),"vector-field"===e.type&&(t.symbolTileSize=e.symbolTileSize)}get rasterFields(){const e=this.fields?.map(e=>e.clone())??[];e.push(j()),"mosaic-dataset"===this.sourceType&&this.fields?.length&&e.push(A()),this.version>=10.4&&null!=this.rasterFunctionInfos&&this.rasterFunctionInfos.some(({name:e})=>"none"===e.toLowerCase())&&e.push(E()),null!=this.rasterFunctionInfos&&this.rasterFunctionInfos.filter(({name:e})=>"none"!==e.toLowerCase()).forEach(({name:t})=>e.push(V(t)));const{rasterInfo:t}=this;if(this._isVectorDataSet()){const i=t?.multidimensionalInfo?.variables[0].unit?.trim(),r=Q(i),s=J();e.push(r,s)}if(t?.multidimensionalInfo&&"raster-dataset"===this.sourceType){const i=U(t.multidimensionalInfo);e.push(...i)}const i=t?.attributeTable;if(null!=i){const t=B(i);e.push(...t)}return e}set rasterFunction(e){let t=e;t?.rasterFunction&&(t=G.fromJSON({...t.toJSON(),rasterFunction:t.rasterFunction,rasterFunctionArguments:t.rasterFunctionArguments})),this._set("rasterFunction",t)}readRasterFunction(e,t){const i=t.rasterFunctionInfos;return t.renderingRule||i?.length&&"None"!==i[0].name?this._isRFTJson(t.renderingRule)?G.fromJSON({rasterFunctionDefinition:t.renderingRule}):G.fromJSON(t.renderingRule||{rasterFunctionInfos:t.rasterFunctionInfos}):null}readSpatialReference(e,t){const i=e||t.extent.spatialReference;return i?I.fromJSON(i):null}writePixelType(e,t,i){null!=this.serviceRasterInfo&&this.pixelType===this.serviceRasterInfo.pixelType||(t[i]=q.toJSON(e))}readVersion(e,t){let i=t.currentVersion;return i||(i=t.hasOwnProperty("fields")||t.hasOwnProperty("timeInfo")?10:9.3),i}applyFilter(e){let t=e;return this.pixelFilter&&(t=this._clonePixelData(e),this.pixelFilter(t)),t}async applyRenderer(e,t){let i=e,{renderer:r,symbolizer:s,pixelFilter:n}=this;const{isRawData:a}=e;if(a&&"lerc"!==this.format&&(r??=ie(this.rasterInfo,{bandIds:this.bandIds,variableName:this.rasterFunction?null:this.mosaicRule?.multidimensionalDefinition?.[0].variableName}),s||(this.symbolizer=new oe({rendererJSON:r.toJSON(),rasterInfo:this.rasterInfo}),s=this.symbolizer)),(a||!this._isPicture())&&r&&s&&!n){await this._updateSymbolizer(s,r);const{bandIds:n}=this;i=await this._symbolize({pixelData:e,bandIds:n,symbolizer:s},t)}return i}async highlightPixels(e,t){const i=e.highlightOptions.map(e=>{const t={...e},{bandId:i}=t;if(null==i)t.bandId=0;else{const e=this.bandIds?.length?this.bandIds.indexOf(i):i;if(e<0||e>2)return;t.bandId=e}return t}).filter(e=>null!=e),r=this._rasterJobHandler;r?await r.highlightPixels({...e,highlightOptions:i},t):ee(e.pixelBlock,e.renderedPixelBlock,i)}destroy(){this._shutdownJobHandler()}async calculateVolume(e,t){if(!(await this._fetchCapabilities(t?.signal)).operations.supportsCalculateVolume)throw new s("imagery-layer:compute-pixel-space-locations","this operation is not supported on the input image service");return e=n(e),this.mosaicRule&&null==e.mosaicRule&&(e.mosaicRule=this.mosaicRule),me(this.url,e,this._getRequestOptions(t))}async computeAngles(e,t){if(!(await this._fetchCapabilities(t?.signal)).operations.supportsComputeAngles)throw new s("imagery-layer:compute-angles","this operation is not supported on the input image service");return ce(this.url,e,this._getRequestOptions(t))}async computePixelSpaceLocations(e,t){if(!(await this._fetchCapabilities(t?.signal)).operations.supportsComputePixelLocation)throw new s("imagery-layer:compute-pixel-space-locations","this operation is not supported on the input image service");return he(this.url,e,this._getRequestOptions(t))}async computeHistograms(e,t){if(!(await this._fetchCapabilities(t?.signal)).operations.supportsComputeHistograms)throw new s("imagery-layer:compute-histograms","this operation is not supported on the input image service");return e=n(e),this._applyMosaicAndRenderingRules(e),de(this.url,e,this._getRequestOptions(t))}async computeStatisticsHistograms(e,t){if(!(await this._fetchCapabilities(t?.signal)).operations.supportsComputeStatisticsHistograms)throw new s("imagery-layer:compute-statistics-histograms","this operation is not supported on the input image service");return e=n(e),this._applyMosaicAndRenderingRules(e),fe(this.url,e,this._getRequestOptions(t))}async measureHeight(e,t){const i=await this._fetchCapabilities(t?.signal);if(!("base-and-top"===e.operationType?i.mensuration.supportsHeightFromBaseAndTop:"base-and-top-shadow"===e.operationType?i.mensuration.supportsHeightFromBaseAndTopShadow:i.mensuration.supportsHeightFromTopAndTopShadow))throw new s("imagery-layer:measure-height","this operation is not supported on the input image service");return e=n(e),this._applyMosaicRule(e),ge(this.url,e,this._getRequestOptions(t))}async measureAreaAndPerimeter(e,t){const i=await this._fetchCapabilities(t?.signal);if(!(i.mensuration.supportsAreaAndPerimeter&&(!e.is3D||i.mensuration.supports3D)))throw new s("imagery-layer:measure-area-and-perimeter","this operation is not supported on the input image service");return e=n(e),this._applyMosaicRule(e),ye(this.url,e,this._getRequestOptions(t))}async measureDistanceAndAngle(e,t){const i=await this._fetchCapabilities(t?.signal);if(!(i.mensuration.supportsDistanceAndAngle&&(!e.is3D||i.mensuration.supports3D)))throw new s("imagery-layer:measure-distance-and-angle","this operation is not supported on the input image service");return e=n(e),this._applyMosaicRule(e),Re(this.url,e,this._getRequestOptions(t))}async measurePointOrCentroid(e,t){const i=await this._fetchCapabilities(t?.signal);if(!(i.mensuration.supportsPointOrCentroid&&(!e.is3D||i.mensuration.supports3D)))throw new s("imagery-layer:measure-point-or-centroid","this operation is not supported on the input image service");return e=n(e),this._applyMosaicRule(e),Ie(this.url,e,this._getRequestOptions(t))}async measureLengthFromImage(e,t){if(!(await this._fetchCapabilities(t?.signal)).operations.supportsMeasureFromImage)throw new s("imagery-layer:measure-length-from-image","this operation is not supported on the input image service");if("polyline"!==e.geometry.type)throw new s("imagery-layer:measure-length-from-image","this input geometry must be a polyline");return ve(this.url,e,this._getRequestOptions(t))}async measureAreaFromImage(e,t){if(!(await this._fetchCapabilities(t?.signal)).operations.supportsMeasureFromImage)throw new s("imagery-layer:measure-area-from-image","this operation is not supported on the input image service");if("polygon"!==e.geometry.type)throw new s("imagery-layer:measure-area-from-image","this input geometry must be a polygon");return we(this.url,e,this._getRequestOptions(t))}getField(e){const{fieldsIndex:t}=this;return null!=t?t.get(e):void 0}getFieldDomain(e,t){const i=this.getField(e);return i?i.domain:null}fetchImage(e,t,i,n={}){if(r(a.getLogger(this),"`ImageryLayer.fetchImage` is deprecated in favor of 'ImageryLayer.fetchPixels'.",{replacement:"ImageryLayer.fetchPixels",version:"4.33",warnOnce:!0}),null==e||null==t||null==i)throw new s("imagery-layer:fetch-image","Insufficient parameters for requesting an image. A valid extent, width and height values are required.");return this.internalFetchImage(e,t,i,n)}async internalFetchImage(e,t,i,r={}){await this._updateCurrentRasterInfo();const{exportImageServiceParameters:s}=this;let n=!1;r.requestRawData&&(await this._initJobHandler(),s.requestRawData||"lerc"===this.format||(n=!0,s.requestRawData=!0));const a=this.getExportImageServiceParameters(e,t,i,r.timeExtent);if(n&&(s.requestRawData=!1),null==a){if(r.requestAsImageElement&&this._canRequestImageElement(this.format)){const e=document.createElement("canvas");if(e.width=t,e.height=i,r.returnImageBitmap){return{imageBitmap:await D(e,`${Ge(this.parsedUrl)}/exportImage`,r.signal)}}return{imageOrCanvasElement:e}}const{bandIds:s,rasterInfo:n}=this,a=(s?.length||n.bandCount)??0,o=t*i,l=n.pixelType,u=[];for(let e=0;e<a;e++)u.push(M.createEmptyBand(l,o));return{pixelData:{pixelBlock:new M({width:t,height:i,pixels:u,mask:new Uint8Array(o),pixelType:l}),extent:e}}}const o=!!r.requestAsImageElement&&!this.pixelFilter,l=o&&!!r.returnImageBitmap,u={imageServiceParameters:a,imageProps:{extent:e,width:t,height:i,format:this.format},requestAsImageElement:o,returnImageBitmap:l,signal:r.signal};return this._requestArrayBuffer(u)}async fetchPixels(e,t,i,r={}){await this._initJobHandler(),r.applyRendering&&this._updateCurrentRasterInfo();const s=r.applyRendering?void 0:new x({layer:this,requestRawData:!0,interpolation:r.interpolation??"nearest",bandIds:r.bandIds??[]}),n=this.getExportImageServiceParameters(e,t,i,r.timeExtent,s);if(null==n)return{extent:e,pixelBlock:null};delete n.pixelType,delete n.bandIds,delete n.compressionQuality;const a={imageServiceParameters:n,imageProps:{extent:e,width:t,height:i,format:this.format},requestAsImageElement:!1,returnImageBitmap:!1,signal:r.signal},{pixelData:o}=await this._requestArrayBuffer(a);return o??{extent:e,pixelBlock:null}}fetchKeyProperties(e){return i(Ge(this.parsedUrl)+"/keyProperties",{query:this._getQueryParams({renderingRule:this.version>=10.3?e?.rasterFunction:null})}).then(e=>e.data)}fetchRasterAttributeTable(e){return this.version<10.1?Promise.reject(new s("#fetchRasterAttributeTable()","Failed to get rasterAttributeTable")):i(Ge(this.parsedUrl)+"/rasterAttributeTable",{query:this._getQueryParams({renderingRule:this.version>=10.3?e?.rasterFunction:null})}).then(e=>Qe.fromJSON(e.data))}getCatalogItemRasterInfo(e,t){const i={...t,query:this._getQueryParams()};return je(Ge(this.parsedUrl),e,i)}async getCatalogItemICSInfo(e,t){const{data:r}=await i(Ge(this.parsedUrl)+"/"+e+"/info/ics",{query:this._getQueryParams(),...t}),s=r?.ics;if(!s)return;let n=null;try{n=(await i(Ge(this.parsedUrl)+"/"+e+"/info",{query:this._getQueryParams(),...t})).data.extent}catch{}if(!n?.spatialReference)return{ics:s,icsToPixelTransform:null,icsExtent:null,northDirection:null};const a=this.version>=10.7?i(Ge(this.parsedUrl)+"/"+e+"/info/icstopixel",{query:this._getQueryParams(),...t}).then(e=>e.data).catch(()=>({})):{},o=n.spatialReference,l={geometries:JSON.stringify({geometryType:"esriGeometryEnvelope",geometries:[n]}),inSR:v(o),outSR:"0:"+e},u=i(Ge(this.parsedUrl)+"/project",{query:this._getQueryParams(l),...t}).then(e=>e.data).catch(()=>({})),p=5,m=(n.xmin+n.xmax)/2,c=(n.ymax-n.ymin)/(p+1),h=n.ymin+c,d=[];for(let i=0;i<p;i++)d.push({x:m,y:h+c*i});const f={geometries:JSON.stringify({geometryType:"esriGeometryPoint",geometries:d}),inSR:v(o),outSR:"0:"+e},g=i(Ge(this.parsedUrl)+"/project",{query:this._getQueryParams(f),...t}).then(e=>e.data).catch(()=>({})),R=await Promise.all([a,u,g]);let w=R[0].ipxf;if(null==w){const e=s.geodataXform?.xf_0;"topup"===e?.name?.toLowerCase()&&6===e?.coefficients?.length&&(w={affine:{name:"ics [sensor: Frame] to pixel (column, row) transformation",coefficients:e.coefficients,cellsizeRatio:0,type:"GeometricXform"}})}const b=y.fromJSON(R[1]?.geometries?.[0]);b&&(b.spatialReference=new I({wkid:0,imageCoordinateSystem:s}));const S=R[2].geometries?R[2].geometries.filter(e=>null!=e?.x&&null!=e.y&&"NaN"!==e.x&&"NaN"!==e.y):[],x=S.length;if(x<3)return{ics:s,icsToPixelTransform:w,icsExtent:b,northDirection:null};let _=0,F=0,D=0,O=0;for(let i=0;i<x;i++)_+=S[i].x,F+=S[i].y,D+=S[i].x*S[i].x,O+=S[i].x*S[i].y;const T=(x*O-_*F)/(x*D-_*_);let C=0;const M=S[p-1].x>S[0].x,P=S[p-1].y>S[0].y;return T===1/0?C=P?90:270:0===T?C=M?0:180:T>0?C=M?180*Math.atan(T)/Math.PI:180*Math.atan(T)/Math.PI+180:T<0&&(C=P?180+180*Math.atan(T)/Math.PI:360+180*Math.atan(T)/Math.PI),{ics:s,icsToPixelTransform:w,icsExtent:b,northDirection:C}}async generateRasterInfo(e,t){e=c(G,e);const i={...t,query:this._getQueryParams()};if(!e||"none"===e.functionName?.toLowerCase()||this._isVectorFieldResampleFunction(e))return this.serviceRasterInfo??Pe(Ge(this.parsedUrl),this.sourceJSON,i);const r=ze(e);if(!r)throw new s("imagery-layer:generate-raster-info","the rendering rule is not supported");if(this._functionRasterInfos[r])return this._functionRasterInfos[r];const n=Ne(Ge(this.parsedUrl),e,i);this._functionRasterInfos[r]=n;try{return await n}catch(a){throw this._functionRasterInfos[r]=null,a}}getExportImageServiceParameters(e,t,i,r,s){e=e.clone().shiftCentralMeridian();const n=be(e.spatialReference,Ge(this.parsedUrl));s??=this.exportImageServiceParameters;const a=s.toJSON(),{bandIds:o,noData:l}=a;let{renderingRule:u}=a;const p=this.rasterFunction?.rasterFunctionDefinition,m=this.renderer?.type,c=!m||"raster-stretch"===m||"raster-colormap"===m||"unique-value"===m||"class-breaks"===m||"raster-shaded-relief"===m;if(o?.length&&this._hasRasterFunction(this.rasterFunction)&&!p&&c){const e={rasterFunction:"ExtractBand",rasterFunctionArguments:{BandIds:o}};if("Stretch"===u.rasterFunction)e.rasterFunctionArguments.Raster=u.rasterFunctionArguments.Raster,u.rasterFunctionArguments.Raster=e;else if("Colormap"===u.rasterFunction){const t=u.rasterFunctionArguments.Raster;"Stretch"===t?.rasterFunction?(e.rasterFunctionArguments.Raster=t.rasterFunctionArguments.Raster,t.rasterFunctionArguments.Raster=e):(e.rasterFunctionArguments.Raster=t,u.rasterFunctionArguments.Raster=e)}else e.rasterFunctionArguments.Raster=u,u=e;a.bandIds=void 0}else a.bandIds=o?.join(",");Array.isArray(l)&&l.length>0&&(a.noData=l.join(","));const h=this._processMultidimensionalIntersection(null,r,s.mosaicRule);if(h.isOutSide)return null;a.mosaicRule=null!=h.mosaicRule?JSON.stringify(h.mosaicRule):null,r=h.timeExtent,a.renderingRule=this._getRenderingRuleString(G.fromJSON(u));const d={};if(null!=r){const{start:e,end:t}=r.toJSON();e&&t&&e===t?d.time=""+e:null==e&&null==t||(d.time=`${e??"null"},${t??"null"}`)}return{bbox:e.xmin+","+e.ymin+","+e.xmax+","+e.ymax,bboxSR:n,imageSR:n,size:t+","+i,...a,...d}}async getSamples(e,t){const i=await this._fetchCapabilities(t?.signal);if(!i?.operations.supportsGetSamples)throw new s("imagery-layer:get-samples","getSamples operation is not supported on the input image service");e=n(e);const{raster:r}=this;return r&&null==e.raster&&(e.raster=r),Se(this.url,e,this._getRequestOptions(t))}async identify(e,t){if(!(await this._fetchCapabilities(t?.signal)).operations.supportsIdentify)throw new s("imagery-layer:identify","identify operation is not supported on the input image service");e=n(e),this.version<10.91&&"extent"===e.geometry?.type&&(e.geometry=R.fromExtent(e.geometry));const i=this._processMultidimensionalIntersection(e.geometry,e.timeExtent,e.mosaicRule||this.mosaicRule);if(i.isOutSide)throw new s("imagery-layer:identify","the request cannot be fulfilled when falling outside of the multidimensional subset");e.timeExtent=i.timeExtent,e.mosaicRule=i.mosaicRule;const{raster:r,rasterFunction:a}=this;return a&&null==e.rasterFunction&&(e.rasterFunction=a),r&&null==e.raster&&(e.raster=r),xe(this.url,e,this._getRequestOptions(t))}async imageToMap(e,t){if(!(await this._fetchCapabilities(t?.signal)).operations.supportsImageToMap)throw new s("imagery-layer:image-to-map","imageToMap operation is not supported on the input image service");return _e(Ge(this.parsedUrl),e,this._getRequestOptions(t))}async imageToMapMultiray(e,t){if(!(await this._fetchCapabilities(t?.signal)).operations.supportsImageToMapMultiray)throw new s("imagery-layer:image-to-map-multiray","imageToMapMultiray operation is not supported on the input image service");return Fe(Ge(this.parsedUrl),e,this._getRequestOptions(t))}async mapToImage(e,t){if(!(await this._fetchCapabilities(t?.signal)).operations.supportsMapToImage)throw new s("imagery-layer:map-to-image","mapToImage operation is not supported on the input image service");return De(Ge(this.parsedUrl),e,this._getRequestOptions(t))}async findImages(e,t){if(!(await this._fetchCapabilities(t?.signal)).operations.supportsFindImages)throw new s("imagery-layer:find-images","findImages operation is not supported on the input image service");return Oe(Ge(this.parsedUrl),e,this._getRequestOptions(t))}async getImageUrl(e,t){if(!(await this._fetchCapabilities(t?.signal)).operations.supportsGetImageUrl)throw new s("imagery-layer:get-image-url","getImageUrl operation is not supported on the input image service");return Te(Ge(this.parsedUrl),e,this._getRequestOptions(t))}createQuery(){return new Ue({outFields:["*"],returnGeometry:!0,where:this.definitionExpression||"1=1"})}async queryBoundary(e,t){if(!(await this._fetchCapabilities(t?.signal)).operations.supportsQueryBoundary)throw new s("imagery-layer:query-boundary","queryBoundary operation is not supported on the input image service");return e=e??{outSpatialReference:this.spatialReference},Ce(Ge(this.parsedUrl),e,this._getRequestOptions(t))}async queryRasters(e,t){return({query:e,requestOptions:t}=await this._prepareForQuery(e,t)),Ve(this.url,e,t)}async queryObjectIds(e,t){return({query:e,requestOptions:t}=await this._prepareForQuery(e,t)),Ee(this.url,e,t)}async queryGPSInfo(e,t){if(!(await this._fetchCapabilities(t?.signal)).operations.supportsQueryGPSInfo)throw new s("imagery-layer:query-gps-info","queryGPSInfo operation is not supported on the input image service");return e=e??{where:"1=1"},Me(Ge(this.parsedUrl),e,this._getRequestOptions(t))}async queryRasterCount(e,t){return({query:e,requestOptions:t}=await this._prepareForQuery(e,t)),Ae(this.url,e,t)}async queryVisibleRasters(e,t){if(!e)throw new s("imagery-layer: query-visible-rasters","missing query parameter");await this.load();const{pixelSize:i,returnDomainValues:r,returnTopmostRaster:n,showNoDataRecords:a}=t||{pixelSize:null,returnDomainValues:!1,returnTopmostRaster:!1,showNoDataRecords:!1};let o=!1,l=null,u=null;const p=L.servicePixelValue.toLowerCase(),m=this._rasterFunctionNamesIndex;if(null!=e.outFields&&(o=e.outFields.some(e=>!e.toLowerCase().startsWith(p)),this.version>=10.4)){const t=e.outFields.filter(e=>e.toLowerCase().startsWith(p)&&e.length>p.length).map(e=>{const t=e.slice(p.length+1);return[this._updateRenderingRulesFunctionName(t,m),t]});l=t.map(e=>new G({functionName:e[0]})),u=t.map(e=>e[1]);const{rasterFunction:i}=this;0===l.length?i?.functionName?(l.push(i),u.push(i.functionName)):l=null:i?.functionName&&!l.some(e=>e.functionName===i.functionName)&&(l.push(i),u.push(i.functionName))}const c=null==e.outSpatialReference||e.outSpatialReference.equals(this.spatialReference),{multidimensionalSubset:h}=this;let d=e.timeExtent||this.timeExtent;if(h){const{isOutside:t,intersection:i}=W(h,{geometry:e.geometry,timeExtent:e.timeExtent,multidimensionalDefinition:this.exportImageServiceParameters.mosaicRule?.multidimensionalDefinition});if(t)throw new s("imagery-layer:query-visible-rasters","the request cannot be fulfilled when falling outside of the multidimensional subset");null!=i?.timeExtent&&(d=i.timeExtent)}const f=this._combineMosaicRuleWithTimeExtent(this.exportImageServiceParameters.mosaicRule,d);let g=e.geometry;this.version<10.91&&"extent"===g?.type&&(g=R.fromExtent(g));const y=this._getQueryParams({geometry:g,timeExtent:d,mosaicRule:f,rasterFunction:this.version<10.4?this.rasterFunction:null,rasterFunctions:l,pixelSize:i,returnCatalogItems:o,returnGeometry:c,raster:this.raster,maxItemCount:n?1:null});delete y.f;const I=new Je(y);try{await this._generateRasterInfo(this.rasterFunction);const i=await xe(this.url,I,{signal:t?.signal,query:{...this.customParameters}}),s=e.outFields,n=null!=i.value&&i.value.toLowerCase().includes("nodata"),l=o&&!c&&i?.catalogItems?.features.length&&(a||!n),p=this.multidimensionalInfo&&"raster-dataset"===this.sourceType?$({rasterInfo:this.rasterInfo,multidimensionalDefinition:f?.multidimensionalDefinition,timeExtent:d,multidimensionalSubset:this.multidimensionalSubset}):null;if(!l)return this._processVisibleRastersResponse(i,{returnDomainValues:r,templateRRFunctionNames:u,showNoDataRecords:a,templateFields:s,effectiveMultidimensionalDefinition:p});const m=this.objectIdField||"ObjectId",h=i.catalogItems?.features??[],g=h.map(e=>e.attributes?.[m]),y=new Ue({objectIds:g,returnGeometry:!0,outSpatialReference:e.outSpatialReference,outFields:[m]}),R=await this.queryRasters(y);return R?.features?.length&&R.features.forEach(t=>{h.forEach(i=>{i.attributes[m]===t.attributes[m]&&t.geometry&&(i.geometry=t.geometry.clone(),null!=e.outSpatialReference&&(i.geometry.spatialReference=e.outSpatialReference))})}),this._processVisibleRastersResponse(i,{returnDomainValues:r,templateRRFunctionNames:u,showNoDataRecords:a,templateFields:s,effectiveMultidimensionalDefinition:p})}catch{throw new s("imagery-layer:query-visible-rasters","encountered error when querying visible rasters")}}async fetchVariableStatisticsHistograms(e,t){const r=i(Ge(this.parsedUrl)+"/statistics",{query:this._getQueryParams({variable:e}),signal:t}).then(e=>e.data?.statistics),s=i(Ge(this.parsedUrl)+"/histograms",{query:this._getQueryParams({variable:e}),signal:t}).then(e=>e.data?.histograms),n=await Promise.all([r,s]);return n[0]&&n[0].forEach(e=>{e.avg=e.mean,e.stddev=e.standardDeviation}),{statistics:n[0]||null,histograms:n[1]||null}}getMultidimensionalSubsetVariables(e){const t=e??this.serviceRasterInfo.multidimensionalInfo;return X(this.multidimensionalSubset,t)}async _fetchService(e){await this._fetchServiceInfo(e),this.rasterInfo||(this.rasterInfo=this.serviceRasterInfo);const t=this.sourceJSON,i=null!=this.serviceRasterInfo?Promise.resolve(this.serviceRasterInfo):Pe(Ge(this.parsedUrl),t,{signal:e,query:this._getQueryParams()}).then(e=>(this._set("serviceRasterInfo",e),this._set("multidimensionalInfo",e.multidimensionalInfo),qe(e,t),e)),r=this._hasRasterFunction(this.rasterFunction)?this._generateRasterInfo(this.rasterFunction,{signal:e}):null,s=this._getRasterFunctionInfos();return Promise.all([i,r,s]).then(e=>{e[1]?this._set("rasterInfo",e[1]):this._set("rasterInfo",e[0]),e[2]&&this._set("rasterFunctionInfos",e[2]),this.internalRenderer&&!this._isSupportedRenderer(this.internalRenderer)&&(this._set("internalRenderer",null),a.getLogger(this).warn("ArcGISImageService","Switching to the default renderer. Renderer applied is not valid for this Imagery Layer")),this._set("internalRenderer",this._configRenderer(this.renderer)),this.addHandles([o(()=>this.rasterFunction,e=>{(this.renderer||this.symbolizer||this.popupEnabled&&this.popupTemplate)&&this._generateRasterInfo(e).then(e=>{e&&(this.rasterInfo=e)})})]);const{serviceRasterInfo:t}=this;null!=t.multidimensionalInfo&&this._updateMultidimensionalDefinition(t)})}_combineMosaicRuleWithTimeExtent(e,t){const i=this.timeInfo,{multidimensionalInfo:r}=this.serviceRasterInfo;if(null==e||null==r||null==t||null==i?.startField)return e;const{startField:s}=i,n=r.variables.some(e=>e.dimensions.some(e=>e.name===s))?s:"StdTime";if(e=e.clone(),"mosaic-dataset"===this.sourceType)return e.multidimensionalDefinition=e.multidimensionalDefinition?.filter(e=>e.dimensionName!==n),this._cleanupMultidimensionalDefinition(e);e.multidimensionalDefinition=e.multidimensionalDefinition||[];const a=e.multidimensionalDefinition.filter(e=>e.dimensionName===n),o=null!=t.start?t.start.getTime():null,l=null!=t.end?t.end.getTime():null,u=null==o||null==l||o===l,p=u?[o||l]:[[o,l]],m=this.version>=10.8;if(a.length)a.forEach(e=>{e.dimensionName===n&&(m?(e.dimensionName=null,e.isSlice=!1,e.values=[]):(e.isSlice=u,e.values=p))});else if(!m){const t=e.multidimensionalDefinition.filter(e=>null!=e.variableName&&null==e.dimensionName);t.length?t.forEach(e=>{e.dimensionName=n,e.isSlice=u,e.values=p}):e.multidimensionalDefinition.push(new S({variableName:"",dimensionName:n,isSlice:u,values:p}))}return this._cleanupMultidimensionalDefinition(e)}_cleanupMultidimensionalDefinition(e){return null==e?null:(e.multidimensionalDefinition&&(e.multidimensionalDefinition=e.multidimensionalDefinition.filter(e=>!(!e.variableName&&!e.dimensionName)),0===e.multidimensionalDefinition.length&&(e.multidimensionalDefinition=null)),"mosaic-dataset"!==this.sourceType&&null==e.multidimensionalDefinition?null:e)}async _prepareForQuery(e,t){if(!(await this._fetchCapabilities(t?.signal)).operations.supportsQuery)throw new s("imagery-layer:query-rasters","query operation is not supported on the input image service");return e=null!=e?c(Ue,e):this.createQuery(),t=this._getRequestOptions(t),this.raster&&(t.query={...t.query,raster:this.raster}),{query:e,requestOptions:t}}_isSupportedRenderer(e){const{rasterInfo:t,rasterFunction:i}=this;return"unique-value"===e.type&&this._hasRasterFunction(i)&&1===t?.bandCount&&["u8","s8"].includes(t.pixelType)||null!=t&&null!=e&&re(t).includes(e.type)}async _fetchCapabilities(e){return this.capabilities||await this._fetchServiceInfo(e),this.capabilities}async _fetchServiceInfo(e){let t=this.sourceJSON;if(!t){const{data:r,ssl:s}=await i(Ge(this.parsedUrl),{query:this._getQueryParams(),signal:e});t=r,this.sourceJSON=t,s&&(this.url=this.url.replace(/^http:/i,"https:"))}if(t.capabilities?.toLowerCase().split(",").map(e=>e.trim()).indexOf("tilesonly")>-1)throw new s("imagery-layer:fetch-service-info","use ImageryTileLayer to open tiles-only image services");this.read(t,{origin:"service",url:this.parsedUrl})}_isMosaicDataset(e){return e.serviceSourceType?"esriImageServiceSourceTypeMosaicDataset"===e.serviceSourceType:e.fields?.length>0}_isMosaicRuleSupported(e){if(!e)return!1;const t=this._isMosaicDataset(e),i=e.currentVersion>=10.71&&e.hasMultidimensions&&!(e.fields?.length>1);return t||i}_isVectorFieldResampleFunction(e){if(null==e)return!1;const{functionName:t,functionArguments:i}=e,r="resample"===t?.toLowerCase(),s=i?.ResampleType||i?.resampleType;return r&&(7===s||10===s)}_isPicture(){return!this.format||this.format.includes("jpg")||this.format.includes("png")}_configRenderer(e){const t=this._isPicture(),{rasterInfo:i}=this;if(!t&&!this.pixelFilter||this._isVectorDataSet()){const t=this.mosaicRule?.multidimensionalDefinition?.[0].variableName,r=se({variableName:t,rasterFunctionName:this.rasterFunction?.functionName,presetRenderers:this.presetRenderers});if(!this.bandIds&&i.bandCount>=3){const e=r?.bandIds??ne(i);!e||3===i.bandCount&&0===e[0]&&1===e[1]&&2===e[2]||(this.bandIds=e)}e||(e=r?.renderer??ie(i,{bandIds:this.bandIds,variableName:this.rasterFunction?null:t}));const s=ae(e.toJSON());this.symbolizer?(this.symbolizer.rendererJSON=s,this.symbolizer.rasterInfo=i):this.symbolizer=new oe({rendererJSON:s,rasterInfo:i}),this.symbolizer.bind().success||(this.symbolizer=null)}return e}_clonePixelData(e){return null==e?e:{extent:e.extent&&e.extent.clone(),pixelBlock:null!=e.pixelBlock?e.pixelBlock.clone():null}}_getQueryParams(e){null!=e?.renderingRule&&"string"!=typeof e.renderingRule&&(e.renderingRule=this._getRenderingRuleString(e.renderingRule));const{raster:t,viewId:i}=this;return{raster:t,viewId:i,f:"json",...e,...this.customParameters}}_getRequestOptions(e){return{...e,query:{...e?.query,...this.customParameters}}}_decodePixelBlock(e,t,i){return this._rasterJobHandler?this._rasterJobHandler.decode({data:e,options:t}):Y(e,t,i)}async _getRasterFunctionInfos(e){const t=this.sourceJSON.rasterFunctionInfos;if(this.loaded)return t;if(t&&this.version>=10.3){if(1===t.length&&"none"===t[0].name.toLowerCase())return t;const r=await i(Ge(this.parsedUrl)+"/rasterFunctionInfos",{query:this._getQueryParams(),signal:e});return r.data?.rasterFunctionInfos}return null}_canRequestImageElement(e){return!this.pixelFilter&&(!e||e.includes("png"))}async _requestArrayBuffer(e){const{imageProps:t,requestAsImageElement:r,returnImageBitmap:n,signal:a}=e;if(r&&this._canRequestImageElement(t.format)){const r=`${Ge(this.parsedUrl)}/exportImage`,{data:s}=await i(r,{responseType:n?"blob":"image",query:this._getQueryParams({f:"image",...this.refreshParameters,...e.imageServiceParameters}),signal:a});if(s instanceof Blob){return{imageBitmap:await D(s,r,a),params:t}}return{imageOrCanvasElement:s,params:t}}const o=this._initJobHandler(),l=i(Ge(this.parsedUrl)+"/exportImage",{responseType:"array-buffer",query:this._getQueryParams({f:"image",...e.imageServiceParameters}),signal:a}),u=(await Promise.all([l,o]))[0].data,p=t.format||"jpgpng";let m=p;if("bsq"!==m&&"bip"!==m&&(m=Z(u)),!m)throw new s("imagery-layer:fetch-image","unsupported format signature "+String.fromCharCode.apply(null,new Uint8Array(u)));const c={signal:a},h="gif"===p||"bmp"===p||p.includes("png")&&("png"===m||"jpg"===m)?Y(u,{useCanvas:!0,...t},c):this._decodePixelBlock(u,{width:t.width,height:t.height,planes:null,pixelType:null,noDataValue:null,format:p},c);return{pixelData:{pixelBlock:await h,extent:t.extent},params:t}}_generateRasterInfo(e,t){return this.generateRasterInfo(e,t).catch(()=>null)}_isValidCustomizedMosaicRule(e){return e&&JSON.stringify(e.toJSON())!==JSON.stringify(this.defaultMosaicRule?.toJSON())}_updateMultidimensionalDefinition(e){if(this._isValidCustomizedMosaicRule(this.mosaicRule))return;let t=K(e,{multidimensionalSubset:this.multidimensionalSubset});if(null!=t&&t.length>0){this.mosaicRule=this.mosaicRule||new T;const e=this.mosaicRule.multidimensionalDefinition;!this.sourceJSON.defaultVariableName&&this.rasterFunction&&"none"!==this.rasterFunction.functionName?.toLowerCase()&&t.forEach(e=>e.variableName=""),t=t.filter(({variableName:e,dimensionName:t})=>e&&"*"!==e||t),!e?.length&&t.length&&(this.mosaicRule.multidimensionalDefinition=t)}}_processVisibleRastersResponse(e,i){i=i||{};const r=e.value,{templateRRFunctionNames:s,showNoDataRecords:n,returnDomainValues:a,templateFields:o}=i,l=e.processedValues;let u=e.catalogItems?.features,p=e.properties?.Values?.map(e=>e.replaceAll(/ /gi,", "))||[];const m=this.objectIdField||"ObjectId",c="string"==typeof r&&r.toLowerCase().includes("nodata"),h=[];if(r&&!u&&(!c||n)){const e={};e[m]=0;p=[r],u=[new t({geometry:this.fullExtent,attributes:e})],this.multidimensionalInfo&&"raster-dataset"===this.sourceType&&z(this.rasterFields,e,i.effectiveMultidimensionalDefinition)}if(!u)return[];this._updateResponseFieldNames(u,o),c&&!n&&(u=[]);const{itemPixelValue:d,servicePixelValue:f}=L,g=this.rasterFields.some(e=>e.name===d);for(let t=0;t<u.length;t++){const e=u[t];if(null!=r){const i=p[t],a=this.rasterFunction&&l&&l.length>0&&s&&s.length>0&&s.includes(this.rasterFunction.functionName)?l[s.indexOf(this.rasterFunction.functionName)]:r;if("nodata"===i.toLowerCase()&&!n)continue;g&&(e.attributes[d]=i),e.attributes[f]=a,this._updateFeatureWithMagDirValues(e,i);const o=this.fields&&this.fields.length>0;let u=this.rasterFunction&&null!=this.serviceRasterInfo.attributeTable?o?i:r:a;this.rasterFunction||(u=o?i:r),this._updateFeatureWithRasterAttributeTableValues(e,u)}if(e.sourceLayer=e.layer=this,a&&this._updateFeatureWithDomainValues(e),s&&l&&s.length===l.length)for(let t=0;t<s.length;t++){const i=`${L.servicePixelValue}.${s[t]}`;e.attributes[i]=l[t]}h.push(u[t])}return h}_processMultidimensionalIntersection(e,t,i){const{multidimensionalSubset:r}=this;if(!r)return{isOutSide:!1,timeExtent:t,mosaicRule:i=this._combineMosaicRuleWithTimeExtent(i,t)};if(r){const{isOutside:i,intersection:s}=W(r,{geometry:e,timeExtent:t});if(i)return{isOutSide:!0,timeExtent:null,mosaicRule:null};null!=s?.timeExtent&&(t=s.timeExtent)}if(i=this._combineMosaicRuleWithTimeExtent(i,t),i?.multidimensionalDefinition){const{isOutside:e}=W(r,{multidimensionalDefinition:i.multidimensionalDefinition});if(e)return{isOutSide:!0,timeExtent:null,mosaicRule:null}}return{isOutSide:!1,timeExtent:t,mosaicRule:i}}_updateFeatureWithRasterAttributeTableValues(e,t){const i=this.rasterInfo.attributeTable||this.serviceRasterInfo.attributeTable;if(null==i)return;const{features:r,fields:s}=i,n=s.map(e=>e.name).find(e=>"value"===e.toLowerCase());if(!n)return;const a=r.filter(e=>e.attributes[n]===(null!=t?parseInt(t,10):null));a&&a[0]&&s.forEach(t=>{const i=H+t.name;e.attributes[i]=a[0].attributes[t.name]})}_updateFeatureWithMagDirValues(e,t){if(!this._isVectorDataSet())return;const i=t.split(/,\s*/).map(e=>parseFloat(e)),r=i.map(e=>[e]),s=i.map(e=>({minValue:e,maxValue:e,noDataValue:null})),n=new M({height:1,width:1,pixelType:"f32",pixels:r,statistics:s});null!=this.pixelFilter&&this.pixelFilter({pixelBlock:n,extent:new y(0,0,0,0,this.spatialReference)});const a="esriImageServiceDataTypeVector-MagDir"===this.serviceDataType?[n.pixels[0][0],n.pixels[1][0]]:te([n.pixels[0][0],n.pixels[1][0]]);e.attributes[L.magnitude]=a[0],e.attributes[L.direction]=a[1]}_updateFeatureWithDomainValues(e){const t=this.fields&&this.fields.filter(e=>e.domain&&"coded-value"===e.domain.type);null!=t&&t.forEach(t=>{const i=e.attributes[t.name];if(null!=i){const r=t.domain.codedValues.find(e=>e.code===i);r&&(e.attributes[t.name]=r.name)}})}_updateResponseFieldNames(e,t){if(!t||t.length<1)return;const i=this.fieldsIndex;null!=i&&e.forEach(e=>{if(e?.attributes)for(const r of t){const t=i.get(r)?.name;t&&t!==r&&(e.attributes[r]=e.attributes[t],delete e.attributes[t])}})}_getRenderingRuleString(e){if(e){let t=e.toJSON();return t=t.rasterFunctionDefinition??t,(t.thumbnail||t.thumbnailEx)&&(t.thumbnail=t.thumbnailEx=null),JSON.stringify(t)}return null}_hasRasterFunction(e){return null!=e?.functionName&&"none"!==e.functionName.toLowerCase()}_updateRenderingRulesFunctionName(e,t){if(!e||e.length<1)return;if("Raw"===e)return e.replace("Raw","None");const i=e.toLowerCase().replaceAll(/ /gi,"_");return t.has(i)?t.get(i):e}_isRFTJson(e){return e?.name&&e.arguments&&e.function&&e.hasOwnProperty("functionType")}_isVectorDataSet(){return"esriImageServiceDataTypeVector-UV"===this.serviceDataType||"esriImageServiceDataTypeVector-MagDir"===this.serviceDataType}_applyMosaicAndRenderingRules(e){const{raster:t,mosaicRule:i,rasterFunction:r}=this;r&&null==e.rasterFunction&&(e.rasterFunction=r),i&&null==e.mosaicRule&&(e.mosaicRule=i),t&&null==e.raster&&(e.raster=t)}async _updateCurrentRasterInfo(e){if(this.renderer||this.symbolizer){const t=await this._generateRasterInfo(this.rasterFunction,{signal:e});t&&(this.rasterInfo=t)}}_applyMosaicRule(e){const{raster:t,mosaicRule:i}=this;i&&null==e.mosaicRule&&(e.mosaicRule=i),t&&null==e.raster&&(e.raster=t)}_readCapabilities(e){const t=e.capabilities?e.capabilities.toLowerCase().split(",").map(e=>e.trim()):["image","catalog"],{currentVersion:i,maxRecordCount:r}=e,s=t.includes("image"),n="esriImageServiceDataTypeElevation"===e.serviceDataType,a=!(!e.spatialReference&&!e.extent?.spatialReference),o=t.includes("edit"),l=t.includes("mensuration")&&a,u=null==e.mensurationCapabilities?[]:e.mensurationCapabilities.toLowerCase().split(",").map(e=>e.trim()),p=l&&u.includes("basic"),m=this._isMosaicDataset(e)&&t.includes("catalog"),c=t.includes("download"),h=i>=10.7&&n||i>=11.4&&(n||l&&u.includes("3d")),d=m&&e.fields&&e.fields.length>0,f=d&&e.supportsAdvancedQueries?e.advancedQueryCapabilities:void 0;return{data:{supportsAttachment:!1},operations:{supportsComputeHistograms:s,supportsExportImage:s,supportsIdentify:s,supportsImageToMap:i>=11.2&&m,supportsImageToMapMultiray:i>=11.2&&m,supportsMapToImage:i>=11.2&&m,supportsFindImages:i>=11.2&&m,supportsGetImageUrl:i>=11.3&&c,supportsMeasure:l,supportsMeasureFromImage:i>=11.2,supportsDownload:c,supportsQuery:d,supportsGetSamples:i>=10.2&&s,supportsProject:i>=10.3&&s,supportsComputeStatisticsHistograms:i>=10.4&&s,supportsQueryBoundary:i>=10.6&&s,supportsCalculateVolume:h,supportsComputePixelLocation:i>=10.7&&m,supportsComputeAngles:i>=10.91,supportsQueryGPSInfo:i>=11.2&&m,supportsAdd:o,supportsDelete:o,supportsEditing:o,supportsUpdate:o,supportsCalculate:!1,supportsTruncate:!1,supportsValidateSql:!1,supportsChangeTracking:!1,supportsQueryAttachments:!1,supportsResizeAttachments:!1,supportsSync:!1,supportsExceedsLimitStatistics:!1,supportsQueryAnalytics:!1,supportsQueryBins:!1,supportsQueryTopFeatures:!1,supportsAsyncConvert3D:!1},query:{maxRecordCount:r,maxRecordCountFactor:void 0,maxUniqueIDCount:void 0,supportsStatistics:!!f?.supportsStatistics,supportsOrderBy:!!f?.supportsOrderBy,supportsDistinct:!!f?.supportsDistinct,supportsPagination:!!f?.supportsPagination,supportsPaginationOnAggregatedQueries:!!f?.supportsPaginationOnAggregatedQueries,supportsStandardizedQueriesOnly:!!f?.useStandardizedQueries,supportsPercentileStatistics:!!f?.supportsPercentileStatistics,supportsCentroid:!!f?.supportsReturningGeometryCentroid,supportsCentroidOnDegeneratedQuantizedGeometry:!1,supportsCurrentUser:!1,supportsDegeneratedQuantizedGeometry:!1,supportsDistance:!!f?.supportsQueryWithDistance,supportsExtent:!!f?.supportsReturningQueryExtent,supportsGeometryProperties:!!f?.supportsReturningGeometryProperties,supportsHavingClause:!!f?.supportsHavingClause,supportsQuantization:!1,supportsQuantizationEditMode:!1,supportsQueryGeometry:!1,supportsResultType:!1,supportsReturnMesh:!1,supportsMaxRecordCountFactor:!1,supportsSqlExpression:f?.supportsSqlExpression??!!f,supportsTopFeaturesQuery:!1,supportsQueryByAnonymous:!1,supportsQueryByOthers:!1,supportsHistoricMoment:!1,supportsFormatPBF:!1,supportsDisjointSpatialRelationship:!1,supportsCacheHint:!1,supportsSpatialAggregationStatistics:!1,supportedSpatialAggregationStatistics:{envelope:!1,centroid:!1,convexHull:!1},supportsDefaultSpatialReference:!!f?.supportsDefaultSR,supportsFullTextSearch:!1,supportsCompactGeometry:!1,standardMaxRecordCount:void 0,tileMaxRecordCount:void 0,supportsTrueCurve:!1},mensuration:{supportsDistanceAndAngle:p,supportsAreaAndPerimeter:p,supportsPointOrCentroid:p,supportsHeightFromBaseAndTop:l&&u.includes("base-top height"),supportsHeightFromBaseAndTopShadow:l&&u.includes("base-top shadow height"),supportsHeightFromTopAndTopShadow:l&&u.includes("top-top shadow height"),supports3D:l&&u.includes("3d")}}}};function Ge(e){return e?.path??""}return e([u({clonable:!1})],He.prototype,"_functionRasterInfos",void 0),e([u({readOnly:!0})],He.prototype,"_serviceSupportsMosaicRule",void 0),e([d("_serviceSupportsMosaicRule",["currentVersion","fields"])],He.prototype,"readServiceSupportsMosaicRule",null),e([u({readOnly:!0})],He.prototype,"_rasterFunctionNamesIndex",null),e([u()],He.prototype,"adjustAspectRatio",void 0),e([u({type:[p],json:{write:!0}})],He.prototype,"bandIds",void 0),e([d("bandIds")],He.prototype,"readBandIds",null),e([u({readOnly:!0,json:{read:!1}})],He.prototype,"capabilities",void 0),e([d("service","capabilities",["capabilities","currentVersion","serviceDataType"])],He.prototype,"readCapabilities",null),e([u({type:Number})],He.prototype,"compressionQuality",void 0),e([g("compressionQuality")],He.prototype,"writeCompressionQuality",null),e([u({type:Number})],He.prototype,"compressionTolerance",void 0),e([g("compressionTolerance")],He.prototype,"writeCompressionTolerance",null),e([u({json:{read:{source:"copyrightText"}}})],He.prototype,"copyright",void 0),e([u({readOnly:!0,dependsOn:["_serviceSupportsMosaicRule"]})],He.prototype,"defaultMosaicRule",void 0),e([d("defaultMosaicRule",["defaultMosaicMethod"])],He.prototype,"readDefaultMosaicRule",null),e([u({type:String,json:{name:"layerDefinition.definitionExpression",write:{enabled:!0,allowNull:!0}}})],He.prototype,"definitionExpression",void 0),e([u({readOnly:!0,constructOnly:!0})],He.prototype,"exportImageServiceParameters",void 0),e([u()],He.prototype,"rasterInfo",void 0),e([u({readOnly:!0,type:[_]})],He.prototype,"fields",void 0),e([u({readOnly:!0})],He.prototype,"fieldsIndex",null),e([u({type:["png","png8","png24","png32","jpg","bmp","gif","jpgpng","lerc","tiff","bip","bsq"],json:{write:!0}})],He.prototype,"format",null),e([d("service","format",["serviceDataType"])],He.prototype,"readFormat",null),e([u({type:y})],He.prototype,"fullExtent",void 0),e([u({readOnly:!0})],He.prototype,"hasMultidimensions",void 0),e([u({json:{read:{source:"maxImageHeight"}}})],He.prototype,"imageMaxHeight",void 0),e([u({json:{read:{source:"maxImageWidth"}}})],He.prototype,"imageMaxWidth",void 0),e([u({type:String,json:{type:P.jsonValues,read:P.read,write:P.write}})],He.prototype,"interpolation",void 0),e([u()],He.prototype,"minScale",void 0),e([d("service","minScale")],He.prototype,"readMinScale",null),e([u()],He.prototype,"maxScale",void 0),e([d("service","maxScale")],He.prototype,"readMaxScale",null),e([u({type:T})],He.prototype,"mosaicRule",null),e([d("mosaicRule",["mosaicRule","defaultMosaicMethod"])],He.prototype,"readMosaicRule",null),e([g("mosaicRule")],He.prototype,"writeMosaicRule",null),e([u()],He.prototype,"multidimensionalInfo",void 0),e([u({type:C,json:{write:!0}})],He.prototype,"multidimensionalSubset",void 0),e([u({json:{type:p}})],He.prototype,"noData",void 0),e([g("noData")],He.prototype,"writeNoData",null),e([u({type:String,json:{type:N.jsonValues,read:N.read,write:N.write}})],He.prototype,"noDataInterpretation",void 0),e([u({type:String,readOnly:!0,json:{read:{source:["fields"]}}})],He.prototype,"objectIdField",void 0),e([d("objectIdField")],He.prototype,"readObjectIdField",null),e([u({readOnly:!0})],He.prototype,"geometryType",void 0),e([u({})],He.prototype,"typeIdField",void 0),e([u({})],He.prototype,"types",void 0),e([u({readOnly:!0})],He.prototype,"parsedUrl",null),e([u({type:Function})],He.prototype,"pixelFilter",void 0),e([u()],He.prototype,"raster",void 0),e([u({readOnly:!0})],He.prototype,"sourceType",void 0),e([d("sourceType",["serviceSourceType","fields"])],He.prototype,"readSourceType",null),e([u()],He.prototype,"viewId",void 0),e([u()],He.prototype,"renderer",null),e([u({types:ue,json:{name:"layerDefinition.drawingInfo.renderer",origins:{"web-scene":{types:le,name:"layerDefinition.drawingInfo.renderer",write:{overridePolicy:e=>({enabled:e&&"vector-field"!==e.type})}}}}})],He.prototype,"internalRenderer",null),e([d("internalRenderer")],He.prototype,"readRenderer",null),e([g("internalRenderer")],He.prototype,"writeRenderer",null),e([u({clonable:!1})],He.prototype,"symbolizer",void 0),e([u(w)],He.prototype,"opacity",void 0),e([u({readOnly:!0})],He.prototype,"rasterFields",null),e([u({constructOnly:!0})],He.prototype,"rasterFunctionInfos",void 0),e([u({type:G,json:{name:"renderingRule"}})],He.prototype,"rasterFunction",null),e([d("rasterFunction",["renderingRule","rasterFunctionInfos"])],He.prototype,"readRasterFunction",null),e([u({readOnly:!0})],He.prototype,"serviceDataType",void 0),e([u({readOnly:!0,type:I})],He.prototype,"spatialReference",void 0),e([d("spatialReference",["spatialReference","extent"])],He.prototype,"readSpatialReference",null),e([u({type:q.apiValues,json:{read:q.read,type:q.jsonValues}})],He.prototype,"pixelType",void 0),e([g("pixelType")],He.prototype,"writePixelType",null),e([u({constructOnly:!0,type:k})],He.prototype,"serviceRasterInfo",void 0),e([u()],He.prototype,"sourceJSON",void 0),e([u(b)],He.prototype,"url",void 0),e([u({readOnly:!0})],He.prototype,"version",void 0),e([d("version",["currentVersion","fields","timeInfo"])],He.prototype,"readVersion",null),He=e([f("esri.layers.mixins.ArcGISImageService")],He),He};export{He as ArcGISImageService};
|
|
5
|
+
import{__decorate as e}from"tslib";import t from"../../Graphic.js";import i from"../../request.js";import{deprecatedFunction as r}from"../../core/deprecate.js";import s from"../../core/Error.js";import{clone as n}from"../../core/lang.js";import a from"../../core/Logger.js";import{watch as o}from"../../core/reactiveUtils.js";import{urlToObject as l}from"../../core/urlUtils.js";import{property as u}from"../../core/accessorSupport/decorators/property.js";import{Integer as p,ensureRange as m,ensureClass as c,ensureNumber as h}from"../../core/accessorSupport/ensureType.js";import{reader as d}from"../../core/accessorSupport/decorators/reader.js";import{subclass as f}from"../../core/accessorSupport/decorators/subclass.js";import{writer as g}from"../../core/accessorSupport/decorators/writer.js";import y from"../../geometry/Extent.js";import R from"../../geometry/Polygon.js";import I from"../../geometry/SpatialReference.js";import{srToRESTValue as v}from"../../geometry/support/spatialReferenceUtils.js";import{opacity as w,url as b}from"../support/commonProperties.js";import S from"../support/DimensionalDefinition.js";import{ExportImageServiceParameters as x}from"../support/ExportImageServiceParameters.js";import _ from"../support/Field.js";import F from"../support/FieldsIndex.js";import{createBitmap as D}from"../support/imageBitmapUtils.js";import{isSupportedRendererType as O}from"../support/imageryRendererUtils.js";import T from"../support/MosaicRule.js";import C from"../support/MultidimensionalSubset.js";import M from"../support/PixelBlock.js";import{interpolationKebab as P,noDataInterpretationKebab as N,pixelTypeKebabDict as q}from"../support/rasterEnums.js";import{getServicePixelValueField as j,getItemPixelValueField as A,getRawServicePixelValueField as E,getProcessedServicePixelValueField as V,getMagnitudeField as Q,getDirectionField as J,getMultidimensionalFields as U,getRasterAttributeTableFields as B,commonRasterFieldNames as L,addMultidimensionalFieldValues as z,rasterFieldPrefix as H}from"../support/rasterFieldUtils.js";import G from"../support/RasterFunction.js";import k from"../support/RasterInfo.js";import{intersectMultimensionalSubset as W,getEffectiveMultidimensionalDefinition as $,getSubsetVariablesFromMdInfo as X,getDefaultMultidimensionalDefinition as K}from"../support/rasterDatasets/multidimensionalUtils.js";import{decode as Y,getFormat as Z}from"../support/rasterFormats/RasterCodec.js";import{highlightPixels as ee}from"../support/rasterFunctions/pixelUtils.js";import{uvComponentToVector as te}from"../support/rasterFunctions/vectorFieldUtils.js";import{createDefaultRenderer as ie,getSupportedRendererTypes as re,matchPresetRenderer as se,getDefaultBandCombination as ne,normalizeRendererJSON as ae}from"../../renderers/support/rasterRendererHelper.js";import oe from"../../renderers/support/RasterSymbolizer.js";import{websceneRasterRendererTypes as le,rasterRendererTypes as ue,read as pe}from"../../renderers/support/rasterTypeUtils.js";import{calculateVolume as me,computeAngles as ce,computePixelSpaceLocations as he,computeHistograms as de,computeStatisticsHistograms as fe,measureHeight as ge,measureAreaAndPerimeter as ye,measureDistanceAndAngle as Re,measurePointOrCentroid as Ie,measureLengthFromImage as ve,measureAreaFromImage as we,getImageSpatialReferenceQueryParameter as be,getSamples as Se,identify as xe,imageToMap as _e,imageToMapMultiray as Fe,mapToImage as De,findImages as Oe,getImageUrl as Te,queryBoundary as Ce,queryGPSInfo as Me}from"../../rest/imageService.js";import{fetchServiceRasterInfo as Pe,generateRasterInfo as Ne,patchServiceInfo as qe}from"../../rest/imageService/fetchRasterInfo.js";import{getCatalogItemRasterInfo as je}from"../../rest/imageService/getCatalogItemRasterInfo.js";import{executeForCount as Ae}from"../../rest/query/executeForCount.js";import{executeForIds as Ee}from"../../rest/query/executeForIds.js";import{executeQueryJSON as Ve}from"../../rest/query/executeQueryJSON.js";import Qe from"../../rest/support/FeatureSet.js";import Je from"../../rest/support/ImageIdentifyParameters.js";import Ue from"../../rest/support/Query.js";const Be=new Set(["png","png8","png24","png32","jpg","bmp","gif","jpgpng","lerc","tiff"]),Le=m(h,{min:0,max:255});function ze(e){const t=JSON.stringify(e),i=t.includes('"rasterFunctionDefinition":{'),r=i?t.match(/"type":"(.*?FunctionArguments")/gi):t.match(/"rasterFunction":"(.*?")/gi),s=r?.map(e=>i?e.slice(8,-18):e.slice(18,-1));return s?s.join("/"):null}const He=m=>{const h=m;let He=class extends h{constructor(){super(...arguments),this._functionRasterInfos={},this._serviceSupportsMosaicRule=null,this.adjustAspectRatio=null,this.bandIds=void 0,this.capabilities=null,this.compressionQuality=void 0,this.compressionTolerance=.01,this.copyright=null,this.defaultMosaicRule=null,this.definitionExpression=null,this.exportImageServiceParameters=null,this.rasterInfo=null,this.fields=null,this.fullExtent=null,this.hasMultidimensions=!1,this.imageMaxHeight=4100,this.imageMaxWidth=4100,this.interpolation=void 0,this.minScale=0,this.maxScale=0,this.multidimensionalInfo=null,this.multidimensionalSubset=null,this.noData=null,this.noDataInterpretation=void 0,this.objectIdField=null,this.geometryType="polygon",this.typeIdField=null,this.types=[],this.pixelFilter=null,this.raster=void 0,this.sourceType=null,this.viewId=void 0,this.symbolizer=null,this.rasterFunctionInfos=null,this.serviceDataType=null,this.spatialReference=null,this.pixelType=null,this.serviceRasterInfo=null,this.sourceJSON=null,this.url=null,this.version=void 0}initialize(){this._set("exportImageServiceParameters",new x({layer:this}))}readServiceSupportsMosaicRule(e,t){return this._isMosaicRuleSupported(t)}get _rasterFunctionNamesIndex(){const e=new Map;return!this.rasterFunctionInfos||null!=this.rasterFunctionInfos&&this.rasterFunctionInfos.length<1||null!=this.rasterFunctionInfos&&this.rasterFunctionInfos.forEach(t=>{e.set(t.name.toLowerCase().replaceAll(/ /gi,"_"),t.name)}),e}readBandIds(e,t){if(Array.isArray(e)&&e.length>0&&e.every(e=>"number"==typeof e))return e}readCapabilities(e,t){return this._readCapabilities(t)}writeCompressionQuality(e,t,i){null!=e&&"lerc"!==this.format&&(t[i]=e)}writeCompressionTolerance(e,t,i){"lerc"===this.format&&null!=e&&(t[i]=e)}readDefaultMosaicRule(e,t){return this._serviceSupportsMosaicRule?T.fromJSON(t):null}get fieldsIndex(){return this.fields?new F(this.fields):null}set format(e){e&&Be.has(e.toLowerCase())&&this._set("format",e.toLowerCase())}readFormat(e,t){return"esriImageServiceDataTypeVector-UV"===t.serviceDataType||"esriImageServiceDataTypeVector-MagDir"===t.serviceDataType||null!=this.pixelFilter?"lerc":"jpgpng"}readMinScale(e,t){return null!=t.minLOD&&null!=t.maxLOD?e:0}readMaxScale(e,t){return null!=t.minLOD&&null!=t.maxLOD?e:0}set mosaicRule(e){let t=e;t?.mosaicMethod&&(t=T.fromJSON({...t.toJSON(),mosaicMethod:t.mosaicMethod,mosaicOperation:t.mosaicOperation})),this._set("mosaicRule",t)}readMosaicRule(e,t){const i=e||t.mosaicRule;return i?T.fromJSON(i):this._isMosaicRuleSupported(t)?T.fromJSON(t):null}writeMosaicRule(e,t,i){const{mosaicRule:r}=this;this._isValidCustomizedMosaicRule(r)&&(t[i]=r.toJSON())}writeNoData(e,t,i){null!=e&&"number"==typeof e&&(t[i]=Le(e))}readObjectIdField(e,t){if(!e){const i=t.fields.find(e=>"esriFieldTypeOID"===e.type||"oid"===e.type);e=i?.name}return e}get parsedUrl(){return l(this.url)}readSourceType(e,t){return this._isMosaicDataset(t)?"mosaic-dataset":"raster-dataset"}get renderer(){const{activePresetRendererName:e,presetRenderers:t}=this;if(e){const i=t?.find(({name:t})=>t===e);return i?.renderer.clone()}return this.internalRenderer}set renderer(e){this.activePresetRendererName=null,this.internalRenderer=e}set internalRenderer(e){this.loaded&&(e=this._configRenderer(e)),this._set("internalRenderer",e)}readRenderer(e,t,i){const r=t?.layerDefinition?.drawingInfo?.renderer,s=pe(r,i);return null==s?null:("vector-field"===s.type&&t.symbolTileSize&&!r.symbolTileSize&&(s.symbolTileSize=t.symbolTileSize),O(s)||a.getLogger(this).warn("ArcGISImageService","Imagery layer doesn't support given renderer type."),s)}writeRenderer(e,t,i){t.layerDefinition=t.layerDefinition||{},t.layerDefinition.drawingInfo=t.layerDefinition.drawingInfo||{},t.layerDefinition.drawingInfo.renderer=e.toJSON(),"vector-field"===e.type&&(t.symbolTileSize=e.symbolTileSize)}get rasterFields(){const e=this.fields?.map(e=>e.clone())??[];e.push(j()),"mosaic-dataset"===this.sourceType&&this.fields?.length&&e.push(A()),this.version>=10.4&&null!=this.rasterFunctionInfos&&this.rasterFunctionInfos.some(({name:e})=>"none"===e.toLowerCase())&&e.push(E()),null!=this.rasterFunctionInfos&&this.rasterFunctionInfos.filter(({name:e})=>"none"!==e.toLowerCase()).forEach(({name:t})=>e.push(V(t)));const{rasterInfo:t}=this;if(this._isVectorDataSet()){const i=t?.multidimensionalInfo?.variables[0].unit?.trim(),r=Q(i),s=J();e.push(r,s)}if(t?.multidimensionalInfo&&"raster-dataset"===this.sourceType){const i=U(t.multidimensionalInfo);e.push(...i)}const i=t?.attributeTable;if(null!=i){const t=B(i);e.push(...t)}return e}set rasterFunction(e){let t=e;t?.rasterFunction&&(t=G.fromJSON({...t.toJSON(),rasterFunction:t.rasterFunction,rasterFunctionArguments:t.rasterFunctionArguments})),this._set("rasterFunction",t)}readRasterFunction(e,t){const i=t.rasterFunctionInfos;return t.renderingRule||i?.length&&"None"!==i[0].name?this._isRFTJson(t.renderingRule)?G.fromJSON({rasterFunctionDefinition:t.renderingRule}):G.fromJSON(t.renderingRule||{rasterFunctionInfos:t.rasterFunctionInfos}):null}readSpatialReference(e,t){const i=e||t.extent.spatialReference;return i?I.fromJSON(i):null}writePixelType(e,t,i){null!=this.serviceRasterInfo&&this.pixelType===this.serviceRasterInfo.pixelType||(t[i]=q.toJSON(e))}readVersion(e,t){let i=t.currentVersion;return i||(i=t.hasOwnProperty("fields")||t.hasOwnProperty("timeInfo")?10:9.3),i}applyFilter(e){let t=e;return this.pixelFilter&&(t=this._clonePixelData(e),this.pixelFilter(t)),t}async applyRenderer(e,t){let i=e,{renderer:r,symbolizer:s,pixelFilter:n}=this;const{isRawData:a}=e;if(a&&"lerc"!==this.format&&(r??=ie(this.rasterInfo,{bandIds:this.bandIds,variableName:this.rasterFunction?null:this.mosaicRule?.multidimensionalDefinition?.[0].variableName}),s||(this.symbolizer=new oe({rendererJSON:r.toJSON(),rasterInfo:this.rasterInfo}),s=this.symbolizer)),(a||!this._isPicture())&&r&&s&&!n){await this._updateSymbolizer(s,r);const{bandIds:n}=this;i=await this._symbolize({pixelData:e,bandIds:n,symbolizer:s},t)}return i}async highlightPixels(e,t){const i=e.highlightOptions.map(e=>{const t={...e},{bandId:i}=t;if(null==i)t.bandId=0;else{const e=this.bandIds?.length?this.bandIds.indexOf(i):i;if(e<0||e>2)return;t.bandId=e}return t}).filter(e=>null!=e),r=this._rasterJobHandler;r?await r.highlightPixels({...e,highlightOptions:i},t):ee(e.pixelBlock,e.renderedPixelBlock,i)}destroy(){this._shutdownJobHandler()}async calculateVolume(e,t){if(!(await this._fetchCapabilities(t?.signal)).operations.supportsCalculateVolume)throw new s("imagery-layer:compute-pixel-space-locations","this operation is not supported on the input image service");return e=n(e),this.mosaicRule&&null==e.mosaicRule&&(e.mosaicRule=this.mosaicRule),me(this.url,e,this._getRequestOptions(t))}async computeAngles(e,t){if(!(await this._fetchCapabilities(t?.signal)).operations.supportsComputeAngles)throw new s("imagery-layer:compute-angles","this operation is not supported on the input image service");return ce(this.url,e,this._getRequestOptions(t))}async computePixelSpaceLocations(e,t){if(!(await this._fetchCapabilities(t?.signal)).operations.supportsComputePixelLocation)throw new s("imagery-layer:compute-pixel-space-locations","this operation is not supported on the input image service");return he(this.url,e,this._getRequestOptions(t))}async computeHistograms(e,t){if(!(await this._fetchCapabilities(t?.signal)).operations.supportsComputeHistograms)throw new s("imagery-layer:compute-histograms","this operation is not supported on the input image service");return e=n(e),this._applyMosaicAndRenderingRules(e),de(this.url,e,this._getRequestOptions(t))}async computeStatisticsHistograms(e,t){if(!(await this._fetchCapabilities(t?.signal)).operations.supportsComputeStatisticsHistograms)throw new s("imagery-layer:compute-statistics-histograms","this operation is not supported on the input image service");return e=n(e),this._applyMosaicAndRenderingRules(e),fe(this.url,e,this._getRequestOptions(t))}async measureHeight(e,t){const i=await this._fetchCapabilities(t?.signal);if(!("base-and-top"===e.operationType?i.mensuration.supportsHeightFromBaseAndTop:"base-and-top-shadow"===e.operationType?i.mensuration.supportsHeightFromBaseAndTopShadow:i.mensuration.supportsHeightFromTopAndTopShadow))throw new s("imagery-layer:measure-height","this operation is not supported on the input image service");return e=n(e),this._applyMosaicRule(e),ge(this.url,e,this._getRequestOptions(t))}async measureAreaAndPerimeter(e,t){const i=await this._fetchCapabilities(t?.signal);if(!(i.mensuration.supportsAreaAndPerimeter&&(!e.is3D||i.mensuration.supports3D)))throw new s("imagery-layer:measure-area-and-perimeter","this operation is not supported on the input image service");return e=n(e),this._applyMosaicRule(e),ye(this.url,e,this._getRequestOptions(t))}async measureDistanceAndAngle(e,t){const i=await this._fetchCapabilities(t?.signal);if(!(i.mensuration.supportsDistanceAndAngle&&(!e.is3D||i.mensuration.supports3D)))throw new s("imagery-layer:measure-distance-and-angle","this operation is not supported on the input image service");return e=n(e),this._applyMosaicRule(e),Re(this.url,e,this._getRequestOptions(t))}async measurePointOrCentroid(e,t){const i=await this._fetchCapabilities(t?.signal);if(!(i.mensuration.supportsPointOrCentroid&&(!e.is3D||i.mensuration.supports3D)))throw new s("imagery-layer:measure-point-or-centroid","this operation is not supported on the input image service");return e=n(e),this._applyMosaicRule(e),Ie(this.url,e,this._getRequestOptions(t))}async measureLengthFromImage(e,t){if(!(await this._fetchCapabilities(t?.signal)).operations.supportsMeasureFromImage)throw new s("imagery-layer:measure-length-from-image","this operation is not supported on the input image service");if("polyline"!==e.geometry.type)throw new s("imagery-layer:measure-length-from-image","this input geometry must be a polyline");return ve(this.url,e,this._getRequestOptions(t))}async measureAreaFromImage(e,t){if(!(await this._fetchCapabilities(t?.signal)).operations.supportsMeasureFromImage)throw new s("imagery-layer:measure-area-from-image","this operation is not supported on the input image service");if("polygon"!==e.geometry.type)throw new s("imagery-layer:measure-area-from-image","this input geometry must be a polygon");return we(this.url,e,this._getRequestOptions(t))}getField(e){const{fieldsIndex:t}=this;return null!=t?t.get(e):void 0}getFieldDomain(e,t){const i=this.getField(e);return i?i.domain:null}fetchImage(e,t,i,n={}){if(r(a.getLogger(this),"`ImageryLayer.fetchImage` is deprecated in favor of 'ImageryLayer.fetchPixels'.",{replacement:"ImageryLayer.fetchPixels",version:"4.33",warnOnce:!0}),null==e||null==t||null==i)throw new s("imagery-layer:fetch-image","Insufficient parameters for requesting an image. A valid extent, width and height values are required.");return this.internalFetchImage(e,t,i,n)}async internalFetchImage(e,t,i,r={}){await this._updateCurrentRasterInfo();const{exportImageServiceParameters:s}=this;let n=!1;r.requestRawData&&(await this._initJobHandler(),s.requestRawData||"lerc"===this.format||(n=!0,s.requestRawData=!0));const a=this.getExportImageServiceParameters(e,t,i,r.timeExtent);if(n&&(s.requestRawData=!1),null==a){if(r.requestAsImageElement&&this._canRequestImageElement(this.format)){const e=document.createElement("canvas");if(e.width=t,e.height=i,r.returnImageBitmap){return{imageBitmap:await D(e,`${Ge(this.parsedUrl)}/exportImage`,r.signal)}}return{imageOrCanvasElement:e}}const{bandIds:s,rasterInfo:n}=this,a=(s?.length||n.bandCount)??0,o=t*i,l=n.pixelType,u=[];for(let e=0;e<a;e++)u.push(M.createEmptyBand(l,o));return{pixelData:{pixelBlock:new M({width:t,height:i,pixels:u,mask:new Uint8Array(o),pixelType:l}),extent:e}}}const o=!!r.requestAsImageElement&&!this.pixelFilter,l=o&&!!r.returnImageBitmap,u={imageServiceParameters:a,imageProps:{extent:e,width:t,height:i,format:this.format},requestAsImageElement:o,returnImageBitmap:l,signal:r.signal};return this._requestArrayBuffer(u)}async fetchPixels(e,t,i,r={}){await this._initJobHandler(),r.applyRendering&&this._updateCurrentRasterInfo();const s=r.applyRendering?void 0:new x({layer:this,requestRawData:!0,interpolation:r.interpolation??"nearest",bandIds:r.bandIds??[]}),n=this.getExportImageServiceParameters(e,t,i,r.timeExtent,s);if(null==n)return{extent:e,pixelBlock:null};delete n.pixelType,delete n.bandIds,delete n.compressionQuality;const a={imageServiceParameters:n,imageProps:{extent:e,width:t,height:i,format:this.format},requestAsImageElement:!1,returnImageBitmap:!1,signal:r.signal},{pixelData:o}=await this._requestArrayBuffer(a);return o??{extent:e,pixelBlock:null}}fetchKeyProperties(e){return i(Ge(this.parsedUrl)+"/keyProperties",{query:this._getQueryParams({renderingRule:this.version>=10.3?e?.rasterFunction:null})}).then(e=>e.data)}fetchRasterAttributeTable(e){return this.version<10.1?Promise.reject(new s("#fetchRasterAttributeTable()","Failed to get rasterAttributeTable")):i(Ge(this.parsedUrl)+"/rasterAttributeTable",{query:this._getQueryParams({renderingRule:this.version>=10.3?e?.rasterFunction:null})}).then(e=>Qe.fromJSON(e.data))}getCatalogItemRasterInfo(e,t){const i={...t,query:this._getQueryParams()};return je(Ge(this.parsedUrl),e,i)}async getCatalogItemICSInfo(e,t){const{data:r}=await i(Ge(this.parsedUrl)+"/"+e+"/info/ics",{query:this._getQueryParams(),...t}),s=r?.ics;if(!s)return;let n=null;try{n=(await i(Ge(this.parsedUrl)+"/"+e+"/info",{query:this._getQueryParams(),...t})).data.extent}catch{}if(!n?.spatialReference)return{ics:s,icsToPixelTransform:null,icsExtent:null,northDirection:null};const a=this.version>=10.7?i(Ge(this.parsedUrl)+"/"+e+"/info/icstopixel",{query:this._getQueryParams(),...t}).then(e=>e.data).catch(()=>({})):{},o=n.spatialReference,l={geometries:JSON.stringify({geometryType:"esriGeometryEnvelope",geometries:[n]}),inSR:v(o),outSR:"0:"+e},u=i(Ge(this.parsedUrl)+"/project",{query:this._getQueryParams(l),...t}).then(e=>e.data).catch(()=>({})),p=5,m=(n.xmin+n.xmax)/2,c=(n.ymax-n.ymin)/(p+1),h=n.ymin+c,d=[];for(let i=0;i<p;i++)d.push({x:m,y:h+c*i});const f={geometries:JSON.stringify({geometryType:"esriGeometryPoint",geometries:d}),inSR:v(o),outSR:"0:"+e},g=i(Ge(this.parsedUrl)+"/project",{query:this._getQueryParams(f),...t}).then(e=>e.data).catch(()=>({})),R=await Promise.all([a,u,g]);let w=R[0].ipxf;if(null==w){const e=s.geodataXform?.xf_0;"topup"===e?.name?.toLowerCase()&&6===e?.coefficients?.length&&(w={affine:{name:"ics [sensor: Frame] to pixel (column, row) transformation",coefficients:e.coefficients,cellsizeRatio:0,type:"GeometricXform"}})}const b=y.fromJSON(R[1]?.geometries?.[0]);b&&(b.spatialReference=new I({wkid:0,imageCoordinateSystem:s}));const S=R[2].geometries?R[2].geometries.filter(e=>null!=e?.x&&null!=e.y&&"NaN"!==e.x&&"NaN"!==e.y):[],x=S.length;if(x<3)return{ics:s,icsToPixelTransform:w,icsExtent:b,northDirection:null};let _=0,F=0,D=0,O=0;for(let i=0;i<x;i++)_+=S[i].x,F+=S[i].y,D+=S[i].x*S[i].x,O+=S[i].x*S[i].y;const T=(x*O-_*F)/(x*D-_*_);let C=0;const M=S[p-1].x>S[0].x,P=S[p-1].y>S[0].y;return T===1/0?C=P?90:270:0===T?C=M?0:180:T>0?C=M?180*Math.atan(T)/Math.PI:180*Math.atan(T)/Math.PI+180:T<0&&(C=P?180+180*Math.atan(T)/Math.PI:360+180*Math.atan(T)/Math.PI),{ics:s,icsToPixelTransform:w,icsExtent:b,northDirection:C}}async generateRasterInfo(e,t){e=c(G,e);const i={...t,query:this._getQueryParams()};if(!e||"none"===e.functionName?.toLowerCase()||this._isVectorFieldResampleFunction(e))return this.serviceRasterInfo??Pe(Ge(this.parsedUrl),this.sourceJSON,i);const r=ze(e);if(!r)throw new s("imagery-layer:generate-raster-info","the rendering rule is not supported");if(this._functionRasterInfos[r])return this._functionRasterInfos[r];const n=Ne(Ge(this.parsedUrl),e,i);this._functionRasterInfos[r]=n;try{return await n}catch(a){throw this._functionRasterInfos[r]=null,a}}getExportImageServiceParameters(e,t,i,r,s){e=e.clone().shiftCentralMeridian();const n=be(e.spatialReference,Ge(this.parsedUrl));s??=this.exportImageServiceParameters;const a=s.toJSON(),{bandIds:o,noData:l}=a;let{renderingRule:u}=a;const p=this.rasterFunction?.rasterFunctionDefinition,m=this.renderer?.type,c=!m||"raster-stretch"===m||"raster-colormap"===m||"unique-value"===m||"class-breaks"===m||"raster-shaded-relief"===m;if(o?.length&&this._hasRasterFunction(this.rasterFunction)&&!p&&c){const e={rasterFunction:"ExtractBand",rasterFunctionArguments:{BandIds:o}};if("Stretch"===u.rasterFunction)e.rasterFunctionArguments.Raster=u.rasterFunctionArguments.Raster,u.rasterFunctionArguments.Raster=e;else if("Colormap"===u.rasterFunction){const t=u.rasterFunctionArguments.Raster;"Stretch"===t?.rasterFunction?(e.rasterFunctionArguments.Raster=t.rasterFunctionArguments.Raster,t.rasterFunctionArguments.Raster=e):(e.rasterFunctionArguments.Raster=t,u.rasterFunctionArguments.Raster=e)}else e.rasterFunctionArguments.Raster=u,u=e;a.bandIds=void 0}else a.bandIds=o?.join(",");Array.isArray(l)&&l.length>0&&(a.noData=l.join(","));const h=this._processMultidimensionalIntersection(null,r,s.mosaicRule);if(h.isOutSide)return null;a.mosaicRule=null!=h.mosaicRule?JSON.stringify(h.mosaicRule):null,r=h.timeExtent,a.renderingRule=this._getRenderingRuleString(G.fromJSON(u));const d={};if(null!=r){const{start:e,end:t}=r.toJSON();e&&t&&e===t?d.time=""+e:null==e&&null==t||(d.time=`${e??"null"},${t??"null"}`)}return{bbox:e.xmin+","+e.ymin+","+e.xmax+","+e.ymax,bboxSR:n,imageSR:n,size:t+","+i,...a,...d}}async getSamples(e,t){const i=await this._fetchCapabilities(t?.signal);if(!i?.operations.supportsGetSamples)throw new s("imagery-layer:get-samples","getSamples operation is not supported on the input image service");e=n(e);const{raster:r}=this;return r&&null==e.raster&&(e.raster=r),Se(this.url,e,this._getRequestOptions(t))}async identify(e,t){if(!(await this._fetchCapabilities(t?.signal)).operations.supportsIdentify)throw new s("imagery-layer:identify","identify operation is not supported on the input image service");e=n(e),this.version<10.91&&"extent"===e.geometry?.type&&(e.geometry=R.fromExtent(e.geometry));const i=this._processMultidimensionalIntersection(e.geometry,e.timeExtent,e.mosaicRule||this.mosaicRule);if(i.isOutSide)throw new s("imagery-layer:identify","the request cannot be fulfilled when falling outside of the multidimensional subset");e.timeExtent=i.timeExtent,e.mosaicRule=i.mosaicRule;const{raster:r,rasterFunction:a}=this;return a&&null==e.rasterFunction&&(e.rasterFunction=a),r&&null==e.raster&&(e.raster=r),xe(this.url,e,this._getRequestOptions(t))}async imageToMap(e,t){if(!(await this._fetchCapabilities(t?.signal)).operations.supportsImageToMap)throw new s("imagery-layer:image-to-map","imageToMap operation is not supported on the input image service");return _e(Ge(this.parsedUrl),e,this._getRequestOptions(t))}async imageToMapMultiray(e,t){if(!(await this._fetchCapabilities(t?.signal)).operations.supportsImageToMapMultiray)throw new s("imagery-layer:image-to-map-multiray","imageToMapMultiray operation is not supported on the input image service");return Fe(Ge(this.parsedUrl),e,this._getRequestOptions(t))}async mapToImage(e,t){if(!(await this._fetchCapabilities(t?.signal)).operations.supportsMapToImage)throw new s("imagery-layer:map-to-image","mapToImage operation is not supported on the input image service");return De(Ge(this.parsedUrl),e,this._getRequestOptions(t))}async findImages(e,t){if(!(await this._fetchCapabilities(t?.signal)).operations.supportsFindImages)throw new s("imagery-layer:find-images","findImages operation is not supported on the input image service");return Oe(Ge(this.parsedUrl),e,this._getRequestOptions(t))}async getImageUrl(e,t){if(!(await this._fetchCapabilities(t?.signal)).operations.supportsGetImageUrl)throw new s("imagery-layer:get-image-url","getImageUrl operation is not supported on the input image service");return Te(Ge(this.parsedUrl),e,this._getRequestOptions(t))}createQuery(){return new Ue({outFields:["*"],returnGeometry:!0,where:this.definitionExpression||"1=1"})}async queryBoundary(e,t){if(!(await this._fetchCapabilities(t?.signal)).operations.supportsQueryBoundary)throw new s("imagery-layer:query-boundary","queryBoundary operation is not supported on the input image service");return e=e??{outSpatialReference:this.spatialReference},Ce(Ge(this.parsedUrl),e,this._getRequestOptions(t))}async queryRasters(e,t){return({query:e,requestOptions:t}=await this._prepareForQuery(e,t)),Ve(this.url,e,t)}async queryObjectIds(e,t){return({query:e,requestOptions:t}=await this._prepareForQuery(e,t)),Ee(this.url,e,t)}async queryGPSInfo(e,t){if(!(await this._fetchCapabilities(t?.signal)).operations.supportsQueryGPSInfo)throw new s("imagery-layer:query-gps-info","queryGPSInfo operation is not supported on the input image service");return e=e??{where:"1=1"},Me(Ge(this.parsedUrl),e,this._getRequestOptions(t))}async queryRasterCount(e,t){return({query:e,requestOptions:t}=await this._prepareForQuery(e,t)),Ae(this.url,e,t)}async queryVisibleRasters(e,t){if(!e)throw new s("imagery-layer: query-visible-rasters","missing query parameter");await this.load();const{pixelSize:i,returnDomainValues:r,returnTopmostRaster:n,showNoDataRecords:a}=t||{pixelSize:null,returnDomainValues:!1,returnTopmostRaster:!1,showNoDataRecords:!1};let o=!1,l=null,u=null;const p=L.servicePixelValue.toLowerCase(),m=this._rasterFunctionNamesIndex;if(null!=e.outFields&&(o=e.outFields.some(e=>!e.toLowerCase().startsWith(p)),this.version>=10.4)){const t=e.outFields.filter(e=>e.toLowerCase().startsWith(p)&&e.length>p.length).map(e=>{const t=e.slice(p.length+1);return[this._updateRenderingRulesFunctionName(t,m),t]});l=t.map(e=>new G({functionName:e[0]})),u=t.map(e=>e[1]);const{rasterFunction:i}=this;0===l.length?i?.functionName?(l.push(i),u.push(i.functionName)):l=null:i?.functionName&&!l.some(e=>e.functionName===i.functionName)&&(l.push(i),u.push(i.functionName))}const c=null==e.outSpatialReference||e.outSpatialReference.equals(this.spatialReference),{multidimensionalSubset:h}=this;let d=e.timeExtent||this.timeExtent;if(h){const{isOutside:t,intersection:i}=W(h,{geometry:e.geometry,timeExtent:e.timeExtent,multidimensionalDefinition:this.exportImageServiceParameters.mosaicRule?.multidimensionalDefinition});if(t)throw new s("imagery-layer:query-visible-rasters","the request cannot be fulfilled when falling outside of the multidimensional subset");null!=i?.timeExtent&&(d=i.timeExtent)}const f=this._combineMosaicRuleWithTimeExtent(this.exportImageServiceParameters.mosaicRule,d);let g=e.geometry;this.version<10.91&&"extent"===g?.type&&(g=R.fromExtent(g));const y=this._getQueryParams({geometry:g,timeExtent:d,mosaicRule:f,rasterFunction:this.version<10.4?this.rasterFunction:null,rasterFunctions:l,pixelSize:i,returnCatalogItems:o,returnGeometry:c,raster:this.raster,maxItemCount:n?1:null});delete y.f;const I=new Je(y);try{await this._generateRasterInfo(this.rasterFunction);const i=await xe(this.url,I,{signal:t?.signal,query:{...this.customParameters}}),s=e.outFields,n=null!=i.value&&i.value.toLowerCase().includes("nodata"),l=o&&!c&&i?.catalogItems?.features.length&&(a||!n),p=this.multidimensionalInfo&&"raster-dataset"===this.sourceType?$({rasterInfo:this.rasterInfo,multidimensionalDefinition:f?.multidimensionalDefinition,timeExtent:d,multidimensionalSubset:this.multidimensionalSubset}):null;if(!l)return this._processVisibleRastersResponse(i,{returnDomainValues:r,templateRRFunctionNames:u,showNoDataRecords:a,templateFields:s,effectiveMultidimensionalDefinition:p});const m=this.objectIdField||"ObjectId",h=i.catalogItems?.features??[],g=h.map(e=>e.attributes?.[m]),y=new Ue({objectIds:g,returnGeometry:!0,outSpatialReference:e.outSpatialReference,outFields:[m]}),R=await this.queryRasters(y);return R?.features?.length&&R.features.forEach(t=>{h.forEach(i=>{i.attributes[m]===t.attributes[m]&&t.geometry&&(i.geometry=t.geometry.clone(),null!=e.outSpatialReference&&(i.geometry.spatialReference=e.outSpatialReference))})}),this._processVisibleRastersResponse(i,{returnDomainValues:r,templateRRFunctionNames:u,showNoDataRecords:a,templateFields:s,effectiveMultidimensionalDefinition:p})}catch{throw new s("imagery-layer:query-visible-rasters","encountered error when querying visible rasters")}}async fetchVariableStatisticsHistograms(e,t){const r=i(Ge(this.parsedUrl)+"/statistics",{query:this._getQueryParams({variable:e}),signal:t}).then(e=>e.data?.statistics),s=i(Ge(this.parsedUrl)+"/histograms",{query:this._getQueryParams({variable:e}),signal:t}).then(e=>e.data?.histograms),n=await Promise.all([r,s]);return n[0]&&n[0].forEach(e=>{e.avg=e.mean,e.stddev=e.standardDeviation}),{statistics:n[0]||null,histograms:n[1]||null}}getMultidimensionalSubsetVariables(e){const t=e??this.serviceRasterInfo.multidimensionalInfo;return X(this.multidimensionalSubset,t)}async _fetchService(e){await this._fetchServiceInfo(e),this.rasterInfo||(this.rasterInfo=this.serviceRasterInfo);const t=this.sourceJSON,i=null!=this.serviceRasterInfo?Promise.resolve(this.serviceRasterInfo):Pe(Ge(this.parsedUrl),t,{signal:e,query:this._getQueryParams()}).then(e=>(this._set("serviceRasterInfo",e),this._set("multidimensionalInfo",e.multidimensionalInfo),qe(e,t),e)),r=this._hasRasterFunction(this.rasterFunction)?this._generateRasterInfo(this.rasterFunction,{signal:e}):null,s=this._getRasterFunctionInfos();return Promise.all([i,r,s]).then(e=>{e[1]?this._set("rasterInfo",e[1]):this._set("rasterInfo",e[0]),e[2]&&this._set("rasterFunctionInfos",e[2]),this.internalRenderer&&!this._isSupportedRenderer(this.internalRenderer)&&(this._set("internalRenderer",null),a.getLogger(this).warn("ArcGISImageService","Switching to the default renderer. Renderer applied is not valid for this Imagery Layer")),this._set("internalRenderer",this._configRenderer(this.renderer)),this.addHandles([o(()=>this.rasterFunction,e=>{(this.renderer||this.symbolizer||this.popupEnabled&&this.popupTemplate)&&this._generateRasterInfo(e).then(e=>{e&&(this.rasterInfo=e)})})]);const{serviceRasterInfo:t}=this;null!=t.multidimensionalInfo&&this._updateMultidimensionalDefinition(t)})}_combineMosaicRuleWithTimeExtent(e,t){const i=this.timeInfo,{multidimensionalInfo:r}=this.serviceRasterInfo;if(null==e||null==r||null==t||null==i?.startField)return e;const{startField:s}=i,n=r.variables.some(e=>e.dimensions.some(e=>e.name===s))?s:"StdTime";if(e=e.clone(),"mosaic-dataset"===this.sourceType)return e.multidimensionalDefinition=e.multidimensionalDefinition?.filter(e=>e.dimensionName!==n),this._cleanupMultidimensionalDefinition(e);e.multidimensionalDefinition=e.multidimensionalDefinition||[];const a=e.multidimensionalDefinition.filter(e=>e.dimensionName===n),o=null!=t.start?t.start.getTime():null,l=null!=t.end?t.end.getTime():null,u=null==o||null==l||o===l,p=u?[o||l]:[[o,l]],m=this.version>=10.8;if(a.length)a.forEach(e=>{e.dimensionName===n&&(m?(e.dimensionName=null,e.isSlice=!1,e.values=[]):(e.isSlice=u,e.values=p))});else if(!m){const t=e.multidimensionalDefinition.filter(e=>null!=e.variableName&&null==e.dimensionName);t.length?t.forEach(e=>{e.dimensionName=n,e.isSlice=u,e.values=p}):e.multidimensionalDefinition.push(new S({variableName:"",dimensionName:n,isSlice:u,values:p}))}return this._cleanupMultidimensionalDefinition(e)}_cleanupMultidimensionalDefinition(e){return null==e?null:(e.multidimensionalDefinition&&(e.multidimensionalDefinition=e.multidimensionalDefinition.filter(e=>!(!e.variableName&&!e.dimensionName)),0===e.multidimensionalDefinition.length&&(e.multidimensionalDefinition=null)),"mosaic-dataset"!==this.sourceType&&null==e.multidimensionalDefinition?null:e)}async _prepareForQuery(e,t){if(!(await this._fetchCapabilities(t?.signal)).operations.supportsQuery)throw new s("imagery-layer:query-rasters","query operation is not supported on the input image service");return e=null!=e?c(Ue,e):this.createQuery(),t=this._getRequestOptions(t),this.raster&&(t.query={...t.query,raster:this.raster}),{query:e,requestOptions:t}}_isSupportedRenderer(e){const{rasterInfo:t,rasterFunction:i}=this;return"unique-value"===e.type&&this._hasRasterFunction(i)&&1===t?.bandCount&&["u8","s8"].includes(t.pixelType)||null!=t&&null!=e&&re(t).includes(e.type)}async _fetchCapabilities(e){return this.capabilities||await this._fetchServiceInfo(e),this.capabilities}async _fetchServiceInfo(e){let t=this.sourceJSON;if(!t){const{data:r,ssl:s}=await i(Ge(this.parsedUrl),{query:this._getQueryParams(),signal:e});t=r,this.sourceJSON=t,s&&(this.url=this.url.replace(/^http:/i,"https:"))}if(t.capabilities?.toLowerCase().split(",").map(e=>e.trim()).indexOf("tilesonly")>-1)throw new s("imagery-layer:fetch-service-info","use ImageryTileLayer to open tiles-only image services");this.read(t,{origin:"service",url:this.parsedUrl})}_isMosaicDataset(e){return e.serviceSourceType?"esriImageServiceSourceTypeMosaicDataset"===e.serviceSourceType:e.fields?.length>0}_isMosaicRuleSupported(e){if(!e)return!1;const t=this._isMosaicDataset(e),i=e.currentVersion>=10.71&&e.hasMultidimensions&&!(e.fields?.length>1);return t||i}_isVectorFieldResampleFunction(e){if(null==e)return!1;const{functionName:t,functionArguments:i}=e,r="resample"===t?.toLowerCase(),s=i?.ResampleType||i?.resampleType;return r&&(7===s||10===s)}_isPicture(){return!this.format||this.format.includes("jpg")||this.format.includes("png")}_configRenderer(e){const t=this._isPicture(),{rasterInfo:i}=this;if(!t&&!this.pixelFilter||this._isVectorDataSet()){const t=this.mosaicRule?.multidimensionalDefinition?.[0].variableName,r=se({variableName:t,rasterFunctionName:this.rasterFunction?.functionName,presetRenderers:this.presetRenderers});if(!this.bandIds&&i.bandCount>=3){const e=r?.bandIds??ne(i);!e||3===i.bandCount&&0===e[0]&&1===e[1]&&2===e[2]||(this.bandIds=e)}e||(e=r?.renderer??ie(i,{bandIds:this.bandIds,variableName:this.rasterFunction?null:t}));const s=ae(e.toJSON());this.symbolizer?(this.symbolizer.rendererJSON=s,this.symbolizer.rasterInfo=i):this.symbolizer=new oe({rendererJSON:s,rasterInfo:i}),this.symbolizer.bind().success||(this.symbolizer=null)}return e}_clonePixelData(e){return null==e?e:{extent:e.extent&&e.extent.clone(),pixelBlock:null!=e.pixelBlock?e.pixelBlock.clone():null}}_getQueryParams(e){null!=e?.renderingRule&&"string"!=typeof e.renderingRule&&(e.renderingRule=this._getRenderingRuleString(e.renderingRule));const{raster:t,viewId:i}=this;return{raster:t,viewId:i,f:"json",...e,...this.customParameters}}_getRequestOptions(e){return{...e,query:{...e?.query,...this.customParameters}}}_decodePixelBlock(e,t,i){return this._rasterJobHandler?this._rasterJobHandler.decode({data:e,options:t}):Y(e,t,i)}async _getRasterFunctionInfos(e){const t=this.sourceJSON.rasterFunctionInfos;if(this.loaded)return t;if(t&&this.version>=10.3){if(1===t.length&&"none"===t[0].name.toLowerCase())return t;const r=await i(Ge(this.parsedUrl)+"/rasterFunctionInfos",{query:this._getQueryParams(),signal:e});return r.data?.rasterFunctionInfos}return null}_canRequestImageElement(e){return!this.pixelFilter&&(!e||e.includes("png"))}async _requestArrayBuffer(e){const{imageProps:t,requestAsImageElement:r,returnImageBitmap:n,signal:a}=e;if(r&&this._canRequestImageElement(t.format)){const r=`${Ge(this.parsedUrl)}/exportImage`,{data:s}=await i(r,{responseType:n?"blob":"image",query:this._getQueryParams({f:"image",...this.refreshParameters,...e.imageServiceParameters}),signal:a});if(s instanceof Blob){return{imageBitmap:await D(s,r,a),params:t}}return{imageOrCanvasElement:s,params:t}}const o=this._initJobHandler(),l=i(Ge(this.parsedUrl)+"/exportImage",{responseType:"array-buffer",query:this._getQueryParams({f:"image",...e.imageServiceParameters}),signal:a}),u=(await Promise.all([l,o]))[0].data,p=t.format||"jpgpng";let m=p;if("bsq"!==m&&"bip"!==m&&(m=Z(u)),!m)throw new s("imagery-layer:fetch-image","unsupported format signature "+String.fromCharCode.apply(null,new Uint8Array(u)));const c={signal:a},h="gif"===p||"bmp"===p||p.includes("png")&&("png"===m||"jpg"===m)?Y(u,{useCanvas:!0,...t},c):this._decodePixelBlock(u,{width:t.width,height:t.height,planes:null,pixelType:null,noDataValue:null,format:p},c);return{pixelData:{pixelBlock:await h,extent:t.extent},params:t}}_generateRasterInfo(e,t){return this.generateRasterInfo(e,t).catch(()=>null)}_isValidCustomizedMosaicRule(e){return e&&JSON.stringify(e.toJSON())!==JSON.stringify(this.defaultMosaicRule?.toJSON())}_updateMultidimensionalDefinition(e){if(this._isValidCustomizedMosaicRule(this.mosaicRule))return;let t=K(e,{multidimensionalSubset:this.multidimensionalSubset});if(null!=t&&t.length>0){this.mosaicRule=this.mosaicRule||new T;const e=this.mosaicRule.multidimensionalDefinition;!this.sourceJSON.defaultVariableName&&this.rasterFunction&&"none"!==this.rasterFunction.functionName?.toLowerCase()&&t.forEach(e=>e.variableName=""),t=t.filter(({variableName:e,dimensionName:t})=>e&&"*"!==e||t),!e?.length&&t.length&&(this.mosaicRule.multidimensionalDefinition=t)}}_processVisibleRastersResponse(e,i){i=i||{};const r=e.value,{templateRRFunctionNames:s,showNoDataRecords:n,returnDomainValues:a,templateFields:o}=i,l=e.processedValues;let u=e.catalogItems?.features,p=e.properties?.Values?.map(e=>e.replaceAll(/ /gi,", "))||[];const m=this.objectIdField||"ObjectId",c="string"==typeof r&&r.toLowerCase().includes("nodata"),h=[];if(r&&!u&&(!c||n)){const e={};e[m]=0;p=[r],u=[new t({geometry:this.fullExtent,attributes:e})],this.multidimensionalInfo&&"raster-dataset"===this.sourceType&&z(this.rasterFields,e,i.effectiveMultidimensionalDefinition)}if(!u)return[];this._updateResponseFieldNames(u,o),c&&!n&&(u=[]);const{itemPixelValue:d,servicePixelValue:f}=L,g=this.rasterFields.some(e=>e.name===d),y=this.graphicOrigin;for(let t=0;t<u.length;t++){const e=u[t];if(null!=r){const i=p[t],a=this.rasterFunction&&l&&l.length>0&&s&&s.length>0&&s.includes(this.rasterFunction.functionName)?l[s.indexOf(this.rasterFunction.functionName)]:r;if("nodata"===i.toLowerCase()&&!n)continue;g&&(e.attributes[d]=i),e.attributes[f]=a,this._updateFeatureWithMagDirValues(e,i);const o=this.fields&&this.fields.length>0;let u=this.rasterFunction&&null!=this.serviceRasterInfo.attributeTable?o?i:r:a;this.rasterFunction||(u=o?i:r),this._updateFeatureWithRasterAttributeTableValues(e,u)}if(e.sourceLayer=e.layer=this,e.origin=y,a&&this._updateFeatureWithDomainValues(e),s&&l&&s.length===l.length)for(let t=0;t<s.length;t++){const i=`${L.servicePixelValue}.${s[t]}`;e.attributes[i]=l[t]}h.push(u[t])}return h}_processMultidimensionalIntersection(e,t,i){const{multidimensionalSubset:r}=this;if(!r)return{isOutSide:!1,timeExtent:t,mosaicRule:i=this._combineMosaicRuleWithTimeExtent(i,t)};if(r){const{isOutside:i,intersection:s}=W(r,{geometry:e,timeExtent:t});if(i)return{isOutSide:!0,timeExtent:null,mosaicRule:null};null!=s?.timeExtent&&(t=s.timeExtent)}if(i=this._combineMosaicRuleWithTimeExtent(i,t),i?.multidimensionalDefinition){const{isOutside:e}=W(r,{multidimensionalDefinition:i.multidimensionalDefinition});if(e)return{isOutSide:!0,timeExtent:null,mosaicRule:null}}return{isOutSide:!1,timeExtent:t,mosaicRule:i}}_updateFeatureWithRasterAttributeTableValues(e,t){const i=this.rasterInfo.attributeTable||this.serviceRasterInfo.attributeTable;if(null==i)return;const{features:r,fields:s}=i,n=s.map(e=>e.name).find(e=>"value"===e.toLowerCase());if(!n)return;const a=r.filter(e=>e.attributes[n]===(null!=t?parseInt(t,10):null));a&&a[0]&&s.forEach(t=>{const i=H+t.name;e.attributes[i]=a[0].attributes[t.name]})}_updateFeatureWithMagDirValues(e,t){if(!this._isVectorDataSet())return;const i=t.split(/,\s*/).map(e=>parseFloat(e)),r=i.map(e=>[e]),s=i.map(e=>({minValue:e,maxValue:e,noDataValue:null})),n=new M({height:1,width:1,pixelType:"f32",pixels:r,statistics:s});null!=this.pixelFilter&&this.pixelFilter({pixelBlock:n,extent:new y(0,0,0,0,this.spatialReference)});const a="esriImageServiceDataTypeVector-MagDir"===this.serviceDataType?[n.pixels[0][0],n.pixels[1][0]]:te([n.pixels[0][0],n.pixels[1][0]]);e.attributes[L.magnitude]=a[0],e.attributes[L.direction]=a[1]}_updateFeatureWithDomainValues(e){const t=this.fields&&this.fields.filter(e=>e.domain&&"coded-value"===e.domain.type);null!=t&&t.forEach(t=>{const i=e.attributes[t.name];if(null!=i){const r=t.domain.codedValues.find(e=>e.code===i);r&&(e.attributes[t.name]=r.name)}})}_updateResponseFieldNames(e,t){if(!t||t.length<1)return;const i=this.fieldsIndex;null!=i&&e.forEach(e=>{if(e?.attributes)for(const r of t){const t=i.get(r)?.name;t&&t!==r&&(e.attributes[r]=e.attributes[t],delete e.attributes[t])}})}_getRenderingRuleString(e){if(e){let t=e.toJSON();return t=t.rasterFunctionDefinition??t,(t.thumbnail||t.thumbnailEx)&&(t.thumbnail=t.thumbnailEx=null),JSON.stringify(t)}return null}_hasRasterFunction(e){return null!=e?.functionName&&"none"!==e.functionName.toLowerCase()}_updateRenderingRulesFunctionName(e,t){if(!e||e.length<1)return;if("Raw"===e)return e.replace("Raw","None");const i=e.toLowerCase().replaceAll(/ /gi,"_");return t.has(i)?t.get(i):e}_isRFTJson(e){return e?.name&&e.arguments&&e.function&&e.hasOwnProperty("functionType")}_isVectorDataSet(){return"esriImageServiceDataTypeVector-UV"===this.serviceDataType||"esriImageServiceDataTypeVector-MagDir"===this.serviceDataType}_applyMosaicAndRenderingRules(e){const{raster:t,mosaicRule:i,rasterFunction:r}=this;r&&null==e.rasterFunction&&(e.rasterFunction=r),i&&null==e.mosaicRule&&(e.mosaicRule=i),t&&null==e.raster&&(e.raster=t)}async _updateCurrentRasterInfo(e){if(this.renderer||this.symbolizer){const t=await this._generateRasterInfo(this.rasterFunction,{signal:e});t&&(this.rasterInfo=t)}}_applyMosaicRule(e){const{raster:t,mosaicRule:i}=this;i&&null==e.mosaicRule&&(e.mosaicRule=i),t&&null==e.raster&&(e.raster=t)}_readCapabilities(e){const t=e.capabilities?e.capabilities.toLowerCase().split(",").map(e=>e.trim()):["image","catalog"],{currentVersion:i,maxRecordCount:r}=e,s=t.includes("image"),n="esriImageServiceDataTypeElevation"===e.serviceDataType,a=!(!e.spatialReference&&!e.extent?.spatialReference),o=t.includes("edit"),l=t.includes("mensuration")&&a,u=null==e.mensurationCapabilities?[]:e.mensurationCapabilities.toLowerCase().split(",").map(e=>e.trim()),p=l&&u.includes("basic"),m=this._isMosaicDataset(e)&&t.includes("catalog"),c=t.includes("download"),h=i>=10.7&&n||i>=11.4&&(n||l&&u.includes("3d")),d=m&&e.fields&&e.fields.length>0,f=d&&e.supportsAdvancedQueries?e.advancedQueryCapabilities:void 0;return{data:{supportsAttachment:!1},operations:{supportsComputeHistograms:s,supportsExportImage:s,supportsIdentify:s,supportsImageToMap:i>=11.2&&m,supportsImageToMapMultiray:i>=11.2&&m,supportsMapToImage:i>=11.2&&m,supportsFindImages:i>=11.2&&m,supportsGetImageUrl:i>=11.3&&c,supportsMeasure:l,supportsMeasureFromImage:i>=11.2,supportsDownload:c,supportsQuery:d,supportsGetSamples:i>=10.2&&s,supportsProject:i>=10.3&&s,supportsComputeStatisticsHistograms:i>=10.4&&s,supportsQueryBoundary:i>=10.6&&s,supportsCalculateVolume:h,supportsComputePixelLocation:i>=10.7&&m,supportsComputeAngles:i>=10.91,supportsQueryGPSInfo:i>=11.2&&m,supportsAdd:o,supportsDelete:o,supportsEditing:o,supportsUpdate:o,supportsCalculate:!1,supportsTruncate:!1,supportsValidateSql:!1,supportsChangeTracking:!1,supportsQueryAttachments:!1,supportsResizeAttachments:!1,supportsSync:!1,supportsExceedsLimitStatistics:!1,supportsQueryAnalytics:!1,supportsQueryBins:!1,supportsQueryTopFeatures:!1,supportsAsyncConvert3D:!1},query:{maxRecordCount:r,maxRecordCountFactor:void 0,maxUniqueIDCount:void 0,supportsStatistics:!!f?.supportsStatistics,supportsOrderBy:!!f?.supportsOrderBy,supportsDistinct:!!f?.supportsDistinct,supportsPagination:!!f?.supportsPagination,supportsPaginationOnAggregatedQueries:!!f?.supportsPaginationOnAggregatedQueries,supportsStandardizedQueriesOnly:!!f?.useStandardizedQueries,supportsPercentileStatistics:!!f?.supportsPercentileStatistics,supportsCentroid:!!f?.supportsReturningGeometryCentroid,supportsCentroidOnDegeneratedQuantizedGeometry:!1,supportsCurrentUser:!1,supportsDegeneratedQuantizedGeometry:!1,supportsDistance:!!f?.supportsQueryWithDistance,supportsExtent:!!f?.supportsReturningQueryExtent,supportsGeometryProperties:!!f?.supportsReturningGeometryProperties,supportsHavingClause:!!f?.supportsHavingClause,supportsQuantization:!1,supportsQuantizationEditMode:!1,supportsQueryGeometry:!1,supportsResultType:!1,supportsReturnMesh:!1,supportsMaxRecordCountFactor:!1,supportsSqlExpression:f?.supportsSqlExpression??!!f,supportsTopFeaturesQuery:!1,supportsQueryByAnonymous:!1,supportsQueryByOthers:!1,supportsHistoricMoment:!1,supportsFormatPBF:!1,supportsDisjointSpatialRelationship:!1,supportsCacheHint:!1,supportsSpatialAggregationStatistics:!1,supportedSpatialAggregationStatistics:{envelope:!1,centroid:!1,convexHull:!1},supportsDefaultSpatialReference:!!f?.supportsDefaultSR,supportsFullTextSearch:!1,supportsCompactGeometry:!1,standardMaxRecordCount:void 0,tileMaxRecordCount:void 0,supportsTrueCurve:!1},mensuration:{supportsDistanceAndAngle:p,supportsAreaAndPerimeter:p,supportsPointOrCentroid:p,supportsHeightFromBaseAndTop:l&&u.includes("base-top height"),supportsHeightFromBaseAndTopShadow:l&&u.includes("base-top shadow height"),supportsHeightFromTopAndTopShadow:l&&u.includes("top-top shadow height"),supports3D:l&&u.includes("3d")}}}};function Ge(e){return e?.path??""}return e([u({clonable:!1})],He.prototype,"_functionRasterInfos",void 0),e([u({readOnly:!0})],He.prototype,"_serviceSupportsMosaicRule",void 0),e([d("_serviceSupportsMosaicRule",["currentVersion","fields"])],He.prototype,"readServiceSupportsMosaicRule",null),e([u({readOnly:!0})],He.prototype,"_rasterFunctionNamesIndex",null),e([u()],He.prototype,"adjustAspectRatio",void 0),e([u({type:[p],json:{write:!0}})],He.prototype,"bandIds",void 0),e([d("bandIds")],He.prototype,"readBandIds",null),e([u({readOnly:!0,json:{read:!1}})],He.prototype,"capabilities",void 0),e([d("service","capabilities",["capabilities","currentVersion","serviceDataType"])],He.prototype,"readCapabilities",null),e([u({type:Number})],He.prototype,"compressionQuality",void 0),e([g("compressionQuality")],He.prototype,"writeCompressionQuality",null),e([u({type:Number})],He.prototype,"compressionTolerance",void 0),e([g("compressionTolerance")],He.prototype,"writeCompressionTolerance",null),e([u({json:{read:{source:"copyrightText"}}})],He.prototype,"copyright",void 0),e([u({readOnly:!0,dependsOn:["_serviceSupportsMosaicRule"]})],He.prototype,"defaultMosaicRule",void 0),e([d("defaultMosaicRule",["defaultMosaicMethod"])],He.prototype,"readDefaultMosaicRule",null),e([u({type:String,json:{name:"layerDefinition.definitionExpression",write:{enabled:!0,allowNull:!0}}})],He.prototype,"definitionExpression",void 0),e([u({readOnly:!0,constructOnly:!0})],He.prototype,"exportImageServiceParameters",void 0),e([u()],He.prototype,"rasterInfo",void 0),e([u({readOnly:!0,type:[_]})],He.prototype,"fields",void 0),e([u({readOnly:!0})],He.prototype,"fieldsIndex",null),e([u({type:["png","png8","png24","png32","jpg","bmp","gif","jpgpng","lerc","tiff","bip","bsq"],json:{write:!0}})],He.prototype,"format",null),e([d("service","format",["serviceDataType"])],He.prototype,"readFormat",null),e([u({type:y})],He.prototype,"fullExtent",void 0),e([u({readOnly:!0})],He.prototype,"hasMultidimensions",void 0),e([u({json:{read:{source:"maxImageHeight"}}})],He.prototype,"imageMaxHeight",void 0),e([u({json:{read:{source:"maxImageWidth"}}})],He.prototype,"imageMaxWidth",void 0),e([u({type:String,json:{type:P.jsonValues,read:P.read,write:P.write}})],He.prototype,"interpolation",void 0),e([u()],He.prototype,"minScale",void 0),e([d("service","minScale")],He.prototype,"readMinScale",null),e([u()],He.prototype,"maxScale",void 0),e([d("service","maxScale")],He.prototype,"readMaxScale",null),e([u({type:T})],He.prototype,"mosaicRule",null),e([d("mosaicRule",["mosaicRule","defaultMosaicMethod"])],He.prototype,"readMosaicRule",null),e([g("mosaicRule")],He.prototype,"writeMosaicRule",null),e([u()],He.prototype,"multidimensionalInfo",void 0),e([u({type:C,json:{write:!0}})],He.prototype,"multidimensionalSubset",void 0),e([u({json:{type:p}})],He.prototype,"noData",void 0),e([g("noData")],He.prototype,"writeNoData",null),e([u({type:String,json:{type:N.jsonValues,read:N.read,write:N.write}})],He.prototype,"noDataInterpretation",void 0),e([u({type:String,readOnly:!0,json:{read:{source:["fields"]}}})],He.prototype,"objectIdField",void 0),e([d("objectIdField")],He.prototype,"readObjectIdField",null),e([u({readOnly:!0})],He.prototype,"geometryType",void 0),e([u({})],He.prototype,"typeIdField",void 0),e([u({})],He.prototype,"types",void 0),e([u({readOnly:!0})],He.prototype,"parsedUrl",null),e([u({type:Function})],He.prototype,"pixelFilter",void 0),e([u()],He.prototype,"raster",void 0),e([u({readOnly:!0})],He.prototype,"sourceType",void 0),e([d("sourceType",["serviceSourceType","fields"])],He.prototype,"readSourceType",null),e([u()],He.prototype,"viewId",void 0),e([u()],He.prototype,"renderer",null),e([u({types:ue,json:{name:"layerDefinition.drawingInfo.renderer",origins:{"web-scene":{types:le,name:"layerDefinition.drawingInfo.renderer",write:{overridePolicy:e=>({enabled:e&&"vector-field"!==e.type})}}}}})],He.prototype,"internalRenderer",null),e([d("internalRenderer")],He.prototype,"readRenderer",null),e([g("internalRenderer")],He.prototype,"writeRenderer",null),e([u({clonable:!1})],He.prototype,"symbolizer",void 0),e([u(w)],He.prototype,"opacity",void 0),e([u({readOnly:!0})],He.prototype,"rasterFields",null),e([u({constructOnly:!0})],He.prototype,"rasterFunctionInfos",void 0),e([u({type:G,json:{name:"renderingRule"}})],He.prototype,"rasterFunction",null),e([d("rasterFunction",["renderingRule","rasterFunctionInfos"])],He.prototype,"readRasterFunction",null),e([u({readOnly:!0})],He.prototype,"serviceDataType",void 0),e([u({readOnly:!0,type:I})],He.prototype,"spatialReference",void 0),e([d("spatialReference",["spatialReference","extent"])],He.prototype,"readSpatialReference",null),e([u({type:q.apiValues,json:{read:q.read,type:q.jsonValues}})],He.prototype,"pixelType",void 0),e([g("pixelType")],He.prototype,"writePixelType",null),e([u({constructOnly:!0,type:k})],He.prototype,"serviceRasterInfo",void 0),e([u()],He.prototype,"sourceJSON",void 0),e([u(b)],He.prototype,"url",void 0),e([u({readOnly:!0})],He.prototype,"version",void 0),e([d("version",["currentVersion","fields","timeInfo"])],He.prototype,"readVersion",null),He=e([f("esri.layers.mixins.ArcGISImageService")],He),He};export{He as ArcGISImageService};
|
|
@@ -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{throwIfAborted as e}from"../../../core/promiseUtils.js";import{create as t}from"../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{zeros as
|
|
5
|
+
import{throwIfAborted as e}from"../../../core/promiseUtils.js";import{create as t}from"../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{zeros as n}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{transpose as r}from"../../../core/libs/gl-matrix-2/math/mat3.js";import{a,f as o}from"../../../chunks/vec32.js";import i from"../../../geometry/Circle.js";import c from"../../../geometry/Mesh.js";import s from"../../../geometry/Multipoint.js";import f from"../../../geometry/Polygon.js";import{projectWithZConversion as l}from"../../../geometry/projectionUtils.js";import m from"../../../geometry/SpatialReference.js";import{earth as u}from"../../../geometry/support/Ellipsoid.js";import p from"../../../geometry/support/MeshComponent.js";import{MeshVertexAttributes as h}from"../../../geometry/support/MeshVertexAttributes.js";import{create as y,fromArray as g,intersectRay as x}from"../../../geometry/support/plane.js";import{isWebMercator as d}from"../../../geometry/support/spatialReferenceUtils.js";import{convertToSRUnits as w,getWebMercatorScalingFactor as M,createRotationMatrixFromHPR as R,transformMat3 as j,scaleAndAddWithFactor as v,scaleWithFactor as P,computeHFOVAndVFOV as D,projectiveTransform as b}from"../transformations/utils.js";const A=Math.PI/180;function I(e){const t=w(e,e.geometry.spatialReference);return e.isSpherical?O(t):z(t)}function z(e){const{horizontalFieldOfView:t,verticalFieldOfView:n,geometry:r,cameraHeading:a}=e,o=M(r.y,r.spatialReference);let i=e.cameraPitch,c=e.cameraRoll??0,s=150;t>150&&(i=90,c=0,s=5);const l=Math.ceil(t/s),m=V(l,a,t);let u=e.farDistance?e.farDistance*o:e.cameraHeight*o/Math.cos(i*A);e.cameraPitch+n/2>=90&&(u=(e.farDistance||20)*o);const p=new f({spatialReference:r?.spatialReference});p.imageID=e.objectId;let h=null;for(const f of m)h=F(f,i,e.cameraHeight,r,u,o,n,t,l,p,c,e.nearDistance);return h.imageID=e.objectId,{polygon:p,frustum:h}}function V(e,t,n){const r=[];if(e%2==0)for(let a=0;a<e/2;a++)r.push(t-n/e*(a+.5),t+n/e*(a+.5));else{r.push(t);for(let a=1;a<e/2;a++)r.push(t-n/e*a,t+n/e*a)}return r.sort(),r}function F(e,i,c,s,f,l,m,u,p,h,y=0,g=0){const x=r(t(),R([e,i,y??0])),d=C({cameraHeight:c,cameraPitch:i,farDistance:f,location:s,horizontalFieldOfView:u,nearDistance:g,verticalFieldOfView:m},x),w=j([0,0,-1],x),{x:M,y:D}=s,b=v([M,D,c],w,f,l),I=2*Math.tan(m*A/2)*f,z=2*Math.tan(u/p*A/2)*f,V=j([0,1,0],x),F=j([1,0,0],x),O=P(V,I/2,l),S=P(F,z/2,l),q=a(n(),O,S),U=o(n(),O,S),E=H([o(n(),b,q),o(n(),b,U),a(n(),b,q),a(n(),b,U)],c,s,l);return E.push(E[0]),h.addRing(E),d}function H(e,t,n,r){return e.map(e=>U(e,t,n,r))}function O(e){const{geometry:t,farDistance:n,objectId:r,nearDistance:a,cameraHeight:o}=e,s=M(t.y,t.spatialReference),f=new i({center:t.clone(),radius:n*s});if(f.imageID=r,a){const e=new i({center:t.clone(),radius:a*s});f.addRing(e.rings[0])}const l=t.clone();l.z=o-n*s;const m=c.createSphere(l,{size:2*n*s});return m.imageID=r,{polygon:f,frustum:m}}function S(e,t){return e.contains(t)}function q(e,t){return Math.sign(e)!==Math.sign(t)}function C(e,t,r){const{cameraHeight:i,cameraPitch:s,farDistance:f,location:l,horizontalFieldOfView:m,nearDistance:u,verticalFieldOfView:p}=e,y=k(l),g=s+p/2>=90==!1,x=2*Math.tan(p*A/2)*u,d=2*Math.tan(m*A/2)*u,w=2*Math.tan(p*A/2)*f,M=2*Math.tan(m*A/2)*f;let R,D;D=[0,0,-1],D=j(D,t),R=v([l.x,l.y,i],D,f,y),g&&(R[2]=0);const b=v([l.x,l.y,i],D,u,y);let I=[0,1,0];I=j(I,t);let z=[1,0,0];z=j(z,t);let V=[],F=[];u?(F=[{faces:[4,0,3,4,7,3]},{faces:[5,1,2,5,6,2]},{faces:[4,0,1,4,5,1]},{faces:[6,2,3,6,7,3]}],V=V.concat(o(n(),b,a(n(),P(I,x/2,y),P(z,d/2,y)))),V=V.concat(o(n(),b,o(n(),P(I,x/2,y),P(z,d/2,y)))),V=V.concat(a(n(),b,a(n(),P(I,x/2,y),P(z,d/2,y)))),V=V.concat(a(n(),b,o(n(),P(I,x/2,y),P(z,d/2,y))))):(V=[l.x,l.y,i],F=[{faces:[0,1,2,0,2,3,0,3,4,0,4,1]}]),V=V.concat(o(n(),R,a(n(),P(I,w/2,y),P(z,M/2,y)))),V=V.concat(o(n(),R,o(n(),P(I,w/2,y),P(z,M/2,y)))),V=V.concat(a(n(),R,a(n(),P(I,w/2,y),P(z,M/2,y)))),V=V.concat(a(n(),R,o(n(),P(I,w/2,y),P(z,M/2,y))));const H=new h({position:Float64Array.from(V)});return new c({vertexAttributes:H,components:F,spatialReference:l.spatialReference})}function U(e,t,r,o){{const i=Math.sqrt((e[2]-t)**2+(Math.sqrt((e[0]-r.x)**2+(e[1]-r.y)**2)/o)**2)*o,c=P(a(n(),[e[0],e[1],e[2]],[r.x,r.y,t]),1/i,1/o),s=t/(t-e[2]),f={x:(1-s)*r.x+s*e[0],y:(1-s)*r.y+s*e[1],z:(1-s)*t+s*e[2]},l=Math.sqrt((f.z-t)**2+(Math.sqrt((f.x-r.x)**2+(f.y-r.y)**2)/o)**2)*o,m=P(a(n(),[f.x,f.y,f.z],[r.x,r.y,t]),1/l,1/o);return q(c[0],m[0])&&q(c[1],m[1])&&q(c[2],m[2])||e[2]>=0?[e[0],e[1],0]:[f.x,f.y,f.z]}}function E(e){const{spatialReference:t,x:n,y:r}=e.geometry,{cameraHeading:a,cameraPitch:o,farDistance:i,nearDistance:c}=e,s=k(e.geometry),l=new f({spatialReference:t}),m=Math.abs(1.44*i*s);let u=Math.abs(1.44*c*s);(o<20||null==a)&&(u=m);const p=[];return p[0]={x:n+m*Math.sin((a-45)*A),y:r+m*Math.cos((a-45)*A)},p[1]={x:n+m*Math.sin((a+45)*A),y:r+m*Math.cos((a+45)*A)},p[2]={x:n+u*Math.sin((a+135)*A),y:r+u*Math.cos((a+135)*A)},p[3]={x:n+u*Math.sin((a+225)*A),y:r+u*Math.cos((a+225)*A)},l.addRing([[p[0].x,p[0].y,0],[p[1].x,p[1].y,0],[p[2].x,p[2].y,0],[p[3].x,p[3].y,0],[p[0].x,p[0].y,0]]),l}function k(e){return e&&d(e?.spatialReference)?1/Math.cos(Math.PI/2-2*Math.atan(Math.exp(-1*e.y/u.radius))):1}function L(e,t){const r=1+t/100;if("esri.geometry.Circle"===e.declaredClass){const{radius:t,center:n}=e,a=new i({radius:t*r,center:n});return e.rings.length>1&&a.addRing(e.rings[1]),a}if("esri.geometry.Polygon"===e.declaredClass){const t=new f({spatialReference:e.spatialReference}),o=e.centroid;if(o){const i=[];for(let t=0;t<e.rings[0].length;t++){const c=Math.sqrt((o.x-e.rings[0][t][0])**2+(o.y-e.rings[0][t][1])**2),s=P(a(n(),[e.rings[0][t][0],e.rings[0][t][1],0],[o.x,o.y,0]),1/c,1),f=v([o.x,o.y,0],s,c*r,1);i.push({x:f[0],y:f[1]})}t.addRing([[i[0].x,i[0].y,0],[i[1].x,i[1].y,0],[i[2].x,i[2].y,0],[i[3].x,i[3].y,0],[i[0].x,i[0].y,0]])}return t}return e}async function W(e,t,n){const{cameraHeight:r,cameraLocation:a,cameraPitch:o,frustumVertices:i,horizontalFieldOfView:c,imageHeight:s,imageWidth:f,inSRS:l,outSRS:u,verticalFieldOfView:p,cameraRoll:h,options:y}=n,g=new m(l),x=new m(u),d=D(c,p,h??0),w=i.length>15;return o+d.vfov/2>=90?await N(i,e,f,s,g,x,w,y):await B(i,e,t,a,r,w,g,x,y)}async function B(e,t,n,r,a,o,i,s,f){const l=G(e,t,n,r,a);if(!l)return;const{farPlane:m,nearPlane:u}=l,p=await Q([...u?.vertexPositions??e.slice(0,3),...m.vertexPositions],i,s,f),y=$(p);return new c({vertexAttributes:new h({position:p}),components:Z(o?X(y,!0):Y(y,!0)),spatialReference:s})}function G(e,t,n,r,a){const o=T(e),i=T(e,"near");if(!o)return;const c=t.length;for(let s=0;s<c;s++){const e=Array.from(n[s]),t=[e[0]-r[0],e[1]-r[1],e[2]-(r[2]??a)];K(r,t,s,i),J(r,t,s,o)}return{farPlane:o,nearPlane:i}}function J(e,t,r,a){const{coefficients:o,vertexPositions:i}=a,c=n();x(o,{origin:e,direction:t},c)&&i.splice(3*r,3,...c)}function K(e,t,r,a){if(!a)return;const o=n();x(a.coefficients,{origin:e,direction:t},o)&&a.vertexPositions.splice(3*r,3,...o)}async function N(e,t,n,r,a,o,i,s){let f,l=i?new Array:[e[0],e[1],e[2]],m=new Array;for(const c of t)i?(f=b([c[0],c[1],1],[[0,0,1],[n,0,1],[n,r,1],[0,r,1]],[[e[0],e[1],e[2]],[e[3],e[4],e[5]],[e[6],e[7],e[8]],[e[9],e[10],e[11]]]),l=l.concat(...f),f=b([c[0],c[1],1],[[0,0,1],[n,0,1],[n,r,1],[0,r,1]],[[e[12],e[13],e[14]],[e[15],e[16],e[17]],[e[18],e[19],e[20]],[e[21],e[22],e[23]]]),m=m.concat(...f)):(f=b([c[0],c[1],1],[[0,0,1],[n,0,1],[n,r,1],[0,r,1]],[[e[3],e[4],e[5]],[e[6],e[7],e[8]],[e[9],e[10],e[11]],[e[12],e[13],e[14]]]),l=l.concat(...f));l=l.concat(m);const u=await Q(l,a,o,s),p=$(u);return new c({vertexAttributes:new h({position:u}),components:Z(i?X(p,!0):Y(p,!0)),spatialReference:o})}async function Q(t,n,r,a){if(n.equals(r))return t;const o=t.reduce((e,t,n)=>{const r=Math.floor(n/3);return e[r]||(e[r]=new Array),e[r].push(t),e},new Array),{points:i}=await l(new s({points:o,spatialReference:n}),r,a);return e(a),i.flat()}function T(e,t="far"){const n=y();let r;switch(t){case"far":if(r=Array.from(15===e.length?e.slice(3):e.slice(12)),g(n,r,!1))return{coefficients:n,vertexPositions:r};break;case"near":if(r=Array.from(e.slice(0,12)),15===e.length||!g(n,r,!1))return;return{coefficients:n,vertexPositions:r}}}const X=(e,t=!1)=>{if(t&&e-2<=4||e<=4||e%2!=0)throw new Error("Invalid number of vertices");const n=[],r=e/2,a=Math.round((t?e-2:e)/2);for(let o=0;o<a;o++){const a=o+r,i=t?a+1:a,c=i%e,s=(t?a:i+1)%e;n.push({faces:new Uint32Array([o,s,c,o,o+1,c])})}return n};function Y(e,t=!1){if(e<3||t&&e-1<3)throw new Error("Invalid number of vertices");const n=[],r=t?e-2:e-1;for(let a=0;a<r;a++)n.push({faces:new Uint32Array([0,a+1,a+2])});return n}const Z=e=>e.map(e=>new p(e)),$=e=>e.length/3;export{S as checkIfPolygonContainsSelectedPoint,E as computePolygonForInspection,I as createCoveragePolygon,H as limitZToGround,Q as projectVertices,L as resizePolygon,W as updateFrustum};
|
|
@@ -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{result as e}from"../../core/asyncUtils.js";import t from"../../core/Error.js";import{assertIsSome as i}from"../../core/maybe.js";import{whenOrAbort as n,throwIfAbortError as o}from"../../core/promiseUtils.js";import{getMetersPerUnitForSR as l}from"../../core/unitUtils.js";import s from"../../geometry/Multipoint.js";import a from"../../geometry/Point.js";import r from"../../geometry/Polyline.js";import{initializeProjection as c,project as u}from"../../geometry/projectionUtils.js";import{fromExtent as h,create as f,contains as m}from"../../geometry/support/aaBoundingRect.js";import{MultiTileElevationSampler as p}from"./ElevationSampler.js";import{ElevationTile as d}from"./ElevationTile.js";import{TileKey as y}from"./TileKey.js";class T{async queryAll(e,i,n){if(!(e=n?.ignoreInvisibleLayers?e.filter(e=>e.visible):e.slice()).length)throw new t("elevation-query:invalid-layer","Elevation queries require at least one elevation layer to fetch tiles from");const o=v.fromGeometry(i);let l=!1;n?.returnSampleInfo||(l=!0);const s={...R,...n,returnSampleInfo:!0},a=await this.query(e[e.length-1],o,s),r=await this._queryAllContinue(e,a,s);return r.geometry=r.geometry.export(),l&&delete r.sampleInfo,r}async query(e,i,n){if(!e)throw new t("elevation-query:invalid-layer","Elevation queries require an elevation layer to fetch tiles from");if(!i||!(i instanceof v)&&"point"!==i.type&&"multipoint"!==i.type&&"polyline"!==i.type)throw new t("elevation-query:invalid-geometry","Only point, polyline and multipoint geometries can be used to query elevation");const o={...R,...n},l=new x(e,i.spatialReference,o),s=o.signal;return await e.load({signal:s}),await q(l,i,s),await this._selectTiles(l,s),await F(l,s),b(l),z(l,s)}async createSampler(e,i,n){if(!e)throw new t("elevation-query:invalid-layer","Elevation queries require an elevation layer to fetch tiles from");if(!i||"extent"!==i.type)throw new t("elevation-query:invalid-extent","Invalid or undefined extent");const o={...R,...n};return this._createSampler(e,i,o)}async createSamplerAll(e,i,n){if(!(e=n?.ignoreInvisibleLayers?e.filter(e=>e.visible):e.slice()).length)throw new t("elevation-query:invalid-layer","Elevation queries require at least one elevation layer to fetch tiles from");if(!i||"extent"!==i.type)throw new t("elevation-query:invalid-extent","Invalid or undefined extent");const o={...R,...n,returnSampleInfo:!0},l=await this._createSampler(e[e.length-1],i,o);return this._createSamplerAllContinue(e,i,l,o)}async _createSampler(e,t,i,n){const o=i.signal;await e.load({signal:o});const l=t.spatialReference,s=e.tileInfo.spatialReference;l.equals(s)||(await c([{source:l,dest:s}],{signal:o}),t=u(t,s));const a=new _(e,t,i,n);return await this._selectTiles(a,o),await F(a,o),new p(a.elevationTiles,a.layer.tileInfo,a.options.noDataValue)}async _createSamplerAllContinue(e,t,i,n){if(e.pop(),!e.length)return i;const o=i.samplers.filter(e=>!e.tile.hasNoDataValues).map(e=>h(e.extent)),l=await this._createSampler(e[e.length-1],t,n,o);if(0===l.samplers.length)return i;const s=i.samplers.concat(l.samplers),a=new p(s,n.noDataValue);return this._createSamplerAllContinue(e,t,a,n)}async _queryAllContinue(e,t,n){const o=e.pop(),l=t.geometry.coordinates,s=t.sampleInfo;i(s);const a=[],r=[];for(let i=0;i<l.length;i++){const t=s[i];t.demResolution>=0?t.source||(t.source=o):e.length&&(a.push(l[i]),r.push(i))}if(!e.length||0===a.length)return t;const c=t.geometry.clone(a),u=await this.query(e[e.length-1],c,n),h=u.sampleInfo;if(!h)throw new Error("no sampleInfo");return r.forEach((e,t)=>{l[e].z=u.geometry.coordinates[t].z,s[e].demResolution=h[t].demResolution}),this._queryAllContinue(e,t,n)}async _selectTiles(e,i){"geometry"===e.type&&I(e);const n=e.options.demResolution;if("number"==typeof n)C(e,n);else if("finest-contiguous"===n)await this._selectTilesFinestContiguous(e,i);else{if("auto"!==n)throw new t("elevation-query:invalid-dem-resolution",`Invalid dem resolution value '${n}', expected a number, "finest-contiguous" or "auto"`);await this._selectTilesAuto(e,i)}}async _selectTilesFinestContiguous(e,t){const{tileInfo:i,tilemapCache:n}=e.layer,o=E(i,n,e.options.minDemResolution);await this._selectTilesFinestContiguousAt(e,o,t)}async _selectTilesFinestContiguousAt(e,i,l){const s=e.layer;if(e.selectTilesAtLOD(i),i<0)return;const a=s.tilemapCache,r=e.getTilesToFetch();try{if(a&&!L(a))await n(Promise.all(r.map(e=>a.fetchAvailability(e.level,e.row,e.col,{signal:l}))),l);else if(await F(e,l),!e.allElevationTilesFetched())throw e.clearElevationTiles(),new t("elevation-query:has-unavailable-tiles","Some elevation tiles are unavailable")}catch(c){o(c),await this._selectTilesFinestContiguousAt(e,i-1,l)}}async _selectTilesAuto(t,i){M(t),S(t);const l=t.layer.tilemapCache;if(!l||L(l))return this._selectTilesAutoPrefetchUpsample(t,i);const s=t.getTilesToFetch(),a={},r=s.map(async t=>{const n=new y(null,0,0,0,f()),s=await e(l.fetchAvailabilityUpsample(t.level,t.row,t.col,n,{signal:i}));!1!==s.ok?null!=t.id&&(a[t.id]=n):o(s.error)});await n(Promise.all(r),i),t.remapTiles(a)}async _selectTilesAutoPrefetchUpsample(e,t){const i=e.layer.tileInfo;await F(e,t);let n=!1;e.forEachTileToFetch((e,t)=>{i.upsampleTile(e)?n=!0:t()}),n&&await this._selectTilesAutoPrefetchUpsample(e,t)}}class v{export(){return this._exporter(this.coordinates,this.spatialReference)}clone(e){const t=new v;return t.geometry=this.geometry,t.spatialReference=this.spatialReference,t.coordinates=e||this.coordinates.map(e=>e.clone()),t._exporter=this._exporter,t}async project(e,t){if(this.spatialReference.equals(e))return this.clone();await c([{source:this.spatialReference,dest:e}],{signal:t});const i=new s({spatialReference:this.spatialReference,points:this.coordinates.map(e=>[e.x,e.y])}),n=u(i,e);if(!n)return null;const o=this.coordinates.map((e,t)=>{const i=e.clone(),o=n.points[t];return i.x=o[0],i.y=o[1],i}),l=this.clone(o);return l.spatialReference=e,l}static fromGeometry(e){const t=new v;if(t.geometry=e,t.spatialReference=e.spatialReference,e instanceof v)t.coordinates=e.coordinates.map(e=>e.clone()),t._exporter=(t,i)=>{const n=e.clone(t);return n.spatialReference=i,n};else switch(e.type){case"point":{const i=e,{hasZ:n,hasM:o}=i;t.coordinates=n&&o?[new w(i.x,i.y,i.z,i.m)]:n?[new w(i.x,i.y,i.z)]:o?[new w(i.x,i.y,null,i.m)]:[new w(i.x,i.y)],t._exporter=(t,i)=>e.hasM?new a(t[0].x,t[0].y,t[0].z,t[0].m,i):new a(t[0].x,t[0].y,t[0].z,i);break}case"multipoint":{const i=e,{hasZ:n,hasM:o}=i;t.coordinates=n&&o?i.points.map(e=>new w(e[0],e[1],e[2],e[3])):n?i.points.map(e=>new w(e[0],e[1],e[2])):o?i.points.map(e=>new w(e[0],e[1],null,e[2])):i.points.map(e=>new w(e[0],e[1])),t._exporter=(t,i)=>e.hasM?new s({points:t.map(e=>[e.x,e.y,e.z,e.m]),hasZ:!0,hasM:!0,spatialReference:i}):new s(t.map(e=>[e.x,e.y,e.z]),i);break}case"polyline":{const i=e,n=[],o=[],{hasZ:l,hasM:s}=e;let a=0;for(const e of i.paths)if(o.push([a,a+e.length]),a+=e.length,l&&s)for(const t of e)n.push(new w(t[0],t[1],t[2],t[3]));else if(l)for(const t of e)n.push(new w(t[0],t[1],t[2]));else if(s)for(const t of e)n.push(new w(t[0],t[1],null,t[2]));else for(const t of e)n.push(new w(t[0],t[1]));t.coordinates=n,t._exporter=(t,i)=>{const n=e.hasM?t.map(e=>[e.x,e.y,e.z??0,e.m??0]):t.map(e=>[e.x,e.y,e.z??0]),l=o.map(e=>n.slice(e[0],e[1]));return new r({paths:l,hasM:e.hasM,hasZ:!0,spatialReference:i})};break}}return t}}class w{constructor(e,t,i=null,n=null,o=null,l=null){this.x=e,this.y=t,this.z=i,this.m=n,this.tile=o,this.elevationTile=l}clone(){return new w(this.x,this.y,this.z,this.m)}}class g{constructor(e,t){this.layer=e,this.options=t}}class x extends g{constructor(e,t,i){super(e,i),this.outSpatialReference=t,this.type="geometry"}selectTilesAtLOD(e){if(e<0)this.geometry.coordinates.forEach(e=>e.tile=null);else{const{tileInfo:t,tilemapCache:i}=this.layer,n=D(t,i)[e].level;this.geometry.coordinates.forEach(e=>e.tile=t.tileAt(n,e.x,e.y))}}allElevationTilesFetched(){return!this.geometry.coordinates.some(e=>!e.elevationTile)}clearElevationTiles(){for(const e of this.geometry.coordinates)e.elevationTile!==this.outsideExtentTile&&(e.elevationTile=null)}populateElevationTiles(e){for(const t of this.geometry.coordinates)!t.elevationTile&&t.tile?.id&&(t.elevationTile=e[t.tile.id])}remapTiles(e){for(const t of this.geometry.coordinates){const i=t.tile?.id;t.tile=i?e[i]:null}}getTilesToFetch(){const e={},t=[];for(const i of this.geometry.coordinates){const n=i.tile;if(!n)continue;const o=i.tile?.id;i.elevationTile||!o||e[o]||(e[o]=n,t.push(n))}return t}forEachTileToFetch(e){for(const t of this.geometry.coordinates)t.tile&&!t.elevationTile&&e(t.tile,()=>{t.tile=null})}}class _ extends g{constructor(e,t,i,n){super(e,i),this.type="extent",this.elevationTiles=[],this._candidateTiles=[],this._fetchedCandidates=new Set,this.extent=t.clone().intersection(e.fullExtent),this.maskExtents=n}selectTilesAtLOD(e,t){const i=this._maximumLodForRequests(t),n=Math.min(i,e);n<0?this._candidateTiles.length=0:this._selectCandidateTilesCoveringExtentAt(n)}_maximumLodForRequests(e){const{tileInfo:t,tilemapCache:i}=this.layer,n=D(t,i);if(!e)return n.length-1;const o=this.extent;if(null==o)return-1;for(let l=n.length-1;l>=0;l--){const i=n[l],s=i.resolution*t.size[0],a=i.resolution*t.size[1];if(Math.ceil(o.width/s)*Math.ceil(o.height/a)<=e)return l}return-1}allElevationTilesFetched(){return this._candidateTiles.length===this.elevationTiles.length}clearElevationTiles(){this.elevationTiles.length=0,this._fetchedCandidates.clear()}populateElevationTiles(e){for(const t of this._candidateTiles){const i=t.id&&e[t.id];i&&(this._fetchedCandidates.add(t),this.elevationTiles.push(i))}}remapTiles(e){this._candidateTiles=j(this._candidateTiles.map(t=>e[t.id]))}getTilesToFetch(){return this._candidateTiles}forEachTileToFetch(e,t){const i=this._candidateTiles;this._candidateTiles=[],i.forEach(i=>{if(this._fetchedCandidates.has(i))return void t?.(i);let n=!1;e(i,()=>n=!0),n?t?.(i):this._candidateTiles.push(i)}),this._candidateTiles=j(this._candidateTiles,t)}_selectCandidateTilesCoveringExtentAt(e){this._candidateTiles.length=0;const t=this.extent;if(null==t)return;const{tileInfo:i,tilemapCache:n}=this.layer,o=D(i,n)[e],l=i.tileAt(o.level,t.xmin,t.ymin),s=l.extent;if(null==s)return;const a=o.resolution*i.size[0],r=o.resolution*i.size[1],c=Math.ceil((t.xmax-s[0])/a),u=Math.ceil((t.ymax-s[1])/r);for(let h=0;h<u;h++)for(let e=0;e<c;e++){const t=new y(null,l.level,l.row-h,l.col+e);i.updateTileInfo(t),this._tileIsMasked(t)||this._candidateTiles.push(t)}}_tileIsMasked(e){return!!this.maskExtents&&this.maskExtents.some(t=>e.extent&&m(t,e.extent))}}function E(e,t,i=0){const n=D(e,t);let o=n.length-1;if(i>0){const t=i/l(e.spatialReference),s=n.findIndex(e=>e.resolution<t);0===s?o=0:s>0&&(o=s-1)}return o}const R={maximumAutoTileRequests:20,noDataValue:0,returnSampleInfo:!1,demResolution:"auto",minDemResolution:0};async function q(e,i,n){let o;const l=e.layer.tileInfo.spatialReference;if(i instanceof v?o=await i.project(l,n):(await c([{source:i.spatialReference,dest:l}],{signal:n}),o=u(i,l)),!o)throw new t("elevation-query:spatial-reference-mismatch",`Cannot query elevation in '${i.spatialReference.wkid}' on an elevation service in '${l.wkid}'`);e.geometry=v.fromGeometry(o)}function I(e){if(null==e.layer.fullExtent)return;const t=new d(null);t.sample=()=>e.options.noDataValue,e.outsideExtentTile=t;const i=e.layer.fullExtent;e.geometry.coordinates.forEach(e=>{const n=e.x,o=e.y;(n<i.xmin||n>i.xmax||o<i.ymin||o>i.ymax)&&(e.elevationTile=t)})}function A(e,t){const{tileInfo:i,tilemapCache:n}=e.layer,o=t/l(i.spatialReference),s=D(i,n);let a=s[0],r=0;for(let l=1;l<s.length;l++){const e=s[l];Math.abs(e.resolution-o)<Math.abs(a.resolution-o)&&(a=e,r=l)}return r}function C(e,t){const i=A(e,t);e.selectTilesAtLOD(i)}function M(e){const{tileInfo:t,tilemapCache:i}=e.layer,n=E(t,i,e.options.minDemResolution);e.selectTilesAtLOD(n,e.options.maximumAutoTileRequests)}function D(e,t){const i=e.lods;if(L(t)){const{effectiveMinLOD:e,effectiveMaxLOD:n}=t;return i.filter(t=>t.level>=e&&t.level<=n)}return i}async function F(e,t){const i=e.getTilesToFetch(),o={},l=e.options.cache,s=e.options.noDataValue,a=i.map(async i=>{if(null==i.id)return;const n=`${e.layer.uid}:${i.id}:${s}`,a=null!=l?l.get(n):null,r=null!=a?a:await e.layer.fetchTile(i.level,i.row,i.col,{noDataValue:s,signal:t});null!=l&&l.put(n,r),o[i.id]=new d(i,r)});await n(Promise.allSettled(a),t),e.populateElevationTiles(o)}function S(e){const t=e.layer.tileInfo;let i=0;const n={},o=e=>{null!=e.id&&(e.id in n?n[e.id]++:(n[e.id]=1,i++))},l=e=>{if(null==e.id)return;const t=n[e.id];1===t?(delete n[e.id],i--):n[e.id]=t-1};e.forEachTileToFetch(o,l);let s=!0;for(;s&&(s=!1,e.forEachTileToFetch(n=>{i<=e.options.maximumAutoTileRequests||(l(n),t.upsampleTile(n)&&(s=!0),o(n))},l),s););}function b(e){e.geometry.coordinates.forEach(t=>{const i=t.elevationTile;let n=e.options.noDataValue;if(i){const e=i.sample(t.x,t.y);null!=e?n=e:t.elevationTile=null}t.z=n})}function j(e,t){const i={},n=[];for(const l of e){const e=l.id;e&&!i[e]?(i[e]=l,n.push(l)):t?.(l)}const o=n.sort((e,t)=>e.level-t.level);return o.filter((e,i)=>{for(let n=0;n<i;n++){const i=o[n].extent;if(i&&e.extent&&m(i,e.extent))return t?.(e),!1}return!0})}async function z(e,t){const n=await e.geometry.project(e.outSpatialReference,t);i(n);const o={geometry:n.export(),noDataValue:e.options.noDataValue};return e.options.returnSampleInfo&&(o.sampleInfo=k(e)),e.geometry.coordinates.forEach(e=>{e.tile=null,e.elevationTile=null}),o}function k(e){const t=e.layer.tileInfo,i=l(t.spatialReference);return e.geometry.coordinates.map(n=>{let o=-1;if(n.elevationTile&&n.elevationTile!==e.outsideExtentTile){o=t.lodAt(n.elevationTile.tile.level).resolution*i}return{demResolution:o}})}function L(e){return null!=e?.tileInfo}export{T as ElevationQuery,v as GeometryDescriptor,E as getFinestLodIndex};
|
|
5
|
+
import{result as e}from"../../core/asyncUtils.js";import t from"../../core/Error.js";import{assertIsSome as i}from"../../core/maybe.js";import{whenOrAbort as n,throwIfAbortError as o}from"../../core/promiseUtils.js";import{getMetersPerUnitForSR as l}from"../../core/unitUtils.js";import s from"../../geometry/Multipoint.js";import a from"../../geometry/Point.js";import r from"../../geometry/Polyline.js";import{initializeProjection as c,project as u}from"../../geometry/projectionUtils.js";import{fromExtent as h,create as f,contains as p}from"../../geometry/support/aaBoundingRect.js";import{MultiTileElevationSampler as m}from"./ElevationSampler.js";import{ElevationTile as d}from"./ElevationTile.js";import{TileKey as y}from"./TileKey.js";class T{async queryAll(e,i,n){if(!(e=n?.ignoreInvisibleLayers?e.filter(e=>e.visible):e.slice()).length)throw new t("elevation-query:invalid-layer","Elevation queries require at least one elevation layer to fetch tiles from");const o=v.fromGeometry(i);let l=!1;n?.returnSampleInfo||(l=!0);const s={...R,...n,returnSampleInfo:!0},a=await this.query(e[e.length-1],o,s),r=await this._queryAllContinue(e,a,s);return r.geometry=r.geometry.export(),l&&delete r.sampleInfo,r}async query(e,i,n){if(!e)throw new t("elevation-query:invalid-layer","Elevation queries require an elevation layer to fetch tiles from");if(!i||!(i instanceof v)&&"point"!==i.type&&"multipoint"!==i.type&&"polyline"!==i.type)throw new t("elevation-query:invalid-geometry","Only point, polyline and multipoint geometries can be used to query elevation");const o={...R,...n},l=new x(e,i.spatialReference,o),s=o.signal;return await e.load({signal:s}),await q(l,i,s),await this._selectTiles(l,s),await F(l,s),b(l),z(l,s)}async createSampler(e,i,n){if(!e)throw new t("elevation-query:invalid-layer","Elevation queries require an elevation layer to fetch tiles from");if(!i||"extent"!==i.type)throw new t("elevation-query:invalid-extent","Invalid or undefined extent");const o={...R,...n};return this._createSampler(e,i,o)}async createSamplerAll(e,i,n){if(!(e=n?.ignoreInvisibleLayers?e.filter(e=>e.visible):e.slice()).length)throw new t("elevation-query:invalid-layer","Elevation queries require at least one elevation layer to fetch tiles from");if(!i||"extent"!==i.type)throw new t("elevation-query:invalid-extent","Invalid or undefined extent");const o={...R,...n,returnSampleInfo:!0},l=await this._createSampler(e[e.length-1],i,o);return this._createSamplerAllContinue(e,i,l,o)}async _createSampler(e,t,i,n){const o=i.signal;await e.load({signal:o});const l=t.spatialReference,s=e.tileInfo.spatialReference;l.equals(s)||(await c([{source:l,dest:s}],{signal:o}),t=u(t,s));const a=new _(e,t,i,n);return await this._selectTiles(a,o),await F(a,o),new m(a.elevationTiles,a.layer.tileInfo,a.options.noDataValue)}async _createSamplerAllContinue(e,t,i,n){if(e.pop(),!e.length)return i;const o=i.samplers.filter(e=>!e.tile.hasNoDataValues).map(e=>h(e.extent)),l=await this._createSampler(e[e.length-1],t,n,o);if(0===l.samplers.length)return i;const s=i.samplers.concat(l.samplers),a=new m(s,n.noDataValue);return this._createSamplerAllContinue(e,t,a,n)}async _queryAllContinue(e,t,n){const o=e.pop(),l=t.geometry.coordinates,s=t.sampleInfo;i(s);const a=[],r=[];for(let i=0;i<l.length;i++){const t=s[i];t.demResolution>=0?t.source||(t.source=o):e.length&&(a.push(l[i]),r.push(i))}if(!e.length||0===a.length)return t;const c=t.geometry.clone(a),u=await this.query(e[e.length-1],c,n),h=u.sampleInfo;if(!h)throw new Error("no sampleInfo");return r.forEach((e,t)=>{l[e].z=u.geometry.coordinates[t].z,s[e].demResolution=h[t].demResolution}),this._queryAllContinue(e,t,n)}async _selectTiles(e,i){"geometry"===e.type&&I(e);const n=e.options.demResolution;if("number"==typeof n)C(e,n);else if("finest-contiguous"===n)await this._selectTilesFinestContiguous(e,i);else{if("auto"!==n)throw new t("elevation-query:invalid-dem-resolution",`Invalid dem resolution value '${n}', expected a number, "finest-contiguous" or "auto"`);await this._selectTilesAuto(e,i)}}async _selectTilesFinestContiguous(e,t){const{tileInfo:i,tilemapCache:n}=e.layer,o=E(i,n,e.options.minDemResolution);await this._selectTilesFinestContiguousAt(e,o,t)}async _selectTilesFinestContiguousAt(e,i,l){const s=e.layer;if(e.selectTilesAtLOD(i),i<0)return;const a=s.tilemapCache,r=e.getTilesToFetch();try{if(a&&!L(a))await n(Promise.all(r.map(e=>a.fetchAvailability(e.level,e.row,e.col,{signal:l}))),l);else if(await F(e,l),!e.allElevationTilesFetched())throw e.clearElevationTiles(),new t("elevation-query:has-unavailable-tiles","Some elevation tiles are unavailable")}catch(c){o(c),await this._selectTilesFinestContiguousAt(e,i-1,l)}}async _selectTilesAuto(t,i){M(t),S(t);const l=t.layer.tilemapCache;if(!l||L(l))return this._selectTilesAutoPrefetchUpsample(t,i);const s=t.getTilesToFetch(),a={},r=s.map(async t=>{const n=new y(null,0,0,0,f()),s=await e(l.fetchAvailabilityUpsample(t.level,t.row,t.col,n,{signal:i}));!1!==s.ok?null!=t.id&&(a[t.id]=n):o(s.error)});await n(Promise.all(r),i),t.remapTiles(a)}async _selectTilesAutoPrefetchUpsample(e,t){const i=e.layer.tileInfo;await F(e,t);let n=!1;e.forEachTileToFetch((e,t)=>{i.upsampleTile(e)?n=!0:t()}),n&&await this._selectTilesAutoPrefetchUpsample(e,t)}}class v{export(){return this._exporter(this.coordinates,this.spatialReference)}clone(e){const t=new v;return t.geometry=this.geometry,t.spatialReference=this.spatialReference,t.coordinates=e||this.coordinates.map(e=>e.clone()),t._exporter=this._exporter,t}async project(e,t){if(this.spatialReference.equals(e))return this.clone();await c([{source:this.spatialReference,dest:e}],{signal:t});const i=new s({spatialReference:this.spatialReference,points:this.coordinates.map(e=>[e.x,e.y])}),n=u(i,e);if(!n)return null;const o=this.coordinates.map((e,t)=>{const i=e.clone(),o=n.points[t];return i.x=o[0],i.y=o[1],i}),l=this.clone(o);return l.spatialReference=e,l}static fromGeometry(e){const t=new v;if(t.geometry=e,t.spatialReference=e.spatialReference,e instanceof v)t.coordinates=e.coordinates.map(e=>e.clone()),t._exporter=(t,i)=>{const n=e.clone(t);return n.spatialReference=i,n};else switch(e.type){case"point":{const i=e,{hasZ:n,hasM:o}=i;t.coordinates=n&&o?[new w(i.x,i.y,i.z,i.m)]:n?[new w(i.x,i.y,i.z)]:o?[new w(i.x,i.y,null,i.m)]:[new w(i.x,i.y)],t._exporter=(t,i)=>e.hasM?new a(t[0].x,t[0].y,t[0].z,t[0].m,i):new a(t[0].x,t[0].y,t[0].z,i);break}case"multipoint":{const i=e,{hasZ:n,hasM:o}=i;t.coordinates=n&&o?i.points.map(e=>new w(e[0],e[1],e[2],e[3])):n?i.points.map(e=>new w(e[0],e[1],e[2])):o?i.points.map(e=>new w(e[0],e[1],null,e[2])):i.points.map(e=>new w(e[0],e[1])),t._exporter=(t,i)=>e.hasM?new s({points:t.map(e=>[e.x,e.y,e.z??0,e.m??0]),hasZ:!0,hasM:!0,spatialReference:i}):new s({points:t.map(e=>[e.x,e.y,e.z??0]),spatialReference:i});break}case"polyline":{const i=e,n=[],o=[],{hasZ:l,hasM:s}=e;let a=0;for(const e of i.paths)if(o.push([a,a+e.length]),a+=e.length,l&&s)for(const t of e)n.push(new w(t[0],t[1],t[2],t[3]));else if(l)for(const t of e)n.push(new w(t[0],t[1],t[2]));else if(s)for(const t of e)n.push(new w(t[0],t[1],null,t[2]));else for(const t of e)n.push(new w(t[0],t[1]));t.coordinates=n,t._exporter=(t,i)=>{const n=e.hasM?t.map(e=>[e.x,e.y,e.z??0,e.m??0]):t.map(e=>[e.x,e.y,e.z??0]),l=o.map(e=>n.slice(e[0],e[1]));return new r({paths:l,hasM:e.hasM,hasZ:!0,spatialReference:i})};break}}return t}}class w{constructor(e,t,i=null,n=null,o=null,l=null){this.x=e,this.y=t,this.z=i,this.m=n,this.tile=o,this.elevationTile=l}clone(){return new w(this.x,this.y,this.z,this.m)}}class g{constructor(e,t){this.layer=e,this.options=t}}class x extends g{constructor(e,t,i){super(e,i),this.outSpatialReference=t,this.type="geometry"}selectTilesAtLOD(e){if(e<0)this.geometry.coordinates.forEach(e=>e.tile=null);else{const{tileInfo:t,tilemapCache:i}=this.layer,n=D(t,i)[e].level;this.geometry.coordinates.forEach(e=>e.tile=t.tileAt(n,e.x,e.y))}}allElevationTilesFetched(){return!this.geometry.coordinates.some(e=>!e.elevationTile)}clearElevationTiles(){for(const e of this.geometry.coordinates)e.elevationTile!==this.outsideExtentTile&&(e.elevationTile=null)}populateElevationTiles(e){for(const t of this.geometry.coordinates)!t.elevationTile&&t.tile?.id&&(t.elevationTile=e[t.tile.id])}remapTiles(e){for(const t of this.geometry.coordinates){const i=t.tile?.id;t.tile=i?e[i]:null}}getTilesToFetch(){const e={},t=[];for(const i of this.geometry.coordinates){const n=i.tile;if(!n)continue;const o=i.tile?.id;i.elevationTile||!o||e[o]||(e[o]=n,t.push(n))}return t}forEachTileToFetch(e){for(const t of this.geometry.coordinates)t.tile&&!t.elevationTile&&e(t.tile,()=>{t.tile=null})}}class _ extends g{constructor(e,t,i,n){super(e,i),this.type="extent",this.elevationTiles=[],this._candidateTiles=[],this._fetchedCandidates=new Set,this.extent=t.clone().intersection(e.fullExtent),this.maskExtents=n}selectTilesAtLOD(e,t){const i=this._maximumLodForRequests(t),n=Math.min(i,e);n<0?this._candidateTiles.length=0:this._selectCandidateTilesCoveringExtentAt(n)}_maximumLodForRequests(e){const{tileInfo:t,tilemapCache:i}=this.layer,n=D(t,i);if(!e)return n.length-1;const o=this.extent;if(null==o)return-1;for(let l=n.length-1;l>=0;l--){const i=n[l],s=i.resolution*t.size[0],a=i.resolution*t.size[1];if(Math.ceil(o.width/s)*Math.ceil(o.height/a)<=e)return l}return-1}allElevationTilesFetched(){return this._candidateTiles.length===this.elevationTiles.length}clearElevationTiles(){this.elevationTiles.length=0,this._fetchedCandidates.clear()}populateElevationTiles(e){for(const t of this._candidateTiles){const i=t.id&&e[t.id];i&&(this._fetchedCandidates.add(t),this.elevationTiles.push(i))}}remapTiles(e){this._candidateTiles=j(this._candidateTiles.map(t=>e[t.id]))}getTilesToFetch(){return this._candidateTiles}forEachTileToFetch(e,t){const i=this._candidateTiles;this._candidateTiles=[],i.forEach(i=>{if(this._fetchedCandidates.has(i))return void t?.(i);let n=!1;e(i,()=>n=!0),n?t?.(i):this._candidateTiles.push(i)}),this._candidateTiles=j(this._candidateTiles,t)}_selectCandidateTilesCoveringExtentAt(e){this._candidateTiles.length=0;const t=this.extent;if(null==t)return;const{tileInfo:i,tilemapCache:n}=this.layer,o=D(i,n)[e],l=i.tileAt(o.level,t.xmin,t.ymin),s=l.extent;if(null==s)return;const a=o.resolution*i.size[0],r=o.resolution*i.size[1],c=Math.ceil((t.xmax-s[0])/a),u=Math.ceil((t.ymax-s[1])/r);for(let h=0;h<u;h++)for(let e=0;e<c;e++){const t=new y(null,l.level,l.row-h,l.col+e);i.updateTileInfo(t),this._tileIsMasked(t)||this._candidateTiles.push(t)}}_tileIsMasked(e){return!!this.maskExtents&&this.maskExtents.some(t=>e.extent&&p(t,e.extent))}}function E(e,t,i=0){const n=D(e,t);let o=n.length-1;if(i>0){const t=i/l(e.spatialReference),s=n.findIndex(e=>e.resolution<t);0===s?o=0:s>0&&(o=s-1)}return o}const R={maximumAutoTileRequests:20,noDataValue:0,returnSampleInfo:!1,demResolution:"auto",minDemResolution:0};async function q(e,i,n){let o;const l=e.layer.tileInfo.spatialReference;if(i instanceof v?o=await i.project(l,n):(await c([{source:i.spatialReference,dest:l}],{signal:n}),o=u(i,l)),!o)throw new t("elevation-query:spatial-reference-mismatch",`Cannot query elevation in '${i.spatialReference.wkid}' on an elevation service in '${l.wkid}'`);e.geometry=v.fromGeometry(o)}function I(e){if(null==e.layer.fullExtent)return;const t=new d(null);t.sample=()=>e.options.noDataValue,e.outsideExtentTile=t;const i=e.layer.fullExtent;e.geometry.coordinates.forEach(e=>{const n=e.x,o=e.y;(n<i.xmin||n>i.xmax||o<i.ymin||o>i.ymax)&&(e.elevationTile=t)})}function A(e,t){const{tileInfo:i,tilemapCache:n}=e.layer,o=t/l(i.spatialReference),s=D(i,n);let a=s[0],r=0;for(let l=1;l<s.length;l++){const e=s[l];Math.abs(e.resolution-o)<Math.abs(a.resolution-o)&&(a=e,r=l)}return r}function C(e,t){const i=A(e,t);e.selectTilesAtLOD(i)}function M(e){const{tileInfo:t,tilemapCache:i}=e.layer,n=E(t,i,e.options.minDemResolution);e.selectTilesAtLOD(n,e.options.maximumAutoTileRequests)}function D(e,t){const i=e.lods;if(L(t)){const{effectiveMinLOD:e,effectiveMaxLOD:n}=t;return i.filter(t=>t.level>=e&&t.level<=n)}return i}async function F(e,t){const i=e.getTilesToFetch(),o={},l=e.options.cache,s=e.options.noDataValue,a=i.map(async i=>{if(null==i.id)return;const n=`${e.layer.uid}:${i.id}:${s}`,a=null!=l?l.get(n):null,r=null!=a?a:await e.layer.fetchTile(i.level,i.row,i.col,{noDataValue:s,signal:t});null!=l&&l.put(n,r),o[i.id]=new d(i,r)});await n(Promise.allSettled(a),t),e.populateElevationTiles(o)}function S(e){const t=e.layer.tileInfo;let i=0;const n={},o=e=>{null!=e.id&&(e.id in n?n[e.id]++:(n[e.id]=1,i++))},l=e=>{if(null==e.id)return;const t=n[e.id];1===t?(delete n[e.id],i--):n[e.id]=t-1};e.forEachTileToFetch(o,l);let s=!0;for(;s&&(s=!1,e.forEachTileToFetch(n=>{i<=e.options.maximumAutoTileRequests||(l(n),t.upsampleTile(n)&&(s=!0),o(n))},l),s););}function b(e){e.geometry.coordinates.forEach(t=>{const i=t.elevationTile;let n=e.options.noDataValue;if(i){const e=i.sample(t.x,t.y);null!=e?n=e:t.elevationTile=null}t.z=n})}function j(e,t){const i={},n=[];for(const l of e){const e=l.id;e&&!i[e]?(i[e]=l,n.push(l)):t?.(l)}const o=n.sort((e,t)=>e.level-t.level);return o.filter((e,i)=>{for(let n=0;n<i;n++){const i=o[n].extent;if(i&&e.extent&&p(i,e.extent))return t?.(e),!1}return!0})}async function z(e,t){const n=await e.geometry.project(e.outSpatialReference,t);i(n);const o={geometry:n.export(),noDataValue:e.options.noDataValue};return e.options.returnSampleInfo&&(o.sampleInfo=k(e)),e.geometry.coordinates.forEach(e=>{e.tile=null,e.elevationTile=null}),o}function k(e){const t=e.layer.tileInfo,i=l(t.spatialReference);return e.geometry.coordinates.map(n=>{let o=-1;if(n.elevationTile&&n.elevationTile!==e.outsideExtentTile){o=t.lodAt(n.elevationTile.tile.level).resolution*i}return{demResolution:o}})}function L(e){return null!=e?.tileInfo}export{T as ElevationQuery,v as GeometryDescriptor,E as getFinestLodIndex};
|
|
@@ -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{__decorate as e}from"tslib";import t from"../../core/Collection.js";import{EventedMixin as r}from"../../core/Evented.js";import{JSONSupportMixin as
|
|
5
|
+
import{__decorate as e}from"tslib";import t from"../../core/Collection.js";import{EventedMixin as r}from"../../core/Evented.js";import{JSONSupportMixin as i}from"../../core/JSONSupport.js";import{Loadable as s}from"../../core/Loadable.js";import{on as o,watch as l,sync as a,whenOnce as n}from"../../core/reactiveUtils.js";import{stripHTML as p}from"../../core/string.js";import{property as u}from"../../core/accessorSupport/decorators/property.js";import{ensureType as h}from"../../core/accessorSupport/ensureType.js";import"../../core/has.js";import"../../core/RandomLCG.js";import{reader as y}from"../../core/accessorSupport/decorators/reader.js";import{subclass as c}from"../../core/accessorSupport/decorators/subclass.js";import m from"../../geometry/Extent.js";import f from"../../graphic/KMLGraphicOrigin.js";import{computeExtent as d,sublayersFromJSON as v,fetchService as b,parseKML as j}from"./kmlUtils.js";var S;let g=S=class extends(r(i(s))){constructor(...e){super(...e),this.description=null,this.fullExtent=null,this.id=null,this.networkLink=null,this.parent=null,this.sublayers=null,this.title=null,this.sourceJSON=null,this.layer=null,this.addHandles([o(()=>this.sublayers,"after-add",({item:e})=>{e.parent=this,e.layer=this.layer},a),o(()=>this.sublayers,"after-remove",({item:e})=>{e.layer=e.parent=null},a),l(()=>this.sublayers,(e,t)=>{if(t)for(const r of t)r.layer=r.parent=null;if(e)for(const r of e)r.parent=this,r.layer=this.layer},a),l(()=>this.layer,e=>{if(this.sublayers)for(const t of this.sublayers)t.layer=e},a)])}initialize(){n(()=>this.networkLink).then(()=>n(()=>!0===this.visible)).then(()=>this.load())}load(e){if(!this.networkLink)return;if(this.networkLink.viewFormat)return;const r=null!=e?e.signal:null,i=this._fetchService(this._get("networkLink")?.href??"",r).then(e=>{const r=d(e.sublayers);this.fullExtent=m.fromJSON(r),this.sourceJSON=e;const i=h(t.ofType(S),v(S,e));this.sublayers?this.sublayers.addMany(i):this.sublayers=i,this.layer?.emit("sublayer-update"),this.layer&&this.layer.notifyChange("visibleSublayers")});return this.addResolvingPromise(i),Promise.resolve(this)}get visible(){return this._get("visible")}set visible(e){this._get("visible")!==e&&(this._set("visible",e),this.layer&&this.layer.notifyChange("visibleSublayers"))}readVisible(e,t){return!!t.visibility}get origin(){return this.layer?new f(this.layer,this):null}_fetchService(e,t){return b(e,this.layer.outSpatialReference,this.layer.refreshInterval,t).then(e=>j(e.data))}};e([u()],g.prototype,"description",void 0),e([u({type:m})],g.prototype,"fullExtent",void 0),e([u()],g.prototype,"id",void 0),e([u({readOnly:!0,value:null})],g.prototype,"networkLink",void 0),e([u({json:{write:{allowNull:!0}}})],g.prototype,"parent",void 0),e([u({type:t.ofType(g),json:{write:{allowNull:!0}}})],g.prototype,"sublayers",void 0),e([u({value:null,json:{read:{source:"name",reader:e=>p(e)}}})],g.prototype,"title",void 0),e([u({value:!0})],g.prototype,"visible",null),e([y("visible",["visibility"])],g.prototype,"readVisible",null),e([u()],g.prototype,"sourceJSON",void 0),e([u()],g.prototype,"layer",void 0),e([u()],g.prototype,"origin",null),g=S=e([c("esri.layers.support.KMLSublayer")],g);export{g as default};
|
|
@@ -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{excludeTables as e}from"../../core/accessorSupport/layerContainerType.js";import{FeatureReduction as t}from"./FeatureReduction.js";import i from"./FeatureReductionBinning.js";import
|
|
5
|
+
import{excludeTables as e}from"../../core/accessorSupport/layerContainerType.js";import{FeatureReduction as t}from"./FeatureReduction.js";import i from"./FeatureReductionBinning.js";import o from"./FeatureReductionCluster.js";import r from"./FeatureReductionSelection.js";const n={key:"type",base:t,typeMap:{cluster:o,binning:i}},a={types:{key:"type",base:t,typeMap:{selection:r,cluster:o,binning:i}},json:{name:"layerDefinition.featureReduction",write:{allowNull:!0},origins:{"web-map":{types:n},"portal-item":{types:n},"web-scene":{types:{key:"type",base:t,typeMap:{selection:r}},name:"layerDefinition.featureReduction",write:{allowNull:!0,layerContainerTypes:e}}}}};export{a as featureReductionProperty};
|
|
@@ -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 e from"../../config.js";import{id as o}from"../../kernel.js";import t from"../../PopupTemplate.js";import r from"../../request.js";import{clone as s}from"../../core/lang.js";import{addQueryParameters as n}from"../../core/urlUtils.js";import i from"../../geometry/SpatialReference.js";import{create as f,negativeInfinity as a,expandWithAABB as l,equals as u}from"../../geometry/support/aaBoundingBox.js";import{getBoundsXYZ as m}from"../../geometry/support/boundsUtils.js";import{fromJSON as p}from"../../renderers/support/jsonUtils.js";import y from"../../rest/support/FeatureSet.js";const c={esriGeometryPoint:"points",esriGeometryPolyline:"polylines",esriGeometryPolygon:"polygons"};function d(e){const o=e.folders||[],t=o.slice(),r=new Map,n=new Map,i=new Map,f=new Map,a=new Map,l={esriGeometryPoint:n,esriGeometryPolyline:i,esriGeometryPolygon:f};(e.featureCollection?.layers||[]).forEach(e=>{const o=s(e);o.featureSet.features=[];const t=e.featureSet.geometryType;r.set(t,o);const a=e.layerDefinition.objectIdField;"esriGeometryPoint"===t?h(n,a,e.featureSet.features):"esriGeometryPolyline"===t?h(i,a,e.featureSet.features):"esriGeometryPolygon"===t&&h(f,a,e.featureSet.features)}),e.groundOverlays&&e.groundOverlays.forEach(e=>{a.set(e.id,e)}),o.forEach(o=>{o.networkLinkIds.forEach(r=>{const s=P(r,o.id,e.networkLinks);s&&t.push(s)})}),t.forEach(e=>{if(e.featureInfos){e.points=s(r.get("esriGeometryPoint")),e.polylines=s(r.get("esriGeometryPolyline")),e.polygons=s(r.get("esriGeometryPolygon")),e.mapImages=[];for(const o of e.featureInfos)switch(o.type){case"esriGeometryPoint":case"esriGeometryPolyline":case"esriGeometryPolygon":{const t=l[o.type].get(o.id);t&&e[c[o.type]]?.featureSet.features.push(t);break}case"GroundOverlay":{const t=a.get(o.id);t&&e.mapImages.push(t);break}}e.fullExtent=
|
|
5
|
+
import e from"../../config.js";import{id as o}from"../../kernel.js";import t from"../../PopupTemplate.js";import r from"../../request.js";import{clone as s}from"../../core/lang.js";import{addQueryParameters as n}from"../../core/urlUtils.js";import i from"../../geometry/SpatialReference.js";import{create as f,negativeInfinity as a,expandWithAABB as l,equals as u}from"../../geometry/support/aaBoundingBox.js";import{getBoundsXYZ as m}from"../../geometry/support/boundsUtils.js";import{fromJSON as p}from"../../renderers/support/jsonUtils.js";import y from"../../rest/support/FeatureSet.js";const c={esriGeometryPoint:"points",esriGeometryPolyline:"polylines",esriGeometryPolygon:"polygons"};function d(e){const o=e.folders||[],t=o.slice(),r=new Map,n=new Map,i=new Map,f=new Map,a=new Map,l={esriGeometryPoint:n,esriGeometryPolyline:i,esriGeometryPolygon:f};(e.featureCollection?.layers||[]).forEach(e=>{const o=s(e);o.featureSet.features=[];const t=e.featureSet.geometryType;r.set(t,o);const a=e.layerDefinition.objectIdField;"esriGeometryPoint"===t?h(n,a,e.featureSet.features):"esriGeometryPolyline"===t?h(i,a,e.featureSet.features):"esriGeometryPolygon"===t&&h(f,a,e.featureSet.features)}),e.groundOverlays&&e.groundOverlays.forEach(e=>{a.set(e.id,e)}),o.forEach(o=>{o.networkLinkIds.forEach(r=>{const s=P(r,o.id,e.networkLinks);s&&t.push(s)})}),t.forEach(e=>{if(e.featureInfos){e.points=s(r.get("esriGeometryPoint")),e.polylines=s(r.get("esriGeometryPolyline")),e.polygons=s(r.get("esriGeometryPolygon")),e.mapImages=[];for(const o of e.featureInfos)switch(o.type){case"esriGeometryPoint":case"esriGeometryPolyline":case"esriGeometryPolygon":{const t=l[o.type].get(o.id);t&&e[c[o.type]]?.featureSet.features.push(t);break}case"GroundOverlay":{const t=a.get(o.id);t&&e.mapImages.push(t);break}}e.fullExtent=I([e])}});const u=I(t);return{folders:o,sublayers:t,extent:u}}function g(t,s,i,f){const a=o?.findCredential(t);t=n(t,{token:a?.token});const l=e.kmlServiceUrl;return r(l,{query:{url:t,model:"simple",folders:"",refresh:0!==i||void 0,outSR:JSON.stringify(s)},responseType:"json",signal:f})}function S(e,o,t=null,r=[]){const s=[],n={},i=o.sublayers,f=new Set(o.folders.map(e=>e.id));return i.forEach(o=>{const i=new e;if(t?i.read(o,t):i.read(o),r.length&&f.has(i.id)&&(i.visible=r.includes(i.id)),n[o.id]=i,null!=o.parentFolderId&&-1!==o.parentFolderId){const e=n[o.parentFolderId];e.sublayers||(e.sublayers=[]),e.sublayers?.unshift(i)}else s.unshift(i)}),s}function h(e,o,t){t.forEach(t=>{e.set(t.attributes[o],t)})}function G(e,o){let t;return o.some(o=>o.id===e&&(t=o,!0)),t}function P(e,o,t){const r=G(e,t);return r&&(r.parentFolderId=o,r.networkLink=r),r}async function b(e,o,r,s){const n=e[o];if(!n)return[];const i=y.fromJSON(n.featureSet).features,f=n.layerDefinition,a=p(f.drawingInfo.renderer),l=t.fromJSON(n.popupInfo),u=[];for(const t of i){const e=await a.getSymbolAsync(t);t.symbol=e,t.popupTemplate=l,t.visible=!0;const o=r.sublayerById.get(s);t.origin=o.origin,u.push(t)}return u}function I(e){const o=f(a),t=f(a);for(const r of e){if(r.polygons?.featureSet?.features)for(const e of r.polygons.featureSet.features)m(o,e.geometry),l(t,o);if(r.polylines?.featureSet?.features)for(const e of r.polylines.featureSet.features)m(o,e.geometry),l(t,o);if(r.points?.featureSet?.features)for(const e of r.points.featureSet.features)m(o,e.geometry),l(t,o);if(r.mapImages)for(const e of r.mapImages)m(o,e.extent),l(t,o)}return u(t,a)?void 0:{xmin:t[0],ymin:t[1],zmin:t[2],xmax:t[3],ymax:t[4],zmax:t[5],spatialReference:i.WGS84}}export{I as computeExtent,g as fetchService,b as getGraphics,d as parseKML,S as sublayersFromJSON};
|
package/package.json
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{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};
|