GeoJSONLayer.js 8.6 KB

12345
  1. /*
  2. All material copyright ESRI, All Rights Reserved, unless otherwise specified.
  3. See https://js.arcgis.com/4.24/esri/copyright.txt for details.
  4. */
  5. import{_ as e}from"../chunks/tslib.es6.js";import"../geometry.js";import t 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"../renderers/SimpleRenderer.js";import"../renderers/UniqueValueRenderer.js";import"../renderers/support/jsonUtils.js";import{rendererTypes as r,webSceneRendererTypes as i}from"../renderers/support/types.js";import{isSome as o}from"../core/maybe.js";import{MultiOriginJSONMixin as s}from"../core/MultiOriginJSONSupport.js";import{urlToObject as p}from"../core/urlUtils.js";import{property as n}from"../core/accessorSupport/decorators/property.js";import"../core/arrayUtils.js";import"../core/has.js";import"../core/accessorSupport/ensureType.js";import{subclass as l}from"../core/accessorSupport/decorators/subclass.js";import{featureGeometryTypeKebabDictionary as a}from"../geometry/support/typeUtils.js";import d from"./Layer.js";import{GeoJSONSource as u}from"./graphics/sources/GeoJSONSource.js";import{BlendLayer as m}from"./mixins/BlendLayer.js";import{CustomParametersMixin as y}from"./mixins/CustomParametersMixin.js";import{FeatureEffectLayer as h}from"./mixins/FeatureEffectLayer.js";import{OperationalLayer as c}from"./mixins/OperationalLayer.js";import{OrderedLayer as f}from"./mixins/OrderedLayer.js";import{RefreshableLayer as j}from"./mixins/RefreshableLayer.js";import{ScaleRangeLayer as g}from"./mixins/ScaleRangeLayer.js";import{TemporalLayer as v}from"./mixins/TemporalLayer.js";import{elevationInfo as b,id as x,labelsVisible as I,legendEnabled as O,opacity as S,popupEnabled as E,screenSizePerspectiveEnabled as F,url as P}from"./support/commonProperties.js";import{featureReductionProperty as w}from"./support/featureReductionUtils.js";import R from"./support/FeatureTemplate.js";import T from"./support/FeatureType.js";import L from"./support/Field.js";import{defineFieldProperties as D}from"./support/fieldProperties.js";import{fixRendererFields as q,fixTimeInfoFields as U}from"./support/fieldUtils.js";import N from"./support/LabelClass.js";import{reader as J}from"./support/labelingInfo.js";import Q from"../rest/support/Query.js";import{createPopupTemplate as C}from"../support/popupUtils.js";import _ from"../geometry/SpatialReference.js";import G from"../geometry/Extent.js";const V=D();let B=class extends(f(y(h(m(v(g(j(c(s(d)))))))))){constructor(e){super(e),this.copyright=null,this.definitionExpression=null,this.displayField=null,this.editingEnabled=!1,this.elevationInfo=null,this.featureReduction=null,this.fields=null,this.fieldsIndex=null,this.fullExtent=null,this.geometryType=null,this.hasZ=void 0,this.labelsVisible=!0,this.labelingInfo=null,this.legendEnabled=!0,this.objectIdField=null,this.operationalLayerType="GeoJSON",this.popupEnabled=!0,this.popupTemplate=null,this.screenSizePerspectiveEnabled=!0,this.source=new u({layer:this}),this.spatialReference=_.WGS84,this.templates=null,this.title="GeoJSON",this.type="geojson",this.typeIdField=null,this.types=null}destroy(){this.source?.destroy()}load(e){return this.addResolvingPromise(this.source.load(e).then((()=>{this.read(this.source.sourceJSON,{origin:"service",url:this.parsedUrl}),this.revert(["objectIdField","fields","timeInfo"],"service"),q(this.renderer,this.fieldsIndex),U(this.timeInfo,this.fieldsIndex)}))),Promise.resolve(this)}get capabilities(){return this.source?this.source.capabilities:null}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}get parsedUrl(){return this.url?p(this.url):null}set renderer(e){q(e,this.fieldsIndex),this._set("renderer",e)}set url(e){if(!e)return void this._set("url",e);const t=p(e);this._set("url",t.path),t.query&&(this.customParameters={...this.customParameters,...t.query})}async applyEdits(e,t){const r=await import("./graphics/editingSupport.js");await this.load();const i=await r.applyEdits(this,this.source,e,t);return this.read({extent:this.source.sourceJSON.extent,timeInfo:this.source.sourceJSON.timeInfo},{origin:"service",ignoreDefaults:!0}),i}on(e,t){return super.on(e,t)}createPopupTemplate(e){return C(this,e)}createQuery(){const e=new Q,t=this.get("capabilities.data");e.returnGeometry=!0,t&&t.supportsZ&&(e.returnZ=!0),e.outFields=["*"],e.where=this.definitionExpression||"1=1";const{timeOffset:r,timeExtent:i}=this;return e.timeExtent=null!=r&&null!=i?i.offset(-r.value,r.unit):i||null,e}getFieldDomain(e,t){let r,i=!1;const o=t&&t.feature,s=o&&o.attributes,p=this.typeIdField&&s&&s[this.typeIdField];return null!=p&&this.types&&(i=this.types.some((t=>t.id==p&&(r=t.domains&&t.domains[e],r&&"inherited"===r.type&&(r=this._getLayerDomain(e)),!0)))),i||r||(r=this._getLayerDomain(e)),r}getField(e){return this.fieldsIndex.get(e)}queryFeatures(e,t){return this.load().then((()=>this.source.queryFeatures(Q.from(e)||this.createQuery(),t))).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(Q.from(e)||this.createQuery(),t)))}queryFeatureCount(e,t){return this.load().then((()=>this.source.queryFeatureCount(Q.from(e)||this.createQuery(),t)))}queryExtent(e,t){return this.load().then((()=>this.source.queryExtent(Q.from(e)||this.createQuery(),t)))}async hasDataChanged(){try{const{dataChanged:e,updates:t}=await this.source.refresh(this.customParameters);return o(t)&&this.read(t,{origin:"service",url:this.parsedUrl,ignoreDefaults:!0}),e}catch{}return!1}_getLayerDomain(e){if(!this.fields)return null;let t=null;return this.fields.some((r=>(r.name===e&&(t=r.domain),!!t))),t}};e([n({readOnly:!0,json:{read:!1,write:!1}})],B.prototype,"capabilities",null),e([n({type:String})],B.prototype,"copyright",void 0),e([n({readOnly:!0})],B.prototype,"createQueryVersion",null),e([n({readOnly:!0})],B.prototype,"defaultPopupTemplate",null),e([n({type:String,json:{name:"layerDefinition.definitionExpression",write:{enabled:!0,allowNull:!0}}})],B.prototype,"definitionExpression",void 0),e([n({type:String})],B.prototype,"displayField",void 0),e([n({type:Boolean})],B.prototype,"editingEnabled",void 0),e([n(b)],B.prototype,"elevationInfo",void 0),e([n(w)],B.prototype,"featureReduction",void 0),e([n({type:[L],json:{name:"layerDefinition.fields",write:{ignoreOrigin:!0,isRequired:!0},origins:{service:{name:"fields"}}}})],B.prototype,"fields",void 0),e([n(V.fieldsIndex)],B.prototype,"fieldsIndex",void 0),e([n({type:G,json:{name:"extent"}})],B.prototype,"fullExtent",void 0),e([n({type:["point","polygon","polyline","multipoint"],json:{read:{reader:a.read}}})],B.prototype,"geometryType",void 0),e([n({type:Boolean})],B.prototype,"hasZ",void 0),e([n(x)],B.prototype,"id",void 0),e([n({type:Boolean,readOnly:!0})],B.prototype,"isTable",null),e([n(I)],B.prototype,"labelsVisible",void 0),e([n({type:[N],json:{name:"layerDefinition.drawingInfo.labelingInfo",read:{reader:J},write:!0}})],B.prototype,"labelingInfo",void 0),e([n(O)],B.prototype,"legendEnabled",void 0),e([n({type:["show","hide"]})],B.prototype,"listMode",void 0),e([n({type:String,json:{name:"layerDefinition.objectIdField",write:{ignoreOrigin:!0,isRequired:!0},origins:{service:{name:"objectIdField"}}}})],B.prototype,"objectIdField",void 0),e([n(S)],B.prototype,"opacity",void 0),e([n({type:["GeoJSON"]})],B.prototype,"operationalLayerType",void 0),e([n({readOnly:!0})],B.prototype,"parsedUrl",null),e([n(E)],B.prototype,"popupEnabled",void 0),e([n({type:t,json:{name:"popupInfo",write:!0}})],B.prototype,"popupTemplate",void 0),e([n({types:r,json:{name:"layerDefinition.drawingInfo.renderer",write:!0,origins:{service:{name:"drawingInfo.renderer"},"web-scene":{types:i}}}})],B.prototype,"renderer",null),e([n(F)],B.prototype,"screenSizePerspectiveEnabled",void 0),e([n({readOnly:!0})],B.prototype,"source",void 0),e([n({type:_})],B.prototype,"spatialReference",void 0),e([n({type:[R]})],B.prototype,"templates",void 0),e([n()],B.prototype,"title",void 0),e([n({json:{read:!1},readOnly:!0})],B.prototype,"type",void 0),e([n({type:String,readOnly:!0})],B.prototype,"typeIdField",void 0),e([n({type:[T]})],B.prototype,"types",void 0),e([n(P)],B.prototype,"url",null),B=e([l("esri.layers.GeoJSONLayer")],B);const Z=B;export{Z as default};