@arcgis/core 4.24.0-next.20220607 → 4.24.0-next.20220610
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/analysis/Analysis.js +1 -1
- package/analysis/LineOfSightAnalysis.js +1 -1
- package/arcade/arcadeCompiler.js +1 -1
- package/arcade.d.ts +4 -0
- package/arcade.js +1 -1
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/{4d2181bde97983ecac8b.js → 03ddf44e6fb8bf9db3ff.js} +1 -1
- package/assets/esri/core/workers/chunks/{2e2d7f5952934af43fd7.js → 04034dabc8e0a489b0f8.js} +1 -1
- package/assets/esri/core/workers/chunks/{d7168ff8f26ca2537080.js → 0747c28fce0b344dc89b.js} +1 -1
- package/assets/esri/core/workers/chunks/1e4e5d147263e98536bc.js +1 -0
- package/assets/esri/core/workers/chunks/{cbe98327181d8d7ad9e5.js → 262fabdc409d55831ffa.js} +1 -1
- package/assets/esri/core/workers/chunks/2a52c2c6edd70432f4a5.js +1 -0
- package/assets/esri/core/workers/chunks/{71d445d1e6812e03a1d7.js → 3ce7adaefc9de28d9c87.js} +1 -1
- package/assets/esri/core/workers/chunks/{c165845a117c21246b1e.js → 42aa8ce4eb7bd851475e.js} +1 -1
- package/assets/esri/core/workers/chunks/{a9a4bb1d781b1a995fb3.js → 4824926501e11d04eb4a.js} +1 -1
- package/assets/esri/core/workers/chunks/{e51420d231c286b9c062.js → 540f1ed1ea9cddc739af.js} +1 -1
- package/assets/esri/core/workers/chunks/6196cfdeb91ceba52af3.js +1 -0
- package/assets/esri/core/workers/chunks/71a4618d959a09302c51.js +1 -0
- package/assets/esri/core/workers/chunks/76fbc8eaabba62fd4f9c.js +1 -0
- package/assets/esri/core/workers/chunks/{cb906a3f03dd0805c880.js → 7cc17b716b16a6684023.js} +1 -1
- package/assets/esri/core/workers/chunks/871681c1353026cb6d4b.js +1 -0
- package/assets/esri/core/workers/chunks/{13e9e6f0b4942d79b0eb.js → 88942e9f60687ac006dc.js} +1 -1
- package/assets/esri/core/workers/chunks/{4c5b80ba3dbfe6f6cafb.js → acb1e649cda99d4f69a5.js} +1 -1
- package/assets/esri/core/workers/chunks/b71a0a8a2f446c671161.js +1 -0
- package/assets/esri/core/workers/chunks/b8002aaa665712299121.js +1 -0
- package/assets/esri/core/workers/chunks/{e4ca3f04ca7f71b46240.js → bb3480e231934b7bb34e.js} +1 -1
- package/assets/esri/core/workers/chunks/{185da42e7cc8e440c0f0.js → c157b46b0724f3f0947e.js} +1 -1
- package/assets/esri/core/workers/chunks/{1aba8c73c62a64e0658c.js → c6af8b0903d8d934d542.js} +1 -1
- package/assets/esri/core/workers/chunks/c8402e32307a7b7eaaeb.js +1 -0
- package/assets/esri/core/workers/chunks/c8e08a956b16034d9819.js +1 -0
- package/assets/esri/core/workers/chunks/d0d2566bedc493ed0a3b.js +1 -0
- package/assets/esri/core/workers/chunks/{8152cd26ebeae910b753.js → d3c73da9c2abb59e762a.js} +1 -1
- package/assets/esri/core/workers/chunks/d828a0656e7351a74fc4.js +1 -0
- package/assets/esri/core/workers/chunks/{172368d4eb6e6f8d2bdb.js → d8b9551df1bd196d0126.js} +1 -1
- package/assets/esri/core/workers/chunks/e5c8584ae764892c324d.js +1 -0
- package/assets/esri/core/workers/chunks/{1d893ebc6f203ff1fc3d.js → efe605ff4ba2a95c14c5.js} +1 -1
- package/assets/esri/core/workers/chunks/f54d5abbb9668c45bd19.js +1 -0
- package/assets/esri/core/workers/chunks/{bd2f4a01cb71e25837ba.js → f7ba74fc4eb541c424fc.js} +1 -1
- package/assets/esri/core/workers/chunks/{1ebed6d6f561f926bd36.js → faf6e48f9f1205fb2e43.js} +1 -1
- package/assets/esri/geometry/support/pe-wasm.wasm +0 -0
- package/assets/esri/themes/base/widgets/_BasemapToggle.scss +6 -23
- package/assets/esri/themes/base/widgets/_Directions.scss +0 -3
- package/assets/esri/themes/base/widgets/_FeatureTable.scss +10 -2
- package/assets/esri/themes/base/widgets/_Slider.scss +8 -3
- package/assets/esri/themes/base/widgets/_Tooltip.scss +8 -8
- package/assets/esri/themes/base/widgets/_Weather.scss +5 -1
- package/assets/esri/themes/dark/main.css +1 -1
- package/assets/esri/themes/light/main.css +1 -1
- package/assets/esri/themes/light/view.css +1 -1
- package/assets/esri/widgets/BasemapToggle/t9n/BasemapToggle.json +1 -1
- package/assets/esri/widgets/BasemapToggle/t9n/BasemapToggle_ar.json +1 -1
- package/assets/esri/widgets/BasemapToggle/t9n/BasemapToggle_bg.json +1 -1
- package/assets/esri/widgets/BasemapToggle/t9n/BasemapToggle_bs.json +1 -1
- package/assets/esri/widgets/BasemapToggle/t9n/BasemapToggle_ca.json +1 -1
- package/assets/esri/widgets/BasemapToggle/t9n/BasemapToggle_cs.json +1 -1
- package/assets/esri/widgets/BasemapToggle/t9n/BasemapToggle_da.json +1 -1
- package/assets/esri/widgets/BasemapToggle/t9n/BasemapToggle_de.json +1 -1
- package/assets/esri/widgets/BasemapToggle/t9n/BasemapToggle_el.json +1 -1
- package/assets/esri/widgets/BasemapToggle/t9n/BasemapToggle_en.json +1 -1
- package/assets/esri/widgets/BasemapToggle/t9n/BasemapToggle_es.json +1 -1
- package/assets/esri/widgets/BasemapToggle/t9n/BasemapToggle_et.json +1 -1
- package/assets/esri/widgets/BasemapToggle/t9n/BasemapToggle_fi.json +1 -1
- package/assets/esri/widgets/BasemapToggle/t9n/BasemapToggle_fr.json +1 -1
- package/assets/esri/widgets/BasemapToggle/t9n/BasemapToggle_he.json +1 -1
- package/assets/esri/widgets/BasemapToggle/t9n/BasemapToggle_hr.json +1 -1
- package/assets/esri/widgets/BasemapToggle/t9n/BasemapToggle_hu.json +1 -1
- package/assets/esri/widgets/BasemapToggle/t9n/BasemapToggle_id.json +1 -1
- package/assets/esri/widgets/BasemapToggle/t9n/BasemapToggle_it.json +1 -1
- package/assets/esri/widgets/BasemapToggle/t9n/BasemapToggle_ja.json +1 -1
- package/assets/esri/widgets/BasemapToggle/t9n/BasemapToggle_ko.json +1 -1
- package/assets/esri/widgets/BasemapToggle/t9n/BasemapToggle_lt.json +1 -1
- package/assets/esri/widgets/BasemapToggle/t9n/BasemapToggle_lv.json +1 -1
- package/assets/esri/widgets/BasemapToggle/t9n/BasemapToggle_nb.json +1 -1
- package/assets/esri/widgets/BasemapToggle/t9n/BasemapToggle_nl.json +1 -1
- package/assets/esri/widgets/BasemapToggle/t9n/BasemapToggle_pl.json +1 -1
- package/assets/esri/widgets/BasemapToggle/t9n/BasemapToggle_pt-BR.json +1 -1
- package/assets/esri/widgets/BasemapToggle/t9n/BasemapToggle_pt-PT.json +1 -1
- package/assets/esri/widgets/BasemapToggle/t9n/BasemapToggle_ro.json +1 -1
- package/assets/esri/widgets/BasemapToggle/t9n/BasemapToggle_ru.json +1 -1
- package/assets/esri/widgets/BasemapToggle/t9n/BasemapToggle_sk.json +1 -1
- package/assets/esri/widgets/BasemapToggle/t9n/BasemapToggle_sl.json +1 -1
- package/assets/esri/widgets/BasemapToggle/t9n/BasemapToggle_sr.json +1 -1
- package/assets/esri/widgets/BasemapToggle/t9n/BasemapToggle_sv.json +1 -1
- package/assets/esri/widgets/BasemapToggle/t9n/BasemapToggle_th.json +1 -1
- package/assets/esri/widgets/BasemapToggle/t9n/BasemapToggle_tr.json +1 -1
- package/assets/esri/widgets/BasemapToggle/t9n/BasemapToggle_uk.json +1 -1
- package/assets/esri/widgets/BasemapToggle/t9n/BasemapToggle_vi.json +1 -1
- package/assets/esri/widgets/BasemapToggle/t9n/BasemapToggle_zh-CN.json +1 -1
- package/assets/esri/widgets/BasemapToggle/t9n/BasemapToggle_zh-HK.json +1 -1
- package/assets/esri/widgets/BasemapToggle/t9n/BasemapToggle_zh-TW.json +1 -1
- package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_en.json +1 -1
- package/chunks/RasterColorizer.glsl.js +22 -18
- package/chunks/basis_transcoder.js +1 -1
- package/chunks/i3s.js +1 -1
- package/chunks/lclayout.js +1 -1
- package/chunks/lerc-wasm.js +1 -1
- package/chunks/libtess-asm.js +1 -1
- package/chunks/libtess.js +1 -1
- package/chunks/pe-wasm.js +1 -1
- package/chunks/persistableUrlUtils.js +1 -1
- package/chunks/vxlLayer.js +1 -1
- package/core/quantityUtils.js +1 -1
- package/geometry/projection.js +1 -1
- package/geometry/support/geodesicUtils.js +1 -1
- package/geometry/support/plane.js +1 -1
- package/interfaces.d.ts +471 -52
- package/layers/LineOfSightLayer.js +1 -1
- package/layers/RouteLayer.js +1 -1
- package/layers/VectorTileLayer.js +1 -1
- package/layers/support/LayerContingentValuesCache.js +1 -1
- package/layers/support/RasterInfo.js +1 -1
- package/layers/support/rasterDatasets/ImageAuxRaster.js +1 -1
- package/layers/support/rasterDatasets/InMemoryRaster.js +1 -1
- package/layers/support/rasterDatasets/WCSRaster.js +1 -1
- package/layers/support/rasterDatasets/wcsCoverageParser.js +1 -1
- package/layers/support/rasterFormats/JpgPlus.js +1 -1
- package/layers/support/rasterFormats/RasterCodec.js +1 -1
- package/layers/support/rasterFormats/TiffDecoder.js +1 -1
- package/package.json +1 -1
- package/portal/support/urlUtils.js +5 -0
- package/renderers/support/colorRampUtils.js +1 -1
- package/rest/imageService/fetchRasterInfo.js +1 -1
- package/smartMapping/renderers/pieChart.js +1 -1
- package/smartMapping/support/adapters/FeatureLayerAdapter.js +1 -1
- package/support/arcadeUtils.js +1 -1
- package/support/elevationInfoUtils.js +1 -1
- package/support/persistableUrlUtils.js +1 -1
- package/support/revision.js +1 -1
- package/symbols/cim/cimAnalyzer.js +1 -1
- package/views/2d/engine/vectorTiles/shaders/VTLMaterial.js +1 -1
- package/views/2d/engine/webgl/Utils.js +1 -1
- package/views/2d/engine/webgl/shaders/sources/shaderRepository.js +1 -1
- package/views/2d/layers/graphics/GraphicStoreItem.js +1 -1
- package/views/2d/layers/imagery/BaseImageryTileSubView2D.js +1 -1
- package/views/3d/analysis/AnalysisViewManager3D.js +1 -1
- package/views/3d/analysis/Dimensioning/LengthDimensionComputation.js +1 -1
- package/views/3d/analysis/DirectLineMeasurement/DirectLineMeasurementVisualization.js +1 -1
- package/views/3d/analysis/DirectLineMeasurementAnalysisView3D.js +1 -1
- package/views/3d/analysis/LineOfSight/LineOfSightController.js +1 -1
- package/views/3d/analysis/LineOfSight/LineOfSightRayIntersector.js +1 -1
- package/views/3d/input/SceneInputManager.js +1 -1
- package/views/3d/interactive/editingTools/draw/DrawGraphicTool3D.js +1 -1
- package/views/3d/interactive/editingTools/moveGraphic/GraphicMoveTool.js +1 -1
- package/views/3d/interactive/editingTools/reshapeGraphic/ReshapeOperation.js +1 -1
- package/views/3d/interactive/editingTools/transformGraphic/ExtentTransformTool.js +1 -1
- package/views/3d/interactive/editingTools/transformGraphic/GraphicTransformTool.js +1 -1
- package/views/3d/layers/i3s/I3SAttributeOverrides.js +1 -1
- package/views/3d/layers/i3s/I3SViewportQueries.js +1 -1
- package/views/3d/support/MemoryController.js +1 -1
- package/views/3d/terrain/RasterColorizerTechnique.js +1 -1
- package/views/3d/terrain/TerrainSurface.js +1 -1
- package/views/3d/terrain/TileCompositor.js +1 -1
- package/views/3d/terrain/TileRenderer.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/output/BlendOptions.js +1 -1
- package/views/MapView.js +1 -1
- package/views/SceneView.js +1 -1
- package/views/View.js +1 -1
- package/views/draw/DrawOperation.js +1 -1
- package/views/draw/support/GraphicMover.js +1 -1
- package/views/interactive/SegmentLabels.js +1 -1
- package/views/interactive/editGeometry/support/editPlaneUtils.js +1 -1
- package/views/interactive/tooltip/TranslateTooltipInfos.js +1 -1
- package/views/interactive/tooltip/content/TooltipContentTranslateVertex.js +1 -1
- package/views/interactive/tooltip/support/measurements.js +1 -1
- package/views/support/areaMeasurementUtils.js +1 -1
- package/views/support/automaticLengthMeasurementUtils.js +5 -0
- package/views/support/euclideanLengthMeasurementUtils.js +5 -0
- package/views/support/geodesicLengthMeasurementUtils.js +5 -0
- package/views/support/measurementUtils.js +5 -0
- package/widgets/BasemapToggle/BasemapToggleViewModel.js +1 -1
- package/widgets/BasemapToggle.js +1 -1
- package/widgets/BuildingExplorer/BuildingDisciplinesTree/BuildingDisciplinesTree.js +1 -1
- package/widgets/BuildingExplorer/BuildingLevelPicker/BuildingLevelPicker.js +1 -1
- package/widgets/BuildingExplorer/BuildingPhasePicker/BuildingPhasePicker.js +1 -1
- package/widgets/BuildingExplorer.js +1 -1
- package/widgets/Daylight/DaylightViewModel.js +1 -1
- package/widgets/Directions/DirectionsViewModel.js +1 -1
- package/widgets/Directions.js +1 -1
- package/widgets/Feature/FeatureMedia/FeatureMediaViewModel.js +1 -1
- package/widgets/Feature/support/featureUtils.js +1 -1
- package/widgets/FeatureTable/FieldColumn.js +1 -1
- package/widgets/Legend/support/sizeRampUtils.js +1 -1
- package/widgets/Print/PrintViewModel.js +1 -1
- package/widgets/Sketch/SketchViewModel.js +1 -1
- package/widgets/UtilityNetworkTrace/UtilityNetworkTraceViewModel.js +1 -1
- package/widgets/UtilityNetworkTrace.js +1 -1
- package/widgets/Weather.js +1 -1
- package/widgets/Widget.js +1 -1
- package/widgets/support/AnalysisViewModel.js +1 -1
- package/widgets/support/AnchorElementViewModel.js +1 -1
- package/widgets/support/InteractiveAnalysisViewModel.js +1 -1
- package/assets/esri/core/workers/chunks/2ac6c99aacb873134f7c.js +0 -1
- package/assets/esri/core/workers/chunks/471beeb6924599209567.js +0 -1
- package/assets/esri/core/workers/chunks/5242c9badca17ba2ab25.js +0 -1
- package/assets/esri/core/workers/chunks/72c7d48408d1f8050026.js +0 -1
- package/assets/esri/core/workers/chunks/770cf0a66102100abe74.js +0 -1
- package/assets/esri/core/workers/chunks/96ff15d6c2bfca0c6061.js +0 -1
- package/assets/esri/core/workers/chunks/9c4c721d890b49697132.js +0 -1
- package/assets/esri/core/workers/chunks/af3766a2d27419c7766c.js +0 -1
- package/assets/esri/core/workers/chunks/b50bbfd75768d9a8de88.js +0 -1
- package/assets/esri/core/workers/chunks/b577ec80647cf2ece397.js +0 -1
- package/assets/esri/core/workers/chunks/c1653b6cb201ecbaabaa.js +0 -1
- package/assets/esri/core/workers/chunks/e99b58d07475bffce7ea.js +0 -1
- package/assets/esri/core/workers/chunks/f3d885aec4bca18928d4.js +0 -1
- package/assets/esri/core/workers/chunks/fc0da1dfeef041182ddf.js +0 -1
- package/views/support/lengthMeasurementUtils.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.24/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../chunks/tslib.es6.js";import r from"../analysis/LineOfSightAnalysis.js";import t from"../analysis/LineOfSightAnalysisObserver.js";import s from"../analysis/LineOfSightAnalysisTarget.js";import i from"../core/Collection.js";import{HandleOwnerMixin as o}from"../core/HandleOwner.js";import{
|
|
5
|
+
import{_ as e}from"../chunks/tslib.es6.js";import r from"../analysis/LineOfSightAnalysis.js";import t from"../analysis/LineOfSightAnalysisObserver.js";import s from"../analysis/LineOfSightAnalysisTarget.js";import i from"../core/Collection.js";import{HandleOwnerMixin as o}from"../core/HandleOwner.js";import{isSome as a,applySome as n}from"../core/maybe.js";import{MultiOriginJSONMixin as l}from"../core/MultiOriginJSONSupport.js";import{watch as p,syncAndInitial as y}from"../core/reactiveUtils.js";import{property as m}from"../core/accessorSupport/decorators/property.js";import"../core/arrayUtils.js";import"../core/has.js";import"../core/accessorSupport/ensureType.js";import{subclass as c}from"../core/accessorSupport/decorators/subclass.js";import h from"./Layer.js";import{OperationalLayer as d}from"./mixins/OperationalLayer.js";const u=i.ofType(s);let f=class extends(d(l(o(h)))){constructor(e){super(e),this.type="line-of-sight",this.operationalLayerType="LineOfSightLayer",this.analysis=new r}initialize(){this.handles.add(p((()=>this.analysis),((e,r)=>{a(r)&&r.parent===this&&(r.parent=null),a(e)&&(e.parent=this)}),y))}async load(){return a(this.analysis)&&this.addResolvingPromise(this.analysis.waitComputeExtent()),this}get observer(){return n(this.analysis,(e=>e.observer))}set observer(e){n(this.analysis,(r=>r.observer=e))}get targets(){return a(this.analysis)?this.analysis.targets:null}set targets(e){n(this.analysis,(r=>r.targets=e))}get fullExtent(){return a(this.analysis)?this.analysis.extent:null}get spatialReference(){return a(this.analysis)?this.analysis.spatialReference:null}removeAnalysis(){this.analysis=new r}};e([m({json:{read:!1},readOnly:!0})],f.prototype,"type",void 0),e([m({type:["LineOfSightLayer"]})],f.prototype,"operationalLayerType",void 0),e([m({type:t,json:{read:!0,write:{ignoreOrigin:!0}}})],f.prototype,"observer",null),e([m({type:u,json:{read:!0,write:{ignoreOrigin:!0}}})],f.prototype,"targets",null),e([m({nonNullable:!0,json:{read:!1,write:!1}})],f.prototype,"analysis",void 0),e([m({readOnly:!0})],f.prototype,"fullExtent",null),e([m({readOnly:!0})],f.prototype,"spatialReference",null),e([m({json:{read:!1,write:!1,origins:{service:{read:!1,write:!1},"portal-item":{read:!1,write:!1},"web-document":{read:!1,write:!1}}}})],f.prototype,"opacity",void 0),e([m({type:["show","hide"]})],f.prototype,"listMode",void 0),f=e([c("esri.layers.LineOfSightLayer")],f);const g=f;export{g as default};
|
package/layers/RouteLayer.js
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../chunks/tslib.es6.js";import t from"../config.js";import"../geometry.js";import r from"../Graphic.js";import o from"../PopupTemplate.js";import"../renderers/ClassBreaksRenderer.js";import"../renderers/DictionaryRenderer.js";import"../renderers/DotDensityRenderer.js";import"../renderers/HeatmapRenderer.js";import"../renderers/PieChartRenderer.js";import"../renderers/Renderer.js";import"../renderers/SimpleRenderer.js";import"../renderers/UniqueValueRenderer.js";import{read as i}from"../renderers/support/jsonUtils.js";import s from"../core/Collection.js";import n from"../core/Error.js";import{HandleOwnerMixin as a}from"../core/HandleOwner.js";import l from"../core/Logger.js";import{isSome as p,isNone as u,unwrapOrValue as m,unwrap as c}from"../core/maybe.js";import{MultiOriginJSONMixin as y}from"../core/MultiOriginJSONSupport.js";import{setDeepValue as f}from"../core/object.js";import{isAbortError as d}from"../core/promiseUtils.js";import{on as h}from"../core/reactiveUtils.js";import{convertUnit as w}from"../core/unitUtils.js";import{urlToObject as S}from"../core/urlUtils.js";import{property as g}from"../core/accessorSupport/decorators/property.js";import"../core/arrayUtils.js";import"../core/has.js";import"../core/accessorSupport/ensureType.js";import{reader as b}from"../core/accessorSupport/decorators/reader.js";import{subclass as v}from"../core/accessorSupport/decorators/subclass.js";import{writer as B}from"../core/accessorSupport/decorators/writer.js";import{updateOrigins as P}from"../core/accessorSupport/originUtils.js";import j from"../geometry/Extent.js";import{initializeProjection as I,project as _}from"../geometry/projection.js";import{WGS84 as N}from"../geometry/support/spatialReferenceUtils.js";import L from"./Layer.js";import{BlendLayer as D}from"./mixins/BlendLayer.js";import{OperationalLayer as C}from"./mixins/OperationalLayer.js";import{PortalLayer as R}from"./mixins/PortalLayer.js";import{ScaleRangeLayer as O}from"./mixins/ScaleRangeLayer.js";import{sanitizeUrl as F}from"./support/arcgisLayerUrl.js";import T from"./support/RouteSymbols.js";import x from"../portal/Portal.js";import k from"../portal/PortalItem.js";import{TypeKeyword as A}from"../portal/support/portalItemUtils.js";import{fetchServiceDescription as J}from"../rest/networkService.js";import{solve as G}from"../rest/route.js";import U from"../rest/support/DirectionLine.js";import M from"../rest/support/DirectionPoint.js";import{directionsTimeUnitJsonMap as q,directionsLengthUnitJsonMap as E}from"../rest/support/networkEnums.js";import W from"../rest/support/PointBarrier.js";import V from"../rest/support/PolygonBarrier.js";import H from"../rest/support/PolylineBarrier.js";import K from"../rest/support/RouteInfo.js";import Y from"../rest/support/RouteParameters.js";import z from"../rest/support/RouteSettings.js";import Q from"../rest/support/Stop.js";import Z from"../geometry/SpatialReference.js";import $ from"../geometry/Multipoint.js";function X(e){return e.length?e:null}function ee(e){const{defaultTravelMode:t,supportedTravelModes:r}=e;return r.find((e=>e.id===t))}function te(e){switch(e){case"esriGeometryPoint":return{type:"esriSMS",style:"esriSMSCircle",size:12,color:[0,0,0,0],outline:te("esriGeometryPolyline")};case"esriGeometryPolyline":return{type:"esriSLS",style:"esriSLSSolid",width:1,color:[0,0,0,0]};case"esriGeometryPolygon":return{type:"esriSFS",style:"esriSFSNull",outline:te("esriGeometryPolyline")}}}function re(e){return"layers"in e}function oe(e){return"esri.rest.support.FeatureSet"===e.declaredClass}function ie(e){return"esri.rest.support.NetworkFeatureSet"===e.declaredClass}function se(e,t,r){const o=t.networkDataset.networkAttributes.filter((e=>"cost"===e.usageType)),i=ee(t),s=r.travelMode??i;if(u(s))return void he.warn("route-layer:missing-travel-mode","The routing service must have a default travel mode or one must be specified in the route parameter.");const{timeAttributeName:a,distanceAttributeName:l}=s,m=o.find((e=>e.name===a)),y=o.find((e=>e.name===l)),f=c(r.travelMode)?.impedanceAttributeName??c(r.impedanceAttribute)??t.impedance,d=q.fromJSON(m?.units),h=E.fromJSON(y?.units);if(!d||!h)throw new n("routelayer:unknown-impedance-units","the units of either the distance or time impedance are unknown");const w=r.directionsLanguage??t.directionsLanguage,S=c(r.accumulateAttributes)??t.accumulateAttributeNames??[],g=new Set(o.filter((({name:e})=>e===a||e===l||e===f||S.includes(e))).map((({name:e})=>e))),b=e=>{for(const t in e)g.has(t)||delete e[t]};for(const n of e.pointBarriers)p(n.costs)&&(n.addedCost=n.costs[f]??0,b(n.costs));for(const n of e.polygonBarriers)p(n.costs)&&(n.scaleFactor=n.costs[f]??1,b(n.costs));for(const n of e.polylineBarriers)p(n.costs)&&(n.scaleFactor=n.costs[f]??1,b(n.costs));const{routeInfo:v}=e,{findBestSequence:B,preserveFirstStop:P,preserveLastStop:j,startTimeIsUTC:I,timeWindowsAreUTC:_}=r;v.analysisSettings=new z({accumulateAttributes:S,directionsLanguage:w,findBestSequence:B,preserveFirstStop:P,preserveLastStop:j,startTimeIsUTC:I,timeWindowsAreUTC:_,travelMode:s}),v.totalDuration=ae(v.totalCosts[a]??0,d),v.totalDistance=le(v.totalCosts[l]??0,h),v.totalLateDuration=ae(v.totalViolations[a]??0,d),v.totalWaitDuration=ae(v.totalWait[a]??0,d),p(v.totalCosts)&&b(v.totalCosts),p(v.totalViolations)&&b(v.totalViolations),p(v.totalWait)&&b(v.totalWait);for(const n of e.stops)p(n.serviceCosts)&&(n.serviceDuration=ae(n.serviceCosts[a]??0,d),n.serviceDistance=le(n.serviceCosts[l]??0,h),b(n.serviceCosts)),p(n.cumulativeCosts)&&(n.cumulativeDuration=ae(n.cumulativeCosts[a]??0,d),n.cumulativeDistance=le(n.cumulativeCosts[l]??0,h),b(n.cumulativeCosts)),p(n.violations)&&(n.lateDuration=ae(n.violations[a]??0,d),b(n.violations)),p(n.wait)&&(n.waitDuration=ae(n.wait[a]??0,d),b(n.wait))}async function ne(e){const t=Z.WGS84;return await I(e.spatialReference,t),_(e,t)}function ae(e,t){switch(t){case"seconds":return e/60;case"hours":return 60*e;case"days":return 60*e*24;default:return e}}function le(e,t){return"decimal-degrees"===t||"points"===t||"unknown"===t?e:w(e,t,"meters")}function pe(e){const{attributes:t,geometry:r,popupTemplate:o,symbol:i}=e.toGraphic().toJSON();return{attributes:t,geometry:r,popupInfo:o,symbol:i}}const ue=s.ofType(U),me=s.ofType(M),ce=s.ofType(W),ye=s.ofType(V),fe=s.ofType(H),de=s.ofType(Q),he=l.getLogger("esri.layers.RouteLayer");let we=class extends(D(O(C(R(y(a(L))))))){constructor(e){super(e),this._cachedServiceDescription=null,this._featureCollection=null,this._type="Feature Collection",this.defaultSymbols=new T,this.directionLines=null,this.directionPoints=null,this.featureCollectionType="route",this.legendEnabled=!1,this.maxScale=0,this.minScale=0,this.pointBarriers=new ce,this.polygonBarriers=new ye,this.polylineBarriers=new fe,this.routeInfo=null,this.spatialReference=Z.WGS84,this.stops=new de,this.type="route";const t=()=>{this._setStopSymbol(this.stops)};this.own([h((()=>this.stops),"change",t,{sync:!0,onListenerAdd:t})])}writeFeatureCollectionWebmap(e,t,r,o){const i=[this._writePolygonBarriers(),this._writePolylineBarriers(),this._writePointBarriers(),this._writeRouteInfo(),this._writeDirectionLines(),this._writeDirectionPoints(),this._writeStops()].filter((e=>!!e)),s=i.map(((e,t)=>t)),n="web-map"===o.origin?"featureCollection.layers":"layers";f(n,i,t),t.opacity=this.opacity,t.visibility=this.visible,t.visibleLayers=s}readDirectionLines(e,t){return this._getNetworkFeatures(t,"DirectionLines",(e=>U.fromGraphic(e)))}readDirectionPoints(e,t){return this._getNetworkFeatures(t,"DirectionPoints",(e=>M.fromGraphic(e)))}get fullExtent(){if(p(this.routeInfo)&&p(this.routeInfo.geometry))return this.routeInfo.geometry.extent;const e=new j({xmin:-180,ymin:-90,xmax:180,ymax:90,spatialReference:Z.WGS84}),t=this.stops.filter((e=>p(e.geometry)));if(t.length<2)return e;const{spatialReference:r}=t.getItemAt(0).geometry;if(u(r))return e;const o=t.toArray().map((e=>{const t=e.geometry;return[t.x,t.y]}));return new $({points:o,spatialReference:r}).extent}readMaxScale(e,t){return(re(t)?t.layers:t.featureCollection.layers).find((e=>p(e.layerDefinition.maxScale)))?.layerDefinition.maxScale??0}readMinScale(e,t){return(re(t)?t.layers:t.featureCollection.layers).find((e=>p(e.layerDefinition.minScale)))?.layerDefinition.minScale??0}readPointBarriers(e,t){return this._getNetworkFeatures(t,"Barriers",(e=>W.fromGraphic(e)))}readPolygonBarriers(e,t){return this._getNetworkFeatures(t,"PolygonBarriers",(e=>V.fromGraphic(e)))}readPolylineBarriers(e,t){return this._getNetworkFeatures(t,"PolylineBarriers",(e=>H.fromGraphic(e)))}readRouteInfo(e,t){const r=this._getNetworkFeatures(t,"RouteInfo",(e=>K.fromGraphic(e)));return r.length>0?r.getItemAt(0):null}readSpatialReference(e,t){const r=re(t)?t.layers:t.featureCollection.layers;if(!r.length)return Z.WGS84;const{layerDefinition:o}=r[0],i=o.spatialReference??o.extent.spatialReference??N;return Z.fromJSON(i)}readStops(e,t){return this._getNetworkFeatures(t,"Stops",(e=>Q.fromGraphic(e)),(e=>this._setStopSymbol(e)))}get title(){return p(this.routeInfo)&&p(this.routeInfo.name)?this.routeInfo.name:"Route"}set title(e){e?this._override("title",e):this._clearOverride("title")}get url(){return t.routeServiceUrl}set url(e){null!=e?this._set("url",F(e,he)):this._set("url",t.routeServiceUrl)}load(e){return this.addResolvingPromise(this.loadFromPortal({supportedTypes:["Feature Collection"]},e)),Promise.resolve(this)}removeAll(){p(this.directionLines)&&(this.directionLines.removeAll(),this._set("directionLines",null)),p(this.directionPoints)&&(this.directionPoints.removeAll(),this._set("directionPoints",null)),p(this.routeInfo)&&this._set("routeInfo",null),this.pointBarriers.removeAll(),this.polygonBarriers.removeAll(),this.polylineBarriers.removeAll(),this.stops.removeAll()}async save(){await this.load();const{fullExtent:e,portalItem:t}=this;if(!t)throw new n("routelayer:portal-item-not-set","save() requires to the layer to have a portal item");if(!t.id)throw new n("routelayer:portal-item-not-saved","Please use saveAs() first to save the routelayer");if("Feature Collection"!==t.type)throw new n("routelayer:portal-item-wrong-type",'Portal item needs to have type "Feature Collection"');if(u(this.routeInfo))throw new n("routelayer:route-unsolved","save() requires a solved route");const{portal:r}=t;if(await r._signIn(),r.user||await t.reload(),r.user.username!==t.owner)throw new n("routelayer:not-portal-item-owner","You can only overwrite your portal items");const{itemUrl:o}=t,i={messages:[],origin:"portal-item",portal:r,url:o&&S(o),writtenProperties:[]},s=this.write(null,i);return t.extent=await ne(e),t.title=this.title,await t.update({data:s}),t}async saveAs(e,t={}){if(await this.load(),u(this.routeInfo))throw new n("routelayer:route-unsolved","saveAs() requires a solved route");const r=k.from(e).clone();r.extent??(r.extent=await ne(this.fullExtent)),r.id=null,r.portal??(r.portal=x.getDefault()),r.title??(r.title=this.title),r.type="Feature Collection",r.typeKeywords=["Data","Feature Collection",A.MULTI_LAYER,"Route Layer"];const{portal:o}=r,i={messages:[],origin:"portal-item",portal:o,url:null,writtenProperties:[]};await o._signIn();const s=t?.folder,a=this.write(null,i);return await o.user.addItem({item:r,folder:s,data:a}),this.portalItem=r,P(i),i.portalItem=r,r}async solve(e,t){const r=e?.stops??this.stops,o=e?.pointBarriers??X(this.pointBarriers),i=e?.polylineBarriers??X(this.polylineBarriers),a=e?.polygonBarriers??X(this.polygonBarriers);if(u(r))throw new n("routelayer:undefined-stops","the route layer must have stops defined in the route parameters.");if((oe(r)||ie(r))&&r.features.length<2||s.isCollection(r)&&r.length<2)throw new n("routelayer:insufficent-stops","the route layer must have two or more stops to solve a route.");const l=e?.apiKey,c=this.url,y=await this._getServiceDescription(c,l,t),f=ee(y),h=e?.travelMode??f,w=m(e?.accumulateAttributes,[]);p(h)&&(w.push(h.distanceAttributeName),h.timeAttributeName&&w.push(h.timeAttributeName));const S={startTime:new Date},g={accumulateAttributes:w,directionsOutputType:"featuresets",ignoreInvalidLocations:!0,pointBarriers:o,polylineBarriers:i,polygonBarriers:a,preserveFirstStop:!0,preserveLastStop:!0,returnBarriers:!!o,returnDirections:!0,returnPolygonBarriers:!!a,returnPolylineBarriers:!!i,returnRoutes:!0,returnStops:!0,stops:r},b=e?Y.from(e):new Y;for(const s in S)null==b[s]&&(b[s]=S[s]);let v;b.set(g);try{v=await G(c,b,t)}catch(P){throw d(P)?P:new n("routelayer:failed-route-request","the routing request failed",{error:P})}const B=this._toRouteLayerSolution(v);return this._isOverridden("title")||(this.title=m(B.routeInfo.name,"Route")),se(B,y,b),B}update(e){const{stops:t,directionLines:r,directionPoints:o,pointBarriers:i,polylineBarriers:s,polygonBarriers:n,routeInfo:a}=e;this.set({stops:t,pointBarriers:i,polylineBarriers:s,polygonBarriers:n}),this._set("directionLines",r),this._set("directionPoints",o),this._set("routeInfo",a)}_getNetworkFeatures(e,t,n,a){const l=(re(e)?e.layers:e.featureCollection.layers).find((e=>e.layerDefinition.name===t));if(u(l))return new s;const{layerDefinition:p,popupInfo:m,featureSet:c}=l,y=p.drawingInfo.renderer,{features:f}=c,d=y&&i(y),h=f.map((e=>{const i=r.fromJSON(e),s=n(i);return s.symbol??(s.symbol=d?.getSymbol(i)??this._getNetworkSymbol(t)),s.popupTemplate??(s.popupTemplate=m&&o.fromJSON(m)),s}));return a&&h.some((e=>!e.symbol))&&a(h),new s(h)}_getNetworkSymbol(e){switch(e){case"Barriers":return this.defaultSymbols.pointBarriers;case"DirectionPoints":return this.defaultSymbols.directionPoints;case"DirectionLines":return this.defaultSymbols.directionLines;case"PolylineBarriers":return this.defaultSymbols.polylineBarriers;case"PolygonBarriers":return this.defaultSymbols.polygonBarriers;case"RouteInfo":return this.defaultSymbols.routeInfo;case"Stops":return null}}async _getServiceDescription(e,t,r){if(p(this._cachedServiceDescription)&&this._cachedServiceDescription.url===e)return this._cachedServiceDescription.serviceDescription;const o=await J(e,t,r);return this._cachedServiceDescription={serviceDescription:o,url:e},o}_setStopSymbol(e){if(!e||0===e.length)return;if(u(this.defaultSymbols.stops))return;if(e.every((e=>p(e.symbol))))return;const{first:t,last:r,middle:o,unlocated:i,waypoint:s,break:n}=this.defaultSymbols.stops;if(u(this.routeInfo)||1===e.length)return void e.forEach(((i,s)=>{switch(s){case 0:i.symbol=t;break;case e.length-1:i.symbol=r;break;default:i.symbol=o}}));const a=e.map((e=>e.sequence)).filter((e=>p(e))),l=Math.min(...a),m=Math.max(...a);for(const p of e)p.sequence!==l?p.sequence!==m?"ok"===p.status||"not-located-on-closest"===p.status?"waypoint"!==p.locationType?"break"!==p.locationType?p.symbol=o:p.symbol=n:p.symbol=s:p.symbol=i:p.symbol=r:p.symbol=t}_toRouteLayerSolution(e){const t=e.routeResults[0].stops.map((e=>Q.fromJSON(e.toJSON())));this._setStopSymbol(t);const r=new de(t),o=new ye(e.polygonBarriers?.map((e=>{const t=V.fromJSON(e.toJSON());return t.symbol=this.defaultSymbols.polygonBarriers,t}))),i=new fe(e.polylineBarriers?.map((e=>{const t=H.fromJSON(e.toJSON());return t.symbol=this.defaultSymbols.polylineBarriers,t}))),s=new ce(e.pointBarriers?.map((e=>{const t=W.fromJSON(e.toJSON());return t.symbol=this.defaultSymbols.pointBarriers,t}))),n=K.fromJSON(e.routeResults[0].route.toJSON());n.symbol=this.defaultSymbols.routeInfo;const a=new me(e.routeResults[0].directionPoints?.features.map((e=>{const t=M.fromJSON(e.toJSON());return t.symbol=this.defaultSymbols.directionPoints,t})));return{directionLines:new ue(e.routeResults[0].directionLines?.features.map((e=>{const t=U.fromJSON(e.toJSON());return t.symbol=this.defaultSymbols.directionLines,t}))),directionPoints:a,pointBarriers:s,polygonBarriers:o,polylineBarriers:i,routeInfo:n,stops:r}}_writeDirectionLines(){return this._writeNetworkFeatures(this.directionLines,this.defaultSymbols.directionLines,"esriGeometryPolyline",U.fields,U.popupInfo,"DirectionLines","Direction Lines")}_writeDirectionPoints(){return this._writeNetworkFeatures(this.directionPoints,this.defaultSymbols.directionPoints,"esriGeometryPoint",M.fields,M.popupInfo,"DirectionPoints","Direction Points")}_writeNetworkFeatures(e,t,r,o,i,s,n){return u(e)||!e.length?null:{featureSet:{features:e.toArray().map((e=>pe(e))),geometryType:r},layerDefinition:{capabilities:"Query,Update,Editing",drawingInfo:{renderer:{type:"simple",symbol:p(t)?t.toJSON():te(r)}},extent:this.fullExtent.toJSON(),fields:o,geometryType:r,hasM:!1,hasZ:!1,maxScale:this.maxScale,minScale:this.minScale,name:s,objectIdField:"__OBJECTID",spatialReference:this.spatialReference.toJSON(),title:n,type:"Feature Layer",typeIdField:""},popupInfo:i}}_writePointBarriers(){return this._writeNetworkFeatures(this.pointBarriers,this.defaultSymbols.pointBarriers,"esriGeometryPoint",W.fields,W.popupInfo,"Barriers","Point Barriers")}_writePolygonBarriers(){return this._writeNetworkFeatures(this.polygonBarriers,this.defaultSymbols.polygonBarriers,"esriGeometryPolygon",V.fields,V.popupInfo,"PolygonBarriers","Polygon Barriers")}_writePolylineBarriers(){return this._writeNetworkFeatures(this.polylineBarriers,this.defaultSymbols.polylineBarriers,"esriGeometryPolyline",H.fields,H.popupInfo,"PolylineBarriers","Line Barriers")}_writeRouteInfo(){return this._writeNetworkFeatures(p(this.routeInfo)?new s([this.routeInfo]):null,this.defaultSymbols.routeInfo,"esriGeometryPolyline",K.fields,K.popupInfo,"RouteInfo","Route Details")}_writeStops(){const e=this._writeNetworkFeatures(this.stops,null,"esriGeometryPoint",Q.fields,Q.popupInfo,"Stops","Stops");if(u(e))return null;const{stops:t}=this.defaultSymbols,r=p(t)&&p(t.first)&&t.first.toJSON(),o=p(t)&&p(t.middle)&&t.middle.toJSON(),i=p(t)&&p(t.last)&&t.last.toJSON();return e.layerDefinition.drawingInfo.renderer={type:"uniqueValue",field1:"Sequence",defaultSymbol:o,uniqueValueInfos:[{value:"1",symbol:r,label:"First Stop"},{value:`${this.stops.length}`,symbol:i,label:"Last Stop"}]},e}};e([g({readOnly:!0,json:{read:!1,origins:{"portal-item":{write:{allowNull:!0,ignoreOrigin:!0}},"web-map":{write:{overridePolicy(){return{allowNull:!0,ignoreOrigin:null==this.portalItem}}}}}}})],we.prototype,"_featureCollection",void 0),e([B(["web-map","portal-item"],"_featureCollection")],we.prototype,"writeFeatureCollectionWebmap",null),e([g({readOnly:!0,json:{read:!1,origins:{"web-map":{write:{target:"type",overridePolicy(){return{ignoreOrigin:null!=this.portalItem}}}}}}})],we.prototype,"_type",void 0),e([g({nonNullable:!0,type:T})],we.prototype,"defaultSymbols",void 0),e([g({readOnly:!0})],we.prototype,"directionLines",void 0),e([b(["web-map","portal-item"],"directionLines",["layers","featureCollection.layers"])],we.prototype,"readDirectionLines",null),e([g({readOnly:!0})],we.prototype,"directionPoints",void 0),e([b(["web-map","portal-item"],"directionPoints",["layers","featureCollection.layers"])],we.prototype,"readDirectionPoints",null),e([g({readOnly:!0,json:{read:!1,origins:{"web-map":{write:{ignoreOrigin:!0}}}}})],we.prototype,"featureCollectionType",void 0),e([g({readOnly:!0})],we.prototype,"fullExtent",null),e([g({json:{origins:{"web-map":{name:"featureCollection.showLegend"}},write:!0}})],we.prototype,"legendEnabled",void 0),e([g({type:["show","hide"]})],we.prototype,"listMode",void 0),e([g({type:Number,nonNullable:!0,json:{write:!1}})],we.prototype,"maxScale",void 0),e([b(["web-map","portal-item"],"maxScale",["layers","featureCollection.layers"])],we.prototype,"readMaxScale",null),e([g({type:Number,nonNullable:!0,json:{write:!1}})],we.prototype,"minScale",void 0),e([b(["web-map","portal-item"],"minScale",["layers","featureCollection.layers"])],we.prototype,"readMinScale",null),e([g({type:["ArcGISFeatureLayer"],value:"ArcGISFeatureLayer"})],we.prototype,"operationalLayerType",void 0),e([g({nonNullable:!0,type:s.ofType(W)})],we.prototype,"pointBarriers",void 0),e([b(["web-map","portal-item"],"pointBarriers",["layers","featureCollection.layers"])],we.prototype,"readPointBarriers",null),e([g({nonNullable:!0,type:s.ofType(V)})],we.prototype,"polygonBarriers",void 0),e([b(["web-map","portal-item"],"polygonBarriers",["layers","featureCollection.layers"])],we.prototype,"readPolygonBarriers",null),e([g({nonNullable:!0,type:s.ofType(H)})],we.prototype,"polylineBarriers",void 0),e([b(["web-map","portal-item"],"polylineBarriers",["layers","featureCollection.layers"])],we.prototype,"readPolylineBarriers",null),e([g({readOnly:!0})],we.prototype,"routeInfo",void 0),e([b(["web-map","portal-item"],"routeInfo",["layers","featureCollection.layers"])],we.prototype,"readRouteInfo",null),e([g({type:Z})],we.prototype,"spatialReference",void 0),e([b(["web-map","portal-item"],"spatialReference",["layers","featureCollection.layers"])],we.prototype,"readSpatialReference",null),e([g({nonNullable:!0,type:s.ofType(Q)})],we.prototype,"stops",void 0),e([b(["web-map","portal-item"],"stops",["layers","featureCollection.layers"])],we.prototype,"readStops",null),e([g()],we.prototype,"title",null),e([g({readOnly:!0,json:{read:!1}})],we.prototype,"type",void 0),e([g()],we.prototype,"url",null),we=e([v("esri.layers.RouteLayer")],we);const Se=we;export{Se as default};
|
|
5
|
+
import{_ as e}from"../chunks/tslib.es6.js";import t from"../config.js";import"../geometry.js";import r from"../Graphic.js";import o from"../PopupTemplate.js";import"../renderers/ClassBreaksRenderer.js";import"../renderers/DictionaryRenderer.js";import"../renderers/DotDensityRenderer.js";import"../renderers/HeatmapRenderer.js";import"../renderers/PieChartRenderer.js";import"../renderers/Renderer.js";import"../renderers/SimpleRenderer.js";import"../renderers/UniqueValueRenderer.js";import{read as i}from"../renderers/support/jsonUtils.js";import s from"../core/Collection.js";import n from"../core/Error.js";import{HandleOwnerMixin as a}from"../core/HandleOwner.js";import l from"../core/Logger.js";import{isSome as p,isNone as u,unwrapOrValue as m,unwrap as c}from"../core/maybe.js";import{MultiOriginJSONMixin as y}from"../core/MultiOriginJSONSupport.js";import{setDeepValue as f}from"../core/object.js";import{isAbortError as d}from"../core/promiseUtils.js";import{on as h}from"../core/reactiveUtils.js";import{convertUnit as w}from"../core/unitUtils.js";import{urlToObject as S}from"../core/urlUtils.js";import{property as g}from"../core/accessorSupport/decorators/property.js";import"../core/arrayUtils.js";import"../core/has.js";import"../core/accessorSupport/ensureType.js";import{reader as b}from"../core/accessorSupport/decorators/reader.js";import{subclass as v}from"../core/accessorSupport/decorators/subclass.js";import{writer as B}from"../core/accessorSupport/decorators/writer.js";import{updateOrigins as P}from"../core/accessorSupport/originUtils.js";import j from"../geometry/Extent.js";import{initializeProjection as I,project as _}from"../geometry/projection.js";import{WGS84 as N}from"../geometry/support/spatialReferenceUtils.js";import L from"./Layer.js";import{BlendLayer as D}from"./mixins/BlendLayer.js";import{OperationalLayer as C}from"./mixins/OperationalLayer.js";import{PortalLayer as R}from"./mixins/PortalLayer.js";import{ScaleRangeLayer as O}from"./mixins/ScaleRangeLayer.js";import{sanitizeUrl as F}from"./support/arcgisLayerUrl.js";import T from"./support/RouteSymbols.js";import x from"../portal/Portal.js";import k from"../portal/PortalItem.js";import{TypeKeyword as A}from"../portal/support/portalItemUtils.js";import{fetchServiceDescription as J}from"../rest/networkService.js";import{solve as G}from"../rest/route.js";import U from"../rest/support/DirectionLine.js";import M from"../rest/support/DirectionPoint.js";import{directionsTimeUnitJsonMap as q,directionsLengthUnitJsonMap as E}from"../rest/support/networkEnums.js";import W from"../rest/support/PointBarrier.js";import V from"../rest/support/PolygonBarrier.js";import H from"../rest/support/PolylineBarrier.js";import K from"../rest/support/RouteInfo.js";import Y from"../rest/support/RouteParameters.js";import z from"../rest/support/RouteSettings.js";import Q from"../rest/support/Stop.js";import Z from"../geometry/SpatialReference.js";import $ from"../geometry/Multipoint.js";function X(e){return e.length?e:null}function ee(e){const{defaultTravelMode:t,supportedTravelModes:r}=e;return r.find((e=>e.id===t))}function te(e){switch(e){case"esriGeometryPoint":return{type:"esriSMS",style:"esriSMSCircle",size:12,color:[0,0,0,0],outline:te("esriGeometryPolyline")};case"esriGeometryPolyline":return{type:"esriSLS",style:"esriSLSSolid",width:1,color:[0,0,0,0]};case"esriGeometryPolygon":return{type:"esriSFS",style:"esriSFSNull",outline:te("esriGeometryPolyline")}}}function re(e){return"layers"in e}function oe(e){return"esri.rest.support.FeatureSet"===e.declaredClass}function ie(e){return"esri.rest.support.NetworkFeatureSet"===e.declaredClass}function se(e,t,r){const o=t.networkDataset.networkAttributes.filter((e=>"cost"===e.usageType)),i=ee(t),s=r.travelMode??i;if(u(s))return void he.warn("route-layer:missing-travel-mode","The routing service must have a default travel mode or one must be specified in the route parameter.");const{timeAttributeName:a,distanceAttributeName:l}=s,m=o.find((e=>e.name===a)),y=o.find((e=>e.name===l)),f=c(r.travelMode)?.impedanceAttributeName??c(r.impedanceAttribute)??t.impedance,d=q.fromJSON(m?.units),h=E.fromJSON(y?.units);if(!d||!h)throw new n("routelayer:unknown-impedance-units","the units of either the distance or time impedance are unknown");const w=r.directionsLanguage??t.directionsLanguage,S=c(r.accumulateAttributes)??t.accumulateAttributeNames??[],g=new Set(o.filter((({name:e})=>e===a||e===l||e===f||S.includes(e))).map((({name:e})=>e))),b=e=>{for(const t in e)g.has(t)||delete e[t]};for(const n of e.pointBarriers)p(n.costs)&&(n.addedCost=n.costs[f]??0,b(n.costs));for(const n of e.polygonBarriers)p(n.costs)&&(n.scaleFactor=n.costs[f]??1,b(n.costs));for(const n of e.polylineBarriers)p(n.costs)&&(n.scaleFactor=n.costs[f]??1,b(n.costs));const{routeInfo:v}=e,{findBestSequence:B,preserveFirstStop:P,preserveLastStop:j,startTimeIsUTC:I,timeWindowsAreUTC:_}=r;v.analysisSettings=new z({accumulateAttributes:S,directionsLanguage:w,findBestSequence:B,preserveFirstStop:P,preserveLastStop:j,startTimeIsUTC:I,timeWindowsAreUTC:_,travelMode:s}),v.totalDuration=ae(v.totalCosts[a]??0,d),v.totalDistance=le(v.totalCosts[l]??0,h),v.totalLateDuration=ae(v.totalViolations[a]??0,d),v.totalWaitDuration=ae(v.totalWait[a]??0,d),p(v.totalCosts)&&b(v.totalCosts),p(v.totalViolations)&&b(v.totalViolations),p(v.totalWait)&&b(v.totalWait);for(const n of e.stops)p(n.serviceCosts)&&(n.serviceDuration=ae(n.serviceCosts[a]??0,d),n.serviceDistance=le(n.serviceCosts[l]??0,h),b(n.serviceCosts)),p(n.cumulativeCosts)&&(n.cumulativeDuration=ae(n.cumulativeCosts[a]??0,d),n.cumulativeDistance=le(n.cumulativeCosts[l]??0,h),b(n.cumulativeCosts)),p(n.violations)&&(n.lateDuration=ae(n.violations[a]??0,d),b(n.violations)),p(n.wait)&&(n.waitDuration=ae(n.wait[a]??0,d),b(n.wait))}async function ne(e){const t=Z.WGS84;return await I(e.spatialReference,t),_(e,t)}function ae(e,t){switch(t){case"seconds":return e/60;case"hours":return 60*e;case"days":return 60*e*24;default:return e}}function le(e,t){return"decimal-degrees"===t||"points"===t||"unknown"===t?e:w(e,t,"meters")}function pe(e){const{attributes:t,geometry:r,popupTemplate:o,symbol:i}=e.toGraphic().toJSON();return{attributes:t,geometry:r,popupInfo:o,symbol:i}}const ue=s.ofType(U),me=s.ofType(M),ce=s.ofType(W),ye=s.ofType(V),fe=s.ofType(H),de=s.ofType(Q),he=l.getLogger("esri.layers.RouteLayer");let we=class extends(D(O(C(R(y(a(L))))))){constructor(e){super(e),this._cachedServiceDescription=null,this._featureCollection=null,this._type="Feature Collection",this.defaultSymbols=new T,this.directionLines=null,this.directionPoints=null,this.featureCollectionType="route",this.legendEnabled=!1,this.maxScale=0,this.minScale=0,this.pointBarriers=new ce,this.polygonBarriers=new ye,this.polylineBarriers=new fe,this.routeInfo=null,this.spatialReference=Z.WGS84,this.stops=new de,this.type="route";const t=()=>{this._setStopSymbol(this.stops)};this.own([h((()=>this.stops),"change",t,{sync:!0,onListenerAdd:t})])}writeFeatureCollectionWebmap(e,t,r,o){const i=[this._writePolygonBarriers(),this._writePolylineBarriers(),this._writePointBarriers(),this._writeRouteInfo(),this._writeDirectionLines(),this._writeDirectionPoints(),this._writeStops()].filter((e=>!!e)),s=i.map(((e,t)=>t)),n="web-map"===o.origin?"featureCollection.layers":"layers";f(n,i,t),t.opacity=this.opacity,t.visibility=this.visible,t.visibleLayers=s}readDirectionLines(e,t){return this._getNetworkFeatures(t,"DirectionLines",(e=>U.fromGraphic(e)))}readDirectionPoints(e,t){return this._getNetworkFeatures(t,"DirectionPoints",(e=>M.fromGraphic(e)))}get fullExtent(){if(p(this.routeInfo)&&p(this.routeInfo.geometry))return this.routeInfo.geometry.extent;const e=new j({xmin:-180,ymin:-90,xmax:180,ymax:90,spatialReference:Z.WGS84}),t=this.stops.filter((e=>p(e.geometry)));if(t.length<2)return e;const{spatialReference:r}=t.getItemAt(0).geometry;if(u(r))return e;const o=t.toArray().map((e=>{const t=e.geometry;return[t.x,t.y]}));return new $({points:o,spatialReference:r}).extent}readMaxScale(e,t){return(re(t)?t.layers:t.featureCollection.layers).find((e=>p(e.layerDefinition.maxScale)))?.layerDefinition.maxScale??0}readMinScale(e,t){return(re(t)?t.layers:t.featureCollection.layers).find((e=>p(e.layerDefinition.minScale)))?.layerDefinition.minScale??0}readPointBarriers(e,t){return this._getNetworkFeatures(t,"Barriers",(e=>W.fromGraphic(e)))}readPolygonBarriers(e,t){return this._getNetworkFeatures(t,"PolygonBarriers",(e=>V.fromGraphic(e)))}readPolylineBarriers(e,t){return this._getNetworkFeatures(t,"PolylineBarriers",(e=>H.fromGraphic(e)))}readRouteInfo(e,t){const r=this._getNetworkFeatures(t,"RouteInfo",(e=>K.fromGraphic(e)));return r.length>0?r.getItemAt(0):null}readSpatialReference(e,t){const r=re(t)?t.layers:t.featureCollection.layers;if(!r.length)return Z.WGS84;const{layerDefinition:o}=r[0],i=o.spatialReference??o.extent.spatialReference??N;return Z.fromJSON(i)}readStops(e,t){return this._getNetworkFeatures(t,"Stops",(e=>Q.fromGraphic(e)),(e=>this._setStopSymbol(e)))}get title(){return p(this.routeInfo)&&p(this.routeInfo.name)?this.routeInfo.name:"Route"}set title(e){e?this._override("title",e):this._clearOverride("title")}get url(){return t.routeServiceUrl}set url(e){null!=e?this._set("url",F(e,he)):this._set("url",t.routeServiceUrl)}load(e){return this.addResolvingPromise(this.loadFromPortal({supportedTypes:["Feature Collection"]},e)),Promise.resolve(this)}removeAll(){this.removeResult(),this.pointBarriers.removeAll(),this.polygonBarriers.removeAll(),this.polylineBarriers.removeAll(),this.stops.removeAll()}removeResult(){p(this.directionLines)&&(this.directionLines.removeAll(),this._set("directionLines",null)),p(this.directionPoints)&&(this.directionPoints.removeAll(),this._set("directionPoints",null)),p(this.routeInfo)&&this._set("routeInfo",null)}async save(){await this.load();const{fullExtent:e,portalItem:t}=this;if(!t)throw new n("routelayer:portal-item-not-set","save() requires to the layer to have a portal item");if(!t.id)throw new n("routelayer:portal-item-not-saved","Please use saveAs() first to save the routelayer");if("Feature Collection"!==t.type)throw new n("routelayer:portal-item-wrong-type",'Portal item needs to have type "Feature Collection"');if(u(this.routeInfo))throw new n("routelayer:route-unsolved","save() requires a solved route");const{portal:r}=t;if(await r._signIn(),r.user||await t.reload(),r.user.username!==t.owner)throw new n("routelayer:not-portal-item-owner","You can only overwrite your portal items");const{itemUrl:o}=t,i={messages:[],origin:"portal-item",portal:r,url:o&&S(o),writtenProperties:[]},s=this.write(null,i);return t.extent=await ne(e),t.title=this.title,await t.update({data:s}),t}async saveAs(e,t={}){if(await this.load(),u(this.routeInfo))throw new n("routelayer:route-unsolved","saveAs() requires a solved route");const r=k.from(e).clone();r.extent??(r.extent=await ne(this.fullExtent)),r.id=null,r.portal??(r.portal=x.getDefault()),r.title??(r.title=this.title),r.type="Feature Collection",r.typeKeywords=["Data","Feature Collection",A.MULTI_LAYER,"Route Layer"];const{portal:o}=r,i={messages:[],origin:"portal-item",portal:o,url:null,writtenProperties:[]};await o._signIn();const s=t?.folder,a=this.write(null,i);return await o.user.addItem({item:r,folder:s,data:a}),this.portalItem=r,P(i),i.portalItem=r,r}async solve(e,t){const r=e?.stops??this.stops,o=e?.pointBarriers??X(this.pointBarriers),i=e?.polylineBarriers??X(this.polylineBarriers),a=e?.polygonBarriers??X(this.polygonBarriers);if(u(r))throw new n("routelayer:undefined-stops","the route layer must have stops defined in the route parameters.");if((oe(r)||ie(r))&&r.features.length<2||s.isCollection(r)&&r.length<2)throw new n("routelayer:insufficent-stops","the route layer must have two or more stops to solve a route.");const l=e?.apiKey,c=this.url,y=await this._getServiceDescription(c,l,t),f=ee(y),h=e?.travelMode??f,w=m(e?.accumulateAttributes,[]);p(h)&&(w.push(h.distanceAttributeName),h.timeAttributeName&&w.push(h.timeAttributeName));const S={startTime:new Date},g={accumulateAttributes:w,directionsOutputType:"featuresets",ignoreInvalidLocations:!0,pointBarriers:o,polylineBarriers:i,polygonBarriers:a,preserveFirstStop:!0,preserveLastStop:!0,returnBarriers:!!o,returnDirections:!0,returnPolygonBarriers:!!a,returnPolylineBarriers:!!i,returnRoutes:!0,returnStops:!0,stops:r},b=e?Y.from(e):new Y;for(const s in S)null==b[s]&&(b[s]=S[s]);let v;b.set(g);try{v=await G(c,b,t)}catch(P){throw d(P)?P:new n("routelayer:failed-route-request","the routing request failed",{error:P})}const B=this._toRouteLayerSolution(v);return this._isOverridden("title")||(this.title=m(B.routeInfo.name,"Route")),se(B,y,b),B}update(e){const{stops:t,directionLines:r,directionPoints:o,pointBarriers:i,polylineBarriers:s,polygonBarriers:n,routeInfo:a}=e;this.set({stops:t,pointBarriers:i,polylineBarriers:s,polygonBarriers:n}),this._set("directionLines",r),this._set("directionPoints",o),this._set("routeInfo",a)}_getNetworkFeatures(e,t,n,a){const l=(re(e)?e.layers:e.featureCollection.layers).find((e=>e.layerDefinition.name===t));if(u(l))return new s;const{layerDefinition:p,popupInfo:m,featureSet:c}=l,y=p.drawingInfo.renderer,{features:f}=c,d=y&&i(y),h=f.map((e=>{const i=r.fromJSON(e),s=n(i);return s.symbol??(s.symbol=d?.getSymbol(i)??this._getNetworkSymbol(t)),s.popupTemplate??(s.popupTemplate=m&&o.fromJSON(m)),s}));return a&&h.some((e=>!e.symbol))&&a(h),new s(h)}_getNetworkSymbol(e){switch(e){case"Barriers":return this.defaultSymbols.pointBarriers;case"DirectionPoints":return this.defaultSymbols.directionPoints;case"DirectionLines":return this.defaultSymbols.directionLines;case"PolylineBarriers":return this.defaultSymbols.polylineBarriers;case"PolygonBarriers":return this.defaultSymbols.polygonBarriers;case"RouteInfo":return this.defaultSymbols.routeInfo;case"Stops":return null}}async _getServiceDescription(e,t,r){if(p(this._cachedServiceDescription)&&this._cachedServiceDescription.url===e)return this._cachedServiceDescription.serviceDescription;const o=await J(e,t,r);return this._cachedServiceDescription={serviceDescription:o,url:e},o}_setStopSymbol(e){if(!e||0===e.length)return;if(u(this.defaultSymbols.stops))return;if(e.every((e=>p(e.symbol))))return;const{first:t,last:r,middle:o,unlocated:i,waypoint:s,break:n}=this.defaultSymbols.stops;if(u(this.routeInfo)||1===e.length)return void e.forEach(((i,s)=>{switch(s){case 0:i.symbol=t;break;case e.length-1:i.symbol=r;break;default:i.symbol=o}}));const a=e.map((e=>e.sequence)).filter((e=>p(e))),l=Math.min(...a),m=Math.max(...a);for(const p of e)p.sequence!==l?p.sequence!==m?"ok"===p.status||"not-located-on-closest"===p.status?"waypoint"!==p.locationType?"break"!==p.locationType?p.symbol=o:p.symbol=n:p.symbol=s:p.symbol=i:p.symbol=r:p.symbol=t}_toRouteLayerSolution(e){const t=e.routeResults[0].stops.map((e=>Q.fromJSON(e.toJSON())));this._setStopSymbol(t);const r=new de(t),o=new ye(e.polygonBarriers?.map((e=>{const t=V.fromJSON(e.toJSON());return t.symbol=this.defaultSymbols.polygonBarriers,t}))),i=new fe(e.polylineBarriers?.map((e=>{const t=H.fromJSON(e.toJSON());return t.symbol=this.defaultSymbols.polylineBarriers,t}))),s=new ce(e.pointBarriers?.map((e=>{const t=W.fromJSON(e.toJSON());return t.symbol=this.defaultSymbols.pointBarriers,t}))),n=K.fromJSON(e.routeResults[0].route.toJSON());n.symbol=this.defaultSymbols.routeInfo;const a=new me(e.routeResults[0].directionPoints?.features.map((e=>{const t=M.fromJSON(e.toJSON());return t.symbol=this.defaultSymbols.directionPoints,t})));return{directionLines:new ue(e.routeResults[0].directionLines?.features.map((e=>{const t=U.fromJSON(e.toJSON());return t.symbol=this.defaultSymbols.directionLines,t}))),directionPoints:a,pointBarriers:s,polygonBarriers:o,polylineBarriers:i,routeInfo:n,stops:r}}_writeDirectionLines(){return this._writeNetworkFeatures(this.directionLines,this.defaultSymbols.directionLines,"esriGeometryPolyline",U.fields,U.popupInfo,"DirectionLines","Direction Lines")}_writeDirectionPoints(){return this._writeNetworkFeatures(this.directionPoints,this.defaultSymbols.directionPoints,"esriGeometryPoint",M.fields,M.popupInfo,"DirectionPoints","Direction Points")}_writeNetworkFeatures(e,t,r,o,i,s,n){return u(e)||!e.length?null:{featureSet:{features:e.toArray().map((e=>pe(e))),geometryType:r},layerDefinition:{capabilities:"Query,Update,Editing",drawingInfo:{renderer:{type:"simple",symbol:p(t)?t.toJSON():te(r)}},extent:this.fullExtent.toJSON(),fields:o,geometryType:r,hasM:!1,hasZ:!1,maxScale:this.maxScale,minScale:this.minScale,name:s,objectIdField:"__OBJECTID",spatialReference:this.spatialReference.toJSON(),title:n,type:"Feature Layer",typeIdField:""},popupInfo:i}}_writePointBarriers(){return this._writeNetworkFeatures(this.pointBarriers,this.defaultSymbols.pointBarriers,"esriGeometryPoint",W.fields,W.popupInfo,"Barriers","Point Barriers")}_writePolygonBarriers(){return this._writeNetworkFeatures(this.polygonBarriers,this.defaultSymbols.polygonBarriers,"esriGeometryPolygon",V.fields,V.popupInfo,"PolygonBarriers","Polygon Barriers")}_writePolylineBarriers(){return this._writeNetworkFeatures(this.polylineBarriers,this.defaultSymbols.polylineBarriers,"esriGeometryPolyline",H.fields,H.popupInfo,"PolylineBarriers","Line Barriers")}_writeRouteInfo(){return this._writeNetworkFeatures(p(this.routeInfo)?new s([this.routeInfo]):null,this.defaultSymbols.routeInfo,"esriGeometryPolyline",K.fields,K.popupInfo,"RouteInfo","Route Details")}_writeStops(){const e=this._writeNetworkFeatures(this.stops,null,"esriGeometryPoint",Q.fields,Q.popupInfo,"Stops","Stops");if(u(e))return null;const{stops:t}=this.defaultSymbols,r=p(t)&&p(t.first)&&t.first.toJSON(),o=p(t)&&p(t.middle)&&t.middle.toJSON(),i=p(t)&&p(t.last)&&t.last.toJSON();return e.layerDefinition.drawingInfo.renderer={type:"uniqueValue",field1:"Sequence",defaultSymbol:o,uniqueValueInfos:[{value:"1",symbol:r,label:"First Stop"},{value:`${this.stops.length}`,symbol:i,label:"Last Stop"}]},e}};e([g({readOnly:!0,json:{read:!1,origins:{"portal-item":{write:{allowNull:!0,ignoreOrigin:!0}},"web-map":{write:{overridePolicy(){return{allowNull:!0,ignoreOrigin:null==this.portalItem}}}}}}})],we.prototype,"_featureCollection",void 0),e([B(["web-map","portal-item"],"_featureCollection")],we.prototype,"writeFeatureCollectionWebmap",null),e([g({readOnly:!0,json:{read:!1,origins:{"web-map":{write:{target:"type",overridePolicy(){return{ignoreOrigin:null!=this.portalItem}}}}}}})],we.prototype,"_type",void 0),e([g({nonNullable:!0,type:T})],we.prototype,"defaultSymbols",void 0),e([g({readOnly:!0})],we.prototype,"directionLines",void 0),e([b(["web-map","portal-item"],"directionLines",["layers","featureCollection.layers"])],we.prototype,"readDirectionLines",null),e([g({readOnly:!0})],we.prototype,"directionPoints",void 0),e([b(["web-map","portal-item"],"directionPoints",["layers","featureCollection.layers"])],we.prototype,"readDirectionPoints",null),e([g({readOnly:!0,json:{read:!1,origins:{"web-map":{write:{ignoreOrigin:!0}}}}})],we.prototype,"featureCollectionType",void 0),e([g({readOnly:!0})],we.prototype,"fullExtent",null),e([g({json:{origins:{"web-map":{name:"featureCollection.showLegend"}},write:!0}})],we.prototype,"legendEnabled",void 0),e([g({type:["show","hide"]})],we.prototype,"listMode",void 0),e([g({type:Number,nonNullable:!0,json:{write:!1}})],we.prototype,"maxScale",void 0),e([b(["web-map","portal-item"],"maxScale",["layers","featureCollection.layers"])],we.prototype,"readMaxScale",null),e([g({type:Number,nonNullable:!0,json:{write:!1}})],we.prototype,"minScale",void 0),e([b(["web-map","portal-item"],"minScale",["layers","featureCollection.layers"])],we.prototype,"readMinScale",null),e([g({type:["ArcGISFeatureLayer"],value:"ArcGISFeatureLayer"})],we.prototype,"operationalLayerType",void 0),e([g({nonNullable:!0,type:s.ofType(W)})],we.prototype,"pointBarriers",void 0),e([b(["web-map","portal-item"],"pointBarriers",["layers","featureCollection.layers"])],we.prototype,"readPointBarriers",null),e([g({nonNullable:!0,type:s.ofType(V)})],we.prototype,"polygonBarriers",void 0),e([b(["web-map","portal-item"],"polygonBarriers",["layers","featureCollection.layers"])],we.prototype,"readPolygonBarriers",null),e([g({nonNullable:!0,type:s.ofType(H)})],we.prototype,"polylineBarriers",void 0),e([b(["web-map","portal-item"],"polylineBarriers",["layers","featureCollection.layers"])],we.prototype,"readPolylineBarriers",null),e([g({readOnly:!0})],we.prototype,"routeInfo",void 0),e([b(["web-map","portal-item"],"routeInfo",["layers","featureCollection.layers"])],we.prototype,"readRouteInfo",null),e([g({type:Z})],we.prototype,"spatialReference",void 0),e([b(["web-map","portal-item"],"spatialReference",["layers","featureCollection.layers"])],we.prototype,"readSpatialReference",null),e([g({nonNullable:!0,type:s.ofType(Q)})],we.prototype,"stops",void 0),e([b(["web-map","portal-item"],"stops",["layers","featureCollection.layers"])],we.prototype,"readStops",null),e([g()],we.prototype,"title",null),e([g({readOnly:!0,json:{read:!1}})],we.prototype,"type",void 0),e([g()],we.prototype,"url",null),we=e([v("esri.layers.RouteLayer")],we);const Se=we;export{Se 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.24/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../chunks/tslib.es6.js";import t from"../request.js";import r from"../core/Error.js";import{clone as o}from"../core/lang.js";import{
|
|
5
|
+
import{_ as e}from"../chunks/tslib.es6.js";import t from"../request.js";import r from"../core/Error.js";import{clone as o}from"../core/lang.js";import{unwrap as s}from"../core/maybe.js";import{MultiOriginJSONMixin as i}from"../core/MultiOriginJSONSupport.js";import{throwIfAbortError as l,createTask as a}from"../core/promiseUtils.js";import{urlToObject as n,addQueryParameters as p,isProtocolRelative as y,normalize as u}from"../core/urlUtils.js";import{property as c}from"../core/accessorSupport/decorators/property.js";import"../core/accessorSupport/ensureType.js";import{reader as m}from"../core/accessorSupport/decorators/reader.js";import{subclass as h}from"../core/accessorSupport/decorators/subclass.js";import{writer as d}from"../core/accessorSupport/decorators/writer.js";import S from"../geometry/Extent.js";import f from"../geometry/SpatialReference.js";import g from"./Layer.js";import{APIKeyMixin as v}from"./mixins/APIKeyMixin.js";import{ArcGISCachedService as j}from"./mixins/ArcGISCachedService.js";import{ArcGISService as _}from"./mixins/ArcGISService.js";import{BlendLayer as b}from"./mixins/BlendLayer.js";import{CustomParametersMixin as w}from"./mixins/CustomParametersMixin.js";import{OperationalLayer as T}from"./mixins/OperationalLayer.js";import{PortalLayer as L}from"./mixins/PortalLayer.js";import{ScaleRangeLayer as I}from"./mixins/ScaleRangeLayer.js";import{checkWebPSupport as U}from"./support/imageUtils.js";import x from"./support/SpriteSource.js";import P from"./support/TileInfo.js";import{loadMetadata as R}from"./support/vectorTileLayerLoader.js";import{createForItemRead as O}from"../portal/support/jsonContext.js";import{parseKnownArcGISOnlineDomain as M}from"../portal/support/urlUtils.js";import{e as V}from"../chunks/persistableUrlUtils.js";import{areSchemasOverlapping as D,unionTileInfos as k}from"../views/2d/engine/vectorTiles/tileInfoUtils.js";import C from"../views/2d/engine/vectorTiles/style/StyleRepository.js";import{getWebGLCapabilities as N}from"../views/webgl/capabilities.js";let B=class extends(b(I(j(_(T(L(w(v(i(g)))))))))){constructor(...e){super(...e),this._spriteSourceMap=new Map,this.currentStyleInfo=null,this.style=null,this.isReference=null,this.operationalLayerType="VectorTileLayer",this.type="vector-tile",this.url=null,this.symbolCollisionBoxesVisible=!1,this.path=null}normalizeCtorArgs(e,t){return"string"==typeof e?{url:e,...t}:e}destroy(){if(this.sourceNameToSource)for(const e of Object.values(this.sourceNameToSource))e?.destroy();this._spriteSourceMap.clear()}async prefetchResources(e){await this.loadSpriteSource(globalThis.devicePixelRatio||1,e)}load(e){const r=this.loadFromPortal({supportedTypes:["Vector Tile Service"],supportsData:!1},e).catch(l).then((async()=>{if(!this.portalItem||!this.portalItem.id)return;const r=`${this.portalItem.itemUrl}/resources/styles/root.json`;(await t(r,{...e,query:{f:"json",...this.customParameters,token:this.apiKey}})).data&&this.read({url:r},O(this.portalItem))})).catch(l).then((()=>this._loadStyle(e)));return this.addResolvingPromise(r),Promise.resolve(this)}get attributionDataUrl(){const e=this.currentStyleInfo,t=e&&e.serviceUrl&&n(e.serviceUrl);if(!t)return null;const r=this._getDefaultAttribution(t.path);return r?p(r,{...this.customParameters,token:this.apiKey}):null}get capabilities(){const e=this.primarySource;return e?e.capabilities:{operations:{supportsExportTiles:!1,supportsTileMap:!1},exportTiles:null}}get fullExtent(){return this.primarySource?.fullExtent||null}get parsedUrl(){return this.serviceUrl?n(this.serviceUrl):null}get serviceUrl(){return this.currentStyleInfo&&this.currentStyleInfo.serviceUrl||null}get spatialReference(){return this.tileInfo&&this.tileInfo.spatialReference||null}get styleUrl(){return this.currentStyleInfo&&this.currentStyleInfo.styleUrl||null}writeStyleUrl(e,t){e&&y(e)&&(e=`https:${e}`);const r=s(M(e));t.styleUrl=V(e,r)}get tileInfo(){const e=[];for(const r in this.sourceNameToSource)e.push(this.sourceNameToSource[r]);let t=this.primarySource?.tileInfo||new P;if(e.length>1)for(let r=0;r<e.length;r++)D(t,e[r].tileInfo)&&(t=k(t,e[r].tileInfo));return t}readVersion(e,t){return t.version?parseFloat(t.version):parseFloat(t.currentVersion)}async loadSpriteSource(e=1,t){if(!this._spriteSourceMap.has(e)){const r=N("2d").maxTextureSize,o=this.currentStyleInfo?.spriteUrl?p(this.currentStyleInfo.spriteUrl,{...this.customParameters,token:this.apiKey}):null,s=new x(o,e,r,this.currentStyleInfo.spriteFormat);await s.load(t),this._spriteSourceMap.set(e,s)}return this._spriteSourceMap.get(e)}async setSpriteSource(e,t="png",r=1,o){const s=N("2d").maxTextureSize,i=e?p(e,{...this.customParameters,token:this.apiKey}):null;if(!i)return null;const a=new x(i,r,s,t);try{return await a.load(o),this._spriteSourceMap.clear(),this._spriteSourceMap.set(r,a),this.currentStyleInfo.spriteUrl=i,this.emit("spriteSource-change",{spriteSource:a}),a}catch(n){l(n)}return null}async loadStyle(e,t){const r=e||this.style||this.url;return this._loadingTask&&"string"==typeof r&&this.url===r||(this._loadingTask?.abort(),this._loadingTask=a((e=>(this._spriteSourceMap.clear(),this._getSourceAndStyle(r,{signal:e}))),t)),this._loadingTask.promise}getStyleLayerId(e){return this.styleRepository.getStyleLayerId(e)}getStyleLayerIndex(e){return this.styleRepository.getStyleLayerIndex(e)}getPaintProperties(e){return o(this.styleRepository.getPaintProperties(e))}setPaintProperties(e,t){const r=this.styleRepository.isPainterDataDriven(e);this.styleRepository.setPaintProperties(e,t);const o=this.styleRepository.isPainterDataDriven(e);this.emit("paint-change",{layer:e,paint:t,isDataDriven:r||o})}getStyleLayer(e){return o(this.styleRepository.getStyleLayer(e))}setStyleLayer(e,t){this.styleRepository.setStyleLayer(e,t),this.emit("style-layer-change",{layer:e,index:t})}deleteStyleLayer(e){this.styleRepository.deleteStyleLayer(e),this.emit("delete-style-layer",{layer:e})}getLayoutProperties(e){return o(this.styleRepository.getLayoutProperties(e))}setLayoutProperties(e,t){this.styleRepository.setLayoutProperties(e,t),this.emit("layout-change",{layer:e,layout:t})}setStyleLayerVisibility(e,t){this.styleRepository.setStyleLayerVisibility(e,t),this.emit("style-layer-visibility-change",{layer:e,visibility:t})}getStyleLayerVisibility(e){return this.styleRepository.getStyleLayerVisibility(e)}write(e,t){return t?.origin&&!this.styleUrl?(t.messages&&t.messages.push(new r("vectortilelayer:unsupported",`VectorTileLayer (${this.title}, ${this.id}) with style defined by JSON only are not supported`,{layer:this})),null):super.write(e,t)}getTileUrl(e,t,r){return null}async _getSourceAndStyle(e,t){if(!e)throw new Error("invalid style!");const r=await R(e,{...t,query:{...this.customParameters,token:this.apiKey}});if("webp"===r.spriteFormat){await U("lossy")||(r.spriteFormat="png")}this._set("currentStyleInfo",{...r}),"string"==typeof e?(this.url=e,this.style=null):(this.url=null,this.style=e),this._set("sourceNameToSource",r.sourceNameToSource),this._set("primarySource",r.sourceNameToSource[r.primarySourceName]),this._set("styleRepository",new C(r.style)),this.read(r.layerDefinition,{origin:"service"}),this.emit("load-style")}_getDefaultAttribution(e){const t=e.match(/^https?:\/\/(?:basemaps|basemapsbeta|basemapsdev)(?:-api)?\.arcgis\.com(\/[^\/]+)?\/arcgis\/rest\/services\/([^\/]+(\/[^\/]+)*)\/vectortileserver/i),r=["OpenStreetMap_v2","OpenStreetMap_Daylight_v2","OpenStreetMap_Export_v2","OpenStreetMap_FTS_v2","OpenStreetMap_GCS_v2","World_Basemap","World_Basemap_v2","World_Basemap_Export_v2","World_Basemap_GCS_v2","World_Basemap_WGS84","World_Contours_v2"];if(!t)return;const o=t[2]&&t[2].toLowerCase();if(!o)return;const s=t[1]||"";for(const i of r)if(i.toLowerCase().includes(o))return u(`//static.arcgis.com/attribution/Vector${s}/${i}`)}async _loadStyle(e){return this._loadingTask?.promise??this.loadStyle(null,e)}};e([c({readOnly:!0})],B.prototype,"attributionDataUrl",null),e([c({type:["show","hide"]})],B.prototype,"listMode",void 0),e([c({json:{read:!0,write:!0}})],B.prototype,"blendMode",void 0),e([c({readOnly:!0,json:{read:!1}})],B.prototype,"capabilities",null),e([c({readOnly:!0})],B.prototype,"currentStyleInfo",void 0),e([c({json:{read:!1},readOnly:!0,type:S})],B.prototype,"fullExtent",null),e([c()],B.prototype,"style",void 0),e([c({type:Boolean,json:{read:!1,write:{enabled:!0,overridePolicy:()=>({enabled:!1})}}})],B.prototype,"isReference",void 0),e([c({type:["VectorTileLayer"]})],B.prototype,"operationalLayerType",void 0),e([c({readOnly:!0})],B.prototype,"parsedUrl",null),e([c({readOnly:!0})],B.prototype,"serviceUrl",null),e([c({type:f,readOnly:!0})],B.prototype,"spatialReference",null),e([c({readOnly:!0})],B.prototype,"styleRepository",void 0),e([c({readOnly:!0})],B.prototype,"sourceNameToSource",void 0),e([c({readOnly:!0})],B.prototype,"primarySource",void 0),e([c({type:String,readOnly:!0,json:{write:{ignoreOrigin:!0},origins:{"web-document":{write:{ignoreOrigin:!0,isRequired:!0}}}}})],B.prototype,"styleUrl",null),e([d(["portal-item","web-document"],"styleUrl")],B.prototype,"writeStyleUrl",null),e([c({json:{read:!1,origins:{service:{read:!1}}},readOnly:!0,type:P})],B.prototype,"tileInfo",null),e([c({json:{read:!1},readOnly:!0,value:"vector-tile"})],B.prototype,"type",void 0),e([c({json:{origins:{"web-document":{read:{source:"styleUrl"}},"portal-item":{read:{source:"url"}}},write:!1,read:!1}})],B.prototype,"url",void 0),e([c({readOnly:!0})],B.prototype,"version",void 0),e([m("version",["version","currentVersion"])],B.prototype,"readVersion",null),e([c({type:Boolean})],B.prototype,"symbolCollisionBoxesVisible",void 0),e([c({type:String,json:{origins:{"web-scene":{read:!0,write:!0}},read:!1}})],B.prototype,"path",void 0),B=e([h("esri.layers.VectorTileLayer")],B);const E=B;export{E 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.24/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../request.js";import{JSONSupportMixin as n}from"../../core/JSONSupport.js";import i from"../../core/Loadable.js";import{isNone as s,unwrap as r}from"../../core/maybe.js";import{property as o}from"../../core/accessorSupport/decorators/property.js";import"../../core/arrayUtils.js";import"../../core/has.js";import"../../core/accessorSupport/ensureType.js";import{subclass as a}from"../../core/accessorSupport/decorators/subclass.js";import{parse as l}from"./arcgisLayerUrl.js";import u from"./Contingency.js";import c from"./ContingencyConstraintViolation.js";import p from"./ContingentValue.js";import d from"./ContingentValuesResult.js";import f from"./FieldGroup.js";import y from"./Subtype.js";var m;let h=m=class extends(n(i)){constructor(e){super(e),this.request=t,this.fieldGroups=null,this.fieldGroupDefinitions=null}initialize(){}static async createLoadedLayerContingentValuesCache(e){await e.load();const t=e.sourceJSON.hasContingentValuesDefinition;if(t)return new m({layer:e}).load();if(void 0===t){const t=l(e.url);if(s(t))return null;const n=t.url.path;if((await m._staticFetchEnterpriseFeatureRoot(n)).supportsQueryDataElements){const t=e.layerId.toString(),i=await m._staticFetchEnterpriseFieldGroup(n,t);if(i){const t=i.map((e=>({name:e.name,isEditingRestrictive:e.isEditingRestrictive,fields:e.fieldNames.names})));return new m({layer:e,fieldGroupDefinitions:t}).load()}}}return null}async load(e){const t=this.layer.load(e).then((()=>this._initializeContingentValues(this.fieldGroupDefinitions,e)));return this.addResolvingPromise(t),this}validateContingencyConstraints(e,t){const n=this.layer.typeIdField,i=Object.keys(e),s=[],r=[];for(const o of this.fieldGroups){const a=o.isEditingRestrictive?"error":"warning";if(t&&!o.fields.some((e=>t.includes(e))))continue;if(!o.fields.every((e=>i.includes(e)))){r.push(new c({fieldGroup:o,type:a}));continue}let l=!1;const u=e[n],p=o.contingencies.filter((e=>!(!e.isRetired&&e.subtype)||e.subtype.code===u));for(const t of p){let n=!0;for(const i in t.values){const s=t.values[i];if("any"!==s.objectType)if("null"===s.objectType){if(null!=e[i]){n=!1;break}}else if("code"===s.objectType){if(e[i]!==s.codedValue.code){n=!1;break}}else if("range"===s.objectType){const t=e[i];if(t<s.minValue||t>s.maxValue){n=!1;break}}}if(n){l=!0;break}}l||s.push(new c({fieldGroup:o,type:a}))}return{invalid:s,incomplete:r}}getContingentValues(e,t,n=!1){const i=e[this.layer.typeIdField],s=null!=i,r={};let o=[];const a=this.fieldGroups.filter((e=>e.fields.includes(t)));o.push(new p({objectType:"any"}));for(const l of a){let a=[];const u=l.contingencies.filter((e=>!(e.isRetired||e.subtype&&s&&e.subtype.code!==i)));let c=!1;const p={};for(const n of u){let i,s=!0;for(const r in n.values){const o=n.values[r];if(t!==r){if(void 0!==e[r]&&"any"!==o.objectType)if("null"===o.objectType)null!==e[r]&&(s=!1);else if("code"===o.objectType)e[r]!==o.codedValue.code&&(s=!1);else if("range"===o.objectType){const t=e[r];(t<o.minValue||t>o.maxValue)&&(s=!1)}}else i=o,c=c||"range"===o.objectType}if(i&&s){if("any"===i.objectType){a.length=0,a.push(i);break}const e=this._generateKey(i);p[e]||a.push(i),p[e]=!0}}c&&(a=this._joinRange(a)),r[l.name]=a,o=n?this._filterIntersection(o,a):null}return 1===a.length&&n&&(o=[]),new d({contingentValuesAllGroups:o,contingentValuesByFieldGroup:r})}_generateKey(e){switch(e.objectType){case"any":return"@any@";case"null":return"@null@";case"code":return e.codedValue.name+e.codedValue.code.toString();case"range":return e.minValue.toString()+"-"+e.maxValue.toString()}}_joinRange(e){let t,n;e.sort(((e,t)=>"null"===e.objectType?-1:"null"===t.objectType?1:e.minValue-t.minValue));const i=[];for(const s of e)"null"!==s.objectType?void 0!==t?n<s.minValue?(i.push(new p({objectType:"range",minValue:t,maxValue:n})),t=s.minValue,n=s.maxValue):n<s.maxValue&&(n=s.maxValue):(t=s.minValue,n=s.maxValue):i.push(s);return i.push(new p({objectType:"range",minValue:t,maxValue:n})),i}_filterIntersection(e,t){if(0===e.length||0===t.length)return[];if("any"===e[0].objectType)return t;if("any"===t[0].objectType)return e;const n="range"===e[0].objectType||"range"===e[1]?.objectType,i="range"===t[0].objectType||"range"===t[1]?.objectType;return n||i?this._intersectRanges(e,t):this._intersectValues(e,t)}_intersectRanges(e,t){const n=[];let i,s=0;for(const r of e)for(;s<t.length;s++){const e=t[s];if("null"===r.objectType&&"null"===e.objectType)n.push(new p({objectType:"null"}));else{if("null"===r.objectType)break;if("null"===e.objectType)continue}if(r.maxValue<e.minValue)break;if(r.maxValue===e.minValue){n.push(new p({objectType:"range",minValue:r.maxValue,maxValue:e.minValue}));break}if(!(r.minValue>e.maxValue))if(r.minValue!==e.maxValue){if(i=r.minValue>e.minValue?r.minValue:e.minValue,r.maxValue<e.maxValue){n.push(new p({objectType:"range",minValue:i,maxValue:r.maxValue}));break}n.push(new p({objectType:"range",minValue:i,maxValue:e.maxValue}))}else n.push(new p({objectType:"range",minValue:r.minValue,maxValue:e.maxValue}))}return n}_intersectValues(e,t){const n=[];for(const i of e)t.some((e=>{if(i.objectType===e.objectType)switch(i.objectType){case"any":case"null":return!0;case"code":return i.codedValue.code===e.codedValue.code&&i.codedValue.name===e.codedValue.name}return!1}))&&n.push(i);return n}static async _staticFetchEnterpriseFeatureRoot(e,n){return t(e,{responseType:"json",query:{f:"json"},...n}).then((e=>e.data))}static async _staticFetchEnterpriseFieldGroup(e,n,i){return t(`${e}/queryDataElements`,{responseType:"json",query:{layers:JSON.stringify([n]),f:"json"},...i}).then((e=>e.data.layerDataElements?.[0].dataElement.fieldGroups))}async _initializeContingentValues(e,t){const n=e||await this._fetchFieldGroupDefs(t);if(0===n.length)return void(this.fieldGroups=[]);const i=await this._fetchContingentValues(n,t);this.fieldGroups=i}async _fetchFieldGroupDefs(e){const t=this.layer.sourceJSON,n=this.layer.layerId.toString(),i=r(l(this.layer.url)).url.path;if(t.hasContingentValuesDefinition){return(await this._fetchAGOLFieldGroup(i,n,e)).map((e=>({name:e.name,isEditingRestrictive:e.restrictive,fields:e.fields.map((e=>this.layer.fieldsIndex.normalizeFieldName(e)))})))}return void 0!==t.hasContingentValuesDefinition?[]:this._fetchEnterpriseFeatureRoot(i,e).then((async t=>{if(t.supportsQueryDataElements){return(await this._fetchEnterpriseFieldGroup(i,n,e)).map((e=>({name:e.name,isEditingRestrictive:e.isEditingRestrictive,fields:e.fieldNames.names.map((e=>this.layer.fieldsIndex.normalizeFieldName(e)))})))}return[]}))}async _fetchAGOLFieldGroup(e,n,i){return t(`${e}/${n}/fieldgroups`,{responseType:"json",query:{f:"json"},...i}).then((e=>e.data.fieldGroups))}async _fetchEnterpriseFieldGroup(e,t,n){return m._staticFetchEnterpriseFieldGroup(e,t,n)}async _fetchEnterpriseFeatureRoot(e,t){return m._staticFetchEnterpriseFeatureRoot(e,t)}async _fetchContingentValues(e,t){const n=this.layer.sourceJSON,i=this.layer.layerId.toString(),s=r(l(this.layer.url)).url.path;if(n.hasContingentValuesDefinition){const n=await this._fetchAGOLContingentValues(s,i,t);return this._constructFieldGroupsAGOL(e,n)}const o=await this._fetchEnterpriseContingentValues(s,i,t);return this._constructFieldGroupsEnterprise(e,o)}_constructFieldGroupsAGOL(e,t){return e.map((e=>{const n=t.contingentValuesDefinition.fieldGroups.find((t=>t.name===e.name));if(n){let i=[];return i=t.contingentValuesDefinition.hasSubType?this._parseAGOLFieldGroupSubtype(e,t,n.subTypes):this._parseAGOLFieldGroup(e,t,n.contingentValues),new f({name:e.name,isEditingRestrictive:e.isEditingRestrictive,fields:e.fields,contingencies:i})}return null})).filter((e=>null!==e))}_parseAGOLFieldGroupSubtype(e,t,n){let i=[];return n.forEach((n=>{const s=this._getSubtypeAGOL(n.name);i=i.concat(this._parseAGOLFieldGroup(e,t,n.contingentValues,s))})),i}_parseAGOLFieldGroup(e,t,n,i=null){const s=[];for(const r of n){const n=this._parseAGOLContingency(r,e,t,i);s.push(n)}return s}_parseAGOLContingency(e,t,n,i){const s=e.id,r=!!e.retired&&1===e.retired,o={};for(let a=0,l=0;a<t.fields.length;a++){const s=t.fields[a],r=n.typeCodes[e.types[a]];if("Code"===r){let t=e.values[l];l++;const r=this._getDomain(i,s);if("string"===this.layer.getField(s).type){const e=n.stringDicts.find((e=>e.domain===r.name));e&&(t=e.entries[t])}const a=r.codedValues.find((e=>e.code===t)),u=new p({codedValue:a,objectType:"code"});o[s]=u}else if("Range"===r){const t=e.values[l];l++;const n=t.range[0],i=t.range[1],r=new p({minValue:n,maxValue:i,objectType:"range"});o[s]=r}else if("Any"===r){const e=new p({objectType:"any"});o[s]=e}else{const e=new p({objectType:"null"});o[s]=e}}return new u({id:s,isRetired:r,subtype:i,values:o})}_constructFieldGroupsEnterprise(e,t){const n=t.fieldGroups;return e.map((e=>{const i=n.find((t=>t.name===e.name));if(i){const n=i.contingencies.map((n=>{const i=n.id,s=n.isRetired||!1,r=this._getSubtypeEnterprise(n.subtypeCode),o={};for(let a=0;a<e.fields.length;a++){const i=e.fields[a];let s=n.values[a];if("number"==typeof s||"string"==typeof s){const e=this._getDomain(r,i),n=this.layer.getField(i);if("string"===n.type)s=t.stringDictionary[s];else if("date"===n.type){const e=new Date(`${s}+00:00`);s=e.getTime()}const a=e.codedValues.find((e=>e.code===s)),l=new p({codedValue:a,objectType:"code"});o[i]=l}else if("object"==typeof s){const e=s.minValue,t=s.maxValue,n=new p({minValue:e,maxValue:t,objectType:"range"});o[i]=n}else if(s){const e=new p({objectType:"any"});o[i]=e}else{const e=new p({objectType:"null"});o[i]=e}}return new u({id:i,isRetired:s,subtype:r,values:o})}));return new f({name:e.name,isEditingRestrictive:e.isEditingRestrictive,fields:e.fields,contingencies:n})}return null})).filter((e=>null!==e))}async _fetchEnterpriseContingentValues(e,n,i){return t(`${e}/queryContingentValues`,{responseType:"json",query:{layers:JSON.stringify([n]),f:"json"},...i}).then((e=>e.data.contingentValueSets?.[0]))}async _fetchAGOLContingentValues(e,n,i){return t(`${e}/${n}/contingentValues`,{responseType:"json",query:{f:"json"},...i}).then((e=>e.data))}_getSubtypeEnterprise(e){const t=this.layer.sourceJSON;let n;if(t.subtypes){const i=t.subtypes.find((t=>t.code===e));n=y.fromJSON(i)}return n||null}_getSubtypeAGOL(e){const t=this.layer.sourceJSON;let n;if(t.subtypes){const i=t.subtypes.find((t=>t.name===e));n=y.fromJSON(i)}return n||null}_getDomain(e,t){const n=e?e.domains[t]:this.layer.getFieldDomain(t);return"inherited"===n.type?this.layer.getFieldDomain(t):n}};e([o({constructOnly:!0})],h.prototype,"layer",void 0),e([o({constructOnly:!0})],h.prototype,"request",void 0),e([o({type:[f]})],h.prototype,"fieldGroups",void 0),e([o()],h.prototype,"fieldGroupDefinitions",void 0),h=m=e([a("esri.layers.support.LayerContingentValuesCache")],h);const g=h;export{g as default};
|
|
5
|
+
import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../request.js";import{JSONSupportMixin as n}from"../../core/JSONSupport.js";import i from"../../core/Loadable.js";import{isNone as s,unwrap as r}from"../../core/maybe.js";import{property as o}from"../../core/accessorSupport/decorators/property.js";import"../../core/arrayUtils.js";import"../../core/has.js";import"../../core/accessorSupport/ensureType.js";import{subclass as a}from"../../core/accessorSupport/decorators/subclass.js";import{parse as l}from"./arcgisLayerUrl.js";import u from"./Contingency.js";import c from"./ContingencyConstraintViolation.js";import p from"./ContingentValue.js";import d from"./ContingentValuesResult.js";import f from"./FieldGroup.js";import y from"./Subtype.js";var m;let h=m=class extends(n(i)){constructor(e){super(e),this.request=t,this.fieldGroups=null,this.fieldGroupDefinitions=null}initialize(){}static async createLoadedLayerContingentValuesCache(e){await e.load();const t=e.sourceJSON;if(void 0===e.layerId)return null;const n=t.hasContingentValuesDefinition;if(n)return new m({layer:e}).load();if(void 0===n){const t=l(e.url);if(s(t))return null;const n=t.url.path;if((await m._staticFetchEnterpriseFeatureRoot(n)).supportsQueryDataElements){const t=e.layerId.toString(),i=await m._staticFetchEnterpriseFieldGroup(n,t);if(i){const t=i.map((e=>({name:e.name,isEditingRestrictive:e.isEditingRestrictive,fields:e.fieldNames.names})));return new m({layer:e,fieldGroupDefinitions:t}).load()}}}return null}async load(e){const t=this.layer.load(e).then((()=>this._initializeContingentValues(this.fieldGroupDefinitions,e)));return this.addResolvingPromise(t),this}validateContingencyConstraints(e,t){const n=this.layer.typeIdField,i=Object.keys(e),s=[],r=[];for(const o of this.fieldGroups){const a=o.isEditingRestrictive?"error":"warning";if(t&&!o.fields.some((e=>t.includes(e))))continue;if(!o.fields.every((e=>i.includes(e)))){r.push(new c({fieldGroup:o,type:a}));continue}let l=!1;const u=e[n],p=o.contingencies.filter((e=>!(!e.isRetired&&e.subtype)||e.subtype.code===u));for(const t of p){let n=!0;for(const i in t.values){const s=t.values[i];if("any"!==s.objectType)if("null"===s.objectType){if(null!=e[i]){n=!1;break}}else if("code"===s.objectType){if(e[i]!==s.codedValue.code){n=!1;break}}else if("range"===s.objectType){const t=e[i];if(t<s.minValue||t>s.maxValue){n=!1;break}}}if(n){l=!0;break}}l||s.push(new c({fieldGroup:o,type:a}))}return{invalid:s,incomplete:r}}getContingentValues(e,t,n=!1){const i=e[this.layer.typeIdField],s=null!=i,r={};let o=[];const a=this.fieldGroups.filter((e=>e.fields.includes(t)));o.push(new p({objectType:"any"}));for(const l of a){let a=[];const u=l.contingencies.filter((e=>!(e.isRetired||e.subtype&&s&&e.subtype.code!==i)));let c=!1;const p={};for(const n of u){let i,s=!0;for(const r in n.values){const o=n.values[r];if(t!==r){if(void 0!==e[r]&&"any"!==o.objectType)if("null"===o.objectType)null!==e[r]&&(s=!1);else if("code"===o.objectType)e[r]!==o.codedValue.code&&(s=!1);else if("range"===o.objectType){const t=e[r];(t<o.minValue||t>o.maxValue)&&(s=!1)}}else i=o,c=c||"range"===o.objectType}if(i&&s){if("any"===i.objectType){a.length=0,a.push(i);break}const e=this._generateKey(i);p[e]||a.push(i),p[e]=!0}}c&&(a=this._joinRange(a)),r[l.name]=a,o=n?this._filterIntersection(o,a):null}return 1===a.length&&n&&(o=[]),new d({contingentValuesAllGroups:o,contingentValuesByFieldGroup:r})}_generateKey(e){switch(e.objectType){case"any":return"@any@";case"null":return"@null@";case"code":return e.codedValue.name+e.codedValue.code.toString();case"range":return e.minValue.toString()+"-"+e.maxValue.toString()}}_joinRange(e){let t,n;e.sort(((e,t)=>"null"===e.objectType?-1:"null"===t.objectType?1:e.minValue-t.minValue));const i=[];for(const s of e)"null"!==s.objectType?void 0!==t?n<s.minValue?(i.push(new p({objectType:"range",minValue:t,maxValue:n})),t=s.minValue,n=s.maxValue):n<s.maxValue&&(n=s.maxValue):(t=s.minValue,n=s.maxValue):i.push(s);return i.push(new p({objectType:"range",minValue:t,maxValue:n})),i}_filterIntersection(e,t){if(0===e.length||0===t.length)return[];if("any"===e[0].objectType)return t;if("any"===t[0].objectType)return e;const n="range"===e[0].objectType||"range"===e[1]?.objectType,i="range"===t[0].objectType||"range"===t[1]?.objectType;return n||i?this._intersectRanges(e,t):this._intersectValues(e,t)}_intersectRanges(e,t){const n=[];let i,s=0;for(const r of e)for(;s<t.length;s++){const e=t[s];if("null"===r.objectType&&"null"===e.objectType)n.push(new p({objectType:"null"}));else{if("null"===r.objectType)break;if("null"===e.objectType)continue}if(r.maxValue<e.minValue)break;if(r.maxValue===e.minValue){n.push(new p({objectType:"range",minValue:r.maxValue,maxValue:e.minValue}));break}if(!(r.minValue>e.maxValue))if(r.minValue!==e.maxValue){if(i=r.minValue>e.minValue?r.minValue:e.minValue,r.maxValue<e.maxValue){n.push(new p({objectType:"range",minValue:i,maxValue:r.maxValue}));break}n.push(new p({objectType:"range",minValue:i,maxValue:e.maxValue}))}else n.push(new p({objectType:"range",minValue:r.minValue,maxValue:e.maxValue}))}return n}_intersectValues(e,t){const n=[];for(const i of e)t.some((e=>{if(i.objectType===e.objectType)switch(i.objectType){case"any":case"null":return!0;case"code":return i.codedValue.code===e.codedValue.code&&i.codedValue.name===e.codedValue.name}return!1}))&&n.push(i);return n}static async _staticFetchEnterpriseFeatureRoot(e,n){return t(e,{responseType:"json",query:{f:"json"},...n}).then((e=>e.data))}static async _staticFetchEnterpriseFieldGroup(e,n,i){return t(`${e}/queryDataElements`,{responseType:"json",query:{layers:JSON.stringify([n]),f:"json"},...i}).then((e=>e.data.layerDataElements?.[0].dataElement.fieldGroups))}async _initializeContingentValues(e,t){const n=e||await this._fetchFieldGroupDefs(t);if(0===n.length)return void(this.fieldGroups=[]);const i=await this._fetchContingentValues(n,t);this.fieldGroups=i}async _fetchFieldGroupDefs(e){if(void 0===this.layer.layerId)return[];const t=this.layer.sourceJSON,n=this.layer.layerId.toString(),i=r(l(this.layer.url)).url.path;if(t.hasContingentValuesDefinition){return(await this._fetchAGOLFieldGroup(i,n,e)).map((e=>({name:e.name,isEditingRestrictive:e.restrictive,fields:e.fields.map((e=>this.layer.fieldsIndex.normalizeFieldName(e)))})))}return void 0!==t.hasContingentValuesDefinition?[]:this._fetchEnterpriseFeatureRoot(i,e).then((async t=>{if(t.supportsQueryDataElements){return(await this._fetchEnterpriseFieldGroup(i,n,e)).map((e=>({name:e.name,isEditingRestrictive:e.isEditingRestrictive,fields:e.fieldNames.names.map((e=>this.layer.fieldsIndex.normalizeFieldName(e)))})))}return[]}))}async _fetchAGOLFieldGroup(e,n,i){return t(`${e}/${n}/fieldgroups`,{responseType:"json",query:{f:"json"},...i}).then((e=>e.data.fieldGroups))}async _fetchEnterpriseFieldGroup(e,t,n){return m._staticFetchEnterpriseFieldGroup(e,t,n)}async _fetchEnterpriseFeatureRoot(e,t){return m._staticFetchEnterpriseFeatureRoot(e,t)}async _fetchContingentValues(e,t){if(void 0===this.layer.layerId)return[];const n=this.layer.sourceJSON,i=this.layer.layerId.toString(),s=r(l(this.layer.url)).url.path;if(n.hasContingentValuesDefinition){const n=await this._fetchAGOLContingentValues(s,i,t);return this._constructFieldGroupsAGOL(e,n)}const o=await this._fetchEnterpriseContingentValues(s,i,t);return this._constructFieldGroupsEnterprise(e,o)}_constructFieldGroupsAGOL(e,t){return e.map((e=>{const n=t.contingentValuesDefinition.fieldGroups.find((t=>t.name===e.name));if(n){let i=[];return i=t.contingentValuesDefinition.hasSubType?this._parseAGOLFieldGroupSubtype(e,t,n.subTypes):this._parseAGOLFieldGroup(e,t,n.contingentValues),new f({name:e.name,isEditingRestrictive:e.isEditingRestrictive,fields:e.fields,contingencies:i})}return null})).filter((e=>null!==e))}_parseAGOLFieldGroupSubtype(e,t,n){let i=[];return n.forEach((n=>{const s=this._getSubtypeAGOL(n.name);i=i.concat(this._parseAGOLFieldGroup(e,t,n.contingentValues,s))})),i}_parseAGOLFieldGroup(e,t,n,i=null){const s=[];for(const r of n){const n=this._parseAGOLContingency(r,e,t,i);s.push(n)}return s}_parseAGOLContingency(e,t,n,i){const s=e.id,r=!!e.retired&&1===e.retired,o={};for(let a=0,l=0;a<t.fields.length;a++){const s=t.fields[a],r=n.typeCodes[e.types[a]];if("Code"===r){let t=e.values[l];l++;const r=this._getDomain(i,s);if("string"===this.layer.getField(s).type){const e=n.stringDicts.find((e=>e.domain===r.name));e&&(t=e.entries[t])}const a=r.codedValues.find((e=>e.code===t)),u=new p({codedValue:a,objectType:"code"});o[s]=u}else if("Range"===r){const t=e.values[l];l++;const n=t.range[0],i=t.range[1],r=new p({minValue:n,maxValue:i,objectType:"range"});o[s]=r}else if("Any"===r){const e=new p({objectType:"any"});o[s]=e}else{const e=new p({objectType:"null"});o[s]=e}}return new u({id:s,isRetired:r,subtype:i,values:o})}_constructFieldGroupsEnterprise(e,t){const n=t.fieldGroups;return e.map((e=>{const i=n.find((t=>t.name===e.name));if(i){const n=i.contingencies.map((n=>{const i=n.id,s=n.isRetired||!1,r=this._getSubtypeEnterprise(n.subtypeCode),o={};for(let a=0;a<e.fields.length;a++){const i=e.fields[a];let s=n.values[a];if("number"==typeof s||"string"==typeof s){const e=this._getDomain(r,i),n=this.layer.getField(i);if("string"===n.type)s=t.stringDictionary[s];else if("date"===n.type){const e=new Date(`${s}+00:00`);s=e.getTime()}const a=e.codedValues.find((e=>e.code===s)),l=new p({codedValue:a,objectType:"code"});o[i]=l}else if("object"==typeof s){const e=s.minValue,t=s.maxValue,n=new p({minValue:e,maxValue:t,objectType:"range"});o[i]=n}else if(s){const e=new p({objectType:"any"});o[i]=e}else{const e=new p({objectType:"null"});o[i]=e}}return new u({id:i,isRetired:s,subtype:r,values:o})}));return new f({name:e.name,isEditingRestrictive:e.isEditingRestrictive,fields:e.fields,contingencies:n})}return null})).filter((e=>null!==e))}async _fetchEnterpriseContingentValues(e,n,i){return t(`${e}/queryContingentValues`,{responseType:"json",query:{layers:JSON.stringify([n]),f:"json"},...i}).then((e=>e.data.contingentValueSets?.[0]))}async _fetchAGOLContingentValues(e,n,i){return t(`${e}/${n}/contingentValues`,{responseType:"json",query:{f:"json"},...i}).then((e=>e.data))}_getSubtypeEnterprise(e){const t=this.layer.sourceJSON;let n;if(t.subtypes){const i=t.subtypes.find((t=>t.code===e));n=y.fromJSON(i)}return n||null}_getSubtypeAGOL(e){const t=this.layer.sourceJSON;let n;if(t.subtypes){const i=t.subtypes.find((t=>t.name===e));n=y.fromJSON(i)}return n||null}_getDomain(e,t){const n=e?e.domains[t]:this.layer.getFieldDomain(t);return"inherited"===n.type?this.layer.getFieldDomain(t):n}};e([o({constructOnly:!0})],h.prototype,"layer",void 0),e([o({constructOnly:!0})],h.prototype,"request",void 0),e([o({type:[f]})],h.prototype,"fieldGroups",void 0),e([o()],h.prototype,"fieldGroupDefinitions",void 0),h=m=e([a("esri.layers.support.LayerContingentValuesCache")],h);const g=h;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.24/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as t}from"../../chunks/tslib.es6.js";import{JSONSupport as e}from"../../core/JSONSupport.js";import{isNone as o}from"../../core/maybe.js";import{property as i}from"../../core/accessorSupport/decorators/property.js";import"../../core/arrayUtils.js";import"../../core/has.js";import"../../core/accessorSupport/ensureType.js";import{subclass as r}from"../../core/accessorSupport/decorators/subclass.js";import s from"../../geometry/Extent.js";import n from"../../geometry/SpatialReference.js";import p from"./RasterStorageInfo.js";let a=class extends e{constructor(t){super(t),this.attributeTable=null,this.bandCount=null,this.colormap=null,this.extent=null,this.format=void 0,this.height=null,this.width=null,this.histograms=null,this.keyProperties={},this.multidimensionalInfo=null,this.noDataValue=null,this.pixelSize=null,this.pixelType=null,this.isPseudoSpatialReference=!1,this.spatialReference=null,this.statistics=null,this.storageInfo=null,this.transform=null}get dataType(){const t=this.keyProperties?.DataType?.toLowerCase()??"generic";return"stdtime"===t?"standard-time":t}get nativeExtent(){return this._get("nativeExtent")||this.extent}set nativeExtent(t){t&&this._set("nativeExtent",t)}get nativePixelSize(){if(o(this.transform)||!this.transform.affectsPixelSize)return this.pixelSize;const t=this.nativeExtent;return{x:t.width/this.width,y:t.height/this.height}}get hasMultidimensionalTranspose(){return!!this.storageInfo?.transposeInfo}};t([i({json:{write:!0}})],a.prototype,"attributeTable",void 0),t([i({json:{write:!0}})],a.prototype,"bandCount",void 0),t([i({json:{write:!0}})],a.prototype,"colormap",void 0),t([i({type:String,readOnly:!0})],a.prototype,"dataType",null),t([i({type:s,json:{write:!0}})],a.prototype,"extent",void 0),t([i({type:s,json:{write:!0}})],a.prototype,"nativeExtent",null),t([i({json:{write:!0}})],a.prototype,"nativePixelSize",null),t([i({json:{write:!0}})],a.prototype,"format",void 0),t([i({json:{write:!0}})],a.prototype,"height",void 0),t([i({json:{write:!0}})],a.prototype,"width",void 0),t([i({json:{write:!0}})],a.prototype,"hasMultidimensionalTranspose",null),t([i({json:{write:!0}})],a.prototype,"histograms",void 0),t([i({json:{write:!0}})],a.prototype,"keyProperties",void 0),t([i({json:{write:!0}})],a.prototype,"multidimensionalInfo",void 0),t([i()],a.prototype,"noDataValue",void 0),t([i({json:{write:!0}})],a.prototype,"pixelSize",void 0),t([i({json:{write:!0}})],a.prototype,"pixelType",void 0),t([i()],a.prototype,"isPseudoSpatialReference",void 0),t([i({type:n,json:{write:!0}})],a.prototype,"spatialReference",void 0),t([i({json:{write:!0}})],a.prototype,"statistics",void 0),t([i({type:p,json:{write:!0}})],a.prototype,"storageInfo",void 0),t([i({json:{write:!0}})],a.prototype,"transform",void 0),a=t([r("esri.layers.support.RasterInfo")],a);const l=a;export{l as default};
|
|
5
|
+
import{_ as t}from"../../chunks/tslib.es6.js";import{JSONSupport as e}from"../../core/JSONSupport.js";import{isNone as o}from"../../core/maybe.js";import{property as i}from"../../core/accessorSupport/decorators/property.js";import"../../core/arrayUtils.js";import"../../core/has.js";import"../../core/accessorSupport/ensureType.js";import{subclass as r}from"../../core/accessorSupport/decorators/subclass.js";import s from"../../geometry/Extent.js";import n from"../../geometry/SpatialReference.js";import p from"./RasterStorageInfo.js";let a=class extends e{constructor(t){super(t),this.attributeTable=null,this.bandCount=null,this.colormap=null,this.extent=null,this.format=void 0,this.height=null,this.width=null,this.histograms=null,this.keyProperties={},this.multidimensionalInfo=null,this.noDataValue=null,this.pixelSize=null,this.pixelType=null,this.isPseudoSpatialReference=!1,this.spatialReference=null,this.statistics=null,this.storageInfo=null,this.transform=null}get dataType(){const t=this.keyProperties?.DataType?.toLowerCase()??"generic";return"stdtime"===t?"standard-time":t}get nativeExtent(){return this._get("nativeExtent")||this.extent}set nativeExtent(t){t&&this._set("nativeExtent",t)}get nativePixelSize(){if(o(this.transform)||!this.transform.affectsPixelSize)return this.pixelSize;const t=this.nativeExtent;return{x:t.width/this.width,y:t.height/this.height}}get hasMultidimensionalTranspose(){return!!this.storageInfo?.transposeInfo}};t([i({json:{write:!0}})],a.prototype,"attributeTable",void 0),t([i({json:{write:!0}})],a.prototype,"bandCount",void 0),t([i({json:{write:!0}})],a.prototype,"colormap",void 0),t([i({type:String,readOnly:!0})],a.prototype,"dataType",null),t([i({type:s,json:{write:!0}})],a.prototype,"extent",void 0),t([i({type:s,json:{write:!0}})],a.prototype,"nativeExtent",null),t([i({json:{write:!0}})],a.prototype,"nativePixelSize",null),t([i({json:{write:!0}})],a.prototype,"format",void 0),t([i({json:{write:!0}})],a.prototype,"height",void 0),t([i({json:{write:!0}})],a.prototype,"width",void 0),t([i({json:{write:!0}})],a.prototype,"hasMultidimensionalTranspose",null),t([i({json:{write:!0}})],a.prototype,"histograms",void 0),t([i({json:{write:!0}})],a.prototype,"keyProperties",void 0),t([i({json:{write:!0}})],a.prototype,"multidimensionalInfo",void 0),t([i({json:{write:!0}})],a.prototype,"noDataValue",void 0),t([i({json:{write:!0}})],a.prototype,"pixelSize",void 0),t([i({json:{write:!0}})],a.prototype,"pixelType",void 0),t([i()],a.prototype,"isPseudoSpatialReference",void 0),t([i({type:n,json:{write:!0}})],a.prototype,"spatialReference",void 0),t([i({json:{write:!0}})],a.prototype,"statistics",void 0),t([i({type:p,json:{write:!0}})],a.prototype,"storageInfo",void 0),t([i({json:{write:!0}})],a.prototype,"transform",void 0),a=t([r("esri.layers.support.RasterInfo")],a);const l=a;export{l 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.24/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as t}from"../../../chunks/tslib.es6.js";import"../../../geometry.js";import
|
|
5
|
+
import{_ as t}from"../../../chunks/tslib.es6.js";import"../../../geometry.js";import s from"../../../core/Error.js";import e from"../../../core/has.js";import{unwrap as r}from"../../../core/maybe.js";import{eachAlways as a,createAbortError as o}from"../../../core/promiseUtils.js";import{property as i}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/arrayUtils.js";import"../../../core/accessorSupport/ensureType.js";import{subclass as n}from"../../../core/accessorSupport/decorators/subclass.js";import m from"./BaseRaster.js";import l from"./InMemoryRaster.js";import{parsePAMInfo as p}from"./pamParser.js";import{getFormat as c}from"../rasterFormats/RasterCodec.js";import{estimateStatisticsFromHistograms as f}from"../rasterFunctions/stretchUtils.js";import u from"../rasterTransforms/PolynomialTransform.js";import h from"../../../geometry/SpatialReference.js";import d from"../../../geometry/Extent.js";let y=class extends m{async open(t){await this.init();const s=await this._fetchData(t);let{spatialReference:e,statistics:r,histograms:a,transform:o}=await this._fetchAuxiliaryData(t);const i=!e;i&&(e=new h({wkid:3857})),a?.length&&null==r&&(r=f(a));const{width:n,height:m}=s;let p=new d({xmin:-.5,ymin:.5-m,xmax:n-.5,ymax:.5,spatialReference:e});const c=o?o.forwardTransform(p):p;let u=!0;if(o){const t=o.forwardCoefficients;u=t&&0===t[1]&&0===t[2],u&&(o=null,p=c)}const y=new l({data:{extent:c,nativeExtent:p,transform:o,pixelBlock:s,statistics:r,histograms:a,keyProperties:{DateType:"Processed"},isPseudoSpatialReference:i}});await y.open(),y.data=null,this._set("rasterInfo",y.rasterInfo),this._inMemoryRaster=y}fetchRawTile(t,s,e,r={}){return this._inMemoryRaster.fetchRawTile(t,s,e,r)}async _fetchData(t){const{data:r}=await this.request(this.url,{responseType:"array-buffer",signal:t?.signal}),a=c(r).toUpperCase();if("JPG"!==a&&"PNG"!==a&&"GIF"!==a&&"BMP"!==a)throw new s("image-aux-raster:open","the data is not a supported format");this._set("datasetFormat",a);const o=a.toLowerCase(),i="gif"===o||"bmp"===o||!e("ios");return await this.decodePixelBlock(r,{format:o,useCanvas:i,hasNoZlibMask:!0})}async _fetchAuxiliaryData(t){const s=r(t?.signal),e=this.ioConfig.skipExtensions??[],i=e.includes("aux.xml")?null:this.request(this.url+".aux.xml",{responseType:"xml",signal:s}),n=this.datasetFormat,m="JPG"===n?"jgw":"PNG"===n?"pgw":"BMP"===n?"bpw":null,l=e.includes(m)?null:this.request(this.url.slice(0,this.url.lastIndexOf("."))+"."+m,{responseType:"text",signal:s}),c=await a([i,l]);if(s?.aborted)throw o();const f=p(c[0].value?.data);if(!f.transform){const t=c[1].value?c[1].value.data.split("\n").slice(0,6).map((t=>Number(t))):null;f.transform=6===t?.length?new u({forwardCoefficients:[t[4],t[5],t[0],-t[1],t[2],-t[3]]}):null}return f}};t([i({type:String,json:{write:!0}})],y.prototype,"datasetFormat",void 0),y=t([n("esri.layers.support.rasterDatasets.ImageAuxRaster")],y);const w=y;export{w 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.24/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as t}from"../../../chunks/tslib.es6.js";import"../../../geometry.js";import e from"../../../core/Error.js";import{isSome as s}from"../../../core/maybe.js";import{eachAlways as r}from"../../../core/promiseUtils.js";import{property as i}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/arrayUtils.js";import"../../../core/has.js";import"../../../core/accessorSupport/ensureType.js";import{subclass as o}from"../../../core/accessorSupport/decorators/subclass.js";import a from"../RasterInfo.js";import m from"./BaseRaster.js";import{split as n}from"../rasterFunctions/pixelUtils.js";import{estimateStatisticsHistograms as l}from"../rasterFunctions/stretchUtils.js";import p from"../../../geometry/Extent.js";import c from"../../../geometry/SpatialReference.js";let h=class extends m{constructor(){super(...arguments),this.datasetFormat="MEMORY"}async open(t){await this.init();const{pixelBlock:e,statistics:s,histograms:r,name:i,keyProperties:o,nativeExtent:m,transform:n}=this.data,{width:l,height:h,pixelType:f}=e,d=this.data.extent||new p({xmin:-.5,ymin:.5,xmax:l-.5,ymax:h-.5,spatialReference:new c({wkid:3857})}),u=this.data.isPseudoSpatialReference??!this.data.extent,y={x:d.width/l,y:d.height/h},x=new a({width:l,height:h,pixelType:f,extent:d,nativeExtent:m,transform:n,pixelSize:y,spatialReference:d.spatialReference,bandCount:3,keyProperties:o||{},statistics:s,isPseudoSpatialReference:u,histograms:r});this.createRemoteDatasetStorageInfo(x,512,512),this._set("rasterInfo",x),this.updateTileInfo(),await this._buildInMemoryRaster(e,{width:512,height:512},t),this.datasetName=i,this.url="/InMemory/"+i}fetchRawTile(t,e,s,r={}){const i=this._pixelBlockTiles.get(`${t}/${e}/${s}`);return Promise.resolve(i)}async _buildInMemoryRaster(t,i,o){const a=this.rasterInfo.storageInfo.maximumPyramidLevel,m=this.rasterJobHandler?this.rasterJobHandler.split({pixelBlock:t,tileSize:i,maximumPyramidLevel:a},o):Promise.resolve(n(t,i,a)),p=s(this.rasterInfo.statistics),c=s(this.rasterInfo.histograms),h=p
|
|
5
|
+
import{_ as t}from"../../../chunks/tslib.es6.js";import"../../../geometry.js";import e from"../../../core/Error.js";import{isSome as s}from"../../../core/maybe.js";import{eachAlways as r}from"../../../core/promiseUtils.js";import{property as i}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/arrayUtils.js";import"../../../core/has.js";import"../../../core/accessorSupport/ensureType.js";import{subclass as o}from"../../../core/accessorSupport/decorators/subclass.js";import a from"../RasterInfo.js";import m from"./BaseRaster.js";import{split as n}from"../rasterFunctions/pixelUtils.js";import{estimateStatisticsHistograms as l}from"../rasterFunctions/stretchUtils.js";import p from"../../../geometry/Extent.js";import c from"../../../geometry/SpatialReference.js";let h=class extends m{constructor(){super(...arguments),this.datasetFormat="MEMORY"}async open(t){await this.init();const{pixelBlock:e,statistics:s,histograms:r,name:i,keyProperties:o,nativeExtent:m,transform:n}=this.data,{width:l,height:h,pixelType:f}=e,d=this.data.extent||new p({xmin:-.5,ymin:.5,xmax:l-.5,ymax:h-.5,spatialReference:new c({wkid:3857})}),u=this.data.isPseudoSpatialReference??!this.data.extent,y={x:d.width/l,y:d.height/h},x=new a({width:l,height:h,pixelType:f,extent:d,nativeExtent:m,transform:n,pixelSize:y,spatialReference:d.spatialReference,bandCount:3,keyProperties:o||{},statistics:s,isPseudoSpatialReference:u,histograms:r});this.createRemoteDatasetStorageInfo(x,512,512),this._set("rasterInfo",x),this.updateTileInfo(),await this._buildInMemoryRaster(e,{width:512,height:512},t),this.datasetName=i,this.url="/InMemory/"+i}fetchRawTile(t,e,s,r={}){const i=this._pixelBlockTiles.get(`${t}/${e}/${s}`);return Promise.resolve(i)}async _buildInMemoryRaster(t,i,o){const a=this.rasterInfo.storageInfo.maximumPyramidLevel,m=this.rasterJobHandler?this.rasterJobHandler.split({pixelBlock:t,tileSize:i,maximumPyramidLevel:a},o):Promise.resolve(n(t,i,a)),p=s(this.rasterInfo.statistics),c=s(this.rasterInfo.histograms),h=p?Promise.resolve({statistics:null,histograms:null}):this.rasterJobHandler?this.rasterJobHandler.estimateStatisticsHistograms({pixelBlock:t},o):Promise.resolve(l(t)),f=await r([m,h]);if(!f[0].value&&f[1].value)throw new e("inmemory-raster:open","failed to build in memory raster");this._pixelBlockTiles=f[0].value,p||(this.rasterInfo.statistics=f[1].value?.statistics),c||(this.rasterInfo.histograms=f[1].value?.histograms)}};t([i({type:String,json:{write:!0}})],h.prototype,"datasetFormat",void 0),t([i()],h.prototype,"data",void 0),h=t([o("esri.layers.support.rasterDatasets.InMemoryRaster")],h);const f=h;export{f 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.24/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../chunks/tslib.es6.js";import"../../../geometry.js";import t from"../../../core/Error.js";import{isSome as i,isNone as s,unwrap as n}from"../../../core/maybe.js";import{isAbortError as o}from"../../../core/promiseUtils.js";import{property as r}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/arrayUtils.js";import"../../../core/has.js";import"../../../core/accessorSupport/ensureType.js";import{subclass as a}from"../../../core/accessorSupport/decorators/subclass.js";import{isAxesOrderReversedForWkid as l}from"../../ogc/crsUtils.js";import c from"../DimensionalDefinition.js";import p from"./BaseRaster.js";import{parse as d}from"./multipartParser.js";import{parseCapabilities as h}from"./wcsCapabilitiesParser.js";import{standardizeInterpolations as u,parseCoverages as f}from"./wcsCoverageParser.js";import{clip as g}from"../rasterFunctions/pixelUtils.js";import m from"../../../geometry/Extent.js";const v=["nearest neighbor","bilinear","bicubic"],w=["nearest","linear","cubic"];let x=class extends p{constructor(){super(...arguments),this.datasetFormat="WCSServer"}async open(e){await this.init();const i=e?.signal,s=await this._getCapabilities(i);if(this.capabilities=s,!this.version){let e=s.capabilitiesVersion?.slice(0,3);"2.0"===e||"1.1"===e||"1.0"===e?this.version=s.capabilitiesVersion:(e=s.supportedVersions.find((e=>"2.0.1"===e))||s.supportedVersions.find((e=>"2.0"===e.slice(0,3)))||s.supportedVersions.find((e=>"1.1"===e.slice(0,3)))||s.supportedVersions.find((e=>"1.0"===e.slice(0,3)))||"1.0.0",this.version=e)}null==this.coverageId&&(this.coverageId=s.coverages[0].id);const n=s.coverages.find((e=>e.id===this.coverageId));if(null==n)throw new t("wcsraster-open",`the coverageId ${this.coverageId} does not exist in capabilities`);const o=await this._describeCoverage(i);this.coverageInfo=o[0],"2.0"===this.version.slice(0,3)&&(this.coverageInfo.lonLatEnvelope=n.lonLatEnvelope,this.coverageInfo.supportedInterpolations=u(s.supportedInterpolations)),this.datasetName=this.coverageInfo.title;const{rasterInfo:r}=this.coverageInfo;if(this.createRemoteDatasetStorageInfo(r,512,512),this._set("rasterInfo",r),null==r.spatialReference)throw new t("wcsraster-open",`coverage without spatial referernce is not supported: ${this.coverageId}`);const{pixelType:a,bandCount:l}=await this._getPixelTypeAndBandCount(i);r.pixelType=a,1===r.bandCount&&l>1&&(r.bandCount=l),this.updateTileInfo()}async fetchRawTile(e,n,o,r={}){if(this.isBlockOutside(e,n,o))return null;const{nativePixelSize:a,spatialReference:l}=this.rasterInfo,c=2**e,p=a.x*c,d=a.y*c,{blockWidth:h,blockHeight:u}=this.getBlockWidthHeight(e),{origin:f}=this.rasterInfo.storageInfo.tileInfo,m=this.getTileExtent({x:p,y:d},n,o,f,l,[h,u]),v=this.rasterInfo.extent,w=m.xmax>v.xmax||m.ymin<v.ymin;let x=m,y=h,I=u;if(w&&(x=m.clone().intersection(v),i(x)&&(y=Math.floor((x.xmax-x.xmin)/p),I=Math.floor((x.ymax-x.ymin)/d),x.xmax=x.xmin+p*y,x.ymin=x.ymax-d*I)),s(x)||y<=1||I<=1)return null;const b=await this._getCoverage(x,y,I,c,r);if(!b)return null;const C=await this.decodePixelBlock(b,{width:y,height:I,planes:null,pixelType:null});if(C&&(C.width!==y||C.height!==I))throw new t("wcsraster-fetch",`the reponse has unexpected dimension width: ${C.width}, height: {pixelBlock.height}`);return w?g(C,{x:0,y:0},{width:u,height:u}):C}async _getCapabilities(e){const i={service:"WCS",request:"GetCapabilities"};this.version&&(i.version=this.version,i.acceptVersions=this.version);try{const{data:t}=await this.request(this.url,{query:i,responseType:"xml",signal:e});return h(t)}catch(s){if(!o(s))throw new t("wcslayer:open","wcs capabilities is not valid or supported");throw s}}async _describeCoverage(e){const i={service:"WCS",request:"DescribeCoverage",version:this.version},s=this.version.slice(0,3);"1.0"===s?i.coverage=this.coverageId:"1.1"===s?i.identifiers=this.coverageId:"2.0"===s&&(i.coverageId=this.coverageId);try{const{data:t}=await this.request(this.url,{query:i,responseType:"xml",signal:e});return f(t,this.version)}catch(n){if(!o(n))throw new t("wcslayer:open","wcs coverage description is not valid or supported");throw n}}async _getPixelTypeAndBandCount(e){const{pixelSize:s,extent:o,multidimensionalInfo:r}=this.rasterInfo,a=o.center,l=new m({xmin:a.x-s.x,xmax:a.x+s.x,ymin:a.y-s.y,ymax:a.y+s.y,spatialReference:o.spatialReference});let p;if(i(r)){const e=r.variables[0];p=[],e.dimensions.forEach((t=>{p.push(new c({variableName:e.name,dimensionName:t.name,values:t.hasRegularIntervals?t.extent[0]:t.values[0],isSlice:!0}))}))}const d=await this._getCoverage(l,2,2,1,{multidimensionalDefinition:p,signal:n(e)});if(!d)throw new t("wcsraster-open","unable to determine pixel type");const h=await this.decodePixelBlock(d,{width:2,height:2,planes:null,pixelType:null});return{pixelType:h.pixelType,bandCount:h.getPlaneCount()}}async _getCoverage(e,i,s,n,o){const{coverageDescription:r}=this.coverageInfo,{version:a}=r,l="2.0"===r.version?this._getCoverage201Parameters(e,i,s,n,o,r):"1.1"===r.version?this._getCoverage110Parameters(e,i,s,o,r):this._getCoverage100Parameters(e,i,s,o),c="2.0"===r.version?await this.request(this._constructWCS201Url(l),{signal:o.signal,responseType:"array-buffer"}):await this.request(this.url,{query:l,signal:o.signal,responseType:"array-buffer"});if("1.0"===a)return c.data;const p=d(c);if(p.isMultipart&&p.data){return p.data.find((e=>e.contentType?.toLowerCase().includes("image")&&null!=e.contentData))?.contentData}if(this.ioConfig.allowAnyMediaType)return c.data;throw new t("wcsraster:getcoverage","response is not a valid coverage, multipart response is expected")}_getInterpolationIndex(e){return this.coverageInfo.supportedInterpolations.includes(e)?"nearest"===e?0:"bilinear"===e?1:"cubic"===e?2:0:0}_getCoverage100Parameters(e,t,i,s){const n=`${e.xmin},${e.ymin},${e.xmax},${e.ymax}`,o=e.spatialReference.wkid,r=(this.coverageInfo.supportedFormats||[]).find((e=>e.toLowerCase().includes("tiff")))||"GEOTIFF",{bandIds:a,interpolation:l}=s,c=this._getInterpolationIndex(l),p=a?a.map((e=>this.coverageInfo.bandNames[e])):null,d=v[c];return{service:"WCS",request:"GetCoverage",version:this.version,coverage:this.coverageId,format:r,crs:`EPSG:${o}`,bbox:n,width:t,height:i,interpolation:d,band:p?.join(",")}}_getCoverage110Parameters(e,t,s,n,o){const{multidimensionalDefinition:r,bandIds:a,interpolation:c}=n,p=e.spatialReference.wkid,d=`urn:ogc:def:crs:EPSG::${p}`,h=(this.coverageInfo.supportedFormats||[]).find((e=>e.toLowerCase().includes("tiff")))||"image/tiff",u=this._getInterpolationIndex(c),f=w[u],g=null==c||0===this.coverageInfo.supportedInterpolations?.indexOf(c),m=o.domain.spatialDomain,v=m.origin.x<=m.envelope.xmin&&m.origin.y<=m.envelope.ymin,x=e.width/t,y=e.height/s*(v?1:-1),I=v?[e.xmin,e.ymin]:[e.xmin,e.ymax],b=m.useEPSGAxis&&l(p),C=b?`${I[1]},${I[0]}`:`${I[0]},${I[1]}`,$=b?`${y},0,0,${x}`:`${x},0,0,${y}`,S=x/2,j=e.xmin+S,T=e.xmax-S,_=Math.abs(y)/2,P=e.ymin+_,L=e.ymax-_,E=b?`${P},${j},${L},${T},${d}`:`${j},${P},${T},${L},${d}`,R=o.range.find((e=>e.axis.some((e=>e.identifier.toLowerCase().includes("band")))));let q,k=R&&f&&a?g?`${R.identifier}[${R.axis[0].identifier}[${a.join(",")}]]`:`${R.identifier}:${f}[${R.axis[0].identifier}[${a.join(",")}]]`:null;if(i(r)&&r.length)for(let i=0;i<r.length;i++){let e=r[i].values;const t=r[i].dimensionName.toLowerCase(),s=r[i].variableName.toLowerCase();if(e.length>0)if(e[0]instanceof Array&&(e=e[0]),"stdtime"===t)q=e.map((e=>this._convertToISOTime(e))).join(",");else{const i=o.range.find((e=>e.identifier.toLowerCase()===s));if(i){const s=i.axis.find((e=>e.identifier.toLowerCase()===t));s&&(k=g?i.identifier+"["+s.identifier+"["+e.join(",")+"]]":i.identifier+":"+f+"["+s.identifier+"["+e.join(",")+"]]")}}}return{service:"WCS",request:"GetCoverage",version:this.version,identifier:this.coverageId,format:h,crs:`EPSG:${p}`,boundingbox:E,gridCS:"urn:ogc:def:cs:OGC:0.0:Grid2dSquareCS",gridType:"urn:ogc:def:method:WCS:1.1:2dGridIn2dCrs",gridOrigin:C,gridOffsets:$,gridBaseCRS:d,timeSequence:q,rangeSubset:k}}_convertToISOTime(e,t=!1){return(t?new Date(24*(e-25569)*60*60*1e3):new Date(e)).toISOString()}_getCoverage201Parameters(e,t,s,n,o,r){const{multidimensionalDefinition:a,interpolation:l}=o,c=this._getInterpolationIndex(l);let p=null;const{supportedInterpolations:d}=this.capabilities;if(d?.length)switch(c){case 0:p=d.find((e=>e.includes("nearest")));break;case 1:p=d.find((e=>e.includes("linear")));break;case 2:p=d.find((e=>e.includes("cubic")||e.includes("quadratic")))}const h=(this.coverageInfo.supportedFormats||[]).find((e=>e.toLowerCase().includes("tiff")))||"image/tiff",{bandNames:u}=this.coverageInfo,{boundedBy:f,domainSet:g,rangeType:m}=r,v=f.isEastFirst?0:1,w=1-v,{axisLabels:x}=f,y=x[v],I=x[w],b=`http://www.opengis.net/def/crs/EPSG/0/${e.spatialReference.wkid}`,C=b,$=[];$.push(`${y}(${e.xmin},${e.xmax})`),$.push(`${I}(${e.ymin},${e.ymax})`);const S=[];if(x.length>2)for(let i=2;i<x.length;i++){const e=g.origin[i];if(x[i].toLowerCase().includes("time")){let t=e.toString();f.uomLabels[i].toLowerCase().includes("ole")&&(S.push(x[i]),t=this._convertToISOTime(e,!0)),$.push(x[i]+",http://www.opengis.net("+t+")")}else $.push(x[i]+",http://www.opengis.net("+e+")")}let j=null;if(i(a)&&a.length){const e=[];m.forEach((t=>t.forEach((t=>e.push(t.name)))));const t=[];for(let i=0;i<a.length;i++){const s=x.find((e=>e===a[i].dimensionName)),n=e.find((e=>e===a[i].variableName));if(t.includes(n)||t.push(n),s){let e=a[i].values;if(e.length>0){Array.isArray(e[0])&&(e=e[0]);let t="";t=s.toLowerCase().includes("time")?e.map((e=>this._convertToISOTime(e))).join(","):e.join(",");const i=$.findIndex((e=>0===e.indexOf(s+",http://www.opengis.net")));-1===i&&$.push(s+",http://www.opengis.net("+t+")"),-1===i||$[i].includes("("+t+")")||$.splice(i,1,s+",http://www.opengis.net("+t+")")}}}t.length&&(j=t.join(","))}else if(u?.length){j=(o.bandIds?o.bandIds.map((e=>u[e])):u).join(",")}const T=$.join("&subset="),_=!(r.domainSet.axisLabels.join("")===r.boundedBy.axisLabels.join(""))&&!1!==this.ioConfig.allowScaleFactor,P=_?null:`${y}(${t}),${I}(${s})`,L=_?1/n:null;return{service:"WCS",request:"GetCoverage",version:this.version,coverageId:this.coverageId,rangesubset:j,interpolation:p,scaleSize:P,scaleFactor:L,subset:T,format:h,mediaType:this.ioConfig.allowAnyMediaType?null:"multipart/related",outputcrs:b,subsettingcrs:C}}_constructWCS201Url(e){const t={...this.ioConfig.customFetchParameters,...e},i=[];Object.keys(t).forEach((e=>{const s=t[e];null!=s&&("subset"===e?s.split("&subset=").forEach((e=>{e&&i.push(`subset=${encodeURIComponent(e)}`)})):i.push(`${e}=${encodeURIComponent(s)}`))}));return`${encodeURI(this.url)}?${i.join("&")}`}};e([r({type:String,json:{write:!0}})],x.prototype,"datasetFormat",void 0),e([r()],x.prototype,"tileType",void 0),e([r({type:String,json:{write:!0}})],x.prototype,"version",void 0),e([r({type:String,json:{write:!0}})],x.prototype,"coverageId",void 0),x=e([a("esri.layers.support.rasterDatasets.ImageServerRaster")],x);const y=x;export{y as default};
|
|
5
|
+
import{_ as e}from"../../../chunks/tslib.es6.js";import"../../../geometry.js";import i from"../../../core/Error.js";import{isSome as t,isNone as s,unwrap as n}from"../../../core/maybe.js";import{isAbortError as o}from"../../../core/promiseUtils.js";import{property as r}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/arrayUtils.js";import"../../../core/has.js";import"../../../core/accessorSupport/ensureType.js";import{subclass as a}from"../../../core/accessorSupport/decorators/subclass.js";import{isAxesOrderReversedForWkid as l}from"../../ogc/crsUtils.js";import c from"../DimensionalDefinition.js";import p from"./BaseRaster.js";import{parse as d}from"./multipartParser.js";import{parseCapabilities as h}from"./wcsCapabilitiesParser.js";import{standardizeInterpolations as u,parseCoverages as f}from"./wcsCoverageParser.js";import{clip as g}from"../rasterFunctions/pixelUtils.js";import m from"../../../geometry/Extent.js";const v=["nearest neighbor","bilinear","bicubic"],w=["nearest","linear","cubic"];let y=class extends p{constructor(){super(...arguments),this.datasetFormat="WCSServer"}async open(e){await this.init();const t=e?.signal,s=await this._getCapabilities(t);if(this.capabilities=s,!this.version){let e=s.capabilitiesVersion?.slice(0,3);"2.0"===e||"1.1"===e||"1.0"===e?this.version=s.capabilitiesVersion:(e=s.supportedVersions.find((e=>"2.0.1"===e))||s.supportedVersions.find((e=>"2.0"===e.slice(0,3)))||s.supportedVersions.find((e=>"1.1"===e.slice(0,3)))||s.supportedVersions.find((e=>"1.0"===e.slice(0,3)))||"1.0.0",this.version=e)}null==this.coverageId&&(this.coverageId=s.coverages[0].id);const n=s.coverages.find((e=>e.id===this.coverageId));if(null==n)throw new i("wcsraster-open",`the coverageId ${this.coverageId} does not exist in capabilities`);const o=await this._describeCoverage(t);this.coverageInfo=o[0],"2.0"===this.version.slice(0,3)&&(this.coverageInfo.lonLatEnvelope=n.lonLatEnvelope,this.coverageInfo.supportedInterpolations=u(s.supportedInterpolations)),this.datasetName=this.coverageInfo.title;const{rasterInfo:r}=this.coverageInfo;if(this.createRemoteDatasetStorageInfo(r,512,512),this._set("rasterInfo",r),null==r.spatialReference)throw new i("wcsraster-open",`coverage without spatial referernce is not supported: ${this.coverageId}`);const{pixelType:a,bandCount:l}=await this._getPixelTypeAndBandCount(t);r.pixelType=a,1===r.bandCount&&l>1&&(r.bandCount=l),this.updateTileInfo()}async fetchRawTile(e,n,o,r={}){if(this.isBlockOutside(e,n,o))return null;const{nativePixelSize:a,spatialReference:l}=this.rasterInfo,c=2**e,p=a.x*c,d=a.y*c,{blockWidth:h,blockHeight:u}=this.getBlockWidthHeight(e),{origin:f}=this.rasterInfo.storageInfo.tileInfo,m=this.getTileExtent({x:p,y:d},n,o,f,l,[h,u]),v=this.rasterInfo.extent,w=m.xmax>v.xmax||m.ymin<v.ymin;let y=m,x=h,I=u;if(w&&(y=m.clone().intersection(v),t(y)&&(x=Math.floor((y.xmax-y.xmin)/p),I=Math.floor((y.ymax-y.ymin)/d),y.xmax=y.xmin+p*x,y.ymin=y.ymax-d*I)),s(y)||x<=1||I<=1)return null;const b=await this._getCoverage(y,x,I,c,r);if(!b)return null;const{coverageDescription:C}=this.coverageInfo;let{noDataValue:$,multidimensionalInfo:S}=this.rasterInfo;const{multidimensionalDefinition:j}=r;if(t(S)&&t(j)&&j.length){const e=j[0].variableName;if("2.0"===C.version){$=C.rangeType[0].find((i=>i.name===e))?.nilValue}else if("1.1"===C.version){$=C.range.find((i=>i.identifier===e))?.nullValues}}const T=await this.decodePixelBlock(b,{width:x,height:I,planes:null,pixelType:null,noDataValue:Array.isArray($)?$[0]:$});if(T&&(T.width!==x||T.height!==I))throw new i("wcsraster-fetch",`the reponse has unexpected dimension width: ${T.width}, height: {pixelBlock.height}`);return w?g(T,{x:0,y:0},{width:u,height:u}):T}async _getCapabilities(e){const t={service:"WCS",request:"GetCapabilities"};this.version&&(t.version=this.version,t.acceptVersions=this.version);try{const{data:i}=await this.request(this.url,{query:t,responseType:"xml",signal:e});return h(i)}catch(s){if(!o(s))throw new i("wcslayer:open","wcs capabilities is not valid or supported");throw s}}async _describeCoverage(e){const t={service:"WCS",request:"DescribeCoverage",version:this.version},s=this.version.slice(0,3);"1.0"===s?t.coverage=this.coverageId:"1.1"===s?t.identifiers=this.coverageId:"2.0"===s&&(t.coverageId=this.coverageId);try{const{data:i}=await this.request(this.url,{query:t,responseType:"xml",signal:e});return f(i,this.version)}catch(n){if(!o(n))throw new i("wcslayer:open","wcs coverage description is not valid or supported");throw n}}async _getPixelTypeAndBandCount(e){const{pixelSize:s,extent:o,multidimensionalInfo:r}=this.rasterInfo,a=o.center,l=new m({xmin:a.x-s.x,xmax:a.x+s.x,ymin:a.y-s.y,ymax:a.y+s.y,spatialReference:o.spatialReference});let p;if(t(r)){const e=r.variables[0];p=[],e.dimensions.forEach((i=>{p.push(new c({variableName:e.name,dimensionName:i.name,values:i.hasRegularIntervals?i.extent[0]:i.values[0],isSlice:!0}))}))}const d=await this._getCoverage(l,2,2,1,{multidimensionalDefinition:p,signal:n(e)});if(!d)throw new i("wcsraster-open","unable to determine pixel type");const h=await this.decodePixelBlock(d,{width:2,height:2,planes:null,pixelType:null});return{pixelType:h.pixelType,bandCount:h.getPlaneCount()}}async _getCoverage(e,t,s,n,o){const{coverageDescription:r}=this.coverageInfo,{version:a}=r,l="2.0"===r.version?this._getCoverage201Parameters(e,t,s,n,o,r):"1.1"===r.version?this._getCoverage110Parameters(e,t,s,o,r):this._getCoverage100Parameters(e,t,s,o),c="2.0"===r.version?await this.request(this._constructWCS201Url(l),{signal:o.signal,responseType:"array-buffer"}):await this.request(this.url,{query:l,signal:o.signal,responseType:"array-buffer"});if("1.0"===a)return c.data;const p=d(c);if(p.isMultipart&&p.data){return p.data.find((e=>e.contentType?.toLowerCase().includes("image")&&null!=e.contentData))?.contentData}if(this.ioConfig.allowAnyMediaType)return c.data;throw new i("wcsraster:getcoverage","response is not a valid coverage, multipart response is expected")}_getInterpolationIndex(e){return this.coverageInfo.supportedInterpolations.includes(e)?"nearest"===e?0:"bilinear"===e?1:"cubic"===e?2:0:0}_getCoverage100Parameters(e,i,t,s){const n=`${e.xmin},${e.ymin},${e.xmax},${e.ymax}`,o=e.spatialReference.wkid,r=(this.coverageInfo.supportedFormats||[]).find((e=>e.toLowerCase().includes("tiff")))||"GEOTIFF",{bandIds:a,interpolation:l}=s,c=this._getInterpolationIndex(l),p=a?a.map((e=>this.coverageInfo.bandNames[e])):null,d=v[c];return{service:"WCS",request:"GetCoverage",version:this.version,coverage:this.coverageId,format:r,crs:`EPSG:${o}`,bbox:n,width:i,height:t,interpolation:d,band:p?.join(",")}}_getCoverage110Parameters(e,i,s,n,o){const{multidimensionalDefinition:r,bandIds:a,interpolation:c}=n,p=e.spatialReference.wkid,d=`urn:ogc:def:crs:EPSG::${p}`,h=(this.coverageInfo.supportedFormats||[]).find((e=>e.toLowerCase().includes("tiff")))||"image/tiff",u=this._getInterpolationIndex(c),f=w[u],g=null==c||0===this.coverageInfo.supportedInterpolations?.indexOf(c),m=o.domain.spatialDomain,v=m.origin.x<=m.envelope.xmin&&m.origin.y<=m.envelope.ymin,y=e.width/i,x=e.height/s*(v?1:-1),I=v?[e.xmin,e.ymin]:[e.xmin,e.ymax],b=m.useEPSGAxis&&l(p),C=b?`${I[1]},${I[0]}`:`${I[0]},${I[1]}`,$=b?`${x},0,0,${y}`:`${y},0,0,${x}`,S=y/2,j=e.xmin+S,T=e.xmax-S,_=Math.abs(x)/2,P=e.ymin+_,D=e.ymax-_,L=b?`${P},${j},${D},${T},${d}`:`${j},${P},${T},${D},${d}`,E=o.range.find((e=>e.axis.some((e=>e.identifier.toLowerCase().includes("band")))));let R,q=E&&f&&a?g?`${E.identifier}[${E.axis[0].identifier}[${a.join(",")}]]`:`${E.identifier}:${f}[${E.axis[0].identifier}[${a.join(",")}]]`:null;if(t(r)&&r.length)for(let t=0;t<r.length;t++){let e=r[t].values;const i=r[t].dimensionName.toLowerCase(),s=r[t].variableName.toLowerCase();if(e.length>0)if(e[0]instanceof Array&&(e=e[0]),"stdtime"===i)R=e.map((e=>this._convertToISOTime(e))).join(",");else{const t=o.range.find((e=>e.identifier.toLowerCase()===s));if(t){const s=t.axis.find((e=>e.identifier.toLowerCase()===i));s&&(q=g?t.identifier+"["+s.identifier+"["+e.join(",")+"]]":t.identifier+":"+f+"["+s.identifier+"["+e.join(",")+"]]")}}}return{service:"WCS",request:"GetCoverage",version:this.version,identifier:this.coverageId,format:h,crs:`EPSG:${p}`,boundingbox:L,gridCS:"urn:ogc:def:cs:OGC:0.0:Grid2dSquareCS",gridType:"urn:ogc:def:method:WCS:1.1:2dGridIn2dCrs",gridOrigin:C,gridOffsets:$,gridBaseCRS:d,timeSequence:R,rangeSubset:q}}_convertToISOTime(e,i=!1){return(i?new Date(24*(e-25569)*60*60*1e3):new Date(e)).toISOString()}_getCoverage201Parameters(e,i,s,n,o,r){const{multidimensionalDefinition:a,interpolation:l}=o,c=this._getInterpolationIndex(l);let p=null;const{supportedInterpolations:d}=this.capabilities;if(d?.length)switch(c){case 0:p=d.find((e=>e.includes("nearest")));break;case 1:p=d.find((e=>e.includes("linear")));break;case 2:p=d.find((e=>e.includes("cubic")||e.includes("quadratic")))}const h=(this.coverageInfo.supportedFormats||[]).find((e=>e.toLowerCase().includes("tiff")))||"image/tiff",{bandNames:u}=this.coverageInfo,{boundedBy:f,domainSet:g,rangeType:m}=r,v=f.isEastFirst?0:1,w=1-v,{axisLabels:y}=f,x=y[v],I=y[w],b=`http://www.opengis.net/def/crs/EPSG/0/${e.spatialReference.wkid}`,C=b,$=[];$.push(`${x}(${e.xmin},${e.xmax})`),$.push(`${I}(${e.ymin},${e.ymax})`);const S=[];if(y.length>2)for(let t=2;t<y.length;t++){const e=g.origin[t];if(y[t].toLowerCase().includes("time")){let i=e.toString();f.uomLabels[t].toLowerCase().includes("ole")&&(S.push(y[t]),i=this._convertToISOTime(e,!0)),$.push(y[t]+",http://www.opengis.net("+i+")")}else $.push(y[t]+",http://www.opengis.net("+e+")")}let j=null;if(t(a)&&a.length){const e=[];m.forEach((i=>i.forEach((i=>e.push(i.name)))));const i=[];for(let t=0;t<a.length;t++){const s=y.find((e=>e===a[t].dimensionName)),n=e.find((e=>e===a[t].variableName));if(i.includes(n)||i.push(n),s){let e=a[t].values;if(e.length>0){Array.isArray(e[0])&&(e=e[0]);let i="";i=s.toLowerCase().includes("time")?e.map((e=>this._convertToISOTime(e))).join(","):e.join(",");const t=$.findIndex((e=>0===e.indexOf(s+",http://www.opengis.net")));-1===t&&$.push(s+",http://www.opengis.net("+i+")"),-1===t||$[t].includes("("+i+")")||$.splice(t,1,s+",http://www.opengis.net("+i+")")}}}i.length&&(j=i.join(","))}else if(u?.length){j=(o.bandIds?o.bandIds.map((e=>u[e])):u).join(",")}const T=$.join("&subset="),_=!(r.domainSet.axisLabels.join("")===r.boundedBy.axisLabels.join(""))&&!1!==this.ioConfig.allowScaleFactor,P=_?null:`${x}(${i}),${I}(${s})`,D=_?1/n:null;return{service:"WCS",request:"GetCoverage",version:this.version,coverageId:this.coverageId,rangesubset:j,interpolation:p,scaleSize:P,scaleFactor:D,subset:T,format:h,mediaType:this.ioConfig.allowAnyMediaType?null:"multipart/related",outputcrs:b,subsettingcrs:C}}_constructWCS201Url(e){const i={...this.ioConfig.customFetchParameters,...e},t=[];Object.keys(i).forEach((e=>{const s=i[e];null!=s&&("subset"===e?s.split("&subset=").forEach((e=>{e&&t.push(`subset=${encodeURIComponent(e)}`)})):t.push(`${e}=${encodeURIComponent(s)}`))}));return`${encodeURI(this.url)}?${t.join("&")}`}};e([r({type:String,json:{write:!0}})],y.prototype,"datasetFormat",void 0),e([r()],y.prototype,"tileType",void 0),e([r({type:String,json:{write:!0}})],y.prototype,"version",void 0),e([r({type:String,json:{write:!0}})],y.prototype,"coverageId",void 0),y=e([a("esri.layers.support.rasterDatasets.ImageServerRaster")],y);const x=y;export{x 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.24/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import e from"../../../geometry/Extent.js";import t from"../../../geometry/Polygon.js";import{isAxesOrderReversedForWkid as n}from"../../ogc/crsUtils.js";import i from"../RasterInfo.js";import{getElements as s,isSameTagIgnoreNS as o,getElementValue as a,getElementValues as r,getNodeNameIgnoreNS as l,getElement as p,getSpaceDelimitedNumericValues as u}from"./xmlUtilities.js";function m(e){return{requestResponseCRSs:r(e,"requestResponseCRSs").map((e=>e.split(":")[1])),nativeCRSs:r(e,"nativeCRSs").map((e=>e.split(":")[1]))}}function c(e,t){const n=r(e,"1.0.0"===t?"interpolationMethod":"InterpolationMethod"),i="1.0.0"===t?e.getAttribute("default"):a(e,"InterpolationMethods/Default");return null!=i?[i].concat(n.filter((e=>e.toLowerCase()!==i.toLowerCase()))):n}function d(e){return null==e?["nearest"]:e.map((e=>{const t=e.toLowerCase();return t.includes("nearest")?"nearest":t.includes("linear")?"bilinear":t.includes("cubic")?"cubic":null})).filter((e=>!!e))}function f(t){const n=s(t,"pos"),i=u(n[0]),o=u(n[1]);return new e({xmin:i[0],ymin:i[1],xmax:o[0],ymax:o[1],spatialReference:{wkid:4326}})}function g(e){const t=[],n=s(e,"RangeSet");let i=[];for(let o=0;o<n.length;o++){const e=a(n[o],"name"),l=a(n[o],"label"),p=[],u=s(n[o],"AxisDescription");for(let t=0;t<u.length;t++){const e=a(u[t],"name"),n=a(u[t],"label"),s=r(u[t],"singleValue");if(0===s.length){const e=a(u[t],"min"),n=a(u[t],"max"),i=Number(a(u[t],"res"))||1;if(null!==e&&null!==n)for(let t=parseInt(e,10);t<=parseInt(n,10);t+=i)s.push(t.toString())}"band"===e.toLowerCase()&&(i=s),p.push({name:e,label:n,values:s})}t.push({name:e,label:l,axis:p})}return{rangeSet:t,bandNames:i}}function h(e=null){if(!e)return{resolution:null,units:null};let t=e.toUpperCase();const n=["Y","M","D"],i=["H","M","S"],s=["Years","Months","Days","Hours","Minutes","Seconds"];let o,a,r;return t.includes("PT")?(t=t.slice(2),r=i.findIndex((e=>t.includes(e))),o=s[3+r],a=parseFloat(t.substring(0,t.length-1))):(t=t.slice(1),r=n.findIndex((e=>t.includes(e))),r>-1&&(o=s[r]),a=parseFloat(t.substring(0,t.length-1))),{resolution:a,units:o}}function b(e){const t=s(e,"timeposition");if(t.length>0){const e=[];for(let n=0;n<t.length;n++)e.push(new Date(a(t[n])));return{begin:e[0],end:e[e.length-1],values:e}}const n=p(e,"timePeriod")||p(e,"TimePeriod");if(n){return{begin:new Date(a(n,"beginPosition")||a(n,"BeginPosition")),end:new Date(a(n,"endPosition")||a(n,"EndPosition")),...h(a(n,"timeResolution")||a(n,"TimeResolution"))}}return null}function x(t){const n=p(t,"spatialDomain"),i=p(n,"Envelope")||p(n,"EnvelopeWithTimePeriod"),o=i.getAttribute("srsName").split(":"),r=o[o.length-1],l=s(i,"pos"),m=u(l[0]),c=u(l[1]),d=parseInt(r,10),f=isNaN(d)?null:{wkid:d},g=new e({xmin:m[0],ymin:m[1],xmax:c[0],ymax:c[1],spatialReference:f}),h=p(n,"RectifiedGrid"),x=a(h,"low").split(" "),v=a(h,"high").split(" "),w=parseInt(v[0],10)-parseInt(x[0],10)+1,y=parseInt(v[1],10)-parseInt(x[1],10)+1,D=u(n,"origin/pos"),L=s(n,"offsetVector"),S={envelope:g,columns:w,rows:y,offset:{x:parseFloat(a(L[0]).split(" ")[0]),y:parseFloat(a(L[1]).split(" ")[1])},origin:{x:D[0],y:D[1]}},C=p(t,"temporalDomain")||p(t,"TemporalDomain");return{spatialDomain:S,temporalDomain:C?b(C):null}}function v(e){const t={version:"1.0"};let n=[];for(let i=0;i<e.childNodes.length;i++){const s=e.childNodes[i];if(1===s.nodeType)if(o(s,"description"))t.description=a(s);else if(o(s,"name"))t.name=a(s);else if(o(s,"label"))t.label=a(s);else if(o(s,"supportedFormats"))t.supportedFormats=r(s,"formats");else if(o(s,"supportedCRSs"))t.supportedCRSs=m(s);else if(o(s,"supportedInterpolations"))t.supportedInterpolations=c(s,"1.0.0");else if(o(s,"lonLatEnvelope"))t.lonLatEnvelope=f(s);else if(o(s,"rangeSet")){const e=g(s);t.rangeSet=e.rangeSet,n=e.bandNames}else o(s,"domainSet")&&(t.domainSet=x(s))}const s=d(t.supportedInterpolations),{name:l,description:p,label:u,lonLatEnvelope:h,supportedFormats:b}=t,{spatialDomain:v}=t.domainSet,w={x:Math.abs(v.offset.x),y:Math.abs(v.offset.y)},y=new i({width:v.columns,height:v.rows,pixelSize:w,extent:v.envelope,spatialReference:v.envelope.spatialReference,bandCount:n.length||1});return{id:l,title:t.name,description:p||u,lonLatEnvelope:h,rasterInfo:y,bandNames:n,supportedFormats:b,supportedInterpolations:s,coverageDescription:t,version:"1.0.0",useEPSGAxis:!1}}function w(e){const t=[],n=s(e,"Field");let i=[];for(let o=0;o<n.length;o++){const e=a(n[o],"Identifier"),l=a(n[o],"Description"),p=a(n[o],"Definition"),u=a(n[o],"Abstract"),m=a(n[o],"Title"),d=c(n[o],"1.1.0"),f=[],g=s(n[o],"Axis");for(let t=0;t<g.length;t++){const e=g[t].getAttribute("identifier"),n=a(g[t],"UOM"),s=a(g[t],"DataType"),o=r(g[t],"Key");"band"===e.toLowerCase()&&(i=o),f.push({identifier:e,uom:n,dataType:s,values:o})}t.push({identifier:e,description:l,definition:p,abstract:u,title:m,supportedInterpolations:d,axis:f})}return{rangeSet:t,bandNames:i}}function y(e,t){const n=e.filter((e=>!e.identifier.toLowerCase().includes("field_1")&&!e.axis.some((e=>"band"===e.identifier.toLowerCase())))),i=[];if(n.length&&n.forEach((e=>{const t=e.axis.map((e=>{const t=e.values.map((t=>{if("ISO8601"===e.uom){return(t=t.trim()).toLowerCase().includes("z")?new Date(t).getTime():new Date(t+"Z").getTime()}return parseFloat(t.trim())})),n=[Math.min.apply(null,t),Math.max.apply(null,t)];return{name:e.identifier.trim(),description:"",field:e.identifier.trim(),unit:e.uom?e.uom.trim():"",hasRegularIntervals:!1,values:t,extent:n}}));i.push({name:e.identifier.trim(),description:e.description?.trim()??"",unit:"",dimensions:t})})),t.temporalDomain){const{begin:e,end:n,values:s,units:o,resolution:a}=t.temporalDomain;i.some((e=>e.dimensions.some((e=>"stdtime"===e.name.toLowerCase()))))||i.forEach((t=>{t.dimensions.push({name:"StdTime",description:"",unit:"ISO8601",values:s?.map((e=>e.getTime())),hasRegularIntervals:!s,interval:a,intervalUnit:o,extent:[e.getTime(),n.getTime()]})}))}return i.length?{variables:i}:null}function D(t){const i=p(t,"SpatialDomain"),o=p(i,"GridCRS"),r=a(o,"GridBaseCRS"),l=a(o,"GridOrigin")?.split(" ").map((e=>parseFloat(e)))??[0,0],m=u(o,"GridOffsets"),c=s(i,"BoundingBox");let d,f,g,h;for(let n=0;n<c.length;n++){const t=c[n].getAttribute("crs")?.toLowerCase();if(null!=t)if(t.includes("imagecrs")){const e=u(c[n],"LowerCorner"),t=u(c[n],"UpperCorner");d=t[0]-e[0]+1,f=t[1]-e[1]+1}else if(t.indexOf("epsg")>0){const i=t.split(":");g=parseInt(i[i.length-1],10);const s=u(c[n],"LowerCorner"),o=u(c[n],"UpperCorner");h=new e({xmin:s[0],ymin:s[1],xmax:o[0],ymax:o[1],spatialReference:{wkid:g}})}}const x=d>f,v=h.xmax-h.xmin>h.ymax-h.ymin;let w=!1;n(g)&&(x===v?w=!1:(w=!0,h=new e({xmin:h.ymin,ymin:h.xmin,xmax:h.ymax,ymax:h.xmax,spatialReference:{wkid:g}})));const y={columns:d,rows:f,origin:{x:l[0],y:l[1]},offset:{x:m[0],y:m[1]},gridBaseCRS:r,envelope:h,useEPSGAxis:w},D=p(t,"temporalDomain")||p(t,"TemporalDomain");return{spatialDomain:y,temporalDomain:D?b(D):null}}function L(e,t){const n=[],s=[],o={supportedFormats:n,supportedCRSs:s,version:"1.1"};let r;for(let i=0;i<e.childNodes.length;i++){const t=e.childNodes[i];if(1!==t.nodeType)continue;const p=l(t).toLowerCase();switch(p){case"title":case"abstract":case"identifier":o[p]=a(t);break;case"supportedformat":{const e=a(t);n.includes(e)||n.push(e)}break;case"supportedcrs":{const e=a(t);s.includes(e)||s.push(e)}break;case"range":{const e=w(t);o.range=e.rangeSet,r=e.bandNames}break;case"domain":o.domain=D(t)}}const p=d(o.range[0].supportedInterpolations),{identifier:u,abstract:m,title:c,domain:f,range:g}=o,h={x:Math.abs(f.spatialDomain.offset.x),y:Math.abs(f.spatialDomain.offset.y)},b=y(g,f),x=new i({width:f.spatialDomain.columns,height:f.spatialDomain.rows,pixelSize:h,extent:f.spatialDomain.envelope,spatialReference:f.spatialDomain.envelope.spatialReference,bandCount:r.length||1,multidimensionalInfo:b});return{id:u,title:o.title,description:m||c,lonLatEnvelope:null,bandNames:r,rasterInfo:x,supportedFormats:n,supportedInterpolations:p,coverageDescription:o,version:t,useEPSGAxis:f.spatialDomain.useEPSGAxis}}function S(t){const n=p(t,"Envelope")||p(t,"EnvelopeWithTimePeriod"),i=n.getAttribute("srsName"),s=i.slice(i.lastIndexOf("/")+1),r=n.getAttribute("axisLabels").split(" ").map((e=>e.trim())).filter((e=>""!==e.trim())),l=u(n,"lowerCorner"),m=u(n,"upperCorner"),c=!["y","lat","latitude","north","nor","n","b"].includes(r[0].toLowerCase());let d;const f=parseInt(s,10),g=isNaN(f)?null:{wkid:f};d=new e(c?{xmin:l[0],ymin:l[1],xmax:m[0],ymax:m[1],spatialReference:g}:{xmin:l[1],ymin:l[0],xmax:m[1],ymax:m[0],spatialReference:g});const h={mins:l,maxs:m},b=n.getAttribute("uomLabels").trim().split(" ");let x,v;if(o(n,"EnvelopeWithTimePeriod")){x=new Date(a(t,"beginPosition")||a(t,"BeginPosition")),v=new Date(a(t,"endPosition")||a(t,"EndPosition"));const e=b?.findIndex((e=>"oledatetime"===e?.toLowerCase()));e>-1&&(b[e]="ISO8601")}return{envelope:d,axisLabels:r,uomLabels:b.length?b:null,envelopeAllDims:h,beginPosition:x,endPosition:v,isEastFirst:c}}function C(e){const t=[],n=s(e,"DataRecord"),i=[];let o;for(let r=0;r<n.length;r++){const e=s(n[r],"field"),l=[];for(let t=0;t<e.length;t++){const n=e[t].getAttribute("name"),s=a(e[t],"description")||"",r=p(e[t],"uom")?.getAttribute("code")||"",m=u(e[t],"interval");n.toLowerCase().includes("band")&&(i.push(n),m?.length&&(o=o||[],o.push({min:m[0],max:m[1],avg:-1,stddev:-1}))),l.push({name:n,description:s,uom:r,allowedValues:m})}t.push(l)}return{rangeType:t,bandNames:i,bandStats:o}}function I(e){let t=1,n="";const i=.01;return Math.abs(e-1/24)<1/24*i?n="Hours":Math.abs(e-1)<1*i?n="Days":e<1?(t=Math.round(24*e),n="Hours"):e>28-i&&e<31+i||Math.round(e/30)<12?n="Months":e>365-i&&e<366+i&&(n="Years"),{interval:t,intervalUnit:n}}function R(e,t,n){const i=[];for(let o=0;o<e.length;o++){const t=e[o];for(let e=0;e<t.length;e++)t[e].name.toLowerCase().includes("band")||i.push(t[e])}const s=[];if(i.length){const e=[];for(let i=2;i<n.axisLabels.length;i++){const s=(t.uomLabels&&t.uomLabels.length)>i?t.uomLabels[i]:"",o=n.axisLabels[i].toLowerCase().includes("time")||"iso8601"===s.toLowerCase()||"oledatetime"===s.toLowerCase();let a,r;if(o){const e=I(n.offset[i]);a=e.interval,r=e.intervalUnit}else a=n.offset[i],r=s;const l=[];o?(l.push((new Date).setTime(24*(t.envelopeAllDims.mins[i]-25569)*3600*1e3)),l.push((new Date).setTime(24*(t.envelopeAllDims.maxs[i]-25569)*3600*1e3))):(l.push(t.envelopeAllDims.mins[i]),l.push(t.envelopeAllDims.maxs[i])),e.push({name:n.axisLabels[i].trim(),description:n.axisLabels[i].trim(),unit:t.uomLabels&&t.uomLabels.length>i?t.uomLabels[i].trim():"",hasRegularIntervals:!0,extent:l,interval:a,intervalUnit:r})}if(i.forEach((t=>{const{allowedValues:n}=t,i=2===n?.length?[{min:n[0],max:n[1],avg:-1,stddev:-1}]:null;s.push({name:t.name.trim(),description:t.description?.trim()??"",unit:t.uom.trim(),statistics:i,dimensions:e})})),s.length)return{variables:s}}return null}function T(e,t){const n=p(e,"RectifiedGrid"),i=u(n,"low"),o=u(n,"high"),r=[];for(let s=0;s<i.length;s++)r.push(o[s]-i[s]+1);const l=a(n,"axisLabels").split(" "),m=u(n,"origin/pos"),c=s(n,"offsetVector"),d=[];for(let s=0;s<c.length;s++){const e=u(c[s]),t=e.findIndex((e=>0!==e));d[t]=e[t]}let f,g,h;return["y","lat","latitude","north","nor","n","b"].includes((t||l)[0].toLowerCase())?(f=r[1],g=r[0],h={y:Math.abs(d[0]),x:Math.abs(d[1])}):(f=r[0],g=r[1],h={x:Math.abs(d[0]),y:Math.abs(d[1])}),{columns:f,rows:g,origin:m,offset:d,resolution:h,gridSamples:r,axisLabels:l}}function M(e){const n=p(e,"EarthObservation");if(!n)return null;const i=p(n,"phenomenonTime"),s=i?b(i):null,o=p(n,"phenomenonTime"),r=o?b(o):null,l=a(n,"featureOfInterest/Footprint/multiExtentOf/MultiSurface/surfaceMembers/Polygon/exterior/LinearRing/posList");let u=null;if(l){const e=l.split(" ").map((e=>e.trim())).filter((e=>null!=e&&""!==e));if(e.length){const n=[];for(let t=0;t<e.length/2;t+=2)n.push(e[t],e[t+1]);u=new t({rings:[n],spatialReference:{wkid:4326}})}}return{observation:{phonomenonTime:s,resultTime:r,footprint:u,identifier:a(e,"metaDataProperty/EarthObservationMetaData/identifier"),acquisitionType:a(e,"metaDataProperty/EarthObservationMetaData/acquisitionType"),status:a(e,"metaDataProperty/EarthObservationMetaData/status")}}}function P(e){const t={version:"2.0"};let n,s=[];for(let i=0;i<e.childNodes.length;i++){const l=e.childNodes[i];if(1===l.nodeType)if(o(l,"coverageId"))t.coverageId=a(l);else if(o(l,"ServiceParameters"))t.serviceParameters={supportedFormats:r(l,"nativeFormat")};else if(o(l,"boundedBy"))t.boundedBy=S(l);else if(o(l,"rangeType")){const e=C(l);t.rangeType=e.rangeType,s=e.bandNames,n=e.bandStats}else if(o(l,"domainSet"))t.domainSet=T(l,t.boundedBy?.axisLabels);else if(o(l,"metadata")){const e=p(l,"EOMetadata");t.eoMetadata=e?M(e):null}}const{coverageId:l,boundedBy:u,domainSet:m,rangeType:c,serviceParameters:d}=t,f=R(c,u,m);!n&&f&&(n=f?.variables[0].statistics);return{id:l,title:l,description:l,lonLatEnvelope:null,bandNames:s,rasterInfo:new i({width:m.columns,height:m.rows,pixelSize:m.resolution,extent:u.envelope,spatialReference:u.envelope.spatialReference,bandCount:s.length||1,statistics:n,multidimensionalInfo:f}),supportedFormats:d.supportedFormats,supportedInterpolations:null,coverageDescription:t,version:"2.0.1",useEPSGAxis:!1}}function E(e,t){let n=null;if("string"==typeof e){n=(new DOMParser).parseFromString(e,"text/xml")}else n=e;if("1.0.0"===t){return s(n,"CoverageOffering").map((e=>v(e)))}const i=s(n,"CoverageDescription");return"1.1.0"===t||"1.1.1"===t||"1.1.2"===t?i.map((e=>L(e,t))):i.map((e=>P(e)))}export{E as parseCoverages,d as standardizeInterpolations};
|
|
5
|
+
import e from"../../../geometry/Extent.js";import t from"../../../geometry/Polygon.js";import{isAxesOrderReversedForWkid as n}from"../../ogc/crsUtils.js";import i from"../RasterInfo.js";import{getElements as s,isSameTagIgnoreNS as o,getElementValue as a,getElementValues as r,getNodeNameIgnoreNS as l,getElement as u,getSpaceDelimitedNumericValues as p}from"./xmlUtilities.js";function m(e){return{requestResponseCRSs:r(e,"requestResponseCRSs").map((e=>e.split(":")[1])),nativeCRSs:r(e,"nativeCRSs").map((e=>e.split(":")[1]))}}function c(e,t){const n=r(e,"1.0.0"===t?"interpolationMethod":"InterpolationMethod"),i="1.0.0"===t?e.getAttribute("default"):a(e,"InterpolationMethods/Default");return null!=i?[i].concat(n.filter((e=>e.toLowerCase()!==i.toLowerCase()))):n}function d(e){return null==e?["nearest"]:e.map((e=>{const t=e.toLowerCase();return t.includes("nearest")?"nearest":t.includes("linear")?"bilinear":t.includes("cubic")?"cubic":null})).filter((e=>!!e))}function f(t){const n=s(t,"pos"),i=p(n[0]),o=p(n[1]);return new e({xmin:i[0],ymin:i[1],xmax:o[0],ymax:o[1],spatialReference:{wkid:4326}})}function g(e,t){const n=r(e,t);return n?.length&&""!==n[0]&&!isNaN(Number(n[0]))?n.map((e=>Number(e))):null}function h(e){return e.every((t=>t===e[0]))?e[0]:e}function b(e){const t=[],n=s(e,"RangeSet");let i=[];for(let o=0;o<n.length;o++){const e=a(n[o],"name"),l=a(n[o],"label"),u=[],p=g(n[o],"nullValues/singleValue"),m=s(n[o],"AxisDescription");for(let t=0;t<m.length;t++){const e=a(m[t],"name"),n=a(m[t],"label"),s=r(m[t],"singleValue");if(0===s.length){const e=a(m[t],"min"),n=a(m[t],"max"),i=Number(a(m[t],"res"))||1;if(null!==e&&null!==n)for(let t=parseInt(e,10);t<=parseInt(n,10);t+=i)s.push(t.toString())}"band"===e.toLowerCase()&&(i=s),u.push({name:e,label:n,values:s})}t.push({name:e,label:l,nullValues:p,axis:u})}return{rangeSet:t,bandNames:i}}function x(e=null){if(!e)return{resolution:null,units:null};let t=e.toUpperCase();const n=["Y","M","D"],i=["H","M","S"],s=["Years","Months","Days","Hours","Minutes","Seconds"];let o,a,r;return t.includes("PT")?(t=t.slice(2),r=i.findIndex((e=>t.includes(e))),o=s[3+r],a=parseFloat(t.substring(0,t.length-1))):(t=t.slice(1),r=n.findIndex((e=>t.includes(e))),r>-1&&(o=s[r]),a=parseFloat(t.substring(0,t.length-1))),{resolution:a,units:o}}function v(e){const t=s(e,"timeposition");if(t.length>0){const e=[];for(let n=0;n<t.length;n++)e.push(new Date(a(t[n])));return{begin:e[0],end:e[e.length-1],values:e}}const n=u(e,"timePeriod")||u(e,"TimePeriod");if(n){return{begin:new Date(a(n,"beginPosition")||a(n,"BeginPosition")),end:new Date(a(n,"endPosition")||a(n,"EndPosition")),...x(a(n,"timeResolution")||a(n,"TimeResolution"))}}return null}function D(t){const n=u(t,"spatialDomain"),i=u(n,"Envelope")||u(n,"EnvelopeWithTimePeriod"),o=i.getAttribute("srsName").split(":"),r=o[o.length-1],l=s(i,"pos"),m=p(l[0]),c=p(l[1]),d=parseInt(r,10),f=isNaN(d)?null:{wkid:d},g=new e({xmin:m[0],ymin:m[1],xmax:c[0],ymax:c[1],spatialReference:f}),h=u(n,"RectifiedGrid"),b=a(h,"low").split(" "),x=a(h,"high").split(" "),D=parseInt(x[0],10)-parseInt(b[0],10)+1,w=parseInt(x[1],10)-parseInt(b[1],10)+1,y=p(n,"origin/pos"),L=s(n,"offsetVector"),S={envelope:g,columns:D,rows:w,offset:{x:parseFloat(a(L[0]).split(" ")[0]),y:parseFloat(a(L[1]).split(" ")[1])},origin:{x:y[0],y:y[1]}},C=u(t,"temporalDomain")||u(t,"TemporalDomain");return{spatialDomain:S,temporalDomain:C?v(C):null}}function w(e){const t={version:"1.0"};let n,s=[];for(let i=0;i<e.childNodes.length;i++){const l=e.childNodes[i];if(1===l.nodeType)if(o(l,"description"))t.description=a(l);else if(o(l,"name"))t.name=a(l);else if(o(l,"label"))t.label=a(l);else if(o(l,"supportedFormats"))t.supportedFormats=r(l,"formats");else if(o(l,"supportedCRSs"))t.supportedCRSs=m(l);else if(o(l,"supportedInterpolations"))t.supportedInterpolations=c(l,"1.0.0");else if(o(l,"lonLatEnvelope"))t.lonLatEnvelope=f(l);else if(o(l,"rangeSet")){const e=b(l);t.rangeSet=e.rangeSet,s=e.bandNames;const i=e.rangeSet[0].nullValues;i?.length&&(n=h(i))}else o(l,"domainSet")&&(t.domainSet=D(l))}const l=d(t.supportedInterpolations),{name:u,description:p,label:g,lonLatEnvelope:x,supportedFormats:v}=t,{spatialDomain:w}=t.domainSet,y={x:Math.abs(w.offset.x),y:Math.abs(w.offset.y)},L=new i({width:w.columns,height:w.rows,pixelSize:y,extent:w.envelope,spatialReference:w.envelope.spatialReference,bandCount:s.length||1,noDataValue:n});return{id:u,title:t.name,description:p||g,lonLatEnvelope:x,rasterInfo:L,bandNames:s,supportedFormats:v,supportedInterpolations:l,coverageDescription:t,version:"1.0.0",useEPSGAxis:!1}}function y(e){const t=[],n=s(e,"Field");let i,o=[];for(let l=0;l<n.length;l++){const e=a(n[l],"Identifier"),u=a(n[l],"Description"),p=a(n[l],"Definition"),m=a(n[l],"Abstract"),d=a(n[l],"Title"),f=g(n[l],"NullValue"),h=c(n[l],"1.1.0"),b=[],x=s(n[l],"Axis");for(let t=0;t<x.length;t++){const e=x[t].getAttribute("identifier"),n=a(x[t],"UOM"),s=a(x[t],"DataType"),l=r(x[t],"Key");"band"===e.toLowerCase()&&(o=l,i=f),b.push({identifier:e,uom:n,dataType:s,values:l,bandNoDataValues:i})}t.push({identifier:e,description:u,definition:p,abstract:m,title:d,supportedInterpolations:h,axis:b,nullValues:f})}return{rangeSet:t,bandNames:o,bandNoDataValues:i}}function L(e,t){const n=e.filter((e=>!e.identifier.toLowerCase().includes("field_1")&&!e.axis.some((e=>"band"===e.identifier.toLowerCase())))),i=[];if(n.length&&n.forEach((e=>{const t=e.axis.map((e=>{const t=e.values.map((t=>{if("ISO8601"===e.uom){return(t=t.trim()).toLowerCase().includes("z")?new Date(t).getTime():new Date(t+"Z").getTime()}return parseFloat(t.trim())})),n=[Math.min.apply(null,t),Math.max.apply(null,t)];return{name:e.identifier.trim(),description:"",field:e.identifier.trim(),unit:e.uom?e.uom.trim():"",hasRegularIntervals:!1,values:t,extent:n}}));i.push({name:e.identifier.trim(),description:e.description?.trim()??"",unit:"",dimensions:t})})),t.temporalDomain){const{begin:e,end:n,values:s,units:o,resolution:a}=t.temporalDomain;i.some((e=>e.dimensions.some((e=>"stdtime"===e.name.toLowerCase()))))||i.forEach((t=>{t.dimensions.push({name:"StdTime",description:"",unit:"ISO8601",values:s?.map((e=>e.getTime())),hasRegularIntervals:!s,interval:a,intervalUnit:o,extent:[e.getTime(),n.getTime()]})}))}return i.length?{variables:i}:null}function S(t){const i=u(t,"SpatialDomain"),o=u(i,"GridCRS"),r=a(o,"GridBaseCRS"),l=a(o,"GridOrigin")?.split(" ").map((e=>parseFloat(e)))??[0,0],m=p(o,"GridOffsets"),c=s(i,"BoundingBox");let d,f,g,h;for(let n=0;n<c.length;n++){const t=c[n].getAttribute("crs")?.toLowerCase();if(null!=t)if(t.includes("imagecrs")){const e=p(c[n],"LowerCorner"),t=p(c[n],"UpperCorner");d=t[0]-e[0]+1,f=t[1]-e[1]+1}else if(t.indexOf("epsg")>0){const i=t.split(":");g=parseInt(i[i.length-1],10);const s=p(c[n],"LowerCorner"),o=p(c[n],"UpperCorner");h=new e({xmin:s[0],ymin:s[1],xmax:o[0],ymax:o[1],spatialReference:{wkid:g}})}}const b=d>f,x=h.xmax-h.xmin>h.ymax-h.ymin;let D=!1;n(g)&&(b===x?D=!1:(D=!0,h=new e({xmin:h.ymin,ymin:h.xmin,xmax:h.ymax,ymax:h.xmax,spatialReference:{wkid:g}})));const w={columns:d,rows:f,origin:{x:l[0],y:l[1]},offset:{x:m[0],y:m[1]},gridBaseCRS:r,envelope:h,useEPSGAxis:D},y=u(t,"temporalDomain")||u(t,"TemporalDomain");return{spatialDomain:w,temporalDomain:y?v(y):null}}function C(e,t){const n=[],s=[],o={supportedFormats:n,supportedCRSs:s,version:"1.1"};let r,u;for(let i=0;i<e.childNodes.length;i++){const t=e.childNodes[i];if(1!==t.nodeType)continue;const p=l(t).toLowerCase();switch(p){case"title":case"abstract":case"identifier":o[p]=a(t);break;case"supportedformat":{const e=a(t);n.includes(e)||n.push(e)}break;case"supportedcrs":{const e=a(t);s.includes(e)||s.push(e)}break;case"range":{const e=y(t);o.range=e.rangeSet,r=e.bandNames;const{bandNoDataValues:n}=e;n?.length&&(u=h(n))}break;case"domain":o.domain=S(t)}}const p=d(o.range[0].supportedInterpolations),{identifier:m,abstract:c,title:f,domain:g,range:b}=o,x={x:Math.abs(g.spatialDomain.offset.x),y:Math.abs(g.spatialDomain.offset.y)},v=L(b,g);v&&(u=b[0].nullValues,1===u?.length&&(u=u[0]));const D=new i({width:g.spatialDomain.columns,height:g.spatialDomain.rows,pixelSize:x,extent:g.spatialDomain.envelope,spatialReference:g.spatialDomain.envelope.spatialReference,bandCount:r.length||1,noDataValue:u,multidimensionalInfo:v});return{id:m,title:o.title,description:c||f,lonLatEnvelope:null,bandNames:r,rasterInfo:D,supportedFormats:n,supportedInterpolations:p,coverageDescription:o,version:t,useEPSGAxis:g.spatialDomain.useEPSGAxis}}function I(t){const n=u(t,"Envelope")||u(t,"EnvelopeWithTimePeriod"),i=n.getAttribute("srsName"),s=i.slice(i.lastIndexOf("/")+1),r=n.getAttribute("axisLabels").split(" ").map((e=>e.trim())).filter((e=>""!==e.trim())),l=p(n,"lowerCorner"),m=p(n,"upperCorner"),c=!["y","lat","latitude","north","nor","n","b"].includes(r[0].toLowerCase());let d;const f=parseInt(s,10),g=isNaN(f)?null:{wkid:f};d=new e(c?{xmin:l[0],ymin:l[1],xmax:m[0],ymax:m[1],spatialReference:g}:{xmin:l[1],ymin:l[0],xmax:m[1],ymax:m[0],spatialReference:g});const h={mins:l,maxs:m},b=n.getAttribute("uomLabels").trim().split(" ");let x,v;if(o(n,"EnvelopeWithTimePeriod")){x=new Date(a(t,"beginPosition")||a(t,"BeginPosition")),v=new Date(a(t,"endPosition")||a(t,"EndPosition"));const e=b?.findIndex((e=>"oledatetime"===e?.toLowerCase()));e>-1&&(b[e]="ISO8601")}return{envelope:d,axisLabels:r,uomLabels:b.length?b:null,envelopeAllDims:h,beginPosition:x,endPosition:v,isEastFirst:c}}function R(e){const t=[],n=s(e,"DataRecord"),i=[];let o,r=[];for(let l=0;l<n.length;l++){const e=s(n[l],"field"),m=[];for(let t=0;t<e.length;t++){const n=e[t].getAttribute("name"),s=a(e[t],"description")||"",l=u(e[t],"uom")?.getAttribute("code")||"",c=p(e[t],"interval"),d=g(e[t],"nilValue")?.[0];n.toLowerCase().includes("band")&&(i.push(n),c?.length&&(o=o||[],o.push({min:c[0],max:c[1],avg:-1,stddev:-1})),r.push(d)),m.push({name:n,description:s,uom:l,allowedValues:c,nilValue:d})}t.push(m)}return r.some((e=>null!=e))||(r=null),{rangeType:t,bandNames:i,bandStats:o,bandNoDataValues:r}}function T(e){let t=1,n="";const i=.01;return Math.abs(e-1/24)<1/24*i?n="Hours":Math.abs(e-1)<1*i?n="Days":e<1?(t=Math.round(24*e),n="Hours"):e>28-i&&e<31+i||Math.round(e/30)<12?n="Months":e>365-i&&e<366+i&&(n="Years"),{interval:t,intervalUnit:n}}function N(e,t,n){const i=[];for(let o=0;o<e.length;o++){const t=e[o];for(let e=0;e<t.length;e++)t[e].name.toLowerCase().includes("band")||i.push(t[e])}const s=[];if(i.length){const e=[];for(let i=2;i<n.axisLabels.length;i++){const s=(t.uomLabels&&t.uomLabels.length)>i?t.uomLabels[i]:"",o=n.axisLabels[i].toLowerCase().includes("time")||"iso8601"===s.toLowerCase()||"oledatetime"===s.toLowerCase();let a,r;if(o){const e=T(n.offset[i]);a=e.interval,r=e.intervalUnit}else a=n.offset[i],r=s;const l=[];o?(l.push((new Date).setTime(24*(t.envelopeAllDims.mins[i]-25569)*3600*1e3)),l.push((new Date).setTime(24*(t.envelopeAllDims.maxs[i]-25569)*3600*1e3))):(l.push(t.envelopeAllDims.mins[i]),l.push(t.envelopeAllDims.maxs[i])),e.push({name:n.axisLabels[i].trim(),description:n.axisLabels[i].trim(),unit:t.uomLabels&&t.uomLabels.length>i?t.uomLabels[i].trim():"",hasRegularIntervals:!0,extent:l,interval:a,intervalUnit:r})}if(i.forEach((t=>{const{allowedValues:n}=t,i=2===n?.length?[{min:n[0],max:n[1],avg:-1,stddev:-1}]:null;s.push({name:t.name.trim(),description:t.description?.trim()??"",unit:t.uom.trim(),statistics:i,dimensions:e})})),s.length)return{variables:s}}return null}function M(e,t){const n=u(e,"RectifiedGrid"),i=p(n,"low"),o=p(n,"high"),r=[];for(let s=0;s<i.length;s++)r.push(o[s]-i[s]+1);const l=a(n,"axisLabels").split(" "),m=p(n,"origin/pos"),c=s(n,"offsetVector"),d=[];for(let s=0;s<c.length;s++){const e=p(c[s]),t=e.findIndex((e=>0!==e));d[t]=e[t]}let f,g,h;return["y","lat","latitude","north","nor","n","b"].includes((t||l)[0].toLowerCase())?(f=r[1],g=r[0],h={y:Math.abs(d[0]),x:Math.abs(d[1])}):(f=r[0],g=r[1],h={x:Math.abs(d[0]),y:Math.abs(d[1])}),{columns:f,rows:g,origin:m,offset:d,resolution:h,gridSamples:r,axisLabels:l}}function P(e){const n=u(e,"EarthObservation");if(!n)return null;const i=u(n,"phenomenonTime"),s=i?v(i):null,o=u(n,"phenomenonTime"),r=o?v(o):null,l=a(n,"featureOfInterest/Footprint/multiExtentOf/MultiSurface/surfaceMembers/Polygon/exterior/LinearRing/posList");let p=null;if(l){const e=l.split(" ").map((e=>e.trim())).filter((e=>null!=e&&""!==e));if(e.length){const n=[];for(let t=0;t<e.length/2;t+=2)n.push(e[t],e[t+1]);p=new t({rings:[n],spatialReference:{wkid:4326}})}}return{observation:{phonomenonTime:s,resultTime:r,footprint:p,identifier:a(e,"metaDataProperty/EarthObservationMetaData/identifier"),acquisitionType:a(e,"metaDataProperty/EarthObservationMetaData/acquisitionType"),status:a(e,"metaDataProperty/EarthObservationMetaData/status")}}}function E(e){const t={version:"2.0"};let n,s,l=[];for(let i=0;i<e.childNodes.length;i++){const p=e.childNodes[i];if(1===p.nodeType)if(o(p,"coverageId"))t.coverageId=a(p);else if(o(p,"ServiceParameters"))t.serviceParameters={supportedFormats:r(p,"nativeFormat")};else if(o(p,"boundedBy"))t.boundedBy=I(p);else if(o(p,"rangeType")){const e=R(p);t.rangeType=e.rangeType,l=e.bandNames,n=e.bandStats;const{bandNoDataValues:i}=e;i?.length&&(s=h(i))}else if(o(p,"domainSet"))t.domainSet=M(p,t.boundedBy?.axisLabels);else if(o(p,"metadata")){const e=u(p,"EOMetadata");t.eoMetadata=e?P(e):null}}const{coverageId:p,boundedBy:m,domainSet:c,rangeType:d,serviceParameters:f}=t,g=N(d,m,c);!n&&g&&(n=g?.variables[0].statistics),null!=g&&(s=d[0][0].nilValue);return{id:p,title:p,description:p,lonLatEnvelope:null,bandNames:l,rasterInfo:new i({width:c.columns,height:c.rows,pixelSize:c.resolution,extent:m.envelope,spatialReference:m.envelope.spatialReference,bandCount:l.length||1,statistics:n,noDataValue:s,multidimensionalInfo:g}),supportedFormats:f.supportedFormats,supportedInterpolations:null,coverageDescription:t,version:"2.0.1",useEPSGAxis:!1}}function V(e,t){let n=null;if("string"==typeof e){n=(new DOMParser).parseFromString(e,"text/xml")}else n=e;if("1.0.0"===t){return s(n,"CoverageOffering").map((e=>w(e)))}const i=s(n,"CoverageDescription");return"1.1.0"===t||"1.1.1"===t||"1.1.2"===t?i.map((e=>C(e,t))):i.map((e=>E(e)))}export{V as parseCoverages,d as standardizeInterpolations};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{J as t}from"../../../chunks/Jpg.js";import{Z as e}from"../../../chunks/Zlib.js";class n{static decode(n){const s=new Uint8Array(n),
|
|
5
|
+
import{J as t}from"../../../chunks/Jpg.js";import{Z as e}from"../../../chunks/Zlib.js";class n{static decode(n,r=!1){const s=new Uint8Array(n),o=new t;o.parse(s);const{width:a,height:i,numComponents:l,eof:h}=o,c=o.getData(a,i,!0);let f;const g=a*i;let p=0,u=0,m=0;if(!r&&h<s.length-1)try{const t=new e(s.subarray(h)).getBytes();f=new Uint8Array(g);let n=0;for(p=0;p<t.length;p++)for(m=7;m>=0;m--)f[n++]=t[p]>>m&1}catch{}let w,y=null;if(1===l&&c.length===a*i)y=[c,c,c];else{for(y=[],p=0;p<3;p++)w=new Uint8Array(g),y.push(w);for(m=0,u=0;u<g;u++)for(p=0;p<3;p++)y[p][u]=c[m++]}return{width:a,height:i,pixels:y,mask:f}}}export{n 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.24/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import t from"../../../core/Error.js";import e from"../PixelBlock.js";import i from"./ImageCanvasDecoder.js";import a from"./JpgPlus.js";import{load as s,decode as r}from"./Lerc.js";import{decode as n}from"./Lzw.js";import{Z as o}from"../../../chunks/Zlib.js";import h from"./Raw.js";import{decodeTileOrStrip as c,decode as p}from"./TiffDecoder.js";import{isPlatformLittleEndian as l}from"./utils.js";var d=function(t){var e,i,a,s,r,n;function h(t){var e,i,a,s,r,n,o,h,c,p,l,d,u;for(this.data=t,this.pos=8,this.palette=[],this.imgData=[],this.transparency={},this.animation=null,this.text={},r=null;;){switch(e=this.readUInt32(),h=function(){var t,e;for(e=[],t=0;t<4;++t)e.push(String.fromCharCode(this.data[this.pos++]));return e}.call(this).join(""),h){case"IHDR":this.width=this.readUInt32(),this.height=this.readUInt32(),this.bits=this.data[this.pos++],this.colorType=this.data[this.pos++],this.compressionMethod=this.data[this.pos++],this.filterMethod=this.data[this.pos++],this.interlaceMethod=this.data[this.pos++];break;case"acTL":this.animation={numFrames:this.readUInt32(),numPlays:this.readUInt32()||1/0,frames:[]};break;case"PLTE":this.palette=this.read(e);break;case"fcTL":r&&this.animation.frames.push(r),this.pos+=4,r={width:this.readUInt32(),height:this.readUInt32(),xOffset:this.readUInt32(),yOffset:this.readUInt32()},s=this.readUInt16(),a=this.readUInt16()||100,r.delay=1e3*s/a,r.disposeOp=this.data[this.pos++],r.blendOp=this.data[this.pos++],r.data=[];break;case"IDAT":case"fdAT":for("fdAT"===h&&(this.pos+=4,e-=4),t=(null!=r?r.data:void 0)||this.imgData,l=0;0<=e?l<e:l>e;0<=e?++l:--l)t.push(this.data[this.pos++]);break;case"tRNS":switch(this.transparency={},this.colorType){case 3:if(this.transparency.indexed=this.read(e),(c=255-this.transparency.indexed.length)>0)for(d=0;0<=c?d<c:d>c;0<=c?++d:--d)this.transparency.indexed.push(255);break;case 0:this.transparency.grayscale=this.read(e)[0];break;case 2:this.transparency.rgb=this.read(e)}break;case"tEXt":n=(p=this.read(e)).indexOf(0),o=String.fromCharCode.apply(String,p.slice(0,n)),this.text[o]=String.fromCharCode.apply(String,p.slice(n+1));break;case"IEND":return r&&this.animation.frames.push(r),this.colors=function(){switch(this.colorType){case 0:case 3:case 4:return 1;case 2:case 6:return 3}}.call(this),this.hasAlphaChannel=4===(u=this.colorType)||6===u,i=this.colors+(this.hasAlphaChannel?1:0),this.pixelBitlength=this.bits*i,this.colorSpace=function(){switch(this.colors){case 1:return"DeviceGray";case 3:return"DeviceRGB"}}.call(this),void(this.imgData=new Uint8Array(this.imgData));default:this.pos+=e}if(this.pos+=4,this.pos>this.data.length)throw new Error("Incomplete or corrupt PNG file")}}return h.load=function(t,e,i){var a;return"function"==typeof e&&(i=e),(a=new XMLHttpRequest).open("GET",t,!0),a.responseType="arraybuffer",a.onload=function(){var t;return t=new h(new Uint8Array(a.response||a.mozResponseArrayBuffer)),"function"==typeof(null!=e?e.getContext:void 0)&&t.render(e),"function"==typeof i?i(t):void 0},a.send(null)},i=1,a=2,e=0,h.prototype.read=function(t){var e,i;for(i=[],e=0;0<=t?e<t:e>t;0<=t?++e:--e)i.push(this.data[this.pos++]);return i},h.prototype.readUInt32=function(){return this.data[this.pos++]<<24|this.data[this.pos++]<<16|this.data[this.pos++]<<8|this.data[this.pos++]},h.prototype.readUInt16=function(){return this.data[this.pos++]<<8|this.data[this.pos++]},h.prototype.decodePixels=function(t){var e,i,a,s,r,n,h,c,p,l,d,u,f,m,g,w,y,x,b,k,T,U,I;if(null==t&&(t=this.imgData),0===t.length)return new Uint8Array(0);for(t=(t=new o(t)).getBytes(),w=(u=this.pixelBitlength/8)*this.width,f=new Uint8Array(w*this.height),n=t.length,g=0,m=0,i=0;m<n;){switch(t[m++]){case 0:for(s=b=0;b<w;s=b+=1)f[i++]=t[m++];break;case 1:for(s=k=0;k<w;s=k+=1)e=t[m++],r=s<u?0:f[i-u],f[i++]=(e+r)%256;break;case 2:for(s=T=0;T<w;s=T+=1)e=t[m++],a=(s-s%u)/u,y=g&&f[(g-1)*w+a*u+s%u],f[i++]=(y+e)%256;break;case 3:for(s=U=0;U<w;s=U+=1)e=t[m++],a=(s-s%u)/u,r=s<u?0:f[i-u],y=g&&f[(g-1)*w+a*u+s%u],f[i++]=(e+Math.floor((r+y)/2))%256;break;case 4:for(s=I=0;I<w;s=I+=1)e=t[m++],a=(s-s%u)/u,r=s<u?0:f[i-u],0===g?y=x=0:(y=f[(g-1)*w+a*u+s%u],x=a&&f[(g-1)*w+(a-1)*u+s%u]),h=r+y-x,c=Math.abs(h-r),l=Math.abs(h-y),d=Math.abs(h-x),p=c<=l&&c<=d?r:l<=d?y:x,f[i++]=(e+p)%256;break;default:throw new Error("Invalid filter algorithm: "+t[m-1])}g++}return f},h.prototype.decodePalette=function(){var t,e,i,a,s,r,n,o,h;for(i=this.palette,r=this.transparency.indexed||[],s=new Uint8Array((r.length||0)+i.length),a=0,t=0,e=n=0,o=i.length;n<o;e=n+=3)s[a++]=i[e],s[a++]=i[e+1],s[a++]=i[e+2],s[a++]=null!=(h=r[t++])?h:255;return s},h.prototype.copyToImageData=function(t,e){var i,a,s,r,n,o,h,c,p,l,d;if(a=this.colors,p=null,i=this.hasAlphaChannel,this.palette.length&&(p=null!=(d=this._decodedPalette)?d:this._decodedPalette=this.decodePalette(),a=4,i=!0),c=(s=t.data||t).length,n=p||e,r=o=0,1===a)for(;r<c;)h=p?4*e[r/4]:o,l=n[h++],s[r++]=l,s[r++]=l,s[r++]=l,s[r++]=i?n[h++]:this.transparency.grayscale&&this.transparency.grayscale===l?0:255,o=h;else for(;r<c;)h=p?4*e[r/4]:o,s[r++]=n[h++],s[r++]=n[h++],s[r++]=n[h++],s[r++]=i?n[h++]:this.transparency.rgb&&this.transparency.rgb[1]===n[h-3]&&this.transparency.rgb[3]===n[h-2]&&this.transparency.rgb[5]===n[h-1]?0:255,o=h},h.prototype.decode=function(){var t;return t=new Uint8Array(this.width*this.height*4),this.copyToImageData(t,this.decodePixels()),t},r=t.document&&t.document.createElement("canvas"),n=r&&r.getContext("2d"),s=function(t){var e;return n.width=t.width,n.height=t.height,n.clearRect(0,0,t.width,t.height),n.putImageData(t,0,0),(e=new Image).src=r.toDataURL(),e},h.prototype.decodeFrames=function(t){var e,i,a,r,n,o,h,c;if(this.animation){for(c=[],i=n=0,o=(h=this.animation.frames).length;n<o;i=++n)e=h[i],a=t.createImageData(e.width,e.height),r=this.decodePixels(new Uint8Array(e.data)),this.copyToImageData(a,r),e.imageData=a,c.push(e.image=s(a));return c}},h.prototype.renderFrame=function(t,s){var r,n,o;return r=(n=this.animation.frames)[s],o=n[s-1],0===s&&t.clearRect(0,0,this.width,this.height),(null!=o?o.disposeOp:void 0)===i?t.clearRect(o.xOffset,o.yOffset,o.width,o.height):(null!=o?o.disposeOp:void 0)===a&&t.putImageData(o.imageData,o.xOffset,o.yOffset),r.blendOp===e&&t.clearRect(r.xOffset,r.yOffset,r.width,r.height),t.drawImage(r.image,r.xOffset,r.yOffset)},h.prototype.animate=function(t){var e,i,a,s,r,n,o=this;return i=0,n=this.animation,s=n.numFrames,a=n.frames,r=n.numPlays,(e=function(){var n,h;if(n=i++%s,h=a[n],o.renderFrame(t,n),s>1&&i/s<r)return o.animation._timeout=setTimeout(e,h.delay)})()},h.prototype.stopAnimation=function(){var t;return clearTimeout(null!=(t=this.animation)?t._timeout:void 0)},h.prototype.render=function(t){var e,i;return t._png&&t._png.stopAnimation(),t._png=this,t.width=this.width,t.height=this.height,e=t.getContext("2d"),this.animation?(this.decodeFrames(e),this.animate(e)):(i=e.createImageData(this.width,this.height),this.copyToImageData(i,this.decodePixels()),e.putImageData(i,0,0))},h}(self);const u=new Set(["jpg","png","bmp","gif"]),f=new Set(["S8","U8","S16","U16","S32","U32","F32","F64"]);async function m(i,a){if(!l)throw new t("rasterCoded:decode","lerc decoder is not supported on big endian platform");await s();const{offset:n,noDataValue:o}=a;let h=a.pixelType?.toUpperCase();h&&!f.has(h)&&(h=null);const{width:c,height:p,pixelType:d,statistics:u,pixels:m,mask:g}=r(i,{inputOffset:n,noDataValue:o,pixelType:h,returnPixelInterleavedDims:a.returnPixelInterleavedDims});return new e({width:c,height:p,pixelType:d.toLowerCase(),pixels:m,mask:g,statistics:u})}async function g(t,i){const a=await p(t,i.pyramidLevel||0),s=new e({width:a.width,height:a.height,pixels:a.pixels,pixelType:a.pixelType.toLowerCase(),mask:a.mask,statistics:null});return s.updateStatistics(),s}async function w(t,i){const a=await c(t,i.customOptions),s=new e({width:a.width,height:a.height,pixels:a.pixels,pixelType:a.pixelType.toLowerCase(),mask:a.mask,statistics:null});return s.updateStatistics(),s}function y(t,i){const a=i.pixelType||"u8",s=e.getPixelArrayConstructor(a),r="u8"===a?t:new s(t.buffer),n=[],o=i.planes||1;if(1===o)n.push(r);else for(let e=0;e<o;e++){const a=(i.width||1)*(i.height||t.length),h=new s(a);for(let t=0;t<a;t++)h[t]=r[t*o+e];n.push(h)}const h=new e({width:i.width||1,height:i.height||t.length,pixels:n,pixelType:a,statistics:null});return h.updateStatistics(),h}function x(t,e){return y(new o(new Uint8Array(t)).getBytes(),e)}function b(t,e){return y(n(t,e.offset,e.eof,!e.isInputBigEndian),e)}function k(t,i,a){const{pixelTypeCtor:s}=A(i.pixelType),r=(0,h.decode)(t,{width:i.width,height:i.height,pixelType:s,format:a}),n=new e({width:i.width,height:i.height,pixels:r.pixels,pixelType:i.pixelType,mask:r.mask,statistics:null});return n.updateStatistics(),n}function T(t){const i=a.decode(t),s=new e({width:i.width,height:i.height,pixels:i.pixels,pixelType:"U8",mask:i.mask,statistics:null});return s.updateStatistics(),s}function U(t,i){const a=new Uint8Array(t),s=new d(a),{width:r,height:n}=i,o=r*n,h=s.decode();let c,p=0,l=0;const u=new Uint8Array(o);for(p=0;p<o;p++)u[p]=h[4*p+3];const f=new e({width:r,height:n,pixels:[],pixelType:"U8",mask:u,statistics:[]});for(p=0;p<3;p++){for(c=new Uint8Array(o),l=0;l<o;l++)c[l]=h[4*l+p];f.addData({pixels:c})}return f.updateStatistics(),f}async function I(t,a,s,r){const n=new i,o={applyJpegMask:!1,format:a,...s},h=await n.decode(t,o,r),c=new e(h);return c.updateStatistics(),c}function v(e){if(null==e)throw new t("rasterCodec:decode","parameter encodeddata is required.");const i=new Uint8Array(e,0,10);let a="";return 255===i[0]&&216===i[1]?a="jpg":137===i[0]&&80===i[1]&&78===i[2]&&71===i[3]?a="png":67===i[0]&&110===i[1]&&116===i[2]&&90===i[3]&&73===i[4]&&109===i[5]&&97===i[6]&&103===i[7]&&101===i[8]&&32===i[9]?a="lerc":76===i[0]&&101===i[1]&&114===i[2]&&99===i[3]&&50===i[4]&&32===i[5]?a="lerc2":73===i[0]&&73===i[1]&&42===i[2]&&0===i[3]||77===i[0]&&77===i[1]&&0===i[2]&&42===i[3]||73===i[0]&&73===i[1]&&43===i[2]&&0===i[3]||77===i[0]&&77===i[1]&&0===i[2]&&43===i[3]?a="tiff":71===i[0]&&73===i[1]&&70===i[2]?a="gif":66===i[0]&&77===i[1]?a="bmp":String.fromCharCode.apply(null,i).toLowerCase().includes("error")&&(a="error"),a}function C(e){let i=null;switch(e){case"lerc":case"lerc2":i=m;break;case"jpg":i=T;break;case"png":i=U;break;case"bsq":case"bip":i=(t,i)=>k(t,i,e);break;case"tiff":i=g;break;case"deflate":i=x;break;case"lzw":i=b;break;case"error":i=()=>{throw new t("rasterCodec:decode","input data contains error")};break;default:i=()=>{throw new t("rasterCodec:decode","unsupported raster format")}}return i}function A(t){let e=null,i=null;switch(t?t.toLowerCase():"f32"){case"u1":case"u2":case"u4":case"u8":i=255,e=Uint8Array;break;case"u16":i=i||65535,e=Uint16Array;break;case"u32":i=i||2**32-1,e=Uint32Array;break;case"s8":i=i||-128,e=Int8Array;break;case"s16":i=i||-32768,e=Int16Array;break;case"s32":i=i||0-2**31,e=Int32Array;break;default:e=Float32Array}return{pixelTypeCtor:e,noDataValue:i}}function D(t,i=1){if(!t)return;const{pixels:a,width:s,height:r,mask:n}=t;if(!a||0===a.length)return;const o=a.length,h=s-1,c=r-1,p=[];let l,d,u,f,m,g,w;const y=e.getPixelArrayConstructor(t.pixelType);if(0===i){for(l=0;l<o;l++){for(m=a[l],g=new y(h*c),d=0;d<c;d++)for(f=d*s,u=0;u<h;u++)g[d*h+u]=m[f+u];p.push(g)}if(n)for(w=new Uint8Array(h*c),d=0;d<c;d++)for(f=d*s,u=0;u<h;u++)w[d*h+u]=n[f+u]}else{for(l=0;l<o;l++){for(m=a[l],g=new y(h*c),d=0;d<c;d++)for(f=d*s,u=0;u<h;u++)g[d*h+u]=(m[f+u]+m[f+u+1]+m[f+s+u]+m[f+s+u+1])/4;p.push(g)}if(n)for(w=new Uint8Array(h*c),d=0;d<c;d++)for(f=d*s,u=0;u<h;u++)w[d*h+u]=Math.min.apply(null,[n[f+u],n[f+u+1],n[f+s+u],n[f+s+u+1]])}t.width=h,t.height=c,t.mask=w,t.pixels=p}function P(t){let e=v(t);return"lerc2"===e?e="lerc":"error"===e&&(e=""),e}async function S(e,i={},a){if(null==e)throw new t("rasterCodec:decode","missing encodeddata parameter.");let s,r,n=i.format&&i.format.toLowerCase();if(!("bsq"!==n&&"bip"!==n||null!=i.width&&null!=i.height))throw new t("rasterCodec:decode","requires width and height in options parameter.");return"tiff"===n&&i.customOptions?w(e,i):((!n||"bsq"!==n&&"bip"!==n&&"deflate"!==n&&"lzw"!==n)&&(n=v(e)),i.useCanvas&&u.has(n)?r=await I(e,n,i,a):(s=C(n),i.isPoint&&((i={...i}).width++,i.height++),r=await s(e,i),i.isPoint&&D(r)),r)}export{S as decode,P as getFormat};
|
|
5
|
+
import t from"../../../core/Error.js";import e from"../PixelBlock.js";import i from"./ImageCanvasDecoder.js";import a from"./JpgPlus.js";import{load as s,decode as r}from"./Lerc.js";import{decode as n}from"./Lzw.js";import{Z as o}from"../../../chunks/Zlib.js";import h from"./Raw.js";import{decodeTileOrStrip as c,decode as p}from"./TiffDecoder.js";import{isPlatformLittleEndian as l}from"./utils.js";var d=function(t){var e,i,a,s,r,n;function h(t){var e,i,a,s,r,n,o,h,c,p,l,d,u;for(this.data=t,this.pos=8,this.palette=[],this.imgData=[],this.transparency={},this.animation=null,this.text={},r=null;;){switch(e=this.readUInt32(),h=function(){var t,e;for(e=[],t=0;t<4;++t)e.push(String.fromCharCode(this.data[this.pos++]));return e}.call(this).join(""),h){case"IHDR":this.width=this.readUInt32(),this.height=this.readUInt32(),this.bits=this.data[this.pos++],this.colorType=this.data[this.pos++],this.compressionMethod=this.data[this.pos++],this.filterMethod=this.data[this.pos++],this.interlaceMethod=this.data[this.pos++];break;case"acTL":this.animation={numFrames:this.readUInt32(),numPlays:this.readUInt32()||1/0,frames:[]};break;case"PLTE":this.palette=this.read(e);break;case"fcTL":r&&this.animation.frames.push(r),this.pos+=4,r={width:this.readUInt32(),height:this.readUInt32(),xOffset:this.readUInt32(),yOffset:this.readUInt32()},s=this.readUInt16(),a=this.readUInt16()||100,r.delay=1e3*s/a,r.disposeOp=this.data[this.pos++],r.blendOp=this.data[this.pos++],r.data=[];break;case"IDAT":case"fdAT":for("fdAT"===h&&(this.pos+=4,e-=4),t=(null!=r?r.data:void 0)||this.imgData,l=0;0<=e?l<e:l>e;0<=e?++l:--l)t.push(this.data[this.pos++]);break;case"tRNS":switch(this.transparency={},this.colorType){case 3:if(this.transparency.indexed=this.read(e),(c=255-this.transparency.indexed.length)>0)for(d=0;0<=c?d<c:d>c;0<=c?++d:--d)this.transparency.indexed.push(255);break;case 0:this.transparency.grayscale=this.read(e)[0];break;case 2:this.transparency.rgb=this.read(e)}break;case"tEXt":n=(p=this.read(e)).indexOf(0),o=String.fromCharCode.apply(String,p.slice(0,n)),this.text[o]=String.fromCharCode.apply(String,p.slice(n+1));break;case"IEND":return r&&this.animation.frames.push(r),this.colors=function(){switch(this.colorType){case 0:case 3:case 4:return 1;case 2:case 6:return 3}}.call(this),this.hasAlphaChannel=4===(u=this.colorType)||6===u,i=this.colors+(this.hasAlphaChannel?1:0),this.pixelBitlength=this.bits*i,this.colorSpace=function(){switch(this.colors){case 1:return"DeviceGray";case 3:return"DeviceRGB"}}.call(this),void(this.imgData=new Uint8Array(this.imgData));default:this.pos+=e}if(this.pos+=4,this.pos>this.data.length)throw new Error("Incomplete or corrupt PNG file")}}return h.load=function(t,e,i){var a;return"function"==typeof e&&(i=e),(a=new XMLHttpRequest).open("GET",t,!0),a.responseType="arraybuffer",a.onload=function(){var t;return t=new h(new Uint8Array(a.response||a.mozResponseArrayBuffer)),"function"==typeof(null!=e?e.getContext:void 0)&&t.render(e),"function"==typeof i?i(t):void 0},a.send(null)},i=1,a=2,e=0,h.prototype.read=function(t){var e,i;for(i=[],e=0;0<=t?e<t:e>t;0<=t?++e:--e)i.push(this.data[this.pos++]);return i},h.prototype.readUInt32=function(){return this.data[this.pos++]<<24|this.data[this.pos++]<<16|this.data[this.pos++]<<8|this.data[this.pos++]},h.prototype.readUInt16=function(){return this.data[this.pos++]<<8|this.data[this.pos++]},h.prototype.decodePixels=function(t){var e,i,a,s,r,n,h,c,p,l,d,u,f,m,g,w,y,x,b,k,T,U,I;if(null==t&&(t=this.imgData),0===t.length)return new Uint8Array(0);for(t=(t=new o(t)).getBytes(),w=(u=this.pixelBitlength/8)*this.width,f=new Uint8Array(w*this.height),n=t.length,g=0,m=0,i=0;m<n;){switch(t[m++]){case 0:for(s=b=0;b<w;s=b+=1)f[i++]=t[m++];break;case 1:for(s=k=0;k<w;s=k+=1)e=t[m++],r=s<u?0:f[i-u],f[i++]=(e+r)%256;break;case 2:for(s=T=0;T<w;s=T+=1)e=t[m++],a=(s-s%u)/u,y=g&&f[(g-1)*w+a*u+s%u],f[i++]=(y+e)%256;break;case 3:for(s=U=0;U<w;s=U+=1)e=t[m++],a=(s-s%u)/u,r=s<u?0:f[i-u],y=g&&f[(g-1)*w+a*u+s%u],f[i++]=(e+Math.floor((r+y)/2))%256;break;case 4:for(s=I=0;I<w;s=I+=1)e=t[m++],a=(s-s%u)/u,r=s<u?0:f[i-u],0===g?y=x=0:(y=f[(g-1)*w+a*u+s%u],x=a&&f[(g-1)*w+(a-1)*u+s%u]),h=r+y-x,c=Math.abs(h-r),l=Math.abs(h-y),d=Math.abs(h-x),p=c<=l&&c<=d?r:l<=d?y:x,f[i++]=(e+p)%256;break;default:throw new Error("Invalid filter algorithm: "+t[m-1])}g++}return f},h.prototype.decodePalette=function(){var t,e,i,a,s,r,n,o,h;for(i=this.palette,r=this.transparency.indexed||[],s=new Uint8Array((r.length||0)+i.length),a=0,i.length,t=0,e=n=0,o=i.length;n<o;e=n+=3)s[a++]=i[e],s[a++]=i[e+1],s[a++]=i[e+2],s[a++]=null!=(h=r[t++])?h:255;return s},h.prototype.copyToImageData=function(t,e){var i,a,s,r,n,o,h,c,p,l,d;if(a=this.colors,p=null,i=this.hasAlphaChannel,this.palette.length&&(p=null!=(d=this._decodedPalette)?d:this._decodedPalette=this.decodePalette(),a=4,i=!0),c=(s=t.data||t).length,n=p||e,r=o=0,1===a)for(;r<c;)h=p?4*e[r/4]:o,l=n[h++],s[r++]=l,s[r++]=l,s[r++]=l,s[r++]=i?n[h++]:this.transparency.grayscale&&this.transparency.grayscale===l?0:255,o=h;else for(;r<c;)h=p?4*e[r/4]:o,s[r++]=n[h++],s[r++]=n[h++],s[r++]=n[h++],s[r++]=i?n[h++]:this.transparency.rgb&&this.transparency.rgb[1]===n[h-3]&&this.transparency.rgb[3]===n[h-2]&&this.transparency.rgb[5]===n[h-1]?0:255,o=h},h.prototype.decode=function(){var t;return t=new Uint8Array(this.width*this.height*4),this.copyToImageData(t,this.decodePixels()),t},r=t.document&&t.document.createElement("canvas"),n=r&&r.getContext("2d"),s=function(t){var e;return n.width=t.width,n.height=t.height,n.clearRect(0,0,t.width,t.height),n.putImageData(t,0,0),(e=new Image).src=r.toDataURL(),e},h.prototype.decodeFrames=function(t){var e,i,a,r,n,o,h,c;if(this.animation){for(c=[],i=n=0,o=(h=this.animation.frames).length;n<o;i=++n)e=h[i],a=t.createImageData(e.width,e.height),r=this.decodePixels(new Uint8Array(e.data)),this.copyToImageData(a,r),e.imageData=a,c.push(e.image=s(a));return c}},h.prototype.renderFrame=function(t,s){var r,n,o;return r=(n=this.animation.frames)[s],o=n[s-1],0===s&&t.clearRect(0,0,this.width,this.height),(null!=o?o.disposeOp:void 0)===i?t.clearRect(o.xOffset,o.yOffset,o.width,o.height):(null!=o?o.disposeOp:void 0)===a&&t.putImageData(o.imageData,o.xOffset,o.yOffset),r.blendOp===e&&t.clearRect(r.xOffset,r.yOffset,r.width,r.height),t.drawImage(r.image,r.xOffset,r.yOffset)},h.prototype.animate=function(t){var e,i,a,s,r,n,o=this;return i=0,n=this.animation,s=n.numFrames,a=n.frames,r=n.numPlays,(e=function(){var n,h;if(n=i++%s,h=a[n],o.renderFrame(t,n),s>1&&i/s<r)return o.animation._timeout=setTimeout(e,h.delay)})()},h.prototype.stopAnimation=function(){var t;return clearTimeout(null!=(t=this.animation)?t._timeout:void 0)},h.prototype.render=function(t){var e,i;return t._png&&t._png.stopAnimation(),t._png=this,t.width=this.width,t.height=this.height,e=t.getContext("2d"),this.animation?(this.decodeFrames(e),this.animate(e)):(i=e.createImageData(this.width,this.height),this.copyToImageData(i,this.decodePixels()),e.putImageData(i,0,0))},h}(self);const u=new Set(["jpg","png","bmp","gif"]),f=new Set(["S8","U8","S16","U16","S32","U32","F32","F64"]);async function m(i,a){if(!l)throw new t("rasterCoded:decode","lerc decoder is not supported on big endian platform");await s();const{offset:n,noDataValue:o}=a;let h=a.pixelType?.toUpperCase();h&&!f.has(h)&&(h=null);const{width:c,height:p,pixelType:d,statistics:u,pixels:m,mask:g}=r(i,{inputOffset:n,noDataValue:o,pixelType:h,returnPixelInterleavedDims:a.returnPixelInterleavedDims});return new e({width:c,height:p,pixelType:d.toLowerCase(),pixels:m,mask:g,statistics:u})}async function g(t,i){const a=await p(t,i),s=new e({width:a.width,height:a.height,pixels:a.pixels,pixelType:a.pixelType.toLowerCase(),mask:a.mask,statistics:null});return s.updateStatistics(),s}async function w(t,i){const a=await c(t,i.customOptions),s=new e({width:a.width,height:a.height,pixels:a.pixels,pixelType:a.pixelType.toLowerCase(),mask:a.mask,statistics:null});return s.updateStatistics(),s}function y(t,i){const a=i.pixelType||"u8",s=e.getPixelArrayConstructor(a),r="u8"===a?t:new s(t.buffer),n=[],o=i.planes||1;if(1===o)n.push(r);else for(let e=0;e<o;e++){const a=(i.width||1)*(i.height||t.length),h=new s(a);for(let t=0;t<a;t++)h[t]=r[t*o+e];n.push(h)}const h=new e({width:i.width||1,height:i.height||t.length,pixels:n,pixelType:a,statistics:null});return h.updateStatistics(),h}function x(t,e){return y(new o(new Uint8Array(t)).getBytes(),e)}function b(t,e){return y(n(t,e.offset,e.eof,!e.isInputBigEndian),e)}function k(t,i,a){const{pixelTypeCtor:s}=A(i.pixelType),r=(0,h.decode)(t,{width:i.width,height:i.height,pixelType:s,format:a}),n=new e({width:i.width,height:i.height,pixels:r.pixels,pixelType:i.pixelType,mask:r.mask,statistics:null});return n.updateStatistics(),n}function T(t,i){const s=a.decode(t,i.hasNoZlibMask),r=new e({width:s.width,height:s.height,pixels:s.pixels,pixelType:"U8",mask:s.mask,statistics:null});return r.updateStatistics(),r}function U(t,i){const a=new Uint8Array(t),s=new d(a),{width:r,height:n}=i,o=r*n,h=s.decode();let c,p=0,l=0;const u=new Uint8Array(o);for(p=0;p<o;p++)u[p]=h[4*p+3];const f=new e({width:r,height:n,pixels:[],pixelType:"U8",mask:u,statistics:[]});for(p=0;p<3;p++){for(c=new Uint8Array(o),l=0;l<o;l++)c[l]=h[4*l+p];f.addData({pixels:c})}return f.updateStatistics(),f}async function I(t,a,s,r){const n=new i,o={applyJpegMask:!1,format:a,...s},h=await n.decode(t,o,r),c=new e(h);return c.updateStatistics(),c}function v(e){if(null==e)throw new t("rasterCodec:decode","parameter encodeddata is required.");const i=new Uint8Array(e,0,10);let a="";return 255===i[0]&&216===i[1]?a="jpg":137===i[0]&&80===i[1]&&78===i[2]&&71===i[3]?a="png":67===i[0]&&110===i[1]&&116===i[2]&&90===i[3]&&73===i[4]&&109===i[5]&&97===i[6]&&103===i[7]&&101===i[8]&&32===i[9]?a="lerc":76===i[0]&&101===i[1]&&114===i[2]&&99===i[3]&&50===i[4]&&32===i[5]?a="lerc2":73===i[0]&&73===i[1]&&42===i[2]&&0===i[3]||77===i[0]&&77===i[1]&&0===i[2]&&42===i[3]||73===i[0]&&73===i[1]&&43===i[2]&&0===i[3]||77===i[0]&&77===i[1]&&0===i[2]&&43===i[3]?a="tiff":71===i[0]&&73===i[1]&&70===i[2]?a="gif":66===i[0]&&77===i[1]?a="bmp":String.fromCharCode.apply(null,i).toLowerCase().includes("error")&&(a="error"),a}function C(e){let i=null;switch(e){case"lerc":case"lerc2":i=m;break;case"jpg":i=T;break;case"png":i=U;break;case"bsq":case"bip":i=(t,i)=>k(t,i,e);break;case"tiff":i=g;break;case"deflate":i=x;break;case"lzw":i=b;break;case"error":i=()=>{throw new t("rasterCodec:decode","input data contains error")};break;default:i=()=>{throw new t("rasterCodec:decode","unsupported raster format")}}return i}function A(t){let e=null,i=null;switch(t?t.toLowerCase():"f32"){case"u1":case"u2":case"u4":case"u8":i=255,e=Uint8Array;break;case"u16":i=i||65535,e=Uint16Array;break;case"u32":i=i||2**32-1,e=Uint32Array;break;case"s8":i=i||-128,e=Int8Array;break;case"s16":i=i||-32768,e=Int16Array;break;case"s32":i=i||0-2**31,e=Int32Array;break;default:e=Float32Array}return{pixelTypeCtor:e,noDataValue:i}}function D(t,i=1){if(!t)return;const{pixels:a,width:s,height:r,mask:n}=t;if(!a||0===a.length)return;const o=a.length,h=s-1,c=r-1,p=[];let l,d,u,f,m,g,w;const y=e.getPixelArrayConstructor(t.pixelType);if(0===i){for(l=0;l<o;l++){for(m=a[l],g=new y(h*c),d=0;d<c;d++)for(f=d*s,u=0;u<h;u++)g[d*h+u]=m[f+u];p.push(g)}if(n)for(w=new Uint8Array(h*c),d=0;d<c;d++)for(f=d*s,u=0;u<h;u++)w[d*h+u]=n[f+u]}else{for(l=0;l<o;l++){for(m=a[l],g=new y(h*c),d=0;d<c;d++)for(f=d*s,u=0;u<h;u++)g[d*h+u]=(m[f+u]+m[f+u+1]+m[f+s+u]+m[f+s+u+1])/4;p.push(g)}if(n)for(w=new Uint8Array(h*c),d=0;d<c;d++)for(f=d*s,u=0;u<h;u++)w[d*h+u]=Math.min.apply(null,[n[f+u],n[f+u+1],n[f+s+u],n[f+s+u+1]])}t.width=h,t.height=c,t.mask=w,t.pixels=p}function P(t){let e=v(t);return"lerc2"===e?e="lerc":"error"===e&&(e=""),e}async function S(e,i={},a){if(null==e)throw new t("rasterCodec:decode","missing encodeddata parameter.");let s,r,n=i.format&&i.format.toLowerCase();if(!("bsq"!==n&&"bip"!==n||null!=i.width&&null!=i.height))throw new t("rasterCodec:decode","requires width and height in options parameter.");return"tiff"===n&&i.customOptions?w(e,i):((!n||"bsq"!==n&&"bip"!==n&&"deflate"!==n&&"lzw"!==n)&&(n=v(e)),i.useCanvas&&u.has(n)?r=await I(e,n,i,a):(s=C(n),i.isPoint&&((i={...i}).width++,i.height++),r=await s(e,i),i.isPoint&&D(r)),r)}export{S as decode,P as getFormat};
|