@arcgis/core
Version:
ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API
6 lines (5 loc) • 3.14 kB
JavaScript
/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.32/esri/copyright.txt for details.
*/
import{_ as t}from"../../../chunks/tslib.es6.js";import has from"../../../core/has.js";import e from"../../../core/Loadable.js";import{debounce as o}from"../../../core/promiseUtils.js";import{open as r}from"../../../core/workers/workers.js";import{property as i}from"../../../core/accessorSupport/decorators/property.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 a from"../../../rest/support/FeatureSet.js";let c=class extends e{constructor(t){super(t),this.type="csv",this.refresh=o((async t=>{await this.load();const{extent:e,timeExtent:o}=await this._connection.invoke("refresh",t);return e&&(this.sourceJSON.extent=e),o&&(this.sourceJSON.timeInfo.timeExtent=[o.start,o.end]),{dataChanged:!0,updates:{extent:this.sourceJSON.extent,timeInfo:this.sourceJSON.timeInfo}}}))}load(t){const e=null!=t?t.signal:null;return this.addResolvingPromise(this._startWorker(e)),Promise.resolve(this)}destroy(){this._connection?.close(),this._connection=null}async openPorts(){return await this.load(),this._connection.openPorts()}async queryFeatures(t,e={}){await this.load(e);const o=await this._connection.invoke("queryFeatures",t?t.toJSON():null,e);return a.fromJSON(o)}async queryFeaturesJSON(t,e={}){return await this.load(e),this._connection.invoke("queryFeatures",t?t.toJSON():null,e)}async queryFeatureCount(t,e={}){return await this.load(e),this._connection.invoke("queryFeatureCount",t?t.toJSON():null,e)}async queryObjectIds(t,e={}){return await this.load(e),this._connection.invoke("queryObjectIds",t?t.toJSON():null,e)}async queryExtent(t,e={}){await this.load(e);const o=await this._connection.invoke("queryExtent",t?t.toJSON():null,e);return{count:o.count,extent:n.fromJSON(o.extent)}}async querySnapping(t,e={}){return await this.load(e),this._connection.invoke("querySnapping",t,e)}async queryAttributeBins(t,e={}){return await this.load(),this._connection.invoke("queryAttributeBins",t?t.toJSON():null,e)}async _startWorker(t){this._connection=await r("CSVSourceWorker",{strategy:has("feature-layers-workers")?"dedicated":"local",signal:t,registryTarget:this});const{url:e,delimiter:o,fields:i,latitudeField:s,longitudeField:n,spatialReference:a,timeInfo:c}=this.loadOptions,u=await this._connection.invoke("load",{url:e,customParameters:this.customParameters,parsingOptions:{delimiter:o,fields:i?.map((t=>t.toJSON())),latitudeField:s,longitudeField:n,spatialReference:a?.toJSON(),timeInfo:c?.toJSON()}},{signal:t});this.locationInfo=u.locationInfo,this.sourceJSON=u.layerDefinition,this.delimiter=u.delimiter}};t([i()],c.prototype,"type",void 0),t([i()],c.prototype,"loadOptions",void 0),t([i()],c.prototype,"customParameters",void 0),t([i()],c.prototype,"locationInfo",void 0),t([i()],c.prototype,"sourceJSON",void 0),t([i()],c.prototype,"delimiter",void 0),c=t([s("esri.layers.graphics.sources.CSVSource")],c);export{c as CSVSource};