@vertigis/arcgis-extensions 48.4.1 → 48.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/data/Feature.js +1 -1
- package/docs/html/classes/tasks_identify_WMSSublayerIdentifyProvider.WMSSublayerIdentifyProvider.html +2 -2
- package/docs/html/variables/version.version.html +1 -1
- package/package.json +1 -1
- package/tasks/identify/WMSLayerFeatureInfoIdentifyProvider.js +1 -1
- package/tasks/identify/WMSSublayerIdentifyProvider.d.ts +3 -2
- package/tasks/identify/WMSSublayerIdentifyProvider.js +1 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
package/data/Feature.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__decorate as e}from"tslib";import t from"@arcgis/core/Graphic";import s from"@arcgis/core/core/Collection";import{fromJSON as i}from"@arcgis/core/geometry/support/jsonUtils";import{EntityBase as r}from"../Entity.js";import{Hyperlink as a}from"../Hyperlink.js";import{InvalidOperationError as o}from"../InvalidOperationError.js";import{isLayerExtension as n,isTableExtension as l,ItemType as h}from"../ItemType.js";import{serializable as u}from"../support/Serializable.js";import{CaseInsensitiveObservableMap as p}from"../utilities/CaseInsensitiveObservableMap.js";import{MapTransformCollection as c}from"../utilities/MapTransformCollection.js";import{ObservableMap as m}from"../utilities/ObservableMap.js";import{ReadOnlyMap as f}from"../utilities/ReadOnlyMap.js";import{Time as d}from"../utilities/Time.js";import{flatten as g,groupBy as y}from"../utilities/array.js";import{checkArg as _}from"../utilities/checkArg.js";import{compare as b}from"../utilities/collection.js";import{isCodedValueDomain as x,isGeometry as F}from"../utilities/esri.js";import{getArcadeExpressionFromField as w,getRelationshipFromField as v,isArcadeExpressionField as I}from"../utilities/field.js";import{parse as S,esriFormatToGeocortexFormat as z}from"../utilities/format/date.js";import{NumberFormat as A}from"../utilities/format/formats.js";import{parse as E}from"../utilities/format/number.js";import{format as j}from"../utilities/format/string.js";import{parse as T,esriFormatToGeocortexFormat as k}from"../utilities/format/time.js";import{map as R,find as O}from"../utilities/iterable.js";import{getLogger as C}from"../utilities/log.js";import{map as M}from"../utilities/promise.js";import{caseInsensitiveEquals as N}from"../utilities/string.js";import{onCollectionPropertyChange as D}from"../utilities/watch.js";import{FeatureSettings as V}from"./FeatureSettings.js";import{Schema as P}from"./Schema.js";const U=C("geocortex.api.data.Feature");export const SCORE_FIELD="_score";export const SCORE_FIELD_ORIGINAL="_score_original";let G=class extends r{attributes;get geometry(){return this._geometry}set geometry(e){this.notifyChange("geometryType"),this._geometry=F(e)||!e?e:i(e),this.schema.spatialReference=this._geometry?.spatialReference}settings;schema;attachments;expressionFieldValues;_itemType=h.FEATURE;get geometryType(){return this.geometry?this.geometry.type:void 0}get source(){return this._source}set source(e){this._source&&this.settings.parent===this._source.featureSettings&&(this.settings.parent=void 0),this._source&&this.schema.parent===this._source.schema&&(this.schema.parent=void 0),this._source=e,this.settings.parent||(this.settings.parent=e?e.featureSettings:void 0),this.schema.parent||(this.schema.parent=e?e.schema:void 0),this.notifyChange("attachmentsInitialized"),this.notifyChange("relatedFeaturesInitialized")}get primaryKey(){const e=this.attributes.get(this.schema.primaryKeyField);return null!=e?`${e}`:void 0}get hasGlobalId(){return!!this.schema.fields.find((e=>"global-id"===e.type))}get globalId(){const e=this.schema.fields.find((e=>"global-id"===e.type));return e?this.attributes.get(e.name):void 0}set globalId(e){const t=this.schema.fields.find((e=>"global-id"===e.type));if(!t)throw new o("Cannot set global ID on feature -- no global ID field.");this.attributes.set(t.name,e)}get presentableAttributes(){return this._presentableAttributes=this._presentableAttributes||new H(this),this._presentableAttributes}get title(){return this.format(this._title||"")}get description(){return this.format(this._description)}get hyperlinks(){return this._hyperlinks||(this._hyperlinks=new X(this))}get relatedFeatures(){return this._relatedFeatures}get type(){if(this.schema.typeIdField&&this.attributes.has(this.schema.typeIdField)){const e=this.attributes.get(this.schema.typeIdField);return this.schema.types.find((t=>t.id===e))}}get attachmentsInitialized(){return!this.source||this._attachmentsInitialized}get relatedFeaturesInitialized(){return!this.source||this.source.relationships.every((e=>this._initializedRelationships.has(e)))}get expressionsInitialized(){return!this.settings.popupTemplate?.expressionInfos?.length||this._expressionsInitialized}get _hydrationStatus(){return this._featureHydrationStatus?this._featureHydrationStatus:this.source?.capabilities?.supportsQuery&&1===this.attributes.size&&void 0!==this.primaryKey?"dehydrated":"hydrated"}set _hydrationStatus(e){this._featureHydrationStatus=e}get _key(){return`${this.source?.id}//${this.primaryKey??this.globalId??this.id}`}get _title(){let e;return this.settings.popupTemplate&&(e="function"==typeof this.settings.popupTemplate.title?this.settings.popupTemplate.title():this.settings.popupTemplate.title),e||this.schema.displayField&&this.presentableAttributes.get(this.schema.displayField)||""}get _description(){if(this.settings.popupTemplate?.content){if("string"==typeof this.settings.popupTemplate.content)return this.settings.popupTemplate.content;if(Array.isArray(this.settings.popupTemplate.content)){const e=this.settings.popupTemplate.content.find((e=>"text"===e.type));if(e)return e.text}}return""}_geometry;_source;_presentableAttributes;_hyperlinks;_featureHydrationStatus;_relatedFeatures;_expressionFieldValues=new m;_expressionValuesUpdatePending=!1;_attachmentsInitialized=!1;_expressionsInitialized=!1;_initializedRelationships=new WeakSet;constructor(e){super(e),this.settings=new V,this.settings._setFeature(this),this.schema=new P,this.schema._featureSettings=this.settings,this.attachments=new s,this.attributes=new p,this._relatedFeatures=new m,this.expressionFieldValues=new $(this._expressionFieldValues,this),D(this,"source.relationships",(()=>{this.notifyChange("relatedFeaturesInitialized")}),!0),this.settings.watch("popupTemplate",((e,t)=>{e!==t&&(this._expressionsInitialized=!1,this.notifyChange("expressionsInitialized"))}),!0)}format(e,...t){let s="string"==typeof e?{format:e}:e;_("options",s).isNotMissing();const{format:i}=s;_("format",i).isNotMissing();let r=s.format.replace(Q,B);return r=r.replace(K,((e,t,i,r,a)=>ee(this,t||i,r,{...s,format:a?`{0:${a}}`:"{0}"}))),r=r.replace(W,"{{"),s={...s},s.format=r,j(s,...t)}clearExpressionInfos(){this._expressionFieldValues.clear()}toGraphic(){return toGraphic(this)}async fetchExpressionInfos(e=!1){const{expressionInfos:t}=this.settings.popupTemplate??{};if(!t)return;const{runAsyncArcadeExpression:s}=await import("../utilities/arcade.js");if(await Promise.all(t.map((async e=>{try{const t=this.source?.layer??this.source?.sublayer;let i=this.source?.mapExtension;if(!i){const e=this.source?.layerExtension;i=e?.mapExtension}this._expressionFieldValues.set(e.name,await s(e.expression,{layer:t,map:i?.map,feature:this,spatialReference:this.schema.spatialReference}))}catch(t){t instanceof Error&&U.error({message:"Error evaluating expression '{0}': {1}.",error:t},e.name,t.message),this._expressionFieldValues.set(e.name,q)}}))),e)return this.attributes.on("change",(async e=>{this._expressionValuesUpdatePending||(this._expressionValuesUpdatePending=!0,setTimeout((async()=>{this._expressionValuesUpdatePending=!1,await this.fetchExpressionInfos()}),0))}));this._expressionsInitialized=!0,this.notifyChange("expressionsInitialized")}async fetchRelatedFeatures(e,t){if(!this.source)return;let s=[];if(e){const t=new Set(Array.isArray(e)?e:[e]);for(const e of t){const t="string"==typeof e?this.source.relationships.find((t=>t.id===e)):e;if(!t||!this.source.relationships.includes(t))throw new o("Relationship not found in feature source.");s.push(t)}}else s=this.source.relationships.toArray();const i=await M(s,(async e=>[e,await(async()=>{const s=await e.getRelatedFeatures(this,t);return this._initializedRelationships.add(e),s})()]));for(const e of i)this._relatedFeatures.set(e[0],e[1]);this.notifyChange("relatedFeaturesInitialized")}async fetchAttachments(){if(this.source){const e=await this.source.getAttachments(this);b(this.attachments,e,{equals:(e,t)=>e.id===t.id,onMissing:(e,t)=>{this.attachments.remove(e)},onNew:(e,t)=>{this.attachments.add(e)},onMatch:(e,t,s,i)=>{this.attachments.splice(s,1,t)}}),this._attachmentsInitialized=!0,this.notifyChange("attachmentsInitialized")}}async addAttachment(e){return this.source?.addAttachment(this,e)}async deleteAttachments(e){return this.source?.deleteAttachments(this,e)}_getSerializableProperties(){return{...super._getSerializableProperties(),attributes:{serializeModes:["project"],serialize:e=>{const t={};if("project"===e&&this.primaryKey&&(this.source?.capabilities).supportsQuery)t[this.schema.primaryKeyField]=this.primaryKey;else for(const[e,s]of this.attributes.entries())t[e]=s;return t},deserialize:e=>{if(this.attributes.clear(),e instanceof Map)e.forEach(((e,t)=>{this.attributes.set(t,e)}));else for(const[t,s]of Object.entries(e))this.attributes.set(t,s)}},geometry:{serializeModes:["project"],serialize:e=>"project"===e&&(this.source?.capabilities).supportsQuery?this.getDefault("geometry"):this.geometry?.toJSON(),deserialize:e=>{this.geometry=e}},settings:{serializeModes:["project"],serialize:e=>"project"===e&&(this.source?.capabilities).supportsQuery?this.getDefault("settings"):this.settings.toJSON(e)},schema:{serializeModes:["project"],serialize:e=>"project"===e&&(this.source?.capabilities).supportsQuery?this.getDefault("schema"):this.schema.toJSON(e)},source:["project"]}}_watchProperty(e,t,s,i){if("title"===e||"description"===e){const r=super._watchProperty(e,t,s,i),a="title"===e?"settings.popupTemplate.title":"settings.popupTemplate.content",o=this.watch(a,(()=>{this.notifyChange(e)})),n=this.presentableAttributes.on("change",(()=>{this.notifyChange(e)}));return{remove(){r.remove(),o.remove(),n.remove()}}}return super._watchProperty(e,t,s,i)}async _onInitialize(){const e=this._findRelationshipIds(this._title,this._description),t=this.source?this.source.relationships.map((e=>e.id)).toArray():[],s=[];for(const i of e)t.includes(i)?s.push(this.fetchRelatedFeatures(i)):U.error("Could not find relationship '{0}' referenced in feature title or description.",i);await Promise.all(s)}_findRelationshipIds(...e){const t=[];for(const s of e){let e;const i=s.replace(Q,B);for(;e=J.exec(i),null!==e;){const s=e[0];t.includes(s)||t.push(e[1])}}return t}};G=e([u],G);export{G as Feature};export function toFeature(e,t){const s=new G(t);if(e.attributes){const t=e.attributes;for(const[e,i]of Object.entries(t))s.attributes.set(e,i)}return s.geometry=e.geometry,e.popupTemplate&&(s.settings.popupTemplate=e.popupTemplate),s}export function toGraphic(e){const s=new t;s.attributes={};for(const t of e.attributes.keys())s.attributes[t]=e.attributes.get(t);return n(e.source)&&e.source.layer&&(s.layer=e.source.layer),l(e.source)&&e.source.table&&(s.layer=e.source.table),s.geometry=e.geometry,e.settings.popupTemplate&&(s.popupTemplate=e.settings.popupTemplate),s}const L="Presentable attributes are read-only.",Z="Feature hyperlinks are read-only. Modify the feature's hyperlink templates instead.";class $ extends f{_feature;_pending=new Set;constructor(e,t){super(e),this._feature=t}get(e){return super.has(e)||this._calcExpressionValue(e),super.get(e)}async _calcExpressionValue(e){if(!this._pending.has(e)){this._pending.add(e);try{const{spatialReference:t}=this._feature.schema,s=this._feature.settings.popupTemplate?.expressionInfos?.find((t=>t.name===e));if(!s)return;const{isArcadeScriptAsync:i,runAsyncArcadeExpression:r,arcadeScriptUsesGeometry:a,runArcadeExpression:o}=await import("../utilities/arcade.js");try{if(i(s.expression,t)){const i=this._feature.source?.layer??this._feature.source?.sublayer;let a=this._feature.source?.mapExtension;if(!a){const e=this._feature.source?.layerExtension;a=e?.mapExtension}this._originalMap.set(e,await r(s.expression,{feature:this._feature,layer:i,map:a?.map,spatialReference:t}))}else{if(a(s.expression,t)){const{enableGeometrySupport:e}=await import("@arcgis/core/arcade/arcade");await e()}this._originalMap.set(e,o(s.expression,{feature:this._feature,spatialReference:t}))}}catch(t){t instanceof Error&&U.error({message:"Error evaluating expression '{0}': {1}.",error:t},e,t.message),this._originalMap.set(e,q)}}finally{this._pending.delete(e)}}}}class H extends f{[Symbol.toStringTag];get size(){return this._feature.attributes.size+this._feature.schema.fields._expressionFieldsLength}_feature;_numObservers;_onAllObserversRemoved;constructor(e){super(new p),this._feature=e}clear(){throw new o(L)}delete(e){throw new o(L)}forEach(e,t){_("callback",e).isNotMissing();for(const s of this.keys())e.call(t,this.get(s),s,this)}get(e){const t=this._getFieldExtensionFormat(e);return this._formatAttribute(e,t)}has(e){for(const t of this.keys())if(N(t,e))return!0;return!1}set(...e){throw new o(L)}*entries(){yield*R(this.keys(),(e=>[e,this.get(e)]))}*keys(){yield*this._feature.attributes.keys();for(const e of this._feature.schema.fields.expressionFields)yield e.name;if(null!=this._feature.source?.relationships)for(const e of this._feature.source.relationships)if("one-to-one"===e.cardinality||"many-to-one"===e.cardinality)for(const t of e.relatedSource.schema.fields)yield`relationships/${e.id}/${t.name}`}*values(){yield*R(this.keys(),(e=>this.get(e)))}[Symbol.iterator](){return this.entries()}toJSON(){return Array.from(this.entries())}on(e,t){if(_("callback",t).isNotMissing(),!this._numObservers){const e=new Map,t=new Set,s=()=>{for(const e of t)e.remove();t.clear()};let i;const r=()=>{const t=()=>{i&&(window.clearTimeout(i),i=void 0)};t(),i=window.setTimeout((()=>{const s=[],i=[];for(const[t,i]of this.entries())i!==e.get(t)&&s.push([t,i]);for(const[t,s]of e.entries())this.has(t)&&s===this.get(t)||i.push([t,s]);if(s.length||i.length){const e={added:s,removed:i,target:this};this.emit("change",e),a()}t()}))},a=()=>{e.clear(),s();for(const s of this.keys()){const i=this._getFieldExtension(s);let a="{0}";if(i){const e=i.watch("format",r);t.add(e),i.format&&(a=i.format)}e.set(s,this._formatAttribute(s,a))}};a();const o=this._feature.attributes.on("change",r),n=this._feature.schema.fieldExtensions.on("change",r),l=this._feature.settings.formatSettings.watch(["numberFormat","dateFormat","timeFormat","locale"],r),h=this._feature.expressionFieldValues.on("change",r),u=this._feature.schema.fields.on("change",(e=>{(e.added?.some((e=>I(e.name)))||e.removed?.some((e=>I(e.name))))&&r()})),p=this._feature.settings.watch("popupTemplate",r);this._onAllObserversRemoved=()=>{h.remove(),o.remove(),n.remove(),u.remove(),l.remove(),p.remove(),e.clear(),s()}}const s=super.on("change",t);return this._numObservers++,{remove:()=>{s.remove(),this._numObservers--,this._numObservers||this._onAllObserversRemoved()}}}watch(e,t){if("size"===e){const e=this._feature.attributes.watch("size",((e,s)=>{t(e+this._feature.schema.fields._expressionFieldsLength,s+this._feature.schema.fields._expressionFieldsLength,"size",this)})),s=this._feature.schema.fields.watch("_expressionFieldsLength",((e,s)=>{t(e+this._feature.attributes.size,s+this._feature.attributes.size,"size",this)}));return{remove:()=>{e.remove(),s.remove()}}}return super.watch(e,t)}_getFieldExtension(e){const t=this._feature.schema.findFieldByName(e);if(t)return this._feature.schema.fieldExtensions.forField(t)}_getFieldExtensionFormat(e){const t=this._getFieldExtension(e);return t?t.format:"{0}"}_formatAttribute(e,t){const s=w(e);if(null!=s)return ee(this._feature,"expression",s,{format:t});const[i,r]=v(e);return null!=i?ee(this._feature,i,r,{format:t}):ee(this._feature,void 0,e,{format:t})}}const K=/\{(?:relationships[\\/]([\w-]*)[\\/])?(?:(expression)[\\/])?([_a-zA-ZÀ-ÖØ-öø-ÿ][._a-zA-ZÀ-ÖØ-öø-ÿ0-9]*)(?::([^}]*))?\}/gi,J=/\{relationships\/([\w-]*)[\\/]([^}]*)\}/gi,Q=/{{/g,B="\0MAGIC\0",W=new RegExp(B,"g"),q="#INVALID";class X extends c{_feature;_hyperlinks;constructor(e){super(e.settings.hyperlinkTemplates,(e=>this._getHyperlink(e))),this._feature=e}_getHyperlink(e){return this._hyperlinks=this._hyperlinks||new WeakMap,this._hyperlinks.has(e)||this._hyperlinks.set(e,new Y(this._feature,e)),this._hyperlinks.get(e)}}let Y=class extends a{get url(){return this._template.url?this._feature.format(this._template.url):this._template.url}set url(e){throw new o(Z)}get text(){return this._template.text?this._feature.format(this._template.text):this._template.text}set text(e){throw new o(Z)}get iconUrl(){return this._template.iconUrl?this._feature.format(this._template.iconUrl):this._template.iconUrl}set iconUrl(e){throw new o(Z)}get target(){return this._template.target?this._feature.format(this._template.target):this._template.target}set target(e){throw new o(Z)}get tooltip(){return this._template.tooltip?this._feature.format(this._template.tooltip):this._template.tooltip}set tooltip(e){throw new o(Z)}_feature;_template;constructor(e,t){super(t.toJSON()),this._feature=e,this._template=t}_watchProperty(e,t,s,i){const r=super._watchProperty(e,t,s,i),a=this._template.watch(e,(()=>{this.notifyChange(e)})),o=this._feature.presentableAttributes.on("change",(()=>{this.notifyChange(e)})),n=this._feature.relatedFeatures.on("change",(()=>{this.notifyChange(e)}));return{remove:()=>{r.remove(),a.remove(),o.remove(),n.remove()}}}_getSerializableProperties(){return{}}};function ee(e,t,s,i={format:"{0}"}){if(!N(t,"expression")){if(t){const r=O(e.relatedFeatures.keys(),(e=>N(e.id,t)));if(!r)return U.debug("Could not resolve related field '{0}/{1}",t,s),q;const a=Array.from(e.relatedFeatures.get(r));return"many-to-one"===r.cardinality||"one-to-one"===r.cardinality?a.length<1?(U.debug("Could not resolve related field '{0}/{1}",t,s),q):te(a[0],s,i):a.map((e=>te(e,s,i))).filter((e=>""!==e)).join(",")}return te(e,s,i)}if(!e.settings.popupTemplate?.expressionInfos?.find((e=>N(e.name,s))))return U.debug("Could not find expression '{0}'.",s),q;try{const t=e.expressionFieldValues.get(s)??i.defaultExpressionValue??"",r=e.schema.findFieldByName(`expression/${s}`),a=null==r?void 0:e.schema.fieldExtensions.forField(r);return se(e,t,s,a?.formatSettings,i)}catch(e){if(e instanceof Error)return U.error({message:"Error evaluating expression '{0}': {1}.",error:e},s,e.message),q;throw e}}function te(e,t,s){let i;if(i=e.attributes.get(t),null==i)return"";const r=e.schema.findFieldByName(t),a=e.type?.domains?.[r?.name??t],o=e=>e.codedValues?.find((e=>e.code.toString()===i.toString()))?.name??i;let n;if(N(t,e.schema.typeIdField)){const t=a&&"inherited"!==a.type?a:r?.domain;i="coded-value"===t?.type?o(t):e.type?.name??i}else if(a&&x(a))i=o(a);else if(r?.domain&&x(r.domain))i=o(r.domain);else if(r){switch(r.type){case"integer":case"small-integer":case"big-integer":case"single":case"double":i=E(i);break;case"date":i=S({timeZone:e.schema.timeZone},i);break;case"timestamp-offset":case"date-only":i=S({},i),"date-only"===r.type&&(s.isDateOnly=!0);break;case"time-only":i=T(i);break;default:i=`${i.toString()}`}const t=e.schema.fieldExtensions.forField(r);t&&(n=t.formatSettings)}return se(e,i,t,n,s)}function se(e,t,s,i,r){if("string"==typeof t&&(null==r.format||"{0}"===r.format))return t;const a={...r};if("number"==typeof t||t instanceof Date||t instanceof d){null==a.locale&&(a.locale=i?.locale??e.settings.formatSettings.locale);const r=e.settings.popupTemplate?.fieldInfos?.find((e=>N(e.fieldName,s)))?.format;"number"==typeof t?function(e,t,s,i){null==e.currency&&(e.currency=t?.currency??i.settings.formatSettings.currency);null==e.numberFormat&&(e.numberFormat=t?.numberFormat,null==e.numberFormat&&(e.numberFormat=null==s?i.settings.formatSettings.numberFormat:s.digitSeparator?A.NUMBER:A.FIXED_POINT));null==e.fractionalDigits&&(e.fractionalDigits=t?.fractionalDigits,null==e.fractionalDigits&&(e.fractionalDigits=null==s?i.settings.formatSettings.fractionalDigits:s.places))}(a,i,r,e):t instanceof Date?function(e,t,s,i){null==e.dateFormat&&(e.dateFormat=t?.dateFormat,null==e.dateFormat&&(e.dateFormat=null==s?i.settings.formatSettings.dateFormat:z(s.dateFormat)));null==e.timeZone&&(e.timeZone=t?.timeZone??i.settings.formatSettings.timeZone)}(a,i,r,e):function(e,t,s,i){null==e.timeFormat&&(e.timeFormat=t?.timeFormat,null==e.timeFormat&&(e.timeFormat=null==s?i.settings.formatSettings.timeFormat:k(s.dateFormat)))}(a,i,r,e)}return j(a,t)}Y=e([u],Y);export async function resolveRelatedFeatures(e){const t=y(e,(e=>e.source));await Promise.all(g([...t.keys()].map((e=>e.relationships.toArray()))).map((e=>(async e=>{[...(await e.getAllRelatedFeatures(t.get(e.source))).entries()].forEach((([t,s])=>{t.relatedFeatures.set(e,s)}))})(e))))}
|
|
1
|
+
import{__decorate as e}from"tslib";import t from"@arcgis/core/Graphic";import s from"@arcgis/core/core/Collection";import{fromJSON as i}from"@arcgis/core/geometry/support/jsonUtils";import{EntityBase as r}from"../Entity.js";import{Hyperlink as a}from"../Hyperlink.js";import{InvalidOperationError as o}from"../InvalidOperationError.js";import{isLayerExtension as n,isTableExtension as l,ItemType as h}from"../ItemType.js";import{serializable as u}from"../support/Serializable.js";import{CaseInsensitiveObservableMap as p}from"../utilities/CaseInsensitiveObservableMap.js";import{MapTransformCollection as c}from"../utilities/MapTransformCollection.js";import{ObservableMap as m}from"../utilities/ObservableMap.js";import{ReadOnlyMap as f}from"../utilities/ReadOnlyMap.js";import{Time as d}from"../utilities/Time.js";import{flatten as g,groupBy as y}from"../utilities/array.js";import{checkArg as _}from"../utilities/checkArg.js";import{compare as b}from"../utilities/collection.js";import{isCodedValueDomain as x,isGeometry as F}from"../utilities/esri.js";import{getArcadeExpressionFromField as w,getRelationshipFromField as v,isArcadeExpressionField as I}from"../utilities/field.js";import{parse as S,esriFormatToGeocortexFormat as z}from"../utilities/format/date.js";import{NumberFormat as A}from"../utilities/format/formats.js";import{parse as E}from"../utilities/format/number.js";import{format as j}from"../utilities/format/string.js";import{parse as T,esriFormatToGeocortexFormat as k}from"../utilities/format/time.js";import{map as R,find as O}from"../utilities/iterable.js";import{getLogger as C}from"../utilities/log.js";import{map as M}from"../utilities/promise.js";import{caseInsensitiveEquals as N}from"../utilities/string.js";import{onCollectionPropertyChange as D}from"../utilities/watch.js";import{FeatureSettings as V}from"./FeatureSettings.js";import{Schema as P}from"./Schema.js";const U=C("geocortex.api.data.Feature");export const SCORE_FIELD="_score";export const SCORE_FIELD_ORIGINAL="_score_original";let G=class extends r{attributes;get geometry(){return this._geometry}set geometry(e){this.notifyChange("geometryType"),this._geometry=F(e)||!e?e:i(e),this.schema.spatialReference=this._geometry?.spatialReference}settings;schema;attachments;expressionFieldValues;_itemType=h.FEATURE;get geometryType(){return this.geometry?this.geometry.type:void 0}get source(){return this._source}set source(e){this._source&&this.settings.parent===this._source.featureSettings&&(this.settings.parent=void 0),this._source&&this.schema.parent===this._source.schema&&(this.schema.parent=void 0),this._source=e,this.settings.parent||(this.settings.parent=e?e.featureSettings:void 0),this.schema.parent||(this.schema.parent=e?e.schema:void 0),this.notifyChange("attachmentsInitialized"),this.notifyChange("relatedFeaturesInitialized")}get primaryKey(){const e=this.attributes.get(this.schema.primaryKeyField);return null!=e?`${e}`:void 0}get hasGlobalId(){return!!this.schema.fields.find((e=>"global-id"===e.type))}get globalId(){const e=this.schema.fields.find((e=>"global-id"===e.type));return e?this.attributes.get(e.name):void 0}set globalId(e){const t=this.schema.fields.find((e=>"global-id"===e.type));if(!t)throw new o("Cannot set global ID on feature -- no global ID field.");this.attributes.set(t.name,e)}get presentableAttributes(){return this._presentableAttributes=this._presentableAttributes||new H(this),this._presentableAttributes}get title(){return this.format(this._title||"")}get description(){return this.format(this._description)}get hyperlinks(){return this._hyperlinks||(this._hyperlinks=new X(this))}get relatedFeatures(){return this._relatedFeatures}get type(){if(this.schema.typeIdField&&this.attributes.has(this.schema.typeIdField)){const e=this.attributes.get(this.schema.typeIdField);return this.schema.types.find((t=>t.id===e))}}get attachmentsInitialized(){return!this.source||this._attachmentsInitialized}get relatedFeaturesInitialized(){return!this.source||this.source.relationships.every((e=>this._initializedRelationships.has(e)))}get expressionsInitialized(){return!this.settings.popupTemplate?.expressionInfos?.length||this._expressionsInitialized}get _hydrationStatus(){return this._featureHydrationStatus?this._featureHydrationStatus:this.source?.capabilities?.supportsQuery&&1===this.attributes.size&&void 0!==this.primaryKey?"dehydrated":"hydrated"}set _hydrationStatus(e){this._featureHydrationStatus=e}get _key(){return`${this.source?.id}//${this.primaryKey??this.globalId??this.id}`}get _title(){let e;return this.settings.popupTemplate&&(e="function"==typeof this.settings.popupTemplate.title?this.settings.popupTemplate.title():this.settings.popupTemplate.title),e||this.schema.displayField&&this.presentableAttributes.get(this.schema.displayField)||""}get _description(){if(this.settings.popupTemplate?.content){if("string"==typeof this.settings.popupTemplate.content)return this.settings.popupTemplate.content;if(Array.isArray(this.settings.popupTemplate.content)){const e=this.settings.popupTemplate.content.find((e=>"text"===e.type));if(e)return e.text}}return""}_geometry;_source;_presentableAttributes;_hyperlinks;_featureHydrationStatus;_relatedFeatures;_expressionFieldValues=new m;_expressionValuesUpdatePending=!1;_attachmentsInitialized=!1;_expressionsInitialized=!1;_initializedRelationships=new WeakSet;constructor(e){super(e),this.settings=new V,this.settings._setFeature(this),this.schema=new P,this.schema._featureSettings=this.settings,this.attachments=new s,this.attributes=new p,this._relatedFeatures=new m,this.expressionFieldValues=new $(this._expressionFieldValues,this),D(this,"source.relationships",(()=>{this.notifyChange("relatedFeaturesInitialized")}),!0),this.settings.watch("popupTemplate",((e,t)=>{e!==t&&(this._expressionsInitialized=!1,this.notifyChange("expressionsInitialized"))}),!0)}format(e,...t){let s="string"==typeof e?{format:e}:e;_("options",s).isNotMissing();const{format:i}=s;_("format",i).isNotMissing();let r=s.format.replace(Q,B);return r=r.replace(K,((e,t,i,r,a)=>ee(this,t||i,r,{...s,format:a?`{0:${a}}`:"{0}"}))),r=r.replace(W,"{{"),s={...s},s.format=r,j(s,...t)}clearExpressionInfos(){this._expressionFieldValues.clear()}toGraphic(){return toGraphic(this)}async fetchExpressionInfos(e=!1){const{expressionInfos:t}=this.settings.popupTemplate??{};if(!t)return;const{runAsyncArcadeExpression:s}=await import("../utilities/arcade.js");if(await Promise.all(t.map((async e=>{try{const t=this.source?.layer??this.source?.sublayer;let i=this.source?.mapExtension;if(!i){const e=this.source?.layerExtension;i=e?.mapExtension}this._expressionFieldValues.set(e.name,await s(e.expression,{layer:t,map:i?.map,feature:this,spatialReference:this.schema.spatialReference}))}catch(t){t instanceof Error&&U.error({message:"Error evaluating expression '{0}': {1}.",error:t},e.name,t.message),this._expressionFieldValues.set(e.name,q)}}))),e)return this.attributes.on("change",(async e=>{this._expressionValuesUpdatePending||(this._expressionValuesUpdatePending=!0,setTimeout((async()=>{this._expressionValuesUpdatePending=!1,await this.fetchExpressionInfos()}),0))}));this._expressionsInitialized=!0,this.notifyChange("expressionsInitialized")}async fetchRelatedFeatures(e,t){if(!this.source)return;let s=[];if(e){const t=new Set(Array.isArray(e)?e:[e]);for(const e of t){const t="string"==typeof e?this.source.relationships.find((t=>t.id===e)):e;if(!t||!this.source.relationships.includes(t))throw new o("Relationship not found in feature source.");s.push(t)}}else s=this.source.relationships.toArray();const i=await M(s,(async e=>[e,await(async()=>{const s=await e.getRelatedFeatures(this,t);return this._initializedRelationships.add(e),s})()]));for(const e of i)this._relatedFeatures.set(e[0],e[1]);this.notifyChange("relatedFeaturesInitialized")}async fetchAttachments(){if(this.source){const e=await this.source.getAttachments(this);b(this.attachments,e,{equals:(e,t)=>e.id===t.id,onMissing:(e,t)=>{this.attachments.remove(e)},onNew:(e,t)=>{this.attachments.add(e)},onMatch:(e,t,s,i)=>{this.attachments.splice(s,1,t)}}),this._attachmentsInitialized=!0,this.notifyChange("attachmentsInitialized")}}async addAttachment(e){return this.source?.addAttachment(this,e)}async deleteAttachments(e){return this.source?.deleteAttachments(this,e)}_getSerializableProperties(){return{...super._getSerializableProperties(),attributes:{serializeModes:["project"],serialize:e=>{const t={};if("project"===e&&this.primaryKey&&(this.source?.capabilities).supportsQuery)t[this.schema.primaryKeyField]=this.primaryKey;else for(const[e,s]of this.attributes.entries())t[e]=s;return t},deserialize:e=>{if(this.attributes.clear(),e instanceof Map||e instanceof m)e.forEach(((e,t)=>{this.attributes.set(t,e)}));else for(const[t,s]of Object.entries(e))this.attributes.set(t,s)}},geometry:{serializeModes:["project"],serialize:e=>"project"===e&&(this.source?.capabilities).supportsQuery?this.getDefault("geometry"):this.geometry?.toJSON(),deserialize:e=>{this.geometry=e}},settings:{serializeModes:["project"],serialize:e=>"project"===e&&(this.source?.capabilities).supportsQuery?this.getDefault("settings"):this.settings.toJSON(e)},schema:{serializeModes:["project"],serialize:e=>"project"===e&&(this.source?.capabilities).supportsQuery?this.getDefault("schema"):this.schema.toJSON(e)},source:["project"]}}_watchProperty(e,t,s,i){if("title"===e||"description"===e){const r=super._watchProperty(e,t,s,i),a="title"===e?"settings.popupTemplate.title":"settings.popupTemplate.content",o=this.watch(a,(()=>{this.notifyChange(e)})),n=this.presentableAttributes.on("change",(()=>{this.notifyChange(e)}));return{remove(){r.remove(),o.remove(),n.remove()}}}return super._watchProperty(e,t,s,i)}async _onInitialize(){const e=this._findRelationshipIds(this._title,this._description),t=this.source?this.source.relationships.map((e=>e.id)).toArray():[],s=[];for(const i of e)t.includes(i)?s.push(this.fetchRelatedFeatures(i)):U.error("Could not find relationship '{0}' referenced in feature title or description.",i);await Promise.all(s)}_findRelationshipIds(...e){const t=[];for(const s of e){let e;const i=s.replace(Q,B);for(;e=J.exec(i),null!==e;){const s=e[0];t.includes(s)||t.push(e[1])}}return t}};G=e([u],G);export{G as Feature};export function toFeature(e,t){const s=new G(t);if(e.attributes){const t=e.attributes;for(const[e,i]of Object.entries(t))s.attributes.set(e,i)}return s.geometry=e.geometry,e.popupTemplate&&(s.settings.popupTemplate=e.popupTemplate),s}export function toGraphic(e){const s=new t;s.attributes={};for(const t of e.attributes.keys())s.attributes[t]=e.attributes.get(t);return n(e.source)&&e.source.layer&&(s.layer=e.source.layer),l(e.source)&&e.source.table&&(s.layer=e.source.table),s.geometry=e.geometry,e.settings.popupTemplate&&(s.popupTemplate=e.settings.popupTemplate),s}const L="Presentable attributes are read-only.",Z="Feature hyperlinks are read-only. Modify the feature's hyperlink templates instead.";class $ extends f{_feature;_pending=new Set;constructor(e,t){super(e),this._feature=t}get(e){return super.has(e)||this._calcExpressionValue(e),super.get(e)}async _calcExpressionValue(e){if(!this._pending.has(e)){this._pending.add(e);try{const{spatialReference:t}=this._feature.schema,s=this._feature.settings.popupTemplate?.expressionInfos?.find((t=>t.name===e));if(!s)return;const{isArcadeScriptAsync:i,runAsyncArcadeExpression:r,arcadeScriptUsesGeometry:a,runArcadeExpression:o}=await import("../utilities/arcade.js");try{if(i(s.expression,t)){const i=this._feature.source?.layer??this._feature.source?.sublayer;let a=this._feature.source?.mapExtension;if(!a){const e=this._feature.source?.layerExtension;a=e?.mapExtension}this._originalMap.set(e,await r(s.expression,{feature:this._feature,layer:i,map:a?.map,spatialReference:t}))}else{if(a(s.expression,t)){const{enableGeometrySupport:e}=await import("@arcgis/core/arcade/arcade");await e()}this._originalMap.set(e,o(s.expression,{feature:this._feature,spatialReference:t}))}}catch(t){t instanceof Error&&U.error({message:"Error evaluating expression '{0}': {1}.",error:t},e,t.message),this._originalMap.set(e,q)}}finally{this._pending.delete(e)}}}}class H extends f{[Symbol.toStringTag];get size(){return this._feature.attributes.size+this._feature.schema.fields._expressionFieldsLength}_feature;_numObservers;_onAllObserversRemoved;constructor(e){super(new p),this._feature=e}clear(){throw new o(L)}delete(e){throw new o(L)}forEach(e,t){_("callback",e).isNotMissing();for(const s of this.keys())e.call(t,this.get(s),s,this)}get(e){const t=this._getFieldExtensionFormat(e);return this._formatAttribute(e,t)}has(e){for(const t of this.keys())if(N(t,e))return!0;return!1}set(...e){throw new o(L)}*entries(){yield*R(this.keys(),(e=>[e,this.get(e)]))}*keys(){yield*this._feature.attributes.keys();for(const e of this._feature.schema.fields.expressionFields)yield e.name;if(null!=this._feature.source?.relationships)for(const e of this._feature.source.relationships)if("one-to-one"===e.cardinality||"many-to-one"===e.cardinality)for(const t of e.relatedSource.schema.fields)yield`relationships/${e.id}/${t.name}`}*values(){yield*R(this.keys(),(e=>this.get(e)))}[Symbol.iterator](){return this.entries()}toJSON(){return Array.from(this.entries())}on(e,t){if(_("callback",t).isNotMissing(),!this._numObservers){const e=new Map,t=new Set,s=()=>{for(const e of t)e.remove();t.clear()};let i;const r=()=>{const t=()=>{i&&(window.clearTimeout(i),i=void 0)};t(),i=window.setTimeout((()=>{const s=[],i=[];for(const[t,i]of this.entries())i!==e.get(t)&&s.push([t,i]);for(const[t,s]of e.entries())this.has(t)&&s===this.get(t)||i.push([t,s]);if(s.length||i.length){const e={added:s,removed:i,target:this};this.emit("change",e),a()}t()}))},a=()=>{e.clear(),s();for(const s of this.keys()){const i=this._getFieldExtension(s);let a="{0}";if(i){const e=i.watch("format",r);t.add(e),i.format&&(a=i.format)}e.set(s,this._formatAttribute(s,a))}};a();const o=this._feature.attributes.on("change",r),n=this._feature.schema.fieldExtensions.on("change",r),l=this._feature.settings.formatSettings.watch(["numberFormat","dateFormat","timeFormat","locale"],r),h=this._feature.expressionFieldValues.on("change",r),u=this._feature.schema.fields.on("change",(e=>{(e.added?.some((e=>I(e.name)))||e.removed?.some((e=>I(e.name))))&&r()})),p=this._feature.settings.watch("popupTemplate",r);this._onAllObserversRemoved=()=>{h.remove(),o.remove(),n.remove(),u.remove(),l.remove(),p.remove(),e.clear(),s()}}const s=super.on("change",t);return this._numObservers++,{remove:()=>{s.remove(),this._numObservers--,this._numObservers||this._onAllObserversRemoved()}}}watch(e,t){if("size"===e){const e=this._feature.attributes.watch("size",((e,s)=>{t(e+this._feature.schema.fields._expressionFieldsLength,s+this._feature.schema.fields._expressionFieldsLength,"size",this)})),s=this._feature.schema.fields.watch("_expressionFieldsLength",((e,s)=>{t(e+this._feature.attributes.size,s+this._feature.attributes.size,"size",this)}));return{remove:()=>{e.remove(),s.remove()}}}return super.watch(e,t)}_getFieldExtension(e){const t=this._feature.schema.findFieldByName(e);if(t)return this._feature.schema.fieldExtensions.forField(t)}_getFieldExtensionFormat(e){const t=this._getFieldExtension(e);return t?t.format:"{0}"}_formatAttribute(e,t){const s=w(e);if(null!=s)return ee(this._feature,"expression",s,{format:t});const[i,r]=v(e);return null!=i?ee(this._feature,i,r,{format:t}):ee(this._feature,void 0,e,{format:t})}}const K=/\{(?:relationships[\\/]([\w-]*)[\\/])?(?:(expression)[\\/])?([_a-zA-ZÀ-ÖØ-öø-ÿ][._a-zA-ZÀ-ÖØ-öø-ÿ0-9]*)(?::([^}]*))?\}/gi,J=/\{relationships\/([\w-]*)[\\/]([^}]*)\}/gi,Q=/{{/g,B="\0MAGIC\0",W=new RegExp(B,"g"),q="#INVALID";class X extends c{_feature;_hyperlinks;constructor(e){super(e.settings.hyperlinkTemplates,(e=>this._getHyperlink(e))),this._feature=e}_getHyperlink(e){return this._hyperlinks=this._hyperlinks||new WeakMap,this._hyperlinks.has(e)||this._hyperlinks.set(e,new Y(this._feature,e)),this._hyperlinks.get(e)}}let Y=class extends a{get url(){return this._template.url?this._feature.format(this._template.url):this._template.url}set url(e){throw new o(Z)}get text(){return this._template.text?this._feature.format(this._template.text):this._template.text}set text(e){throw new o(Z)}get iconUrl(){return this._template.iconUrl?this._feature.format(this._template.iconUrl):this._template.iconUrl}set iconUrl(e){throw new o(Z)}get target(){return this._template.target?this._feature.format(this._template.target):this._template.target}set target(e){throw new o(Z)}get tooltip(){return this._template.tooltip?this._feature.format(this._template.tooltip):this._template.tooltip}set tooltip(e){throw new o(Z)}_feature;_template;constructor(e,t){super(t.toJSON()),this._feature=e,this._template=t}_watchProperty(e,t,s,i){const r=super._watchProperty(e,t,s,i),a=this._template.watch(e,(()=>{this.notifyChange(e)})),o=this._feature.presentableAttributes.on("change",(()=>{this.notifyChange(e)})),n=this._feature.relatedFeatures.on("change",(()=>{this.notifyChange(e)}));return{remove:()=>{r.remove(),a.remove(),o.remove(),n.remove()}}}_getSerializableProperties(){return{}}};function ee(e,t,s,i={format:"{0}"}){if(!N(t,"expression")){if(t){const r=O(e.relatedFeatures.keys(),(e=>N(e.id,t)));if(!r)return U.debug("Could not resolve related field '{0}/{1}",t,s),q;const a=Array.from(e.relatedFeatures.get(r));return"many-to-one"===r.cardinality||"one-to-one"===r.cardinality?a.length<1?(U.debug("Could not resolve related field '{0}/{1}",t,s),q):te(a[0],s,i):a.map((e=>te(e,s,i))).filter((e=>""!==e)).join(",")}return te(e,s,i)}if(!e.settings.popupTemplate?.expressionInfos?.find((e=>N(e.name,s))))return U.debug("Could not find expression '{0}'.",s),q;try{const t=e.expressionFieldValues.get(s)??i.defaultExpressionValue??"",r=e.schema.findFieldByName(`expression/${s}`),a=null==r?void 0:e.schema.fieldExtensions.forField(r);return se(e,t,s,a?.formatSettings,i)}catch(e){if(e instanceof Error)return U.error({message:"Error evaluating expression '{0}': {1}.",error:e},s,e.message),q;throw e}}function te(e,t,s){let i;if(i=e.attributes.get(t),null==i)return"";const r=e.schema.findFieldByName(t),a=e.type?.domains?.[r?.name??t],o=e=>e.codedValues?.find((e=>e.code.toString()===i.toString()))?.name??i;let n;if(N(t,e.schema.typeIdField)){const t=a&&"inherited"!==a.type?a:r?.domain;i="coded-value"===t?.type?o(t):e.type?.name??i}else if(a&&x(a))i=o(a);else if(r?.domain&&x(r.domain))i=o(r.domain);else if(r){switch(r.type){case"integer":case"small-integer":case"big-integer":case"single":case"double":i=E(i);break;case"date":i=S({timeZone:e.schema.timeZone},i);break;case"timestamp-offset":case"date-only":i=S({},i),"date-only"===r.type&&(s.isDateOnly=!0);break;case"time-only":i=T(i);break;default:i=`${i.toString()}`}const t=e.schema.fieldExtensions.forField(r);t&&(n=t.formatSettings)}return se(e,i,t,n,s)}function se(e,t,s,i,r){if("string"==typeof t&&(null==r.format||"{0}"===r.format))return t;const a={...r};if("number"==typeof t||t instanceof Date||t instanceof d){null==a.locale&&(a.locale=i?.locale??e.settings.formatSettings.locale);const r=e.settings.popupTemplate?.fieldInfos?.find((e=>N(e.fieldName,s)))?.format;"number"==typeof t?function(e,t,s,i){null==e.currency&&(e.currency=t?.currency??i.settings.formatSettings.currency);null==e.numberFormat&&(e.numberFormat=t?.numberFormat,null==e.numberFormat&&(e.numberFormat=null==s?i.settings.formatSettings.numberFormat:s.digitSeparator?A.NUMBER:A.FIXED_POINT));null==e.fractionalDigits&&(e.fractionalDigits=t?.fractionalDigits,null==e.fractionalDigits&&(e.fractionalDigits=null==s?i.settings.formatSettings.fractionalDigits:s.places))}(a,i,r,e):t instanceof Date?function(e,t,s,i){null==e.dateFormat&&(e.dateFormat=t?.dateFormat,null==e.dateFormat&&(e.dateFormat=null==s?i.settings.formatSettings.dateFormat:z(s.dateFormat)));null==e.timeZone&&(e.timeZone=t?.timeZone??i.settings.formatSettings.timeZone)}(a,i,r,e):function(e,t,s,i){null==e.timeFormat&&(e.timeFormat=t?.timeFormat,null==e.timeFormat&&(e.timeFormat=null==s?i.settings.formatSettings.timeFormat:k(s.dateFormat)))}(a,i,r,e)}return j(a,t)}Y=e([u],Y);export async function resolveRelatedFeatures(e){const t=y(e,(e=>e.source));await Promise.all(g([...t.keys()].map((e=>e.relationships.toArray()))).map((e=>(async e=>{[...(await e.getAllRelatedFeatures(t.get(e.source))).entries()].forEach((([t,s])=>{t.relatedFeatures.set(e,s)}))})(e))))}
|
|
@@ -14,13 +14,13 @@
|
|
|
14
14
|
</div><div class="tsd-comment tsd-typography"></div></li><li><span><code class="tsd-tag">Optional</code><span class="tsd-kind-parameter">options</span>: <a href="../interfaces/tasks_identify_IdentifyOptions.IdentifyOptions-1.html" class="tsd-signature-type tsd-kind-interface">IdentifyOptions</a></span><div class="tsd-comment tsd-typography"><p>The identify options object.</p>
|
|
15
15
|
</div><div class="tsd-comment tsd-typography"></div></li></ul></div><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type">Geometry</span><span class="tsd-signature-symbol">></span></h4><div class="tsd-comment tsd-typography"></div><aside class="tsd-sources"><p>Inherited from <a href="tasks_identify_IdentifyProviderBase.IdentifyProviderBase.html">IdentifyProviderBase</a>.<a href="tasks_identify_IdentifyProviderBase.IdentifyProviderBase.html#_applyTolerance">_applyTolerance</a></p></aside></li></ul></section><section class="tsd-panel tsd-member"><a id="_count" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><span>_count</span><a href="#_count" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ul class="tsd-signatures"><li class="tsd-signature tsd-anchor-link"><a id="_count._count-1" class="tsd-anchor"></a><span class="tsd-kind-call-signature">_count</span><span class="tsd-signature-symbol">(</span><span class="tsd-kind-parameter">source</span>, <span class="tsd-kind-parameter">geometry</span>, <span class="tsd-kind-parameter">options</span><span class="tsd-signature-symbol">?</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol"><</span><a href="../interfaces/tasks_CountResult.CountResult.html" class="tsd-signature-type tsd-kind-interface">CountResult</a><span class="tsd-signature-symbol">></span><a href="#_count._count-1" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></li><li class="tsd-description"><div class="tsd-comment tsd-typography"><p>Invoked to perform the actual work for <a href="tasks_identify_IdentifyProviderBase.IdentifyProviderBase.html#count" class="tsd-kind-method">count</a>. Derived classes
|
|
16
16
|
should override this method rather than count().</p>
|
|
17
|
-
</div><div class="tsd-parameters"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameter-list"><li><span><span class="tsd-kind-parameter">source</span>: <a href="
|
|
17
|
+
</div><div class="tsd-parameters"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameter-list"><li><span><span class="tsd-kind-parameter">source</span>: <a href="mapping_WMSSublayerExtension.WMSSublayerExtension.html" class="tsd-signature-type tsd-kind-class">WMSSublayerExtension</a></span><div class="tsd-comment tsd-typography"><p>The source to identify.</p>
|
|
18
18
|
</div><div class="tsd-comment tsd-typography"></div></li><li><span><span class="tsd-kind-parameter">geometry</span>: <span class="tsd-signature-type">Geometry</span></span><div class="tsd-comment tsd-typography"><p>The geometry to match against.</p>
|
|
19
19
|
</div><div class="tsd-comment tsd-typography"></div></li><li><span><span class="tsd-kind-parameter">options</span>: <a href="../interfaces/tasks_identify_IdentifyOptions.IdentifyOptions-1.html" class="tsd-signature-type tsd-kind-interface">IdentifyOptions</a><span class="tsd-signature-symbol"> = {}</span></span><div class="tsd-comment tsd-typography"><p>Options that affect the identify operation.</p>
|
|
20
20
|
</div><div class="tsd-comment tsd-typography"></div></li></ul></div><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol"><</span><a href="../interfaces/tasks_CountResult.CountResult.html" class="tsd-signature-type tsd-kind-interface">CountResult</a><span class="tsd-signature-symbol">></span></h4><div class="tsd-comment tsd-typography"></div><aside class="tsd-sources"><p>Overrides <a href="tasks_identify_IdentifyProviderBase.IdentifyProviderBase.html">IdentifyProviderBase</a>.<a href="tasks_identify_IdentifyProviderBase.IdentifyProviderBase.html#_count">_count</a></p></aside></li></ul></section><section class="tsd-panel tsd-member"><a id="_identify" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><span>_identify</span><a href="#_identify" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ul class="tsd-signatures"><li class="tsd-signature tsd-anchor-link"><a id="_identify._identify-1" class="tsd-anchor"></a><span class="tsd-kind-call-signature">_identify</span><span class="tsd-signature-symbol">(</span><span class="tsd-kind-parameter">source</span>, <span class="tsd-kind-parameter">geometry</span>, <span class="tsd-kind-parameter">options</span><span class="tsd-signature-symbol">?</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">AsyncIterable</span><span class="tsd-signature-symbol"><</span><a href="data_Feature.Feature.html" class="tsd-signature-type tsd-kind-class">Feature</a><span class="tsd-signature-symbol">, </span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">, </span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">></span><a href="#_identify._identify-1" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></li><li class="tsd-description"><div class="tsd-comment tsd-typography"><p>Invoked to perform the actual work for <a href="tasks_identify_IdentifyProviderBase.IdentifyProviderBase.html#identify" class="tsd-kind-method">identify</a> on a single
|
|
21
21
|
source. Derived classes should override this method rather than
|
|
22
22
|
identify().</p>
|
|
23
|
-
</div><div class="tsd-parameters"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameter-list"><li><span><span class="tsd-kind-parameter">source</span>: <a href="
|
|
23
|
+
</div><div class="tsd-parameters"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameter-list"><li><span><span class="tsd-kind-parameter">source</span>: <a href="mapping_WMSSublayerExtension.WMSSublayerExtension.html" class="tsd-signature-type tsd-kind-class">WMSSublayerExtension</a></span><div class="tsd-comment tsd-typography"><p>The source to identify.</p>
|
|
24
24
|
</div><div class="tsd-comment tsd-typography"></div></li><li><span><span class="tsd-kind-parameter">geometry</span>: <span class="tsd-signature-type">Geometry</span></span><div class="tsd-comment tsd-typography"><p>The geometry to match against.</p>
|
|
25
25
|
</div><div class="tsd-comment tsd-typography"></div></li><li><span><code class="tsd-tag">Optional</code><span class="tsd-kind-parameter">options</span>: <a href="../interfaces/tasks_identify_IdentifyOptions.IdentifyOptions-1.html" class="tsd-signature-type tsd-kind-interface">IdentifyOptions</a></span><div class="tsd-comment tsd-typography"><p>Options that affect the identify operation.</p>
|
|
26
26
|
</div><div class="tsd-comment tsd-typography"></div></li></ul></div><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">AsyncIterable</span><span class="tsd-signature-symbol"><</span><a href="data_Feature.Feature.html" class="tsd-signature-type tsd-kind-class">Feature</a><span class="tsd-signature-symbol">, </span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">, </span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">></span></h4><div class="tsd-comment tsd-typography"></div><aside class="tsd-sources"><p>Overrides <a href="tasks_identify_IdentifyProviderBase.IdentifyProviderBase.html">IdentifyProviderBase</a>.<a href="tasks_identify_IdentifyProviderBase.IdentifyProviderBase.html#_identify">_identify</a></p></aside></li></ul></section><section class="tsd-panel tsd-member tsd-is-protected tsd-is-inherited"><a id="_identifyMany" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><code class="tsd-tag">Protected</code><span>_identify<wbr/>Many</span><a href="#_identifyMany" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ul class="tsd-signatures tsd-is-protected tsd-is-inherited"><li class="tsd-signature tsd-anchor-link"><a id="_identifyMany._identifyMany-1" class="tsd-anchor"></a><span class="tsd-kind-call-signature">_identify<wbr/>Many</span><span class="tsd-signature-symbol">(</span><span class="tsd-kind-parameter">sources</span>, <span class="tsd-kind-parameter">geometry</span>, <span class="tsd-kind-parameter">options</span>, <span class="tsd-kind-parameter">geometryType</span><span class="tsd-signature-symbol">?</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">AsyncIterable</span><span class="tsd-signature-symbol"><</span><a href="data_Feature.Feature.html" class="tsd-signature-type tsd-kind-class">Feature</a><span class="tsd-signature-symbol">, </span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">, </span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">></span><a href="#_identifyMany._identifyMany-1" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></li><li class="tsd-description"><div class="tsd-comment tsd-typography"><p>Invoked to perform the work for <a href="tasks_identify_IdentifyProviderBase.IdentifyProviderBase.html#identify" class="tsd-kind-method">identify</a>. Default implementation
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
<!DOCTYPE html><html class="default" lang="en"><head><meta charset="utf-8"/><meta http-equiv="x-ua-compatible" content="IE=edge"/><title>version | @vertigis/arcgis-extensions</title><meta name="description" content="Documentation for @vertigis/arcgis-extensions"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="stylesheet" href="../assets/style.css"/><link rel="stylesheet" href="../assets/highlight.css"/><script defer src="../assets/main.js"></script><script async src="../assets/icons.js" id="tsd-icons-script"></script><script async src="../assets/search.js" id="tsd-search-script"></script><script async src="../assets/navigation.js" id="tsd-nav-script"></script></head><body><script>document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os";document.body.style.display="none";setTimeout(() => app?app.showPage():document.body.style.removeProperty("display"),500)</script><header class="tsd-page-toolbar"><div class="tsd-toolbar-contents container"><div class="table-cell" id="tsd-search" data-base=".."><div class="field"><label for="tsd-search-field" class="tsd-widget tsd-toolbar-icon search no-caption"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><use href="../assets/icons.svg#icon-search"></use></svg></label><input type="text" id="tsd-search-field" aria-label="Search"/></div><div class="field"><div id="tsd-toolbar-links"></div></div><ul class="results"><li class="state loading">Preparing search index...</li><li class="state failure">The search index is not available</li></ul><a href="../index.html" class="title">@vertigis/arcgis-extensions</a></div><div class="table-cell" id="tsd-widgets"><a href="#" class="tsd-widget tsd-toolbar-icon menu no-caption" data-toggle="menu" aria-label="Menu"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><use href="../assets/icons.svg#icon-menu"></use></svg></a></div></div></header><div class="container container-main"><div class="col-content"><div class="tsd-page-title"><ul class="tsd-breadcrumb"><li><a href="../modules.html">@vertigis/arcgis-extensions</a></li><li><a href="../modules/version.html">version</a></li><li><a href="version.version.html">version</a></li></ul><h1>Variable version<code class="tsd-tag">Const</code></h1></div><div class="tsd-signature"><span class="tsd-kind-variable">version</span><span class="tsd-signature-symbol"> = "48.
|
|
1
|
+
<!DOCTYPE html><html class="default" lang="en"><head><meta charset="utf-8"/><meta http-equiv="x-ua-compatible" content="IE=edge"/><title>version | @vertigis/arcgis-extensions</title><meta name="description" content="Documentation for @vertigis/arcgis-extensions"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="stylesheet" href="../assets/style.css"/><link rel="stylesheet" href="../assets/highlight.css"/><script defer src="../assets/main.js"></script><script async src="../assets/icons.js" id="tsd-icons-script"></script><script async src="../assets/search.js" id="tsd-search-script"></script><script async src="../assets/navigation.js" id="tsd-nav-script"></script></head><body><script>document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os";document.body.style.display="none";setTimeout(() => app?app.showPage():document.body.style.removeProperty("display"),500)</script><header class="tsd-page-toolbar"><div class="tsd-toolbar-contents container"><div class="table-cell" id="tsd-search" data-base=".."><div class="field"><label for="tsd-search-field" class="tsd-widget tsd-toolbar-icon search no-caption"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><use href="../assets/icons.svg#icon-search"></use></svg></label><input type="text" id="tsd-search-field" aria-label="Search"/></div><div class="field"><div id="tsd-toolbar-links"></div></div><ul class="results"><li class="state loading">Preparing search index...</li><li class="state failure">The search index is not available</li></ul><a href="../index.html" class="title">@vertigis/arcgis-extensions</a></div><div class="table-cell" id="tsd-widgets"><a href="#" class="tsd-widget tsd-toolbar-icon menu no-caption" data-toggle="menu" aria-label="Menu"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><use href="../assets/icons.svg#icon-menu"></use></svg></a></div></div></header><div class="container container-main"><div class="col-content"><div class="tsd-page-title"><ul class="tsd-breadcrumb"><li><a href="../modules.html">@vertigis/arcgis-extensions</a></li><li><a href="../modules/version.html">version</a></li><li><a href="version.version.html">version</a></li></ul><h1>Variable version<code class="tsd-tag">Const</code></h1></div><div class="tsd-signature"><span class="tsd-kind-variable">version</span><span class="tsd-signature-symbol"> = "48.5.1"</span></div><div class="tsd-comment tsd-typography"><p>The current version of the Geocortex ArcGIS Extensions API.</p>
|
|
2
2
|
</div><div class="tsd-comment tsd-typography"></div></div><div class="col-sidebar"><div class="page-menu"><div class="tsd-navigation settings"><details class="tsd-accordion"><summary class="tsd-accordion-summary"><h3><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><use href="../assets/icons.svg#icon-chevronDown"></use></svg>Settings</h3></summary><div class="tsd-accordion-details"><div class="tsd-filter-visibility"><span class="settings-label">Member Visibility</span><ul id="tsd-filter-options"><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-protected" name="protected"/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Protected</span></label></li><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-inherited" name="inherited" checked/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Inherited</span></label></li></ul></div><div class="tsd-theme-toggle"><label class="settings-label" for="tsd-theme">Theme</label><select id="tsd-theme"><option value="os">OS</option><option value="light">Light</option><option value="dark">Dark</option></select></div></div></details></div></div><div class="site-menu"><nav class="tsd-navigation"><a href="../modules.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-1"></use></svg><span>@vertigis/arcgis-extensions</span></a><ul class="tsd-small-nested-navigation" id="tsd-nav-container" data-base=".."><li>Loading...</li></ul></nav></div></div></div><footer></footer><div class="overlay"></div></body></html>
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"@arcgis/core/layers/support/Field.js";import t from"@arcgis/core/popup/FieldInfo.js";import o from"@arcgis/core/request";import{Feature as r}from"../../data/Feature.js";import{wfsFeatureCollectionToFeatures as s}from"../../mapping/support/ogc.js";import{geoJSONToEsri as i}from"../../utilities/_geoJson.js";import{take as a,toArray as n}from"../../utilities/asyncIterable.js";import{isWMSLayerExtension as l}from"../../utilities/extensions.js";import{IdentifyProviderBase as m}from"./IdentifyProviderBase.js";import{isIdentifiable as u}from"./IdentifyService.js";const f=["application/json","application/geojson","text/xml"],c=["OBJECTID","GLOBALID"];export class WMSLayerFeatureInfoIdentifyProvider extends m{isSupported(e,t,o){return l(e)&&e.layer?.featureInfoFormats?.some((e=>f.includes(e)))&&"point"===t?.type}_identify(e,t,r,s){const i=this,n=e._layerView,{extent:l}=n.view,m="point"===t.type?t:t.extent.center,c=n.view.toScreen(m),p=e.layer.featureInfoFormats.find((e=>f.includes(e))),{xmin:y,ymin:d,xmax:g,ymax:F,spatialReference:x}=l,I=`${y},${d},${g},${F}`,h=`EPSG:${x.latestWkid??x.wkid}`,
|
|
1
|
+
import e from"@arcgis/core/layers/support/Field.js";import t from"@arcgis/core/popup/FieldInfo.js";import o from"@arcgis/core/request";import{Feature as r}from"../../data/Feature.js";import{wfsFeatureCollectionToFeatures as s}from"../../mapping/support/ogc.js";import{geoJSONToEsri as i}from"../../utilities/_geoJson.js";import{take as a,toArray as n}from"../../utilities/asyncIterable.js";import{isWMSLayerExtension as l}from"../../utilities/extensions.js";import{IdentifyProviderBase as m}from"./IdentifyProviderBase.js";import{isIdentifiable as u}from"./IdentifyService.js";const f=["application/json","application/geojson","text/xml"],c=["OBJECTID","GLOBALID"];export class WMSLayerFeatureInfoIdentifyProvider extends m{isSupported(e,t,o){return l(e)&&e.layer?.featureInfoFormats?.some((e=>f.includes(e)))&&!e.wfsUrl&&"point"===t?.type}_identify(e,t,r,s){const i=this,n=e._layerView,{extent:l}=n.view,m="point"===t.type?t:t.extent.center,c=n.view.toScreen(m),p=e.layer.featureInfoFormats.find((e=>f.includes(e))),{xmin:y,ymin:d,xmax:g,ymax:F,spatialReference:x}=l,I=`${y},${d},${g},${F}`,h=`EPSG:${x.latestWkid??x.wkid}`,w=e.sublayerExtensions.filter(u).map((({sublayer:e})=>e.name)).filter(Boolean).join();return async function*(){const t=await o(e.layer.featureInfoUrl,{query:{SERVICE:"WMS",LAYERS:w,QUERY_LAYERS:w,REQUEST:"GetFeatureInfo",FORMAT:e.layer.imageFormat,INFO_FORMAT:p,FEATURE_COUNT:r.maxResults,BBOX:I,CRS:h,WIDTH:n.view.width.toString(),HEIGHT:n.view.height.toString(),I:Math.round(c.x).toString(),J:Math.round(c.y).toString(),version:e.layer.version},responseType:"text/xml"===p?"xml":"json"});let s;switch(p){case"application/json":case"application/geojson":s=i._jsonToFeatures(t,r,x,e);break;case"text/xml":s=i._xmlToFeatures(t,e,r)}r.maxResults?yield*a(s,r.maxResults):yield*s}()}async _count(e,t,o){return{source:e,count:(await n(this.identify(e,t,o))).length}}_normalizeFeature(o,r){const s=[];for(const e of o.attributes.keys())s.push(e);!r.returnGeometry&&o.geometry&&(o.geometry=void 0);const{featureSettings:i}=o.source,{popupTemplate:a}=i;if(a&&i._isDefaultPopupTemplate){if(!o.title){const e=c.find((e=>o.attributes.has(e)))??"ID";a.title=`{${e}}`,o.attributes.has(e)||o.attributes.set(e,o.id)}for(const e of s)a.fieldInfos.some((t=>t.fieldName===e))||a.fieldInfos.push(new t({fieldName:e}))}const{source:n}=o;for(const t of s)n.schema.findFieldByName(t)||n.schema.fields.add(new e({name:t,alias:t}));return o}async*_xmlToFeatures(e,t,o){const r=e.data.childNodes[0];if("FeatureCollection"===r.localName)for(const e of await s(r,t))yield this._normalizeFeature(e,o);else yield*this._membersToFeature(r,t,o)}async*_jsonToFeatures(e,t,o,s){const a=e.data,n=new Map;for(const e of a.features){let a;const l=e.properties;t.returnGeometry&&e.geometry&&(a=i(e.geometry),a&&(a.spatialReference=o));let m=n.get(e.layerName);m||(m=s.sublayerExtensions.find((t=>t.sublayer.name===e.layerName))??s,n.set(e.layerName,m)),yield this._normalizeFeature(new r({attributes:l,geometry:a,source:m,id:e.id}),t)}}*_membersToFeature(e,t,o){for(const s of e.getElementsByTagName("FIELDS")){const e=new Map;for(const t of s.getAttributeNames())e.set(t,s.getAttribute(t));yield this._normalizeFeature(new r({attributes:e,source:t}),o)}}}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type Geometry from "@arcgis/core/geometry/Geometry";
|
|
2
2
|
import type { Feature } from "../../data/Feature.js";
|
|
3
3
|
import type { FeatureSource } from "../../data/FeatureSource.js";
|
|
4
|
+
import type { WMSSublayerExtension } from "../../mapping/WMSSublayerExtension.js";
|
|
4
5
|
import type { RequestHelper } from "../../utilities/RequestHelper.js";
|
|
5
6
|
import type { CountResult } from "../CountResult.js";
|
|
6
7
|
import type { IdentifyOptions } from "./IdentifyOptions.js";
|
|
@@ -20,11 +21,11 @@ export declare class WMSSublayerIdentifyProvider extends IdentifyProviderBase {
|
|
|
20
21
|
/**
|
|
21
22
|
* @inheritDoc
|
|
22
23
|
*/
|
|
23
|
-
_identify(source:
|
|
24
|
+
_identify(source: WMSSublayerExtension, geometry: Geometry, options?: IdentifyOptions): AsyncIterable<Feature>;
|
|
24
25
|
/**
|
|
25
26
|
* @inheritDoc
|
|
26
27
|
*/
|
|
27
|
-
_count(source:
|
|
28
|
+
_count(source: WMSSublayerExtension, geometry: Geometry, options?: IdentifyOptions): Promise<CountResult>;
|
|
28
29
|
private _createGetFeatureSpatialQuery;
|
|
29
30
|
private _createGetFeatureElement;
|
|
30
31
|
private _createQueryElement;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"@arcgis/core/geometry/SpatialReference";import{InvalidOperationError as t}from"../../InvalidOperationError.js";import{wfsFeatureCollectionToFeatures as r}from"../../mapping/support/ogc.js";import{DefaultRequestHelper as
|
|
1
|
+
import e from"@arcgis/core/geometry/SpatialReference";import{InvalidOperationError as t}from"../../InvalidOperationError.js";import{wfsFeatureCollectionToFeatures as r}from"../../mapping/support/ogc.js";import{DefaultRequestHelper as i}from"../../utilities/RequestHelper.js";import{OgcNamespace as s,inferGmlVersion as a}from"../../utilities/_ogc.js";import{checkArg as n}from"../../utilities/checkArg.js";import{isWMSSublayerExtension as o}from"../../utilities/extensions.js";import{esriToGml as l,project as c,esriWktToWkid as m}from"../../utilities/geometry.js";import{IdentifyProviderBase as u}from"./IdentifyProviderBase.js";const p="2.0.0";export class WMSSublayerIdentifyProvider extends u{requestHelper=new i;isSupported(e,t,r){return o(e)&&void 0!==e.layerExtension?.wfsUrl}_identify(e,t,i){const s=(async()=>{if(await e.initialize(),await e.initializeWfs(),!e.wfsLayerInfo)return;const r=await this._createGetFeatureSpatialQuery(e,t,i),s={method:"post",body:(new XMLSerializer).serializeToString(r),headers:{"Content-Type":"text/xml; charset=utf-8"}};return this.requestHelper.request(e.layerExtension.wfsUrl,s)})();return async function*(){const t=await s;if(t){const i=await t.text(),s=(new DOMParser).parseFromString(i,"text/xml");if(!t||!s||s.childNodes.length<1)throw new Error("Response to WFS GetFeature request was invalid.");yield*await r(s.childNodes[0],e)}}()}async _count(e,t,i={}){const s=(async()=>{if(await e.initialize(),await e.initializeWfs(),!e.wfsLayerInfo)return;const r=await this._createGetFeatureSpatialQuery(e,t,i),s={method:"post",body:(new XMLSerializer).serializeToString(r),headers:{"Content-Type":"text/xml; charset=utf-8"}};return this.requestHelper.request(e.layerExtension.wfsUrl,s)})();let a;const n=await s;if(n){const t=await n.text(),i=(new DOMParser).parseFromString(t,"text/xml");if(!n||!i||i.childNodes.length<1)throw new Error("Response to WFS GetFeature request was invalid.");a=await r(i.childNodes[0],e)}return{source:e,count:a?.length??0}}async _createGetFeatureSpatialQuery(e,t,r){n("sublayerX",e).isNotMissing(),n("geometry",t).isNotMissing().satisfies((e=>["extent","point","polygon","polyline"].includes(e.type)));const{wfsLayerInfo:i}=e,s=i.wfsCapabilities.featureTypes.find((e=>e.namespaceUri===i.namespaceUri&&e.name===i.name)),a=this._createGetFeatureElement(r),o=await this._createQueryElement(s,t);a.appendChild(o);let l=i.fields.map((e=>e.name)).filter((e=>"__esri_wfs_id__"!==e));const c=r.outFields??e.featureSettings.outFields;c&&c.length>0&&(c.includes("*")||(l=c));const{geometryField:m}=e.wfsLayerInfo;l.includes(m)||(l=l.concat(m));for(const e of l){const t=this._createElement("wfs","PropertyName");t.textContent=e,o.appendChild(t)}const u=this._createElement("fes","Filter");o.appendChild(u);const p=this._createElement("fes","Intersects");u.appendChild(p);const f=this._createGeometryFieldElement(e);p.appendChild(f);const d=await this._createGeometryElement(e,t);return p.appendChild(d),a}_createGetFeatureElement(e){const t=this._createElement("wfs","GetFeature");t.setAttribute("service","WFS"),t.setAttribute("version",p),t.setAttribute("xmlns:xs",s.XS),t.setAttribute("xmlns:ogc",s.OGC),t.setAttribute("xmlns:wfs",this._getWfsNameSpace(p)),t.setAttribute("xmlns:gml",this._getGmlNameSpace(p)),t.setAttribute("outputFormat","application/gml+xml; version=3.2");let r=1e3;return e?.maxResults&&(r=e.maxResults),t.setAttribute("count",r.toString()),t.setAttribute("xmlns:fes",s.FES_2_0),t}async _createQueryElement(e,t){const r=this._createElement("wfs","Query"),i=await this._getCompatibleSR(e,t),s=this._getSrsName(i);return r.setAttribute("typeNames",e.name),r.setAttribute("srsName",s),r}_createGeometryFieldElement(e){const{geometryField:r}=e.wfsLayerInfo;if(!r)throw new t("The WFS feature type does not have a geometry field");const i=this._createElement("fes","ValueReference");return i.textContent=r,i}async _createGeometryElement(e,t){n("geometry",t).isNotMissing(),n("geometry.spatialReference",t.spatialReference).isNotMissing();const r={gmlVersion:a(p)},i=await this._getCompatibleSR(e.wfsFeatureType,t);if(r.srsName=this._getSrsName(i),i.equals(t.spatialReference))return l(t,r);{const i=await this.projectGeometry(t,e.wfsFeatureType.defaultSpatialReference);return l(i,r)}}async projectGeometry(t,r){const i=await c([t],new e({wkid:r}));if(i&&i.length>0)return i[0];throw new Error("Unable to create a geometry element.")}_createElement(e,t){n("name",t).isNotMissing();const r=document.implementation.createDocument(void 0,"temp",void 0);return e?r.createElement(`${e}:${t}`):r.createElement(t)}_getWfsNameSpace(e){switch(e){case"1.0.0":case"1.1.0":return s.WFS;default:return s.WFS_2_0}}_getGmlNameSpace(e){switch(e){case"1.0.0":case"1.1.0":return s.GML;default:return s.GML_3_2}}async _getCompatibleSR(t,r){n("wfsFeatureType",t).isNotMissing(),n("geometry",r).isNotMissing();const i=r.spatialReference.wkid?r.spatialReference:new e({wkid:await m(r.spatialReference.wkt)});return t.supportedSpatialReferences.map((t=>new e({wkid:t}))).find((e=>e.equals(i)))??new e({wkid:t.defaultSpatialReference})}_getSrsName(e){return`EPSG:${e.wkid}`}}
|
package/version.d.ts
CHANGED
package/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version="48.
|
|
1
|
+
export const version="48.5.1";
|