@arcgis/core 5.2.0-next.161 → 5.2.0-next.162
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/arcgisGlobal.d.ts +1 -0
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/{0a5a9885ee6f5b5f99f0.js → 167b057ad50e6aef54de.js} +1 -1
- package/assets/esri/core/workers/chunks/17c6d66b47aa690df0d4.js +1 -0
- package/assets/esri/core/workers/chunks/{8480fe6b4372dbbfa7cc.js → 46c5371c7a627537098c.js} +10 -10
- package/assets/esri/core/workers/chunks/{60737732ce495bbdd0fc.js → 5f4feca26102088ea565.js} +1 -1
- package/assets/esri/core/workers/chunks/6da7229433105a69eb3f.js +1 -0
- package/assets/esri/core/workers/chunks/849879c8aed16315194c.js +1 -0
- package/assets/esri/core/workers/chunks/{9401cc22373566e1171e.js → 8a7b02037151767542f1.js} +1 -1
- package/assets/esri/core/workers/chunks/{4ed76fb5f6096a089f5b.js → 8e4a7027d171fb60e51e.js} +1 -1
- package/assets/esri/core/workers/chunks/{32b351b047ce1eb58146.js → 9ce8b9b80da146a5bbf5.js} +1 -1
- package/assets/esri/core/workers/chunks/a6f969851d4278865cc5.js +1 -0
- package/assets/esri/core/workers/chunks/{28b74bc77f7c13080074.js → be97a629e2ae4d13ceb3.js} +1 -1
- package/assets/esri/core/workers/chunks/{d33360c4f85203edafff.js → bf4d913e523eae2fda28.js} +1 -1
- package/assets/esri/core/workers/chunks/{172cfeb5f415e4662432.js → d7429b58c90e015263ad.js} +1 -1
- package/assets/esri/core/workers/chunks/{612104dff305ff062dfa.js → dfc81e66196c402f39b4.js} +2 -2
- package/assets/esri/themes/base/widgets/_OrientedImageryViewer.scss +2 -5
- package/assets/esri/themes/dark/main.css +1 -1
- package/assets/esri/themes/light/main.css +1 -1
- package/assets/esri/themes/light/view.css +1 -1
- package/chunks/DefaultMaterial.glsl.js +1 -1
- package/chunks/RealisticTree.glsl.js +1 -1
- package/chunks/RibbonLine.glsl.js +70 -64
- package/config.js +1 -1
- package/kernel.js +1 -1
- package/layers/FeatureLayer.d.ts +7 -5
- package/layers/FeatureLayer.js +1 -1
- package/layers/MapImageLayer.d.ts +9 -3
- package/layers/MapNotesLayer.d.ts +2 -2
- package/layers/SubtypeGroupLayer.d.ts +1 -1
- package/layers/SubtypeGroupLayer.js +1 -1
- package/layers/graphics/sources/FeatureLayerSource.js +1 -1
- package/layers/graphics/sources/support/QueryTask.js +1 -1
- package/layers/knowledgeGraph/KnowledgeGraphSublayer.d.ts +16 -16
- package/layers/mixins/ArcGISMapService.js +1 -1
- package/layers/ogc/ogcFeatureUtils.js +1 -1
- package/layers/support/Sublayer.d.ts +29 -15
- package/layers/support/Sublayer.js +1 -1
- package/package.json +2 -2
- package/rest/layerSources/DynamicDataLayer.d.ts +4 -2
- package/rest/layerSources/DynamicDataLayer.js +1 -1
- package/rest/layerSources/DynamicMapLayer.d.ts +1 -1
- package/rest/layerSources/DynamicWorkspaceLayer.d.ts +45 -0
- package/rest/layerSources/DynamicWorkspaceLayer.js +2 -0
- package/rest/layerSources/typeUtils.js +2 -0
- package/rest/query/operations/queryRelatedRecords.js +1 -1
- package/rest/query/operations/queryUtils.js +1 -1
- package/rest/support/Query.js +1 -1
- package/rest/support/RelationshipQuery.js +1 -1
- package/symbols/LineSymbol3D.d.ts +5 -3
- package/views/2d/analysis/ElevationProfileAnalysisView2D.d.ts +6 -0
- package/views/2d/analysis/ElevationProfileAnalysisView2D.js +1 -1
- package/views/2d/layers/features/layerAdapters/FeatureLayerAdapter.js +1 -1
- package/views/2d/layers/features/layerAdapters/SubtypeGroupLayerAdapter.js +1 -1
- package/views/3d/analysis/Dimension/DimensionVisualization.js +1 -1
- package/views/3d/analysis/Dimension/LengthDimensionSubTool.js +1 -1
- package/views/3d/analysis/Dimension/lengthDimensionManipulatorUtils.js +1 -1
- package/views/3d/analysis/ElevationProfileAnalysisView3D.d.ts +6 -0
- package/views/3d/analysis/ElevationProfileAnalysisView3D.js +1 -1
- package/views/3d/analysis/LineOfSight/LineOfSightObserverPlugin.js +1 -1
- package/views/3d/analysis/LineOfSight/LineOfSightTargetPlugin.js +1 -1
- package/views/3d/analysis/Viewshed/ViewshedFieldOfViewManipulation.js +1 -1
- package/views/3d/analysis/Viewshed/ViewshedPlacementPointPlugin.js +1 -1
- package/views/3d/analysis/ViewshedAnalysisView3D.js +1 -1
- package/views/3d/interactive/editingTools/move/MoveTool3D.js +1 -1
- package/views/3d/interactive/editingTools/reshape/ReshapeOperation.js +1 -1
- package/views/3d/interactive/manipulators/ResizeManipulator.js +1 -1
- package/views/3d/interactive/manipulators/RotateManipulator.js +1 -1
- package/views/3d/interactive/manipulators/ShiftManipulator.js +1 -1
- package/views/3d/interactive/visualElements/ExtendedLineVisualElement.js +1 -1
- package/views/3d/interactive/visualElements/LineVisualElement.js +1 -1
- package/views/3d/interactive/visualElements/OutlineVisualElement.js +1 -1
- package/views/3d/interactive/visualElements/ParallelLineVisualElement.js +1 -1
- package/views/3d/interactive/visualElements/RightAngleQuadVisualElement.js +1 -1
- package/views/3d/layers/FlowSubView3D.js +1 -1
- package/views/3d/layers/graphics/Graphics3DLineSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/Graphics3DPolygonFillSymbolLayer.js +1 -1
- package/views/3d/support/elevationUpdateUtils.js +1 -1
- package/views/3d/terrain/TerrainData.js +1 -1
- package/views/3d/terrain/terrainUtils.js +1 -1
- package/views/3d/webgl-engine/collections/Component/Material/ComponentData.glsl.js +2 -2
- package/views/3d/webgl-engine/core/shaderLibrary/attributes/SymbolColor.glsl.js +3 -3
- package/views/3d/webgl-engine/core/shaderLibrary/default/DefaultMaterialExternalColor.glsl.js +2 -2
- package/views/3d/webgl-engine/core/shaderLibrary/output/getEmissions.glsl.js +2 -2
- package/views/3d/webgl-engine/lib/GridLocalOriginFactory.js +1 -1
- package/views/3d/webgl-engine/lib/RenderingContext.js +1 -1
- package/views/3d/webgl-engine/materials/RibbonLineMaterial.js +1 -1
- package/views/3d/webgl-engine/shaders/RibbonLineTechniqueConfiguration.js +1 -1
- package/views/BreakpointsOwner.d.ts +6 -0
- package/views/analysis/ElevationProfile/ElevationProfileTool.js +1 -1
- package/views/types.d.ts +3 -0
- package/views/webgl/ShaderBuilder.js +1 -1
- package/assets/esri/core/workers/chunks/3e3e076fa5e8d5d5f33f.js +0 -1
- package/assets/esri/core/workers/chunks/510502a4c9a2ba8d3f7b.js +0 -1
- package/assets/esri/core/workers/chunks/e8bf653376a607f00897.js +0 -1
- package/assets/esri/core/workers/chunks/f4a7aa3cdbc0c429c359.js +0 -1
|
@@ -243,9 +243,10 @@ export interface MapImageLayerEvents extends RefreshableLayerEvents, LayerEvents
|
|
|
243
243
|
* <span id="dynamic-layers"></span>
|
|
244
244
|
* ## Dynamic layers
|
|
245
245
|
*
|
|
246
|
-
* Sublayers may be rendered on the fly as dynamic layers. There are
|
|
247
|
-
* [DynamicMapLayer](https://developers.arcgis.com/javascript/latest/references/core/rest/layerSources/DynamicMapLayer/)
|
|
248
|
-
* [DynamicDataLayer](https://developers.arcgis.com/javascript/latest/references/core/rest/layerSources/DynamicDataLayer/)
|
|
246
|
+
* Sublayers may be rendered on the fly as dynamic layers. There are three types of dynamic layers:
|
|
247
|
+
* [DynamicMapLayer](https://developers.arcgis.com/javascript/latest/references/core/rest/layerSources/DynamicMapLayer/),
|
|
248
|
+
* [DynamicDataLayer](https://developers.arcgis.com/javascript/latest/references/core/rest/layerSources/DynamicDataLayer/), and
|
|
249
|
+
* [DynamicWorkspaceLayer](https://developers.arcgis.com/javascript/latest/references/core/rest/layerSources/DynamicWorkspaceLayer/).
|
|
249
250
|
*
|
|
250
251
|
* [Dynamic map layers](https://developers.arcgis.com/javascript/latest/references/core/rest/layerSources/DynamicMapLayer/) allow you
|
|
251
252
|
* to override sublayers in the map service with new renderers,
|
|
@@ -260,6 +261,11 @@ export interface MapImageLayerEvents extends RefreshableLayerEvents, LayerEvents
|
|
|
260
261
|
* published and configured with the ArcGIS Server Manager.
|
|
261
262
|
* Data from tables may be joined to other tables or dynamic map layers.
|
|
262
263
|
*
|
|
264
|
+
* [Dynamic workspace layers](https://developers.arcgis.com/javascript/latest/references/core/rest/layerSources/DynamicWorkspaceLayer/) allow you
|
|
265
|
+
* to use pre-authored ArcGIS Pro layer files (`.lyrx`) stored in registered folders.
|
|
266
|
+
* These layers support advanced renderers and cartographically enriched symbols
|
|
267
|
+
* that are not supported by the map service's REST API specifications.
|
|
268
|
+
*
|
|
263
269
|
* > [!WARNING]
|
|
264
270
|
* >
|
|
265
271
|
* > Esri requires that when you use an ArcGIS Online basemap in your app, the map must include Esri attribution and you must be licensed to use the content.
|
|
@@ -77,9 +77,9 @@ export interface MapNotesLayerProperties extends LayerProperties, PortalLayerPro
|
|
|
77
77
|
* // get the layer type ("map-notes")
|
|
78
78
|
* console.log(map.layers.at(0).type);
|
|
79
79
|
* // get the title
|
|
80
|
-
* console.log(map.layers.
|
|
80
|
+
* console.log(map.layers.at(0).sublayers.at(0).sublayers.at(0).attributes.title);
|
|
81
81
|
* // update the popupTemplate
|
|
82
|
-
* map.layers.
|
|
82
|
+
* map.layers.at(0).sublayers.at(1).sublayers.at(0).popupTemplate.content = "{title} has an updated popup";
|
|
83
83
|
* });
|
|
84
84
|
* ```
|
|
85
85
|
*
|
|
@@ -17,7 +17,7 @@ import type { APIKeyMixin, APIKeyMixinProperties } from "./mixins/APIKeyMixin.js
|
|
|
17
17
|
import type { BlendLayer, BlendLayerProperties } from "./mixins/BlendLayer.js";
|
|
18
18
|
import type { CustomParametersMixin, CustomParametersMixinProperties } from "./mixins/CustomParametersMixin.js";
|
|
19
19
|
import type { DisplayFilteredLayer, DisplayFilteredLayerProperties } from "./mixins/DisplayFilteredLayer.js";
|
|
20
|
-
import type {
|
|
20
|
+
import type { EditBusLayerEvents, EditBusLayer } from "./mixins/EditBusLayer.js";
|
|
21
21
|
import type { FeatureLayerBase, FeatureLayerBaseProperties } from "./mixins/FeatureLayerBase.js";
|
|
22
22
|
import type { OperationalLayer, OperationalLayerProperties } from "./mixins/OperationalLayer.js";
|
|
23
23
|
import type { PortalLayer, PortalLayerProperties } from "./mixins/PortalLayer.js";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
import{__decorate as e}from"tslib";import{ClonableMixin as t}from"../core/Clonable.js";import n from"../core/Collection.js";import r from"../core/Error.js";import{loadAll as i}from"../core/loadAll.js";import{getOrCreateMapValue as a}from"../core/MapUtils.js";import{MultiOriginJSONSupportMixin as o}from"../core/MultiOriginJSONSupport.js";import{debounce as s,throwIfAbortError as ee,whenOrAbort as c}from"../core/promiseUtils.js";import{watch as te,sync as ne}from"../core/reactiveUtils.js";import{sqlAnd as re}from"../core/sql.js";import{property as l,subclass as ie}from"../core/accessorSupport/decorators.js";import u from"./Layer.js";import{APIKeyMixin as d}from"./mixins/APIKeyMixin.js";import{ArcGISService as ae}from"./mixins/ArcGISService.js";import{BlendLayer as f}from"./mixins/BlendLayer.js";import{CustomParametersMixin as p}from"./mixins/CustomParametersMixin.js";import{DisplayFilteredLayer as m}from"./mixins/DisplayFilteredLayer.js";import{EditBusLayer as h}from"./mixins/EditBusLayer.js";import{FeatureLayerBase as g}from"./mixins/FeatureLayerBase.js";import{OperationalLayer as _}from"./mixins/OperationalLayer.js";import{PortalLayer as v}from"./mixins/PortalLayer.js";import{RefreshableLayer as y}from"./mixins/RefreshableLayer.js";import{ReloadableLayer as b}from"./mixins/ReloadableLayer.js";import{ScaleRangeLayer as x}from"./mixins/ScaleRangeLayer.js";import{TemporalLayer as S}from"./mixins/TemporalLayer.js";import{titleFromUrlAndName as C}from"./support/arcgisLayerUrl.js";import{id as w}from"./support/commonProperties.js";import{ensureLayerCredential as T,computeEffectiveEditingEnabled as E,addAttachment as D,updateAttachment as O,applyEdits as k,createQuery as A,deleteAttachments as oe,fetchRecomputedExtents as j,computeDomainFromSubtypes as M,getFeatureSubtype as N,queryAttachments as P,queryObjectIds as F,queryFeatureCount as I,queryExtent as L,queryRelatedFeatures as R,queryRelatedFeaturesCount as z,hasDataChanged as B}from"./support/featureLayerUtils.js";import{defineFieldProperties as V}from"./support/fieldProperties.js";import{fixTimeInfoFields as H}from"./support/fieldUtils.js";import{getSymbolWithColorSupport as U,createSimpleRenderersWithUniqueColors as W}from"./support/subtypeGroupLayerUtils.js";import G from"./support/SubtypeSublayer.js";import{serviceSupportsSpatialReference as K}from"./support/versionUtils.js";import q from"../rest/support/Query.js";import{isNumber as se}from"../support/guards.js";import{addLayerUnsupportedError as J}from"../webdoc/support/unsupportedErrors.js";import{reader as ce}from"../core/accessorSupport/decorators/reader.js";const Y=`SubtypeGroupLayer`;function X(e,t){let n=[];for(let r of e){let e=new G;e.read(r,t),n.push(e)}return n}const Z=V();function Q(){return{name:`layerType`,read:{enabled:!0},write:{enabled:!0,ignoreOrigin:!0,isRequired:!0}}}let $=class extends b(g(m(h(f(S(x(y(ae(_(v(o(p(d(t(u))))))))))))))){constructor(...e){super(...e),this._sublayerLookup=new Map,this.fields=null,this.fieldsIndex=null,this.outFields=null,this.sublayers=new(n.ofType(G)),this.useUniqueColorsForSublayers=!0,this.supportedPortalItemTypes=[`Feature Service`],this.supportedSourceTypes=new Set([`Feature Layer`,`Table`]),this.title=`Layer`,this.type=`subtype-group`,this._debouncedSaveOperations=s(async(e,t,n)=>{let{save:r,saveAs:i}=await import(`./save/featureLayerUtils.js`);switch(e){case 0:return r(this,t);case 1:return i(this,n,t)}}),this.addHandles(te(()=>this.sublayers,(e,t)=>this._handleSublayersChange(e,t),ne))}destroy(){this.source?.destroy()}normalizeCtorArgs(e,t){return typeof e==`string`?{url:e,...t}:e}load(e){let t=e==null?null:e.signal,n=this.loadFromPortal({supportedTypes:this.supportedPortalItemTypes},e).catch(ee).then(async()=>{if(!this.url)throw new r(`subtype-grouplayer:missing-url-or-source`,`SubtypeGroupLayer must be created with either a url or a portal item`);if(this.layerId==null)throw new r(`subtype-grouplayer:missing-layerid`,`layerId is required for a SubtypeGroupLayer created with url`);this._initLayerProperties(await this.createGraphicsSource(t))}).then(()=>T(this,`load`,e));return this.addResolvingPromise(n),Promise.resolve(this)}get createQueryVersion(){return this.commitProperty(`definitionExpression`),this.commitProperty(`timeExtent`),this.commitProperty(`timeOffset`),this.commitProperty(`geometryType`),this.commitProperty(`gdbVersion`),this.commitProperty(`historicMoment`),this.commitProperty(`returnZ`),this.commitProperty(`capabilities`),this.commitProperty(`returnM`),(this._get(`createQueryVersion`)??0)+1}get editingEnabled(){return this.loaded&&this.capabilities!=null&&this.capabilities.operations.supportsEditing&&this.userHasEditingPrivileges}get effectiveEditingEnabled(){return E(this)}get operationalLayerType(){return this.isTable?`SubtypeGroupTable`:`SubtypeGroupLayer`}set source(e){this._get(`source`)!==e&&this._set(`source`,e)}readTitleFromService(e,{name:t}){return this.url?C(this.url,t):t}async addAttachment(e,t,n){let r=await D(this,e,t,Y,n);return this.lastEditsEventDate=new Date,r}async updateAttachment(e,t,n,r){let i=await O(this,e,t,n,Y,r);return this.lastEditsEventDate=new Date,i}async applyEdits(e,t){return k(this,e,t)}async createGraphicsSource(e){let{default:t}=await c(import(`./graphics/sources/FeatureLayerSource.js`),e);return new t({layer:this,supportedSourceTypes:this.supportedSourceTypes}).load({signal:e})}createQuery(){let e=A(this),t=this.sublayers.map(e=>e.subtypeCode);return e.where=re(`${this.subtypeField} IN (${t.join(`,`)})`,this.definitionExpression),e}async deleteAttachments(e,t,n){let r=await oe(this,e,t,Y,n);return this.lastEditsEventDate=new Date,r}async fetchRecomputedExtents(e){return j(this,e,Y)}findSublayerForFeature(e){let t=this.fieldsIndex.get(this.subtypeField),n=e.attributes[t.name];return this.findSublayerForSubtypeCode(n)}findSublayerForSubtypeCode(e){return this._sublayerLookup.get(e)}getFieldDomain(e,t){if(!t?.excludeImpliedDomains){let t=M(this,e);if(t)return t}let n=N(this,t?.feature);if(n){let t=n.domains?.[e];return t?.type===`inherited`?this._getLayerDomain(e):t}return this._getLayerDomain(e)}loadAll(){return i(this,e=>{e(this.sublayers)})}async queryAttachments(e,t){return P(this,e,t,Y)}async queryFeatures(e,t){let n=await this.load(),r=q.from(e)??n.createQuery(),i=r.outFields??[];i.includes(this.subtypeField)||(i.push(this.subtypeField),r.outFields=i);let a=await n.source.queryFeatures(r,t);if(a?.features)for(let e of a.features)e.origin=this.findSublayerForFeature(e)?.graphicOrigin,e.layer=e.sourceLayer=this.findSublayerForFeature(e);return a}async queryObjectIds(e,t){return(await F(this,e,t,Y)).filter(se)}async queryFeatureCount(e,t){return I(this,e,t,Y)}async queryExtent(e,t){return L(this,e,t,Y)}async queryRelatedFeatures(e,t){return R(this,e,t,Y)}async queryRelatedFeaturesCount(e,t){return z(this,e,t,Y)}async save(e){return this._debouncedSaveOperations(0,e)}async saveAs(e,t){return this._debouncedSaveOperations(1,t,e)}write(e,t){let{origin:n,layerContainerType:i,messages:a}=t;if(this.isTable){if(n===`web-scene`||n===`web-map`&&i!==`tables`)return J(t,this,`a table source cannot be written to web scenes and web maps`),null}else if(this.loaded&&n===`web-map`&&i===`tables`)return J(t,this,`a non-table source cannot be written to tables in web maps`),null;return this.sublayers?.length?super.write(e,t):(a?.push(new r(`web-document-write:invalid-property`,`Layer (${this.title}, ${this.id}) of type '${this.declaredClass}' has invalid value for 'sublayers' property. 'sublayers' collection should contain at least one sublayer`,{layer:this})),null)}serviceSupportsSpatialReference(e){return this.loaded?K(this,e):!1}async getFeatureTitle(e,t){let n=this.findSublayerForFeature(e);return n?await n.getFeatureTitle(e,t):this._getFeatureTitleForUnknownSublayer(e)}async getFeatureTitles(e,t){let n=new Map,r=new Map,i=[],o=[r];if(e.forEach(e=>{let o=this.findSublayerForFeature(e);if(o)a(n,o,()=>[]).push(e);else{let n=e.getObjectId()??e.attributes[this.objectIdField];t?.fetchMissingFields?i.push(e):r.set(n,this._getFeatureTitleForUnknownSublayer(e))}}),i.length>0){let e=new Set(this.featureTitleFields);e.add(this.objectIdField),e.add(this.subtypeField);let t=await this.queryFeatures({outFields:[...e],returnGeometry:!1,objectIds:i.map(e=>e.getObjectId()??e.attributes[this.objectIdField])}),o=new Set;for(let e of t.features??[]){let t=e.getObjectId()??e.attributes[this.objectIdField];o.add(t);let i=this.findSublayerForFeature(e);i?a(n,i,()=>[]).push(e):r.set(t,this._getFeatureTitleForUnknownSublayer(e))}for(let e of i){let t=e.getObjectId()??e.attributes[this.objectIdField];o.has(t)||r.set(t,this._getFeatureTitleForUnknownSublayer(e))}}(await Promise.all(Array.from(n).map(([e,n])=>e.getFeatureTitles(n,t)))).forEach(e=>o.push(e));let s=new Map(o.flatMap(e=>[...e]));return r.forEach((e,t)=>{s.set(t,e)}),s}get featureTitleFields(){let e=new Set;for(let t of this.sublayers){let n=t.featureTitleFields;for(let t of n)e.add(t)}return[...e]}_getLayerDomain(e){let t=this.fieldsIndex.get(e);return t?t.domain:null}_initLayerProperties(e){this._set(`source`,e);let{sourceJSON:t}=e;if(t&&(this.sourceJSON=t,this.read(t,{origin:`service`,url:this.parsedUrl})),!this.subtypes?.length)throw new r(`subtype-grouplayer:missing-subtypes`,`SubtypeGroupLayer must be created using a layer with subtypes`);this._verifyFields(),H(this.timeInfo,this.fieldsIndex)}async reloadFromService(e){let t=this.source;await t.reload({signal:e}),this._initLayerProperties(t)}async hasDataChanged(){return B(this)}_verifyFields(){let e=this.parsedUrl?.path??`undefined`;this.objectIdField||console.log(`SubtypeGroupLayer: 'objectIdField' property is not defined (url: `+e+`)`),!this.isTable&&e.search(/\/FeatureServer\//i)===-1&&!this.fields?.some(e=>e.type===`geometry`)&&console.log(`SubtypeGroupLayer: unable to find field of type 'geometry' in the layer 'fields' list. If you are using a map service layer, features will not have geometry (url: `+e+`)`)}_handleSublayersChange(e,t){t&&(t.forEach(e=>{e.parent=null}),this.removeHandles(`sublayers-owner`),this._sublayerLookup.clear()),e&&(e.forEach(e=>{e.parent=this,this._sublayerLookup.set(e.subtypeCode,e)}),this.addHandles([e.on(`after-add`,({item:e})=>{e.parent=this,this._sublayerLookup.set(e.subtypeCode,e)}),e.on(`after-remove`,({item:e})=>{e.parent=null,this._sublayerLookup.delete(e.subtypeCode)})],`sublayers-owner`))}_getFeatureTitleForUnknownSublayer(e){let{displayField:t,fieldsIndex:n,objectIdField:r}=this;if(t&&n.has(t))return e.attributes[n.get(t).name]??``;let i=e.getObjectId();return i==null?r&&n.has(r)?e.attributes[n.get(r).name]??``:``:i.toString()}};e([l({readOnly:!0})],$.prototype,`createQueryVersion`,null),e([l({readOnly:!0})],$.prototype,`editingEnabled`,null),e([l({readOnly:!0})],$.prototype,`effectiveEditingEnabled`,null),e([l({...Z.fields,readOnly:!0,json:{origins:{service:{read:!0}},read:!1}})],$.prototype,`fields`,void 0),e([l(Z.fieldsIndex)],$.prototype,`fieldsIndex`,void 0),e([l(w)],$.prototype,`id`,void 0),e([l({type:[`show`,`hide`,`hide-children`],json:{origins:{"portal-item":{read:!1,write:!1}}}})],$.prototype,`listMode`,void 0),e([l({type:[`SubtypeGroupLayer`,`SubtypeGroupTable`],json:{...Q(),origins:{"web-document":Q(),"portal-item":Q()}}})],$.prototype,`operationalLayerType`,null),e([l(Z.outFields)],$.prototype,`outFields`,void 0),e([l({clonable:!1})],$.prototype,`source`,null),e([l({type:n.ofType(G),json:{origins:{service:{read:{source:`subtypes`,reader(e,t,r){let i=null;if(this.useUniqueColorsForSublayers){let n=U(t,r);i=n?W(e.length,n):null}let a=e.map(({code:e},n)=>{let a=new G({subtypeCode:e});a.read(t,r);let o=i?.[n];return o&&a.read({drawingInfo:{renderer:o.toJSON()}},r),a});return new(n.ofType(G))(a)}}}},read:{source:[`layers`,`tables`],reader(e,t,r){let i;return t.layerType===`SubtypeGroupLayer`&&t.layers?.length?i=X(t.layers,r):t.layerType===`SubtypeGroupTable`&&t.tables?.length&&(i=X(t.tables,r)),new(n.ofType(G))(i)}},write:{ignoreOrigin:!0,writer(e,t,n,r){let i=[];for(let t of e){let e=t.write({},r);i.push(e)}this.isTable?t.tables=i:t.layers=i}}}})],$.prototype,`sublayers`,void 0),e([l()],$.prototype,`useUniqueColorsForSublayers`,void 0),e([l({json:{origins:{"portal-item":{write:{enabled:!0,ignoreOrigin:!0,writerEnsuresNonNull:!0}}}}})],$.prototype,`title`,void 0),e([ce(`service`,`title`,[`name`])],$.prototype,`readTitleFromService`,null),e([l({json:{read:!1}})],$.prototype,`type`,void 0),e([l({clonable:!1,readOnly:!0})],$.prototype,`featureTitleFields`,null),$=e([ie(`esri.layers.SubtypeGroupLayer`)],$);const le=$;export{le as default};
|
|
2
|
+
import{__decorate as e}from"tslib";import{ClonableMixin as t}from"../core/Clonable.js";import n from"../core/Collection.js";import r from"../core/Error.js";import{loadAll as i}from"../core/loadAll.js";import{getOrCreateMapValue as a}from"../core/MapUtils.js";import{MultiOriginJSONSupportMixin as o}from"../core/MultiOriginJSONSupport.js";import{debounce as s,throwIfAbortError as ee,whenOrAbort as c}from"../core/promiseUtils.js";import{watch as te,sync as ne}from"../core/reactiveUtils.js";import{sqlAnd as re}from"../core/sql.js";import{property as l,subclass as ie}from"../core/accessorSupport/decorators.js";import ae from"./Layer.js";import{APIKeyMixin as u}from"./mixins/APIKeyMixin.js";import{ArcGISService as d}from"./mixins/ArcGISService.js";import{BlendLayer as f}from"./mixins/BlendLayer.js";import{CustomParametersMixin as p}from"./mixins/CustomParametersMixin.js";import{DisplayFilteredLayer as m}from"./mixins/DisplayFilteredLayer.js";import{EditBusLayer as h}from"./mixins/EditBusLayer.js";import{FeatureLayerBase as g}from"./mixins/FeatureLayerBase.js";import{OperationalLayer as _}from"./mixins/OperationalLayer.js";import{PortalLayer as v}from"./mixins/PortalLayer.js";import{RefreshableLayer as y}from"./mixins/RefreshableLayer.js";import{ReloadableLayer as b}from"./mixins/ReloadableLayer.js";import{ScaleRangeLayer as x}from"./mixins/ScaleRangeLayer.js";import{TemporalLayer as S}from"./mixins/TemporalLayer.js";import{titleFromUrlAndName as C}from"./support/arcgisLayerUrl.js";import{id as w}from"./support/commonProperties.js";import{ensureLayerCredential as T,computeEffectiveEditingEnabled as E,addAttachment as D,updateAttachment as O,applyEdits as k,createQuery as A,deleteAttachments as j,fetchRecomputedExtents as M,computeDomainFromSubtypes as N,getFeatureSubtype as P,queryAttachments as oe,queryObjectIds as F,queryFeatureCount as I,queryExtent as L,queryRelatedFeatures as R,queryRelatedFeaturesCount as z,hasDataChanged as B}from"./support/featureLayerUtils.js";import{defineFieldProperties as V}from"./support/fieldProperties.js";import{fixTimeInfoFields as H}from"./support/fieldUtils.js";import{getSymbolWithColorSupport as U,createSimpleRenderersWithUniqueColors as W}from"./support/subtypeGroupLayerUtils.js";import G from"./support/SubtypeSublayer.js";import{serviceSupportsSpatialReference as K}from"./support/versionUtils.js";import q from"../rest/layerSources/DynamicWorkspaceLayer.js";import se from"../rest/support/Query.js";import{isNumber as ce}from"../support/guards.js";import{addLayerUnsupportedError as J}from"../webdoc/support/unsupportedErrors.js";import{reader as le}from"../core/accessorSupport/decorators/reader.js";const Y=`SubtypeGroupLayer`;function X(e,t){let n=[];for(let r of e){let e=new G;e.read(r,t),n.push(e)}return n}const Z=V();function Q(){return{name:`layerType`,read:{enabled:!0},write:{enabled:!0,ignoreOrigin:!0,isRequired:!0}}}let $=class extends b(g(m(h(f(S(x(y(d(_(v(o(p(u(t(ae))))))))))))))){constructor(...e){super(...e),this._sublayerLookup=new Map,this.dynamicDataSource=null,this.fields=null,this.fieldsIndex=null,this.outFields=null,this.sublayers=new(n.ofType(G)),this.useUniqueColorsForSublayers=!0,this.supportedPortalItemTypes=[`Feature Service`],this.supportedSourceTypes=new Set([`Feature Layer`,`Table`]),this.title=`Layer`,this.type=`subtype-group`,this._debouncedSaveOperations=s(async(e,t,n)=>{let{save:r,saveAs:i}=await import(`./save/featureLayerUtils.js`);switch(e){case 0:return r(this,t);case 1:return i(this,n,t)}}),this.addHandles(te(()=>this.sublayers,(e,t)=>this._handleSublayersChange(e,t),ne))}destroy(){this.source?.destroy()}normalizeCtorArgs(e,t){return typeof e==`string`?{url:e,...t}:e}load(e){let t=e==null?null:e.signal,n=this.loadFromPortal({supportedTypes:this.supportedPortalItemTypes},e).catch(ee).then(async()=>{if(!this.url)throw new r(`subtype-grouplayer:missing-url-or-source`,`SubtypeGroupLayer must be created with either a url or a portal item`);if(this.layerId==null&&this.dynamicDataSource==null)throw new r(`subtype-grouplayer:missing-layerid`,`layerId or dynamicDataSource are required for a SubtypeGroupLayer created with url`);this._initLayerProperties(await this.createGraphicsSource(t))}).then(()=>T(this,`load`,e));return this.addResolvingPromise(n),Promise.resolve(this)}get createQueryVersion(){return this.commitProperty(`definitionExpression`),this.commitProperty(`dynamicDataSource`),this.commitProperty(`timeExtent`),this.commitProperty(`timeOffset`),this.commitProperty(`geometryType`),this.commitProperty(`gdbVersion`),this.commitProperty(`historicMoment`),this.commitProperty(`returnZ`),this.commitProperty(`capabilities`),this.commitProperty(`returnM`),(this._get(`createQueryVersion`)??0)+1}get editingEnabled(){return this.loaded&&this.capabilities!=null&&this.capabilities.operations.supportsEditing&&this.userHasEditingPrivileges}get effectiveEditingEnabled(){return E(this)}get operationalLayerType(){return this.isTable?`SubtypeGroupTable`:`SubtypeGroupLayer`}set source(e){this._get(`source`)!==e&&this._set(`source`,e)}readTitleFromService(e,{name:t}){return this.url?C(this.url,t):t}async addAttachment(e,t,n){let r=await D(this,e,t,Y,n);return this.lastEditsEventDate=new Date,r}async updateAttachment(e,t,n,r){let i=await O(this,e,t,n,Y,r);return this.lastEditsEventDate=new Date,i}async applyEdits(e,t){return k(this,e,t)}async createGraphicsSource(e){let{default:t}=await c(import(`./graphics/sources/FeatureLayerSource.js`),e);return new t({layer:this,supportedSourceTypes:this.supportedSourceTypes}).load({signal:e})}createQuery(){let e=A(this);e.dynamicDataSource=this.dynamicDataSource;let t=this.sublayers.map(e=>e.subtypeCode);return e.where=re(`${this.subtypeField} IN (${t.join(`,`)})`,this.definitionExpression),e}async deleteAttachments(e,t,n){let r=await j(this,e,t,Y,n);return this.lastEditsEventDate=new Date,r}async fetchRecomputedExtents(e){return M(this,e,Y)}findSublayerForFeature(e){let t=this.fieldsIndex.get(this.subtypeField),n=e.attributes[t.name];return this.findSublayerForSubtypeCode(n)}findSublayerForSubtypeCode(e){return this._sublayerLookup.get(e)}getFieldDomain(e,t){if(!t?.excludeImpliedDomains){let t=N(this,e);if(t)return t}let n=P(this,t?.feature);if(n){let t=n.domains?.[e];return t?.type===`inherited`?this._getLayerDomain(e):t}return this._getLayerDomain(e)}loadAll(){return i(this,e=>{e(this.sublayers)})}async queryAttachments(e,t){return oe(this,e,t,Y)}async queryFeatures(e,t){let n=await this.load(),r=se.from(e)??n.createQuery(),i=r.outFields??[];i.includes(this.subtypeField)||(i.push(this.subtypeField),r.outFields=i);let a=await n.source.queryFeatures(r,t);if(a?.features)for(let e of a.features)e.origin=this.findSublayerForFeature(e)?.graphicOrigin,e.layer=e.sourceLayer=this.findSublayerForFeature(e);return a}async queryObjectIds(e,t){return(await F(this,e,t,Y)).filter(ce)}async queryFeatureCount(e,t){return I(this,e,t,Y)}async queryExtent(e,t){return L(this,e,t,Y)}async queryRelatedFeatures(e,t){return R(this,e,t,Y)}async queryRelatedFeaturesCount(e,t){return z(this,e,t,Y)}async save(e){return this._debouncedSaveOperations(0,e)}async saveAs(e,t){return this._debouncedSaveOperations(1,t,e)}write(e,t){let{origin:n,layerContainerType:i,messages:a}=t;if(this.dynamicDataSource)return J(t,this,`a dynamic data source cannot be written to web scenes, web maps and feature service items`),null;if(this.isTable){if(n===`web-scene`||n===`web-map`&&i!==`tables`)return J(t,this,`a table source cannot be written to web scenes and web maps`),null}else if(this.loaded&&n===`web-map`&&i===`tables`)return J(t,this,`a non-table source cannot be written to tables in web maps`),null;return this.sublayers?.length?super.write(e,t):(a?.push(new r(`web-document-write:invalid-property`,`Layer (${this.title}, ${this.id}) of type '${this.declaredClass}' has invalid value for 'sublayers' property. 'sublayers' collection should contain at least one sublayer`,{layer:this})),null)}serviceSupportsSpatialReference(e){return this.loaded?K(this,e):!1}async getFeatureTitle(e,t){let n=this.findSublayerForFeature(e);return n?await n.getFeatureTitle(e,t):this._getFeatureTitleForUnknownSublayer(e)}async getFeatureTitles(e,t){let n=new Map,r=new Map,i=[],o=[r];if(e.forEach(e=>{let o=this.findSublayerForFeature(e);if(o)a(n,o,()=>[]).push(e);else{let n=e.getObjectId()??e.attributes[this.objectIdField];t?.fetchMissingFields?i.push(e):r.set(n,this._getFeatureTitleForUnknownSublayer(e))}}),i.length>0){let e=new Set(this.featureTitleFields);e.add(this.objectIdField),e.add(this.subtypeField);let t=await this.queryFeatures({outFields:[...e],returnGeometry:!1,objectIds:i.map(e=>e.getObjectId()??e.attributes[this.objectIdField])}),o=new Set;for(let e of t.features??[]){let t=e.getObjectId()??e.attributes[this.objectIdField];o.add(t);let i=this.findSublayerForFeature(e);i?a(n,i,()=>[]).push(e):r.set(t,this._getFeatureTitleForUnknownSublayer(e))}for(let e of i){let t=e.getObjectId()??e.attributes[this.objectIdField];o.has(t)||r.set(t,this._getFeatureTitleForUnknownSublayer(e))}}(await Promise.all(Array.from(n).map(([e,n])=>e.getFeatureTitles(n,t)))).forEach(e=>o.push(e));let s=new Map(o.flatMap(e=>[...e]));return r.forEach((e,t)=>{s.set(t,e)}),s}get featureTitleFields(){let e=new Set;for(let t of this.sublayers){let n=t.featureTitleFields;for(let t of n)e.add(t)}return[...e]}_getLayerDomain(e){let t=this.fieldsIndex.get(e);return t?t.domain:null}_initLayerProperties(e){this._set(`source`,e);let{sourceJSON:t}=e;if(t&&(this.sourceJSON=t,this.read(t,{origin:`service`,url:this.parsedUrl})),!this.subtypes?.length)throw new r(`subtype-grouplayer:missing-subtypes`,`SubtypeGroupLayer must be created using a layer with subtypes`);this._verifyFields(),H(this.timeInfo,this.fieldsIndex)}async reloadFromService(e){let t=this.source;await t.reload({signal:e}),this._initLayerProperties(t)}async hasDataChanged(){return B(this)}_verifyFields(){let e=this.parsedUrl?.path??`undefined`;this.objectIdField||console.log(`SubtypeGroupLayer: 'objectIdField' property is not defined (url: `+e+`)`),!this.isTable&&e.search(/\/FeatureServer\//i)===-1&&!this.fields?.some(e=>e.type===`geometry`)&&console.log(`SubtypeGroupLayer: unable to find field of type 'geometry' in the layer 'fields' list. If you are using a map service layer, features will not have geometry (url: `+e+`)`)}_handleSublayersChange(e,t){t&&(t.forEach(e=>{e.parent=null}),this.removeHandles(`sublayers-owner`),this._sublayerLookup.clear()),e&&(e.forEach(e=>{e.parent=this,this._sublayerLookup.set(e.subtypeCode,e)}),this.addHandles([e.on(`after-add`,({item:e})=>{e.parent=this,this._sublayerLookup.set(e.subtypeCode,e)}),e.on(`after-remove`,({item:e})=>{e.parent=null,this._sublayerLookup.delete(e.subtypeCode)})],`sublayers-owner`))}_getFeatureTitleForUnknownSublayer(e){let{displayField:t,fieldsIndex:n,objectIdField:r}=this;if(t&&n.has(t))return e.attributes[n.get(t).name]??``;let i=e.getObjectId();return i==null?r&&n.has(r)?e.attributes[n.get(r).name]??``:``:i.toString()}};e([l({readOnly:!0})],$.prototype,`createQueryVersion`,null),e([l({type:q})],$.prototype,`dynamicDataSource`,void 0),e([l({readOnly:!0})],$.prototype,`editingEnabled`,null),e([l({readOnly:!0})],$.prototype,`effectiveEditingEnabled`,null),e([l({...Z.fields,readOnly:!0,json:{origins:{service:{read:!0}},read:!1}})],$.prototype,`fields`,void 0),e([l(Z.fieldsIndex)],$.prototype,`fieldsIndex`,void 0),e([l(w)],$.prototype,`id`,void 0),e([l({type:[`show`,`hide`,`hide-children`],json:{origins:{"portal-item":{read:!1,write:!1}}}})],$.prototype,`listMode`,void 0),e([l({type:[`SubtypeGroupLayer`,`SubtypeGroupTable`],json:{...Q(),origins:{"web-document":Q(),"portal-item":Q()}}})],$.prototype,`operationalLayerType`,null),e([l(Z.outFields)],$.prototype,`outFields`,void 0),e([l({clonable:!1})],$.prototype,`source`,null),e([l({type:n.ofType(G),json:{origins:{service:{read:{source:`subtypes`,reader(e,t,r){let i=null;if(this.useUniqueColorsForSublayers){let n=U(t,r);i=n?W(e.length,n):null}let a=e.map(({code:e},n)=>{let a=new G({subtypeCode:e});a.read(t,r);let o=i?.[n];return o&&a.read({drawingInfo:{renderer:o.toJSON()}},r),a});return new(n.ofType(G))(a)}}}},read:{source:[`layers`,`tables`],reader(e,t,r){let i;return t.layerType===`SubtypeGroupLayer`&&t.layers?.length?i=X(t.layers,r):t.layerType===`SubtypeGroupTable`&&t.tables?.length&&(i=X(t.tables,r)),new(n.ofType(G))(i)}},write:{ignoreOrigin:!0,writer(e,t,n,r){let i=[];for(let t of e){let e=t.write({},r);i.push(e)}this.isTable?t.tables=i:t.layers=i}}}})],$.prototype,`sublayers`,void 0),e([l()],$.prototype,`useUniqueColorsForSublayers`,void 0),e([l({json:{origins:{"portal-item":{write:{enabled:!0,ignoreOrigin:!0,writerEnsuresNonNull:!0}}}}})],$.prototype,`title`,void 0),e([le(`service`,`title`,[`name`])],$.prototype,`readTitleFromService`,null),e([l({json:{read:!1}})],$.prototype,`type`,void 0),e([l({clonable:!1,readOnly:!0})],$.prototype,`featureTitleFields`,null),$=e([ie(`esri.layers.SubtypeGroupLayer`)],$);const ue=$;export{ue as default};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
import{__decorate as e}from"tslib";import t from"../../../config.js";import n from"../../../request.js";import{isSome as r,remove as i}from"../../../core/arrayUtils.js";import a from"../../../core/Error.js";import has from"../../../core/has.js";import{JSONMap as o}from"../../../core/jsonMap.js";import{Loadable as s}from"../../../core/Loadable.js";import c from"../../../core/Logger.js";import{setDeepValue as l}from"../../../core/object.js";import{debounce as u,after as d,throwIfAbortError as f}from"../../../core/promiseUtils.js";import{watch as p}from"../../../core/reactiveUtils.js";import{join as m}from"../../../core/urlUtils.js";import{generateBracedUUID as h}from"../../../core/uuid.js";import{property as g,subclass as _}from"../../../core/accessorSupport/decorators.js";import v from"../../../geometry/Extent.js";import y from"../../../geometry/SpatialReference.js";import b from"../../../geometry/support/MeshGeoreferencedVertexSpace.js";import{isRelativeVertexSpace as x}from"../../../geometry/support/meshVertexSpaceUtils.js";import{isOriginalExternal as S}from"../../../geometry/support/meshUtils/External.js";import{createFeatureEditResult as C,getFeatureJSON as w,getFeatureIds as T,getAttachmentEditsJSON as E,isProtectedOrPrivateVersionError as D,unpackEditResultData as O,createEditedFeatures as k}from"../applyEditsUtils.js";import{createDrawingInfo as A}from"./support/clientSideDefaults.js";import j from"./support/QueryTask.js";import{isHostedAgolService as M}from"../../support/arcgisLayerUrl.js";import{ensureLayerCredential as N}from"../../support/featureLayerUtils.js";import{getAssetMapTable as P}from"../../support/infoFor3D.js";import{executeQueryJSON as F}from"../../../rest/query/executeQueryJSON.js";import{unapplyEditsZUnitScaling as I}from"../../../rest/query/operations/editsZScale.js";import L from"../../../rest/support/Query.js";import R from"../../../time/TimeExtent.js";import{isSafeToEditVersion as z,isVersionInEditSession as B,isHistoricVersion as V,currentSessionId as H}from"../../../versionManagement/support/versionManagementUtils.js";const U=new o({originalAndCurrentFeatures:`original-and-current-features`,none:`none`}),W=new o({Started:`published`,Publishing:`publishing`,Stopped:`unavailable`});let G=class extends s{constructor(e){super(e),this.type=`feature-layer`,this.supportedSourceTypes=new Set([`Feature Layer`,`Oriented Imagery Layer`,`Table`,`Catalog Layer`,`Annotation Layer`,`Dimension Layer`]),this.refresh=u(async()=>{await this.load();let e=this.sourceJSON.editingInfo?.lastEditDate;if(e==null)return{dataChanged:!0,updates:{}};try{await this._fetchService(null)}catch{return{dataChanged:!0,updates:{}}}let t=e!==this.sourceJSON.editingInfo?.lastEditDate;return{dataChanged:t,updates:t?{editingInfo:this.sourceJSON.editingInfo,extent:this.sourceJSON.extent}:null}}),this._ongoingAssetUploads=new Map}load(e){let t=this.layer.sourceJSON,n=this._fetchService(t,{...e}).then(()=>this.layer.setUserPrivileges(this.sourceJSON.serviceItemId,e)).then(()=>this._ensureLatestMetadata(e));return this.addResolvingPromise(n),Promise.resolve(this)}async reload(e){let t=this.layer.userHasUpdateItemPrivileges&&this.sourceJSON.cacheMaxAge>0;await this._fetchService(null,{...e,cacheBust:t})}initialize(){this.addHandles([p(()=>{let e=this.layer;return e&&`lastEditsEventDate`in e?e.lastEditsEventDate:null},e=>this._handleLastEditsEventChange(e))])}destroy(){this._removeEditInterceptor()}get queryTask(){let{capabilities:e,parsedUrl:t,gdbVersion:n,spatialReference:r,fieldsIndex:i,uniqueIdFields:a}=this.layer,o=`infoFor3D`in this.layer?this.layer.infoFor3D:null,s=`dynamicDataSource`in this.layer?this.layer.dynamicDataSource:null,c=has(`featurelayer-pbf`)&&e?.query.supportsFormatPBF&&o==null,l=c&&e?.query.supportsFormatPBFWithCurves,u=e?.operations?.supportsQueryAttachments??!1,d=e?.query?.relativeTimeBinWindow??0,f=t.path;return new j({dynamicDataSource:s,fieldsIndex:i,gdbVersion:n,infoFor3D:o,pbfSupported:c,pbfSupportedWithCurves:l,queryAttachmentsSupported:u,relativeTimeBinWindow:d,sourceSpatialReference:r,uniqueIdFields:a,url:f})}async addAttachment(e,t,r){await this.load();let{layer:i}=this;await N(i,`editing`);let a=e.attributes[i.objectIdField],o=i.parsedUrl.path+`/`+a+`/addAttachment`,s=this._getLayerRequestOptions({query:r}),c=this._getFormDataForAttachment(t,s.query);try{let e=await n(o,{body:c});return C(e.data.addAttachmentResult)}catch(e){throw this._createAttachmentErrorResult(a,e)}}async updateAttachment(e,t,r,i){await this.load();let{layer:a}=this;await N(a,`editing`);let o=e.attributes[a.objectIdField],s=a.parsedUrl.path+`/`+o+`/updateAttachment`,c=this._getLayerRequestOptions({query:{attachmentId:t,...i}}),l=this._getFormDataForAttachment(r,c.query);try{let e=await n(s,{body:l});return C(e.data.updateAttachmentResult)}catch(e){throw this._createAttachmentErrorResult(o,e)}}async applyEdits(e,t){await this.load();let{layer:i}=this;await N(i,`editing`);let o=`infoFor3D`in i?i.infoFor3D:null,s=o!=null,c=s||(t?.globalIdUsed??!1),l=s?await this._uploadMeshesAndGetAssetMapEditsJSON(e):null,u=e.addFeatures?.map(e=>w(this.layer,e,o))??[],d=(await Promise.all(u)).filter(r),f=e.updateFeatures?.map(e=>w(this.layer,e,o))??[],p=(await Promise.all(f)).filter(r),m=T(this.layer,e.deleteFeatures,c);I(d,p,i.spatialReference);let h=await E(this.layer,e),g=i.capabilities.editing.supportsAsyncApplyEdits&&s,_=t?.gdbVersion||i.gdbVersion,v={gdbVersion:_,rollbackOnFailure:t?.rollbackOnFailureEnabled,useGlobalIds:c,returnEditMoment:t?.returnEditMoment,trueCurveClient:t?.editsRespectTrueCurves,usePreviousEditMoment:t?.usePreviousEditMoment,async:g};await z(this.layer.url,_,!0);let y=B(this.layer.url,_||null);if(await V(i.url,_,i.historicMoment))throw new a(`feature-layer-source:historic-version`,`Editing a historic version is not allowed`);t?.returnServiceEditsOption?(v.edits=JSON.stringify([{id:i.layerId,adds:d.length?d:null,updates:p.length?p:null,deletes:m.length?m:null,attachments:h,assetMaps:l}]),v.returnServiceEditsOption=U.toJSON(t?.returnServiceEditsOption),v.returnServiceEditsInSourceSR=t?.returnServiceEditsInSourceSR):(v.adds=d.length?JSON.stringify(d):null,v.updates=p.length?JSON.stringify(p):null,v.deletes=m.length?c?JSON.stringify(m):m.join(`,`):null,v.attachments=h&&JSON.stringify(h),v.assetMaps=l==null?void 0:JSON.stringify(l));let b=this._getLayerRequestOptions({method:`post`,query:v});y&&(b.authMode=`immediate`,b.query.returnEditMoment=!0,b.query.sessionId=H);let x=t?.returnServiceEditsOption?i.url:i.parsedUrl.path,S;try{S=g?await this._asyncApplyEdits(x+`/applyEdits`,b):await n(x+`/applyEdits`,b)}catch(e){if(D(e))b.authMode=`immediate`,S=g?await this._asyncApplyEdits(x+`/applyEdits`,b):await n(x+`/applyEdits`,b);else throw e}return this._createEditsResult(S)}async deleteAttachments(e,t,r){await this.load();let{layer:i}=this;await N(i,`editing`);let a=e.attributes[i.objectIdField],o=i.parsedUrl.path+`/`+a+`/deleteAttachments`;try{return(await n(o,this._getLayerRequestOptions({query:{attachmentIds:t.join(`,`),...r},method:`post`}))).data.deleteAttachmentResults.map(C)}catch(e){throw this._createAttachmentErrorResult(a,e)}}fetchRecomputedExtents(e={}){let t=e.signal;return this.load({signal:t}).then(async()=>{let t=this._getLayerRequestOptions({...e,query:{returnUpdates:!0}}),{layerId:r,url:i}=this.layer,{data:a}=await n(`${i}/${r}`,t),{id:o,extent:s,fullExtent:c,timeExtent:l}=a,u=s||c;return{id:o,fullExtent:u&&v.fromJSON(u),timeExtent:l&&R.fromJSON({start:l[0],end:l[1]})}})}async queryAttachments(e,t={}){await this.load();let n=this._getLayerRequestOptions(t);return this.queryTask.executeAttachmentQuery(e,n)}async queryFeatures(e,t){await this.load();let n=await this.queryTask.execute(e,{...t,query:this._createRequestQueryOptions(t)});if(e.outStatistics?.length&&n.features.length){let t=new Map;if(n.features.forEach(n=>{let r=n.attributes;e.outStatistics?.forEach(({outStatisticFieldName:e})=>{if(e){let n=e.toLowerCase();n&&n in r&&e!==n&&(r[e]=r[n],delete r[n],t.set(n,e))}})}),n.fields!=null)for(let e of n.fields){let n=t.get(e.name.toLowerCase());n!=null&&(e.name=n)}}return n}async queryFeaturesJSON(e,t){return await this.load(),this.queryTask.executeJSON(e,{...t,query:this._createRequestQueryOptions(t)})}async queryObjectIds(e,t){return await this.load(),this.queryTask.executeForIds(e,{...t,query:this._createRequestQueryOptions(t)})}async queryFeatureCount(e,t){return await this.load(),this.queryTask.executeForCount(e,{...t,query:this._createRequestQueryOptions(t)})}async queryExtent(e,t){return await this.load(),this.queryTask.executeForExtent(e,{...t,query:this._createRequestQueryOptions(t)})}async queryRelatedFeatures(e,t){return await this.load(),this.queryTask.executeRelationshipQuery(e,{...t,query:this._createRequestQueryOptions(t)})}async queryRelatedFeaturesCount(e,t){return await this.load(),this.queryTask.executeRelationshipQueryForCount(e,{...t,query:this._createRequestQueryOptions(t)})}async queryPivot(e,t){return await this.load(),this.queryTask.executePivotQuery(e,{...t,query:this._createRequestQueryOptions(t)})}async queryTopFeatures(e,t){return await this.load(),this.queryTask.executeTopFeaturesQuery(e,{...t,query:this._createRequestQueryOptions(t)})}async queryAttributeBins(e,t){return await this.load(),this.queryTask.executeAttributeBinsQuery(e,{...t,query:this._createRequestQueryOptions(t)})}async queryTopObjectIds(e,t){return await this.load(),this.queryTask.executeForTopIds(e,{...t,query:this._createRequestQueryOptions(t)})}async queryTopExtents(e,t){return await this.load(),this.queryTask.executeForTopExtents(e,{...t,query:this._createRequestQueryOptions(t)})}async queryTopCount(e,t){return await this.load(),this.queryTask.executeForTopCount(e,{...t,query:this._createRequestQueryOptions(t)})}async fetchPublishingStatus(){if(!M(this.layer.url))return`unavailable`;let e=m(this.layer.url,`status`),t=await n(e,{query:{f:`json`}});return W.fromJSON(t.data.status)}async uploadAssets(e,t){let{uploadAssets:n}=await import(`./support/uploadAssets.js`);return n(e,{layer:this.layer,ongoingUploads:this._ongoingAssetUploads},t)}_handleLastEditsEventChange(e){let t=this.layer;if(e==null||!(`capabilities`in t)||!(`effectiveCapabilities`in t)||t.capabilities?.operations?.supportsEditing||!t.effectiveCapabilities?.operations?.supportsEditing)return;let n=t.url;if(n==null)return;`layerId`in t&&(n=m(n,t.layerId.toString()));let r=this._getOrCreateEditInterceptor(n);r.before=t=>{let n=t.requestOptions.method??`auto`;if(n===`auto`||n===`head`){let n=t.requestOptions.query??{};n._ts=e.getTime(),t.requestOptions.query=n}}}_getOrCreateEditInterceptor(e){return this._editInterceptor??(this._editInterceptor={urls:e},t.request.internalInterceptors.push(this._editInterceptor)),this._editInterceptor}_removeEditInterceptor(){this._editInterceptor!=null&&(i(t.request.internalInterceptors,this._editInterceptor),this._editInterceptor=null)}async _asyncApplyEdits(e,t){let r=(await n(e,t)).data.statusUrl;for(;;){let e=(await n(r,{query:{f:`json`},responseType:`json`})).data;switch(e.status){case`Completed`:return n(e.resultUrl,{query:{f:`json`},responseType:`json`});case`CompletedWithErrors`:throw new a(`async-applyEdits-failed`,`asynchronous applyEdits call failed.`);case`Failed ImportChanges`:case`InProgress`:case`Pending`:case`ExportAttachments`:case`ExportChanges`:case`ExportingData`:case`ExportingSnapshot`:case`ImportAttachments`:case`ProvisioningReplica`:case`UnRegisteringReplica`:break;default:throw new a(`async-applyEdits-failed`,`asynchronous applyEdits call failed (undefined response status)`)}await d(K)}}_createRequestQueryOptions(e){let t={...this.layer.customParameters,token:this.layer.apiKey,...e?.query};return this.layer.datesInUnknownTimezone&&(t.timeReferenceUnknownClient=!0),t}async _fetchService(e,t){if(!e){let r={};has(`featurelayer-advanced-symbols`)&&(r.returnAdvancedSymbols=!0),t?.cacheBust&&(r._ts=Date.now());let{data:i}=await n(this.layer.parsedUrl.path,this._getLayerRequestOptions({query:r,signal:t?.signal}));e=i}this.layer.applyPreferredHost(e),this.sourceJSON=await this._patchServiceJSON(e,t?.signal);let r=e.type;if(!this.supportedSourceTypes.has(r))throw new a(`feature-layer-source:unsupported-type`,`Source type "${r}" is not supported`)}async _patchServiceJSON(e,t){if(e.type!==`Table`&&e.geometryType&&!e?.drawingInfo?.renderer&&!e.defaultSymbol){let t=A(e.geometryType).renderer;l(`drawingInfo.renderer`,t,e)}if(e.geometryType===`esriGeometryMultiPatch`&&e.infoFor3D&&(e.geometryType=`mesh`),e.extent==null)try{let{data:r}=await n(this.layer.url,this._getLayerRequestOptions({signal:t}));r.spatialReference&&(e.extent={xmin:0,ymin:0,xmax:0,ymax:0,spatialReference:r.spatialReference})}catch(e){f(e)}return e}async _ensureLatestMetadata(e){if(this.layer.userHasUpdateItemPrivileges&&this.sourceJSON.cacheMaxAge>0)return this._fetchService(null,{...e,cacheBust:!0})}async _uploadMeshesAndGetAssetMapEditsJSON(e){let{addAssetFeatures:t}=e;if(!t?.length||await this._areAllAssetsAlreadyMapped(t))return null;let n=e.addFeatures.filter(e=>e.geometry);if(t.length!==n.length+e.updateFeatures.length)throw new a(`feature-layer-source:unsupported-mesh-edits`,`Mixing attribute only edits with mesh geometry edits is not currently supported`);let r=[],i=new Map;for(let e of t){let{geometry:t}=e,{vertexSpace:n}=t;if(x(n))r.push(t);else{let n=t.origin,{convertMeshVertexSpace:a}=await import(`../../../geometry/support/meshUtils/convertMeshVertexSpace.js`),o=await a(t,new b({origin:[n.x,n.y,n.z??0]}));i.set(o,t),e.geometry=o,r.push(o)}}await this.uploadAssets(r);for(let[e,t]of i)t.addExternalSources(e.metadata.externalSources.items);return{adds:this._getAssetMapEditsJSON(t),updates:[],deletes:[]}}_getAssetMapEditsJSON(e){let t=[],n=this.layer.globalIdField,r=this.layer.parsedUrl;for(let i of e){let{metadata:e}=i.geometry,a=e.getExternalSourcesOnService(r),o=i.getAttribute(n);if(a.length===0){c.getLogger(this).error(`Skipping feature ${o}. The mesh it is associated with has not been uploaded to the service and cannot be mapped to it.`);continue}let{source:s}=a.find(S)??a[0];for(let e of s.assets){if(e.parts.length!==1){c.getLogger(this).error(`Skipping asset ${e.assetName}. It does not have exactly one part, so we cannot map it to a feature.`);continue}t.push({globalId:h(),parentGlobalId:o,assetName:e.assetName,assetHash:e.parts[0].partHash,flags:[]})}}return t}_createEditsResult(e){let t=e.data,{layerId:n}=this.layer,r=[],i=null;if(Array.isArray(t))for(let e of t)e.editedFeatures!=null&&r.push({id:e.id,editedFeatures:e.editedFeatures}),e.id===n&&(i={addResults:e.addResults??[],updateResults:e.updateResults??[],deleteResults:e.deleteResults??[],attachments:e.attachments,editMoment:e.editMoment});else i=t;let a=O(i);if(r.length>0){a.editedFeatureResults=[];for(let e of r){let{editedFeatures:t}=e,n=t?.spatialReference?new y(t.spatialReference):null;a.editedFeatureResults.push({layerId:e.id,editedFeatures:k(t,n)})}}return a}_createAttachmentErrorResult(e,t){let n=t.details.messages?.[0]||t.message,r=t.details.httpStatus||t.details.messageCode;return{objectId:e,globalId:null,error:new a(`feature-layer-source:attachment-failure`,n,{code:r})}}_getFormDataForAttachment(e,t){let n=e instanceof FormData?e:e&&e.elements?new FormData(e):null;if(n)for(let e in t){let r=t[e];r!=null&&(n.set?n.set(e,r):n.append(e,r))}return n}_getLayerRequestOptions(e={}){let{layer:t,layer:{parsedUrl:n,gdbVersion:r}}=this;return{...e,query:{gdbVersion:r,layer:`dynamicDataSource`in t&&t.dynamicDataSource?JSON.stringify({source:t.dynamicDataSource}):void 0,...n.query,f:`json`,...this._createRequestQueryOptions(e)},responseType:`json`}}async _areAllAssetsAlreadyMapped(e){let{layer:t}=this,{globalIdField:n,parsedUrl:i}=t,a=`infoFor3D`in t?t.infoFor3D:null;if(a==null||n==null)return!1;let o=P(a);if(o==null)return!1;let s=m(i.path,`../${o.id}`),c=[];for(let t of e)if(t.geometry.metadata.getExternalSourcesOnService(i).length>0)c.push(t);else return!1;let l=c.map(e=>e.getAttribute(n)).filter(r);if(l.length===0)return!1;let{assetMapFieldRoles:{parentGlobalId:u,assetHash:d}}=a,f=new L({where:`${u} IN (${l.map(e=>`'${e}'`)})`,outFields:[d,u],returnGeometry:!1}),{features:p}=await F(s,f);return p.length!==0&&!c.some(e=>{let t=e.getAttribute(n);if(!t)return!0;let{metadata:r}=e.geometry,a=p.filter(e=>e.getAttribute(u)===t);if(a.length===0)return!0;let o=a.map(e=>e.getAttribute(d));return r.getExternalSourcesOnService(i).flatMap(({source:e})=>e.assets.flatMap(e=>e.parts.map(e=>e.partHash))).some(e=>o.every(t=>e!==t))})}};e([g()],G.prototype,`type`,void 0),e([g({constructOnly:!0})],G.prototype,`layer`,void 0),e([g({constructOnly:!0})],G.prototype,`supportedSourceTypes`,void 0),e([g({readOnly:!0})],G.prototype,`queryTask`,null),G=e([_(`esri.layers.graphics.sources.FeatureLayerSource`)],G);const K=1e3;export{G as default};
|
|
2
|
+
import{__decorate as e}from"tslib";import t from"../../../config.js";import n from"../../../request.js";import{isSome as r,remove as i}from"../../../core/arrayUtils.js";import a from"../../../core/Error.js";import has from"../../../core/has.js";import{JSONMap as o}from"../../../core/jsonMap.js";import{Loadable as s}from"../../../core/Loadable.js";import c from"../../../core/Logger.js";import{setDeepValue as l}from"../../../core/object.js";import{debounce as u,after as d,throwIfAbortError as f}from"../../../core/promiseUtils.js";import{watch as p}from"../../../core/reactiveUtils.js";import{join as m}from"../../../core/urlUtils.js";import{generateBracedUUID as h}from"../../../core/uuid.js";import{property as g,subclass as _}from"../../../core/accessorSupport/decorators.js";import v from"../../../geometry/Extent.js";import y from"../../../geometry/SpatialReference.js";import b from"../../../geometry/support/MeshGeoreferencedVertexSpace.js";import{isRelativeVertexSpace as x}from"../../../geometry/support/meshVertexSpaceUtils.js";import{isOriginalExternal as S}from"../../../geometry/support/meshUtils/External.js";import{createFeatureEditResult as C,getFeatureJSON as w,getFeatureIds as T,getAttachmentEditsJSON as E,isProtectedOrPrivateVersionError as D,unpackEditResultData as O,createEditedFeatures as k}from"../applyEditsUtils.js";import{createDrawingInfo as A}from"./support/clientSideDefaults.js";import j from"./support/QueryTask.js";import{isHostedAgolService as M}from"../../support/arcgisLayerUrl.js";import{ensureLayerCredential as N}from"../../support/featureLayerUtils.js";import{getAssetMapTable as P}from"../../support/infoFor3D.js";import{executeQueryJSON as F}from"../../../rest/query/executeQueryJSON.js";import{unapplyEditsZUnitScaling as I}from"../../../rest/query/operations/editsZScale.js";import L from"../../../rest/support/Query.js";import R from"../../../time/TimeExtent.js";import{isSafeToEditVersion as z,isVersionInEditSession as B,isHistoricVersion as V,currentSessionId as H}from"../../../versionManagement/support/versionManagementUtils.js";const U=new o({originalAndCurrentFeatures:`original-and-current-features`,none:`none`}),W=new o({Started:`published`,Publishing:`publishing`,Stopped:`unavailable`});let G=class extends s{constructor(e){super(e),this.type=`feature-layer`,this.supportedSourceTypes=new Set([`Feature Layer`,`Oriented Imagery Layer`,`Table`,`Catalog Layer`,`Annotation Layer`,`Dimension Layer`]),this.refresh=u(async()=>{await this.load();let e=this.sourceJSON.editingInfo?.lastEditDate;if(e==null)return{dataChanged:!0,updates:{}};try{await this._fetchService(null)}catch{return{dataChanged:!0,updates:{}}}let t=e!==this.sourceJSON.editingInfo?.lastEditDate;return{dataChanged:t,updates:t?{editingInfo:this.sourceJSON.editingInfo,extent:this.sourceJSON.extent}:null}}),this._ongoingAssetUploads=new Map}load(e){let t=this.layer.sourceJSON,n=this._fetchService(t,{...e}).then(()=>this.layer.setUserPrivileges(this.sourceJSON.serviceItemId,e)).then(()=>this._ensureLatestMetadata(e));return this.addResolvingPromise(n),Promise.resolve(this)}async reload(e){let t=this.layer.userHasUpdateItemPrivileges&&this.sourceJSON.cacheMaxAge>0;await this._fetchService(null,{...e,cacheBust:t})}initialize(){this.addHandles([p(()=>{let e=this.layer;return e&&`lastEditsEventDate`in e?e.lastEditsEventDate:null},e=>this._handleLastEditsEventChange(e))])}destroy(){this._removeEditInterceptor()}get queryTask(){let{capabilities:e,parsedUrl:t,gdbVersion:n,spatialReference:r,fieldsIndex:i,uniqueIdFields:a}=this.layer,o=`infoFor3D`in this.layer?this.layer.infoFor3D:null,s=`dynamicDataSource`in this.layer?this.layer.dynamicDataSource:null,c=has(`featurelayer-pbf`)&&e?.query.supportsFormatPBF&&o==null,l=c&&e?.query.supportsFormatPBFWithCurves,u=e?.operations?.supportsQueryAttachments??!1,d=e?.query?.relativeTimeBinWindow??0,f=t.path;return new j({dynamicDataSource:s,fieldsIndex:i,gdbVersion:n,infoFor3D:o,pbfSupported:c,pbfSupportedWithCurves:l,queryAttachmentsSupported:u,relativeTimeBinWindow:d,sourceSpatialReference:r,uniqueIdFields:a,url:f})}async addAttachment(e,t,r){await this.load();let{layer:i}=this;await N(i,`editing`);let a=e.attributes[i.objectIdField],o=i.parsedUrl.path+`/`+a+`/addAttachment`,s=this._getLayerRequestOptions({query:r}),c=this._getFormDataForAttachment(t,s.query);try{let e=await n(o,{body:c});return C(e.data.addAttachmentResult)}catch(e){throw this._createAttachmentErrorResult(a,e)}}async updateAttachment(e,t,r,i){await this.load();let{layer:a}=this;await N(a,`editing`);let o=e.attributes[a.objectIdField],s=a.parsedUrl.path+`/`+o+`/updateAttachment`,c=this._getLayerRequestOptions({query:{attachmentId:t,...i}}),l=this._getFormDataForAttachment(r,c.query);try{let e=await n(s,{body:l});return C(e.data.updateAttachmentResult)}catch(e){throw this._createAttachmentErrorResult(o,e)}}async applyEdits(e,t){await this.load();let{layer:i}=this;await N(i,`editing`);let o=`infoFor3D`in i?i.infoFor3D:null,s=o!=null,c=s||(t?.globalIdUsed??!1),l=s?await this._uploadMeshesAndGetAssetMapEditsJSON(e):null,u=e.addFeatures?.map(e=>w(this.layer,e,o))??[],d=(await Promise.all(u)).filter(r),f=e.updateFeatures?.map(e=>w(this.layer,e,o))??[],p=(await Promise.all(f)).filter(r),m=T(this.layer,e.deleteFeatures,c);I(d,p,i.spatialReference);let h=await E(this.layer,e),g=i.capabilities.editing.supportsAsyncApplyEdits&&s,_=t?.gdbVersion||i.gdbVersion,v={gdbVersion:_,rollbackOnFailure:t?.rollbackOnFailureEnabled,useGlobalIds:c,returnEditMoment:t?.returnEditMoment,trueCurveClient:t?.editsRespectTrueCurves,usePreviousEditMoment:t?.usePreviousEditMoment,async:g};await z(this.layer.url,_,!0);let y=B(this.layer.url,_||null);if(await V(i.url,_,i.historicMoment))throw new a(`feature-layer-source:historic-version`,`Editing a historic version is not allowed`);t?.returnServiceEditsOption?(v.edits=JSON.stringify([{id:i.layerId,adds:d.length?d:null,updates:p.length?p:null,deletes:m.length?m:null,attachments:h,assetMaps:l}]),v.returnServiceEditsOption=U.toJSON(t?.returnServiceEditsOption),v.returnServiceEditsInSourceSR=t?.returnServiceEditsInSourceSR):(v.adds=d.length?JSON.stringify(d):null,v.updates=p.length?JSON.stringify(p):null,v.deletes=m.length?c?JSON.stringify(m):m.join(`,`):null,v.attachments=h&&JSON.stringify(h),v.assetMaps=l==null?void 0:JSON.stringify(l));let b=this._getLayerRequestOptions({method:`post`,query:v});y&&(b.authMode=`immediate`,b.query.returnEditMoment=!0,b.query.sessionId=H);let x=t?.returnServiceEditsOption?i.url:i.parsedUrl.path,S;try{S=g?await this._asyncApplyEdits(x+`/applyEdits`,b):await n(x+`/applyEdits`,b)}catch(e){if(D(e))b.authMode=`immediate`,S=g?await this._asyncApplyEdits(x+`/applyEdits`,b):await n(x+`/applyEdits`,b);else throw e}return this._createEditsResult(S)}async deleteAttachments(e,t,r){await this.load();let{layer:i}=this;await N(i,`editing`);let a=e.attributes[i.objectIdField],o=i.parsedUrl.path+`/`+a+`/deleteAttachments`;try{return(await n(o,this._getLayerRequestOptions({query:{attachmentIds:t.join(`,`),...r},method:`post`}))).data.deleteAttachmentResults.map(C)}catch(e){throw this._createAttachmentErrorResult(a,e)}}fetchRecomputedExtents(e={}){let t=e.signal;return this.load({signal:t}).then(async()=>{let t=this._getLayerRequestOptions({...e,query:{returnUpdates:!0}}),{layerId:r,url:i}=this.layer,{data:a}=await n(`${i}/${r}`,t),{id:o,extent:s,fullExtent:c,timeExtent:l}=a,u=s||c;return{id:o,fullExtent:u&&v.fromJSON(u),timeExtent:l&&R.fromJSON({start:l[0],end:l[1]})}})}async queryAttachments(e,t={}){await this.load();let n=this._getLayerRequestOptions(t);return this.queryTask.executeAttachmentQuery(e,n)}async queryFeatures(e,t){await this.load();let n=await this.queryTask.execute(e,{...t,query:this._createRequestQueryOptions(t)});if(e.outStatistics?.length&&n.features.length){let t=new Map;if(n.features.forEach(n=>{let r=n.attributes;e.outStatistics?.forEach(({outStatisticFieldName:e})=>{if(e){let n=e.toLowerCase();n&&n in r&&e!==n&&(r[e]=r[n],delete r[n],t.set(n,e))}})}),n.fields!=null)for(let e of n.fields){let n=t.get(e.name.toLowerCase());n!=null&&(e.name=n)}}return n}async queryFeaturesJSON(e,t){return await this.load(),this.queryTask.executeJSON(e,{...t,query:this._createRequestQueryOptions(t)})}async queryObjectIds(e,t){return await this.load(),this.queryTask.executeForIds(e,{...t,query:this._createRequestQueryOptions(t)})}async queryFeatureCount(e,t){return await this.load(),this.queryTask.executeForCount(e,{...t,query:this._createRequestQueryOptions(t)})}async queryExtent(e,t){return await this.load(),this.queryTask.executeForExtent(e,{...t,query:this._createRequestQueryOptions(t)})}async queryRelatedFeatures(e,t){return await this.load(),this.queryTask.executeRelationshipQuery(e,{...t,query:this._createRequestQueryOptions(t)})}async queryRelatedFeaturesCount(e,t){return await this.load(),this.queryTask.executeRelationshipQueryForCount(e,{...t,query:this._createRequestQueryOptions(t)})}async queryPivot(e,t){return await this.load(),this.queryTask.executePivotQuery(e,{...t,query:this._createRequestQueryOptions(t)})}async queryTopFeatures(e,t){return await this.load(),this.queryTask.executeTopFeaturesQuery(e,{...t,query:this._createRequestQueryOptions(t)})}async queryAttributeBins(e,t){return await this.load(),this.queryTask.executeAttributeBinsQuery(e,{...t,query:this._createRequestQueryOptions(t)})}async queryTopObjectIds(e,t){return await this.load(),this.queryTask.executeForTopIds(e,{...t,query:this._createRequestQueryOptions(t)})}async queryTopExtents(e,t){return await this.load(),this.queryTask.executeForTopExtents(e,{...t,query:this._createRequestQueryOptions(t)})}async queryTopCount(e,t){return await this.load(),this.queryTask.executeForTopCount(e,{...t,query:this._createRequestQueryOptions(t)})}async fetchPublishingStatus(){if(!M(this.layer.url))return`unavailable`;let e=m(this.layer.url,`status`),t=await n(e,{query:{f:`json`}});return W.fromJSON(t.data.status)}async uploadAssets(e,t){let{uploadAssets:n}=await import(`./support/uploadAssets.js`);return n(e,{layer:this.layer,ongoingUploads:this._ongoingAssetUploads},t)}_handleLastEditsEventChange(e){let t=this.layer;if(e==null||!(`capabilities`in t)||!(`effectiveCapabilities`in t)||t.capabilities?.operations?.supportsEditing||!t.effectiveCapabilities?.operations?.supportsEditing)return;let n=t.url;if(n==null)return;`layerId`in t&&(n=m(n,t.layerId.toString()));let r=this._getOrCreateEditInterceptor(n);r.before=t=>{let n=t.requestOptions.method??`auto`;if(n===`auto`||n===`head`){let n=t.requestOptions.query??{};n._ts=e.getTime(),t.requestOptions.query=n}}}_getOrCreateEditInterceptor(e){return this._editInterceptor??(this._editInterceptor={urls:e},t.request.internalInterceptors.push(this._editInterceptor)),this._editInterceptor}_removeEditInterceptor(){this._editInterceptor!=null&&(i(t.request.internalInterceptors,this._editInterceptor),this._editInterceptor=null)}async _asyncApplyEdits(e,t){let r=(await n(e,t)).data.statusUrl;for(;;){let e=(await n(r,{query:{f:`json`},responseType:`json`})).data;switch(e.status){case`Completed`:return n(e.resultUrl,{query:{f:`json`},responseType:`json`});case`CompletedWithErrors`:throw new a(`async-applyEdits-failed`,`asynchronous applyEdits call failed.`);case`Failed ImportChanges`:case`InProgress`:case`Pending`:case`ExportAttachments`:case`ExportChanges`:case`ExportingData`:case`ExportingSnapshot`:case`ImportAttachments`:case`ProvisioningReplica`:case`UnRegisteringReplica`:break;default:throw new a(`async-applyEdits-failed`,`asynchronous applyEdits call failed (undefined response status)`)}await d(K)}}_createRequestQueryOptions(e){let t={...this.layer.customParameters,token:this.layer.apiKey,...e?.query};return this.layer.datesInUnknownTimezone&&(t.timeReferenceUnknownClient=!0),t}async _fetchService(e,t){if(!e){let r={};has(`featurelayer-advanced-symbols`)&&(r.returnAdvancedSymbols=!0),t?.cacheBust&&(r._ts=Date.now());let{data:i}=await n(this.layer.parsedUrl.path,this._getLayerRequestOptions({query:r,signal:t?.signal}));e=i}this.layer.applyPreferredHost(e),this.sourceJSON=await this._patchServiceJSON(e,t?.signal);let r=e.type;if(!this.supportedSourceTypes.has(r))throw new a(`feature-layer-source:unsupported-type`,`Source type "${r}" is not supported`)}async _patchServiceJSON(e,t){if(e.type!==`Table`&&e.geometryType&&!e?.drawingInfo?.renderer&&!e.defaultSymbol){let t=A(e.geometryType).renderer;l(`drawingInfo.renderer`,t,e)}if(e.geometryType===`esriGeometryMultiPatch`&&e.infoFor3D&&(e.geometryType=`mesh`),e.extent==null)try{let{data:r}=await n(this.layer.url,this._getLayerRequestOptions({signal:t}));r.spatialReference&&(e.extent={xmin:0,ymin:0,xmax:0,ymax:0,spatialReference:r.spatialReference})}catch(e){f(e)}return e}async _ensureLatestMetadata(e){if(this.layer.userHasUpdateItemPrivileges&&this.sourceJSON.cacheMaxAge>0)return this._fetchService(null,{...e,cacheBust:!0})}async _uploadMeshesAndGetAssetMapEditsJSON(e){let{addAssetFeatures:t}=e;if(!t?.length||await this._areAllAssetsAlreadyMapped(t))return null;let n=e.addFeatures.filter(e=>e.geometry);if(t.length!==n.length+e.updateFeatures.length)throw new a(`feature-layer-source:unsupported-mesh-edits`,`Mixing attribute only edits with mesh geometry edits is not currently supported`);let r=[],i=new Map;for(let e of t){let{geometry:t}=e,{vertexSpace:n}=t;if(x(n))r.push(t);else{let n=t.origin,{convertMeshVertexSpace:a}=await import(`../../../geometry/support/meshUtils/convertMeshVertexSpace.js`),o=await a(t,new b({origin:[n.x,n.y,n.z??0]}));i.set(o,t),e.geometry=o,r.push(o)}}await this.uploadAssets(r);for(let[e,t]of i)t.addExternalSources(e.metadata.externalSources.items);return{adds:this._getAssetMapEditsJSON(t),updates:[],deletes:[]}}_getAssetMapEditsJSON(e){let t=[],n=this.layer.globalIdField,r=this.layer.parsedUrl;for(let i of e){let{metadata:e}=i.geometry,a=e.getExternalSourcesOnService(r),o=i.getAttribute(n);if(a.length===0){c.getLogger(this).error(`Skipping feature ${o}. The mesh it is associated with has not been uploaded to the service and cannot be mapped to it.`);continue}let{source:s}=a.find(S)??a[0];for(let e of s.assets){if(e.parts.length!==1){c.getLogger(this).error(`Skipping asset ${e.assetName}. It does not have exactly one part, so we cannot map it to a feature.`);continue}t.push({globalId:h(),parentGlobalId:o,assetName:e.assetName,assetHash:e.parts[0].partHash,flags:[]})}}return t}_createEditsResult(e){let t=e.data,{layerId:n}=this.layer,r=[],i=null;if(Array.isArray(t))for(let e of t)e.editedFeatures!=null&&r.push({id:e.id,editedFeatures:e.editedFeatures}),e.id===n&&(i={addResults:e.addResults??[],updateResults:e.updateResults??[],deleteResults:e.deleteResults??[],attachments:e.attachments,editMoment:e.editMoment});else i=t;let a=O(i);if(r.length>0){a.editedFeatureResults=[];for(let e of r){let{editedFeatures:t}=e,n=t?.spatialReference?new y(t.spatialReference):null;a.editedFeatureResults.push({layerId:e.id,editedFeatures:k(t,n)})}}return a}_createAttachmentErrorResult(e,t){let n=t.details.messages?.[0]||t.message,r=t.details.httpStatus||t.details.messageCode;return{objectId:e,globalId:null,error:new a(`feature-layer-source:attachment-failure`,n,{code:r})}}_getFormDataForAttachment(e,t){let n=e instanceof FormData?e:e&&e.elements?new FormData(e):null;if(n)for(let e in t){let r=t[e];r!=null&&(n.set?n.set(e,r):n.append(e,r))}return n}_getLayerRequestOptions(e={}){let{layer:t,layer:{parsedUrl:n,gdbVersion:r}}=this;return{...e,query:{gdbVersion:r,layer:`dynamicDataSource`in t&&t.dynamicDataSource?JSON.stringify(t.dynamicDataSource.toLayerSourceJSON()):void 0,...n.query,f:`json`,...this._createRequestQueryOptions(e)},responseType:`json`}}async _areAllAssetsAlreadyMapped(e){let{layer:t}=this,{globalIdField:n,parsedUrl:i}=t,a=`infoFor3D`in t?t.infoFor3D:null;if(a==null||n==null)return!1;let o=P(a);if(o==null)return!1;let s=m(i.path,`../${o.id}`),c=[];for(let t of e)if(t.geometry.metadata.getExternalSourcesOnService(i).length>0)c.push(t);else return!1;let l=c.map(e=>e.getAttribute(n)).filter(r);if(l.length===0)return!1;let{assetMapFieldRoles:{parentGlobalId:u,assetHash:d}}=a,f=new L({where:`${u} IN (${l.map(e=>`'${e}'`)})`,outFields:[d,u],returnGeometry:!1}),{features:p}=await F(s,f);return p.length!==0&&!c.some(e=>{let t=e.getAttribute(n);if(!t)return!0;let{metadata:r}=e.geometry,a=p.filter(e=>e.getAttribute(u)===t);if(a.length===0)return!0;let o=a.map(e=>e.getAttribute(d));return r.getExternalSourcesOnService(i).flatMap(({source:e})=>e.assets.flatMap(e=>e.parts.map(e=>e.partHash))).some(e=>o.every(t=>e!==t))})}};e([g()],G.prototype,`type`,void 0),e([g({constructOnly:!0})],G.prototype,`layer`,void 0),e([g({constructOnly:!0})],G.prototype,`supportedSourceTypes`,void 0),e([g({readOnly:!0})],G.prototype,`queryTask`,null),G=e([_(`esri.layers.graphics.sources.FeatureLayerSource`)],G);const K=1e3;export{G as default};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
import{__decorate as e}from"tslib";import t from"../../../../core/Accessor.js";import n from"../../../../core/Error.js";import has from"../../../../core/has.js";import{whenOrAbort as r}from"../../../../core/promiseUtils.js";import{urlToObject as i}from"../../../../core/urlUtils.js";import{property as a,subclass as o}from"../../../../core/accessorSupport/decorators.js";import{equals as s}from"../../../../geometry/support/spatialReferenceUtils.js";import{getGltfQueryFormat as c}from"../../../support/infoFor3D.js";import{parseUrl as l}from"../../../../rest/utils.js";import u
|
|
2
|
+
import{__decorate as e}from"tslib";import t from"../../../../core/Accessor.js";import n from"../../../../core/Error.js";import has from"../../../../core/has.js";import{whenOrAbort as r}from"../../../../core/promiseUtils.js";import{urlToObject as i}from"../../../../core/urlUtils.js";import{property as a,subclass as o}from"../../../../core/accessorSupport/decorators.js";import{equals as s}from"../../../../geometry/support/spatialReferenceUtils.js";import{getGltfQueryFormat as c}from"../../../support/infoFor3D.js";import{parseUrl as l}from"../../../../rest/utils.js";import{dynamicDataSourceTypes as u}from"../../../../rest/layerSources/typeUtils.js";import{executeForCount as d}from"../../../../rest/query/executeForCount.js";import{executeForExtent as f}from"../../../../rest/query/executeForExtent.js";import{executeForIds as p}from"../../../../rest/query/executeForIds.js";import{executeRawQueryJSON as m}from"../../../../rest/query/executeQueryJSON.js";import{executeRawQueryPBF as h}from"../../../../rest/query/executeQueryPBF.js";import g from"../../../../rest/support/FeatureSet.js";import _ from"../../../../rest/support/Query.js";let v=class extends t{constructor(e){super(e),this.dynamicDataSource=null,this.fieldsIndex=null,this.gdbVersion=null,this.infoFor3D=null,this.pbfSupported=!1,this.pbfSupportedWithCurves=!1,this.queryAttachmentsSupported=!1,this.relativeTimeBinWindow=0,this.sourceSpatialReference=null,this.uniqueIdFields=null,this.url=null}get parsedUrl(){return i(this.url)}async execute(e,t){let n=await this.executeJSON(e,t);return this.featureSetFromJSON(e,n,t)}async executeJSON(e,t){let n=this._normalizeQuery(e),r=e.outStatistics?.[0]!=null,i=has(`featurelayer-pbf-statistics`),a=this.pbfSupported&&(!r||i)&&(!e.returnTrueCurves||this.pbfSupportedWithCurves),o;if(a)try{o=await h(this.url,n,t,{uniqueIdFields:this.uniqueIdFields})}catch(e){if(e.name===`query:parsing-pbf`)this.pbfSupported=!1;else throw e}return o??=await m(this.url,n,t,{uniqueIdFields:this.uniqueIdFields}),this._normalizeFields(o.fields),o}async featureSetFromJSON(e,t,n){if(!this._queryGet3DObjectFormat(e)||this.infoFor3D==null||!t.features)return g.fromJSON(t);let{meshFeatureSetFromJSON:i}=await r(import(`../../../../rest/support/meshFeatureSet.js`),n);return i(e,this.infoFor3D,t)}executeForCount(e,t){return d(this.url,this._normalizeQuery(e),t,{uniqueIdFields:this.uniqueIdFields})}executeForExtent(e,t){return f(this.url,this._normalizeQuery(e),t)}executeForIds(e,t){return p(this.url,this._normalizeQuery(e),t,{uniqueIdFields:this.uniqueIdFields})}async executeRelationshipQuery(e,t){let[{default:n},{executeRelationshipQuery:i}]=await r(Promise.all([import(`../../../../rest/support/RelationshipQuery.js`),import(`../../../../rest/query/executeRelationshipQuery.js`)]),t),a=n.from(e);return(this.gdbVersion||this.dynamicDataSource)&&(a=a.clone(),a.gdbVersion=a.gdbVersion||this.gdbVersion,a.dynamicDataSource=a.dynamicDataSource||this.dynamicDataSource),i(this.url,a,t)}async executeRelationshipQueryForCount(e,t){let[{default:n},{executeRelationshipQueryForCount:i}]=await r(Promise.all([import(`../../../../rest/support/RelationshipQuery.js`),import(`../../../../rest/query/executeRelationshipQuery.js`)]),t),a=n.from(e);return(this.gdbVersion||this.dynamicDataSource)&&(a=a.clone(),a.gdbVersion=a.gdbVersion||this.gdbVersion,a.dynamicDataSource=a.dynamicDataSource||this.dynamicDataSource),i(this.url,a,t)}async executeAttachmentQuery(e,t){let{executeAttachmentQuery:n,fetchAttachments:i,processAttachmentQueryResult:a}=await r(import(`../../../../rest/query/operations/queryAttachments.js`),t),o=l(this.url);return a(o,await(this.queryAttachmentsSupported?n(o,e,t):i(o,e,t)))}async executeAttributeBinsQuery(e,t){let{executeAttributeBinsQuery:n}=await r(import(`../../../../rest/query/executeAttributeBinsQuery.js`),t);return n(this.parsedUrl,e,t)}async executePivotQuery(e,t){let{executePivotQuery:n}=await r(import(`../../../../rest/query/executePivotQuery.js`),t);return n(this.parsedUrl,e,t)}async executeTopFeaturesQuery(e,t){let{executeTopFeaturesQuery:n}=await r(import(`../../../../rest/query/executeTopFeaturesQuery.js`),t);return n(this.parsedUrl,e,this.sourceSpatialReference,t)}async executeForTopIds(e,t){let{executeForTopIds:n}=await r(import(`../../../../rest/query/executeForTopIds.js`),t);return n(this.parsedUrl,e,t)}async executeForTopExtents(e,t){let{executeForTopExtents:n}=await r(import(`../../../../rest/query/executeForTopExtents.js`),t);return n(this.parsedUrl,e,t)}async executeForTopCount(e,t){let{executeForTopCount:n}=await r(import(`../../../../rest/query/executeForTopCount.js`),t);return n(this.parsedUrl,e,t)}_normalizeQuery(e){let t=_.from(e);t.sourceSpatialReference=t.sourceSpatialReference||this.sourceSpatialReference,(this.gdbVersion||this.dynamicDataSource)&&(t=t===e?t.clone():t,t.gdbVersion=e.gdbVersion||this.gdbVersion,t.dynamicDataSource=e.dynamicDataSource||this.dynamicDataSource);let{infoFor3D:r}=this,i=this._queryGet3DObjectFormat(e);if(r!=null&&i){if(t=t===e?t.clone():t,t.formatOf3DObjects=i,t.outSpatialReference&&!s(t.outSpatialReference,this.sourceSpatialReference))throw new n(`query:unsupported-out-spatial-reference`,`3D object feature services do not support projection of geometries`);if(t.outFields==null||!t.outFields.includes(`*`)){t=t===e?t.clone():t,t.outFields??(t.outFields=[]);let{originX:n,originY:i,originZ:a,translationX:o,translationY:s,translationZ:c,scaleX:l,scaleY:u,scaleZ:d,rotationX:f,rotationY:p,rotationZ:m,rotationDeg:h}=r.transformFieldRoles;t.outFields.push(n,i,a,o,s,c,l,u,d,f,p,m,h)}}return t}_normalizeFields(e){if(this.fieldsIndex!=null&&e!=null)for(let t of e){let e=this.fieldsIndex.get(t.name);e&&Object.assign(t,e.toJSON())}}_queryGet3DObjectFormat({returnGeometry:e,multipatchOption:t,outStatistics:n}){return e===!0&&t!==`xyFootprint`&&!n?c(this.infoFor3D):null}};e([a({types:u})],v.prototype,`dynamicDataSource`,void 0),e([a()],v.prototype,`fieldsIndex`,void 0),e([a()],v.prototype,`gdbVersion`,void 0),e([a()],v.prototype,`infoFor3D`,void 0),e([a({readOnly:!0})],v.prototype,`parsedUrl`,null),e([a()],v.prototype,`pbfSupported`,void 0),e([a()],v.prototype,`pbfSupportedWithCurves`,void 0),e([a()],v.prototype,`queryAttachmentsSupported`,void 0),e([a()],v.prototype,`relativeTimeBinWindow`,void 0),e([a()],v.prototype,`sourceSpatialReference`,void 0),e([a()],v.prototype,`uniqueIdFields`,void 0),e([a({type:String})],v.prototype,`url`,void 0),v=e([o(`esri.layers.graphics.sources.support.QueryTask`)],v);export{v as default};
|
|
@@ -122,7 +122,7 @@ export interface KnowledgeGraphSublayerProperties extends LayerProperties, Refre
|
|
|
122
122
|
* }
|
|
123
123
|
* });
|
|
124
124
|
*
|
|
125
|
-
* knowledgeGraphLayer.layers.
|
|
125
|
+
* knowledgeGraphLayer.layers.at(0).labelingInfo = [ statesLabelClass ];
|
|
126
126
|
*/
|
|
127
127
|
labelingInfo?: LabelClassProperties[] | null;
|
|
128
128
|
/**
|
|
@@ -182,7 +182,7 @@ export interface KnowledgeGraphSublayerProperties extends LayerProperties, Refre
|
|
|
182
182
|
* // a 6pt black marker symbol and a thin, white outline
|
|
183
183
|
*
|
|
184
184
|
* //Apply renderer to the first sublayer of the KnowledgeGraphLayer
|
|
185
|
-
* const sublayer = knowledgeGraphLayer.layers.
|
|
185
|
+
* const sublayer = knowledgeGraphLayer.layers.at(0);
|
|
186
186
|
* sublayer.renderer = {
|
|
187
187
|
* type: "simple", // autocasts as new SimpleRenderer()
|
|
188
188
|
* symbol: {
|
|
@@ -223,7 +223,7 @@ export interface KnowledgeGraphSublayerProperties extends LayerProperties, Refre
|
|
|
223
223
|
* @see [knowledgeGraphService](https://developers.arcgis.com/javascript/latest/references/core/rest/knowledgeGraphService/)
|
|
224
224
|
* @example
|
|
225
225
|
* //to access individual sublayers in a KnowledgeGraphLayer
|
|
226
|
-
* knowledgeGraphLayer.layers.
|
|
226
|
+
* knowledgeGraphLayer.layers.forEach((sublayer)=>{
|
|
227
227
|
* sublayer.popupTemplate = new PopupTemplate({
|
|
228
228
|
* title: "{common_name}",
|
|
229
229
|
* content: [{
|
|
@@ -256,7 +256,7 @@ export default class KnowledgeGraphSublayer extends KnowledgeGraphSublayerSuperc
|
|
|
256
256
|
*
|
|
257
257
|
* @example
|
|
258
258
|
* // Set the definition expression directly on sublayer instance to only suppliers with more than 50 employees.
|
|
259
|
-
* knowledgeGraphLayer.layers.
|
|
259
|
+
* knowledgeGraphLayer.layers.at(0).definitionExpression = "employee_count > 50";
|
|
260
260
|
*/
|
|
261
261
|
accessor definitionExpression: string | null | undefined;
|
|
262
262
|
/**
|
|
@@ -407,7 +407,7 @@ export default class KnowledgeGraphSublayer extends KnowledgeGraphSublayerSuperc
|
|
|
407
407
|
* }
|
|
408
408
|
* });
|
|
409
409
|
*
|
|
410
|
-
* knowledgeGraphLayer.layers.
|
|
410
|
+
* knowledgeGraphLayer.layers.at(0).labelingInfo = [ statesLabelClass ];
|
|
411
411
|
*/
|
|
412
412
|
get labelingInfo(): LabelClass[] | null | undefined;
|
|
413
413
|
set labelingInfo(value: LabelClassProperties[] | null | undefined);
|
|
@@ -515,7 +515,7 @@ export default class KnowledgeGraphSublayer extends KnowledgeGraphSublayerSuperc
|
|
|
515
515
|
* // a 6pt black marker symbol and a thin, white outline
|
|
516
516
|
*
|
|
517
517
|
* //Apply renderer to the first sublayer of the KnowledgeGraphLayer
|
|
518
|
-
* const sublayer = knowledgeGraphLayer.layers.
|
|
518
|
+
* const sublayer = knowledgeGraphLayer.layers.at(0);
|
|
519
519
|
* sublayer.renderer = {
|
|
520
520
|
* type: "simple", // autocasts as new SimpleRenderer()
|
|
521
521
|
* symbol: {
|
|
@@ -629,7 +629,7 @@ export default class KnowledgeGraphSublayer extends KnowledgeGraphSublayerSuperc
|
|
|
629
629
|
* // Get a range domain associated with the first feature
|
|
630
630
|
* // returned from queryFeatures().
|
|
631
631
|
* //get the first sublayer from the parent KnowledgeGraphLayer
|
|
632
|
-
* const sublayer = knowledgeGraphLayer.layers.
|
|
632
|
+
* const sublayer = knowledgeGraphLayer.layers.at(0);
|
|
633
633
|
* sublayer.queryFeatures(query).then(function(results){
|
|
634
634
|
* const domain = sublayer.getFieldDomain("Height", {feature: results.features[0]});
|
|
635
635
|
* console.log("domain", domain)
|
|
@@ -656,14 +656,14 @@ export default class KnowledgeGraphSublayer extends KnowledgeGraphSublayerSuperc
|
|
|
656
656
|
* // Queries for the extent of all features matching the layer's configurations
|
|
657
657
|
* // e.g. definitionExpression
|
|
658
658
|
* //get the first sublayer from the parent KnowledgeGraphLayer
|
|
659
|
-
* const sublayer = knowledgeGraphLayer.layers.
|
|
659
|
+
* const sublayer = knowledgeGraphLayer.layers.at(0);
|
|
660
660
|
* sublayer.queryExtent().then(function(results){
|
|
661
661
|
* // go to the extent of the results satisfying the query
|
|
662
662
|
* view.goTo(results.extent);
|
|
663
663
|
* });
|
|
664
664
|
* @example
|
|
665
665
|
* //get the first sublayer from the parent KnowledgeGraphLayer
|
|
666
|
-
* const sublayer = knowledgeGraphLayer.layers.
|
|
666
|
+
* const sublayer = knowledgeGraphLayer.layers.at(0);
|
|
667
667
|
*
|
|
668
668
|
* const query = new Query();
|
|
669
669
|
* query.where = "region = 'Southern California'";
|
|
@@ -690,14 +690,14 @@ export default class KnowledgeGraphSublayer extends KnowledgeGraphSublayerSuperc
|
|
|
690
690
|
* // Queries for the count of all features matching the layer's configurations
|
|
691
691
|
* // e.g. definitionExpression
|
|
692
692
|
* //get the first sublayer from the parent KnowledgeGraphLayer
|
|
693
|
-
* const sublayer = knowledgeGraphLayer.layers.
|
|
693
|
+
* const sublayer = knowledgeGraphLayer.layers.at(0);
|
|
694
694
|
* sublayer.queryFeatureCount().then(function(numFeatures){
|
|
695
695
|
* // prints the total count to the console
|
|
696
696
|
* console.log(numFeatures);
|
|
697
697
|
* });
|
|
698
698
|
* @example
|
|
699
699
|
* //get the first sublayer from the parent KnowledgeGraphLayer
|
|
700
|
-
* const sublayer = knowledgeGraphLayer.layers.
|
|
700
|
+
* const sublayer = knowledgeGraphLayer.layers.at(0);
|
|
701
701
|
*
|
|
702
702
|
* const query = new Query();
|
|
703
703
|
* query.where = "region = 'Southern California'";
|
|
@@ -736,14 +736,14 @@ export default class KnowledgeGraphSublayer extends KnowledgeGraphSublayerSuperc
|
|
|
736
736
|
* // Queries for all the features matching the layer's configurations
|
|
737
737
|
* // e.g. definitionExpression
|
|
738
738
|
* //get the first sublayer from the parent KnowledgeGraphLayer
|
|
739
|
-
* const sublayer = knowledgeGraphLayer.layers.
|
|
739
|
+
* const sublayer = knowledgeGraphLayer.layers.at(0);
|
|
740
740
|
* sublayer.queryFeatures().then(function(results){
|
|
741
741
|
* // prints the array of result graphics to the console
|
|
742
742
|
* console.log(results.features);
|
|
743
743
|
* });
|
|
744
744
|
* @example
|
|
745
745
|
* //get the first sublayer from the parent KnowledgeGraphLayer
|
|
746
|
-
* const sublayer = knowledgeGraphLayer.layers.
|
|
746
|
+
* const sublayer = knowledgeGraphLayer.layers.at(0);
|
|
747
747
|
*
|
|
748
748
|
* const query = new Query();
|
|
749
749
|
* query.where = "STATE_NAME = 'Washington'";
|
|
@@ -769,7 +769,7 @@ export default class KnowledgeGraphSublayer extends KnowledgeGraphSublayerSuperc
|
|
|
769
769
|
* });
|
|
770
770
|
* @example
|
|
771
771
|
* //get the first sublayer from the parent KnowledgeGraphLayer
|
|
772
|
-
* const sublayer = knowledgeGraphLayer.layers.
|
|
772
|
+
* const sublayer = knowledgeGraphLayer.layers.at(0);
|
|
773
773
|
*
|
|
774
774
|
* // query all features from the layer and only return
|
|
775
775
|
* // attributes specified in outFields.
|
|
@@ -799,14 +799,14 @@ export default class KnowledgeGraphSublayer extends KnowledgeGraphSublayerSuperc
|
|
|
799
799
|
* // Queries for all the Object IDs of features matching the layer's configurations
|
|
800
800
|
* // e.g. definitionExpression
|
|
801
801
|
* //get the first sublayer from the parent KnowledgeGraphLayer
|
|
802
|
-
* const sublayer = knowledgeGraphLayer.layers.
|
|
802
|
+
* const sublayer = knowledgeGraphLayer.layers.at(0);
|
|
803
803
|
* sublayer.queryObjectIds().then(function(results){
|
|
804
804
|
* // prints the array of Object IDs to the console
|
|
805
805
|
* console.log(results);
|
|
806
806
|
* });
|
|
807
807
|
* @example
|
|
808
808
|
* //get the first sublayer from the parent KnowledgeGraphLayer
|
|
809
|
-
* const sublayer = linkChartLayer.layers.
|
|
809
|
+
* const sublayer = linkChartLayer.layers.at(0);
|
|
810
810
|
*
|
|
811
811
|
* const query = new Query();
|
|
812
812
|
* query.where = "region = 'Southern California'";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
import{__decorate as e}from"tslib";import t from"../../request.js";import{some as n}from"../../core/iteratorUtils.js";import{getOrCreateMapValue as r}from"../../core/MapUtils.js";import{throwIfAborted as i}from"../../core/promiseUtils.js";import{join as a}from"../../core/urlUtils.js";import o from"../../core/Version.js";import{property as s,subclass as c}from"../../core/accessorSupport/decorators.js";import l from"../../geometry/Extent.js";import u from"../../geometry/SpatialReference.js";import{parse as d}from"../support/arcgisLayerUrl.js";import{id as f,popupEnabled as p}from"../support/commonProperties.js";import{isHostedLayer as m}from"../../portal/support/portalItemUtils.js";import{reader as h}from"../../core/accessorSupport/decorators/reader.js";const g=g=>{let _=g,v=class extends _{constructor(){super(...arguments),this.capabilities=void 0,this.copyright=null,this.fullExtent=null,this.legendEnabled=!0,this.spatialReference=null,this.version=void 0,this._allLayersAndTablesMap=null}readCapabilities(e,t){let n=t.capabilities&&t.capabilities.split(`,`).map(e=>e.toLowerCase().trim());if(!n)return{operations:{supportsExportMap:!1,supportsExportTiles:!1,supportsIdentify:!1,supportsQuery:!1,supportsTileMap:!1},exportMap:null,exportTiles:null};let r=this.type,i=r!==`tile`&&!!t.supportsDynamicLayers,a=n.includes(`query`),s=n.includes(`map`),c=!!t.exportTilesAllowed,l=n.includes(`tilemap`),u=n.includes(`data`),d=r!==`tile`&&(!t.tileInfo||i),f=r!==`tile`&&(!t.tileInfo||i),p=r!==`tile`,m=r!==`tile`&&i&&t.currentVersion>=11.1,h=t.cimVersion?o.parse(t.cimVersion):null,g=h?.greaterEqual(1,4)??!1,_=h?.greaterEqual(2,0)??!1;return{operations:{supportsExportMap:s,supportsExportTiles:c,supportsIdentify:a,supportsQuery:u,supportsTileMap:l},exportMap:s?{supportsArcadeExpressionForLabeling:g,supportsCIMSymbols:_,supportsDynamicLayers:i,supportsSublayerOrderBy:m,supportsSublayerDefinitionExpression:f,supportsSublayerVisibility:d,supportsSublayersChanges:p}:null,exportTiles:c?{maxExportTilesCount:+t.maxExportTilesCount}:null}}readVersion(e,t){let n=t.currentVersion;return n||=t.hasOwnProperty(`capabilities`)||t.hasOwnProperty(`tables`)?10:t.hasOwnProperty(`supportedImageFormatTypes`)?9.31:9.3,n}async fetchRelatedService(e){let t=this.portalItem;if(!t||!m(t))return null;this._relatedFeatureServicePromise||=t.fetchRelatedItems({relationshipType:`Service2Service`,direction:`reverse`},e).then(e=>e.find(e=>e.type===`Feature Service`)??null,()=>null);let n=await this._relatedFeatureServicePromise;return i(e),n?{itemId:n.id,url:n.url}:null}async fetchSublayerInfo(e,n){let{source:r}=e;if(this?.portalItem&&this.type===`tile`&&r?.type===`map-layer`&&m(this.portalItem)&&e.originIdOf(`url`)<2){let t=await this.fetchRelatedService(n);t&&(e.url=a(t.url,r.mapLayerId.toString()),e.layerItemId=t.itemId)}let{url:i}=e,o;if(r.type===`data-layer`)o=(await t(i,{responseType:`json`,query:{f:`json`,...this.customParameters,token:this.apiKey},...n})).data;else{let t=e.id;r?.type===`map-layer`&&(t=r.mapLayerId);try{o=(await this.fetchAllLayersAndTables(n)).get(t)}catch{}if(i&&e.originIdOf(`url`)>2)try{let e=await this._fetchAllLayersAndTablesFromService(i),t=d(i)?.sublayer??r.mapLayerId,n=structuredClone(e.get(t));if(n!=null){for(let e of[`drawingInfo`,`maxScale`,`minScale`,`name`])delete n[e];o={...o,...n}}}catch{}}return o}async fetchAllLayersAndTables(e){return this._fetchAllLayersAndTablesFromService(this.parsedUrl?.path,e)}async _fetchAllLayersAndTablesFromService(e,o){await this.load(o),this._allLayersAndTablesMap||=new Map;let s=d(e),c=await r(this._allLayersAndTablesMap,s?.url.path,()=>t(a(s?.url.path,`/layers`),{query:{f:`json`,...this.customParameters,token:this.apiKey}}).then(async e=>{let r=new Map,{layers:i,tables:a}=e.data,o=[...i??[],...a??[]];for(let e of o)r.set(e.id,e);if(n(r.values(),e=>e.capabilities==null||e.extent==null)){let{data:e}=await t(s?.url.path,{query:{f:`json`,...this.customParameters,token:this.apiKey}}).catch(()=>({data:{capabilities:``,fullExtent:void 0}}));for(let t of r.values())t.capabilities??=e.capabilities??``,t.extent??=e.fullExtent}return{result:r}},e=>({error:e})));if(i(o),`result`in c)return c.result;throw c.error}};return e([s({readOnly:!0})],v.prototype,`capabilities`,void 0),e([h(`service`,`capabilities`,[`capabilities`,`cimVersion`,`currentVersion`,`exportTilesAllowed`,`maxExportTilesCount`,`supportsDynamicLayers`,`tileInfo`])],v.prototype,`readCapabilities`,null),e([s({json:{read:{source:`copyrightText`}}})],v.prototype,`copyright`,void 0),e([s({type:l})],v.prototype,`fullExtent`,void 0),e([s(f)],v.prototype,`id`,void 0),e([s({type:Boolean,json:{origins:{service:{read:{enabled:!1}}},read:{source:`showLegend`},write:{target:`showLegend`}}})],v.prototype,`legendEnabled`,void 0),e([s(p)],v.prototype,`popupEnabled`,void 0),e([s({type:u})],v.prototype,`spatialReference`,void 0),e([s({readOnly:!0})],v.prototype,`version`,void 0),e([h(`service`,`version`,[`currentVersion`,`capabilities`,`tables`,`supportedImageFormatTypes`])],v.prototype,`readVersion`,null),v=e([c(`esri.layers.mixins.ArcGISMapService`)],v),v};export{g as ArcGISMapService};
|
|
2
|
+
import{__decorate as e}from"tslib";import t from"../../request.js";import{some as n}from"../../core/iteratorUtils.js";import{getOrCreateMapValue as r}from"../../core/MapUtils.js";import{throwIfAborted as i}from"../../core/promiseUtils.js";import{join as a}from"../../core/urlUtils.js";import o from"../../core/Version.js";import{property as s,subclass as c}from"../../core/accessorSupport/decorators.js";import l from"../../geometry/Extent.js";import u from"../../geometry/SpatialReference.js";import{parse as d}from"../support/arcgisLayerUrl.js";import{id as f,popupEnabled as p}from"../support/commonProperties.js";import{isHostedLayer as m}from"../../portal/support/portalItemUtils.js";import{reader as h}from"../../core/accessorSupport/decorators/reader.js";const g=g=>{let _=g,v=class extends _{constructor(){super(...arguments),this.capabilities=void 0,this.copyright=null,this.fullExtent=null,this.legendEnabled=!0,this.spatialReference=null,this.version=void 0,this._allLayersAndTablesMap=null}readCapabilities(e,t){let n=t.capabilities&&t.capabilities.split(`,`).map(e=>e.toLowerCase().trim());if(!n)return{operations:{supportsExportMap:!1,supportsExportTiles:!1,supportsIdentify:!1,supportsQuery:!1,supportsTileMap:!1},exportMap:null,exportTiles:null};let r=this.type,i=r!==`tile`&&!!t.supportsDynamicLayers,a=n.includes(`query`),s=n.includes(`map`),c=!!t.exportTilesAllowed,l=n.includes(`tilemap`),u=n.includes(`data`),d=r!==`tile`&&(!t.tileInfo||i),f=r!==`tile`&&(!t.tileInfo||i),p=r!==`tile`,m=r!==`tile`&&i&&t.currentVersion>=11.1,h=t.cimVersion?o.parse(t.cimVersion):null,g=h?.greaterEqual(1,4)??!1,_=h?.greaterEqual(2,0)??!1;return{operations:{supportsExportMap:s,supportsExportTiles:c,supportsIdentify:a,supportsQuery:u,supportsTileMap:l},exportMap:s?{supportsArcadeExpressionForLabeling:g,supportsCIMSymbols:_,supportsDynamicLayers:i,supportsSublayerOrderBy:m,supportsSublayerDefinitionExpression:f,supportsSublayerVisibility:d,supportsSublayersChanges:p}:null,exportTiles:c?{maxExportTilesCount:+t.maxExportTilesCount}:null}}readVersion(e,t){let n=t.currentVersion;return n||=t.hasOwnProperty(`capabilities`)||t.hasOwnProperty(`tables`)?10:t.hasOwnProperty(`supportedImageFormatTypes`)?9.31:9.3,n}async fetchRelatedService(e){let t=this.portalItem;if(!t||!m(t))return null;this._relatedFeatureServicePromise||=t.fetchRelatedItems({relationshipType:`Service2Service`,direction:`reverse`},e).then(e=>e.find(e=>e.type===`Feature Service`)??null,()=>null);let n=await this._relatedFeatureServicePromise;return i(e),n?{itemId:n.id,url:n.url}:null}async fetchSublayerInfo(e,n){let{source:r}=e;if(this?.portalItem&&this.type===`tile`&&r?.type===`map-layer`&&m(this.portalItem)&&e.originIdOf(`url`)<2){let t=await this.fetchRelatedService(n);t&&(e.url=a(t.url,r.mapLayerId.toString()),e.layerItemId=t.itemId)}let{url:i}=e,o;if(r.type===`data-layer`||r.type===`workspace-layer`)o=(await t(i,{responseType:`json`,query:{f:`json`,...this.customParameters,token:this.apiKey},...n})).data;else{let t=e.id;r?.type===`map-layer`&&(t=r.mapLayerId);try{o=(await this.fetchAllLayersAndTables(n)).get(t)}catch{}if(i&&e.originIdOf(`url`)>2)try{let e=await this._fetchAllLayersAndTablesFromService(i),t=d(i)?.sublayer??r.mapLayerId,n=structuredClone(e.get(t));if(n!=null){for(let e of[`drawingInfo`,`maxScale`,`minScale`,`name`])delete n[e];o={...o,...n}}}catch{}}return o}async fetchAllLayersAndTables(e){return this._fetchAllLayersAndTablesFromService(this.parsedUrl?.path,e)}async _fetchAllLayersAndTablesFromService(e,o){await this.load(o),this._allLayersAndTablesMap||=new Map;let s=d(e),c=await r(this._allLayersAndTablesMap,s?.url.path,()=>t(a(s?.url.path,`/layers`),{query:{f:`json`,...this.customParameters,token:this.apiKey}}).then(async e=>{let r=new Map,{layers:i,tables:a}=e.data,o=[...i??[],...a??[]];for(let e of o)r.set(e.id,e);if(n(r.values(),e=>e.capabilities==null||e.extent==null)){let{data:e}=await t(s?.url.path,{query:{f:`json`,...this.customParameters,token:this.apiKey}}).catch(()=>({data:{capabilities:``,fullExtent:void 0}}));for(let t of r.values())t.capabilities??=e.capabilities??``,t.extent??=e.fullExtent}return{result:r}},e=>({error:e})));if(i(o),`result`in c)return c.result;throw c.error}};return e([s({readOnly:!0})],v.prototype,`capabilities`,void 0),e([h(`service`,`capabilities`,[`capabilities`,`cimVersion`,`currentVersion`,`exportTilesAllowed`,`maxExportTilesCount`,`supportsDynamicLayers`,`tileInfo`])],v.prototype,`readCapabilities`,null),e([s({json:{read:{source:`copyrightText`}}})],v.prototype,`copyright`,void 0),e([s({type:l})],v.prototype,`fullExtent`,void 0),e([s(f)],v.prototype,`id`,void 0),e([s({type:Boolean,json:{origins:{service:{read:{enabled:!1}}},read:{source:`showLegend`},write:{target:`showLegend`}}})],v.prototype,`legendEnabled`,void 0),e([s(p)],v.prototype,`popupEnabled`,void 0),e([s({type:u})],v.prototype,`spatialReference`,void 0),e([s({readOnly:!0})],v.prototype,`version`,void 0),e([h(`service`,`version`,[`currentVersion`,`capabilities`,`tables`,`supportedImageFormatTypes`])],v.prototype,`readVersion`,null),v=e([c(`esri.layers.mixins.ArcGISMapService`)],v),v};export{g as ArcGISMapService};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
import e from"../../request.js";import t from"../../core/Error.js";import n from"../../core/Logger.js";import{makeAbsolute as r,addQueryParameters as i,urlToObject as a}from"../../core/urlUtils.js";import o from"../../geometry/SpatialReference.js";import{wgs84 as s}from"../../geometry/support/spatialReferenceUtils.js";import{project as c}from"../../geometry/support/webMercatorUtils.js";import{convertToFeatureSet as l,convertToGeometry as u,convertFromGeometry as d}from"../graphics/featureConversionUtils.js";import f from"../graphics/OptimizedFeatureSet.js";import{validateGeoJSON as p,inferLayerProperties as m,createOptimizedFeatures as h}from"../graphics/sources/geojson/geojson.js";import{createDrawingInfo as g}from"../graphics/sources/support/clientSideDefaults.js";import{mixAttributes as _}from"../graphics/sources/support/sourceUtils.js";import v from"../support/FieldsIndex.js";import{kebabDict as y}from"../support/fieldType.js";import{utc as b}from"../../time/constants.js";const x=()=>n.getLogger(`esri.layers.ogc.ogcFeatureUtils`),S=`startindex`,C=new Set([S,`offset`]),w=`http://www.opengis.net/def/crs/`,T=`${w}OGC/1.3/CRS84`;async function E(n,a,o={},s=5){let{links:c}=n,l=U(c);if(!l)throw new t(`ogc-feature-layer:missing-items-page`,`Missing items url`);let{apiKey:u,customParameters:d,signal:f}=o,h=r(l.href,n.landingPage.url),_={limit:s,...d,token:u},C=i(h,_),{data:w}=await e(C,{signal:f,headers:{accept:`application/geo+json`}}),T=K(C,s,w.links)??S;p(w);let E=w.numberMatched,D=m(w,{geometryType:a.geometryType}),O=a.fields||D.fields||[],k=a.hasZ==null?D.hasZ:a.hasZ,A=D.geometryType,j=a.objectIdField||D.objectIdFieldName||`OBJECTID`,M=a.timeInfo,N=O.find(({name:e})=>e===j);if(N)N.editable=!1,N.nullable=!1;else{if(!D.objectIdFieldType)throw new t(`ogc-feature-layer:missing-feature-id`,`Collection geojson require a feature id as a unique identifier`);O.unshift({name:j,alias:j,type:D.objectIdFieldType===`number`?`esriFieldTypeOID`:`esriFieldTypeString`,editable:!1,nullable:!1})}if(j!==D.objectIdFieldName){let e=O.find(({name:e})=>e===D.objectIdFieldName);e&&(e.type=`esriFieldTypeInteger`)}O===D.fields&&D.unknownFields.length>0&&x().warn({name:`ogc-feature-layer:unknown-field-types`,message:`Some fields types couldn't be inferred from the features and were dropped`,details:{unknownFields:D.unknownFields}});for(let e of O){if(e.name??=e.alias,e.alias??=e.name,e.type!==`esriFieldTypeOID`&&e.type!==`esriFieldTypeGlobalID`&&(e.editable??=!0,e.nullable??=!0),!e.name)throw new t(`ogc-feature-layer:invalid-field-name`,`field name is missing`,{field:e});if(!y.jsonValues.includes(e.type))throw new t(`ogc-feature-layer:invalid-field-type`,`invalid type for field "${e.name}"`,{field:e})}if(M){let e=new v(O);if(M.startTimeField){let t=e.get(M.startTimeField);t?(M.startTimeField=t.name,t.type=`esriFieldTypeDate`):M.startTimeField=null}if(M.endTimeField){let t=e.get(M.endTimeField);t?(M.endTimeField=t.name,t.type=`esriFieldTypeDate`):M.endTimeField=null}if(M.trackIdField){let t=e.get(M.trackIdField);t?M.trackIdField=t.name:(M.trackIdField=null,x().warn({name:`ogc-feature-layer:invalid-timeInfo-trackIdField`,message:`trackIdField is missing`,details:{timeInfo:M}}))}M.timeReference||={timeZoneIANA:b},!M.startTimeField&&!M.endTimeField&&(x().warn({name:`ogc-feature-layer:invalid-timeInfo`,message:`startTimeField and endTimeField are missing`,details:{timeInfo:M}}),M=void 0)}return{drawingInfo:A?g(A):null,extent:H(n),geometryType:A,fields:O,hasZ:!!k,objectIdField:j,paginationParameter:T,timeInfo:M,featureCount:E}}async function D(n,i={}){let{links:a,url:o}=n,s=V(a);if(!s)throw new t(`ogc-feature-layer:missing-collections-page`,`Missing collections url`);let{apiKey:c,customParameters:l,signal:u}=i,d=r(s.href,o),{data:f}=await e(d,{signal:u,headers:{accept:`application/json`},query:{...l,token:c}});for(let e of f.collections)e.landingPage=n;return f}async function O(n,i={}){let{links:a,url:o}=n,s=B(a);if(!s)throw new t(`ogc-feature-layer:missing-conformance-page`,`Missing conformance url`);let{apiKey:c,customParameters:l,signal:u}=i,d=r(s.href,o),{data:f}=await e(d,{signal:u,headers:{accept:`application/json`},query:{...l,token:c}});return f}async function k(t,n={}){let{apiKey:r,customParameters:i,signal:a}=n,{data:o}=await e(t,{signal:a,headers:{accept:`application/json`},query:{...i,token:r}});return o.url=t,o}async function A(t,n={}){let{links:i,url:a}=t,o=W(i,`service-desc`,`application/vnd.oai.openapi+json;version=3.0`);if(!o)return x().warn(`ogc-feature-layer:missing-openapi-page`,`The OGC API-Features server does not have an OpenAPI page.`),null;let{apiKey:s,customParameters:c,signal:l}=n,u=r(o.href,a),{data:d}=await e(u,{signal:l,headers:{accept:`application/vnd.oai.openapi+json;version=3.0`},query:{...c,token:s}});return d}function j(e){let t=/^http:\/\/www\.opengis.net\/def\/crs\/(?<authority>.*)\/(?<version>.*)\/(?<code>.*)$/i.exec(e)?.groups;if(!t)return null;let{authority:n,code:r}=t;switch(n.toLowerCase()){case`ogc`:switch(r.toLowerCase()){case`crs27`:return o.GCS_NAD_1927.wkid;case`crs83`:return 4269;case`crs84`:case`crs84h`:return o.WGS84.wkid;default:return null}case`esri`:case`epsg`:{let e=Number.parseInt(r,10);return Number.isNaN(e)?null:e}default:return null}}async function M(e,t,n){let r=await N(e,t,n);return l(r)}async function N(n,i,a){let{collection:{links:l,landingPage:{url:p}},layerDefinition:m,maxRecordCount:g,queryParameters:{apiKey:y,customParameters:b},spatialReference:x,supportedCrs:S}=n,C=U(l);if(!C)throw new t(`ogc-feature-layer:missing-items-page`,`Missing items url`);let{geometry:w,num:T,start:E,timeExtent:D,where:O}=i;if(i.objectIds)throw new t(`ogc-feature-layer:query-by-objectids-not-supported`,`Queries with object ids are not supported`);let k=o.fromJSON(x),A=i.outSpatialReference??k,j=A.isWGS84?null:F(A,S),M=z(w,S),N=L(D),P=R(O),I=T??(E==null?g:10),B=E===0?void 0:E,{fields:V,geometryType:H,hasZ:W,objectIdField:K,paginationParameter:q}=m,J=r(C.href,p),{data:Y}=await e(J,{...a,query:{...b,...M,crs:j,datetime:N,query:P,limit:I,[q]:B,token:y},headers:{accept:`application/geo+json`}}),X=h(Y,{geometryType:H,hasZ:W,objectIdField:K}),Z=X.length===I&&!!G(Y.links??[]),Q=new v(V);for(let e of X){let t={};_(Q,t,e.attributes,!0);for(let e of Q.fields)e.nullable&&!(e.name in t)&&(t[e.name]=null);t[K]=e.attributes[K],e.attributes=t}if(!j&&A.isWebMercator){for(let e of X)if(e.geometry!=null&&H!=null){let t=u(e.geometry,H,W,!1);t.spatialReference=o.WGS84,e.geometry=d(c(t,A))}}for(let e of X)e.objectId=e.attributes[K];let ee=j||!j&&A.isWebMercator?A.toJSON():s,$=new f;return $.exceededTransferLimit=Z,$.features=X,$.fields=V,$.geometryType=H,$.hasZ=W,$.spatialReference=ee,$}function P(e){return e!=null&&e.type===`extent`}function F(e,t){let{isWebMercator:n,wkid:r,latestWkid:i}=e;if(!r&&!i)return null;let a=n?t[3857]??t[102100]??t[102113]??t[900913]:r&&t[r]||i&&t[i];return a?`${w}${a}`:null}function I(e){if(!e)return``;let{xmin:t,ymin:n,xmax:r,ymax:i}=e;return`${t},${n},${r},${i}`}function L(e){if(!e)return null;let{start:t,end:n}=e;return`${t==null?`..`:t.toISOString()}/${n==null?`..`:n.toISOString()}`}function R(e){return!e||e===`1=1`?null:e}function z(e,t){if(!P(e))return null;let{spatialReference:n}=e;if(!n||n.isWGS84)return{bbox:I(e)};let r=F(n,t);return r==null?n.isWebMercator?{bbox:I(c(e,o.WGS84))}:null:{bbox:I(e),"bbox-crs":r}}function B(e){return W(e,`conformance`,`application/json`)??W(e,`http://www.opengis.net/def/rel/ogc/1.0/conformance`,`application/json`)}function V(e){return W(e,`data`,`application/json`)??W(e,`http://www.opengis.net/def/rel/ogc/1.0/data`,`application/json`)}function H(e){let t=e.extent?.spatial;if(!t)return null;let n=t.bbox[0],r=n.length===4,[i,a]=n,s=r?void 0:n[2];return{xmin:i,ymin:a,xmax:r?n[2]:n[3],ymax:r?n[3]:n[4],zmin:s,zmax:r?void 0:n[5],spatialReference:o.WGS84.toJSON()}}function U(e){return W(e,`items`,`application/geo+json`,`http://www.opengis.net/def/profile/
|
|
2
|
+
import e from"../../request.js";import t from"../../core/Error.js";import n from"../../core/Logger.js";import{makeAbsolute as r,addQueryParameters as i,urlToObject as a}from"../../core/urlUtils.js";import o from"../../geometry/SpatialReference.js";import{wgs84 as s}from"../../geometry/support/spatialReferenceUtils.js";import{project as c}from"../../geometry/support/webMercatorUtils.js";import{convertToFeatureSet as l,convertToGeometry as u,convertFromGeometry as d}from"../graphics/featureConversionUtils.js";import f from"../graphics/OptimizedFeatureSet.js";import{validateGeoJSON as p,inferLayerProperties as m,createOptimizedFeatures as h}from"../graphics/sources/geojson/geojson.js";import{createDrawingInfo as g}from"../graphics/sources/support/clientSideDefaults.js";import{mixAttributes as _}from"../graphics/sources/support/sourceUtils.js";import v from"../support/FieldsIndex.js";import{kebabDict as y}from"../support/fieldType.js";import{utc as b}from"../../time/constants.js";const x=()=>n.getLogger(`esri.layers.ogc.ogcFeatureUtils`),S=`startindex`,C=new Set([S,`offset`]),w=`http://www.opengis.net/def/crs/`,T=`${w}OGC/1.3/CRS84`;async function E(n,a,o={},s=5){let{links:c}=n,l=U(c);if(!l)throw new t(`ogc-feature-layer:missing-items-page`,`Missing items url`);let{apiKey:u,customParameters:d,signal:f}=o,h=r(l.href,n.landingPage.url),_={limit:s,...d,token:u},C=i(h,_),{data:w}=await e(C,{signal:f,headers:{accept:`application/geo+json`}}),T=K(C,s,w.links)??S;p(w);let E=w.numberMatched,D=m(w,{geometryType:a.geometryType}),O=a.fields||D.fields||[],k=a.hasZ==null?D.hasZ:a.hasZ,A=D.geometryType,j=a.objectIdField||D.objectIdFieldName||`OBJECTID`,M=a.timeInfo,N=O.find(({name:e})=>e===j);if(N)N.editable=!1,N.nullable=!1;else{if(!D.objectIdFieldType)throw new t(`ogc-feature-layer:missing-feature-id`,`Collection geojson require a feature id as a unique identifier`);O.unshift({name:j,alias:j,type:D.objectIdFieldType===`number`?`esriFieldTypeOID`:`esriFieldTypeString`,editable:!1,nullable:!1})}if(j!==D.objectIdFieldName){let e=O.find(({name:e})=>e===D.objectIdFieldName);e&&(e.type=`esriFieldTypeInteger`)}O===D.fields&&D.unknownFields.length>0&&x().warn({name:`ogc-feature-layer:unknown-field-types`,message:`Some fields types couldn't be inferred from the features and were dropped`,details:{unknownFields:D.unknownFields}});for(let e of O){if(e.name??=e.alias,e.alias??=e.name,e.type!==`esriFieldTypeOID`&&e.type!==`esriFieldTypeGlobalID`&&(e.editable??=!0,e.nullable??=!0),!e.name)throw new t(`ogc-feature-layer:invalid-field-name`,`field name is missing`,{field:e});if(!y.jsonValues.includes(e.type))throw new t(`ogc-feature-layer:invalid-field-type`,`invalid type for field "${e.name}"`,{field:e})}if(M){let e=new v(O);if(M.startTimeField){let t=e.get(M.startTimeField);t?(M.startTimeField=t.name,t.type=`esriFieldTypeDate`):M.startTimeField=null}if(M.endTimeField){let t=e.get(M.endTimeField);t?(M.endTimeField=t.name,t.type=`esriFieldTypeDate`):M.endTimeField=null}if(M.trackIdField){let t=e.get(M.trackIdField);t?M.trackIdField=t.name:(M.trackIdField=null,x().warn({name:`ogc-feature-layer:invalid-timeInfo-trackIdField`,message:`trackIdField is missing`,details:{timeInfo:M}}))}M.timeReference||={timeZoneIANA:b},!M.startTimeField&&!M.endTimeField&&(x().warn({name:`ogc-feature-layer:invalid-timeInfo`,message:`startTimeField and endTimeField are missing`,details:{timeInfo:M}}),M=void 0)}return{drawingInfo:A?g(A):null,extent:H(n),geometryType:A,fields:O,hasZ:!!k,objectIdField:j,paginationParameter:T,timeInfo:M,featureCount:E}}async function D(n,i={}){let{links:a,url:o}=n,s=V(a);if(!s)throw new t(`ogc-feature-layer:missing-collections-page`,`Missing collections url`);let{apiKey:c,customParameters:l,signal:u}=i,d=r(s.href,o),{data:f}=await e(d,{signal:u,headers:{accept:`application/json`},query:{...l,token:c}});for(let e of f.collections)e.landingPage=n;return f}async function O(n,i={}){let{links:a,url:o}=n,s=B(a);if(!s)throw new t(`ogc-feature-layer:missing-conformance-page`,`Missing conformance url`);let{apiKey:c,customParameters:l,signal:u}=i,d=r(s.href,o),{data:f}=await e(d,{signal:u,headers:{accept:`application/json`},query:{...l,token:c}});return f}async function k(t,n={}){let{apiKey:r,customParameters:i,signal:a}=n,{data:o}=await e(t,{signal:a,headers:{accept:`application/json`},query:{...i,token:r}});return o.url=t,o}async function A(t,n={}){let{links:i,url:a}=t,o=W(i,`service-desc`,`application/vnd.oai.openapi+json;version=3.0`);if(!o)return x().warn(`ogc-feature-layer:missing-openapi-page`,`The OGC API-Features server does not have an OpenAPI page.`),null;let{apiKey:s,customParameters:c,signal:l}=n,u=r(o.href,a),{data:d}=await e(u,{signal:l,headers:{accept:`application/vnd.oai.openapi+json;version=3.0`},query:{...c,token:s}});return d}function j(e){let t=/^http:\/\/www\.opengis.net\/def\/crs\/(?<authority>.*)\/(?<version>.*)\/(?<code>.*)$/i.exec(e)?.groups;if(!t)return null;let{authority:n,code:r}=t;switch(n.toLowerCase()){case`ogc`:switch(r.toLowerCase()){case`crs27`:return o.GCS_NAD_1927.wkid;case`crs83`:return 4269;case`crs84`:case`crs84h`:return o.WGS84.wkid;default:return null}case`esri`:case`epsg`:{let e=Number.parseInt(r,10);return Number.isNaN(e)?null:e}default:return null}}async function M(e,t,n){let r=await N(e,t,n);return l(r)}async function N(n,i,a){let{collection:{links:l,landingPage:{url:p}},layerDefinition:m,maxRecordCount:g,queryParameters:{apiKey:y,customParameters:b},spatialReference:x,supportedCrs:S}=n,C=U(l);if(!C)throw new t(`ogc-feature-layer:missing-items-page`,`Missing items url`);let{geometry:w,num:T,start:E,timeExtent:D,where:O}=i;if(i.objectIds)throw new t(`ogc-feature-layer:query-by-objectids-not-supported`,`Queries with object ids are not supported`);let k=o.fromJSON(x),A=i.outSpatialReference??k,j=A.isWGS84?null:F(A,S),M=z(w,S),N=L(D),P=R(O),I=T??(E==null?g:10),B=E===0?void 0:E,{fields:V,geometryType:H,hasZ:W,objectIdField:K,paginationParameter:q}=m,J=r(C.href,p),{data:Y}=await e(J,{...a,query:{...b,...M,crs:j,datetime:N,query:P,limit:I,[q]:B,token:y},headers:{accept:`application/geo+json`}}),X=h(Y,{geometryType:H,hasZ:W,objectIdField:K}),Z=X.length===I&&!!G(Y.links??[]),Q=new v(V);for(let e of X){let t={};_(Q,t,e.attributes,!0);for(let e of Q.fields)e.nullable&&!(e.name in t)&&(t[e.name]=null);t[K]=e.attributes[K],e.attributes=t}if(!j&&A.isWebMercator){for(let e of X)if(e.geometry!=null&&H!=null){let t=u(e.geometry,H,W,!1);t.spatialReference=o.WGS84,e.geometry=d(c(t,A))}}for(let e of X)e.objectId=e.attributes[K];let ee=j||!j&&A.isWebMercator?A.toJSON():s,$=new f;return $.exceededTransferLimit=Z,$.features=X,$.fields=V,$.geometryType=H,$.hasZ=W,$.spatialReference=ee,$}function P(e){return e!=null&&e.type===`extent`}function F(e,t){let{isWebMercator:n,wkid:r,latestWkid:i}=e;if(!r&&!i)return null;let a=n?t[3857]??t[102100]??t[102113]??t[900913]:r&&t[r]||i&&t[i];return a?`${w}${a}`:null}function I(e){if(!e)return``;let{xmin:t,ymin:n,xmax:r,ymax:i}=e;return`${t},${n},${r},${i}`}function L(e){if(!e)return null;let{start:t,end:n}=e;return`${t==null?`..`:t.toISOString()}/${n==null?`..`:n.toISOString()}`}function R(e){return!e||e===`1=1`?null:e}function z(e,t){if(!P(e))return null;let{spatialReference:n}=e;if(!n||n.isWGS84)return{bbox:I(e)};let r=F(n,t);return r==null?n.isWebMercator?{bbox:I(c(e,o.WGS84))}:null:{bbox:I(e),"bbox-crs":r}}function B(e){return W(e,`conformance`,`application/json`)??W(e,`http://www.opengis.net/def/rel/ogc/1.0/conformance`,`application/json`)}function V(e){return W(e,`data`,`application/json`)??W(e,`http://www.opengis.net/def/rel/ogc/1.0/data`,`application/json`)}function H(e){let t=e.extent?.spatial;if(!t)return null;let n=t.bbox[0],r=n.length===4,[i,a]=n,s=r?void 0:n[2];return{xmin:i,ymin:a,xmax:r?n[2]:n[3],ymax:r?n[3]:n[4],zmin:s,zmax:r?void 0:n[5],spatialReference:o.WGS84.toJSON()}}function U(e){return W(e,`items`,`application/geo+json`,`http://www.opengis.net/def/profile/OGC/0/rfc7946`)??W(e,`http://www.opengis.net/def/rel/ogc/1.0/items`,`application/geo+json`,`http://www.opengis.net/def/profile/OGC/0/rfc7946`)}function W(e,t,n,r){return r?e.find(({rel:e,type:i,profile:a})=>e===t&&i===n&&a?.some(e=>e.toLowerCase()===r.toLowerCase()))??e.find(({rel:e,type:r,profile:i})=>e===t&&r===n&&!i):e.find(({rel:e,type:r})=>e===t&&r===n)??e.find(({rel:e,type:n})=>e===t&&!n)}function G(e){return W(e,`next`,`application/geo+json`)}function K(e,t,n){if(!n)return;let r=G(n),i=a(r?.href)?.query;if(!i)return;let o=a(e).query,s=Object.keys(o??{});return Object.entries(i).filter(([e])=>!s.includes(e)).find(([e,n])=>C.has(e.toLowerCase())&&Number.parseInt(n,10)===t)?.[0]}export{T as crsDefault,w as crsPrefix,E as getCollectionDefinition,U as getItemsLink,D as getServerCollectionsPage,O as getServerConformance,k as getServerLandingPage,A as getServerOpenApi,j as getSpatialReferenceWkid,M as queryFeatureSetJSON,N as queryOptimizedFeatureSet};
|
|
@@ -16,6 +16,7 @@ import type OrderByInfo from "./OrderByInfo.js";
|
|
|
16
16
|
import type Relationship from "./Relationship.js";
|
|
17
17
|
import type DynamicDataLayer from "../../rest/layerSources/DynamicDataLayer.js";
|
|
18
18
|
import type DynamicMapLayer from "../../rest/layerSources/DynamicMapLayer.js";
|
|
19
|
+
import type DynamicWorkspaceLayer from "../../rest/layerSources/DynamicWorkspaceLayer.js";
|
|
19
20
|
import type AttachmentInfo from "../../rest/query/support/AttachmentInfo.js";
|
|
20
21
|
import type FeatureSet from "../../rest/support/FeatureSet.js";
|
|
21
22
|
import type Query from "../../rest/support/Query.js";
|
|
@@ -46,6 +47,7 @@ import type { DotDensityRendererProperties } from "../../renderers/DotDensityRen
|
|
|
46
47
|
import type { UniqueValueRendererProperties } from "../../renderers/UniqueValueRenderer.js";
|
|
47
48
|
import type { ClassBreaksRendererProperties } from "../../renderers/ClassBreaksRenderer.js";
|
|
48
49
|
import type { SimpleRendererProperties } from "../../renderers/SimpleRenderer.js";
|
|
50
|
+
import type { DynamicWorkspaceLayerProperties } from "../../rest/layerSources/DynamicWorkspaceLayer.js";
|
|
49
51
|
import type { DynamicDataLayerProperties } from "../../rest/layerSources/DynamicDataLayer.js";
|
|
50
52
|
import type { DynamicMapLayerProperties } from "../../rest/layerSources/DynamicMapLayer.js";
|
|
51
53
|
|
|
@@ -202,11 +204,17 @@ export interface SublayerProperties extends LoadableMixinProperties, Identifiabl
|
|
|
202
204
|
/**
|
|
203
205
|
* An object that allows you to create a dynamic layer with data
|
|
204
206
|
* either from the map service sublayers or data from a registered workspace.
|
|
205
|
-
*
|
|
206
|
-
* for creating dynamic layers from
|
|
207
|
-
* rendering, labeling, and filtering (definition expressions).
|
|
208
|
-
*
|
|
209
|
-
*
|
|
207
|
+
*
|
|
208
|
+
* Use [DynamicMapLayer](https://developers.arcgis.com/javascript/latest/references/core/rest/layerSources/DynamicMapLayer/) for creating dynamic layers from
|
|
209
|
+
* map service layers for on the fly rendering, labeling, and filtering (definition expressions).
|
|
210
|
+
*
|
|
211
|
+
* Use [DynamicDataLayer](https://developers.arcgis.com/javascript/latest/references/core/rest/layerSources/DynamicDataLayer/) for creating dynamic layers from other sources in registered
|
|
212
|
+
* workspaces such as tables and table joins.
|
|
213
|
+
*
|
|
214
|
+
* Use [DynamicWorkspaceLayer](https://developers.arcgis.com/javascript/latest/references/core/rest/layerSources/DynamicWorkspaceLayer/) for creating dynamic layers from pre-authored Layer Files (.lyrx) in registered workspaces.
|
|
215
|
+
*
|
|
216
|
+
* > [!WARNING]
|
|
217
|
+
* > Sublayers with a [DynamicWorkspaceLayer](https://developers.arcgis.com/javascript/latest/references/core/rest/layerSources/DynamicWorkspaceLayer/) source cannot be [saved](https://developers.arcgis.com/javascript/latest/references/core/WebMap/#save) to web maps.
|
|
210
218
|
*
|
|
211
219
|
* @example
|
|
212
220
|
* // Creates two sublayers that point to the same map service layer.
|
|
@@ -238,7 +246,7 @@ export interface SublayerProperties extends LoadableMixinProperties, Identifiabl
|
|
|
238
246
|
* }]
|
|
239
247
|
* });
|
|
240
248
|
*/
|
|
241
|
-
source?: (DynamicMapLayerProperties & { type: "map-layer" }) | (DynamicDataLayerProperties & { type: "data-layer" });
|
|
249
|
+
source?: (DynamicMapLayerProperties & { type: "map-layer" }) | (DynamicDataLayerProperties & { type: "data-layer" }) | (DynamicWorkspaceLayerProperties & { type: "workspace-layer" });
|
|
242
250
|
/**
|
|
243
251
|
* If a sublayer contains sublayers, this
|
|
244
252
|
* property is a [Collection](https://developers.arcgis.com/javascript/latest/references/core/core/Collection/) of [Sublayer](https://developers.arcgis.com/javascript/latest/references/core/layers/support/Sublayer/)
|
|
@@ -463,7 +471,7 @@ export default class Sublayer extends SublayerSuperclass {
|
|
|
463
471
|
* @see [loadStatus](https://developers.arcgis.com/javascript/latest/references/core/layers/support/Sublayer/#loadStatus)
|
|
464
472
|
* @example
|
|
465
473
|
* // print the first Sublayer's first field to the console
|
|
466
|
-
* console.log(mapImageLayer.sublayers.
|
|
474
|
+
* console.log(mapImageLayer.sublayers.at(0).fields[0]);
|
|
467
475
|
*
|
|
468
476
|
* // OUTPUT:
|
|
469
477
|
* alias: "OBJECTID"
|
|
@@ -487,7 +495,7 @@ export default class Sublayer extends SublayerSuperclass {
|
|
|
487
495
|
* @see [fields](https://developers.arcgis.com/javascript/latest/references/core/layers/support/Sublayer/#fields)
|
|
488
496
|
* @example
|
|
489
497
|
* // lookup a field by name, name is case-insensitive
|
|
490
|
-
* const fieldsIndex = mapImageLayer.sublayers.
|
|
498
|
+
* const fieldsIndex = mapImageLayer.sublayers.at(0).fieldsIndex.get("OBjecTID");
|
|
491
499
|
*
|
|
492
500
|
* // if there's a field by that name, print it to the console
|
|
493
501
|
* if (fieldsIndex) {
|
|
@@ -839,11 +847,17 @@ export default class Sublayer extends SublayerSuperclass {
|
|
|
839
847
|
/**
|
|
840
848
|
* An object that allows you to create a dynamic layer with data
|
|
841
849
|
* either from the map service sublayers or data from a registered workspace.
|
|
842
|
-
*
|
|
843
|
-
* for creating dynamic layers from
|
|
844
|
-
* rendering, labeling, and filtering (definition expressions).
|
|
845
|
-
*
|
|
846
|
-
*
|
|
850
|
+
*
|
|
851
|
+
* Use [DynamicMapLayer](https://developers.arcgis.com/javascript/latest/references/core/rest/layerSources/DynamicMapLayer/) for creating dynamic layers from
|
|
852
|
+
* map service layers for on the fly rendering, labeling, and filtering (definition expressions).
|
|
853
|
+
*
|
|
854
|
+
* Use [DynamicDataLayer](https://developers.arcgis.com/javascript/latest/references/core/rest/layerSources/DynamicDataLayer/) for creating dynamic layers from other sources in registered
|
|
855
|
+
* workspaces such as tables and table joins.
|
|
856
|
+
*
|
|
857
|
+
* Use [DynamicWorkspaceLayer](https://developers.arcgis.com/javascript/latest/references/core/rest/layerSources/DynamicWorkspaceLayer/) for creating dynamic layers from pre-authored Layer Files (.lyrx) in registered workspaces.
|
|
858
|
+
*
|
|
859
|
+
* > [!WARNING]
|
|
860
|
+
* > Sublayers with a [DynamicWorkspaceLayer](https://developers.arcgis.com/javascript/latest/references/core/rest/layerSources/DynamicWorkspaceLayer/) source cannot be [saved](https://developers.arcgis.com/javascript/latest/references/core/WebMap/#save) to web maps.
|
|
847
861
|
*
|
|
848
862
|
* @example
|
|
849
863
|
* // Creates two sublayers that point to the same map service layer.
|
|
@@ -875,8 +889,8 @@ export default class Sublayer extends SublayerSuperclass {
|
|
|
875
889
|
* }]
|
|
876
890
|
* });
|
|
877
891
|
*/
|
|
878
|
-
get source(): DynamicMapLayer | DynamicDataLayer;
|
|
879
|
-
set source(value: (DynamicMapLayerProperties & { type: "map-layer" }) | (DynamicDataLayerProperties & { type: "data-layer" }));
|
|
892
|
+
get source(): DynamicMapLayer | DynamicDataLayer | DynamicWorkspaceLayer;
|
|
893
|
+
set source(value: (DynamicMapLayerProperties & { type: "map-layer" }) | (DynamicDataLayerProperties & { type: "data-layer" }) | (DynamicWorkspaceLayerProperties & { type: "workspace-layer" }));
|
|
880
894
|
/**
|
|
881
895
|
* The [map service's metadata JSON](https://developers.arcgis.com/rest/services-reference/map-service.htm)
|
|
882
896
|
* exposed by the ArcGIS REST API. While most commonly used properties
|