12345 |
- /*
- All material copyright ESRI, All Rights Reserved, unless otherwise specified.
- See https://js.arcgis.com/4.25/esri/copyright.txt for details.
- */
- import{_ as e}from"../chunks/tslib.es6.js";import"../geometry.js";import r 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 t from"../renderers/SimpleRenderer.js";import o from"../renderers/UniqueValueRenderer.js";import{read as i}from"../renderers/support/jsonUtils.js";import{rendererTypes as s,webSceneRendererTypes as n}from"../renderers/support/types.js";import p from"../request.js";import{symbolTypesRenderer as a}from"../symbols.js";import l from"../core/Error.js";import m from"../core/Logger.js";import{isSome as d}from"../core/maybe.js";import{MultiOriginJSONMixin as c}from"../core/MultiOriginJSONSupport.js";import{throwIfAbortError as y}from"../core/promiseUtils.js";import{property as f}from"../core/accessorSupport/decorators/property.js";import"../core/arrayUtils.js";import{Integer as u}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{createTypeReader as j}from"../core/accessorSupport/extensions/serializableProperty/reader.js";import{featureGeometryTypeKebabDictionary as v}from"../geometry/support/typeUtils.js";import S from"./Layer.js";import{ArcGISService as b}from"./mixins/ArcGISService.js";import{BlendLayer as I}from"./mixins/BlendLayer.js";import{CustomParametersMixin as w}from"./mixins/CustomParametersMixin.js";import{FeatureEffectLayer as x}from"./mixins/FeatureEffectLayer.js";import{FeatureReductionLayer as R}from"./mixins/FeatureReductionLayer.js";import{OperationalLayer as P}from"./mixins/OperationalLayer.js";import{PortalLayer as T}from"./mixins/PortalLayer.js";import{RefreshableLayer as L}from"./mixins/RefreshableLayer.js";import{ScaleRangeLayer as D}from"./mixins/ScaleRangeLayer.js";import{TemporalLayer as F}from"./mixins/TemporalLayer.js";import{labelsVisible as E,legendEnabled as U,maxScale as O,minScale as k,popupEnabled as N,screenSizePerspectiveEnabled as A,url as C}from"./support/commonProperties.js";import{defineFieldProperties as _}from"./support/fieldProperties.js";import{fixRendererFields as J,fixTimeInfoFields as G}from"./support/fieldUtils.js";import q from"./support/LabelClass.js";import{reader as V}from"./support/labelingInfo.js";import z from"./support/PurgeOptions.js";import{loadStyleRenderer as M}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 H from"../geometry/SpatialReference.js";import K from"../geometry/Extent.js";const X=_();let Y=class extends(R(x(I(F(D(L(b(P(T(c(w(S)))))))))))){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.screenSizePerspectiveEnabled=!0,this.sourceJSON=null,this.spatialReference=H.WGS84,this.type="stream",this.url=null,this.updateInterval=300,this.webSocketUrl=null}normalizeCtorArgs(e,r){return"string"==typeof e?{url:e,...r}:e}load(e){if(!("WebSocket"in globalThis))return this.addResolvingPromise(Promise.reject(new l("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 r=d(e)?e.signal:null;return this.addResolvingPromise(this.loadFromPortal({supportedTypes:["Stream Service","Feed"]},e).catch(y).then((()=>this._fetchService(r)))),Promise.resolve(this)}get defaultPopupTemplate(){return this.createPopupTemplate()}set renderer(e){J(e,this.fieldsIndex),this._set("renderer",e)}readRenderer(e,r,s){const n=(r=r.layerDefinition||r).drawingInfo&&r.drawingInfo.renderer||void 0;if(n){const e=i(n,r,s)||void 0;return e||m.getLogger(this.declaredClass).error("Failed to create renderer",{rendererDefinition:r.drawingInfo.renderer,layer:this,context:s}),e}if(r.defaultSymbol)return r.types&&r.types.length?new o({defaultSymbol:Z(r.defaultSymbol,r,s),field:r.typeIdField,uniqueValueInfos:r.types.map((e=>({id:e.id,symbol:Z(e.symbol,e,s)})))}):new t({symbol:Z(r.defaultSymbol,r,s)})}async connect(e){const[{createConnection:r}]=await Promise.all([import("./graphics/sources/connections/createConnection.js"),this.load()]),t=v.toJSON(this.geometryType),{customParameters:o=null,definitionExpression:i=null,geometryDefinition:s=null,maxReconnectionAttempts:n=0,maxReconnectionInterval:p=20,spatialReference:a=this.spatialReference}=e||this.createConnectionParameters();return r(this.parsedUrl,this.spatialReference,a,t,{geometry:s,where:i},n,p,o)}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,r){if(!this.fields)return null;let t=null;return this.fields.some((r=>(r.name===e&&(t=r.domain),!!t))),t}getField(e){return this.fieldsIndex.get(e)}serviceSupportsSpatialReference(e){return!0}async _fetchService(e){if(!!this.webSocketUrl){if(!this.timeInfo?.trackIdField)throw new l("stream-layer:missing-metadata","The stream layer trackIdField must be specified.");if(!this.objectIdField)throw new l("stream-layer:missing-metadata","The stream layer objectIdField must be specified.");if(!this.fields)throw new l("stream-layer:missing-metadata","The stream layer fields must be specified.");if(!this.geometryType)throw new l("stream-layer:missing-metadata","The stream layer geometryType must be specified.");this.url=this.webSocketUrl}else if(!this.sourceJSON){const{data:r}=await p(this.parsedUrl.path,{query:{f:"json",...this.customParameters,...this.parsedUrl.query},responseType:"json",signal:e});this.sourceJSON=r}return this.sourceJSON={...this.sourceJSON??{},objectIdField:"__esri_stream_id__"},this.read(this.sourceJSON,{origin:"service",url:this.parsedUrl}),J(this.renderer,this.fieldsIndex),G(this.timeInfo,this.fieldsIndex),M(this,{origin:"service"})}};e([f({type:String})],Y.prototype,"copyright",void 0),e([f({readOnly:!0})],Y.prototype,"defaultPopupTemplate",null),e([f({type:String,json:{name:"layerDefinition.definitionExpression",write:{enabled:!0,allowNull:!0}}})],Y.prototype,"definitionExpression",void 0),e([f({type:String})],Y.prototype,"displayField",void 0),e([f({type:Q})],Y.prototype,"elevationInfo",void 0),e([f(X.fields)],Y.prototype,"fields",void 0),e([f(X.fieldsIndex)],Y.prototype,"fieldsIndex",void 0),e([f({type:K})],Y.prototype,"geometryDefinition",void 0),e([f({type:v.apiValues,json:{read:{reader:v.read}}})],Y.prototype,"geometryType",void 0),e([f(E)],Y.prototype,"labelsVisible",void 0),e([f({type:[q],json:{read:{source:"layerDefinition.drawingInfo.labelingInfo",reader:V},write:{target:"layerDefinition.drawingInfo.labelingInfo"}}})],Y.prototype,"labelingInfo",void 0),e([f(U)],Y.prototype,"legendEnabled",void 0),e([f({type:["show","hide"]})],Y.prototype,"listMode",void 0),e([f({type:u})],Y.prototype,"maxReconnectionAttempts",void 0),e([f({type:u})],Y.prototype,"maxReconnectionInterval",void 0),e([f(O)],Y.prototype,"maxScale",void 0),e([f(k)],Y.prototype,"minScale",void 0),e([f({type:String})],Y.prototype,"objectIdField",void 0),e([f({value:"ArcGISStreamLayer",type:["ArcGISStreamLayer"]})],Y.prototype,"operationalLayerType",void 0),e([f(N)],Y.prototype,"popupEnabled",void 0),e([f({type:r,json:{read:{source:"popupInfo"},write:{target:"popupInfo"}}})],Y.prototype,"popupTemplate",void 0),e([f({type:z})],Y.prototype,"purgeOptions",void 0),e([f({types:s,json:{origins:{service:{write:{target:"drawingInfo.renderer",enabled:!1}},"web-scene":{name:"layerDefinition.drawingInfo.renderer",types:n,write:!0}},write:{target:"layerDefinition.drawingInfo.renderer"}}})],Y.prototype,"renderer",null),e([h("service","renderer",["drawingInfo.renderer","defaultSymbol"]),h("renderer",["layerDefinition.drawingInfo.renderer","layerDefinition.defaultSymbol"])],Y.prototype,"readRenderer",null),e([f(A)],Y.prototype,"screenSizePerspectiveEnabled",void 0),e([f()],Y.prototype,"sourceJSON",void 0),e([f({type:H,json:{origins:{service:{read:{source:"spatialReference"}}}}})],Y.prototype,"spatialReference",void 0),e([f({json:{read:!1}})],Y.prototype,"type",void 0),e([f(C)],Y.prototype,"url",void 0),e([f({type:Number})],Y.prototype,"updateInterval",void 0),e([f({type:String})],Y.prototype,"webSocketUrl",void 0),Y=e([g("esri.layers.StreamLayer")],Y);const Z=j({types:a}),$=Y;export{$ as default};
|