@arcgis/core
Version:
ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API
3 lines (2 loc) • 10.5 kB
JavaScript
/* COPYRIGHT Esri - https://js.arcgis.com/5.0.8/LICENSE.txt */
import{__decorate as e}from"tslib";import t from"../PopupTemplate.js";import i from"../core/Error.js";import{MultiOriginJSONSupportMixin as r}from"../core/MultiOriginJSONSupport.js";import{throwIfAbortError as o}from"../core/promiseUtils.js";import{urlToObject as s}from"../core/urlUtils.js";import{property as n,subclass as a}from"../core/accessorSupport/decorators.js";import{excludeTables as p}from"../core/accessorSupport/layerContainerType.js";import l from"../geometry/SpatialReference.js";import d from"../graphic/CSVGraphicOrigin.js";import m from"./Layer.js";import{CSVSource as u}from"./graphics/sources/CSVSource.js";import{createCapabilities as y}from"./graphics/sources/support/clientSideDefaults.js";import{BlendLayer as c}from"./mixins/BlendLayer.js";import{CustomParametersMixin as f}from"./mixins/CustomParametersMixin.js";import{DisplayFilteredLayer as h}from"./mixins/DisplayFilteredLayer.js";import{FeatureEffectLayer as g}from"./mixins/FeatureEffectLayer.js";import{FeatureReductionLayer as j}from"./mixins/FeatureReductionLayer.js";import{OperationalLayer as v}from"./mixins/OperationalLayer.js";import{OrderedLayer as b}from"./mixins/OrderedLayer.js";import{PortalLayer as I}from"./mixins/PortalLayer.js";import{RefreshableLayer as w}from"./mixins/RefreshableLayer.js";import{ScaleRangeLayer as x}from"./mixins/ScaleRangeLayer.js";import{TemporalLayer as F}from"./mixins/TemporalLayer.js";import{TrackableLayer as T}from"./mixins/TrackableLayer.js";import{attributeTableTemplate as O,elevationInfo as S,labelsVisible as L,legendEnabled as D,maxScale as P,minScale as E,opacityDrawingInfo as C,popupEnabled as q,screenSizePerspectiveEnabled as V,url as R}from"./support/commonProperties.js";import{validateBinsQuery as Q}from"./support/featureLayerUtils.js";import U from"./support/Field.js";import{defineFieldProperties as N}from"./support/fieldProperties.js";import{fixRendererFields as B,fixTimeInfoFields as A}from"./support/fieldUtils.js";import M from"./support/LabelClass.js";import{reader as Z}from"./support/labelingInfo.js";import _ from"./support/LayerFloorInfo.js";import G from"./support/TimeInfo.js";import{webSceneRendererTypes as W,rendererTypes as z}from"../renderers/support/typeUtils.js";import J from"../rest/support/Query.js";import{createPopupTemplate as k}from"../support/popupUtils.js";import{fromTimeReference as H}from"../time/timeZoneUtils.js";import{reader as K}from"../core/accessorSupport/decorators/reader.js";const X=N();let Y=class extends(b(h(f(j(g(c(F(T(x(w(v(I(r(m)))))))))))))){constructor(e){super(e),this.attributeTableTemplate=null,this.capabilities=y(!1,!1),this.copyright=null,this.definitionExpression=null,this.delimiter=null,this.displayField=null,this.elevationInfo=null,this.fields=null,this.fieldsIndex=null,this.floorInfo=null,this.fullExtent=null,this.geometryType="point",this.graphicOrigin=new d(this),this.labelingInfo=null,this.labelsVisible=!0,this.latitudeField=null,this.legendEnabled=!0,this.locationType="coordinates",this.longitudeField=null,this.maxScale=0,this.minScale=0,this.objectIdField=null,this.opacity=1,this.operationalLayerType="CSV",this.outFields=null,this.popupEnabled=!0,this.popupTemplate=null,this.screenSizePerspectiveEnabled=!0,this.source=new u,this.spatialReference=l.WGS84,this.timeInfo=null,this.type="csv"}load(e){const t=this.loadFromPortal({supportedTypes:["CSV"],supportsData:!1},e).catch(o).then(()=>(this.source.loadOptions={delimiter:this.delimiter,fields:this.fields,latitudeField:this.latitudeField??void 0,longitudeField:this.longitudeField??void 0,spatialReference:this.spatialReference??void 0,timeInfo:this.timeInfo??void 0,url:this.url},this.source.customParameters=this.customParameters??void 0,this.source.load(e))).then(()=>{this.read({layerDefinition:this.source.sourceJSON,locationInfo:this.source.locationInfo,columnDelimiter:this.source.delimiter},{origin:"service",portalItem:this.portalItem,portal:this.portalItem?.portal,url:this.parsedUrl}),B(this.renderer,this.fieldsIndex),A(this.timeInfo,this.fieldsIndex)});return this.addResolvingPromise(t),Promise.resolve(this)}destroy(){this.source?.destroy()}get createQueryVersion(){return this.commitProperty("definitionExpression"),this.commitProperty("timeExtent"),this.commitProperty("timeOffset"),this.commitProperty("geometryType"),this.commitProperty("capabilities"),(this._get("createQueryVersion")||0)+1}get defaultPopupTemplate(){return this.createPopupTemplate()}get isTable(){return this.loaded&&null==this.geometryType}readWebMapLabelsVisible(e,t){return t.showLabels??!!t.layerDefinition?.drawingInfo?.labelingInfo}get portalItem(){return super.portalItem}set portalItem(e){super.portalItem=e}set renderer(e){B(e,this.fieldsIndex),this._set("renderer",e)}set url(e){if(!e)return void this._set("url",e);const t=s(e);this._set("url",t.path),t.query&&(this.customParameters={...this.customParameters,...t.query})}createPopupTemplate(e){return k(this,e)}createQuery(){const e=new J,t=this.capabilities?.data;e.returnGeometry=!0,t?.supportsZ&&(e.returnZ=!0),e.outFields=["*"],e.where=this.definitionExpression||"1=1";const{timeOffset:i,timeExtent:r}=this;return e.timeExtent=i&&r?r.offset(-i.value,i.unit):r??null,e}getFieldDomain(e,t){return this.getField(e)?.domain}getField(e){return this.fieldsIndex.get(e)}async queryAttributeBins(e,t){const{source:r,capabilities:o}=await this.load();if(!r.queryAttributeBins)throw new i("CSVLayer","Layer source does not support queryAttributeBins capability");Q(e,o,"CSVLayer");const{default:s}=await import("../rest/support/AttributeBinsQuery.js"),n=await r.queryAttributeBins(s.from(e),t),a=this.graphicOrigin;if(n.features)for(const i of n.features)i.layer=i.sourceLayer=this,i.origin=a;return n}queryFeatures(e,t){return this.load().then(()=>this.source.queryFeatures(J.from(e)||this.createQuery())).then(e=>{const t=this.graphicOrigin;if(e.features)for(const i of e.features)i.layer=i.sourceLayer=this,i.origin=t;return e})}async queryObjectIds(e,t){return await this.load(),this.source.queryObjectIds(J.from(e)||this.createQuery())}queryFeatureCount(e,t){return this.load().then(()=>this.source.queryFeatureCount(J.from(e)||this.createQuery()))}queryExtent(e,t){return this.load().then(()=>this.source.queryExtent(J.from(e)||this.createQuery()))}read(e,t){super.read(e,t),"service"===t?.origin&&(["objectIdField","fields","timeInfo","dateFieldsTimeZone","latitudeField","longitudeField"].forEach(e=>this.revertToOrigin(e,"service")),this.spatialReference||this.revertToOrigin("spatialReference","service"))}async hasDataChanged(){try{const{dataChanged:e,updates:t}=await this.source.refresh(this.customParameters);return null!=t&&this.read(t,{origin:"service",url:this.parsedUrl,ignoreDefaults:!0}),e}catch{}return!1}};e([n(O)],Y.prototype,"attributeTableTemplate",void 0),e([n({readOnly:!0,json:{read:!1,write:!1}})],Y.prototype,"capabilities",void 0),e([n({type:String,json:{origins:{service:{read:{source:"copyrightText"}}}}})],Y.prototype,"copyright",void 0),e([n({readOnly:!0})],Y.prototype,"createQueryVersion",null),e([n({json:{name:"layerDefinition.dateFieldsTimeReference",read:{reader:H}}})],Y.prototype,"dateFieldsTimeZone",void 0),e([n({readOnly:!0})],Y.prototype,"defaultPopupTemplate",null),e([n({type:String,json:{name:"layerDefinition.definitionExpression",write:{enabled:!0,allowNull:!0}}})],Y.prototype,"definitionExpression",void 0),e([n({type:[","," ",";","|","\t"],json:{name:"columnDelimiter",write:{ignoreOrigin:!0}}})],Y.prototype,"delimiter",void 0),e([n({type:String})],Y.prototype,"displayField",void 0),e([n(S)],Y.prototype,"elevationInfo",void 0),e([n({type:[U],json:{name:"layerDefinition.fields",write:{ignoreOrigin:!0}}})],Y.prototype,"fields",void 0),e([n(X.fieldsIndex)],Y.prototype,"fieldsIndex",void 0),e([n({type:_,json:{name:"layerDefinition.floorInfo",write:{layerContainerTypes:p}}})],Y.prototype,"floorInfo",void 0),e([n({json:{origins:{service:{name:"layerDefinition.extent"}}}})],Y.prototype,"fullExtent",void 0),e([n({readOnly:!0,json:{read:!1}})],Y.prototype,"geometryType",void 0),e([n({readOnly:!0})],Y.prototype,"graphicOrigin",void 0),e([n({readOnly:!0})],Y.prototype,"isTable",null),e([n({type:[M],json:{name:"layerDefinition.drawingInfo.labelingInfo",read:{reader:Z},write:!0}})],Y.prototype,"labelingInfo",void 0),e([n(L)],Y.prototype,"labelsVisible",void 0),e([K("web-map","labelsVisible",["layerDefinition.drawingInfo.labelingInfo","showLabels"])],Y.prototype,"readWebMapLabelsVisible",null),e([n({type:String,json:{name:"locationInfo.latitudeFieldName",write:{ignoreOrigin:!0}}})],Y.prototype,"latitudeField",void 0),e([n(D)],Y.prototype,"legendEnabled",void 0),e([n({type:["show","hide"]})],Y.prototype,"listMode",void 0),e([n({type:["coordinates"],json:{name:"locationInfo.locationType",write:{ignoreOrigin:!0,isRequired:!0}}})],Y.prototype,"locationType",void 0),e([n({type:String,json:{name:"locationInfo.longitudeFieldName",write:{ignoreOrigin:!0}}})],Y.prototype,"longitudeField",void 0),e([n(P)],Y.prototype,"maxScale",void 0),e([n(E)],Y.prototype,"minScale",void 0),e([n({type:String,json:{name:"layerDefinition.objectIdField",origins:{"web-map":{write:{target:"layerDefinition.objectIdField",ignoreOrigin:!0}}}}})],Y.prototype,"objectIdField",void 0),e([n(C)],Y.prototype,"opacity",void 0),e([n({type:["CSV"]})],Y.prototype,"operationalLayerType",void 0),e([n()],Y.prototype,"outFields",void 0),e([n(q)],Y.prototype,"popupEnabled",void 0),e([n({type:t,json:{name:"popupInfo",write:!0}})],Y.prototype,"popupTemplate",void 0),e([n({types:z,json:{name:"layerDefinition.drawingInfo.renderer",origins:{"web-scene":{types:W,name:"layerDefinition.drawingInfo.renderer",write:!0}},write:{ignoreOrigin:!0,layerContainerTypes:p}}})],Y.prototype,"renderer",null),e([n(V)],Y.prototype,"screenSizePerspectiveEnabled",void 0),e([n({readOnly:!0})],Y.prototype,"source",void 0),e([n({type:l,json:{origins:{service:{name:"layerDefinition.extent.spatialReference"}}}})],Y.prototype,"spatialReference",void 0),e([n({type:G,json:{name:"layerDefinition.timeInfo"}})],Y.prototype,"timeInfo",void 0),e([n({type:String,json:{origins:{service:{name:"layerDefinition.name"},"web-document":{name:"title",write:{isRequired:!0,ignoreOrigin:!0,writerEnsuresNonNull:!0}}}}})],Y.prototype,"title",void 0),e([n({json:{read:!1},value:"csv",readOnly:!0})],Y.prototype,"type",void 0),e([n(R)],Y.prototype,"url",null),Y=e([a("esri.layers.CSVLayer")],Y);const $=Y;export{$ as default};