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 t from"../core/Error.js";import{isSome as r}from"../core/maybe.js";import{throwIfAbortError as i}from"../core/promiseUtils.js";import{urlToObject as o}from"../core/urlUtils.js";import{property as s}from"../core/accessorSupport/decorators/property.js";import"../core/arrayUtils.js";import"../core/accessorSupport/ensureType.js";import{reader as a}from"../core/accessorSupport/decorators/reader.js";import{subclass as n}from"../core/accessorSupport/decorators/subclass.js";import l from"./FeatureLayer.js";import{CSVSource as u}from"./graphics/sources/CSVSource.js";import{createCapabilities as d}from"./graphics/sources/support/clientSideDefaults.js";import c from"../rest/support/Query.js";import{r as p,w as y}from"../chunks/persistableUrlUtils.js";import h from"../geometry/SpatialReference.js";function m(e,r){throw new t(r,`CSVLayer (title: ${e.title}, id: ${e.id}) cannot be saved to a portal item`)}let f=class extends l{constructor(...e){super(...e),this.geometryType="point",this.capabilities=d(!1,!1),this.delimiter=null,this.editingEnabled=!1,this.fields=null,this.latitudeField=null,this.locationType="coordinates",this.longitudeField=null,this.operationalLayerType="CSV",this.outFields=["*"],this.path=null,this.spatialReference=h.WGS84,this.source=null,this.type="csv"}normalizeCtorArgs(e,t){return"string"==typeof e?{url:e,...t}:e}load(e){const t=r(e)?e.signal:null,o=this.loadFromPortal({supportedTypes:["CSV"],supportsData:!1},e).catch(i).then((async()=>this.initLayerProperties(await this.createGraphicsSource(t))));return this.addResolvingPromise(o),Promise.resolve(this)}get isTable(){return this.loaded&&null==this.geometryType}readWebMapLabelsVisible(e,t){return null!=t.showLabels?t.showLabels:!!(t.layerDefinition&&t.layerDefinition.drawingInfo&&t.layerDefinition.drawingInfo.labelingInfo)}set url(e){if(!e)return void this._set("url",e);const t=o(e);this._set("url",t.path),t.query&&(this.customParameters={...this.customParameters,...t.query})}async createGraphicsSource(e){const t=new u({loadOptions:{delimiter:this.delimiter,fields:this.fields,latitudeField:this.latitudeField,longitudeField:this.longitudeField,spatialReference:this.spatialReference,timeInfo:this.timeInfo,url:this.url},customParameters:this.customParameters});return this._set("source",t),await t.load({signal:e}),this.read({locationInfo:t.locationInfo,columnDelimiter:t.delimiter},{origin:"service",url:this.parsedUrl}),t}queryFeatures(e,t){return this.load().then((()=>this.source.queryFeatures(c.from(e)||this.createQuery()))).then((e=>{if(e?.features)for(const t of e.features)t.layer=t.sourceLayer=this;return e}))}queryObjectIds(e,t){return this.load().then((()=>this.source.queryObjectIds(c.from(e)||this.createQuery())))}queryFeatureCount(e,t){return this.load().then((()=>this.source.queryFeatureCount(c.from(e)||this.createQuery())))}queryExtent(e,t){return this.load().then((()=>this.source.queryExtent(c.from(e)||this.createQuery())))}read(e,t){super.read(e,t),t&&"service"===t.origin&&this.revert(["latitudeField","longitudeField"],"service")}write(e,t){return super.write(e,{...t,writeLayerSchema:!0})}clone(){throw new t("csv-layer:clone",`CSVLayer (title: ${this.title}, id: ${this.id}) cannot be cloned`)}async save(e){return m(this,"csv-layer:save")}async saveAs(e,t){return m(this,"csv-layer:save-as")}async hasDataChanged(){try{const{dataChanged:e,updates:t}=await this.source.refresh(this.customParameters);return r(t)&&this.read(t,{origin:"service",url:this.parsedUrl,ignoreDefaults:!0}),e}catch{}return!1}_verifyFields(){}_verifySource(){}_hasMemorySource(){return!1}};e([s({readOnly:!0,json:{read:!1,write:!1}})],f.prototype,"capabilities",void 0),e([s({type:[","," ",";","|","\t"],json:{read:{source:"columnDelimiter"},write:{target:"columnDelimiter",ignoreOrigin:!0}}})],f.prototype,"delimiter",void 0),e([s({readOnly:!0,type:Boolean,json:{origins:{"web-scene":{read:!1,write:!1}}}})],f.prototype,"editingEnabled",void 0),e([s({json:{read:{source:"layerDefinition.fields"},write:{target:"layerDefinition.fields"}}})],f.prototype,"fields",void 0),e([s({type:Boolean,readOnly:!0})],f.prototype,"isTable",null),e([a("web-map","labelsVisible",["layerDefinition.drawingInfo.labelingInfo","showLabels"])],f.prototype,"readWebMapLabelsVisible",null),e([s({type:String,json:{read:{source:"locationInfo.latitudeFieldName"},write:{target:"locationInfo.latitudeFieldName",ignoreOrigin:!0}}})],f.prototype,"latitudeField",void 0),e([s({type:["show","hide"]})],f.prototype,"listMode",void 0),e([s({type:["coordinates"],json:{read:{source:"locationInfo.locationType"},write:{target:"locationInfo.locationType",ignoreOrigin:!0,isRequired:!0}}})],f.prototype,"locationType",void 0),e([s({type:String,json:{read:{source:"locationInfo.longitudeFieldName"},write:{target:"locationInfo.longitudeFieldName",ignoreOrigin:!0}}})],f.prototype,"longitudeField",void 0),e([s({type:["CSV"]})],f.prototype,"operationalLayerType",void 0),e([s()],f.prototype,"outFields",void 0),e([s({type:String,json:{origins:{"web-scene":{read:!1,write:!1}},read:!1,write:!1}})],f.prototype,"path",void 0),e([s({json:{read:!1},cast:null,type:u,readOnly:!0})],f.prototype,"source",void 0),e([s({json:{read:!1},value:"csv",readOnly:!0})],f.prototype,"type",void 0),e([s({json:{read:p,write:{isRequired:!0,ignoreOrigin:!0,writer:y}}})],f.prototype,"url",null),f=e([n("esri.layers.CSVLayer")],f);const g=f;export{g as default};
|