@arcgis/core 4.28.1 → 4.28.3
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/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/02e86a792dbe2fdec974.js +1 -0
- package/assets/esri/core/workers/chunks/{5386b166f2e5dc0d9143.js → 12797aa1d6a2b49abb3f.js} +1 -1
- package/assets/esri/core/workers/chunks/15852a47129b9e0d04c6.js +1 -0
- package/assets/esri/core/workers/chunks/1687431f7b233d950195.js +1 -0
- package/assets/esri/core/workers/chunks/{a1e16c33f1843dbdce26.js → 175bbe8a048f17dd482b.js} +1 -1
- package/assets/esri/core/workers/chunks/{d0119dff8771e749436a.js → 30d3b31df52d40e5b2e6.js} +1 -1
- package/assets/esri/core/workers/chunks/{768271a12dc7e1781447.js → 32fbd4355a4a649623a7.js} +1 -1
- package/assets/esri/core/workers/chunks/3dbc399eedd347b0fbbb.js +1 -0
- package/assets/esri/core/workers/chunks/{6bc1f6f8a2408fa4bb6a.js → 423672fe765083e1a0ec.js} +1 -1
- package/assets/esri/core/workers/chunks/{18e0c5bfeb1aa7213dfa.js → 4363f2cc3909c9258064.js} +1 -1
- package/assets/esri/core/workers/chunks/{d5fec54e98c8622349a4.js → 46ddc52fe9cdd573a614.js} +1 -1
- package/assets/esri/core/workers/chunks/4747741429e8ff7112bb.js +1 -0
- package/assets/esri/core/workers/chunks/49d958631bcd93f6333a.js +1 -0
- package/assets/esri/core/workers/chunks/4ae8308e5b9c7772a11f.js +1 -0
- package/assets/esri/core/workers/chunks/{da124ccd18d2745195fe.js → 4bd342f13002888b6467.js} +1 -1
- package/assets/esri/core/workers/chunks/{7756ed853b4ba54cd081.js → 5247c00088303da7ef3b.js} +1 -1
- package/assets/esri/core/workers/chunks/534726130ef1698ec89e.js +1 -0
- package/assets/esri/core/workers/chunks/551bc697e3e17983c2bc.js +1 -0
- package/assets/esri/core/workers/chunks/{65d8135c89ffdd17a3c1.js → 59d3f4c0d1a43180aff3.js} +1 -1
- package/assets/esri/core/workers/chunks/{2d92df1e3ba4f05e0510.js → 633b34a5817f1f719e22.js} +1 -1
- package/assets/esri/core/workers/chunks/{c7bd63103f101c09b1ea.js → 6996537249869c41e736.js} +1 -1
- package/assets/esri/core/workers/chunks/{41778f8c49febe1f9404.js → 6fa0cccd4f3e1fa71421.js} +1 -1
- package/assets/esri/core/workers/chunks/{78e49a70193e5adea17c.js → 77f557359a5033d7e429.js} +1 -1
- package/assets/esri/core/workers/chunks/{6334a8a7b671d4042108.js → 7beae29abdfae23b15cc.js} +1 -1
- package/assets/esri/core/workers/chunks/7cc56b132c46c5922dac.js +1 -0
- package/assets/esri/core/workers/chunks/80831e90fe1a52f8f982.js +1 -0
- package/assets/esri/core/workers/chunks/{ea9ae9d2aef01af90896.js → 80d9bb9f247ecdfa266f.js} +1 -1
- package/assets/esri/core/workers/chunks/846e5e51dc278bc3f80f.js +1 -0
- package/assets/esri/core/workers/chunks/{f73563b23fd8dc6cf2fe.js → 86df7357a2bac73c0ef4.js} +1 -1
- package/assets/esri/core/workers/chunks/8b541cbf82a5ba0317ee.js +1 -0
- package/assets/esri/core/workers/chunks/{08a98e85e86ce560d005.js → 8bd621693692050d76aa.js} +1 -1
- package/assets/esri/core/workers/chunks/{630b31a205d9db7147d0.js → 8cdece03397d01767593.js} +1 -1
- package/assets/esri/core/workers/chunks/{b9a726f3bbad6fd4d65a.js → 8e91be2e38010391e351.js} +1 -1
- package/assets/esri/core/workers/chunks/{cbddfcf57f72428a6992.js → 90f96a2ddfb25d851d4d.js} +1 -1
- package/assets/esri/core/workers/chunks/91a3181071874525ed44.js +1 -0
- package/assets/esri/core/workers/chunks/{2304b7456ced997904f6.js → 97fd7b82eec26449977e.js} +1 -1
- package/assets/esri/core/workers/chunks/{b7c81a5bbcdd94b8a7f6.js → 9979ff59a144fe1df80b.js} +1 -1
- package/assets/esri/core/workers/chunks/{0422c5160491fbcf01dc.js → 9d97a20f69047d0c47cc.js} +1 -1
- package/assets/esri/core/workers/chunks/9f0e8dd5c9bacfc0f03c.js +1 -0
- package/assets/esri/core/workers/chunks/{a8e4726c1db23324eb54.js → 9fc1206ad378f0829e0a.js} +1 -1
- package/assets/esri/core/workers/chunks/{09e8babe75407c2e64c4.js → a351ab5082772b267895.js} +1 -1
- package/assets/esri/core/workers/chunks/{43575b9acf9819f195f9.js → a3bbf5da4f7830d2a2a1.js} +1 -1
- package/assets/esri/core/workers/chunks/{b03eaba5fa75d6ef834a.js → a47f74fc959b11f029a5.js} +1 -1
- package/assets/esri/core/workers/chunks/{cb4b17f5cf96a9e36781.js → a8cf23c3a55c1834178c.js} +1 -1
- package/assets/esri/core/workers/chunks/{dd55151bfac60b0deaac.js → ac4636e82a103e2c27ca.js} +1 -1
- package/assets/esri/core/workers/chunks/ae7ba94af6d4fd97dd8b.js +1 -0
- package/assets/esri/core/workers/chunks/{4adf3a8c6b49c381a633.js → b0653f63745e756f55fe.js} +1 -1
- package/assets/esri/core/workers/chunks/{6867ed1860afb7aac536.js → b8f3a1d887c9e054feaa.js} +1 -1
- package/assets/esri/core/workers/chunks/{e06cd10b6f8f363b5131.js → bdc751a752a7ff1387de.js} +1 -1
- package/assets/esri/core/workers/chunks/{70aa04b09143b7dd2ecb.js → c2199fb8f7a54a0ef18a.js} +1 -1
- package/assets/esri/core/workers/chunks/c3f462d11ed570482e7a.js +1 -0
- package/assets/esri/core/workers/chunks/{830d99e6c58a52a58973.js → c8cb5fe1d23145c4842b.js} +1 -1
- package/assets/esri/core/workers/chunks/{1f87f22e00e3218661c6.js → ce53413dd3e2062e8378.js} +1 -1
- package/assets/esri/core/workers/chunks/de30ff1fcb6079178958.js +1 -0
- package/assets/esri/core/workers/chunks/e12090768e945091cc5d.js +1 -0
- package/assets/esri/core/workers/chunks/e3950975030412ff6e20.js +1 -0
- package/assets/esri/core/workers/chunks/e8b7d1c586aff229484c.js +1 -0
- package/assets/esri/core/workers/chunks/{710a6268de62003af825.js → e8d1f91dc97b42d0c4f6.js} +1 -1
- package/assets/esri/core/workers/chunks/{6747503826bfc94bc6c0.js → eb5213ffb83d83a4dd05.js} +1 -1
- package/assets/esri/core/workers/chunks/{020825b9c12f2b6386a7.js → f037e4f9877ea08ced9d.js} +1 -1
- package/assets/esri/core/workers/chunks/f520f093aa81d8ee1790.js +1 -0
- package/assets/esri/core/workers/chunks/{abcfe3bda6f40318b092.js → f7ccc6c681fc9218555c.js} +1 -1
- package/assets/esri/core/workers/chunks/{eea0fb90cd5cc80de388.js → fa750885bb27bbb03e7d.js} +1 -1
- package/assets/esri/core/workers/chunks/{e67c4b7ad06d8404895a.js → fab4ee57b7c5376c9ccd.js} +1 -1
- package/interfaces.d.ts +6 -6
- package/kernel.js +1 -1
- package/layers/StreamLayer.js +1 -1
- package/layers/support/LayerContingentValuesCache.js +1 -1
- package/layers/support/RangeDomain.js +1 -1
- package/layers/support/domainUtils.js +1 -1
- package/layers/support/fieldUtils.js +1 -1
- package/layers/support/labelFormatUtils.js +1 -1
- package/layers/support/vectorTileLayerLoader.js +1 -1
- package/package.json +1 -1
- package/renderers/support/RasterSymbolizer.js +1 -1
- package/support/revision.js +1 -1
- package/versionManagement/VersionManagementService.js +1 -1
- package/views/2d/engine/vectorTiles/TileManager.js +1 -1
- package/views/3d/layers/i3s/I3SIndex.js +1 -1
- package/widgets/ElevationProfile/support/chartUtils.js +1 -1
- package/widgets/FeatureForm/FieldInput.js +1 -1
- package/widgets/FeatureForm/featureFormUtils.js +1 -1
- package/widgets/FeatureForm.js +1 -1
- package/widgets/Search/support/layerSearchUtils.js +1 -1
- package/widgets/support/dataUtils.js +5 -0
- package/widgets/support/dateUtils.js +1 -1
- package/assets/esri/core/workers/chunks/02d235849ba93541d7ad.js +0 -1
- package/assets/esri/core/workers/chunks/0a3da4b73beeaacd4667.js +0 -1
- package/assets/esri/core/workers/chunks/10dc578a90e1194c8720.js +0 -1
- package/assets/esri/core/workers/chunks/1eb5468c7cf653338d53.js +0 -1
- package/assets/esri/core/workers/chunks/1f30ea1a598ddd2e5df3.js +0 -1
- package/assets/esri/core/workers/chunks/366cf9bba6989342e447.js +0 -1
- package/assets/esri/core/workers/chunks/3ac9001b19a90faf5573.js +0 -1
- package/assets/esri/core/workers/chunks/43f7d9366d06d69e7c50.js +0 -1
- package/assets/esri/core/workers/chunks/4672504d6fe649da19f2.js +0 -1
- package/assets/esri/core/workers/chunks/56a61a8bff08ae273de4.js +0 -1
- package/assets/esri/core/workers/chunks/580e7d3cbf6797a50ded.js +0 -1
- package/assets/esri/core/workers/chunks/6046be598e8c673eeb1f.js +0 -1
- package/assets/esri/core/workers/chunks/69c1c850af7ee33258e0.js +0 -1
- package/assets/esri/core/workers/chunks/8f7997e8e6ee9e56239f.js +0 -1
- package/assets/esri/core/workers/chunks/a160576f21ada91995ac.js +0 -1
- package/assets/esri/core/workers/chunks/a50ec5b647a160199cb2.js +0 -1
- package/assets/esri/core/workers/chunks/b138196d304883efd5f6.js +0 -1
- package/assets/esri/core/workers/chunks/b3f5e97b47e896c6008a.js +0 -1
- package/assets/esri/core/workers/chunks/c447f4bf0e5f012f8f9b.js +0 -1
- package/assets/esri/core/workers/chunks/c87e9280681c20d042b5.js +0 -1
- package/assets/esri/core/workers/chunks/cc86c8c88124d916e1b3.js +0 -1
- package/assets/esri/core/workers/chunks/d878bb6409df183ea0ce.js +0 -1
- package/assets/esri/core/workers/chunks/ef757269fb3fe0e74ef8.js +0 -1
package/layers/StreamLayer.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.28/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../chunks/tslib.es6.js";import"../geometry.js";import t 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 r}from"../renderers/support/jsonUtils.js";import{rendererTypes as i,webSceneRendererTypes as o}from"../renderers/support/types.js";import s from"../request.js";import{ClonableMixin as n}from"../core/Clonable.js";import a from"../core/Error.js";import{handlesGroup as p}from"../core/handleUtils.js";import{clone as l}from"../core/lang.js";import m from"../core/Logger.js";import{MultiOriginJSONMixin as d}from"../core/MultiOriginJSONSupport.js";import{debounce as c,throwIfAbortError as u}from"../core/promiseUtils.js";import{property as y}from"../core/accessorSupport/decorators/property.js";import{Integer as f}from"../core/accessorSupport/ensureType.js";import{reader as h}from"../core/accessorSupport/decorators/reader.js";import{subclass as g}from"../core/accessorSupport/decorators/subclass.js";import{featureGeometryTypeKebabDictionary as j}from"../geometry/support/typeUtils.js";import v from"./Layer.js";import{ArcGISService as w}from"./mixins/ArcGISService.js";import{BlendLayer as b}from"./mixins/BlendLayer.js";import{CustomParametersMixin as S}from"./mixins/CustomParametersMixin.js";import{FeatureEffectLayer as I}from"./mixins/FeatureEffectLayer.js";import{FeatureReductionLayer as x}from"./mixins/FeatureReductionLayer.js";import{OperationalLayer as R}from"./mixins/OperationalLayer.js";import{PortalLayer as T}from"./mixins/PortalLayer.js";import{RefreshableLayer as P}from"./mixins/RefreshableLayer.js";import{ScaleRangeLayer as F}from"./mixins/ScaleRangeLayer.js";import{TemporalLayer as L}from"./mixins/TemporalLayer.js";import{labelsVisible as U,legendEnabled as E,maxScale as k,minScale as A,popupEnabled as D,screenSizePerspectiveEnabled as _,url as O}from"./support/commonProperties.js";import{createDefaultRenderer as C}from"./support/featureLayerUtils.js";import V from"./support/Field.js";import{defineFieldProperties as N}from"./support/fieldProperties.js";import{fixRendererFields as G,fixTimeInfoFields as J}from"./support/fieldUtils.js";import M from"./support/LabelClass.js";import{reader as q}from"./support/labelingInfo.js";import z from"./support/PurgeOptions.js";import{loadStyleRenderer as $}from"../renderers/support/styleUtils.js";import W from"../rest/support/Query.js";import{createPopupTemplate as B}from"../support/popupUtils.js";import Q from"../symbols/support/ElevationInfo.js";import{SaveOperationType as H}from"../webdoc/interfaces.js";import K from"../geometry/SpatialReference.js";import X from"../geometry/Extent.js";const Y=N();function Z(e,t){return new a("layer:unsupported",`Layer (${e.title}, ${e.id}) of type '${e.declaredClass}' ${t}`,{layer:e})}let ee=class extends(x(I(b(L(F(P(w(R(T(d(S(n(v))))))))))))){constructor(...e){super(...e),this.copyright=null,this.definitionExpression=null,this.displayField=null,this.elevationInfo=null,this.fields=null,this.fieldsIndex=null,this.geometryDefinition=null,this.geometryType=null,this.labelsVisible=!0,this.labelingInfo=null,this.legendEnabled=!0,this.maxReconnectionAttempts=0,this.maxReconnectionInterval=20,this.maxScale=0,this.minScale=0,this.objectIdField=null,this.operationalLayerType="ArcGISStreamLayer",this.popupEnabled=!0,this.popupTemplate=null,this.purgeOptions=new z,this.refreshInterval=0,this.screenSizePerspectiveEnabled=!0,this.sourceJSON=null,this.spatialReference=K.WGS84,this.type="stream",this.url=null,this.updateInterval=300,this.useViewTime=!0,this.webSocketUrl=null,this._debouncedSaveOperations=c((async(e,t,r)=>{const{save:i,saveAs:o}=await import("./save/streamLayerUtils.js");switch(e){case H.SAVE:return i(this,t);case H.SAVE_AS:return o(this,r,t)}}))}normalizeCtorArgs(e,t){return"string"==typeof e?{url:e,...t}:e}load(e){if(!("WebSocket"in globalThis))return this.addResolvingPromise(Promise.reject(new a("stream-layer:websocket-unsupported","WebSocket is not supported in this browser. StreamLayer will not have real-time connection with the stream service."))),Promise.resolve(this);const t=null!=e?e.signal:null;return this.addResolvingPromise(this.loadFromPortal({supportedTypes:["Stream Service","Feed"]},e).catch(u).then((()=>this._fetchService(t)))),Promise.resolve(this)}get defaultPopupTemplate(){return this.createPopupTemplate()}set featureReduction(e){const t=this._normalizeFeatureReduction(e);this._set("featureReduction",t)}set renderer(e){G(e,this.fieldsIndex),this._set("renderer",e)}readRenderer(e,t,i){t=t.layerDefinition||t;const o=t.drawingInfo?.renderer;if(o){const e=r(o,t,i)||void 0;return e||m.getLogger(this).error("Failed to create renderer",{rendererDefinition:t.drawingInfo.renderer,layer:this,context:i}),e}return C(t,i)}async connect(e){const[{createConnection:t}]=await Promise.all([import("./graphics/sources/connections/createConnection.js"),this.load()]),r=this.geometryType?j.toJSON(this.geometryType):null,{customParameters:i=null,definitionExpression:o=null,geometryDefinition:s=null,maxReconnectionAttempts:n=0,maxReconnectionInterval:a=20,spatialReference:l=this.spatialReference}=e||this.createConnectionParameters(),m=t(this.parsedUrl,this.spatialReference,l,r,{geometry:s,where:o},n,a,i??void 0),d=p([this.on("send-message-to-socket",(e=>m.sendMessageToSocket(e))),this.on("send-message-to-client",(e=>m.sendMessageToClient(e)))]);return m.once("destroy",d.remove),m}createConnectionParameters(){return{spatialReference:this.spatialReference,customParameters:this.customParameters,definitionExpression:this.definitionExpression,geometryDefinition:this.geometryDefinition,maxReconnectionAttempts:this.maxReconnectionAttempts,maxReconnectionInterval:this.maxReconnectionInterval}}createPopupTemplate(e){return B(this,e)}createQuery(){const e=new W;return e.returnGeometry=!0,e.outFields=["*"],e.where=this.definitionExpression||"1=1",e}getFieldDomain(e,t){if(!this.fields)return null;let r=null;return this.fields.some((t=>(t.name===e&&(r=t.domain),!!r))),r}getField(e){return this.fieldsIndex.get(e)}serviceSupportsSpatialReference(e){return!0}sendMessageToSocket(e){this.emit("send-message-to-socket",e)}sendMessageToClient(e){this.emit("send-message-to-client",e)}async save(e){return this._debouncedSaveOperations(H.SAVE,e)}async saveAs(e,t){return this._debouncedSaveOperations(H.SAVE_AS,t,e)}write(e,t){const r=t?.messages;return this.webSocketUrl?(r?.push(Z(this,"using a custom websocket connection cannot be written to web scenes and web maps")),null):this.parsedUrl?super.write(e,t):(r?.push(Z(this,"using a client-side only connection without a url cannot be written to web scenes and web maps")),null)}async _fetchService(e){if(!!!this.webSocketUrl&&this.parsedUrl){if(!this.sourceJSON){const{data:t}=await s(this.parsedUrl.path,{query:{f:"json",...this.customParameters,...this.parsedUrl.query},responseType:"json",signal:e});this.sourceJSON=t}}else{if(!this.timeInfo?.trackIdField)throw new a("stream-layer:missing-metadata","The stream layer trackIdField must be specified.");if(!this.objectIdField){const e=this.fields.find((e=>"oid"===e.type))?.name;if(!e)throw new a("stream-layer:missing-metadata","The stream layer objectIdField must be specified.");this.objectIdField=e}if(!this.fields)throw new a("stream-layer:missing-metadata","The stream layer fields must be specified.");if(this.fields.some((e=>e.name===this.objectIdField))||this.fields.push(new V({name:this.objectIdField,alias:this.objectIdField,type:"oid"})),!this.geometryType)throw new a("stream-layer:missing-metadata","The stream layer geometryType must be specified.");this.webSocketUrl&&(this.url=this.webSocketUrl)}return this.read(this.sourceJSON,{origin:"service",portalItem:this.portalItem,portal:this.portalItem?.portal,url:this.parsedUrl}),G(this.renderer,this.fieldsIndex),J(this.timeInfo,this.fieldsIndex),this.objectIdField||(this.objectIdField="__esri_stream_id__"),$(this,{origin:"service"})}};e([y({type:String})],ee.prototype,"copyright",void 0),e([y({readOnly:!0})],ee.prototype,"defaultPopupTemplate",null),e([y({type:String,json:{name:"layerDefinition.definitionExpression",write:{enabled:!0,allowNull:!0}}})],ee.prototype,"definitionExpression",void 0),e([y({type:String})],ee.prototype,"displayField",void 0),e([y({type:Q})],ee.prototype,"elevationInfo",void 0),e([y({json:{origins:{"web-map":{read:!1,write:!1},"portal-item":{read:!1,write:!1},"web-scene":{read:!1,write:!1}}}})],ee.prototype,"featureReduction",null),e([y(Y.fields)],ee.prototype,"fields",void 0),e([y(Y.fieldsIndex)],ee.prototype,"fieldsIndex",void 0),e([y({type:X,json:{name:"layerDefinition.definitionGeometry",write:!0}})],ee.prototype,"geometryDefinition",void 0),e([y({type:j.apiValues,json:{read:{reader:j.read}}})],ee.prototype,"geometryType",void 0),e([y(U)],ee.prototype,"labelsVisible",void 0),e([y({type:[M],json:{name:"layerDefinition.drawingInfo.labelingInfo",read:{reader:q},write:!0}})],ee.prototype,"labelingInfo",void 0),e([y(E)],ee.prototype,"legendEnabled",void 0),e([y({type:["show","hide"],json:{origins:{"portal-item":{read:!1,write:!1}}}})],ee.prototype,"listMode",void 0),e([y({type:f})],ee.prototype,"maxReconnectionAttempts",void 0),e([y({type:f})],ee.prototype,"maxReconnectionInterval",void 0),e([y(k)],ee.prototype,"maxScale",void 0),e([y(A)],ee.prototype,"minScale",void 0),e([y({type:String})],ee.prototype,"objectIdField",void 0),e([y({value:"ArcGISStreamLayer",type:["ArcGISStreamLayer"]})],ee.prototype,"operationalLayerType",void 0),e([y(D)],ee.prototype,"popupEnabled",void 0),e([y({type:t,json:{name:"popupInfo",write:!0}})],ee.prototype,"popupTemplate",void 0),e([y({type:z})],ee.prototype,"purgeOptions",void 0),e([y({json:{read:!1,write:!1}})],ee.prototype,"refreshInterval",void 0),e([y({types:i,json:{origins:{service:{write:{target:"drawingInfo.renderer",enabled:!1}},"web-scene":{name:"layerDefinition.drawingInfo.renderer",types:o,write:!0}},write:{target:"layerDefinition.drawingInfo.renderer"}}})],ee.prototype,"renderer",null),e([h("service","renderer",["drawingInfo.renderer","defaultSymbol"]),h("renderer",["layerDefinition.drawingInfo.renderer","layerDefinition.defaultSymbol"])],ee.prototype,"readRenderer",null),e([y((()=>{const e=l(_);return e.json.origins["portal-item"]={read:!1,write:!1},e})())],ee.prototype,"screenSizePerspectiveEnabled",void 0),e([y()],ee.prototype,"sourceJSON",void 0),e([y({type:K,json:{origins:{service:{read:{source:"spatialReference"}}}}})],ee.prototype,"spatialReference",void 0),e([y({json:{read:!1}})],ee.prototype,"type",void 0),e([y(O)],ee.prototype,"url",void 0),e([y({type:Number})],ee.prototype,"updateInterval",void 0),e([y({json:{read:!1,write:!1}})],ee.prototype,"useViewTime",void 0),e([y({type:String})],ee.prototype,"webSocketUrl",void 0),ee=e([g("esri.layers.StreamLayer")],ee);const te=ee;export{te as default};
|
|
5
|
+
import{_ as e}from"../chunks/tslib.es6.js";import"../geometry.js";import t 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 r}from"../renderers/support/jsonUtils.js";import{rendererTypes as i,webSceneRendererTypes as o}from"../renderers/support/types.js";import s from"../request.js";import{ClonableMixin as n}from"../core/Clonable.js";import a from"../core/Error.js";import{handlesGroup as p}from"../core/handleUtils.js";import{clone as l}from"../core/lang.js";import d from"../core/Logger.js";import{MultiOriginJSONMixin as m}from"../core/MultiOriginJSONSupport.js";import{debounce as c,throwIfAbortError as u}from"../core/promiseUtils.js";import{property as y}from"../core/accessorSupport/decorators/property.js";import{Integer as f}from"../core/accessorSupport/ensureType.js";import{reader as h}from"../core/accessorSupport/decorators/reader.js";import{subclass as g}from"../core/accessorSupport/decorators/subclass.js";import{featureGeometryTypeKebabDictionary as j}from"../geometry/support/typeUtils.js";import v from"./Layer.js";import{ArcGISService as w}from"./mixins/ArcGISService.js";import{BlendLayer as b}from"./mixins/BlendLayer.js";import{CustomParametersMixin as S}from"./mixins/CustomParametersMixin.js";import{FeatureEffectLayer as I}from"./mixins/FeatureEffectLayer.js";import{FeatureReductionLayer as x}from"./mixins/FeatureReductionLayer.js";import{OperationalLayer as R}from"./mixins/OperationalLayer.js";import{PortalLayer as T}from"./mixins/PortalLayer.js";import{RefreshableLayer as F}from"./mixins/RefreshableLayer.js";import{ScaleRangeLayer as P}from"./mixins/ScaleRangeLayer.js";import{TemporalLayer as L}from"./mixins/TemporalLayer.js";import{labelsVisible as U,legendEnabled as E,maxScale as k,minScale as A,popupEnabled as D,screenSizePerspectiveEnabled as O,url as _}from"./support/commonProperties.js";import{createDefaultRenderer as C}from"./support/featureLayerUtils.js";import V from"./support/Field.js";import{defineFieldProperties as N}from"./support/fieldProperties.js";import{fixRendererFields as G,fixTimeInfoFields as J}from"./support/fieldUtils.js";import M from"./support/LabelClass.js";import{reader as q}from"./support/labelingInfo.js";import z from"./support/PurgeOptions.js";import{loadStyleRenderer as $}from"../renderers/support/styleUtils.js";import W from"../rest/support/Query.js";import{createPopupTemplate as B}from"../support/popupUtils.js";import Q from"../symbols/support/ElevationInfo.js";import{SaveOperationType as H}from"../webdoc/interfaces.js";import K from"../geometry/SpatialReference.js";import X from"../geometry/Extent.js";const Y=N();function Z(e,t){return new a("layer:unsupported",`Layer (${e.title}, ${e.id}) of type '${e.declaredClass}' ${t}`,{layer:e})}let ee=class extends(x(I(b(L(P(F(w(R(T(m(S(n(v))))))))))))){constructor(...e){super(...e),this.copyright=null,this.definitionExpression=null,this.displayField=null,this.elevationInfo=null,this.fields=null,this.fieldsIndex=null,this.geometryDefinition=null,this.geometryType=null,this.labelsVisible=!0,this.labelingInfo=null,this.legendEnabled=!0,this.maxReconnectionAttempts=0,this.maxReconnectionInterval=20,this.maxScale=0,this.minScale=0,this.objectIdField=null,this.operationalLayerType="ArcGISStreamLayer",this.outFields=["*"],this.popupEnabled=!0,this.popupTemplate=null,this.purgeOptions=new z,this.refreshInterval=0,this.screenSizePerspectiveEnabled=!0,this.sourceJSON=null,this.spatialReference=K.WGS84,this.type="stream",this.url=null,this.updateInterval=300,this.useViewTime=!0,this.webSocketUrl=null,this._debouncedSaveOperations=c((async(e,t,r)=>{const{save:i,saveAs:o}=await import("./save/streamLayerUtils.js");switch(e){case H.SAVE:return i(this,t);case H.SAVE_AS:return o(this,r,t)}}))}normalizeCtorArgs(e,t){return"string"==typeof e?{url:e,...t}:e}load(e){if(!("WebSocket"in globalThis))return this.addResolvingPromise(Promise.reject(new a("stream-layer:websocket-unsupported","WebSocket is not supported in this browser. StreamLayer will not have real-time connection with the stream service."))),Promise.resolve(this);const t=null!=e?e.signal:null;return this.addResolvingPromise(this.loadFromPortal({supportedTypes:["Stream Service","Feed"]},e).catch(u).then((()=>this._fetchService(t)))),Promise.resolve(this)}get defaultPopupTemplate(){return this.createPopupTemplate()}set featureReduction(e){const t=this._normalizeFeatureReduction(e);this._set("featureReduction",t)}set renderer(e){G(e,this.fieldsIndex),this._set("renderer",e)}readRenderer(e,t,i){t=t.layerDefinition||t;const o=t.drawingInfo?.renderer;if(o){const e=r(o,t,i)||void 0;return e||d.getLogger(this).error("Failed to create renderer",{rendererDefinition:t.drawingInfo.renderer,layer:this,context:i}),e}return C(t,i)}async connect(e){const[{createConnection:t}]=await Promise.all([import("./graphics/sources/connections/createConnection.js"),this.load()]),r=this.geometryType?j.toJSON(this.geometryType):null,{customParameters:i=null,definitionExpression:o=null,geometryDefinition:s=null,maxReconnectionAttempts:n=0,maxReconnectionInterval:a=20,spatialReference:l=this.spatialReference}=e||this.createConnectionParameters(),d=t(this.parsedUrl,this.spatialReference,l,r,{geometry:s,where:o},n,a,i??void 0),m=p([this.on("send-message-to-socket",(e=>d.sendMessageToSocket(e))),this.on("send-message-to-client",(e=>d.sendMessageToClient(e)))]);return d.once("destroy",m.remove),d}createConnectionParameters(){return{spatialReference:this.spatialReference,customParameters:this.customParameters,definitionExpression:this.definitionExpression,geometryDefinition:this.geometryDefinition,maxReconnectionAttempts:this.maxReconnectionAttempts,maxReconnectionInterval:this.maxReconnectionInterval}}createPopupTemplate(e){return B(this,e)}createQuery(){const e=new W;return e.returnGeometry=!0,e.outFields=["*"],e.where=this.definitionExpression||"1=1",e}getFieldDomain(e,t){if(!this.fields)return null;let r=null;return this.fields.some((t=>(t.name===e&&(r=t.domain),!!r))),r}getField(e){return this.fieldsIndex.get(e)}serviceSupportsSpatialReference(e){return!0}sendMessageToSocket(e){this.emit("send-message-to-socket",e)}sendMessageToClient(e){this.emit("send-message-to-client",e)}async save(e){return this._debouncedSaveOperations(H.SAVE,e)}async saveAs(e,t){return this._debouncedSaveOperations(H.SAVE_AS,t,e)}write(e,t){const r=t?.messages;return this.webSocketUrl?(r?.push(Z(this,"using a custom websocket connection cannot be written to web scenes and web maps")),null):this.parsedUrl?super.write(e,t):(r?.push(Z(this,"using a client-side only connection without a url cannot be written to web scenes and web maps")),null)}async _fetchService(e){if(!!!this.webSocketUrl&&this.parsedUrl){if(!this.sourceJSON){const{data:t}=await s(this.parsedUrl.path,{query:{f:"json",...this.customParameters,...this.parsedUrl.query},responseType:"json",signal:e});this.sourceJSON=t}}else{if(!this.timeInfo?.trackIdField)throw new a("stream-layer:missing-metadata","The stream layer trackIdField must be specified.");if(!this.objectIdField){const e=this.fields.find((e=>"oid"===e.type))?.name;if(!e)throw new a("stream-layer:missing-metadata","The stream layer objectIdField must be specified.");this.objectIdField=e}if(!this.fields)throw new a("stream-layer:missing-metadata","The stream layer fields must be specified.");if(this.fields.some((e=>e.name===this.objectIdField))||this.fields.push(new V({name:this.objectIdField,alias:this.objectIdField,type:"oid"})),!this.geometryType)throw new a("stream-layer:missing-metadata","The stream layer geometryType must be specified.");this.webSocketUrl&&(this.url=this.webSocketUrl)}return this.read(this.sourceJSON,{origin:"service",portalItem:this.portalItem,portal:this.portalItem?.portal,url:this.parsedUrl}),G(this.renderer,this.fieldsIndex),J(this.timeInfo,this.fieldsIndex),this.objectIdField||(this.objectIdField="__esri_stream_id__"),$(this,{origin:"service"})}};e([y({type:String})],ee.prototype,"copyright",void 0),e([y({readOnly:!0})],ee.prototype,"defaultPopupTemplate",null),e([y({type:String,json:{name:"layerDefinition.definitionExpression",write:{enabled:!0,allowNull:!0}}})],ee.prototype,"definitionExpression",void 0),e([y({type:String})],ee.prototype,"displayField",void 0),e([y({type:Q})],ee.prototype,"elevationInfo",void 0),e([y({json:{origins:{"web-map":{read:!1,write:!1},"portal-item":{read:!1,write:!1},"web-scene":{read:!1,write:!1}}}})],ee.prototype,"featureReduction",null),e([y(Y.fields)],ee.prototype,"fields",void 0),e([y(Y.fieldsIndex)],ee.prototype,"fieldsIndex",void 0),e([y({type:X,json:{name:"layerDefinition.definitionGeometry",write:!0}})],ee.prototype,"geometryDefinition",void 0),e([y({type:j.apiValues,json:{read:{reader:j.read}}})],ee.prototype,"geometryType",void 0),e([y(U)],ee.prototype,"labelsVisible",void 0),e([y({type:[M],json:{name:"layerDefinition.drawingInfo.labelingInfo",read:{reader:q},write:!0}})],ee.prototype,"labelingInfo",void 0),e([y(E)],ee.prototype,"legendEnabled",void 0),e([y({type:["show","hide"],json:{origins:{"portal-item":{read:!1,write:!1}}}})],ee.prototype,"listMode",void 0),e([y({type:f})],ee.prototype,"maxReconnectionAttempts",void 0),e([y({type:f})],ee.prototype,"maxReconnectionInterval",void 0),e([y(k)],ee.prototype,"maxScale",void 0),e([y(A)],ee.prototype,"minScale",void 0),e([y({type:String})],ee.prototype,"objectIdField",void 0),e([y({value:"ArcGISStreamLayer",type:["ArcGISStreamLayer"]})],ee.prototype,"operationalLayerType",void 0),e([y({readOnly:!0})],ee.prototype,"outFields",void 0),e([y(D)],ee.prototype,"popupEnabled",void 0),e([y({type:t,json:{name:"popupInfo",write:!0}})],ee.prototype,"popupTemplate",void 0),e([y({type:z})],ee.prototype,"purgeOptions",void 0),e([y({json:{read:!1,write:!1}})],ee.prototype,"refreshInterval",void 0),e([y({types:i,json:{origins:{service:{write:{target:"drawingInfo.renderer",enabled:!1}},"web-scene":{name:"layerDefinition.drawingInfo.renderer",types:o,write:!0}},write:{target:"layerDefinition.drawingInfo.renderer"}}})],ee.prototype,"renderer",null),e([h("service","renderer",["drawingInfo.renderer","defaultSymbol"]),h("renderer",["layerDefinition.drawingInfo.renderer","layerDefinition.defaultSymbol"])],ee.prototype,"readRenderer",null),e([y((()=>{const e=l(O);return e.json.origins["portal-item"]={read:!1,write:!1},e})())],ee.prototype,"screenSizePerspectiveEnabled",void 0),e([y()],ee.prototype,"sourceJSON",void 0),e([y({type:K,json:{origins:{service:{read:{source:"spatialReference"}}}}})],ee.prototype,"spatialReference",void 0),e([y({json:{read:!1}})],ee.prototype,"type",void 0),e([y(_)],ee.prototype,"url",void 0),e([y({type:Number})],ee.prototype,"updateInterval",void 0),e([y({json:{read:!1,write:!1}})],ee.prototype,"useViewTime",void 0),e([y({type:String})],ee.prototype,"webSocketUrl",void 0),ee=e([g("esri.layers.StreamLayer")],ee);const te=ee;export{te 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.28/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../request.js";import{isSome as n}from"../../core/arrayUtils.js";import{JSONSupportMixin as i}from"../../core/JSONSupport.js";import s from"../../core/Loadable.js";import{property as r}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/has.js";import{subclass as o}from"../../core/accessorSupport/decorators/subclass.js";import{parse as a}from"./arcgisLayerUrl.js";import l from"./Contingency.js";import u from"./ContingencyConstraintViolation.js";import c from"./ContingentValue.js";import p from"./ContingentValuesResult.js";import d from"./FieldGroup.js";import{isStringField as f,isDateField as y}from"./fieldUtils.js";import m from"./Subtype.js";var h;let g=h=class extends(i(s)){constructor(e){super(e),this.request=t,this.fieldGroups=null,this.fieldGroupDefinitions=null}initialize(){}get subtypeFieldName(){const{layer:e}=this;return"subtype-group"===e.type?e.subtypeField:e.typeIdField}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 h({layer:e}).load();if(void 0===n){const t=a(e.url);if(null==t)return null;const n=t.url.path;if((await h._staticFetchEnterpriseFeatureRoot(n)).supportsQueryDataElements){const t=e.layerId.toString(),i=await h._staticFetchEnterpriseFieldGroup(n,t);if(i){const t=i.map((e=>({name:e.name,isEditingRestrictive:e.isEditingRestrictive,fields:e.fieldNames.names})));return new h({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=Object.keys(e),i=[],s=[];for(const r of this.fieldGroups){const o=r.isEditingRestrictive?"error":"warning";if(t&&!r.fields.some((e=>t.includes(e))))continue;if(!r.fields.every((e=>n.includes(e)))){s.push(new u({fieldGroup:r,type:o}));continue}let a=!1;const l=e[this.subtypeFieldName],c=r.contingencies.filter((e=>!(!e.isRetired&&e.subtype)||e.subtype.code===l));for(const t of c){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){a=!0;break}}a||i.push(new u({fieldGroup:r,type:o}))}return{invalid:i,incomplete:s}}getContingentValues(e,t,n=!1){const i=e[this.subtypeFieldName],s=null!=i,r={};let o=[];const a=this.fieldGroups.filter((e=>e.fields.includes(t)));o.push(new c({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):[]}return 1===a.length&&n&&(o=[]),new p({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?null!=t&&null!=n?n<s.minValue?(i.push(new c({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 c({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 c({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 c({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 c({objectType:"range",minValue:i,maxValue:r.maxValue}));break}n.push(new c({objectType:"range",minValue:i,maxValue:e.maxValue}))}else n.push(new c({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=a(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 h._staticFetchEnterpriseFieldGroup(e,t,n)}async _fetchEnterpriseFeatureRoot(e,t){return h._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=a(this.layer.url).url.path;if(n.hasContingentValuesDefinition){const n=await this._fetchAGOLContingentValues(s,i,t);return this._constructFieldGroupsAGOL(e,n)}const r=await this._fetchEnterpriseContingentValues(s,i,t);return this._constructFieldGroupsEnterprise(e,r)}_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 d({name:e.name,isEditingRestrictive:e.isEditingRestrictive,fields:e.fields,contingencies:i})}return null})).filter(n)}_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),a=this.layer.getField(s);if("string"===a?.type){const e=n.stringDicts.find((e=>e.domain===r?.name));e&&(t=e.entries[t])}const u=r?.codedValues.find((e=>e.code===t)),p=new c({codedValue:u,objectType:"code"});o[s]=p}else if("Range"===r){const t=e.values[l];l++;const n=t.range[0],i=t.range[1],r=new c({minValue:n,maxValue:i,objectType:"range"});o[s]=r}else if("Any"===r){const e=new c({objectType:"any"});o[s]=e}else{const e=new c({objectType:"null"});o[s]=e}}return new l({id:s,isRetired:r,subtype:i,values:o})}_constructFieldGroupsEnterprise(e,t){const i=t.fieldGroups;return e.map((e=>{const n=i.find((t=>t.name===e.name));if(n){const i=n.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(f(n))s=t.stringDictionary[s];else if(y(n)){const e=new Date(`${s}+00:00`);s=e.getTime()}const a=e?.codedValues.find((e=>e.code===s)),l=new c({codedValue:a,objectType:"code"});o[i]=l}else if("object"==typeof s){const e=s.minValue,t=s.maxValue,n=new c({minValue:e,maxValue:t,objectType:"range"});o[i]=n}else if(s){const e=new c({objectType:"any"});o[i]=e}else{const e=new c({objectType:"null"});o[i]=e}}return new l({id:i,isRetired:s,subtype:r,values:o})}));return new d({name:e.name,isEditingRestrictive:e.isEditingRestrictive,fields:e.fields,contingencies:i})}return null})).filter(n)}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=m.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=m.fromJSON(i)}return n||null}_findDomainByFieldName(e,t){const n=e.domains;if(n){const[e,i]=Object.entries(n).find((([e])=>e.trim().toLowerCase()===t.trim().toLowerCase()))||[];return i||null}return null}_getDomain(e,t){const n=e?this._findDomainByFieldName(e,t):this.layer.getFieldDomain(t);return"inherited"===n?.type?this.layer.getFieldDomain(t):n}};e([r({constructOnly:!0})],g.prototype,"layer",void 0),e([r({constructOnly:!0})],g.prototype,"request",void 0),e([r({type:[d]})],g.prototype,"fieldGroups",void 0),e([r({constructOnly:!0})],g.prototype,"fieldGroupDefinitions",void 0),e([r()],g.prototype,"subtypeFieldName",null),g=h=e([o("esri.layers.support.LayerContingentValuesCache")],g);const V=g;export{V as default};
|
|
5
|
+
import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../request.js";import{isSome as n}from"../../core/arrayUtils.js";import{JSONSupportMixin as i}from"../../core/JSONSupport.js";import s from"../../core/Loadable.js";import{property as r}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/has.js";import{subclass as o}from"../../core/accessorSupport/decorators/subclass.js";import{parse as a}from"./arcgisLayerUrl.js";import l from"./Contingency.js";import u from"./ContingencyConstraintViolation.js";import c from"./ContingentValue.js";import p from"./ContingentValuesResult.js";import d from"./FieldGroup.js";import{isStringField as f,isDateField as y}from"./fieldUtils.js";import m from"./Subtype.js";var h;let g=h=class extends(i(s)){constructor(e){super(e),this.request=t,this.fieldGroups=null,this.fieldGroupDefinitions=null}initialize(){}get subtypeFieldName(){const{layer:e}=this;return"subtype-group"===e.type?e.subtypeField:e.typeIdField}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 h({layer:e}).load();if(void 0===n){const t=a(e.url);if(null==t)return null;const n=t.url.path;if((await h._staticFetchEnterpriseFeatureRoot(n)).supportsQueryDataElements){const t=e.layerId.toString(),i=await h._staticFetchEnterpriseFieldGroup(n,t);if(i){const t=i.map((t=>({name:t.name,isEditingRestrictive:t.isEditingRestrictive,fields:t.fieldNames.names.map((t=>e.fieldsIndex.normalizeFieldName(t)))})));return new h({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=Object.keys(e),i=[],s=[];for(const r of this.fieldGroups){const o=r.isEditingRestrictive?"error":"warning";if(t&&!r.fields.some((e=>t.includes(e))))continue;if(!r.fields.every((e=>n.includes(e)))){s.push(new u({fieldGroup:r,type:o}));continue}let a=!1;const l=e[this.subtypeFieldName],c=r.contingencies.filter((e=>!(!e.isRetired&&e.subtype)||e.subtype.code===l));for(const t of c){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){a=!0;break}}a||i.push(new u({fieldGroup:r,type:o}))}return{invalid:i,incomplete:s}}getContingentValues(e,t,n=!1){const i=e[this.subtypeFieldName],s=null!=i,r={};let o=[];const a=this.fieldGroups.filter((e=>e.fields.includes(t)));o.push(new c({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):[]}return 1===a.length&&n&&(o=[]),new p({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?null!=t&&null!=n?n<s.minValue?(i.push(new c({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 c({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 c({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 c({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 c({objectType:"range",minValue:i,maxValue:r.maxValue}));break}n.push(new c({objectType:"range",minValue:i,maxValue:e.maxValue}))}else n.push(new c({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=a(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 h._staticFetchEnterpriseFieldGroup(e,t,n)}async _fetchEnterpriseFeatureRoot(e,t){return h._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=a(this.layer.url).url.path;if(n.hasContingentValuesDefinition){const n=await this._fetchAGOLContingentValues(s,i,t);return this._constructFieldGroupsAGOL(e,n)}const r=await this._fetchEnterpriseContingentValues(s,i,t);return this._constructFieldGroupsEnterprise(e,r)}_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 d({name:e.name,isEditingRestrictive:e.isEditingRestrictive,fields:e.fields,contingencies:i})}return null})).filter(n)}_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),a=this.layer.getField(s);if("string"===a?.type){const e=n.stringDicts.find((e=>e.domain===r?.name));e&&(t=e.entries[t])}const u=r?.codedValues.find((e=>e.code===t)),p=new c({codedValue:u,objectType:"code"});o[s]=p}else if("Range"===r){const t=e.values[l];l++;const n=t.range[0],i=t.range[1],r=new c({minValue:n,maxValue:i,objectType:"range"});o[s]=r}else if("Any"===r){const e=new c({objectType:"any"});o[s]=e}else{const e=new c({objectType:"null"});o[s]=e}}return new l({id:s,isRetired:r,subtype:i,values:o})}_constructFieldGroupsEnterprise(e,t){const i=t.fieldGroups;return e.map((e=>{const n=i.find((t=>t.name===e.name));if(n){const i=n.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(f(n))s=t.stringDictionary[s];else if(y(n)){const e=new Date(`${s}+00:00`);s=e.getTime()}const a=e?.codedValues.find((e=>e.code===s)),l=new c({codedValue:a,objectType:"code"});o[i]=l}else if("object"==typeof s){const e=s.minValue,t=s.maxValue,n=new c({minValue:e,maxValue:t,objectType:"range"});o[i]=n}else if(s){const e=new c({objectType:"any"});o[i]=e}else{const e=new c({objectType:"null"});o[i]=e}}return new l({id:i,isRetired:s,subtype:r,values:o})}));return new d({name:e.name,isEditingRestrictive:e.isEditingRestrictive,fields:e.fields,contingencies:i})}return null})).filter(n)}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=m.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=m.fromJSON(i)}return n||null}_findDomainByFieldName(e,t){const n=e.domains;if(n){const[e,i]=Object.entries(n).find((([e])=>e.trim().toLowerCase()===t.trim().toLowerCase()))||[];return i||null}return null}_getDomain(e,t){const n=e?this._findDomainByFieldName(e,t):this.layer.getFieldDomain(t);return"inherited"===n?.type?this.layer.getFieldDomain(t):n}};e([r({constructOnly:!0})],g.prototype,"layer",void 0),e([r({constructOnly:!0})],g.prototype,"request",void 0),e([r({type:[d]})],g.prototype,"fieldGroups",void 0),e([r({constructOnly:!0})],g.prototype,"fieldGroupDefinitions",void 0),e([r()],g.prototype,"subtypeFieldName",null),g=h=e([o("esri.layers.support.LayerContingentValuesCache")],g);const V=g;export{V 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.28/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../chunks/tslib.es6.js";import{property as r}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{enumeration as
|
|
5
|
+
import{_ as e}from"../../chunks/tslib.es6.js";import{property as r}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{enumeration as a}from"../../core/accessorSupport/decorators/enumeration.js";import{subclass as o}from"../../core/accessorSupport/decorators/subclass.js";import t from"./Domain.js";var s;let i=s=class extends t{constructor(e){super(e),this.maxValue=null,this.minValue=null,this.type="range"}clone(){return new s({maxValue:this.maxValue,minValue:this.minValue,name:this.name})}};e([r({json:{type:[Number],read:{source:"range",reader:(e,r)=>r.range?.[1]},write:{enabled:!1,overridePolicy(){return{enabled:null!=this.maxValue&&null==this.minValue}},target:"range",writer(e,r,a){r[a]=[this.minValue||0,e]}}}})],i.prototype,"maxValue",void 0),e([r({json:{type:[Number],read:{source:"range",reader:(e,r)=>r.range?.[0]},write:{target:"range",writer(e,r,a){r[a]=[e,this.maxValue||0]}}}})],i.prototype,"minValue",void 0),e([a({range:"range"})],i.prototype,"type",void 0),i=s=e([o("esri.layers.support.RangeDomain")],i);const n=i;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.28/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
|
|
5
|
+
import{isString as n}from"../../widgets/support/dataUtils.js";import{dateOnlyToDateTime as e,timeOnlyToDateTime as l,timestampOffsetToDateTime as i}from"../../widgets/support/dateUtils.js";var t;!function(n){n.VALUE_OUT_OF_RANGE="domain-validation-error::value-out-of-range",n.INVALID_CODED_VALUE="domain-validation-error::invalid-coded-value"}(t||(t={}));const r=new Set(["integer","small-integer","big-integer","esriFieldTypeInteger","esriFieldTypeSmallInteger","esriFieldTypeBigInteger"]);function u(n){return null!=n&&r.has(n.type)}function a(n){return null!=n&&("date-only"===n.type||"esriFieldTypeDateOnly"===n.type)}function o(n){return null!=n&&("timestamp-offset"===n.type||"esriFieldTypeTimestampOffset"===n.type)}function s(n){return null!=n&&("time-only"===n.type||"esriFieldTypeTimeOnly"===n.type)}function m(n,e){const l=n?.domain;if(!l)return null;switch(l.type){case"range":{const{min:l,max:i}=d(n);if(null!=l&&+e<l||null!=i&&+e>i)return t.VALUE_OUT_OF_RANGE;break}case"coded-value":case"codedValue":if(null==l.codedValues||l.codedValues.every((n=>null==n||n.code!==e)))return t.INVALID_CODED_VALUE}return null}function d(n,e){const l=e??n?.domain;if(!l||"range"!==l.type)return;const i="range"in l?l.range[0]:l.minValue,t="range"in l?l.range[1]:l.maxValue,r=u(n);return a(n)||s(n)||o(n)?{...p(n,t,i),isInteger:r}:{min:null!=i&&"number"==typeof i?i:null,max:null!=t&&"number"==typeof t?t:null,rawMin:i,rawMax:t,isInteger:r}}function p(t,r,u){if(a(t)){return{min:null!=u&&n(u)?e(u).toMillis():null,max:null!=r&&n(r)?e(r).toMillis():null,rawMin:u,rawMax:r}}if(s(t)){return{min:null!=u&&n(u)?l(u).toMillis():null,max:null!=r&&n(r)?l(r).toMillis():null,rawMin:u,rawMax:r}}if(o(t)){return{min:null!=u&&n(u)?i(u).toMillis():null,max:null!=r&&n(r)?i(r).toMillis():null,rawMin:u,rawMax:r}}return{max:null,min:null}}export{t as DomainValidationError,p as dateTimeFieldValuesToNumericRange,d as getDomainRange,m as validateDomainValue};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.28/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import e from"../../core/Error.js";import{getDeepValue as n,setDeepValue as i}from"../../core/object.js";import{union as t}from"../../core/SetUtils.js";import{parseWhereClause as r}from"../../core/sql.js";import{validateDomainValue as l,getDomainRange as o,DomainValidationError as s}from"./domainUtils.js";import{loadArcade as a}from"../../support/arcadeOnDemand.js";const u=/^([0-9_])/,f=/[^a-z0-9_\u0080-\uffff]+/gi;function d(e){if(null==e)return null;return e.trim().replaceAll(f,"_").replace(u,"F$1")||null}const c=["field","field2","field3","normalizationField","rotationInfo.field","proportionalSymbolInfo.field","proportionalSymbolInfo.normalizationField","colorInfo.field","colorInfo.normalizationField"],p=["field","normalizationField"];function m(e,n){if(null!=e&&null!=n)for(const i of Array.isArray(e)?e:[e])if(y(c,i,n),"visualVariables"in i&&i.visualVariables)for(const e of i.visualVariables)y(p,e,n)}function y(e,t,r){if(e)for(const l of e){const e=n(l,t),o=e&&"function"!=typeof e&&r.get(e);o&&i(l,o.name,t)}}function g(e,n){if(null!=e&&n?.fields?.length)if("startField"in e){const i=n.get(e.startField),t=n.get(e.endField);e.startField=i?.name??null,e.endField=t?.name??null}else{const i=n.get(e.startTimeField),t=n.get(e.endTimeField);e.startTimeField=i?.name??null,e.endTimeField=t?.name??null}}const F=new Set;function I(e,n){return e&&n?(F.clear(),b(F,e,n),Array.from(F).sort()):[]}function b(e,n,i){if(i)if(n?.fields?.length)if(i.includes("*"))for(const{name:t}of n.fields)e.add(t);else for(const t of i)T(e,n,t);else{if(i.includes("*"))return e.clear(),void e.add("*");for(const n of i)null!=n&&e.add(n)}}function T(e,n,i){if("string"==typeof i)if(n){const t=n.get(i);t&&e.add(t.name)}else e.add(i)}function x(e,n){return null==n||null==e?[]:n.includes("*")?(e.fields??[]).map((e=>e.name)):n}function w(e,n,i=1){if(!n||!e)return[];if(n.includes("*"))return["*"];const t=I(e,n);return t.length/e.fields.length>=i?["*"]:t}async function h(e,n,i){if(!i)return;const{arcadeUtils:t}=await a(),r=t.extractFieldNames(i,n?.fields?.map((e=>e.name)));for(const l of r)T(e,n,l)}async function _(n,i,t){if(t&&"1=1"!==t){const l=await r(t,i);if(!l.isStandardized)throw new e("fieldUtils:collectFilterFields","Where clause is not standardized",{where:t});b(n,i,l.fieldNames)}}function E({displayField:e,fields:n}){return e||(n?.length?v(n,"name-or-title")||v(n,"unique-identifier")||v(n,"type-or-category")||S(n):null)}function S(e){for(const n of e){if(!n?.name)continue;const e=n.name.toLowerCase();if(e.includes("name")||e.includes("title"))return n.name}return null}function v(e,n){for(const i of e)if(i?.valueType&&i.valueType===n)return i.name;return null}async function A(e){if(!e)return[];const n=new Set;return await N(n,e),Array.from(n).sort()}async function N(e,n){if(!n)return;const i=n.elevationInfo?.featureExpressionInfo;return i?i.collectRequiredFields(e,n.fieldsIndex):void 0}function $(e,n,i){i.onStatisticExpression?h(e,n,i.onStatisticExpression.expression):e.add(i.onStatisticField)}async function D(e,n,i){if(!n||!i||!("fields"in i))return;const t=[],r=i.popupTemplate;t.push(L(e,n,r)),i.fields&&t.push(...i.fields.map((async i=>$(e,n.fieldsIndex,i)))),await Promise.all(t)}async function L(e,n,i){const t=[];i?.expressionInfos&&t.push(...i.expressionInfos.map((i=>h(e,n.fieldsIndex,i.expression))));const r=i?.content;if(Array.isArray(r))for(const l of r)"expression"===l.type&&l.expressionInfo&&t.push(h(e,n.fieldsIndex,l.expressionInfo.expression));await Promise.all(t)}async function O(e,n,i){n&&(n.timeInfo&&i?.timeExtent&&b(e,n.fieldsIndex,[n.timeInfo.startField,n.timeInfo.endField]),n.floorInfo&&b(e,n.fieldsIndex,[n.floorInfo.floorField]),null!=i?.where&&await _(e,n.fieldsIndex,i.where))}async function V(e,n,i){n&&i&&await Promise.all(i.map((i=>j(e,n,i))))}async function j(e,n,i){n&&i&&(i.valueExpression?await h(e,n.fieldsIndex,i.valueExpression):i.field&&T(e,n.fieldsIndex,i.field))}async function U(e){if(!e)return[];const n="timeInfo"in e&&e.timeInfo;return n?I(e.fieldsIndex,[e.trackIdField,n.startField,n.endField]):[]}function C(e){return e?I(e.fieldsIndex,B(e)):[]}function R(e){if(!e)return[];const n=e.geometryFieldsInfo;return n?I(e.fieldsIndex,[n.shapeAreaField,n.shapeLengthField]):[]}const k=new Set(["oid","global-id","guid"]),z=new Set(["oid","global-id"]),G=[/^fnode_$/i,/^tnode_$/i,/^lpoly_$/i,/^rpoly_$/i,/^poly_$/i,/^subclass$/i,/^subclass_$/i,/^rings_ok$/i,/^rings_nok$/i,/shape/i,/perimeter/i,/objectid/i,/_i$/i];function P(e){const n=new Set;M(e).forEach((e=>n.add(e))),R(e).forEach((e=>n.add(e.toLowerCase())));const i=e&&"infoFor3D"in e?e.infoFor3D:void 0;return i&&(Object.values(i.assetMapFieldRoles).forEach((e=>n.add(e.toLowerCase()))),Object.values(i.transformFieldRoles).forEach((e=>n.add(e.toLowerCase())))),Array.from(n)}function B(e){if(!e)return[];const n="editFieldsInfo"in e&&e.editFieldsInfo;if(!n)return[];const{creationDateField:i,creatorField:t,editDateField:r,editorField:l}=n;return[i,t,r,l].filter(Boolean)}function M(e){return B(e).map((e=>e.toLowerCase()))}function X(e,n){return e.editable&&!k.has(e.type)&&!M(n).includes(e.name?.toLowerCase()??"")}function q(e,n){const i=e.name?.toLowerCase()??"";return!(null!=n?.objectIdField&&i===n.objectIdField.toLowerCase()||null!=n?.globalIdField&&i===n.globalIdField.toLowerCase()||P(n).includes(i)||z.has(e.type)||G.some((e=>e.test(i))))}async function Y(e){if(!e)return[];const n=new Set;return await J(n,e),Array.from(n).sort()}async function J(e,n){const{labelingInfo:i,fieldsIndex:t}=n;i?.length&&await Promise.all(i.map((n=>W(e,t,n))))}async function W(e,n,i){if(!i)return;const t=i.getLabelExpression(),r=i.where;if("arcade"===t.type)await h(e,n,t.expression);else{const i=t.expression.match(/{[^}]*}/g);i&&i.forEach((i=>{T(e,n,i.slice(1,-1))}))}await _(e,n,r)}function H(e){const n=e.defaultValue;return void 0!==n&&re(e,n)?n:e.nullable?null:void 0}function K(e){const n="string"==typeof e?{type:e}:e;return ye(n)?255:"esriFieldTypeDate"===n.type||"date"===n.type?8:void 0}function Q(e){return"number"==typeof e&&!isNaN(e)&&isFinite(e)}function Z(e){return null===e||Q(e)}function ee(e){return null===e||Number.isInteger(e)}function ne(e){return null!=e&&"string"==typeof e}function ie(e){return null===e||ne(e)}function te(){return!0}function re(e,n){let i;switch(e.type){case"date":case"integer":case"long":case"small-integer":case"big-integer":case"esriFieldTypeDate":case"esriFieldTypeInteger":case"esriFieldTypeLong":case"esriFieldTypeSmallInteger":case"esriFieldTypeBigInteger":i=e.nullable?ee:Number.isInteger;break;case"double":case"single":case"esriFieldTypeSingle":case"esriFieldTypeDouble":i=e.nullable?Z:Q;break;case"string":case"esriFieldTypeString":i=e.nullable?ie:ne;break;default:i=te}return 1===arguments.length?i:i(n)}const le=["integer","small-integer","big-integer"],oe=["single","double"],se=[...le,...oe],ae=["esriFieldTypeInteger","esriFieldTypeSmallInteger","esriFieldTypeBigInteger"],ue=["esriFieldTypeSingle","esriFieldTypeDouble"],fe=new Set([...le,...ae]),de=new Set([...oe,...ue]),ce=t(fe,de);function pe(e){return null!=e&&fe.has(e.type)}function me(e){return null!=e&&ce.has(e.type)}function ye(e){return null!=e&&("string"===e.type||"esriFieldTypeString"===e.type)}function ge(e){return null!=e&&("date"===e.type||"esriFieldTypeDate"===e.type)}function Fe(e){return null!=e&&("date-only"===e.type||"esriFieldTypeDateOnly"===e.type)}function Ie(e){return null!=e&&("timestamp-offset"===e.type||"esriFieldTypeTimestampOffset"===e.type)}function be(e){return null!=e&&("time-only"===e.type||"esriFieldTypeTimeOnly"===e.type)}function Te(e){return null!=e&&("oid"===e.type||"esriFieldTypeOID"===e.type)}function xe(e){return null!=e&&("global-id"===e.type||"esriFieldTypeGlobalID"===e.type)}function we(e,n){return null===Se(e,n)}var he,_e;function Ee(e){return null==e||"number"==typeof e&&isNaN(e)?null:e}function Se(e,n){return null==e||e.nullable&&null===n?null:me(e)&&!ve(e.type,Number(n))?he.OUT_OF_RANGE:re(e,n)?e.domain?l(e.domain,n):null:_e.INVALID_TYPE}function ve(e,n){const i="string"==typeof e?Ne(e):e;if(!i)return!1;const t=i.min,r=i.max;return i.isInteger?Number.isInteger(n)&&n>=t&&n<=r:n>=t&&n<=r}function Ae(e){const n=o(e.domain);return n||(me(e)?Ne(e.type):void 0)}function Ne(e){switch(e){case"esriFieldTypeSmallInteger":case"small-integer":return De;case"esriFieldTypeInteger":case"integer":return Le;case"esriFieldTypeBigInteger":case"big-integer":return Oe;case"esriFieldTypeSingle":case"single":return Ve;case"esriFieldTypeDouble":case"double":return je}}function $e(e){if(!Q(e))return null;if(Number.isInteger(e)){if(e>=De.min&&e<=De.max)return"esriFieldTypeSmallInteger";if(e>=Le.min&&e<=Le.max)return"esriFieldTypeInteger";if(e>=Oe.min&&e<=Oe.max)return"esriFieldTypeBigInteger"}return e>=Ve.min&&e<=Ve.max?"esriFieldTypeSingle":"esriFieldTypeDouble"}!function(e){e.OUT_OF_RANGE="numeric-range-validation-error::out-of-range"}(he||(he={})),function(e){e.INVALID_TYPE="type-validation-error::invalid-type"}(_e||(_e={}));const De={min:-32768,max:32767,isInteger:!0},Le={min:-2147483648,max:2147483647,isInteger:!0},Oe={min:-Number.MAX_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER,isInteger:!0},Ve={min:-34e37,max:12e37,isInteger:!1},je={min:-Number.MAX_VALUE,max:Number.MAX_VALUE,isInteger:!1};function Ue(e,n,i){switch(e){case s.INVALID_CODED_VALUE:return`Value ${i} is not in the coded domain - field: ${n.name}, domain: ${JSON.stringify(n.domain)}`;case s.VALUE_OUT_OF_RANGE:return`Value ${i} is out of the range of valid values - field: ${n.name}, domain: ${JSON.stringify(n.domain)}`;case _e.INVALID_TYPE:return`Value ${i} is not a valid value for the field type - field: ${n.name}, type: ${n.type}, nullable: ${n.nullable}`;case he.OUT_OF_RANGE:{const{min:e,max:t}=Ne(n.type);return`Value ${i} is out of range for the number type - field: ${n.name}, type: ${n.type}, value range is ${e} to ${t}`}}}function Ce(e,n){return!Re(e,n,null)}function Re(e,n,i){if(!n?.attributes||!e){if(null!=i)for(const n of e??[])i.add(n);return!0}const t=new Set(Object.keys(n.attributes));let r=!1;for(const l of e)if(!t.has(l)){if(r=!0,null==i)break;i.add(l)}return r}async function ke(e,n){const i=new Set;for(const t of n)await h(i,e.fieldsIndex,t);return Array.from(i).sort()}function ze(e){return!!e&&["raster.itempixelvalue","raster.servicepixelvalue"].some((n=>e.toLowerCase().startsWith(n)))}export{he as NumericRangeValidationError,_e as TypeValidationError,Oe as bigIntegerRange,h as collectArcadeFieldNames,N as collectElevationFields,D as collectFeatureReductionFields,T as collectField,b as collectFields,O as collectFilterFields,J as collectLabelingFields,V as collectOrderByInfos,L as collectPopupTemplateFields,je as doubleRange,Ce as featureHasFields,I as fixFields,m as fixRendererFields,g as fixTimeInfoFields,ue as floatJSONTypes,oe as floatTypes,E as getDisplayFieldName,B as getEditTrackingFields,A as getElevationFields,ke as getExpressionFields,C as getFeatureEditFields,R as getFeatureGeometryFields,K as getFieldDefaultLength,H as getFieldDefaultValue,Ae as getFieldRange,Y as getLabelingFields,P as getLowerCaseDefaultHiddenFields,M as getLowerCaseEditTrackingFields,$e as getNumericTypeForValue,U as getTimeFields,ae as integerJSONTypes,Le as integerRange,le as integerTypes,ge as isDateField,Fe as isDateOnlyField,X as isFieldEditable,q as isFieldVisibleByDefault,xe as isGlobalIDField,pe as isIntegerField,ve as isNumberInRange,me as isNumericField,Te as isObjectIDField,ze as isRasterPixelValueField,ye as isStringField,be as isTimeOnlyField,Ie as isTimestampOffsetField,we as isValidFieldValue,re as isValueMatchingFieldType,d as normalizeFieldName,se as numericTypes,w as packFields,Re as populateMissingFields,c as rendererFields,Ee as sanitizeNullFieldValue,Ve as singleRange,De as smallIntegerRange,x as unpackFieldNames,Se as validateFieldValue,Ue as validationErrorToString,p as visualVariableFields};
|
|
5
|
+
import e from"../../core/Error.js";import{getDeepValue as n,setDeepValue as i}from"../../core/object.js";import{union as t}from"../../core/SetUtils.js";import{parseWhereClause as r}from"../../core/sql.js";import{validateDomainValue as l,getDomainRange as o,DomainValidationError as s}from"./domainUtils.js";import{loadArcade as a}from"../../support/arcadeOnDemand.js";const u=/^([0-9_])/,f=/[^a-z0-9_\u0080-\uffff]+/gi;function d(e){if(null==e)return null;return e.trim().replaceAll(f,"_").replace(u,"F$1")||null}const c=["field","field2","field3","normalizationField","rotationInfo.field","proportionalSymbolInfo.field","proportionalSymbolInfo.normalizationField","colorInfo.field","colorInfo.normalizationField"],m=["field","normalizationField"];function p(e,n){if(null!=e&&null!=n)for(const i of Array.isArray(e)?e:[e])if(y(c,i,n),"visualVariables"in i&&i.visualVariables)for(const e of i.visualVariables)y(m,e,n)}function y(e,t,r){if(e)for(const l of e){const e=n(l,t),o=e&&"function"!=typeof e&&r.get(e);o&&i(l,o.name,t)}}function g(e,n){if(null!=e&&n?.fields?.length)if("startField"in e){const i=n.get(e.startField),t=n.get(e.endField);e.startField=i?.name??null,e.endField=t?.name??null}else{const i=n.get(e.startTimeField),t=n.get(e.endTimeField);e.startTimeField=i?.name??null,e.endTimeField=t?.name??null}}const F=new Set;function I(e,n){return e&&n?(F.clear(),b(F,e,n),Array.from(F).sort()):[]}function b(e,n,i){if(i)if(n?.fields?.length)if(i.includes("*"))for(const{name:t}of n.fields)e.add(t);else for(const t of i)w(e,n,t);else{if(i.includes("*"))return e.clear(),void e.add("*");for(const n of i)null!=n&&e.add(n)}}function w(e,n,i){if("string"==typeof i)if(n){const t=n.get(i);t&&e.add(t.name)}else e.add(i)}function x(e,n){return null==n||null==e?[]:n.includes("*")?(e.fields??[]).map((e=>e.name)):n}function T(e,n,i=1){if(!n||!e)return[];if(n.includes("*"))return["*"];const t=I(e,n);return t.length/e.fields.length>=i?["*"]:t}async function h(e,n,i){if(!i)return;const{arcadeUtils:t}=await a(),r=t.extractFieldNames(i,n?.fields?.map((e=>e.name)));for(const l of r)w(e,n,l)}async function E(n,i,t){if(t&&"1=1"!==t){const l=await r(t,i);if(!l.isStandardized)throw new e("fieldUtils:collectFilterFields","Where clause is not standardized",{where:t});b(n,i,l.fieldNames)}}function _({displayField:e,fields:n}){return e||(n?.length?N(n,"name-or-title")||N(n,"unique-identifier")||N(n,"type-or-category")||A(n):null)}function A(e){for(const n of e){if(!n?.name)continue;const e=n.name.toLowerCase();if(e.includes("name")||e.includes("title"))return n.name}return null}function N(e,n){for(const i of e)if(i?.valueType&&i.valueType===n)return i.name;return null}async function S(e){if(!e)return[];const n=new Set;return await v(n,e),Array.from(n).sort()}async function v(e,n){if(!n)return;const i=n.elevationInfo?.featureExpressionInfo;return i?i.collectRequiredFields(e,n.fieldsIndex):void 0}function $(e,n,i){i.onStatisticExpression?h(e,n,i.onStatisticExpression.expression):e.add(i.onStatisticField)}async function L(e,n,i){if(!n||!i||!("fields"in i))return;const t=[],r=i.popupTemplate;t.push(D(e,n,r)),i.fields&&t.push(...i.fields.map((async i=>$(e,n.fieldsIndex,i)))),await Promise.all(t)}async function D(e,n,i){const t=[];i?.expressionInfos&&t.push(...i.expressionInfos.map((i=>h(e,n.fieldsIndex,i.expression))));const r=i?.content;if(Array.isArray(r))for(const l of r)"expression"===l.type&&l.expressionInfo&&t.push(h(e,n.fieldsIndex,l.expressionInfo.expression));await Promise.all(t)}async function M(e,n,i){n&&(n.timeInfo&&i?.timeExtent&&b(e,n.fieldsIndex,[n.timeInfo.startField,n.timeInfo.endField]),n.floorInfo&&b(e,n.fieldsIndex,[n.floorInfo.floorField]),null!=i?.where&&await E(e,n.fieldsIndex,i.where))}async function O(e,n,i){n&&i&&await Promise.all(i.map((i=>V(e,n,i))))}async function V(e,n,i){n&&i&&(i.valueExpression?await h(e,n.fieldsIndex,i.valueExpression):i.field&&w(e,n.fieldsIndex,i.field))}async function U(e){if(!e)return[];const n="timeInfo"in e&&e.timeInfo;return n?I(e.fieldsIndex,[e.trackIdField,n.startField,n.endField]):[]}function j(e){return e?I(e.fieldsIndex,z(e)):[]}function C(e){if(!e)return[];const n=e.geometryFieldsInfo;return n?I(e.fieldsIndex,[n.shapeAreaField,n.shapeLengthField]):[]}const R=new Set(["oid","global-id","guid"]),G=new Set(["oid","global-id"]),k=[/^fnode_$/i,/^tnode_$/i,/^lpoly_$/i,/^rpoly_$/i,/^poly_$/i,/^subclass$/i,/^subclass_$/i,/^rings_ok$/i,/^rings_nok$/i,/shape/i,/perimeter/i,/objectid/i,/_i$/i];function X(e){const n=new Set;P(e).forEach((e=>n.add(e))),C(e).forEach((e=>n.add(e.toLowerCase())));const i=e&&"infoFor3D"in e?e.infoFor3D:void 0;return i&&(Object.values(i.assetMapFieldRoles).forEach((e=>n.add(e.toLowerCase()))),Object.values(i.transformFieldRoles).forEach((e=>n.add(e.toLowerCase())))),Array.from(n)}function z(e){if(!e)return[];const n="editFieldsInfo"in e&&e.editFieldsInfo;if(!n)return[];const{creationDateField:i,creatorField:t,editDateField:r,editorField:l}=n;return[i,t,r,l].filter(Boolean)}function P(e){return z(e).map((e=>e.toLowerCase()))}function B(e,n){return e.editable&&!R.has(e.type)&&!P(n).includes(e.name?.toLowerCase()??"")}function q(e,n){const i=e.name?.toLowerCase()??"";return!(null!=n?.objectIdField&&i===n.objectIdField.toLowerCase()||null!=n?.globalIdField&&i===n.globalIdField.toLowerCase()||X(n).includes(i)||G.has(e.type)||k.some((e=>e.test(i))))}async function Y(e){if(!e)return[];const n=new Set;return await J(n,e),Array.from(n).sort()}async function J(e,n){const{labelingInfo:i,fieldsIndex:t}=n;i?.length&&await Promise.all(i.map((n=>W(e,t,n))))}async function W(e,n,i){if(!i)return;const t=i.getLabelExpression(),r=i.where;if("arcade"===t.type)await h(e,n,t.expression);else{const i=t.expression.match(/{[^}]*}/g);i&&i.forEach((i=>{w(e,n,i.slice(1,-1))}))}await E(e,n,r)}function H(e){const n=e.defaultValue;return void 0!==n&&re(e,n)?n:e.nullable?null:void 0}function K(e){const n="string"==typeof e?{type:e}:e;return ye(n)?255:"esriFieldTypeDate"===n.type||"date"===n.type?8:void 0}function Q(e){return"number"==typeof e&&!isNaN(e)&&isFinite(e)}function Z(e){return null===e||Q(e)}function ee(e){return null===e||Number.isInteger(e)}function ne(e){return null!=e&&"string"==typeof e}function ie(e){return null===e||ne(e)}function te(){return!0}function re(e,n){let i;switch(e.type){case"date":case"integer":case"long":case"small-integer":case"big-integer":case"esriFieldTypeDate":case"esriFieldTypeInteger":case"esriFieldTypeLong":case"esriFieldTypeSmallInteger":case"esriFieldTypeBigInteger":i=e.nullable?ee:Number.isInteger;break;case"double":case"single":case"esriFieldTypeSingle":case"esriFieldTypeDouble":i=e.nullable?Z:Q;break;case"string":case"esriFieldTypeString":i=e.nullable?ie:ne;break;default:i=te}return 1===arguments.length?i:i(n)}const le=["integer","small-integer","big-integer"],oe=["single","double"],se=[...le,...oe],ae=["esriFieldTypeInteger","esriFieldTypeSmallInteger","esriFieldTypeBigInteger"],ue=["esriFieldTypeSingle","esriFieldTypeDouble"],fe=new Set([...le,...ae]),de=new Set([...oe,...ue]),ce=t(fe,de);function me(e){return null!=e&&fe.has(e.type)}function pe(e){return null!=e&&ce.has(e.type)}function ye(e){return null!=e&&("string"===e.type||"esriFieldTypeString"===e.type)}function ge(e){return null!=e&&("date"===e.type||"esriFieldTypeDate"===e.type)}function Fe(e){return null!=e&&("date-only"===e.type||"esriFieldTypeDateOnly"===e.type)}function Ie(e){return null!=e&&("timestamp-offset"===e.type||"esriFieldTypeTimestampOffset"===e.type)}function be(e){return null!=e&&("time-only"===e.type||"esriFieldTypeTimeOnly"===e.type)}function we(e){return null!=e&&("oid"===e.type||"esriFieldTypeOID"===e.type)}function xe(e){return null!=e&&("global-id"===e.type||"esriFieldTypeGlobalID"===e.type)}function Te(e,n){return null===Ae(e,n)}var he,Ee;function _e(e){return null==e||"number"==typeof e&&isNaN(e)?null:e}function Ae(e,n){return null==e||e.nullable&&null===n?null:pe(e)&&!Ne(e.type,Number(n))?he.OUT_OF_RANGE:re(e,n)?e.domain?l(e,n):null:Ee.INVALID_TYPE}function Ne(e,n){const i="string"==typeof e?ve(e):e;if(!i)return!1;const t=i.min,r=i.max;return i.isInteger?Number.isInteger(n)&&n>=t&&n<=r:n>=t&&n<=r}function Se(e,n){const i=o(e,n);return i||(pe(e)?ve(e.type):void 0)}function ve(e){switch(e){case"esriFieldTypeSmallInteger":case"small-integer":return Le;case"esriFieldTypeInteger":case"integer":return De;case"esriFieldTypeBigInteger":case"big-integer":return Me;case"esriFieldTypeSingle":case"single":return Oe;case"esriFieldTypeDouble":case"double":return Ve}}function $e(e){if(!Q(e))return null;if(Number.isInteger(e)){if(e>=Le.min&&e<=Le.max)return"esriFieldTypeSmallInteger";if(e>=De.min&&e<=De.max)return"esriFieldTypeInteger";if(e>=Me.min&&e<=Me.max)return"esriFieldTypeBigInteger"}return e>=Oe.min&&e<=Oe.max?"esriFieldTypeSingle":"esriFieldTypeDouble"}!function(e){e.OUT_OF_RANGE="numeric-range-validation-error::out-of-range"}(he||(he={})),function(e){e.INVALID_TYPE="type-validation-error::invalid-type"}(Ee||(Ee={}));const Le={min:-32768,max:32767,isInteger:!0,rawMin:-32768,rawMax:32767},De={min:-2147483648,max:2147483647,isInteger:!0,rawMin:-2147483648,rawMax:2147483647},Me={min:-Number.MAX_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER,isInteger:!0,rawMin:-Number.MAX_SAFE_INTEGER,rawMax:Number.MAX_SAFE_INTEGER},Oe={min:-34e37,max:12e37,isInteger:!1,rawMin:-34e37,rawMax:12e37},Ve={min:-Number.MAX_VALUE,max:Number.MAX_VALUE,isInteger:!1,rawMin:-Number.MAX_VALUE,rawMax:Number.MAX_VALUE};function Ue(e,n,i){switch(e){case s.INVALID_CODED_VALUE:return`Value ${i} is not in the coded domain - field: ${n.name}, domain: ${JSON.stringify(n.domain)}`;case s.VALUE_OUT_OF_RANGE:return`Value ${i} is out of the range of valid values - field: ${n.name}, domain: ${JSON.stringify(n.domain)}`;case Ee.INVALID_TYPE:return`Value ${i} is not a valid value for the field type - field: ${n.name}, type: ${n.type}, nullable: ${n.nullable}`;case he.OUT_OF_RANGE:{const{min:e,max:t}=ve(n.type);return`Value ${i} is out of range for the number type - field: ${n.name}, type: ${n.type}, value range is ${e} to ${t}`}}}function je(e,n){return!Ce(e,n,null)}function Ce(e,n,i){if(!n?.attributes||!e){if(null!=i)for(const n of e??[])i.add(n);return!0}const t=new Set(Object.keys(n.attributes));let r=!1;for(const l of e)if(!t.has(l)){if(r=!0,null==i)break;i.add(l)}return r}async function Re(e,n){const i=new Set;for(const t of n)await h(i,e.fieldsIndex,t);return Array.from(i).sort()}function Ge(e){return!!e&&["raster.itempixelvalue","raster.servicepixelvalue"].some((n=>e.toLowerCase().startsWith(n)))}export{he as NumericRangeValidationError,Ee as TypeValidationError,Me as bigIntegerRange,h as collectArcadeFieldNames,v as collectElevationFields,L as collectFeatureReductionFields,w as collectField,b as collectFields,M as collectFilterFields,J as collectLabelingFields,O as collectOrderByInfos,D as collectPopupTemplateFields,Ve as doubleRange,je as featureHasFields,I as fixFields,p as fixRendererFields,g as fixTimeInfoFields,ue as floatJSONTypes,oe as floatTypes,_ as getDisplayFieldName,z as getEditTrackingFields,S as getElevationFields,Re as getExpressionFields,j as getFeatureEditFields,C as getFeatureGeometryFields,K as getFieldDefaultLength,H as getFieldDefaultValue,Se as getFieldRange,Y as getLabelingFields,X as getLowerCaseDefaultHiddenFields,P as getLowerCaseEditTrackingFields,$e as getNumericTypeForValue,U as getTimeFields,ae as integerJSONTypes,De as integerRange,le as integerTypes,ge as isDateField,Fe as isDateOnlyField,B as isFieldEditable,q as isFieldVisibleByDefault,xe as isGlobalIDField,me as isIntegerField,Ne as isNumberInRange,pe as isNumericField,we as isObjectIDField,Ge as isRasterPixelValueField,ye as isStringField,be as isTimeOnlyField,Ie as isTimestampOffsetField,Te as isValidFieldValue,re as isValueMatchingFieldType,d as normalizeFieldName,se as numericTypes,T as packFields,Ce as populateMissingFields,c as rendererFields,_e as sanitizeNullFieldValue,Oe as singleRange,Le as smallIntegerRange,x as unpackFieldNames,Ae as validateFieldValue,Ue as validationErrorToString,m as visualVariableFields};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.28/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import e from"../../core/Error.js";import r from"../../core/Logger.js";import{parseWhereClause as t}from"../../core/sql.js";import{formatDate as n,convertDateFormatToIntlOptions as
|
|
5
|
+
import e from"../../core/Error.js";import r from"../../core/Logger.js";import{parseWhereClause as t}from"../../core/sql.js";import{formatDate as n,convertDateFormatToIntlOptions as o}from"../../intl/date.js";import{formatNumber as a}from"../../intl/number.js";import{getDomainRange as l}from"./domainUtils.js";import{isDateField as i,isNumericField as s}from"./fieldUtils.js";import{getLabelExpression as u,getSingleFieldArcadeExpression as c}from"./labelUtils.js";import{createLabelExpression as f}from"../../support/arcadeOnDemand.js";const m=r.getLogger("esri.layers.support.labelFormatUtils"),p={type:"simple",evaluate:()=>null},d={getAttribute:(e,r)=>e.field(r)};async function w(r,n,o){if(!r||!r.symbol||!n)return p;const a=r.where,l=u(r);let i;if("arcade"===l.type){const r=await f(l.expression,o,n);if(null==r)return p;i={type:"arcade",evaluate(t,n){try{const e="attributes"in t?r.repurposeFeature(t):t;e.contextTimeZone=n??null;const o=r.evaluate({$view:{timeZone:n},$feature:e},r.services);if(null!=o)return o.toString()}catch(o){m.error(new e("arcade-expression-error","Encountered an error when evaluating label expression for feature",{error:o,feature:t,expression:l}))}return null},needsHydrationToEvaluate:()=>null==c(l.expression)}}else i={type:"simple",evaluate:e=>l.expression.replaceAll(/{[^}]*}/g,(r=>{const t=r.slice(1,-1),o=n.get(t);if(!o)return r;let a=null;if("attributes"in e){e&&e.attributes&&(a=e.attributes[o.name])}else a=e.field(o.name);return null==a?"":g(a,o)}))};if(a){let r;try{r=await t(a,n)}catch(s){return m.error(new e("bad-where-clause","Encountered an error when evaluating where clause, ignoring",{where:a,error:s})),p}const o=i.evaluate;i.evaluate=(t,n)=>{const l="attributes"in t?void 0:d;try{if(r.testFeature(t,l))return o(t,n)}catch(s){m.error(new e("bad-where-clause","Encountered an error when evaluating where clause for feature",{where:a,feature:t,error:s}))}return null}}return i}function g(e,r){if(null==e)return"";const t=r.domain;if(t)if("codedValue"===t.type||"coded-value"===t.type){const r=e;for(const e of t.codedValues)if(e.code===r)return e.name}else if("range"===t.type){const{max:n,min:o}=l(r),a=+e;if(null!=o&&null!=n&&o<=a&&a<=n)return t.name}let u=e;return i(r)?u=n(u,o("short-date")):s(r)&&(u=a(+u)),u||""}export{w as createLabelFunction,g as formatField};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.28/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import e from"../../request.js";import{clone as
|
|
5
|
+
import"../../geometry.js";import e from"../../request.js";import{clone as t}from"../../core/lang.js";import{throwIfAborted as r}from"../../core/promiseUtils.js";import{isProtocolRelative as o,isAbsolute as s,join as l,removeTrailingSlash as n,normalize as i,removeFile as u,getAppBaseUrl as a,addQueryParameters as c}from"../../core/urlUtils.js";import{WGS84 as f,WebMercator as m}from"../../geometry/support/spatialReferenceUtils.js";import{geographicToWebMercator as p}from"../../geometry/support/webMercatorUtils.js";import y from"./TileInfo.js";import d from"../../views/2d/engine/vectorTiles/style/VectorTileSource.js";import x from"../../views/2d/tiling/TileInfoView.js";import S from"../../geometry/SpatialReference.js";async function w(e,t){const r={source:null,sourceBase:null,sourceUrl:null,validatedSource:null,style:null,styleBase:null,styleUrl:null,sourceNameToSource:{},primarySourceName:"",spriteFormat:"png"},[o,s]="string"==typeof e?[e,null]:[null,e.jsonUrl];await j(r,"esri",e,s,t);return{layerDefinition:r.validatedSource,url:o,serviceUrl:r.sourceUrl,style:r.style,styleUrl:r.styleUrl,spriteUrl:r.style.sprite&&h(r.styleBase,r.style.sprite),spriteFormat:r.spriteFormat,glyphsUrl:r.style.glyphs&&h(r.styleBase,r.style.glyphs),sourceNameToSource:r.sourceNameToSource,primarySourceName:r.primarySourceName}}function h(...e){let t;for(const r of e)if(null!=r)if(o(r)){if(t){const e=t.split("://")[0];t=e+":"+r.trim()}}else t=s(r)?r:l(t,r);return t?n(t):void 0}async function j(t,o,s,l,n){let u,a,c;if(r(n),"string"==typeof s){const t=i(s);c=await e(t,{...n,responseType:"json",query:{f:"json",...n?.query}}),c.ssl&&(u&&(u=u.replace(/^http:/i,"https:")),a&&(a=a.replace(/^http:/i,"https:"))),u=t,a=t}else null!=s&&(c={data:s},u=s.jsonUrl||null,a=l);const f=c?.data;if(U(f))return t.styleUrl=u||null,N(t,f,a,n);if(v(f))return t.sourceUrl?I(t,f,a,!1,o,n):(t.sourceUrl=u||null,I(t,f,a,!0,o,n));throw new Error("You must specify the URL or the JSON for a service or for a style.")}function g(e){return"object"==typeof e&&!!e&&"tilejson"in e&&null!=e.tilejson}function U(e){return!!e&&"sources"in e&&!!e.sources}function v(e){return!U(e)}async function N(e,t,r,o){const s=r?u(r):a();e.styleBase=s,e.style=t,t["sprite-format"]&&"webp"===t["sprite-format"].toLowerCase()&&(e.spriteFormat="webp");const l=[];if(t.sources&&t.sources.esri){const r=t.sources.esri;r.url?await j(e,"esri",h(s,r.url),void 0,o):l.push(j(e,"esri",r,s,o))}for(const n of Object.keys(t.sources))"esri"!==n&&"vector"===t.sources[n].type&&(t.sources[n].url?l.push(j(e,n,h(s,t.sources[n].url),void 0,o)):t.sources[n].tiles&&l.push(j(e,n,t.sources[n],s,o)));await Promise.all(l)}async function I(e,t,r,o,s,l){const i=r?n(r)+"/":a(),u=T(t),f=new d(s,c(i,l?.query??{}),u);if(!o&&e.primarySourceName in e.sourceNameToSource){const t=e.sourceNameToSource[e.primarySourceName];if(!t.isCompatibleWith(f))return;null!=f.fullExtent&&(null!=t.fullExtent?t.fullExtent.union(f.fullExtent):t.fullExtent=f.fullExtent.clone()),t.tileInfo&&f.tileInfo&&t.tileInfo.lods.length<f.tileInfo.lods.length&&(t.tileInfo=f.tileInfo)}if(o&&(e.sourceBase=i,e.source=t,e.validatedSource=u,e.primarySourceName=s),e.sourceNameToSource[s]=f,!g(e)&&"defaultStyles"in t&&!e.style){if(null==t.defaultStyles)throw new Error;return"string"==typeof t.defaultStyles?j(e,"",h(i,t.defaultStyles,"root.json"),void 0,l):j(e,"",t.defaultStyles,h(i,"root.json"),l)}}function T(e){if(e.hasOwnProperty("tileInfo"))return e;const r={xmin:-20037507.067161843,ymin:-20037507.067161843,xmax:20037507.067161843,ymax:20037507.067161843,spatialReference:{wkid:102100,latestWkid:3857}};let o=null;if(g(e)){const{bounds:r}=e;if(r){const e=p({x:r[0],y:r[1],spatialReference:t(f)}),s=p({x:r[2],y:r[3],spatialReference:t(f)});o={xmin:e.x,ymin:e.y,xmax:s.x,ymax:s.y,spatialReference:t(m)}}}null===o&&(o=r);const s=new x(y.create({spatialReference:S.WebMercator,size:512,numLODs:25})),l=512;let n=78271.51696400007,i=295828763.7957775;const u=[],a=e.hasOwnProperty("minzoom")&&null!=e.minzoom,c=e.hasOwnProperty("maxzoom")&&null!=e.maxzoom,d=a?+e.minzoom:0,w=c?+e.maxzoom:22;let h=0;a&&d>0&&d<25&&(h=s.getLODInfoAt(d).scale);let j=0;c&&w>0&&w<25&&(j=s.getLODInfoAt(w).scale);for(let t=0;t<=w;t++)u.push({level:t,scale:i,resolution:n}),n/=2,i/=2;return{capabilities:"TilesOnly",initialExtent:o,fullExtent:r,minScale:h,maxScale:j,tiles:e.tiles,tileInfo:{rows:l,cols:l,dpi:96,format:"pbf",origin:{x:-20037508.342787,y:20037508.342787},lods:u,spatialReference:t(m)}}}export{w as loadMetadata};
|
package/package.json
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.28/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../chunks/tslib.es6.js";import{toHSV as t}from"../../core/colorUtils.js";import{JSONSupport as r}from"../../core/JSONSupport.js";import s from"../../core/Logger.js";import{property as o}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as a}from"../../core/accessorSupport/decorators/subclass.js";import n from"../../layers/support/RasterInfo.js";import{colorize as i,remapColor as l,lookupPixels as u,createColormapLUT as c,isValidPixelBlock as p}from"../../layers/support/rasterFunctions/pixelUtils.js";import{stretch as d,getStretchCutoff as h,createStretchLUT as m,computeGammaValues as f,createHistogramEqualizationLUT as y}from"../../layers/support/rasterFunctions/stretchUtils.js";import{hillshade as g,tintHillshade as b,calculateHillshadeParams as S}from"../../layers/support/rasterFunctions/surfaceUtils.js";import{convertColorRampToColormap as k}from"./colorRampUtils.js";import{isUVRendererSupported as R,isColormapRendererSupported as x,isShadedReliefRendererSupported as I}from"./rasterRendererChecks.js";let C=class extends r{constructor(e){super(e)}bind(){const{rendererJSON:e}=this;if(!e)return{success:!1};let t;switch(this.lookup={rendererJSON:{}},e.type){case"uniqueValue":t=this._updateUVRenderer(e);break;case"rasterColormap":t=this._updateColormapRenderer(e);break;case"rasterStretch":t=this._updateStretchRenderer(e);break;case"classBreaks":t=this._updateClassBreaksRenderer(e);break;case"rasterShadedRelief":t=this._updateShadedReliefRenderer(e);break;case"vectorField":t=this._updateVectorFieldRenderer();break;case"flowRenderer":t=this._updateFlowRenderer()}return t}symbolize(e){let t=e?.pixelBlock;if(!_(t))return t;if(e.simpleStretchParams&&"rasterStretch"===this.rendererJSON.type)return this.simpleStretch(t,e.simpleStretchParams);try{let r;switch(t.pixels.length>3&&(t=t.extractBands([0,1,2])),this.rendererJSON.type){case"uniqueValue":case"rasterColormap":r=this._symbolizeColormap(t);break;case"classBreaks":r=this._symbolizeClassBreaks(t);break;case"rasterStretch":r=this._symbolizeStretch(t,e.bandIds);break;case"rasterShadedRelief":{const s=e.extent,o=s.spatialReference.isGeographic,a={x:(s.xmax-s.xmin)/t.width,y:(s.ymax-s.ymin)/t.height};r=this._symbolizeShadedRelief(t,{isGCS:o,resolution:a});break}}return r}catch(r){return s.getLogger(this).error("symbolize",r.message),t}}simpleStretch(e,t){if(!_(e))return e;try{return e.pixels.length>3&&(e=e.extractBands([0,1,2])),d(e,{...t,isRenderer:!0})}catch(r){return s.getLogger(this).error("symbolize",r.message),e}}generateWebGLParameters(e){if(["uniqueValue","rasterColormap","classBreaks"].includes(this.rendererJSON.type)){const{indexedColormap:e,offset:t}=this.lookup.colormapLut||{};return{colormap:e,colormapOffset:t,type:"lut"}}const{pixelBlock:t,isGCS:r,resolution:s,bandIds:o}=e,{rendererJSON:a}=this;return"rasterStretch"===a.type?this._generateStretchWebGLParams(t,a,o):"rasterShadedRelief"===a.type?this._generateShadedReliefWebGLParams(a,r,s??void 0):"vectorField"===a.type?this._generateVectorFieldWebGLParams(a):null}_isLUTChanged(e){if(!this.lookup||!this.lookup.rendererJSON)return!0;if("colorRamp"in this.rendererJSON){const t=this.rendererJSON.colorRamp;return e?JSON.stringify(t)!==JSON.stringify(this.lookup.rendererJSON.colorRamp):(this.rendererJSON,this.lookup.rendererJSON,JSON.stringify(this.rendererJSON)!==JSON.stringify(this.lookup.rendererJSON))}return JSON.stringify(this.rendererJSON)!==JSON.stringify(this.lookup.rendererJSON)}_symbolizeColormap(e){if(this._isLUTChanged()){if(!this.bind().success)return e}return i(e,this.lookup.colormapLut)}_symbolizeClassBreaks(e){const{canUseIndexedLUT:t}=this._analyzeClassBreaks(this.rendererJSON);if(this._isLUTChanged()){if(!this.bind().success)return e}return t?i(e,this.lookup.colormapLut):l(e,this.lookup.remapLut??[])}_symbolizeStretch(e,t){const{rasterInfo:r}=this,{pixelType:s,bandCount:o}=r,a=this.rendererJSON,n=["u8","u16","s8","s16"].includes(s);let l,c;const{dra:p}=a,{gamma:f}=this.lookup;if("histogramEqualization"===a.stretchType){const s=p?null:this.lookup?.histogramLut,o=h(a,{rasterInfo:r,pixelBlock:e,bandIds:t,returnHistogramLut:!s}),n=d(e,{...o,gamma:f,isRenderer:!0});c=u(n,{lut:p?o.histogramLut:s,offset:0})}else if(n){if(p){const o=h(a,{rasterInfo:r,pixelBlock:e,bandIds:t});l=m({pixelType:s,...o,gamma:f,rounding:"floor"})}else if(this._isLUTChanged()){if(!this.bind().success)return e;l=this.lookup?this.lookup.stretchLut:null}else l=this.lookup?this.lookup.stretchLut:null;if(!l)return e;o>1&&null!=t&&t.length===e?.pixels.length&&l?.lut.length===o&&(l={lut:t.map((e=>l.lut[e])),offset:l.offset}),c=u(e,l)}else{const s=h(a,{rasterInfo:r,pixelBlock:e,bandIds:t});c=d(e,{...s,gamma:f,isRenderer:!0})}if(a.colorRamp){if(this._isLUTChanged(!0)){if(!this.bind().success)return e}c=i(c,this.lookup?.colormapLut)}return c}_symbolizeShadedRelief(e,t){const r=this.rendererJSON,s={...r,...t},o=g(e,s);if(!r.colorRamp)return o;let a;if(this._isLUTChanged(!0)){if(!this.bind().success)return o;a=this.lookup?this.lookup.hsvMap:null}else a=this.lookup?this.lookup.hsvMap:null;if(!a)return o;const n=this.rasterInfo.statistics?.[0]??{min:0,max:8e3};return b(o,e,a,n),o}_isVectorFieldData(){const{bandCount:e,dataType:t}=this.rasterInfo;return 2===e&&("vector-magdir"===t||"vector-uv"===t)}_updateVectorFieldRenderer(){return this._isVectorFieldData()?{success:!0}:{success:!1,error:`Unsupported data type "${this.rasterInfo.dataType}"; VectorFieldRenderer only supports "vector-magdir" and "vector-uv".`}}_updateFlowRenderer(){return this._isVectorFieldData()?{success:!0}:{success:!1,error:`Unsupported data type "${this.rasterInfo.dataType}"; FlowRenderer only supports "vector-magdir" and "vector-uv".`}}_updateUVRenderer(e){const{bandCount:t,attributeTable:r,pixelType:s}=this.rasterInfo,o=e.field1;if(!o)return{success:!1,error:"Unsupported renderer; missing UniqueValueRenderer.field."};const a=e.defaultSymbol,n=1===t&&["u8","s8"].includes(s);if(!R(this.rasterInfo,o)&&!n)return{success:!1,error:"Unsupported data; UniqueValueRenderer is only supported on single band data with a valid raster attribute table."};const i=[];if(null!=r){const t=r.fields.find((e=>"value"===e.name.toLowerCase()));if(!t)return{success:!1,error:"Unsupported data; the data's raster attribute table does not have a value field."};r.features.forEach((r=>{const s=e.uniqueValueInfos?.find((e=>String(e.value)===String(r.attributes[o]))),n=s?.symbol?.color;n?i.push([r.attributes[t.name]].concat(n)):a&&i.push([r.attributes[t.name]].concat(a.color))}))}else{if("value"!==o.toLowerCase())return{success:!1,error:'Unsupported renderer; UniqueValueRenderer.field must be "Value" when raster attribute table is not availalbe.'};e.uniqueValueInfos?.forEach((e=>{const t=e?.symbol?.color;t?i.push([parseInt(""+e.value,10)].concat(t)):a&&i.push([parseInt(""+e.value,10)].concat(a?.color))}))}if(0===i.length)return{success:!1,error:"Invalid UniqueValueRenderer. Cannot find matching records in the raster attribute table."};const l=c({colormap:i});return this.lookup={rendererJSON:e,colormapLut:l},this.canRenderInWebGL=!0,{success:!0}}_updateColormapRenderer(e){if(!x(this.rasterInfo))return{success:!1,error:"Unsupported data; the data source does not have a colormap."};const t=e.colormapInfos.map((e=>[e.value].concat(e.color))).sort(((e,t)=>e[0]-t[0]));if(!t||0===t.length)return{success:!1,error:"Unsupported renderer; ColormapRenderer must have meaningful colormapInfos."};const r=c({colormap:t});return this.lookup={rendererJSON:e,colormapLut:r},this.canRenderInWebGL=!0,{success:!0}}_updateShadedReliefRenderer(e){if(!I(this.rasterInfo))return{success:!1,error:`Unsupported data type "${this.rasterInfo.dataType}"; ShadedReliefRenderer only supports "elevation", or single band float/s16 data.`};if(e.colorRamp){const r=k(e.colorRamp,{interpolateAlpha:!0}),s=c({colormap:r}),o=[],a=s.indexedColormap;for(let e=0;e<a.length;e+=4){const r=t({r:a[e],g:a[e+1],b:a[e+2]});o.push([r.h/60,r.s/100,255*r.v/100])}this.lookup={rendererJSON:e,colormapLut:s,hsvMap:o}}else this.lookup=null;return this.canRenderInWebGL=!0,{success:!0}}_analyzeClassBreaks(e){const{attributeTable:t,pixelType:r}=this.rasterInfo,s=null!=t?t.fields.find((e=>"value"===e.name.toLowerCase())):null,o=null!=t?t.fields.find((t=>t.name.toLowerCase()===e.field.toLowerCase())):null,a=null!=s&&null!==o;return{canUseIndexedLUT:["u8","u16","s8","s16"].includes(r)||a,tableValueField:s,tableBreakField:o}}_updateClassBreaksRenderer(e){const{attributeTable:t}=this.rasterInfo,{canUseIndexedLUT:r,tableValueField:s,tableBreakField:o}=this._analyzeClassBreaks(e),a=e.classBreakInfos;if(!a?.length)return{success:!1,error:"Unsupported renderer; missing or invalid ClassBreaksRenderer.classBreakInfos."};const n=a.sort(((e,t)=>e.classMaxValue-t.classMaxValue)),i=n[n.length-1];let l=e.minValue;if(!r){const t=[];for(let e=0;e<n.length;e++)t.push({value:n[e].classMinValue??l,mappedColor:n[e].symbol.color}),l=n[e].classMaxValue;return t.push({value:i.classMaxValue,mappedColor:i.symbol.color}),this.lookup={rendererJSON:e,remapLut:t},this.canRenderInWebGL=!1,{success:!0}}const u=[];if(null!=t&&null!=s&&null!==o&&s!==o){const r=s.name,a=o.name,i=n[n.length-1],{classMaxValue:c}=i;l=e.minValue;for(const e of t.features){const t=e.attributes[r],s=e.attributes[a],o=s===c?i:s<l?null:n.find((({classMaxValue:e})=>e>s));o&&u.push([t].concat(o.symbol.color))}}else{l=Math.floor(e.minValue);for(let e=0;e<n.length;e++){const t=n[e];for(let e=l;e<t.classMaxValue;e++)u.push([e].concat(t.symbol.color));l=Math.ceil(t.classMaxValue)}i.classMaxValue===l&&u.push([i.classMaxValue].concat(i.symbol.color))}const p=c({colormap:u,fillUnspecified:!1});return this.lookup={rendererJSON:e,colormapLut:p},this.canRenderInWebGL=!0,{success:!0}}_isHistogramRequired(e){return"percentClip"===e||"histogramEqualization"===e}_isValidRasterStatistics(e){return null!=e&&e.length>0&&null!=e[0].min&&null!=e[0].max}_updateStretchRenderer(e){let{stretchType:t,dra:r}=e;if(!("none"===t||e.statistics?.length||this._isValidRasterStatistics(this.rasterInfo.statistics)||r))return{success:!1,error:"Unsupported renderer; StretchRenderer.statistics is required when dynamic range adjustment is not used."};const s=e.histograms||this.rasterInfo.histograms;!this._isHistogramRequired(e.stretchType)||s?.length||r||(t="minMax");const{computeGamma:o,useGamma:a,colorRamp:n}=e;let{gamma:i}=e;if(a&&o&&!i?.length){const t=e.statistics?.length?e.statistics:this.rasterInfo.statistics;i=f(this.rasterInfo.pixelType,t)}const l=this.rasterInfo.pixelType,u=!r&&["u8","u16","s8","s16"].includes(l);if("histogramEqualization"===t){const t=s.map((e=>y(e)));this.lookup={rendererJSON:e,histogramLut:t}}else if(u){const t=h(e,{rasterInfo:this.rasterInfo}),r=m({pixelType:l,...t,gamma:a?i:null,rounding:"floor"});this.lookup={rendererJSON:e,stretchLut:r}}if(n&&!this._isStretchColorRampNoop(n)){const t=k(n,{interpolateAlpha:!0});this.lookup||(this.lookup={rendererJSON:e}),this.lookup.colormapLut=c({colormap:t}),this.lookup.rendererJSON=e}return this.lookup.gamma=a&&i?.length?i:null,this.canRenderInWebGL=!0,{success:!0}}_isStretchColorRampNoop(e){return"algorithmic"===e.type&&["0,0,0,255","0,0,0"].includes(e.fromColor.join(","))&&["255,255,255,255","255,255,255"].includes(e.toColor.join(","))}_generateStretchWebGLParams(e,t,r){let s=null,o=null;const a=this.lookup?.colormapLut;t.colorRamp&&a&&(s=a.indexedColormap,o=a.offset),"histogramEqualization"===t.stretchType&&(t={...t,stretchType:"minMax"});const{gamma:n}=this.lookup,i=!!(t.useGamma&&n&&n.some((e=>1!==e))),{minCutOff:l,maxCutOff:u,outMin:c,outMax:p}=h(t,{rasterInfo:this.rasterInfo,pixelBlock:e,bandIds:r});let d=0;null!=e&&(d=e.getPlaneCount(),2===d&&((e=e.clone()).statistics=[e.statistics[0]],e.pixels=[e.pixels[0]]));const{bandCount:m}=this.rasterInfo,f=Math.min(3,r?.length||d||m,m),y=new Float32Array(f),g=s||i?1:255;let b;for(b=0;b<l.length;b++)y[b]=u[b]===l[b]?0:(p-c)/(u[b]-l[b])/g;const S=new Float32Array(f);if(i&&n)for(b=0;b<f;b++)n[b]>1?n[b]>2?S[b]=6.5+(n[b]-2)**2.5:S[b]=6.5+100*(2-n[b])**4:S[b]=1;return{bandCount:f,outMin:c/g,outMax:p/g,minCutOff:l,maxCutOff:u,factor:y,useGamma:i,gamma:i?n:[1,1,1],gammaCorrection:i?S:[1,1,1],colormap:s,colormapOffset:o,stretchType:t.stretchType,type:"stretch"}}_generateShadedReliefWebGLParams(e,t=!1,r={x:0,y:0}){let s=null,o=null;const a=this.lookup?.colormapLut;e.colorRamp&&a&&(s=a.indexedColormap,o=a.offset);const n={...e,isGCS:t,resolution:r},i=S(n),l=this.rasterInfo.statistics?.[0];return{...i,minValue:l?.min??0,maxValue:l?.max??8e3,hillshadeType:"traditional"===e.hillshadeType?0:1,type:"hillshade",colormap:s,colormapOffset:o}}_generateVectorFieldWebGLParams(e){const{style:t,inputUnit:r,outputUnit:s,visualVariables:o,symbolTileSize:a,flowRepresentation:n}=e;let i;const l=this.rasterInfo.statistics?.[0].min??0,u=this.rasterInfo.statistics?.[0].max??50,c=o?.find((e=>"sizeInfo"===e.type))??{type:"sizeInfo",field:"Magnitude",maxDataValue:u,maxSize:.8*a,minDataValue:l,minSize:.2*a},p=c.minDataValue??l,d=c.maxDataValue??u,h=null!=c.maxSize&&null!=c.minSize?[c.minSize/a,c.maxSize/a]:[.2,.8];if("wind_speed"===t){const e=(h[0]+h[1])/2;h[0]=h[1]=e}const m=null!=p&&null!=d?[p,d]:null;if("classified_arrow"===t)if(null!=p&&null!=d&&null!=c){i=[];const e=(c.maxDataValue-c.minDataValue)/5;for(let t=0;t<6;t++)i.push(c.minDataValue+e*t)}else i=[0,1e-6,3.5,7,10.5,14];const f="flow_to"===n===("ocean_current_kn"===t||"ocean_current_m"===t)?0:Math.PI,y=o?.find((e=>"rotationInfo"===e.type));return{breakValues:i,dataRange:m,inputUnit:r,outputUnit:s,symbolTileSize:a,symbolPercentRange:h,style:t||"single_arrow",rotation:f,rotationType:this.rasterInfo.storageInfo?.tileInfo&&"vector-uv"===this.rasterInfo.dataType?"geographic":y?.rotationType||e.rotationType,type:"vectorField"}}};function _(e){return p(e)&&0!==e.validPixelCount}e([o({json:{write:!0}})],C.prototype,"rendererJSON",void 0),e([o({type:n,json:{write:!0}})],C.prototype,"rasterInfo",void 0),e([o({json:{write:!0}})],C.prototype,"lookup",void 0),e([o()],C.prototype,"canRenderInWebGL",void 0),C=e([a("esri.renderers.support.RasterSymbolizer")],C);const L=C;export{L as default};
|
|
5
|
+
import{_ as e}from"../../chunks/tslib.es6.js";import{toHSV as t}from"../../core/colorUtils.js";import{JSONSupport as r}from"../../core/JSONSupport.js";import s from"../../core/Logger.js";import{property as o}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as a}from"../../core/accessorSupport/decorators/subclass.js";import n from"../../layers/support/RasterInfo.js";import{colorize as i,remapColor as l,lookupPixels as u,createColormapLUT as c,isValidPixelBlock as p}from"../../layers/support/rasterFunctions/pixelUtils.js";import{stretch as d,getStretchCutoff as h,createStretchLUT as m,computeGammaValues as f,createHistogramEqualizationLUT as y}from"../../layers/support/rasterFunctions/stretchUtils.js";import{hillshade as b,tintHillshade as g,calculateHillshadeParams as S}from"../../layers/support/rasterFunctions/surfaceUtils.js";import{convertColorRampToColormap as k}from"./colorRampUtils.js";import{isUVRendererSupported as x,isColormapRendererSupported as R,isShadedReliefRendererSupported as I}from"./rasterRendererChecks.js";let C=class extends r{constructor(e){super(e)}bind(){const{rendererJSON:e}=this;if(!e)return{success:!1};let t;switch(this.lookup={rendererJSON:{}},e.type){case"uniqueValue":t=this._updateUVRenderer(e);break;case"rasterColormap":t=this._updateColormapRenderer(e);break;case"rasterStretch":t=this._updateStretchRenderer(e);break;case"classBreaks":t=this._updateClassBreaksRenderer(e);break;case"rasterShadedRelief":t=this._updateShadedReliefRenderer(e);break;case"vectorField":t=this._updateVectorFieldRenderer();break;case"flowRenderer":t=this._updateFlowRenderer()}return t}symbolize(e){let t=e?.pixelBlock;if(!_(t))return t;if(e.simpleStretchParams&&"rasterStretch"===this.rendererJSON.type)return this.simpleStretch(t,e.simpleStretchParams);try{let r;switch(t.pixels.length>3&&(t=t.extractBands([0,1,2])),this.rendererJSON.type){case"uniqueValue":case"rasterColormap":r=this._symbolizeColormap(t);break;case"classBreaks":r=this._symbolizeClassBreaks(t);break;case"rasterStretch":r=this._symbolizeStretch(t,e.bandIds);break;case"rasterShadedRelief":{const s=e.extent,o=s.spatialReference.isGeographic,a={x:(s.xmax-s.xmin)/t.width,y:(s.ymax-s.ymin)/t.height};r=this._symbolizeShadedRelief(t,{isGCS:o,resolution:a});break}}return r}catch(r){return s.getLogger(this).error("symbolize",r.message),t}}simpleStretch(e,t){if(!_(e))return e;try{return e.pixels.length>3&&(e=e.extractBands([0,1,2])),d(e,{...t,isRenderer:!0})}catch(r){return s.getLogger(this).error("symbolize",r.message),e}}generateWebGLParameters(e){if(["uniqueValue","rasterColormap","classBreaks"].includes(this.rendererJSON.type)){const{indexedColormap:e,offset:t}=this.lookup.colormapLut||{};return{colormap:e,colormapOffset:t,type:"lut"}}const{pixelBlock:t,isGCS:r,resolution:s,bandIds:o}=e,{rendererJSON:a}=this;return"rasterStretch"===a.type?this._generateStretchWebGLParams(t,a,o):"rasterShadedRelief"===a.type?this._generateShadedReliefWebGLParams(a,r,s??void 0):"vectorField"===a.type?this._generateVectorFieldWebGLParams(a):null}_isLUTChanged(e){if(!this.lookup||!this.lookup.rendererJSON)return!0;if("colorRamp"in this.rendererJSON){const t=this.rendererJSON.colorRamp;return e?JSON.stringify(t)!==JSON.stringify(this.lookup.rendererJSON.colorRamp):(this.rendererJSON,this.lookup.rendererJSON,JSON.stringify(this.rendererJSON)!==JSON.stringify(this.lookup.rendererJSON))}return JSON.stringify(this.rendererJSON)!==JSON.stringify(this.lookup.rendererJSON)}_symbolizeColormap(e){if(this._isLUTChanged()){if(!this.bind().success)return e}return i(e,this.lookup.colormapLut)}_symbolizeClassBreaks(e){const{canUseIndexedLUT:t}=this._analyzeClassBreaks(this.rendererJSON);if(this._isLUTChanged()){if(!this.bind().success)return e}return t?i(e,this.lookup.colormapLut):l(e,this.lookup.remapLut??[])}_symbolizeStretch(e,t){const{rasterInfo:r}=this,{pixelType:s,bandCount:o}=r,a=this.rendererJSON,n=["u8","u16","s8","s16"].includes(s);let l,c;const{dra:p}=a,{gamma:f}=this.lookup;if("histogramEqualization"===a.stretchType){const s=p?null:this.lookup?.histogramLut,o=h(a,{rasterInfo:r,pixelBlock:e,bandIds:t,returnHistogramLut:!s}),n=d(e,{...o,gamma:f,isRenderer:!0});c=u(n,{lut:p?o.histogramLut:s,offset:0})}else if(n){if(p){const o=h(a,{rasterInfo:r,pixelBlock:e,bandIds:t});l=m({pixelType:s,...o,gamma:f,rounding:"floor"})}else if(this._isLUTChanged()){if(!this.bind().success)return e;l=this.lookup?this.lookup.stretchLut:null}else l=this.lookup?this.lookup.stretchLut:null;if(!l)return e;o>1&&null!=t&&t.length===e?.pixels.length&&l?.lut.length===o&&(l={lut:t.map((e=>l.lut[e])),offset:l.offset}),c=u(e,l)}else{const s=h(a,{rasterInfo:r,pixelBlock:e,bandIds:t});c=d(e,{...s,gamma:f,isRenderer:!0})}if(a.colorRamp){if(this._isLUTChanged(!0)){if(!this.bind().success)return e}c=i(c,this.lookup?.colormapLut)}return c}_symbolizeShadedRelief(e,t){const r=this.rendererJSON,s={...r,...t},o=b(e,s);if(!r.colorRamp)return o;let a;if(this._isLUTChanged(!0)){if(!this.bind().success)return o;a=this.lookup?this.lookup.hsvMap:null}else a=this.lookup?this.lookup.hsvMap:null;if(!a)return o;const n=this.rasterInfo.statistics?.[0]??{min:0,max:8e3};return g(o,e,a,n),o}_isVectorFieldData(){const{bandCount:e,dataType:t}=this.rasterInfo;return 2===e&&("vector-magdir"===t||"vector-uv"===t)}_updateVectorFieldRenderer(){return this._isVectorFieldData()?{success:!0}:{success:!1,error:`Unsupported data type "${this.rasterInfo.dataType}"; VectorFieldRenderer only supports "vector-magdir" and "vector-uv".`}}_updateFlowRenderer(){return this._isVectorFieldData()?{success:!0}:{success:!1,error:`Unsupported data type "${this.rasterInfo.dataType}"; FlowRenderer only supports "vector-magdir" and "vector-uv".`}}_updateUVRenderer(e){const{bandCount:t,attributeTable:r,pixelType:s}=this.rasterInfo,o=e.field1;if(!o)return{success:!1,error:"Unsupported renderer; missing UniqueValueRenderer.field."};const a=e.defaultSymbol,n=1===t&&["u8","s8"].includes(s);if(!x(this.rasterInfo,o)&&!n)return{success:!1,error:"Unsupported data; UniqueValueRenderer is only supported on single band data with a valid raster attribute table."};const i=[];if(null!=r){const t=r.fields.find((e=>"value"===e.name.toLowerCase()));if(!t)return{success:!1,error:"Unsupported data; the data's raster attribute table does not have a value field."};r.features.forEach((r=>{const s=e.uniqueValueInfos?.find((e=>String(e.value)===String(r.attributes[o]))),n=s?.symbol?.color;n?i.push([r.attributes[t.name]].concat(n)):a&&i.push([r.attributes[t.name]].concat(a.color))}))}else{if("value"!==o.toLowerCase())return{success:!1,error:'Unsupported renderer; UniqueValueRenderer.field must be "Value" when raster attribute table is not availalbe.'};e.uniqueValueInfos?.forEach((e=>{const t=e?.symbol?.color;t?i.push([parseInt(""+e.value,10)].concat(t)):a&&i.push([parseInt(""+e.value,10)].concat(a?.color))}))}if(0===i.length)return{success:!1,error:"Invalid UniqueValueRenderer. Cannot find matching records in the raster attribute table."};const l=c({colormap:i});return this.lookup={rendererJSON:e,colormapLut:l},this.canRenderInWebGL=this._isColormapSupportedByWebGL(l?.indexedColormap),{success:!0}}_updateColormapRenderer(e){if(!R(this.rasterInfo))return{success:!1,error:"Unsupported data; the data source does not have a colormap."};const t=e.colormapInfos.map((e=>[e.value].concat(e.color))).sort(((e,t)=>e[0]-t[0]));if(!t||0===t.length)return{success:!1,error:"Unsupported renderer; ColormapRenderer must have meaningful colormapInfos."};const r=c({colormap:t});return this.lookup={rendererJSON:e,colormapLut:r},this.canRenderInWebGL=this._isColormapSupportedByWebGL(r?.indexedColormap),{success:!0}}_updateShadedReliefRenderer(e){if(!I(this.rasterInfo))return{success:!1,error:`Unsupported data type "${this.rasterInfo.dataType}"; ShadedReliefRenderer only supports "elevation", or single band float/s16 data.`};if(e.colorRamp){const r=k(e.colorRamp,{interpolateAlpha:!0}),s=c({colormap:r}),o=[],a=s.indexedColormap;for(let e=0;e<a.length;e+=4){const r=t({r:a[e],g:a[e+1],b:a[e+2]});o.push([r.h/60,r.s/100,255*r.v/100])}this.lookup={rendererJSON:e,colormapLut:s,hsvMap:o}}else this.lookup=null;return this.canRenderInWebGL=!0,{success:!0}}_analyzeClassBreaks(e){const{attributeTable:t,pixelType:r}=this.rasterInfo,s=null!=t?t.fields.find((e=>"value"===e.name.toLowerCase())):null,o=null!=t?t.fields.find((t=>t.name.toLowerCase()===e.field.toLowerCase())):null,a=null!=s&&null!==o;return{canUseIndexedLUT:["u8","u16","s8","s16"].includes(r)||a,tableValueField:s,tableBreakField:o}}_updateClassBreaksRenderer(e){const{attributeTable:t}=this.rasterInfo,{canUseIndexedLUT:r,tableValueField:s,tableBreakField:o}=this._analyzeClassBreaks(e),a=e.classBreakInfos;if(!a?.length)return{success:!1,error:"Unsupported renderer; missing or invalid ClassBreaksRenderer.classBreakInfos."};const n=a.sort(((e,t)=>e.classMaxValue-t.classMaxValue)),i=n[n.length-1];let l=e.minValue;if(!r){const t=[];for(let e=0;e<n.length;e++)t.push({value:n[e].classMinValue??l,mappedColor:n[e].symbol.color}),l=n[e].classMaxValue;return t.push({value:i.classMaxValue,mappedColor:i.symbol.color}),this.lookup={rendererJSON:e,remapLut:t},this.canRenderInWebGL=!1,{success:!0}}const u=[];if(null!=t&&null!=s&&null!==o&&s!==o){const r=s.name,a=o.name,i=n[n.length-1],{classMaxValue:c}=i;l=e.minValue;for(const e of t.features){const t=e.attributes[r],s=e.attributes[a],o=s===c?i:s<l?null:n.find((({classMaxValue:e})=>e>s));o&&u.push([t].concat(o.symbol.color))}}else{l=Math.floor(e.minValue);for(let e=0;e<n.length;e++){const t=n[e];for(let e=l;e<t.classMaxValue;e++)u.push([e].concat(t.symbol.color));l=Math.ceil(t.classMaxValue)}i.classMaxValue===l&&u.push([i.classMaxValue].concat(i.symbol.color))}const p=c({colormap:u,fillUnspecified:!1});return this.lookup={rendererJSON:e,colormapLut:p},this.canRenderInWebGL=this._isColormapSupportedByWebGL(p?.indexedColormap),{success:!0}}_isColormapSupportedByWebGL(e){return!!e?.length&&e.length<=16384}_isHistogramRequired(e){return"percentClip"===e||"histogramEqualization"===e}_isValidRasterStatistics(e){return null!=e&&e.length>0&&null!=e[0].min&&null!=e[0].max}_updateStretchRenderer(e){let{stretchType:t,dra:r}=e;if(!("none"===t||e.statistics?.length||this._isValidRasterStatistics(this.rasterInfo.statistics)||r))return{success:!1,error:"Unsupported renderer; StretchRenderer.statistics is required when dynamic range adjustment is not used."};const s=e.histograms||this.rasterInfo.histograms;!this._isHistogramRequired(e.stretchType)||s?.length||r||(t="minMax");const{computeGamma:o,useGamma:a,colorRamp:n}=e;let{gamma:i}=e;if(a&&o&&!i?.length){const t=e.statistics?.length?e.statistics:this.rasterInfo.statistics;i=f(this.rasterInfo.pixelType,t)}const l=this.rasterInfo.pixelType,u=!r&&["u8","u16","s8","s16"].includes(l);if("histogramEqualization"===t){const t=s.map((e=>y(e)));this.lookup={rendererJSON:e,histogramLut:t}}else if(u){const t=h(e,{rasterInfo:this.rasterInfo}),r=m({pixelType:l,...t,gamma:a?i:null,rounding:"floor"});this.lookup={rendererJSON:e,stretchLut:r}}if(n&&!this._isStretchColorRampNoop(n)){const t=k(n,{interpolateAlpha:!0});this.lookup||(this.lookup={rendererJSON:e}),this.lookup.colormapLut=c({colormap:t}),this.lookup.rendererJSON=e}return this.lookup.gamma=a&&i?.length?i:null,this.canRenderInWebGL=!0,{success:!0}}_isStretchColorRampNoop(e){return"algorithmic"===e.type&&["0,0,0,255","0,0,0"].includes(e.fromColor.join(","))&&["255,255,255,255","255,255,255"].includes(e.toColor.join(","))}_generateStretchWebGLParams(e,t,r){let s=null,o=null;const a=this.lookup?.colormapLut;t.colorRamp&&a&&(s=a.indexedColormap,o=a.offset),"histogramEqualization"===t.stretchType&&(t={...t,stretchType:"minMax"});const{gamma:n}=this.lookup,i=!!(t.useGamma&&n&&n.some((e=>1!==e))),{minCutOff:l,maxCutOff:u,outMin:c,outMax:p}=h(t,{rasterInfo:this.rasterInfo,pixelBlock:e,bandIds:r});let d=0;null!=e&&(d=e.getPlaneCount(),2===d&&((e=e.clone()).statistics=[e.statistics[0]],e.pixels=[e.pixels[0]]));const{bandCount:m}=this.rasterInfo,f=Math.min(3,r?.length||d||m,m),y=new Float32Array(f),b=s||i?1:255;let g;for(g=0;g<l.length;g++)y[g]=u[g]===l[g]?0:(p-c)/(u[g]-l[g])/b;const S=new Float32Array(f);if(i&&n)for(g=0;g<f;g++)n[g]>1?n[g]>2?S[g]=6.5+(n[g]-2)**2.5:S[g]=6.5+100*(2-n[g])**4:S[g]=1;return{bandCount:f,outMin:c/b,outMax:p/b,minCutOff:l,maxCutOff:u,factor:y,useGamma:i,gamma:i?n:[1,1,1],gammaCorrection:i?S:[1,1,1],colormap:s,colormapOffset:o,stretchType:t.stretchType,type:"stretch"}}_generateShadedReliefWebGLParams(e,t=!1,r={x:0,y:0}){let s=null,o=null;const a=this.lookup?.colormapLut;e.colorRamp&&a&&(s=a.indexedColormap,o=a.offset);const n={...e,isGCS:t,resolution:r},i=S(n),l=this.rasterInfo.statistics?.[0];return{...i,minValue:l?.min??0,maxValue:l?.max??8e3,hillshadeType:"traditional"===e.hillshadeType?0:1,type:"hillshade",colormap:s,colormapOffset:o}}_generateVectorFieldWebGLParams(e){const{style:t,inputUnit:r,outputUnit:s,visualVariables:o,symbolTileSize:a,flowRepresentation:n}=e;let i;const l=this.rasterInfo.statistics?.[0].min??0,u=this.rasterInfo.statistics?.[0].max??50,c=o?.find((e=>"sizeInfo"===e.type))??{type:"sizeInfo",field:"Magnitude",maxDataValue:u,maxSize:.8*a,minDataValue:l,minSize:.2*a},p=c.minDataValue??l,d=c.maxDataValue??u,h=null!=c.maxSize&&null!=c.minSize?[c.minSize/a,c.maxSize/a]:[.2,.8];if("wind_speed"===t){const e=(h[0]+h[1])/2;h[0]=h[1]=e}const m=null!=p&&null!=d?[p,d]:null;if("classified_arrow"===t)if(null!=p&&null!=d&&null!=c){i=[];const e=(c.maxDataValue-c.minDataValue)/5;for(let t=0;t<6;t++)i.push(c.minDataValue+e*t)}else i=[0,1e-6,3.5,7,10.5,14];const f="flow_to"===n===("ocean_current_kn"===t||"ocean_current_m"===t)?0:Math.PI,y=o?.find((e=>"rotationInfo"===e.type));return{breakValues:i,dataRange:m,inputUnit:r,outputUnit:s,symbolTileSize:a,symbolPercentRange:h,style:t||"single_arrow",rotation:f,rotationType:this.rasterInfo.storageInfo?.tileInfo&&"vector-uv"===this.rasterInfo.dataType?"geographic":y?.rotationType||e.rotationType,type:"vectorField"}}};function _(e){return p(e)&&0!==e.validPixelCount}e([o({json:{write:!0}})],C.prototype,"rendererJSON",void 0),e([o({type:n,json:{write:!0}})],C.prototype,"rasterInfo",void 0),e([o({json:{write:!0}})],C.prototype,"lookup",void 0),e([o()],C.prototype,"canRenderInWebGL",void 0),C=e([a("esri.renderers.support.RasterSymbolizer")],C);const L=C;export{L as default};
|
package/support/revision.js
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.28/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
const
|
|
5
|
+
const c="20231027",e="4365eabcb865212b826cc225af940caae85e3e7d";export{c as buildDate,e as commitHash};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.28/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../chunks/tslib.es6.js";import t from"../request.js";import{JSONSupportMixin as
|
|
5
|
+
import{_ as e}from"../chunks/tslib.es6.js";import t from"../request.js";import r from"../core/Error.js";import{JSONSupportMixin as i}from"../core/JSONSupport.js";import s from"../core/Loadable.js";import{removeTrailingSlash as n,Url as o}from"../core/urlUtils.js";import{property as a}from"../core/accessorSupport/decorators/property.js";import"../core/accessorSupport/ensureType.js";import"../core/arrayUtils.js";import"../core/has.js";import{reader as d}from"../core/accessorSupport/decorators/reader.js";import{subclass as l}from"../core/accessorSupport/decorators/subclass.js";import{writer as u}from"../core/accessorSupport/decorators/writer.js";import{onApplyEditsEvent as c,emitUpdateMomentEvent as m}from"../layers/mixins/EditBusLayer.js";import{parseUrl as g}from"../rest/utils.js";import p from"./support/EditMomentStack.js";import{versionCollection as f,versionCollectionCount as h,defaultVersionNameLookup as V,currentSessionId as v}from"./support/versionManagementUtils.js";let w=class extends(i(s)){constructor(e){super(e),this.url=null,this.sourceJSON=null,this.name=null,this.defaultVersionIdentifier=null,this.capabilities=null,this._applyEditsHandler=e=>{const{serviceUrl:t,gdbVersion:r,result:i}=e;t===this._featureServiceUrl&&i.then((e=>{const t=e.historicMoment;t&&this._addMomentToVersionItem(r,t)}))}}initialize(){this.url=n(this.url),this._featureServiceUrl=this.url.replace(/\/VersionManagementServer/i,"/FeatureServer"),f.has(this.url)||f.set(this.url,new Map);const e=(h.get(this.url)??0)+1;h.set(this.url,e),this.when().then((()=>this.addHandles(c(this._applyEditsHandler))),(()=>{}))}destroy(){const e=(h.get(this.url)??1)-1;h.set(this.url,e),0===e&&f.delete(this.url),V.delete(this._featureServiceUrl)}read(e,t){this.sourceJSON=e,super.read(e,t)}readDefaultVersionIdentifier(e,t){return{name:t.defaultVersionName,guid:t.defaultVersionGuid}}writeDefaultVersionIdentifier(e,t){t.defaultVersionName=e.name,t.defaultVersionGuid=e.guid}load(e){return this.addResolvingPromise(this._fetchService(this.url,e)),Promise.resolve(this)}async createVersion(e){const[{createVersion:t},{default:r}]=await Promise.all([import("../rest/versionManagement/createVersion.js"),import("../rest/versionManagement/support/CreateVersionParameters.js")]),i=r.from(e);return t(this.url,i)}async deleteVersion(e){const[{deleteVersion:t},{default:r}]=await Promise.all([import("../rest/versionManagement/deleteVersion.js"),import("../rest/versionManagement/support/DeleteVersionParameters.js")]);let i;e.guid&&f.get(this.url)?.has(e.guid)&&(i=v??void 0);const s=new r({versionName:e.name,sessionId:i});return t(this.url,s)}async getVersionInfoExtended(e){const{getVersion:t}=await import("../rest/versionManagement/getVersion.js");return t(this.url,e.guid)}async getVersionInfos(e={}){const[{getVersionInfos:t},{default:r}]=await Promise.all([import("../rest/versionManagement/getVersionInfos.js"),import("../rest/versionManagement/support/GetVersionInfosParameters.js")]),i=r.from(e);return t(this.url,i)}async reconcile(e,t={}){const[{reconcile:r},{default:i}]=await Promise.all([import("../rest/versionManagement/gdbVersion/reconcile.js"),import("../rest/versionManagement/gdbVersion/support/ReconcileParameters.js")]),s=i.from(t);return s.sessionId=v,r(this.url,e.guid,s)}async post(e){const[{post:t},{default:r}]=await Promise.all([import("../rest/versionManagement/gdbVersion/post.js"),import("../rest/versionManagement/gdbVersion/support/PostParameters.js")]),i=r.from({sessionId:v});return t(this.url,e.guid,i)}async alterVersion(e,t){const[{alterVersion:r},{default:i}]=await Promise.all([import("../rest/versionManagement/gdbVersion/alterVersion.js"),import("../rest/versionManagement/gdbVersion/support/AlterVersionParameters.js")]),s=i.from(t);return r(this.url,e.guid,s)}async startReading(e){const{startReading:t}=await import("../rest/versionManagement/gdbVersion/startReading.js"),r=await t(this.url,e.guid,v);if(r){const t=await this.getVersionInfoExtended(e),r=new Date(t.modifiedDate),i={name:t.versionIdentifier.name,moment:r,lockType:"read"};this._addOrUpdateItem(e.guid,i),m(this._featureServiceUrl,null,e.name,r)}return r}async stopReading(e){const{stopReading:t}=await import("../rest/versionManagement/gdbVersion/stopReading.js"),r=await t(this.url,e.guid,v);return r&&(f.get(this.url)?.delete(e.guid),m(this._featureServiceUrl,null,e.name,null)),r}async startEditing(e){const{startEditing:t}=await import("../rest/versionManagement/gdbVersion/startEditing.js"),r=await t(this.url,e.guid,v);if(r){const t=await this.getVersionInfoExtended(e),r=new Date(t.modifiedDate),i=new p(r),s={name:e.name,moment:r,lockType:"edit",stack:i};this._addOrUpdateItem(e.guid,s),m(this._featureServiceUrl,null,e.name,r)}return r}async stopEditing(e,t){if(t){const t=f.get(this.url)?.get(e.guid);if(t?.stack?.canRedo()){const[{deleteForwardEdits:r},{default:i}]=await Promise.all([import("../rest/versionManagement/gdbVersion/deleteForwardEdits.js"),import("../rest/versionManagement/gdbVersion/support/DeleteForwardEditsParameters.js")]);if(!await r(this.url,e.guid,new i({sessionId:v,moment:t.moment})))return!1}}const{stopEditing:r}=await import("../rest/versionManagement/gdbVersion/stopEditing.js"),i=await r(this.url,e.guid,v,t);if(i){const t=await this.getVersionInfoExtended(e),r=new Date(t.modifiedDate);this._addOrUpdateItem(e.guid,{name:e.name,moment:r,lockType:"read",editMomentStack:void 0}),m(this._featureServiceUrl,null,e.name,r)}return i}getLockType(e){const t=f.get(this.url)?.get(e.guid)?.lockType;return t??"none"}changeVersionInternal(e,t,r){let i=null,s=null,n=null,o=null;const a=e=>!e||e===this.defaultVersionIdentifier.name,d=e=>{const t=f?.get(this.url)?.get(e.guid);n=e.name,o=t?.moment??null},l=(e,t)=>!e&&!t||!(!e||!t)&&e.toISOString()===t.toISOString();if("name"in t){if("none"!==this.getLockType(t))return!1;i=t.name,s=null,"name"in r?d(r):(n=this.defaultVersionIdentifier.name,o=r)}else i=this.defaultVersionIdentifier.name,s=t,"name"in r?d(r):(n=this.defaultVersionIdentifier.name,o=r);return(a(i)&&a(e.gdbVersion)&&l(e.historicMoment,s)||i===e.gdbVersion&&l(e.historicMoment,s))&&(e.gdbVersion=n,e.historicMoment=o),!0}async changeVersion(e,t,i){if("name"in i&&!await this.getVersionInfoExtended(i))throw new r("version-management-service:invalid-version","version does not exist");if("networkServiceUrl"in e){if(this._featureServiceUrl.toLowerCase()===e.featureServiceUrl.toLowerCase())return this.changeVersionInternal(e,t,i)}else{let r;"layers"in e?(r=e.allTables.concat(e.allLayers),e.utilityNetworks&&e.utilityNetworks.forEach((e=>{this._featureServiceUrl.toLowerCase()===e.featureServiceUrl.toLowerCase()&&this.changeVersionInternal(e,t,i)}))):r=e;for(const e of r)if("feature"===e.type){const r=/^(.*\/FeatureServer)\/\d+$/,s=e.url.replace(r,"$1");if(this._featureServiceUrl.toLowerCase()===s.toLowerCase()&&!this.changeVersionInternal(e,t,i))return!1}}return!0}async getVersionIdentifierFromName(e){try{const t=await this.getVersionInfos({includeHidden:!0});return t.find((t=>t.versionIdentifier.name===e))?.versionIdentifier||null}catch{return null}}async getVersionIdentifierFromGuid(e){const{getVersion:t}=await import("../rest/versionManagement/getVersion.js");try{return(await t(this.url,e)).versionIdentifier}catch{return null}}canUndo(e){const t=f.get(this.url)?.get(e.guid);return!!t?.stack?.canUndo()}canRedo(e){const t=f.get(this.url)?.get(e.guid);return!!t?.stack?.canRedo()}undo(e){const t=f.get(this.url)?.get(e.guid),r=t?.stack?.undo()||void 0;if(t&&r){const r=t.stack.peek();m(this._featureServiceUrl,null,e.name,r),f.get(this.url)?.set(e.guid,{...t,moment:r})}}redo(e){const t=f.get(this.url)?.get(e.guid),r=t?.stack?.redo()||void 0;t&&r&&(m(this._featureServiceUrl,null,e.name,r),f.get(this.url)?.set(e.guid,{...t,moment:r}))}_addMomentToVersionItem(e,t){const r=f.get(this.url);if(r)for(const[i,s]of r){s.name===e&&this._addToStack(i,t)}}_canAddToStack(e,t){if(e){return e.getTime()<t.getTime()}return!0}_addToStack(e,t){const r=f.get(this.url),i=r?.get(e);return!!i?.stack&&(this._canAddToStack(i.stack.peek(),t)&&i.stack.push(t),r.set(e,{...i,moment:t}),!0)}_addOrUpdateItem(e,t){const r=f.get(this.url),i=r?.get(e);return i?(r.set(e,{...i,...t}),!0):!(!t.name||!t.lockType)&&(r?.set(e,{...t,lockType:t.lockType}),!0)}async _fetchService(e,r){if(this.sourceJSON){this.read(this.sourceJSON,{origin:"service",url:g(e)});const t=new o(this.url).host;return void V.set(t,this.defaultVersionIdentifier.name)}const i=await t(e,{responseType:"json",query:{f:"json"},...r});this.read(i.data)}};e([a()],w.prototype,"url",void 0),e([a()],w.prototype,"sourceJSON",void 0),e([a({type:String,json:{write:!0}})],w.prototype,"name",void 0),e([a({json:{write:{target:{defaultVersionName:{type:String},defaultVersionGuid:{type:String}}},read:{source:["defaultVersionName","defaultVersionGuid"]}}})],w.prototype,"defaultVersionIdentifier",void 0),e([d("defaultVersionIdentifier",["defaultVersionName","defaultVersionGuid"])],w.prototype,"readDefaultVersionIdentifier",null),e([u("defaultVersionIdentifier",{defaultVersionName:{type:String},defaultVersionGuid:{type:String}})],w.prototype,"writeDefaultVersionIdentifier",null),e([a({json:{write:!0}})],w.prototype,"capabilities",void 0),w=e([l("esri.versionManagement.VersionManagementService")],w);const y=w;export{y 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.28/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{LRUCache as e}from"../../../../core/LRUCache.js";import i from"../../tiling/TileCoverage.js";import t from"../../tiling/TileKey.js";const l=512,s=1e-6,r=(e,i)=>e+1/(1<<2*i);class o{constructor(i,t){this._tiles=new Map,this._tileCache=new e(40,(e=>e.dispose())),this._viewSize=[0,0],this._visibleTiles=new Map,this.acquireTile=i.acquireTile,this.releaseTile=i.releaseTile,this.tileInfoView=i.tileInfoView,this._container=t}destroy(){for(const[e,i]of this._tiles)i.dispose();this._tiles=null,this._tileCache.clear(),this._tileCache=null}update(e){this._updateCacheSize(e);const l=this.tileInfoView,s=l.getTileCoverage(e.state,0,!0,"smallest")
|
|
5
|
+
import{LRUCache as e}from"../../../../core/LRUCache.js";import i from"../../tiling/TileCoverage.js";import t from"../../tiling/TileKey.js";const l=512,s=1e-6,r=(e,i)=>e+1/(1<<2*i);class o{constructor(i,t){this._tiles=new Map,this._tileCache=new e(40,(e=>e.dispose())),this._viewSize=[0,0],this._visibleTiles=new Map,this.acquireTile=i.acquireTile,this.releaseTile=i.releaseTile,this.tileInfoView=i.tileInfoView,this._container=t}destroy(){for(const[e,i]of this._tiles)i.dispose();this._tiles=null,this._tileCache.clear(),this._tileCache=null}update(e){this._updateCacheSize(e);const l=this.tileInfoView,s=l.getTileCoverage(e.state,0,!0,"smallest");if(!s)return!0;const{spans:r,lodInfo:o}=s,{level:n}=o,a=this._tiles,c=new Set,h=new Set;for(const{row:i,colFrom:_,colTo:f}of r)for(let e=_;e<=f;e++){const l=t.getId(n,i,o.normalizeCol(e),o.getWorldForColumn(e)),s=this._getOrAcquireTile(l);c.add(l),s.processed()?this._addToContainer(s):h.add(new t(l))}for(const[i,t]of a)t.isCoverage=c.has(i);for(const i of h)this._findPlaceholdersForMissingTiles(i,c);let d=!1;for(const[i,t]of a)t.neededForCoverage=c.has(i),t.neededForCoverage||t.isHoldingForFade&&l.intersects(s,t.key)&&c.add(i),t.isFading&&(d=!0);for(const[i,t]of this._tiles)c.has(i)||this._releaseTile(i);return i.pool.release(s),!d}clear(){this._tiles.clear(),this._tileCache.clear(),this._visibleTiles.clear()}clearCache(){this._tileCache.clear()}_findPlaceholdersForMissingTiles(e,i){const t=[];for(const[s,r]of this._tiles)this._addPlaceholderChild(t,r,e,i);const l=t.reduce(r,0);Math.abs(1-l)<s||this._addPlaceholderParent(e.id,i)}_addPlaceholderChild(e,i,t,l){i.key.level<=t.level||!i.hasData()||a(t,i.key)&&(this._addToContainer(i),l.add(i.id),e.push(i.key.level-t.level))}_addPlaceholderParent(e,i){const t=this._tiles;let l=e;for(;;){if(l=n(l),!l||i.has(l))return;const e=t.get(l);if(e&&e.hasData())return this._addToContainer(e),void i.add(e.id)}}_getOrAcquireTile(e){let i=this._tiles.get(e);return i||(i=this._tileCache.pop(e),i||(i=this.acquireTile(new t(e))),this._tiles.set(e,i),i)}_releaseTile(e){const i=this._tiles.get(e);this.releaseTile(i),this._removeFromContainer(i),this._tiles.delete(e),i.hasData()?this._tileCache.put(e,i,1):i.dispose()}_addToContainer(e){let i;const t=[],l=this._container;if(l.contains(e))return;const s=this._visibleTiles;for(const[r,o]of s)this._canConnectDirectly(e,o)&&t.push(o),null==i&&this._canConnectDirectly(o,e)&&(i=o);if(null!=i){for(const l of t)i.childrenTiles.delete(l),e.childrenTiles.add(l),l.parentTile=e;i.childrenTiles.add(e),e.parentTile=i}else for(const r of t)e.childrenTiles.add(r),r.parentTile=e;s.set(e.id,e),l.addChild(e)}_removeFromContainer(e){if(this._visibleTiles.delete(e.id),this._container.removeChild(e),null!=e.parentTile){e.parentTile.childrenTiles.delete(e);for(const i of e.childrenTiles)null!=e.parentTile&&e.parentTile.childrenTiles.add(i)}for(const i of e.childrenTiles)i.parentTile=e.parentTile;e.parentTile=null,e.childrenTiles.clear()}_canConnectDirectly(e,i){const t=e.key;let{level:l,row:s,col:r,world:o}=i.key;const n=this._visibleTiles;for(;l>0;){if(l--,s>>=1,r>>=1,t.level===l&&t.row===s&&t.col===r&&t.world===o)return!0;if(n.has(`${l}/${s}/${r}/${o}`))return!1}return!1}_updateCacheSize(e){const i=e.state.size;if(i[0]===this._viewSize[0]&&i[1]===this._viewSize[1])return;const t=Math.ceil(i[0]/l)+1,s=Math.ceil(i[1]/l)+1;this._viewSize[0]=i[0],this._viewSize[1]=i[1],this._tileCache.maxSize=5*t*s}}function n(e){const[i,t,l,s]=e.split("/"),r=parseInt(i,10);return 0===r?null:`${r-1}/${parseInt(t,10)>>1}/${parseInt(l,10)>>1}/${parseInt(s,10)}`}function a(e,i){const t=i.level-e.level;return e.row===i.row>>t&&e.col===i.col>>t&&e.world===i.world}export{o as TileManager};
|