WFSSourceWorker.acdabd50.js 3.8 KB

1
  1. import{l as h,bC as l,eT as u,a as g,bH as _,c0 as f,ca as d,k as w,g as p,an as E,m as q,s as F}from"./index.6c049565.js";import{u as S}from"./FeatureStore.cb9b2be9.js";import{g as T,f as x}from"./projectionSupport.2b4a8796.js";import{Y as b}from"./QueryEngine.05824aeb.js";import{T as j,I}from"./geojson.eccb99e5.js";import{m as C}from"./sourceUtils.3b4ff83d.js";import{K as k}from"./wfsUtils.d297b1c9.js";import"./PooledRBush.f1e26fa4.js";import"./centroid.0c969b82.js";import"./json.879c9adc.js";import"./QueryEngineResult.fe74257f.js";import"./quantizationUtils.4f3ed95a.js";import"./WhereClause.39c9a123.js";import"./utils.5216fcae.js";import"./generateRendererUtils.03b1f269.js";import"./utils.9592ea84.js";import"./QueryEngineCapabilities.78217f95.js";import"./timeSupport.4d8d3d9b.js";import"./xmlUtils.56e603f6.js";class J{constructor(){this._queryEngine=null,this._customParameters=null,this._snapshotFeatures=async e=>{var i;const{objectIdField:t}=this._queryEngine,s=await k((i=this._getFeatureUrl)!=null?i:"",this._featureType.typeName,this._getFeatureOutputFormat,{customParameters:this._customParameters,dateFields:this._queryEngine.fieldsIndex.dateFields.map(r=>r.name),signal:e});await j(s),h(e);const a=I(s,{geometryType:this._queryEngine.geometryType,hasZ:!1,objectIdField:t});if(!l(this._queryEngine.spatialReference,u))for(const r of a)g(r.geometry)&&(r.geometry=_(T(f(r.geometry,this._queryEngine.geometryType,!1,!1),u,this._queryEngine.spatialReference)));let n=1;for(const r of a){const o={};C(this._fieldsIndex,o,r.attributes,!0),r.attributes=o,r.attributes[t]==null&&(r.objectId=r.attributes[t]=n++)}return a}}destroy(){var e;(e=this._queryEngine)==null||e.destroy(),this._queryEngine=null}async load(e,t){const{getFeatureUrl:s,getFeatureOutputFormat:a,spatialReference:n,fields:i,geometryType:r,featureType:o,objectIdField:y,customParameters:m}=e;this._featureType=o,this._customParameters=m,this._getFeatureUrl=s,this._getFeatureOutputFormat=a,this._fieldsIndex=new d(i),await this._checkProjection(n),h(t),this._queryEngine=new b({fields:i,geometryType:r,hasM:!1,hasZ:!1,objectIdField:y,spatialReference:n,timeInfo:null,featureStore:new S({geometryType:r,hasM:!1,hasZ:!1})});const c=await this._snapshotFeatures(w(t.signal));return this._queryEngine.featureStore.addMany(c),{extent:this._queryEngine.fullExtent}}async applyEdits(){throw new p("wfs-source:editing-not-supported","applyEdits() is not supported on WFSLayer")}async queryFeatures(e={},t={}){return await this._waitSnapshotComplete(),this._queryEngine.executeQuery(e,t.signal)}async queryFeatureCount(e={},t={}){return await this._waitSnapshotComplete(),this._queryEngine.executeQueryForCount(e,t.signal)}async queryObjectIds(e={},t={}){return await this._waitSnapshotComplete(),this._queryEngine.executeQueryForIds(e,t.signal)}async queryExtent(e={},t={}){return await this._waitSnapshotComplete(),this._queryEngine.executeQueryForExtent(e,t.signal)}async querySnapping(e,t={}){return await this._waitSnapshotComplete(),this._queryEngine.executeQueryForSnapping(e,t.signal)}async refresh(e){var t;return this._customParameters=e,(t=this._snapshotTask)==null||t.abort(),this._snapshotTask=E(this._snapshotFeatures),this._snapshotTask.promise.then(s=>{this._queryEngine.featureStore.clear(),s&&this._queryEngine.featureStore.addMany(s)},s=>{this._queryEngine.featureStore.clear(),q(s)||F.getLogger("esri.layers.WFSLayer").error(new p("wfs-layer:getfeature-error","An error occurred during the GetFeature request",{error:s}))}),await this._waitSnapshotComplete(),{extent:this._queryEngine.fullExtent}}async _waitSnapshotComplete(){if(this._snapshotTask&&!this._snapshotTask.finished){try{await this._snapshotTask.promise}catch{}return this._waitSnapshotComplete()}}async _checkProjection(e){try{await x(u,e)}catch{throw new p("unsupported-projection","Projection not supported",{spatialReference:e})}}}export{J as default};