UNPKG

@arcgis/core

Version:

ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API

6 lines (5 loc) 7.31 kB
/* All material copyright ESRI, All Rights Reserved, unless otherwise specified. See https://js.arcgis.com/4.33/esri/copyright.txt for details. */ import{_ as e}from"../chunks/tslib.es6.js";import r from"../PopupTemplate.js";import t from"../core/Error.js";import{MultiOriginJSONMixin as i}from"../core/MultiOriginJSONSupport.js";import{property as o}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/Logger.js";import"../core/RandomLCG.js";import{subclass as s}from"../core/accessorSupport/decorators/subclass.js";import n from"../geometry/Extent.js";import p from"../geometry/SpatialReference.js";import{featureGeometryTypeKebabDictionary as l}from"../geometry/support/typeUtils.js";import a from"./Layer.js";import{OGCFeatureSource as d}from"./graphics/sources/OGCFeatureSource.js";import{APIKeyMixin as y}from"./mixins/APIKeyMixin.js";import{BlendLayer as m}from"./mixins/BlendLayer.js";import{CustomParametersMixin as u}from"./mixins/CustomParametersMixin.js";import{DisplayFilteredLayer as c}from"./mixins/DisplayFilteredLayer.js";import{FeatureEffectLayer as f}from"./mixins/FeatureEffectLayer.js";import{FeatureReductionLayer as h}from"./mixins/FeatureReductionLayer.js";import{OperationalLayer as g}from"./mixins/OperationalLayer.js";import{OrderedLayer as j}from"./mixins/OrderedLayer.js";import{PortalLayer as v}from"./mixins/PortalLayer.js";import{RefreshableLayer as b}from"./mixins/RefreshableLayer.js";import{ScaleRangeLayer as x}from"./mixins/ScaleRangeLayer.js";import{TemporalLayer as I}from"./mixins/TemporalLayer.js";import{TrackableLayer as L}from"./mixins/TrackableLayer.js";import{elevationInfo as F,labelsVisible as S,legendEnabled as O,popupEnabled as w,screenSizePerspectiveEnabled as T,url as R}from"./support/commonProperties.js";import C from"./support/FeatureType.js";import D from"./support/Field.js";import{defineFieldProperties as P}from"./support/fieldProperties.js";import{fixRendererFields as E,fixTimeInfoFields as G}from"./support/fieldUtils.js";import _ from"./support/LabelClass.js";import{reader as q}from"./support/labelingInfo.js";import{webSceneRendererTypes as B,rendererTypes as M}from"../renderers/support/typeUtils.js";import U from"../rest/support/Query.js";import{createPopupTemplate as A}from"../support/popupUtils.js";const N=P();let Q=class extends(c(y(u(h(f(m(j(I(L(x(g(v(b(i(a))))))))))))))){constructor(e){super(e),this.capabilities=null,this.collectionId=null,this.copyright=null,this.description=null,this.displayField=null,this.elevationInfo=null,this.fields=null,this.fieldsIndex=null,this.fullExtent=null,this.geometryType=null,this.hasZ=void 0,this.labelingInfo=null,this.labelsVisible=!0,this.legendEnabled=!0,this.maxRecordCount=null,this.objectIdField=null,this.operationalLayerType="OGCFeatureLayer",this.popupEnabled=!0,this.popupTemplate=null,this.screenSizePerspectiveEnabled=!0,this.source=new d({layer:this}),this.spatialReference=null,this.title=null,this.type="ogc-feature",this.typeIdField=null,this.types=null,this.url=null}destroy(){this.source?.destroy()}load(e){return this.addResolvingPromise(this.loadFromPortal({supportedTypes:["OGCFeatureServer"]},e).then((()=>this._fetchService(e)))),this.when()}get defaultPopupTemplate(){return this.createPopupTemplate()}get effectiveMaxRecordCount(){return this.maxRecordCount??this.capabilities?.query.maxRecordCount??5e3}get isTable(){return this.loaded&&null==this.geometryType}set renderer(e){E(e,this.fieldsIndex),this._set("renderer",e)}on(e,r){return super.on(e,r)}createPopupTemplate(e){return A(this,e)}createQuery(){return new U}getField(e){return this.fieldsIndex.get(e)}getFieldDomain(e,r){let t,i=!1;const o=r?.feature?.attributes,s=this.typeIdField&&o?.[this.typeIdField];return null!=s&&this.types&&(i=this.types.some((r=>r.id==s&&(t=r.domains?.[e],"inherited"===t?.type&&(t=this._getLayerDomain(e)),!0)))),i||t||(t=this._getLayerDomain(e)),t}queryFeatures(e,r){return this.load().then((()=>this.source.queryFeatures(U.from(e)||this.createQuery(),r))).then((e=>(e?.features?.forEach((e=>{e.layer=e.sourceLayer=this})),e)))}async queryAttributeBins(e,r){throw new t("OGCFeatureLayer","Layer source does not support queryAttributeBins capability")}serviceSupportsSpatialReference(e){return this.source?.serviceSupportsSpatialReference(e)??!1}async _fetchService(e){await this.source.load(e),this.read(this.source.featureDefinition,{origin:"service"}),E(this.renderer,this.fieldsIndex),G(this.timeInfo,this.fieldsIndex)}_getLayerDomain(e){if(!this.fields)return null;for(const r of this.fields)if(r.name===e&&r.domain)return r.domain;return null}};e([o({readOnly:!0,json:{origins:{service:{read:!0}}}})],Q.prototype,"capabilities",void 0),e([o({type:String,json:{write:!0}})],Q.prototype,"collectionId",void 0),e([o({type:String})],Q.prototype,"copyright",void 0),e([o({readOnly:!0})],Q.prototype,"defaultPopupTemplate",null),e([o({readOnly:!0,type:String,json:{origins:{service:{name:"collection.description"}}}})],Q.prototype,"description",void 0),e([o({type:String})],Q.prototype,"displayField",void 0),e([o({type:Number})],Q.prototype,"effectiveMaxRecordCount",null),e([o(F)],Q.prototype,"elevationInfo",void 0),e([o({type:[D],json:{origins:{service:{name:"layerDefinition.fields"}}}})],Q.prototype,"fields",void 0),e([o(N.fieldsIndex)],Q.prototype,"fieldsIndex",void 0),e([o({readOnly:!0,type:n,json:{origins:{service:{name:"layerDefinition.extent"}}}})],Q.prototype,"fullExtent",void 0),e([o({type:l.apiValues,json:{origins:{service:{name:"layerDefinition.geometryType",read:{reader:l.read}}}}})],Q.prototype,"geometryType",void 0),e([o({type:Boolean,json:{origins:{service:{name:"layerDefinition.hasZ"}}}})],Q.prototype,"hasZ",void 0),e([o({type:Boolean,readOnly:!0})],Q.prototype,"isTable",null),e([o({type:[_],json:{origins:{"web-document":{name:"layerDefinition.drawingInfo.labelingInfo",read:{reader:q},write:!0}}}})],Q.prototype,"labelingInfo",void 0),e([o(S)],Q.prototype,"labelsVisible",void 0),e([o(O)],Q.prototype,"legendEnabled",void 0),e([o({type:Number})],Q.prototype,"maxRecordCount",void 0),e([o({type:String,json:{origins:{service:{name:"layerDefinition.objectIdField"}}}})],Q.prototype,"objectIdField",void 0),e([o({type:["OGCFeatureLayer"]})],Q.prototype,"operationalLayerType",void 0),e([o(w)],Q.prototype,"popupEnabled",void 0),e([o({type:r,json:{name:"popupInfo",write:!0}})],Q.prototype,"popupTemplate",void 0),e([o({types:M,json:{origins:{service:{name:"layerDefinition.drawingInfo.renderer",write:!1},"web-scene":{types:B,name:"layerDefinition.drawingInfo.renderer",write:!0}},name:"layerDefinition.drawingInfo.renderer",write:!0}})],Q.prototype,"renderer",null),e([o(T)],Q.prototype,"screenSizePerspectiveEnabled",void 0),e([o({readOnly:!0})],Q.prototype,"source",void 0),e([o({readOnly:!0,type:p,json:{origins:{service:{read:!0}}}})],Q.prototype,"spatialReference",void 0),e([o({type:String,json:{write:{enabled:!0,ignoreOrigin:!0,isRequired:!0},origins:{service:{name:"collection.title"}}}})],Q.prototype,"title",void 0),e([o({readOnly:!0,json:{read:!1}})],Q.prototype,"type",void 0),e([o({type:String,readOnly:!0})],Q.prototype,"typeIdField",void 0),e([o({type:[C]})],Q.prototype,"types",void 0),e([o(R)],Q.prototype,"url",void 0),Q=e([s("esri.layers.OGCFeatureLayer")],Q);const V=Q;export{V as default};