@arcgis/core 4.28.0-next.20230721 → 4.28.0-next.20230724
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/applications/SceneViewer/devEnvironmentUtils.d.ts +4 -0
- package/applications/SceneViewer/devEnvironmentUtils.js +5 -0
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/83f65d80d5adf7539cdf.js +1 -0
- package/assets/esri/themes/base/widgets/_Daylight.scss +1 -2
- 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/core/devEnvironmentUtils.js +1 -1
- package/interfaces.d.ts +29 -1
- package/layers/KnowledgeGraphLayer.js +1 -1
- package/layers/LinkChartLayer.js +1 -1
- package/layers/knowledgeGraph/KnowledgeGraphLayerDataManager.js +1 -1
- package/package.json +1 -1
- package/support/revision.js +1 -1
- package/views/2d/engine/vectorTiles/VectorTile.js +1 -1
- package/views/2d/engine/vectorTiles/VectorTileContainer.js +1 -1
- package/views/2d/engine/vectorTiles/decluttering/SymbolFader.js +1 -1
- package/views/2d/layers/VectorTileLayerView2D.js +1 -1
- package/widgets/Daylight/css.js +1 -1
- package/widgets/Daylight.js +1 -1
- package/widgets/Editor/workflowUtils.js +1 -1
- package/widgets/ElevationProfile/components/Legend.js +1 -1
- package/widgets/ElevationProfile/components/SettingsButton.js +1 -1
- package/widgets/ElevationProfile.js +1 -1
- package/widgets/Legend/styles/Card.js +1 -1
- package/widgets/Legend/styles/Classic.js +1 -1
- package/widgets/Slider/css.js +5 -0
- package/widgets/Slider.js +1 -1
- package/assets/esri/core/workers/chunks/a54ec9929a7db879d5db.js +0 -1
- package/layers/orientedImagery/urlUtils.js +0 -5
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.28/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
function c(c){return c=c||globalThis.location.hostname,
|
|
5
|
+
function c(c){return c=c||globalThis.location.hostname,l.some((a=>null!=c?.match(a)))}function a(c,a){return c&&(a=a||globalThis.location.hostname)?null!=a.match(t)||null!=a.match(s)?c.replace("static.arcgis.com","staticdev.arcgis.com"):null!=a.match(o)||null!=a.match(i)?c.replace("static.arcgis.com","staticqa.arcgis.com"):c:c}const t=/^devext.arcgis.com$/,o=/^qaext.arcgis.com$/,s=/^[\w-]*\.mapsdevext.arcgis.com$/,i=/^[\w-]*\.mapsqa.arcgis.com$/,l=[/^([\w-]*\.)?[\w-]*\.zrh-dev-local.esri.com$/,t,o,/^jsapps.esri.com$/,s,i];export{a as adjustStaticAGOUrl,l as devHostnames,c as isDevEnvironment};
|
package/interfaces.d.ts
CHANGED
|
@@ -927,6 +927,28 @@ declare namespace __esri {
|
|
|
927
927
|
|
|
928
928
|
export const SceneViewerColorUtils: SceneViewerColorUtils;
|
|
929
929
|
|
|
930
|
+
/**
|
|
931
|
+
* Note: reserved for internal use only, this is not part of the stable public API.
|
|
932
|
+
*
|
|
933
|
+
* Development environment utilities used in the SceneViewer.
|
|
934
|
+
*/
|
|
935
|
+
interface devEnvironmentUtils {
|
|
936
|
+
/**
|
|
937
|
+
* Note: reserved for internal use only, this is not part of the stable public API.
|
|
938
|
+
*
|
|
939
|
+
* Check if we are running in a dev environment.
|
|
940
|
+
*/
|
|
941
|
+
isDevEnvironment(hostname: string): boolean;
|
|
942
|
+
/**
|
|
943
|
+
* Note: reserved for internal use only, this is not part of the stable public API.
|
|
944
|
+
*
|
|
945
|
+
* Checks whether for telemetry logging purposes, we are running in a development environment.
|
|
946
|
+
*/
|
|
947
|
+
isTelemetryDevEnvironment(hostname: string): boolean;
|
|
948
|
+
}
|
|
949
|
+
|
|
950
|
+
export const devEnvironmentUtils: devEnvironmentUtils;
|
|
951
|
+
|
|
930
952
|
/**
|
|
931
953
|
* Note: reserved for internal use only, this is not part of the stable public API.
|
|
932
954
|
*
|
|
@@ -4135,7 +4157,7 @@ declare namespace __esri {
|
|
|
4135
4157
|
*
|
|
4136
4158
|
* [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-form-elements-RelationshipElement.html#relationshipId)
|
|
4137
4159
|
*/
|
|
4138
|
-
|
|
4160
|
+
relationshipId: number;
|
|
4139
4161
|
/**
|
|
4140
4162
|
* Indicates the type of form [element](https://developers.arcgis.com/javascript/latest/api-reference/esri-form-elements-Element.html).
|
|
4141
4163
|
*
|
|
@@ -4186,6 +4208,12 @@ declare namespace __esri {
|
|
|
4186
4208
|
* [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-form-elements-RelationshipElement.html#orderByFields)
|
|
4187
4209
|
*/
|
|
4188
4210
|
orderByFields?: RelatedRecordsInfoFieldOrderProperties[];
|
|
4211
|
+
/**
|
|
4212
|
+
* The numeric id value for the defined relationship.
|
|
4213
|
+
*
|
|
4214
|
+
* [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-form-elements-RelationshipElement.html#relationshipId)
|
|
4215
|
+
*/
|
|
4216
|
+
relationshipId?: number;
|
|
4189
4217
|
/**
|
|
4190
4218
|
* Indicates the type of form [element](https://developers.arcgis.com/javascript/latest/api-reference/esri-form-elements-Element.html).
|
|
4191
4219
|
*
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.28/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../chunks/tslib.es6.js";import i from"../core/Collection.js";import t from"../core/Error.js";import
|
|
5
|
+
import{_ as e}from"../chunks/tslib.es6.js";import i from"../core/Collection.js";import t from"../core/Error.js";import a from"../core/Logger.js";import{property as o}from"../core/accessorSupport/decorators/property.js";import"../core/accessorSupport/ensureType.js";import"../core/arrayUtils.js";import"../core/has.js";import{subclass as s}from"../core/accessorSupport/decorators/subclass.js";import n from"./Layer.js";import{KnowledgeGraphLayerDataManager as r}from"./knowledgeGraph/KnowledgeGraphLayerDataManager.js";import p from"./knowledgeGraph/KnowledgeGraphSublayer.js";import{BlendLayer as h}from"./mixins/BlendLayer.js";import{ScaleRangeLayer as d}from"./mixins/ScaleRangeLayer.js";import{fetchKnowledgeGraph as l}from"../rest/knowledgeGraphService.js";import y from"../rest/knowledgeGraph/EntityType.js";import m from"../rest/knowledgeGraph/RelationshipType.js";const c=(e,i,t)=>(e.has(i)||e.set(i,t()),e.get(i));let g=class extends(h(d(n))){constructor(e){super(e),this._graphTypeLookup=new Map,this.knowledgeGraph=null,this.layers=new i,this.memberEntityTypes=null,this.memberRelationshipTypes=null,this.sublayerIdsCache=new Map,this.tables=new i,this.type="knowledge-graph",this._originalInclusionList=e.inclusionModeDefinition}normalizeCtorArgs(e){return{url:e.url,title:e.title}}_initializeLayerProperties(e){const i=new Set;let o=[],s=[];if(e.inclusionModeDefinition&&(!e.inclusionModeDefinition.namedTypeDefinitions||e.inclusionModeDefinition.namedTypeDefinitions.size<1))throw new t("knowledge-graph:composite-layer-constructor","If an explicit inclusion definition is defined, at least one namedTypeDefinition must also be defined");e.knowledgeGraph.dataModel.entityTypes?.forEach((e=>{e.name&&this._graphTypeLookup.set(e.name,e)})),e.knowledgeGraph.dataModel.relationshipTypes?.forEach((e=>{e.name&&this._graphTypeLookup.set(e.name,e)})),e.inclusionModeDefinition?.generateAllSublayers?(o=e.knowledgeGraph.dataModel.entityTypes??[],s=e.knowledgeGraph.dataModel.relationshipTypes??[]):e.inclusionModeDefinition?.namedTypeDefinitions&&e.inclusionModeDefinition?.namedTypeDefinitions.size>0?e.inclusionModeDefinition?.namedTypeDefinitions.forEach(((t,n)=>{if(!this._graphTypeLookup.get(n))return a.getLogger(this).warn(`A named type, ${n}, was in the inclusion list that wasn't in the data model and will be removed`),void e.inclusionModeDefinition?.namedTypeDefinitions.delete(n);this._graphTypeLookup.get(n)instanceof m||"strictOrigin"in this._graphTypeLookup.get(n)?i.has(n)||(i.add(n),s.push(this._graphTypeLookup.get(n))):this._graphTypeLookup.get(n)instanceof y||"properties"in this._graphTypeLookup.get(n)?i.has(n)||(i.add(n),o.push(this._graphTypeLookup.get(n))):(a.getLogger(this).warn(`A named type, ${n}, was in the inclusion list that wasn't properly modeled and will be removed`),e.inclusionModeDefinition?.namedTypeDefinitions.delete(n))})):(o=e.knowledgeGraph.dataModel.entityTypes??[],s=e.knowledgeGraph.dataModel.relationshipTypes??[]);const n=new r({knowledgeGraph:e.knowledgeGraph,inclusionModeDefinition:e.inclusionModeDefinition});this.knowledgeGraph=e.knowledgeGraph,this.memberEntityTypes=o,this.memberRelationshipTypes=s,this.dataManager=n}load(){return this.addResolvingPromise(l(this.url).then((e=>{this._initializeLayerProperties({knowledgeGraph:e,inclusionModeDefinition:this._originalInclusionList}),this.loadLayerAssumingLocalCache()}))),Promise.resolve(this)}async _handleNewRecords(e){const i=[];this.dataManager.addToLayer(e);for(const t of e)this.sublayerIdsCache.has(t.typeName)||(this.sublayerIdsCache.set(t.typeName,new Set),i.push(t.typeName)),this.sublayerIdsCache.get(t.typeName).add(t.id);for(const t of i)if(this._graphTypeLookup.has(t)){const e=this._graphTypeLookup.get(t),i="endPoints"in e?"relationship":"entity",a=new p({objectType:e,parentCompositeLayer:this,graphType:i,title:t});"entity"===i?this.dataManager.entityTypeNames.add(t):this.dataManager.relationshipTypeNames.add(t),a.geometryType?this.layers.push(a):this.tables.push(a),this.dataManager.sublayerCaches.set(t,new Map)}this.layers.forEach((e=>{e.emit("refresh",{dataChanged:!0})}))}loadLayerAssumingLocalCache(){this.memberEntityTypes.forEach((e=>{const i=new p({objectType:e,parentCompositeLayer:this,graphType:"entity",title:e.name});i.geometryType?this.layers.push(i):this.tables.push(i),this.dataManager.sublayerCaches.has(e.name)||this.dataManager.sublayerCaches.set(e.name,new Map)})),this.memberRelationshipTypes.forEach((e=>{const i=new p({objectType:e,parentCompositeLayer:this,graphType:"relationship",title:e.name});i.geometryType?this.layers.push(i):this.tables.push(i),this.dataManager.sublayerCaches.has(e.name)||this.dataManager.sublayerCaches.set(e.name,new Map)})),this.dataManager.inclusionModeDefinition?.namedTypeDefinitions&&this.dataManager.inclusionModeDefinition?.namedTypeDefinitions.forEach(((e,i)=>{const t=c(this.sublayerIdsCache,i,(()=>new Set));e.members?.forEach((e=>{t.add(e.id)}))}))}async addRecords(e){await this._handleNewRecords(e)}async removeRecords(e){const i=[];for(const t of e)!1===this.dataManager.inclusionModeDefinition?.namedTypeDefinitions?.get(t.typeName)?.useAllData&&this.dataManager.inclusionModeDefinition?.namedTypeDefinitions?.get(t.typeName)?.members?.has(t.id)&&i.push(t);this.dataManager.removeFromLayer(i);for(const t of i)this.sublayerIdsCache.get(t.typeName)?.delete(t.id);return this.layers.forEach((e=>{e.emit("refresh",{dataChanged:!0})})),i}};e([o()],g.prototype,"dataManager",void 0),e([o()],g.prototype,"knowledgeGraph",void 0),e([o()],g.prototype,"layers",void 0),e([o()],g.prototype,"memberEntityTypes",void 0),e([o()],g.prototype,"memberRelationshipTypes",void 0),e([o()],g.prototype,"sublayerIdsCache",void 0),e([o()],g.prototype,"tables",void 0),e([o({json:{read:!1}})],g.prototype,"type",void 0),g=e([s("esri.layers.KnowledgeGraphLayer")],g);const u=g;export{u as default};
|
package/layers/LinkChartLayer.js
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.28/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../chunks/tslib.es6.js";import"../geometry.js";import t from"../core/Collection.js";import a from"../core/Error.js";import i from"../core/Logger.js";import{throwIfAborted as o}from"../core/promiseUtils.js";import{property as n}from"../core/accessorSupport/decorators/property.js";import"../core/accessorSupport/ensureType.js";import"../core/arrayUtils.js";import"../core/has.js";import{subclass as r}from"../core/accessorSupport/decorators/subclass.js";import{encodeGeohash as s}from"../geohash/geohashUtils.js";import h from"./Layer.js";import{convertFromGeometry as l}from"./graphics/featureConversionUtils.js";import c from"./graphics/OptimizedGeometry.js";import{KnowledgeGraphLayerDataManager as p,MOCK_OID_FIELD_NAME as d,MOCK_ORIGIN_ID_FIELD_NAME as u,MOCK_DESTINATION_ID_FIELD_NAME as y,MOCK_LAYOUT_GEOMETRY_FIELD_NAME as m,GEOHASH_ENCODING_PRECISION as f}from"./knowledgeGraph/KnowledgeGraphLayerDataManager.js";import g from"./knowledgeGraph/KnowledgeGraphSublayer.js";import{BlendLayer as k}from"./mixins/BlendLayer.js";import{ScaleRangeLayer as C}from"./mixins/ScaleRangeLayer.js";import{LCSimpleLayout as L,LCSmartTreeLayout as b,LCRadialTreeLayout as M,LCHierarchicalLayout as w,LCCommunityLayout as x,LCForceDirectedLayout as E,NodeFlag as D,load as T}from"../libs/linkchartlayout/LinkChartLayout.js";import{fetchKnowledgeGraph as G}from"../rest/knowledgeGraphService.js";import I from"../rest/knowledgeGraph/EntityType.js";import A from"../rest/knowledgeGraph/RelationshipType.js";import N from"../geometry/Extent.js";import R from"../geometry/Point.js";import _ from"../geometry/Polyline.js";const v=(e,t,a)=>(e.has(t)||e.set(t,a()),e.get(t));let j=class extends(k(C(h))){constructor(e){if(super(e),this.dataPreloadedInLocalCache=!1,this.defaultLinkChartConfig=null,this._currentLinkChartConfig={layoutMode:"RADIAL_TREE",xScaleFactor:1,yScaleFactor:1},this._graphTypeLookup=new Map,this.knowledgeGraph=null,this.layers=new t,this.linkChartDiagramLookup=new Map,this.linkChartExtent=new N({xmin:-1e-7,ymin:-1e-7,xmax:1e-7,ymax:1e-7}),this.linkChartGeohashLookup=new Map,this.memberEntityTypes=null,this.memberRelationshipTypes=null,this.sublayerIdsCache=new Map,this.tables=new t,this.type="link-chart",this._originalInclusionList=e.inclusionModeDefinition,e.dataPreloadedInLocalCache&&!e.inclusionModeDefinition)throw new a("knowledge-graph:linkchart-layer-constructor","If creating a link chart composite layer and configured that data is already loaded in the cache, you must specify an inclusion list so the Composite Layer knows what records belong to it")}normalizeCtorArgs(e){return{url:e.url,title:e.title,dataPreloadedInLocalCache:e.dataPreloadedInLocalCache,defaultLinkChartConfig:e.defaultLinkChartConfig}}_initializeLayerProperties(e){if(!this.title&&this.url){const e=this.url.split("/");this.title=e[e.length-2]}const t=new Set;let o=[],n=[];if(e.inclusionModeDefinition&&(!e.inclusionModeDefinition.namedTypeDefinitions||e.inclusionModeDefinition.namedTypeDefinitions.size<1))throw new a("knowledge-graph:composite-layer-constructor","If an explicit inclusion definition is defined, at least one namedTypeDefinition must also be defined");e.knowledgeGraph.dataModel.entityTypes?.forEach((e=>{e.name&&this._graphTypeLookup.set(e.name,e)})),e.knowledgeGraph.dataModel.relationshipTypes?.forEach((e=>{e.name&&this._graphTypeLookup.set(e.name,e)})),e.inclusionModeDefinition?.generateAllSublayers?(o=e.knowledgeGraph.dataModel.entityTypes??[],n=e.knowledgeGraph.dataModel.relationshipTypes??[]):e.inclusionModeDefinition?.namedTypeDefinitions&&e.inclusionModeDefinition?.namedTypeDefinitions.size>0?e.inclusionModeDefinition?.namedTypeDefinitions.forEach(((a,r)=>{if(!this._graphTypeLookup.get(r))return i.getLogger(this).warn(`A named type, ${r}, was in the inclusion list that wasn't in the data model and will be removed`),void e.inclusionModeDefinition?.namedTypeDefinitions.delete(r);this._graphTypeLookup.get(r)instanceof A||"strictOrigin"in this._graphTypeLookup.get(r)?t.has(r)||(t.add(r),n.push(this._graphTypeLookup.get(r))):this._graphTypeLookup.get(r)instanceof I||"properties"in this._graphTypeLookup.get(r)?t.has(r)||(t.add(r),o.push(this._graphTypeLookup.get(r))):(i.getLogger(this).warn(`A named type, ${r}, was in the inclusion list that wasn't properly modeled and will be removed`),e.inclusionModeDefinition?.namedTypeDefinitions.delete(r))})):(o=e.knowledgeGraph.dataModel.entityTypes??[],n=e.knowledgeGraph.dataModel.relationshipTypes??[]);const r=new p({knowledgeGraph:e.knowledgeGraph,inclusionModeDefinition:e.inclusionModeDefinition});this.knowledgeGraph=e.knowledgeGraph,this.memberEntityTypes=o,this.memberRelationshipTypes=n,this.dataManager=r}load(e){return this.addResolvingPromise(new Promise((t=>{G(this.url).then((a=>{if(this._initializeLayerProperties({knowledgeGraph:a,inclusionModeDefinition:this._originalInclusionList}),this.dataManager.inclusionModeDefinition?.namedTypeDefinitions?.size||(this.dataManager.inclusionModeDefinition={generateAllSublayers:!1,namedTypeDefinitions:new Map},this.dataManager.knowledgeGraph.dataModel.entityTypes?.forEach((e=>{e.name&&this.dataManager.inclusionModeDefinition?.namedTypeDefinitions.set(e.name,{useAllData:!0})})),this.dataManager.knowledgeGraph.dataModel.relationshipTypes?.forEach((e=>{e.name&&this.dataManager.inclusionModeDefinition?.namedTypeDefinitions.set(e.name,{useAllData:!0})}))),this.dataPreloadedInLocalCache)this.loadLayerAssumingLocalCache(),this.dataManager.inclusionModeDefinition&&(this.dataManager.inclusionModeDefinition.generateAllSublayers=!1),this.dataManager.inclusionModeDefinition?.namedTypeDefinitions.forEach((e=>{e.useAllData=!1,e.members?.forEach((e=>{let t;t=e.linkChartLocation instanceof c?e.linkChartLocation:e.linkChartLocation?l(e.linkChartLocation):null,this.linkChartDiagramLookup.set(e.id,t),t&&2===t.coords.length&&0===t.lengths.length?this.linkChartGeohashLookup.set(e.id,s(t.coords[1],t.coords[0],f)):this.linkChartGeohashLookup.set(e.id,"")})),this.addResolvingPromise(this._initializeDiagram().then((async()=>{this.layers.forEach((async e=>{await e.refreshCachedQueryEngine()})),this.tables.forEach((async e=>{await e.refreshCachedQueryEngine()}))})))}));else{const t="GEOGRAPHIC"===this.defaultLinkChartConfig?.layoutMode;this.addResolvingPromise(this.dataManager.refreshCacheContent(void 0,!1,t,!0).then((async()=>{o(e);const t=[],a=[];this.loadLayerAssumingLocalCache(),this.dataManager.inclusionModeDefinition&&(this.dataManager.inclusionModeDefinition.generateAllSublayers=!1,this.dataManager.inclusionModeDefinition.namedTypeDefinitions.forEach((e=>{e.useAllData=!1}))),await this._initializeDiagram(),this.layers.forEach((e=>{a.push(e.refreshCachedQueryEngine()),t.push(new Promise((t=>{e.on("layerview-create",(()=>{t(null)}))})))})),this.tables.forEach((e=>{a.push(e.refreshCachedQueryEngine())})),await Promise.all(a)})))}t(null)}))}))),Promise.resolve(this)}async addRecords(e){await this._handleNewRecords(e)}async expand(e){const t=await this.dataManager.getConnectedRecordIds(e),a=t.filter((e=>!this.sublayerIdsCache.get(e.typeName)?.has(e.id)));return await this._handleNewRecords(t),{records:a}}loadLayerAssumingLocalCache(){this.memberRelationshipTypes.forEach((e=>{const t=new g({objectType:e,parentCompositeLayer:this,graphType:"relationship",title:e.name});t.geometryType?this.layers.push(t):this.tables.push(t),this.dataManager.sublayerCaches.has(e.name)||this.dataManager.sublayerCaches.set(e.name,new Map)})),this.memberEntityTypes.forEach((e=>{const t=new g({objectType:e,parentCompositeLayer:this,graphType:"entity",title:e.name});t.geometryType?this.layers.push(t):this.tables.push(t),this.dataManager.sublayerCaches.has(e.name)||this.dataManager.sublayerCaches.set(e.name,new Map)})),this.dataManager.inclusionModeDefinition?.namedTypeDefinitions&&this.dataManager.inclusionModeDefinition?.namedTypeDefinitions.forEach(((e,t)=>{const a=v(this.sublayerIdsCache,t,(()=>new Set));e.members?.forEach((e=>{if(a.add(e.id),e.linkChartLocation)if(e.linkChartLocation instanceof c)this.linkChartDiagramLookup.set(e.id,e.linkChartLocation),2===e.linkChartLocation.coords.length&&0===e.linkChartLocation.lengths.length?this.linkChartGeohashLookup.set(e.id,s(e.linkChartLocation.coords[1],e.linkChartLocation.coords[0],f)):this.linkChartGeohashLookup.set(e.id,"");else{const t=l(e.linkChartLocation);this.linkChartDiagramLookup.set(e.id,e.linkChartLocation?t:null),"x"in e.linkChartLocation&&"y"in e.linkChartLocation?this.linkChartGeohashLookup.set(e.id,s(e.linkChartLocation.x,e.linkChartLocation.y,f)):this.linkChartGeohashLookup.set(e.id,"")}}))}))}async calculateLinkChartLayout(e="RADIAL_TREE",t){const o=[],n=[];this.dataManager.sublayerCaches.forEach(((e,t)=>{this.dataManager.entityTypeNames.has(t)?e.forEach((e=>{o.push({typeName:t,feature:e})})):this.dataManager.relationshipTypeNames.has(t)&&e.forEach((e=>{n.push({typeName:t,feature:e})}))})),this.linkChartDiagramLookup=new Map;const r=new Map,h=new Map,c=new Map,p=new Map,g=new Uint8Array(o.length),k=new Float64Array(o.length),C=new Float64Array(o.length),G=new Uint32Array(n.length),I=new Uint32Array(n.length),A=[],v="FORCE_DIRECTED",j=t?.xScaleFactor??1,S=t?.yScaleFactor??1,P=new N({xmin:-1e-7,ymin:-1e-7,xmax:1e-7,ymax:1e-7});let F,z="FORCE_DIRECTED",O=0,U=0;switch(z="GEOGRAPHIC"===e?v:e,z){case"FORCE_DIRECTED":F=E.apply;break;case"COMMUNITY":F=x.apply;break;case"HIERARCHICAL":F=w.apply;break;case"RADIAL_TREE":F=M.apply;break;case"SMART_TREE":F=b.apply;break;default:F=L.apply}o.forEach((({typeName:a,feature:i})=>{if(t?.lockedNodeLocations?.has(i.attributes[d])){"GEOGRAPHIC"===e&&this.dataManager.geographicLookup.has(a)?g[O]=D.IsGeographic:g[O]=D.None;const o=t.lockedNodeLocations.get(i.attributes[d]);k[O]=o.x,C[O]=o.y}else if("GEOGRAPHIC"===e&&this.dataManager.geographicLookup.has(a)){g[O]=D.IsGeographic;let e=null;const t=i.attributes[this.dataManager.geographicLookup.get(a).name],o=this.dataManager.geographicLookup.get(a)?.geometryType;switch(o){case"esriGeometryPoint":k[O]=t?.x,C[O]=t?.y;break;case"esriGeometryPolygon":e=t?.centroid,null!=e?.x&&null!=e?.y?(k[O]=e.x,C[O]=e.y):g[O]=D.IsMovable;break;case"esriGeometryPolyline":case"esriGeometryMultipoint":e=t?.extent?.center,null!=e?.x&&null!=e?.y?(k[O]=e.x,C[O]=e.y):g[O]=D.IsMovable;break;default:g[O]=D.IsMovable}(null==k[O]||null==C[O]||Number.isNaN(k[O])||Number.isNaN(C[O]))&&(g[O]=D.IsMovable,k[O]=0,C[O]=0)}else g[O]=D.IsMovable,k[O]=0,C[O]=0;p.set(i.attributes[d],O),A[O]={feature:i,typeName:a},O++}));let H=!1;n.forEach((e=>{const t=p.get(e.feature.attributes[u]),a=p.get(e.feature.attributes[y]);void 0!==t&&void 0!==a?(G[U]=t,I[U]=a,U++):(H=!0,this.linkChartDiagramLookup.set(e.feature.attributes[u],null),this.linkChartGeohashLookup.set(e.feature.attributes[u],null))})),H&&i.getLogger(this).warn("A relationship is a member of this layer that has either origin or destination entity nodes that are not members. The diagram geometry will be set to null"),await T();if(!F(g,k,C,G,I))throw new a("knowledge-graph:layout-failed","Attempting to arrange the records in the specified layout failed");for(let a=0;a<A.length;a++){if(g[a]===D.IsMovable&&(k[a]=k[a]*j,C[a]=C[a]*S),C[a]>84.9999&&(C[a]=84.9999),C[a]<-84.9999&&(C[a]=-84.9999),k[a]>179.9999&&(k[a]=179.9999),k[a]<-179.9999&&(k[a]=-179.9999),A[a].feature.attributes[m]=new R(k[a],C[a]),r.has(A[a].typeName)){const e=r.get(A[a].typeName);e?.set(A[a].feature.attributes[d],A[a].feature)}else{const e=new Map;e.set(A[a].feature.attributes[d],A[a].feature),r.set(A[a].typeName,e)}c.set(A[a].feature.attributes[d],A[a].feature);const e=l(A[a].feature.attributes[m]);this.linkChartDiagramLookup.set(A[a].feature.attributes[d],A[a].feature.attributes[m]?e:null),this.linkChartGeohashLookup.set(A[a].feature.attributes[d],s(A[a].feature.attributes[m].y,A[a].feature.attributes[m].x,f)),A[a].feature.attributes[m].x<P.xmin&&(P.xmin=A[a].feature.attributes[m].x),A[a].feature.attributes[m].x>P.xmax&&(P.xmax=A[a].feature.attributes[m].x),A[a].feature.attributes[m].y<P.ymin&&(P.ymin=A[a].feature.attributes[m].y),A[a].feature.attributes[m].y>P.ymax&&(P.ymax=A[a].feature.attributes[m].y)}return this.linkChartExtent.xmin=P.xmin,this.linkChartExtent.xmax=P.xmax,this.linkChartExtent.ymin=P.ymin,this.linkChartExtent.ymax=P.ymax,n.forEach((e=>{const t=A[p.get(e.feature.attributes[u])]?.feature.attributes[m],a=A[p.get(e.feature.attributes[y])]?.feature.attributes[m];if(!t||!a)return;const i=new _({paths:[[t.x,t.y],[a.x,a.y]]});if(e.feature.attributes[m]=i,h.has(e.typeName)){const t=h.get(e.typeName);t?.set(e.feature.attributes[d],e.feature)}else{const t=new Map;t.set(e.feature.attributes[d],e.feature),h.set(e.typeName,t)}c.set(e.feature.attributes[d],e.feature);const o=l(e.feature.attributes[m]);this.linkChartDiagramLookup.set(e.feature.attributes[d],e.feature.attributes[m]?o:null),this.linkChartGeohashLookup.set(e.feature.attributes[d],"")})),this._currentLinkChartConfig={layoutMode:e,xScaleFactor:j,yScaleFactor:S},{nodes:r,links:h,idMap:c}}async applyNewLinkChartLayout(e="RADIAL_TREE",t){const a=[];await this.calculateLinkChartLayout(e,t),this.layers.forEach((e=>{a.push(e.refreshCachedQueryEngine())})),await Promise.all(a),this.layers.forEach((e=>{e.emit("refresh",{dataChanged:!0})}))}getCurrentNodeLocations(){const e=new Map;return this.dataManager.inclusionModeDefinition?.namedTypeDefinitions?.forEach((t=>{t?.members?.forEach((t=>{const a=t.linkChartLocation;let i;const o=t.id;a&&(i="x"in a?{x:a.x,y:a.y}:{x:a.coords[0],y:a.coords[1]},e.set(o,new R({x:i.x,y:i.y})))}))})),e}async synchronizeInclusionListWithCache(){return new Promise((e=>{this.dataManager.inclusionModeDefinition?.namedTypeDefinitions.forEach(((e,t)=>{if(e.useAllData=!1,e.members&&e.members.size>0){if(!this.dataManager.sublayerCaches.get(t))return;const a=Array.from(this.dataManager.sublayerCaches.get(t).keys());Array.from(e.members.keys()).filter((e=>!a.includes(e))).forEach((t=>{e.members?.delete(t)}))}})),e()}))}async refreshLinkChartCache(e){await this.dataManager.refreshCacheContent(e);const t=[];this.layers.forEach((e=>{t.push(e.refreshCachedQueryEngine())})),await Promise.all(t),this.layers.forEach((e=>{e.emit("refresh",{dataChanged:!0})}))}async _handleNewRecords(e){const t=[];this.dataManager.addToLayerInclusionSet(e);for(const a of e)this.sublayerIdsCache.has(a.typeName)||(this.sublayerIdsCache.set(a.typeName,new Set),t.push(a.typeName)),this.sublayerIdsCache.get(a.typeName).add(a.id);for(const a of t)if(this._graphTypeLookup.has(a)){const e=this._graphTypeLookup.get(a),t="endPoints"in e?"relationship":"entity",i=new g({objectType:e,parentCompositeLayer:this,graphType:t,title:a});"entity"===t?this.dataManager.entityTypeNames.add(a):this.dataManager.relationshipTypeNames.add(a),i.geometryType?this.layers.push(i):this.tables.push(i),this.dataManager.sublayerCaches.set(a,new Map)}await this.dataManager.refreshCacheContent(e.map((e=>e.id))),await this.applyNewLinkChartLayout(this._currentLinkChartConfig.layoutMode,{xScaleFactor:this._currentLinkChartConfig.xScaleFactor,yScaleFactor:this._currentLinkChartConfig.xScaleFactor})}async _initializeDiagram(){this.defaultLinkChartConfig?this.defaultLinkChartConfig.doNotRecalculateLayout?(this.dataManager.inclusionModeDefinition?.namedTypeDefinitions?.forEach((e=>{e?.members?.forEach((e=>{const t=e.linkChartLocation;let a;const i=e.id;if(!t)return;a="x"in t?{x:t.x,y:t.y}:{x:t.coords[0],y:t.coords[1]};const o=l(a);this.linkChartDiagramLookup.set(i,o),this.linkChartGeohashLookup.set(i,s(a.x,a.y,f)),this.linkChartExtent.xmin>a.x&&(this.linkChartExtent.xmin=a.x),this.linkChartExtent.xmax<a.x&&(this.linkChartExtent.xmax=a.x),this.linkChartExtent.ymin>a.y&&(this.linkChartExtent.ymin=a.y),this.linkChartExtent.ymax<a.y&&(this.linkChartExtent.ymax=a.y)}))})),this.memberRelationshipTypes.forEach((e=>{e.name&&this.dataManager.sublayerCaches.get(e.name)?.forEach((e=>{const t=this.linkChartDiagramLookup.get(e.attributes[u]),a=this.linkChartDiagramLookup.get(e.attributes[y]);if(t&&a){const i=l(new _({paths:[[t.coords[0],t.coords[1]],[a.coords[0],a.coords[1]]]}));this.linkChartDiagramLookup.set(e.attributes[d],i)}else this.linkChartDiagramLookup.set(e.attributes[d],null);this.linkChartGeohashLookup.set(e.attributes[d],"")}))}))):await this.calculateLinkChartLayout(this.defaultLinkChartConfig.layoutMode,{xScaleFactor:this.defaultLinkChartConfig.xScaleFactor,yScaleFactor:this.defaultLinkChartConfig.yScaleFactor,lockedNodeLocations:this.getCurrentNodeLocations()}):await this.calculateLinkChartLayout("RADIAL_TREE",{lockedNodeLocations:this.getCurrentNodeLocations()})}};e([n()],j.prototype,"dataPreloadedInLocalCache",void 0),e([n()],j.prototype,"defaultLinkChartConfig",void 0),e([n()],j.prototype,"dataManager",void 0),e([n()],j.prototype,"knowledgeGraph",void 0),e([n()],j.prototype,"layers",void 0),e([n()],j.prototype,"linkChartDiagramLookup",void 0),e([n()],j.prototype,"linkChartExtent",void 0),e([n()],j.prototype,"linkChartGeohashLookup",void 0),e([n()],j.prototype,"memberEntityTypes",void 0),e([n()],j.prototype,"memberRelationshipTypes",void 0),e([n()],j.prototype,"sublayerIdsCache",void 0),e([n()],j.prototype,"tables",void 0),e([n({json:{read:!1}})],j.prototype,"type",void 0),j=e([r("esri.layers.LinkChartLayer")],j);const S=j;export{S as default};
|
|
5
|
+
import{_ as e}from"../chunks/tslib.es6.js";import"../geometry.js";import t from"../core/Collection.js";import a from"../core/Error.js";import i from"../core/Logger.js";import{throwIfAborted as o}from"../core/promiseUtils.js";import{property as n}from"../core/accessorSupport/decorators/property.js";import"../core/accessorSupport/ensureType.js";import"../core/arrayUtils.js";import"../core/has.js";import{subclass as r}from"../core/accessorSupport/decorators/subclass.js";import{encodeGeohash as s}from"../geohash/geohashUtils.js";import h from"./Layer.js";import{convertFromGeometry as l}from"./graphics/featureConversionUtils.js";import c from"./graphics/OptimizedGeometry.js";import{KnowledgeGraphLayerDataManager as d,MOCK_OID_FIELD_NAME as p,MOCK_ORIGIN_ID_FIELD_NAME as u,MOCK_DESTINATION_ID_FIELD_NAME as y,MOCK_LAYOUT_GEOMETRY_FIELD_NAME as m,GEOHASH_ENCODING_PRECISION as f}from"./knowledgeGraph/KnowledgeGraphLayerDataManager.js";import g from"./knowledgeGraph/KnowledgeGraphSublayer.js";import{BlendLayer as k}from"./mixins/BlendLayer.js";import{ScaleRangeLayer as C}from"./mixins/ScaleRangeLayer.js";import{LCSimpleLayout as L,LCSmartTreeLayout as b,LCRadialTreeLayout as M,LCHierarchicalLayout as w,LCCommunityLayout as x,LCForceDirectedLayout as E,NodeFlag as D,load as T}from"../libs/linkchartlayout/LinkChartLayout.js";import{fetchKnowledgeGraph as G}from"../rest/knowledgeGraphService.js";import I from"../rest/knowledgeGraph/EntityType.js";import R from"../rest/knowledgeGraph/RelationshipType.js";import N from"../geometry/Extent.js";import A from"../geometry/Point.js";import _ from"../geometry/Polyline.js";const v=(e,t,a)=>(e.has(t)||e.set(t,a()),e.get(t));let S=class extends(k(C(h))){constructor(e){if(super(e),this.dataPreloadedInLocalCache=!1,this.defaultLinkChartConfig=null,this._currentLinkChartConfig={layoutMode:"RADIAL_TREE",xScaleFactor:1,yScaleFactor:1},this._graphTypeLookup=new Map,this.knowledgeGraph=null,this.layers=new t,this.linkChartDiagramLookup=new Map,this.linkChartExtent=new N({xmin:-1e-7,ymin:-1e-7,xmax:1e-7,ymax:1e-7}),this.linkChartGeohashLookup=new Map,this.memberEntityTypes=null,this.memberRelationshipTypes=null,this.sublayerIdsCache=new Map,this.tables=new t,this.type="link-chart",this._originalInclusionList=e.inclusionModeDefinition,e.dataPreloadedInLocalCache&&!e.inclusionModeDefinition)throw new a("knowledge-graph:linkchart-layer-constructor","If creating a link chart composite layer and configured that data is already loaded in the cache, you must specify an inclusion list so the Composite Layer knows what records belong to it")}normalizeCtorArgs(e){return{url:e.url,title:e.title,dataPreloadedInLocalCache:e.dataPreloadedInLocalCache,defaultLinkChartConfig:e.defaultLinkChartConfig}}_initializeLayerProperties(e){if(!this.title&&this.url){const e=this.url.split("/");this.title=e[e.length-2]}const t=new Set;let o=[],n=[];if(e.inclusionModeDefinition&&(!e.inclusionModeDefinition.namedTypeDefinitions||e.inclusionModeDefinition.namedTypeDefinitions.size<1))throw new a("knowledge-graph:composite-layer-constructor","If an explicit inclusion definition is defined, at least one namedTypeDefinition must also be defined");e.knowledgeGraph.dataModel.entityTypes?.forEach((e=>{e.name&&this._graphTypeLookup.set(e.name,e)})),e.knowledgeGraph.dataModel.relationshipTypes?.forEach((e=>{e.name&&this._graphTypeLookup.set(e.name,e)})),e.inclusionModeDefinition?.generateAllSublayers?(o=e.knowledgeGraph.dataModel.entityTypes??[],n=e.knowledgeGraph.dataModel.relationshipTypes??[]):e.inclusionModeDefinition?.namedTypeDefinitions&&e.inclusionModeDefinition?.namedTypeDefinitions.size>0?e.inclusionModeDefinition?.namedTypeDefinitions.forEach(((a,r)=>{if(!this._graphTypeLookup.get(r))return i.getLogger(this).warn(`A named type, ${r}, was in the inclusion list that wasn't in the data model and will be removed`),void e.inclusionModeDefinition?.namedTypeDefinitions.delete(r);this._graphTypeLookup.get(r)instanceof R||"strictOrigin"in this._graphTypeLookup.get(r)?t.has(r)||(t.add(r),n.push(this._graphTypeLookup.get(r))):this._graphTypeLookup.get(r)instanceof I||"properties"in this._graphTypeLookup.get(r)?t.has(r)||(t.add(r),o.push(this._graphTypeLookup.get(r))):(i.getLogger(this).warn(`A named type, ${r}, was in the inclusion list that wasn't properly modeled and will be removed`),e.inclusionModeDefinition?.namedTypeDefinitions.delete(r))})):(o=e.knowledgeGraph.dataModel.entityTypes??[],n=e.knowledgeGraph.dataModel.relationshipTypes??[]);const r=new d({knowledgeGraph:e.knowledgeGraph,inclusionModeDefinition:e.inclusionModeDefinition});this.knowledgeGraph=e.knowledgeGraph,this.memberEntityTypes=o,this.memberRelationshipTypes=n,this.dataManager=r}load(e){return this.addResolvingPromise(new Promise((t=>{G(this.url).then((a=>{if(this._initializeLayerProperties({knowledgeGraph:a,inclusionModeDefinition:this._originalInclusionList}),this.dataManager.inclusionModeDefinition?.namedTypeDefinitions?.size||(this.dataManager.inclusionModeDefinition={generateAllSublayers:!1,namedTypeDefinitions:new Map},this.dataManager.knowledgeGraph.dataModel.entityTypes?.forEach((e=>{e.name&&this.dataManager.inclusionModeDefinition?.namedTypeDefinitions.set(e.name,{useAllData:!0})})),this.dataManager.knowledgeGraph.dataModel.relationshipTypes?.forEach((e=>{e.name&&this.dataManager.inclusionModeDefinition?.namedTypeDefinitions.set(e.name,{useAllData:!0})}))),this.dataPreloadedInLocalCache)this.loadLayerAssumingLocalCache(),this.dataManager.inclusionModeDefinition&&(this.dataManager.inclusionModeDefinition.generateAllSublayers=!1),this.dataManager.inclusionModeDefinition?.namedTypeDefinitions.forEach((e=>{e.useAllData=!1,e.members?.forEach((e=>{let t;t=e.linkChartLocation instanceof c?e.linkChartLocation:e.linkChartLocation?l(e.linkChartLocation):null,this.linkChartDiagramLookup.set(e.id,t),t&&2===t.coords.length&&0===t.lengths.length?this.linkChartGeohashLookup.set(e.id,s(t.coords[1],t.coords[0],f)):this.linkChartGeohashLookup.set(e.id,"")})),this.addResolvingPromise(this._initializeDiagram().then((async()=>{this.layers.forEach((async e=>{await e.refreshCachedQueryEngine()})),this.tables.forEach((async e=>{await e.refreshCachedQueryEngine()}))})))}));else{const t="GEOGRAPHIC"===this.defaultLinkChartConfig?.layoutMode;this.addResolvingPromise(this.dataManager.refreshCacheContent(void 0,!1,t,!0).then((async()=>{o(e);const t=[],a=[];this.loadLayerAssumingLocalCache(),this.dataManager.inclusionModeDefinition&&(this.dataManager.inclusionModeDefinition.generateAllSublayers=!1,this.dataManager.inclusionModeDefinition.namedTypeDefinitions.forEach((e=>{e.useAllData=!1}))),await this._initializeDiagram(),this.layers.forEach((e=>{a.push(e.refreshCachedQueryEngine()),t.push(new Promise((t=>{e.on("layerview-create",(()=>{t(null)}))})))})),this.tables.forEach((e=>{a.push(e.refreshCachedQueryEngine())})),await Promise.all(a)})))}t(null)}))}))),Promise.resolve(this)}async addRecords(e){await this._handleNewRecords(e)}async removeRecords(e,{cascadeRemoveRelationships:t=!0,recalculateLayout:a=!1}={cascadeRemoveRelationships:!0,recalculateLayout:!1}){let i=[];for(const n of e)!1===this.dataManager.inclusionModeDefinition?.namedTypeDefinitions?.get(n.typeName)?.useAllData&&this.dataManager.inclusionModeDefinition?.namedTypeDefinitions?.get(n.typeName)?.members?.has(n.id)&&i.push(n);if(t){const e=new Set,t=[];for(const a of i)if(this.dataManager.nodeConnectionsLookup.has(a.id))for(const t of this.dataManager.nodeConnectionsLookup.get(a.id))e.add(t);for(const a of e)this.dataManager.memberIdTypeLookup.has(a)&&t.push({id:a,typeName:this.dataManager.memberIdTypeLookup.get(a)});i=i.concat(t)}this.dataManager.removeFromLayer(i);for(const n of i)this.sublayerIdsCache.get(n.typeName)?.delete(n.id),this.linkChartDiagramLookup.delete(n.id);a&&await this.calculateLinkChartLayout(this._currentLinkChartConfig.layoutMode,{xScaleFactor:this._currentLinkChartConfig.xScaleFactor,yScaleFactor:this._currentLinkChartConfig.xScaleFactor});const o=[];return this.layers.forEach((e=>{o.push(e.refreshCachedQueryEngine())})),await Promise.all(o),this.layers.forEach((e=>{e.emit("refresh",{dataChanged:!0})})),i}async expand(e){const t=await this.dataManager.getConnectedRecordIds(e),a=t.filter((e=>!this.sublayerIdsCache.get(e.typeName)?.has(e.id)));return await this._handleNewRecords(t),{records:a}}loadLayerAssumingLocalCache(){this.memberRelationshipTypes.forEach((e=>{const t=new g({objectType:e,parentCompositeLayer:this,graphType:"relationship",title:e.name});t.geometryType?this.layers.push(t):this.tables.push(t),this.dataManager.sublayerCaches.has(e.name)||this.dataManager.sublayerCaches.set(e.name,new Map)})),this.memberEntityTypes.forEach((e=>{const t=new g({objectType:e,parentCompositeLayer:this,graphType:"entity",title:e.name});t.geometryType?this.layers.push(t):this.tables.push(t),this.dataManager.sublayerCaches.has(e.name)||this.dataManager.sublayerCaches.set(e.name,new Map)})),this.dataManager.inclusionModeDefinition?.namedTypeDefinitions&&this.dataManager.inclusionModeDefinition?.namedTypeDefinitions.forEach(((e,t)=>{const a=v(this.sublayerIdsCache,t,(()=>new Set));e.members?.forEach((e=>{if(a.add(e.id),e.linkChartLocation)if(e.linkChartLocation instanceof c)this.linkChartDiagramLookup.set(e.id,e.linkChartLocation),2===e.linkChartLocation.coords.length&&0===e.linkChartLocation.lengths.length?this.linkChartGeohashLookup.set(e.id,s(e.linkChartLocation.coords[1],e.linkChartLocation.coords[0],f)):this.linkChartGeohashLookup.set(e.id,"");else{const t=l(e.linkChartLocation);this.linkChartDiagramLookup.set(e.id,e.linkChartLocation?t:null),"x"in e.linkChartLocation&&"y"in e.linkChartLocation?this.linkChartGeohashLookup.set(e.id,s(e.linkChartLocation.x,e.linkChartLocation.y,f)):this.linkChartGeohashLookup.set(e.id,"")}}))}))}async calculateLinkChartLayout(e="RADIAL_TREE",t){const o=[],n=[];this.dataManager.sublayerCaches.forEach(((e,t)=>{this.dataManager.entityTypeNames.has(t)?e.forEach((e=>{o.push({typeName:t,feature:e})})):this.dataManager.relationshipTypeNames.has(t)&&e.forEach((e=>{n.push({typeName:t,feature:e})}))})),this.linkChartDiagramLookup=new Map;const r=new Map,h=new Map,c=new Map,d=new Map,g=new Uint8Array(o.length),k=new Float64Array(o.length),C=new Float64Array(o.length),G=new Uint32Array(n.length),I=new Uint32Array(n.length),R=[],v="FORCE_DIRECTED",S=t?.xScaleFactor??1,j=t?.yScaleFactor??1,P=new N({xmin:-1e-7,ymin:-1e-7,xmax:1e-7,ymax:1e-7});let F,z="FORCE_DIRECTED",O=0,U=0;switch(z="GEOGRAPHIC"===e?v:e,z){case"FORCE_DIRECTED":F=E.apply;break;case"COMMUNITY":F=x.apply;break;case"HIERARCHICAL":F=w.apply;break;case"RADIAL_TREE":F=M.apply;break;case"SMART_TREE":F=b.apply;break;default:F=L.apply}o.forEach((({typeName:a,feature:i})=>{if(t?.lockedNodeLocations?.has(i.attributes[p])){"GEOGRAPHIC"===e&&this.dataManager.geographicLookup.has(a)?g[O]=D.IsGeographic:g[O]=D.None;const o=t.lockedNodeLocations.get(i.attributes[p]);k[O]=o.x,C[O]=o.y}else if("GEOGRAPHIC"===e&&this.dataManager.geographicLookup.has(a)){g[O]=D.IsGeographic;let e=null;const t=i.attributes[this.dataManager.geographicLookup.get(a).name],o=this.dataManager.geographicLookup.get(a)?.geometryType;switch(o){case"esriGeometryPoint":k[O]=t?.x,C[O]=t?.y;break;case"esriGeometryPolygon":e=t?.centroid,null!=e?.x&&null!=e?.y?(k[O]=e.x,C[O]=e.y):g[O]=D.IsMovable;break;case"esriGeometryPolyline":case"esriGeometryMultipoint":e=t?.extent?.center,null!=e?.x&&null!=e?.y?(k[O]=e.x,C[O]=e.y):g[O]=D.IsMovable;break;default:g[O]=D.IsMovable}(null==k[O]||null==C[O]||Number.isNaN(k[O])||Number.isNaN(C[O]))&&(g[O]=D.IsMovable,k[O]=0,C[O]=0)}else g[O]=D.IsMovable,k[O]=0,C[O]=0;d.set(i.attributes[p],O),R[O]={feature:i,typeName:a},O++}));let Q=!1;n.forEach((e=>{const t=d.get(e.feature.attributes[u]),a=d.get(e.feature.attributes[y]);void 0!==t&&void 0!==a?(G[U]=t,I[U]=a,U++):(Q=!0,this.linkChartDiagramLookup.set(e.feature.attributes[u],null),this.linkChartGeohashLookup.set(e.feature.attributes[u],null))})),Q&&i.getLogger(this).warn("A relationship is a member of this layer that has either origin or destination entity nodes that are not members. The diagram geometry will be set to null"),await T();if(!F(g,k,C,G,I))throw new a("knowledge-graph:layout-failed","Attempting to arrange the records in the specified layout failed");for(let a=0;a<R.length;a++){if(g[a]===D.IsMovable&&(k[a]=k[a]*S,C[a]=C[a]*j),C[a]>84.9999&&(C[a]=84.9999),C[a]<-84.9999&&(C[a]=-84.9999),k[a]>179.9999&&(k[a]=179.9999),k[a]<-179.9999&&(k[a]=-179.9999),R[a].feature.attributes[m]=new A(k[a],C[a]),r.has(R[a].typeName)){const e=r.get(R[a].typeName);e?.set(R[a].feature.attributes[p],R[a].feature)}else{const e=new Map;e.set(R[a].feature.attributes[p],R[a].feature),r.set(R[a].typeName,e)}c.set(R[a].feature.attributes[p],R[a].feature);const e=l(R[a].feature.attributes[m]);this.linkChartDiagramLookup.set(R[a].feature.attributes[p],R[a].feature.attributes[m]?e:null),this.linkChartGeohashLookup.set(R[a].feature.attributes[p],s(R[a].feature.attributes[m].y,R[a].feature.attributes[m].x,f)),R[a].feature.attributes[m].x<P.xmin&&(P.xmin=R[a].feature.attributes[m].x),R[a].feature.attributes[m].x>P.xmax&&(P.xmax=R[a].feature.attributes[m].x),R[a].feature.attributes[m].y<P.ymin&&(P.ymin=R[a].feature.attributes[m].y),R[a].feature.attributes[m].y>P.ymax&&(P.ymax=R[a].feature.attributes[m].y)}return this.linkChartExtent.xmin=P.xmin,this.linkChartExtent.xmax=P.xmax,this.linkChartExtent.ymin=P.ymin,this.linkChartExtent.ymax=P.ymax,n.forEach((e=>{const t=R[d.get(e.feature.attributes[u])]?.feature.attributes[m],a=R[d.get(e.feature.attributes[y])]?.feature.attributes[m];if(!t||!a)return;const i=new _({paths:[[t.x,t.y],[a.x,a.y]]});if(e.feature.attributes[m]=i,h.has(e.typeName)){const t=h.get(e.typeName);t?.set(e.feature.attributes[p],e.feature)}else{const t=new Map;t.set(e.feature.attributes[p],e.feature),h.set(e.typeName,t)}c.set(e.feature.attributes[p],e.feature);const o=l(e.feature.attributes[m]);this.linkChartDiagramLookup.set(e.feature.attributes[p],e.feature.attributes[m]?o:null),this.linkChartGeohashLookup.set(e.feature.attributes[p],"")})),this._currentLinkChartConfig={layoutMode:e,xScaleFactor:S,yScaleFactor:j},{nodes:r,links:h,idMap:c}}async applyNewLinkChartLayout(e="RADIAL_TREE",t){const a=[];await this.calculateLinkChartLayout(e,t),this.layers.forEach((e=>{a.push(e.refreshCachedQueryEngine())})),await Promise.all(a),this.layers.forEach((e=>{e.emit("refresh",{dataChanged:!0})}))}getCurrentNodeLocations(){const e=new Map;return this.dataManager.inclusionModeDefinition?.namedTypeDefinitions?.forEach((t=>{t?.members?.forEach((t=>{const a=t.linkChartLocation;let i;const o=t.id;a&&(i="x"in a?{x:a.x,y:a.y}:{x:a.coords[0],y:a.coords[1]},e.set(o,new A({x:i.x,y:i.y})))}))})),e}async synchronizeInclusionListWithCache(){return new Promise((e=>{this.dataManager.inclusionModeDefinition?.namedTypeDefinitions.forEach(((e,t)=>{if(e.useAllData=!1,e.members&&e.members.size>0){if(!this.dataManager.sublayerCaches.get(t))return;const a=Array.from(this.dataManager.sublayerCaches.get(t).keys());Array.from(e.members.keys()).filter((e=>!a.includes(e))).forEach((t=>{e.members?.delete(t)}))}})),e()}))}async refreshLinkChartCache(e){await this.dataManager.refreshCacheContent(e);const t=[];this.layers.forEach((e=>{t.push(e.refreshCachedQueryEngine())})),await Promise.all(t),this.layers.forEach((e=>{e.emit("refresh",{dataChanged:!0})}))}async _handleNewRecords(e){const t=[];this.dataManager.addToLayer(e);for(const a of e)this.sublayerIdsCache.has(a.typeName)||(this.sublayerIdsCache.set(a.typeName,new Set),t.push(a.typeName)),this.sublayerIdsCache.get(a.typeName).add(a.id);for(const a of t)if(this._graphTypeLookup.has(a)){const e=this._graphTypeLookup.get(a),t="endPoints"in e?"relationship":"entity",i=new g({objectType:e,parentCompositeLayer:this,graphType:t,title:a});"entity"===t?this.dataManager.entityTypeNames.add(a):this.dataManager.relationshipTypeNames.add(a),i.geometryType?this.layers.push(i):this.tables.push(i),this.dataManager.sublayerCaches.set(a,new Map)}await this.dataManager.refreshCacheContent(e.map((e=>e.id))),await this.applyNewLinkChartLayout(this._currentLinkChartConfig.layoutMode,{xScaleFactor:this._currentLinkChartConfig.xScaleFactor,yScaleFactor:this._currentLinkChartConfig.xScaleFactor})}async _initializeDiagram(){this.defaultLinkChartConfig?this.defaultLinkChartConfig.doNotRecalculateLayout?(this.dataManager.inclusionModeDefinition?.namedTypeDefinitions?.forEach((e=>{e?.members?.forEach((e=>{const t=e.linkChartLocation;let a;const i=e.id;if(!t)return;a="x"in t?{x:t.x,y:t.y}:{x:t.coords[0],y:t.coords[1]};const o=l(a);this.linkChartDiagramLookup.set(i,o),this.linkChartGeohashLookup.set(i,s(a.x,a.y,f)),this.linkChartExtent.xmin>a.x&&(this.linkChartExtent.xmin=a.x),this.linkChartExtent.xmax<a.x&&(this.linkChartExtent.xmax=a.x),this.linkChartExtent.ymin>a.y&&(this.linkChartExtent.ymin=a.y),this.linkChartExtent.ymax<a.y&&(this.linkChartExtent.ymax=a.y)}))})),this.memberRelationshipTypes.forEach((e=>{e.name&&this.dataManager.sublayerCaches.get(e.name)?.forEach((e=>{const t=this.linkChartDiagramLookup.get(e.attributes[u]),a=this.linkChartDiagramLookup.get(e.attributes[y]);if(t&&a){const i=l(new _({paths:[[t.coords[0],t.coords[1]],[a.coords[0],a.coords[1]]]}));this.linkChartDiagramLookup.set(e.attributes[p],i)}else this.linkChartDiagramLookup.set(e.attributes[p],null);this.linkChartGeohashLookup.set(e.attributes[p],"")}))}))):await this.calculateLinkChartLayout(this.defaultLinkChartConfig.layoutMode,{xScaleFactor:this.defaultLinkChartConfig.xScaleFactor,yScaleFactor:this.defaultLinkChartConfig.yScaleFactor,lockedNodeLocations:this.getCurrentNodeLocations()}):await this.calculateLinkChartLayout("RADIAL_TREE",{lockedNodeLocations:this.getCurrentNodeLocations()})}};e([n()],S.prototype,"dataPreloadedInLocalCache",void 0),e([n()],S.prototype,"defaultLinkChartConfig",void 0),e([n()],S.prototype,"dataManager",void 0),e([n()],S.prototype,"knowledgeGraph",void 0),e([n()],S.prototype,"layers",void 0),e([n()],S.prototype,"linkChartDiagramLookup",void 0),e([n()],S.prototype,"linkChartExtent",void 0),e([n()],S.prototype,"linkChartGeohashLookup",void 0),e([n()],S.prototype,"memberEntityTypes",void 0),e([n()],S.prototype,"memberRelationshipTypes",void 0),e([n()],S.prototype,"sublayerIdsCache",void 0),e([n()],S.prototype,"tables",void 0),e([n({json:{read:!1}})],S.prototype,"type",void 0),S=e([r("esri.layers.LinkChartLayer")],S);const j=S;export{j as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.28/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../chunks/tslib.es6.js";import"../../geometry.js";import t from"../../core/Accessor.js";import i from"../../core/Error.js";import n from"../../core/Logger.js";import{parseWhereClause as o}from"../../core/sql.js";import{property as s}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as a}from"../../core/accessorSupport/decorators/subclass.js";import{encodeGeohash as r}from"../../geohash/geohashUtils.js";import p from"../../geometry/Polygon.js";import{initializeProjection as m,project as d}from"../../geometry/projection.js";import{WGS84 as l}from"../../geometry/support/spatialReferenceUtils.js";import h from"./SessionMemoryStorage.js";import{executeQueryStreaming as c}from"../../rest/knowledgeGraphService.js";import y from"../../rest/knowledgeGraph/GraphQueryStreaming.js";import u from"../../rest/support/Query.js";import f from"../../geometry/Extent.js";const g="ESRI__ID",b="ESRI__ORIGIN_ID",w="ESRI__DESTINATION_ID",T="ESRI__LAYOUT_GEOMETRY",D=12,M=n.getLogger("esri.rest.knowledgeGraph.knowledgeGraphLayer.KnowledgeGraphLayerDataManager");let I=class extends t{constructor(e){super(e),this.inclusionModeDefinition={generateAllSublayers:!0,namedTypeDefinitions:new Map},this.entityTypeNames=new Set,this.relationshipTypeNames=new Set,this.geographicLookup=new Map,this.sublayerCaches=new Map,this._processingCacheUpdatesLookup=new Map,this._memberIdTypeLookup=new Map;const t=new Map;e.knowledgeGraph.dataModel.entityTypes?.forEach((i=>{i.name&&(t.set(i.name,"entity"),this._processingCacheUpdatesLookup.set(i.name,[]),e.inclusionModeDefinition&&!e.inclusionModeDefinition?.generateAllSublayers||this.entityTypeNames.add(i.name),i.properties?.forEach((e=>{e.geometryType&&"esriGeometryNull"!==e.geometryType&&this.geographicLookup.set(i.name,{name:e.name??"",geometryType:e.geometryType})})))})),e.knowledgeGraph.dataModel.relationshipTypes?.forEach((i=>{i.name&&(t.set(i.name,"relationship"),this._processingCacheUpdatesLookup.set(i.name,[]),e.inclusionModeDefinition&&!e.inclusionModeDefinition?.generateAllSublayers||this.relationshipTypeNames.add(i.name),i.properties?.forEach((e=>{e.geometryType&&"esriGeometryNull"!==e.geometryType&&this.geographicLookup.set(i.name,{name:e.name??"",geometryType:e.geometryType})})))})),e.inclusionModeDefinition?.namedTypeDefinitions.forEach(((i,n)=>{if("entity"===t.get(n))this.entityTypeNames.add(n);else{if("relationship"!==t.get(n))return M.warn(`A named type, ${n}, was in the inclusion list that wasn't in the data model and will be removed`),void e.inclusionModeDefinition?.namedTypeDefinitions.delete(n);this.relationshipTypeNames.add(n)}const o=new Map;i.members?.forEach((e=>{this._memberIdTypeLookup.set(e.id,n);const t=this.getById(e.id);t&&o.set(e.id,t)})),this.sublayerCaches.set(n,o)}))}addToLayerInclusionSet(e){e.forEach((({typeName:e,id:t})=>{if(!this.inclusionModeDefinition)throw new i("knowledge-graph:layer-data-manager","You cannot add to a layer's exclusion list if it was not created with an exclusion list originally");if(this.inclusionModeDefinition.namedTypeDefinitions.has(e)){if(this.inclusionModeDefinition.namedTypeDefinitions.has(e)){const i=this.inclusionModeDefinition.namedTypeDefinitions.get(e);i.members||(i.members=new Map),i.members.set(t,{id:t}),this._memberIdTypeLookup.set(t,e)}}else{const i=new Map;i.set(t,{id:t}),this.inclusionModeDefinition.namedTypeDefinitions.set(e,{useAllData:!1,members:i}),this._memberIdTypeLookup.set(t,e)}}))}getById(e){return h.getInstance().readFromStoreById(e)}async getData(e,t,i){if(t.objectType.name&&this.inclusionModeDefinition?.namedTypeDefinitions&&this.inclusionModeDefinition.namedTypeDefinitions.size>0&&!this.inclusionModeDefinition.namedTypeDefinitions.has(t.objectType.name))return[];let n;if(n=e||new u({where:"1=1",outFields:["*"]}),"link-chart"===t.parentCompositeLayer.type){const e=t.parentCompositeLayer,i=this._processingCacheUpdatesLookup.get(t.objectType.name??""),o=n.outFields,s=n.geometry;let a="",p="";s&&s.extent&&(a=r(s.extent.ymin,s.extent.xmin,D),p=r(s.extent.ymax,s.extent.xmax,D)),o&&1===o.length&&o[0]===g&&"1=1"===n.where||await Promise.all(i??[]);const m=this.sublayerCaches.has(t.objectType.name??"")?Array.from(this.sublayerCaches.get(t.objectType.name)?.values()):[],d=[];return m.forEach((i=>{if(i.geometry=e.linkChartDiagramLookup.get(i.attributes[t.objectIdField]),i.attributes[T]=i.geometry,a&&p){const n=e.linkChartGeohashLookup.get(i.attributes[t.objectIdField]);n?n>=a&&n<=p&&d.push(i):d.push(i)}else d.push(i)})),d}return this.retrieveDataFromService(n,t,i)}async getConnectedRecordIds(e){const t=[],i=[],n=new Map;return e.forEach((e=>{if(this._memberIdTypeLookup.has(e)){const t=this._memberIdTypeLookup.get(e);if(!this.entityTypeNames.has(t))return;n.has(t)?n.get(t)?.push(e):n.set(t,[e])}})),n.forEach(((e,n)=>{const o=`MATCH (n:${n})-[r]-(m) WHERE id(n) IN $ids RETURN id(r), type(r), id(m), labels(m)[0]`,s=new Promise((i=>{(async()=>{const i=(await c(this.knowledgeGraph,new y({openCypherQuery:o,bindParameters:{ids:e}}))).resultRowsStream.getReader();try{for(;;){const{done:e,value:n}=await i.read();if(e)break;for(let i=0;i<n.length;i++){const e=n[i];t.push({id:e[0],typeName:e[1]}),t.push({id:e[2],typeName:e[3]})}}}catch(n){if("AbortError"!==n.name)throw n;M.info("Request aborted as expected")}})().then((()=>{i()}))}));i.push(s)})),await Promise.all(i),t}async refreshCacheContent(e,t,n,o=!0){const s=h.getInstance(),a=[],r=new Map,p=new Map;this.knowledgeGraph.dataModel.entityTypes?.forEach((e=>{e.name&&p.set(e.name,e)})),this.knowledgeGraph.dataModel.relationshipTypes?.forEach((e=>{e.name&&p.set(e.name,e)})),e||this.inclusionModeDefinition?e?e.forEach((e=>{if(this._memberIdTypeLookup.has(e)){const t=this._memberIdTypeLookup.get(e);r.has(t)?r.get(t)?.push(e):r.set(t,[e])}})):this.inclusionModeDefinition?.namedTypeDefinitions?.forEach(((e,t)=>{e.useAllData?r.set(t,null):e.members&&e.members.forEach((e=>{r.has(t)&&null!==r.get(t)?r.get(t)?.push(e.id):r.set(t,[e.id])}))})):(this.knowledgeGraph.dataModel.entityTypes?.forEach((e=>{e.name&&r.set(e.name,null)})),this.knowledgeGraph.dataModel.entityTypes?.forEach((e=>{e.name&&r.set(e.name,null)})));for(const[m,d]of r){const e=new Promise((e=>{const a=async()=>{const e=new Set,a=[];let r,l="",h=!1;if(t||p.get(m)?.properties?.forEach((t=>{t.name&&e.add(t.name)})),n&&this.geographicLookup.has(m)){const t=this.geographicLookup.get(m)?.name;t&&e.add(t)}if(this.entityTypeNames.has(m))l=`MATCH (n:${m}) ${d?"WHERE id(n) IN $ids ":""}return ID(n)`,e.forEach((e=>{l+=`, n.${e}`,a.push(e)}));else{if(!this.relationshipTypeNames.has(m))throw new i("knowledge-graph:layer-data-manager",`The graph type of ${m} could not be determined. Was this type set in the KG data model and inclusion definition?`);h=!0,l=`MATCH ()-[n:${m}]->() ${d?"WHERE id(n) IN $ids ":""}return ID(n), id(startNode(n)), id(endNode(n))`,e.forEach((e=>{l+=`, n.${e}`,a.push(e)}))}r=new y(d?{openCypherQuery:l,bindParameters:{ids:d}}:{openCypherQuery:l});const u=(await c(this.knowledgeGraph,r)).resultRowsStream.getReader();for(;;){const{done:e,value:t}=await u.read();if(e)break;const i=[];for(let o=0;o<t.length;o++){const e=t[o];let n=0,s=0;const r={properties:{}};for(r.id=e[n],n++,s++,h&&(r.originId=e[n],n++,s++,r.destinationId=e[n],n++,s++);n<e.length;n++)r.properties[a[n-s]]=e[n];i.push(r)}const n=s.writeToStore(i,g,this.geographicLookup.get(m)?.name);this.sublayerCaches.has(m)||this.sublayerCaches.set(m,new Map),o&&!this.inclusionModeDefinition?.namedTypeDefinitions.has(m)&&this.inclusionModeDefinition?.namedTypeDefinitions.set(m,{useAllData:!1,members:new Map}),o&&!this.inclusionModeDefinition?.namedTypeDefinitions.get(m).members&&(this.inclusionModeDefinition.namedTypeDefinitions.get(m).members=new Map);const r=this.sublayerCaches.get(m);n.forEach((e=>{r?.set(e.attributes[g],e),o&&!this.inclusionModeDefinition?.namedTypeDefinitions.get(m).members.has(e.attributes[g])&&(this.inclusionModeDefinition?.namedTypeDefinitions.get(m).members.set(e.attributes[g],{id:e.attributes[g]}),this._memberIdTypeLookup.set(e.attributes[g],m))}))}};a().then((()=>{e(null)}))}));a.push(e),this._processingCacheUpdatesLookup.get(m)?.push(e)}await Promise.all(a)}removeFromLayer(e){const t=new Set;e.forEach((e=>{this._memberIdTypeLookup.get(e)&&t.add(this._memberIdTypeLookup.get(e)),this._memberIdTypeLookup.delete(e),this.inclusionModeDefinition?.namedTypeDefinitions.forEach((t=>{t.members?.has(e)&&t.members.delete(e)}))})),t.forEach((t=>{this.sublayerCaches.get(t)?.forEach(((i,n)=>{e.includes(n)&&this.sublayerCaches.get(t)?.delete(n)}))}))}async retrieveDataFromService(e,t,n){const s=h.getInstance(),a=new Set,r=[];let u,b="",w=[];const T="relationship"===t.graphType,D=this.inclusionModeDefinition?.namedTypeDefinitions?.get(t.objectType.name)?.useAllData,M=t.parentCompositeLayer.sublayerIdsCache.get(t.objectType.name);let I=!D&&M?Array.from(M).sort():null;if(this.inclusionModeDefinition?.namedTypeDefinitions?.get(t.objectType.name)?.useAllData)this.inclusionModeDefinition?.namedTypeDefinitions?.get(t.objectType.name)?.useAllData&&null!=e.objectIds&&(I=e.objectIds);else if(null!=e.objectIds&&I&&I.length>0){const t=e.objectIds;e.objectIds=I.filter((e=>t.includes(e)))}else if(null!=e.objectIds)I=e.objectIds;else{if(this.inclusionModeDefinition?.namedTypeDefinitions.has(t.objectType.name)&&(!this.inclusionModeDefinition.namedTypeDefinitions.get(t.objectType.name)?.members||this.inclusionModeDefinition.namedTypeDefinitions.get(t.objectType.name)?.members?.size<1))return e.objectIds=[],[];e.objectIds=I}if(null!=e.outFields){const i=e.outFields;i.includes("*")?t.fields.forEach((e=>{a.add(e.name)})):i.forEach((e=>{e!==g&&e!==t.geometryFieldName&&a.add(e)}))}if(null!=e.geometry){const n=e.geometry;let s;const h=t.parentCompositeLayer.dataManager.knowledgeGraph.serviceDefinition,c=h?.spatialReference,g=h?.serviceCapabilities?.geometryCapabilities;let w=g?.geometryMaxBoundingRectangleSizeX,D=g?.geometryMaxBoundingRectangleSizeY;if(n?.extent?.spatialReference&&!n.spatialReference?.isWGS84?(await m(n.extent.spatialReference,l),s=d(n.extent,l)):s=n.extent,w&&D&&c){if(4326!==c.wkid){const e=new f({spatialReference:c,xmax:w,ymax:D}),t=d(e,l);w=t.xmax,D=t.ymax}if(s.xmax-s.xmin>w)throw new i("knowledge-graph:layer-data-manager",`Extent x bounds should be within ${w}° latitude, limit exceeded`);if(s.ymax-s.ymin>D)throw new i("knowledge-graph:layer-data-manager",`Extent y bounds should be within ${D}° longitude, limit exceeded`)}if(null!=e.where&&"1=1"!==e.where){const i=await o(e.where.toUpperCase(),t.fieldsIndex);t.fields.forEach((e=>{i.fieldNames.includes(e.name)&&a.add(e.name)}))}b=T?`Match ()-[n:${t.objectType.name}]->() WHERE esri.graph.ST_Intersects($param_filter_geom, n.${t.geometryFieldName}) return ID(n), id(startNode(r)), id(endNode(r))`:`Match (n:${t.objectType.name}) WHERE esri.graph.ST_Intersects($param_filter_geom, n.${t.geometryFieldName}) return ID(n)`,t.geometryFieldName&&a.add(t.geometryFieldName),a.forEach((e=>{b+=`, n.${e}`,r.push(e)})),u=new y({openCypherQuery:b,bindParameters:{param_filter_geom:new p({rings:[[[s.xmin,s.ymin],[s.xmin,s.ymax],[s.xmax,s.ymax],[s.xmax,s.ymin],[s.xmin,s.ymin]]]})}})}else{let i="";if(null!=e.where&&"1=1"!==e.where){const n=await o(e.where,t.fieldsIndex);t.fields.forEach((e=>{n.fieldNames.includes(e.name)&&a.add(e.name)}));const s=["column-reference","string","number","binary-expression"],r=["=","<","<=","<>",">",">=","AND","OR","LIKE"];let p=!1;const m=e=>{if("column-reference"===e.type)return`n.${e.column}`;if("string"===e.type)return`'${e.value}'`;if("number"===e.type)return`${e.value}`;if("binary-expression"===e.type&&s.includes(e.left.type)&&s.includes(e.right.type)&&r.includes(e.operator))return`${m(e.left)} ${e.operator} ${m(e.right)}`;if("binary-expression"===e.type&&"LIKE"===e.operator){let t="";if("function"===e.left.type&&"column-reference"===e.left.args.value[0].type)t+=`lower(n.${e.left.args.value[0].column})`;else{if("column-reference"!==e.left.type)return p=!0,"";t+=`lower(n.${e.left.column})`}if(t+=" CONTAINS (","string"!==e.right.type)return p=!0,"";{let i=e.right.value;"%"===i.charAt(0)&&(i=i.slice(1)),"%"===i.charAt(i.length-1)&&(i=i.slice(0,-1)),t+=`'${i.toLowerCase()}')`}return t}return p=!0,""};i=m(n.parseTree),p&&(i="")}let n="";n=T?`Match ()-[n:${t.objectType.name}]->()`:`Match (n:${t.objectType.name})`;let s=!1;I&&(s=!0,n+=" WHERE ID(n) IN $ids"),i&&(n+=s?" AND":" WHERE",n+=` ${i}`),n+=" return ID(n)",T&&(n+=", id(startNode(n)), id(endNode(n))"),e.returnGeometry&&t.geometryFieldName&&a.add(t.geometryFieldName),a.forEach((e=>{n+=`, n.${e}`,r.push(e)})),u=new y(I?{openCypherQuery:n,bindParameters:{ids:I}}:{openCypherQuery:n})}const E=(await c(t.parentCompositeLayer.dataManager.knowledgeGraph,u,n)).resultRowsStream.getReader();for(;;){const{done:e,value:i}=await E.read();if(e)break;const n=[];for(let t=0;t<i.length;t++){const e=i[t];let o=0,s=0;const a={properties:{}};for(a.id=e[o],o++,s++,T&&(a.originId=e[o],o++,s++,a.destinationId=e[o],o++,s++);o<e.length;o++)a.properties[r[o-s]]=e[o];n.push(a)}w=w.concat(s.writeToStore(n,g,t.parentCompositeLayer.dataManager.geographicLookup.get(t.objectType.name)?.name))}return w}};e([s()],I.prototype,"knowledgeGraph",void 0),e([s()],I.prototype,"inclusionModeDefinition",void 0),e([s()],I.prototype,"entityTypeNames",void 0),e([s()],I.prototype,"relationshipTypeNames",void 0),e([s()],I.prototype,"geographicLookup",void 0),e([s()],I.prototype,"sublayerCaches",void 0),I=e([a("esri.rest.knowledgeGraph.knowledgeGraphLayer.KnowledgeGraphLayerDataManager")],I);export{D as GEOHASH_ENCODING_PRECISION,I as KnowledgeGraphLayerDataManager,w as MOCK_DESTINATION_ID_FIELD_NAME,T as MOCK_LAYOUT_GEOMETRY_FIELD_NAME,g as MOCK_OID_FIELD_NAME,b as MOCK_ORIGIN_ID_FIELD_NAME};
|
|
5
|
+
import{_ as e}from"../../chunks/tslib.es6.js";import"../../geometry.js";import t from"../../core/Accessor.js";import i from"../../core/Error.js";import n from"../../core/Logger.js";import{getOrCreateMapValue as o}from"../../core/MapUtils.js";import{parseWhereClause as s}from"../../core/sql.js";import{property as a}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as r}from"../../core/accessorSupport/decorators/subclass.js";import{encodeGeohash as p}from"../../geohash/geohashUtils.js";import d from"../../geometry/Polygon.js";import{initializeProjection as m,project as l}from"../../geometry/projection.js";import{WGS84 as c}from"../../geometry/support/spatialReferenceUtils.js";import h from"./SessionMemoryStorage.js";import{executeQueryStreaming as y}from"../../rest/knowledgeGraphService.js";import u from"../../rest/knowledgeGraph/GraphQueryStreaming.js";import f from"../../rest/support/Query.js";import g from"../../geometry/Extent.js";const b="ESRI__ID",w="ESRI__ORIGIN_ID",T="ESRI__DESTINATION_ID",D="ESRI__LAYOUT_GEOMETRY",M=12,I=n.getLogger("esri.rest.knowledgeGraph.knowledgeGraphLayer.KnowledgeGraphLayerDataManager");let k=class extends t{constructor(e){super(e),this.inclusionModeDefinition={generateAllSublayers:!0,namedTypeDefinitions:new Map},this.entityTypeNames=new Set,this.relationshipTypeNames=new Set,this.geographicLookup=new Map,this.sublayerCaches=new Map,this.nodeConnectionsLookup=new Map,this.memberIdTypeLookup=new Map,this._processingCacheUpdatesLookup=new Map;const t=new Map;e.knowledgeGraph.dataModel.entityTypes?.forEach((i=>{i.name&&(t.set(i.name,"entity"),this._processingCacheUpdatesLookup.set(i.name,[]),e.inclusionModeDefinition&&!e.inclusionModeDefinition?.generateAllSublayers||this.entityTypeNames.add(i.name),i.properties?.forEach((e=>{e.geometryType&&"esriGeometryNull"!==e.geometryType&&this.geographicLookup.set(i.name,{name:e.name??"",geometryType:e.geometryType})})))})),e.knowledgeGraph.dataModel.relationshipTypes?.forEach((i=>{i.name&&(t.set(i.name,"relationship"),this._processingCacheUpdatesLookup.set(i.name,[]),e.inclusionModeDefinition&&!e.inclusionModeDefinition?.generateAllSublayers||this.relationshipTypeNames.add(i.name),i.properties?.forEach((e=>{e.geometryType&&"esriGeometryNull"!==e.geometryType&&this.geographicLookup.set(i.name,{name:e.name??"",geometryType:e.geometryType})})))})),e.inclusionModeDefinition?.namedTypeDefinitions.forEach(((i,n)=>{if("entity"===t.get(n))this.entityTypeNames.add(n);else{if("relationship"!==t.get(n))return I.warn(`A named type, ${n}, was in the inclusion list that wasn't in the data model and will be removed`),void e.inclusionModeDefinition?.namedTypeDefinitions.delete(n);this.relationshipTypeNames.add(n)}const o=new Map;i.members?.forEach((e=>{this.memberIdTypeLookup.set(e.id,n);const t=this.getById(e.id);t&&o.set(e.id,t)})),this.sublayerCaches.set(n,o)}))}addToLayer(e){e.forEach((({typeName:e,id:t})=>{if(!this.inclusionModeDefinition)throw new i("knowledge-graph:layer-data-manager","You cannot add to a layer's exclusion list if it was not created with an exclusion list originally");if(this.inclusionModeDefinition.namedTypeDefinitions.has(e)){if(this.inclusionModeDefinition.namedTypeDefinitions.has(e)){const i=this.inclusionModeDefinition.namedTypeDefinitions.get(e);i.members||(i.members=new Map),i.members.set(t,{id:t}),this.memberIdTypeLookup.set(t,e)}}else{const i=new Map;i.set(t,{id:t}),this.inclusionModeDefinition.namedTypeDefinitions.set(e,{useAllData:!1,members:i}),this.memberIdTypeLookup.set(t,e)}}))}getById(e){return h.getInstance().readFromStoreById(e)}async getData(e,t,i){if(t.objectType.name&&this.inclusionModeDefinition?.namedTypeDefinitions&&this.inclusionModeDefinition.namedTypeDefinitions.size>0&&!this.inclusionModeDefinition.namedTypeDefinitions.has(t.objectType.name))return[];let n;if(n=e||new f({where:"1=1",outFields:["*"]}),"link-chart"===t.parentCompositeLayer.type){const e=t.parentCompositeLayer,i=this._processingCacheUpdatesLookup.get(t.objectType.name??""),o=n.outFields,s=n.geometry;let a="",r="";s&&s.extent&&(a=p(s.extent.ymin,s.extent.xmin,M),r=p(s.extent.ymax,s.extent.xmax,M)),o&&1===o.length&&o[0]===b&&"1=1"===n.where||await Promise.all(i??[]);const d=this.sublayerCaches.has(t.objectType.name??"")?Array.from(this.sublayerCaches.get(t.objectType.name)?.values()):[],m=[];return d.forEach((i=>{if(i.geometry=e.linkChartDiagramLookup.get(i.attributes[t.objectIdField]),i.attributes[D]=i.geometry,a&&r){const n=e.linkChartGeohashLookup.get(i.attributes[t.objectIdField]);n?n>=a&&n<=r&&m.push(i):m.push(i)}else m.push(i)})),m}return this.retrieveDataFromService(n,t,i)}async getConnectedRecordIds(e){const t=[],i=[],n=new Map;return e.forEach((e=>{if(this.memberIdTypeLookup.has(e)){const t=this.memberIdTypeLookup.get(e);if(!this.entityTypeNames.has(t))return;n.has(t)?n.get(t)?.push(e):n.set(t,[e])}})),n.forEach(((e,n)=>{const o=`MATCH (n:${n})-[r]-(m) WHERE id(n) IN $ids RETURN id(r), type(r), id(m), labels(m)[0]`,s=new Promise((i=>{(async()=>{const i=(await y(this.knowledgeGraph,new u({openCypherQuery:o,bindParameters:{ids:e}}))).resultRowsStream.getReader();try{for(;;){const{done:e,value:n}=await i.read();if(e)break;for(let i=0;i<n.length;i++){const e=n[i];t.push({id:e[0],typeName:e[1]}),t.push({id:e[2],typeName:e[3]})}}}catch(n){if("AbortError"!==n.name)throw n;I.info("Request aborted as expected")}})().then((()=>{i()}))}));i.push(s)})),await Promise.all(i),t}async refreshCacheContent(e,t,n,s=!0){const a=h.getInstance(),r=[],p=new Map,d=new Map;this.knowledgeGraph.dataModel.entityTypes?.forEach((e=>{e.name&&d.set(e.name,e)})),this.knowledgeGraph.dataModel.relationshipTypes?.forEach((e=>{e.name&&d.set(e.name,e)})),e||this.inclusionModeDefinition?e?e.forEach((e=>{if(this.memberIdTypeLookup.has(e)){const t=this.memberIdTypeLookup.get(e);p.has(t)?p.get(t)?.push(e):p.set(t,[e])}})):this.inclusionModeDefinition?.namedTypeDefinitions?.forEach(((e,t)=>{e.useAllData?p.set(t,null):e.members&&e.members.forEach((e=>{p.has(t)&&null!==p.get(t)?p.get(t)?.push(e.id):p.set(t,[e.id])}))})):(this.knowledgeGraph.dataModel.entityTypes?.forEach((e=>{e.name&&p.set(e.name,null)})),this.knowledgeGraph.dataModel.entityTypes?.forEach((e=>{e.name&&p.set(e.name,null)})));for(const[m,l]of p){const e=new Promise((e=>{const r=async()=>{const e=new Set,r=[];let p,c="",h=!1;if(t||d.get(m)?.properties?.forEach((t=>{t.name&&e.add(t.name)})),n&&this.geographicLookup.has(m)){const t=this.geographicLookup.get(m)?.name;t&&e.add(t)}if(this.entityTypeNames.has(m))c=`MATCH (n:${m}) ${l?"WHERE id(n) IN $ids ":""}return ID(n)`,e.forEach((e=>{c+=`, n.${e}`,r.push(e)}));else{if(!this.relationshipTypeNames.has(m))throw new i("knowledge-graph:layer-data-manager",`The graph type of ${m} could not be determined. Was this type set in the KG data model and inclusion definition?`);h=!0,c=`MATCH ()-[n:${m}]->() ${l?"WHERE id(n) IN $ids ":""}return ID(n), id(startNode(n)), id(endNode(n))`,e.forEach((e=>{c+=`, n.${e}`,r.push(e)}))}p=new u(l?{openCypherQuery:c,bindParameters:{ids:l}}:{openCypherQuery:c});const f=(await y(this.knowledgeGraph,p)).resultRowsStream.getReader();for(;;){const{done:e,value:t}=await f.read();if(e)break;const i=[];for(let s=0;s<t.length;s++){const e=t[s];let n=0,a=0;const p={properties:{}};for(p.id=e[n],n++,a++,h&&(p.originId=e[n],n++,a++,p.destinationId=e[n],n++,a++,o(this.nodeConnectionsLookup,p.originId,(()=>new Set)).add(p.id),o(this.nodeConnectionsLookup,p.destinationId,(()=>new Set)).add(p.id));n<e.length;n++)p.properties[r[n-a]]=e[n];i.push(p)}const n=a.writeToStore(i,b,this.geographicLookup.get(m)?.name);this.sublayerCaches.has(m)||this.sublayerCaches.set(m,new Map),s&&!this.inclusionModeDefinition?.namedTypeDefinitions.has(m)&&this.inclusionModeDefinition?.namedTypeDefinitions.set(m,{useAllData:!1,members:new Map}),s&&!this.inclusionModeDefinition?.namedTypeDefinitions.get(m).members&&(this.inclusionModeDefinition.namedTypeDefinitions.get(m).members=new Map);const p=this.sublayerCaches.get(m);n.forEach((e=>{p?.set(e.attributes[b],e),s&&!this.inclusionModeDefinition?.namedTypeDefinitions.get(m).members.has(e.attributes[b])&&(this.inclusionModeDefinition?.namedTypeDefinitions.get(m).members.set(e.attributes[b],{id:e.attributes[b]}),this.memberIdTypeLookup.set(e.attributes[b],m))}))}};r().then((()=>{e(null)}))}));r.push(e),this._processingCacheUpdatesLookup.get(m)?.push(e)}await Promise.all(r)}removeFromLayer(e){const t=new Set,i=e.map((e=>e.id));for(const n of e)t.add(n.typeName),this.memberIdTypeLookup.delete(n.id),this.inclusionModeDefinition?.namedTypeDefinitions.forEach((e=>{e.members?.has(n.id)&&e.members.delete(n.id)}));t.forEach((e=>{this.sublayerCaches.get(e)?.forEach(((t,n)=>{i.includes(n)&&this.sublayerCaches.get(e)?.delete(n)}))}))}async retrieveDataFromService(e,t,n){const o=h.getInstance(),a=new Set,r=[];let p,f="",w=[];const T="relationship"===t.graphType,D=this.inclusionModeDefinition?.namedTypeDefinitions?.get(t.objectType.name)?.useAllData,M=t.parentCompositeLayer.sublayerIdsCache.get(t.objectType.name);let I=!D&&M?Array.from(M).sort():null;if(this.inclusionModeDefinition?.namedTypeDefinitions?.get(t.objectType.name)?.useAllData)this.inclusionModeDefinition?.namedTypeDefinitions?.get(t.objectType.name)?.useAllData&&null!=e.objectIds&&(I=e.objectIds);else if(null!=e.objectIds&&I&&I.length>0){const t=e.objectIds;e.objectIds=I.filter((e=>t.includes(e)))}else if(null!=e.objectIds)I=e.objectIds;else{if(this.inclusionModeDefinition?.namedTypeDefinitions.has(t.objectType.name)&&(!this.inclusionModeDefinition.namedTypeDefinitions.get(t.objectType.name)?.members||this.inclusionModeDefinition.namedTypeDefinitions.get(t.objectType.name)?.members?.size<1))return e.objectIds=[],[];e.objectIds=I}if(null!=e.outFields){const i=e.outFields;i.includes("*")?t.fields.forEach((e=>{a.add(e.name)})):i.forEach((e=>{e!==b&&e!==t.geometryFieldName&&a.add(e)}))}if(null!=e.geometry){const n=e.geometry;let o;const h=t.parentCompositeLayer.dataManager.knowledgeGraph.serviceDefinition,y=h?.spatialReference,b=h?.serviceCapabilities?.geometryCapabilities;let w=b?.geometryMaxBoundingRectangleSizeX,D=b?.geometryMaxBoundingRectangleSizeY;if(n?.extent?.spatialReference&&!n.spatialReference?.isWGS84?(await m(n.extent.spatialReference,c),o=l(n.extent,c)):o=n.extent,w&&D&&y){if(4326!==y.wkid){const e=new g({spatialReference:y,xmax:w,ymax:D}),t=l(e,c);w=t.xmax,D=t.ymax}if(o.xmax-o.xmin>w)throw new i("knowledge-graph:layer-data-manager",`Extent x bounds should be within ${w}° latitude, limit exceeded`);if(o.ymax-o.ymin>D)throw new i("knowledge-graph:layer-data-manager",`Extent y bounds should be within ${D}° longitude, limit exceeded`)}if(null!=e.where&&"1=1"!==e.where){const i=await s(e.where.toUpperCase(),t.fieldsIndex);t.fields.forEach((e=>{i.fieldNames.includes(e.name)&&a.add(e.name)}))}f=T?`Match ()-[n:${t.objectType.name}]->() WHERE esri.graph.ST_Intersects($param_filter_geom, n.${t.geometryFieldName}) return ID(n), id(startNode(r)), id(endNode(r))`:`Match (n:${t.objectType.name}) WHERE esri.graph.ST_Intersects($param_filter_geom, n.${t.geometryFieldName}) return ID(n)`,t.geometryFieldName&&a.add(t.geometryFieldName),a.forEach((e=>{f+=`, n.${e}`,r.push(e)})),p=new u({openCypherQuery:f,bindParameters:{param_filter_geom:new d({rings:[[[o.xmin,o.ymin],[o.xmin,o.ymax],[o.xmax,o.ymax],[o.xmax,o.ymin],[o.xmin,o.ymin]]]})}})}else{let i="";if(null!=e.where&&"1=1"!==e.where){const n=await s(e.where,t.fieldsIndex);t.fields.forEach((e=>{n.fieldNames.includes(e.name)&&a.add(e.name)}));const o=["column-reference","string","number","binary-expression"],r=["=","<","<=","<>",">",">=","AND","OR","LIKE"];let p=!1;const d=e=>{if("column-reference"===e.type)return`n.${e.column}`;if("string"===e.type)return`'${e.value}'`;if("number"===e.type)return`${e.value}`;if("binary-expression"===e.type&&o.includes(e.left.type)&&o.includes(e.right.type)&&r.includes(e.operator))return`${d(e.left)} ${e.operator} ${d(e.right)}`;if("binary-expression"===e.type&&"LIKE"===e.operator){let t="";if("function"===e.left.type&&"column-reference"===e.left.args.value[0].type)t+=`lower(n.${e.left.args.value[0].column})`;else{if("column-reference"!==e.left.type)return p=!0,"";t+=`lower(n.${e.left.column})`}if(t+=" CONTAINS (","string"!==e.right.type)return p=!0,"";{let i=e.right.value;"%"===i.charAt(0)&&(i=i.slice(1)),"%"===i.charAt(i.length-1)&&(i=i.slice(0,-1)),t+=`'${i.toLowerCase()}')`}return t}return p=!0,""};i=d(n.parseTree),p&&(i="")}let n="";n=T?`Match ()-[n:${t.objectType.name}]->()`:`Match (n:${t.objectType.name})`;let o=!1;I&&(o=!0,n+=" WHERE ID(n) IN $ids"),i&&(n+=o?" AND":" WHERE",n+=` ${i}`),n+=" return ID(n)",T&&(n+=", id(startNode(n)), id(endNode(n))"),e.returnGeometry&&t.geometryFieldName&&a.add(t.geometryFieldName),a.forEach((e=>{n+=`, n.${e}`,r.push(e)})),p=new u(I?{openCypherQuery:n,bindParameters:{ids:I}}:{openCypherQuery:n})}const k=(await y(t.parentCompositeLayer.dataManager.knowledgeGraph,p,n)).resultRowsStream.getReader();for(;;){const{done:e,value:i}=await k.read();if(e)break;const n=[];for(let t=0;t<i.length;t++){const e=i[t];let o=0,s=0;const a={properties:{}};for(a.id=e[o],o++,s++,T&&(a.originId=e[o],o++,s++,a.destinationId=e[o],o++,s++);o<e.length;o++)a.properties[r[o-s]]=e[o];n.push(a)}w=w.concat(o.writeToStore(n,b,t.parentCompositeLayer.dataManager.geographicLookup.get(t.objectType.name)?.name))}return w}};e([a()],k.prototype,"knowledgeGraph",void 0),e([a()],k.prototype,"inclusionModeDefinition",void 0),e([a()],k.prototype,"entityTypeNames",void 0),e([a()],k.prototype,"relationshipTypeNames",void 0),e([a()],k.prototype,"geographicLookup",void 0),e([a()],k.prototype,"sublayerCaches",void 0),e([a()],k.prototype,"nodeConnectionsLookup",void 0),e([a()],k.prototype,"memberIdTypeLookup",void 0),k=e([r("esri.rest.knowledgeGraph.knowledgeGraphLayer.KnowledgeGraphLayerDataManager")],k);export{M as GEOHASH_ENCODING_PRECISION,k as KnowledgeGraphLayerDataManager,T as MOCK_DESTINATION_ID_FIELD_NAME,D as MOCK_LAYOUT_GEOMETRY_FIELD_NAME,b as MOCK_OID_FIELD_NAME,w as MOCK_ORIGIN_ID_FIELD_NAME};
|
package/package.json
CHANGED
package/support/revision.js
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.28/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
const a="
|
|
5
|
+
const a="20230724",e="83a90f2e164b63aa78a3786a0edf1b528e85a29f";export{a as buildDate,e as commitHash};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.28/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import"../../../../core/has.js";import{g as e,h as t,r as s,s as a}from"../../../../chunks/mat3.js";import{c as r}from"../../../../chunks/mat3f32.js";import{BucketType as i}from"./enums.js";import{CircleRenderBucket as o,SymbolRenderBucket as h,LineRenderBucket as n,FillRenderBucket as l}from"./RenderBucket.js";import{FADE_DURATION as
|
|
5
|
+
import"../../../../core/has.js";import{g as e,h as t,r as s,s as a}from"../../../../chunks/mat3.js";import{c as r}from"../../../../chunks/mat3f32.js";import{BucketType as i}from"./enums.js";import{CircleRenderBucket as o,SymbolRenderBucket as h,LineRenderBucket as n,FillRenderBucket as l}from"./RenderBucket.js";import{FADE_DURATION as c}from"./decluttering/config.js";import{TiledDisplayObject as y}from"../webgl/TiledDisplayObject.js";class d extends y{constructor(e,t,s,a,r,i,o,h=null){super(e,t,s,a,r,i,4096,4096),this.styleRepository=o,this._memCache=h,this.type="vector-tile",this._referenced=0,this._hasSymbolBuckets=!1,this._memoryUsedByLayerData=0,this.layerData=new Map,this.status="loading",this.allSymbolsFadingOut=!1,this.lastOpacityUpdate=0,this.symbols=new Map,this.isCoverage=!1,this.neededForCoverage=!1,this.decluttered=!1,this.parentTile=null,this.childrenTiles=new Set,this._processed=!1,this._referenced=1,this.id=e.id}get hasSymbolBuckets(){return this._hasSymbolBuckets}get isFading(){return this._hasSymbolBuckets&&performance.now()-this.lastOpacityUpdate<c}get isHoldingForFade(){return this._hasSymbolBuckets&&(!this.allSymbolsFadingOut||performance.now()-this.lastOpacityUpdate<c)}get wasRequested(){return"errored"===this.status||"loaded"===this.status||"reloading"===this.status}setData(e){this.changeDataImpl(e),this.requestRender(),this.ready(),this._processed=!0}deleteLayerData(e){let t=!1;for(const s of e){const e=this.layerData.get(s);e&&(this._memoryUsedByLayerData-=e.memoryUsed,e.type===i.SYMBOL&&this.symbols.delete(s)&&(t=!0),e.destroy(),this.layerData.delete(s))}this._memCache?.updateSize(this.key.id,this,this._memoryUsedByLayerData),t&&this.emit("symbols-changed"),this.requestRender()}processed(){return this._processed}hasData(){return this.layerData.size>0}dispose(){"unloaded"!==this.status&&(m.delete(this),d._destroyRenderBuckets(this.layerData),this.layerData=null,this._memoryUsedByLayerData=0,this.destroy(),this.status="unloaded")}release(){return 0==--this._referenced&&(this.dispose(),this.stage=null,!0)}retain(){++this._referenced}get referenced(){return this._referenced}get memoryUsed(){return this._memoryUsedByLayerData+256}changeDataImpl(e){let t=!1;if(e){const{bucketsWithData:s,emptyBuckets:a}=e,r=this._createRenderBuckets(s);if(a&&a.byteLength>0){const e=new Uint32Array(a);for(const t of e)this._deleteLayerData(t)}for(const[e,o]of r)this._deleteLayerData(e),o.type===i.SYMBOL&&(this.symbols.set(e,o.symbols),t=!0),this._memoryUsedByLayerData+=o.memoryUsed,this.layerData.set(e,o);this._memCache?.updateSize(this.key.id,this,this.memoryUsed)}this._hasSymbolBuckets=!1;for(const[s,a]of this.layerData)a.type===i.SYMBOL&&(this._hasSymbolBuckets=!0);t&&this.emit("symbols-changed")}attachWithContext(e){this.stage={context:e,trashDisplayObject(e){e.processDetach()},untrashDisplayObject:()=>!1}}setTransform(r){super.setTransform(r);const i=this.resolution/(r.resolution*r.pixelRatio),o=this.width/this.rangeX*i,h=this.height/this.rangeY*i,n=[0,0];r.toScreen(n,[this.x,this.y]);const l=this.transforms.tileUnitsToPixels;e(l),t(l,l,n),s(l,l,Math.PI*r.rotation/180),a(l,l,[o,h,1])}_createTransforms(){return{dvs:r(),tileMat3:r(),tileUnitsToPixels:r()}}static _destroyRenderBuckets(e){if(!e)return;const t=new Set;for(const s of e.values())t.has(s)||(s.destroy(),t.add(s));e.clear()}_createRenderBuckets(e){const t=new Map,s=new Map;for(const a of e){const e=this._deserializeBucket(a,s);for(const s of e.layerUIDs)t.set(s,e)}return t}_deserializeBucket(e,t){let s=t.get(e);if(s)return s;switch(new Uint32Array(e)[0]){case i.FILL:s=new l(e,this.styleRepository);break;case i.LINE:s=new n(e,this.styleRepository);break;case i.SYMBOL:s=new h(e,this.styleRepository,this);break;case i.CIRCLE:s=new o(e,this.styleRepository)}return t.set(e,s),s}_deleteLayerData(e){if(!this.layerData.has(e))return;const t=this.layerData.get(e);this._memoryUsedByLayerData-=t.memoryUsed,t.destroy(),this.layerData.delete(e)}}const m=new Map;function u(){m.forEach(((e,t)=>{console.log(`\n${t.key}:`),e[0].forEach((e=>console.log(e))),console.log("========"),e[1].forEach((e=>console.log(e)))}))}export{d as VectorTile,u as printAllocations};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.28/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{createResolver as e}from"../../../../core/promiseUtils.js";import{create as t}from"../../../../geometry/support/aaBoundingRect.js";import{SymbolFader as s}from"./decluttering/SymbolFader.js";import{Visibility as r,StyleLayerType as i}from"./style/StyleDefinition.js";import{WGLDrawPhase as l}from"../webgl/enums.js";import{RenderableTile as o}from"../webgl/RenderableTile.js";import n from"../webgl/TileContainer.js";import a from"../../tiling/TileCoverage.js";import d from"../../tiling/TileKey.js";import{StencilOperation as h,CompareFunction as c,BlendFactor as u}from"../../../webgl/enums.js";const y=1e-6;function p(e,t){if(e){const s=e.getLayoutProperty("visibility");if(!s||s.getValue()!==r.NONE&&(void 0===e.minzoom||e.minzoom<t+y)&&(void 0===e.maxzoom||e.maxzoom>=t-y))return!0}return!1}class m extends n{constructor(e){super(e),this._backgroundTiles=[],this._pointToCallbacks=new Map}destroy(){this.removeAllChildren(),this._spriteMosaic?.dispose(),this._spriteMosaic=null,this._glyphMosaic?.dispose(),this._glyphMosaic=null,null!=this._symbolFader&&(this._symbolFader.clear(),this._symbolFader=null),this._styleRepository=null,this._backgroundTiles=[],this._pointToCallbacks.clear()}setStyleResources(e,t,r){
|
|
5
|
+
import{createResolver as e}from"../../../../core/promiseUtils.js";import{create as t}from"../../../../geometry/support/aaBoundingRect.js";import{SymbolFader as s}from"./decluttering/SymbolFader.js";import{Visibility as r,StyleLayerType as i}from"./style/StyleDefinition.js";import{WGLDrawPhase as l}from"../webgl/enums.js";import{RenderableTile as o}from"../webgl/RenderableTile.js";import n from"../webgl/TileContainer.js";import a from"../../tiling/TileCoverage.js";import d from"../../tiling/TileKey.js";import{StencilOperation as h,CompareFunction as c,BlendFactor as u}from"../../../webgl/enums.js";const y=1e-6;function p(e,t){if(e){const s=e.getLayoutProperty("visibility");if(!s||s.getValue()!==r.NONE&&(void 0===e.minzoom||e.minzoom<t+y)&&(void 0===e.maxzoom||e.maxzoom>=t-y))return!0}return!1}class m extends n{constructor(e){super(e),this._backgroundTiles=[],this._pointToCallbacks=new Map}destroy(){this.removeAllChildren(),this._spriteMosaic?.dispose(),this._spriteMosaic=null,this._glyphMosaic?.dispose(),this._glyphMosaic=null,null!=this._symbolFader&&(this._symbolFader.clear(),this._symbolFader=null),this._styleRepository=null,this._backgroundTiles=[],this._pointToCallbacks.clear()}get fading(){return this._symbolFader?.fading??!1}setStyleResources(e,t,r){this._spriteMosaic=e,this._glyphMosaic=t,this._styleRepository=r,null==this._symbolFader&&(this._symbolFader=new s(this._styleRepository,this.children)),this._symbolFader.styleRepository=r}setSpriteMosaic(e){this._spriteMosaic?.dispose(),this._spriteMosaic=e}deleteStyleLayers(e){null!=this._symbolFader&&this._symbolFader.deleteStyleLayers(e)}async hitTest(t){const s=e();return this._pointToCallbacks.set(t,s),this.requestRender(),s.promise}createRenderParams(e){return{...super.createRenderParams(e),renderPass:null,styleLayer:null,styleLayerUID:-1,glyphMosaic:this._glyphMosaic,spriteMosaic:this._spriteMosaic,hasClipping:!!this._clippingInfos}}doRender(e){!this.visible||e.drawPhase!==l.MAP&&e.drawPhase!==l.DEBUG||void 0===this._spriteMosaic||super.doRender(e)}addChild(e){return super.addChild(e),null!=this._symbolFader?this._symbolFader.addTile(e):e.decluttered=!0,this.requestRender(),e}removeChild(e){return null!=this._symbolFader&&this._symbolFader.removeTile(e),this.requestRender(),super.removeChild(e)}renderChildren(e){const{drawPhase:t}=e;if(t!==l.DEBUG){if(this._doRender(e),this._pointToCallbacks.size>0){e.drawPhase=l.HITTEST;const s=e.painter.effects.hittestVTL;s.bind(e),this._doRender(e),s.draw(e,this._pointToCallbacks),s.unbind(e),e.drawPhase=t}}else super.renderChildren(e)}removeAllChildren(){for(let e=0;e<this.children.length;e++){const t=this.children[e];null!=this._symbolFader&&this._symbolFader.removeTile(t),t.dispose()}super.removeAllChildren()}getStencilTarget(){return this.children.filter((e=>e.neededForCoverage&&e.hasData()))}restartDeclutter(){null!=this._symbolFader&&this._symbolFader.restartDeclutter()}_doRender(e){const{context:t}=e,s=this._styleRepository;if(!s)return;const r=s.layers;let i=!0;e.drawPhase===l.HITTEST&&(i=!1),s.backgroundBucketIds.length>0&&(e.renderPass="background",this._renderBackgroundLayers(e,s.backgroundBucketIds)),super.renderChildren(e),e.drawPhase===l.MAP&&this._fade(e.displayLevel,e.state);const o=this.children.filter((e=>e.visible&&e.hasData()));if(!o||0===o.length)return t.bindVAO(),t.setStencilTestEnabled(!0),void t.setBlendingEnabled(!0);for(const l of o)l.triangleCount=0;t.setStencilWriteMask(0),t.setColorMask(!0,!0,!0,!0),t.setStencilOp(h.KEEP,h.KEEP,h.REPLACE),t.setStencilTestEnabled(!0),t.setBlendingEnabled(!1),t.setDepthTestEnabled(!0),t.setDepthWriteEnabled(!0),t.setDepthFunction(c.LEQUAL),t.setClearDepth(1),t.clear(t.gl.DEPTH_BUFFER_BIT),e.renderPass="opaque";for(let l=r.length-1;l>=0;l--)this._renderStyleLayer(r[l],e,o);t.setDepthWriteEnabled(!1),t.setBlendingEnabled(i),t.setBlendFunctionSeparate(u.ONE,u.ONE_MINUS_SRC_ALPHA,u.ONE,u.ONE_MINUS_SRC_ALPHA),e.renderPass="translucent";for(let l=0;l<r.length;l++)this._renderStyleLayer(r[l],e,o);t.bindVAO(),t.setStencilTestEnabled(!0),t.setBlendingEnabled(!0)}_fade(e,t){null!=this._symbolFader&&(this._symbolFader.update(e,t)||this.requestRender())}_renderStyleLayer(e,t,s){const{painter:l,renderPass:o}=t;if(void 0===e)return;const n=e.getLayoutProperty("visibility");if(n&&n.getValue()===r.NONE)return;let a;switch(e.type){case i.BACKGROUND:return;case i.FILL:if("opaque"!==o&&"translucent"!==t.renderPass)return;a="vtlFill";break;case i.LINE:if("translucent"!==o)return;a="vtlLine";break;case i.CIRCLE:if("translucent"!==o)return;a="vtlCircle";break;case i.SYMBOL:if("translucent"!==o)return;a="vtlSymbol"}if(s=e.type===i.SYMBOL?s.filter((e=>e.decluttered)):s.filter((e=>e.neededForCoverage)),"vtlSymbol"!==a){const r=t.displayLevel;if(0===s.length||void 0!==e.minzoom&&e.minzoom>=r+y||void 0!==e.maxzoom&&e.maxzoom<r-y)return}const d=e.uid;t.styleLayerUID=d,t.styleLayer=e;for(const r of s)if(r.layerData.has(d)){l.renderObjects(t,s,a);break}}_renderBackgroundLayers(e,s){const{context:r,displayLevel:n,painter:u,state:y}=e,m=this._styleRepository;let _=!1;for(const t of s){if(m.getLayerById(t).type===i.BACKGROUND&&p(m.getLayerById(t),n)){_=!0;break}}if(!_)return;const b=this._tileInfoView.getTileCoverage(e.state,0,!0,"smallest"),{spans:f,lodInfo:g}=b,{level:T}=g,E=t(),C=[];if(this._renderPasses){const t=this._renderPasses[0];null!=this._clippingInfos&&(t.brushes[0].prepareState(e),t.brushes[0].drawMany(e,this._clippingInfos))}const L=this._backgroundTiles;let v,F=0;for(const{row:i,colFrom:l,colTo:a}of f)for(let e=l;e<=a;e++){if(F<L.length)v=L[F],v.key.set(T,i,g.normalizeCol(e),g.getWorldForColumn(e)),this._tileInfoView.getTileBounds(E,v.key,!1),v.x=E[0],v.y=E[3],v.resolution=this._tileInfoView.getTileResolution(T);else{const s=new d(T,i,g.normalizeCol(e),g.getWorldForColumn(e)),r=this._tileInfoView.getTileBounds(t(),s),l=this._tileInfoView.getTileResolution(T);v=new o(s,l,r[0],r[3],512,512,4096,4096),L.push(v)}v.setTransform(y),C.push(v),F++}r.setStencilWriteMask(0),r.setColorMask(!0,!0,!0,!0),r.setStencilOp(h.KEEP,h.KEEP,h.REPLACE),r.setStencilFunction(c.EQUAL,0,255);let S=!0;e.drawPhase===l.HITTEST&&(S=!1),r.setStencilTestEnabled(S);for(const t of s){const s=m.getLayerById(t);s.type===i.BACKGROUND&&p(s,n)&&(e.styleLayerUID=s.uid,e.styleLayer=s,u.renderObjects(e,C,"vtlBackground"))}a.pool.release(b)}}export{m as VectorTileContainer};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.28/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import t
|
|
5
|
+
import{signal as t}from"../../../../../core/signal.js";import{DECLUTTER_BUDGET as e,FADE_DURATION as i}from"./config.js";import{VTLUniqueSymbol as s}from"./core.js";import{CollisionJob as o}from"./jobs.js";import{SymbolDeclutterer as l}from"./SymbolDeclutterer.js";import{SymbolRepository as r}from"./SymbolRepository.js";import{writeOpacityToBuffers as a}from"./util.js";import{Visibility as h}from"../style/StyleDefinition.js";const n=.5,c=1e-6;class _{constructor(e,i){this.styleRepository=e,this._tileToHandle=new Map,this._viewState={scale:0,rotation:0,center:[0,0],size:[0,0]},this._declutterViewState={scale:0,rotation:0,center:[0,0],size:[0,0]},this._completed=!1,this._fading=t(!1),this._symbolRepository=new r(4096,i,(()=>new s)),this._symbolDeclutterer=new l(i,this._symbolRepository,((t,e,i)=>new o(t,e,i,this.styleRepository,this._zoom,this._viewState.rotation)),((t,e)=>{t.allSymbolsFadingOut=!0,t.lastOpacityUpdate=e,a(t,e,!0),t.decluttered=!0,t.requestRender()}),((t,e)=>this.styleRepository.getStyleLayerByUID(t.styleLayerUID).z-this.styleRepository.getStyleLayerByUID(e.styleLayerUID).z),(t=>{const e=this.styleRepository.getStyleLayerByUID(t);if(this._zoom+c<e.minzoom||this._zoom-c>=e.maxzoom)return!1;const i=e.getLayoutProperty("visibility");return!i||i.getValue()!==h.NONE}))}get fading(){return this._fading.value}addTile(t){t.decluttered=!1,this._tileToHandle.set(t,t.on("symbols-changed",(()=>{this._symbolRepository.add(t),this.restartDeclutter()}))),this._symbolRepository.add(t),this.restartDeclutter()}removeTile(t){const e=this._tileToHandle.get(t);e&&(this._symbolRepository.removeTile(t),this.restartDeclutter(),e.remove(),this._tileToHandle.delete(t))}update(t,e){return this._zoom=t,this._viewState={scale:e.scale,rotation:e.rotation,center:[e.center[0],e.center[1]],size:[e.size[0],e.size[1]]},this._continueDeclutter(),this._completed}restartDeclutter(){this._completed=!1,this._symbolDeclutterer.restart(),this._notifyUnstable()}clear(){this._completed=!1,this._symbolRepository=null,this._symbolDeclutterer.restart(),this._tileToHandle.forEach((t=>t.remove())),this._tileToHandle.clear()}get stale(){return this._zoom!==this._declutterZoom||this._viewState.size[0]!==this._declutterViewState.size[0]||this._viewState.size[1]!==this._declutterViewState.size[1]||this._viewState.scale!==this._declutterViewState.scale||this._viewState.rotation!==this._declutterViewState.rotation}deleteStyleLayers(t){this._symbolRepository.deleteStyleLayers(t)}_continueDeclutter(){this._completed&&!this.stale||(this._symbolDeclutterer.running||(this._declutterZoom=this._zoom,this._declutterViewState.center[0]=this._viewState.center[0],this._declutterViewState.center[1]=this._viewState.center[1],this._declutterViewState.rotation=this._viewState.rotation,this._declutterViewState.scale=this._viewState.scale,this._declutterViewState.size[0]=this._viewState.size[0],this._declutterViewState.size[1]=this._viewState.size[1],this._symbolDeclutterer.restart()),this._symbolDeclutterer.setScreenSize(this._viewState.size[0],this._viewState.size[1]),this._completed=this._symbolDeclutterer.continue(e),this._completed&&this._scheduleNotifyStable())}_scheduleNotifyStable(){null!=this._stableNotificationHandle&&clearTimeout(this._stableNotificationHandle),this._stableNotificationHandle=setTimeout((()=>{this._stableNotificationHandle=null,this._fading.value=!1}),(1+n)*i)}_notifyUnstable(){null!=this._stableNotificationHandle&&(clearTimeout(this._stableNotificationHandle),this._stableNotificationHandle=null),this._fading.value=!0}}export{_ as SymbolFader};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.28/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../Graphic.js";import{clone as i}from"../../../core/lang.js";import s from"../../../core/Logger.js";import{destroyMaybe as r}from"../../../core/maybe.js";import{isAbortError as a}from"../../../core/promiseUtils.js";import{property as l}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import{subclass as o}from"../../../core/accessorSupport/decorators/subclass.js";import{diff as n,hasDiff as h}from"../../../core/accessorSupport/diffUtils.js";import{create as u}from"../../../geometry/support/aaBoundingRect.js";import{equals as c}from"../../../geometry/support/spatialReferenceUtils.js";import{StyleUpdateType as y}from"../engine/vectorTiles/enums.js";import{TileHandler as p}from"../engine/vectorTiles/TileHandler.js";import{TileManager as _}from"../engine/vectorTiles/TileManager.js";import{VectorTile as d}from"../engine/vectorTiles/VectorTile.js";import{VectorTileContainer as f}from"../engine/vectorTiles/VectorTileContainer.js";import{StyleLayerType as g}from"../engine/vectorTiles/style/StyleDefinition.js";import m from"../engine/vectorTiles/style/StyleRepository.js";import{LayerView2DMixin as T}from"./LayerView2D.js";import C from"../tiling/TileInfoViewPOT.js";import v from"../tiling/TileQueue.js";import R from"../../layers/LayerView.js";let H=class extends(T(R)){constructor(){super(...arguments),this._styleChanges=[],this._fetchQueue=null,this._parseQueue=null,this._tileHandlerPromise=null,this._isTileHandlerReady=!1,this._collisionOverlay=null,this.fading=!1}async hitTest(e,i){if(!this._tileHandlerPromise)return null;await this._tileHandlerPromise;const s=await this._vectorTileContainer.hitTest(i);if(!s||0===s.length)return null;const r=s[0]-1,a=this._styleRepository,l=a.getStyleLayerByUID(r);if(!l)return null;const o=a.getStyleLayerIndex(l.id);return[{type:"graphic",mapPoint:e,layer:this.layer,graphic:new t({attributes:{layerId:o,layerName:l.id,layerUID:r},layer:this.layer,sourceLayer:this.layer})}]}update(e){if(this._tileHandlerPromise&&this._isTileHandlerReady)return e.pixelRatio!==this._tileHandler.devicePixelRatio?(this._start(),void(this._tileHandler.devicePixelRatio=e.pixelRatio)):void(this._styleChanges.length>0?this._tileHandlerPromise=this._applyStyleChanges():(this._fetchQueue.pause(),this._parseQueue.pause(),this._fetchQueue.state=e.state,this._parseQueue.state=e.state,this._tileManager.update(e)||this.requestUpdate(),this._parseQueue.resume(),this._fetchQueue.resume()))}attach(){const{style:e}=this.layer.currentStyleInfo;this._styleRepository=new m(e),this._tileInfoView=new C(this.layer.tileInfo,this.layer.fullExtent),this._vectorTileContainer=new f(this._tileInfoView),this._tileHandler=new p(this.layer,this._styleRepository,window.devicePixelRatio||1),this.container.addChild(this._vectorTileContainer),this._start(),this.addAttachHandles([this._vectorTileContainer.on("fade-start",(()=>{this.fading=!0,this.requestUpdate()})),this._vectorTileContainer.on("fade-complete",(()=>{this._collisionOverlay?.requestRender(),this.fading=!1,this.requestUpdate()})),this.layer.on("paint-change",(e=>{if(e.isDataDriven)this._styleChanges.push({type:y.PAINTER_CHANGED,data:e}),this.requestUpdate();else{const t=this._styleRepository,i=t.getLayerById(e.layer);if(!i)return;const s=i.type===g.SYMBOL;t.setPaintProperties(e.layer,e.paint),s&&this._vectorTileContainer.restartDeclutter(),this._vectorTileContainer.requestRender()}})),this.layer.on("layout-change",(e=>{const t=this._styleRepository,i=t.getLayerById(e.layer);if(!i)return;const s=n(i.layout,e.layout);if(null!=s){if(h(s,"visibility")&&1===S(s))return t.setLayoutProperties(e.layer,e.layout),i.type===g.SYMBOL&&this._vectorTileContainer.restartDeclutter(),void this._vectorTileContainer.requestRender();this._styleChanges.push({type:y.LAYOUT_CHANGED,data:e}),this.requestUpdate()}})),this.layer.on("style-layer-visibility-change",(e=>{const t=this._styleRepository,i=t.getLayerById(e.layer);i&&(t.setStyleLayerVisibility(e.layer,e.visibility),i.type===g.SYMBOL&&this._vectorTileContainer.restartDeclutter(),this._vectorTileContainer.requestRender())})),this.layer.on("style-layer-change",(e=>{this._styleChanges.push({type:y.LAYER_CHANGED,data:e}),this.requestUpdate()})),this.layer.on("delete-style-layer",(e=>{this._styleChanges.push({type:y.LAYER_REMOVED,data:e}),this.requestUpdate()})),this.layer.on("load-style",(()=>this._loadStyle())),this.layer.on("spriteSource-change",(e=>{this._newSpriteSource=e.spriteSource,this._styleChanges.push({type:y.SPRITES_CHANGED,data:null});const t=this._styleRepository.layers;for(const i of t)switch(i.type){case g.SYMBOL:i.getLayoutProperty("icon-image")&&this._styleChanges.push({type:y.LAYOUT_CHANGED,data:{layer:i.id,layout:i.layout}});break;case g.LINE:i.getPaintProperty("line-pattern")&&this._styleChanges.push({type:y.PAINTER_CHANGED,data:{layer:i.id,paint:i.paint,isDataDriven:i.isPainterDataDriven()}});break;case g.FILL:i.getLayoutProperty("fill-pattern")&&this._styleChanges.push({type:y.PAINTER_CHANGED,data:{layer:i.id,paint:i.paint,isDataDriven:i.isPainterDataDriven()}})}this.requestUpdate()}))])}detach(){this._stop(),this.container.removeAllChildren(),this._vectorTileContainer=r(this._vectorTileContainer),this._tileHandler=r(this._tileHandler)}moveStart(){this.requestUpdate()}viewChange(){this.requestUpdate()}moveEnd(){this._collisionOverlay&&this._vectorTileContainer.restartDeclutter(),this.requestUpdate()}supportsSpatialReference(e){return c(this.layer.tileInfo?.spatialReference,e)}canResume(){let e=super.canResume();const{currentStyleInfo:t}=this.layer;if(e&&t?.layerDefinition){const i=this.view.scale,{minScale:s,maxScale:r}=t.layerDefinition;t&&t.layerDefinition&&(s&&s<i&&(e=!1),r&&r>i&&(e=!1))}return e}isUpdating(){return this.fading}acquireTile(e){const t=this._createVectorTile(e);return this._updatingHandles.addPromise(this._fetchQueue.push(t.key).then((e=>this._parseQueue.push({key:t.key,data:e}))).then((e=>{t.once("attach",(()=>this.requestUpdate())),t.setData(e),this.requestUpdate()})).catch((e=>{a(e)||s.getLogger(this).error(e)}))),t}releaseTile(e){const t=e.key.id;this._fetchQueue.abort(t),this._parseQueue.abort(t),this.requestUpdate()}_start(){if(this._stop(),this._tileManager=new _({acquireTile:e=>this.acquireTile(e),releaseTile:e=>this.releaseTile(e),tileInfoView:this._tileInfoView},this._vectorTileContainer),!this.layer.currentStyleInfo)return;const e=new AbortController,t=this._tileHandler.start({signal:e.signal}).then((()=>{this._fetchQueue=new v({tileInfoView:this._tileInfoView,process:(e,t)=>this._getTileData(e,t),concurrency:15}),this._parseQueue=new v({tileInfoView:this._tileInfoView,process:(e,t)=>this._parseTileData(e,t),concurrency:8}),this.requestUpdate(),this._isTileHandlerReady=!0}));this._tileHandler.spriteMosaic.then((e=>{this._vectorTileContainer.setStyleResources(e,this._tileHandler.glyphMosaic,this._styleRepository),this.requestUpdate()})),this._tileHandlerAbortController=e,this._tileHandlerPromise=t}_stop(){if(!this._tileHandlerAbortController||!this._vectorTileContainer)return;const e=this._tileHandlerAbortController;e&&e.abort(),this._tileHandlerPromise=null,this._isTileHandlerReady=!1,this._fetchQueue=r(this._fetchQueue),this._parseQueue=r(this._parseQueue),this._tileManager=r(this._tileManager),this._vectorTileContainer.removeAllChildren()}async _getTileData(e,t){return this._tileHandler.fetchTileData(e,t)}async _parseTileData(e,t){return this._tileHandler.parseTileData(e,t)}async _applyStyleChanges(){this._isTileHandlerReady=!1,this._fetchQueue.pause(),this._parseQueue.pause(),this._fetchQueue.clear(),this._parseQueue.clear(),this._tileManager.clearCache();const e=this._styleChanges;try{await this._tileHandler.updateStyle(e)}catch(o){s.getLogger(this).error("error applying vector-tiles style update",o.message),this._fetchQueue.resume(),this._parseQueue.resume(),this._isTileHandlerReady=!0}const t=this._styleRepository,i=[];e.forEach((e=>{if(e.type!==y.LAYER_REMOVED)return;const s=e.data,r=t.getLayerById(s.layer);r&&i.push(r.uid)}));const r=[];let a;e.forEach((e=>{const i=e.type,s=e.data;switch(i){case y.PAINTER_CHANGED:t.setPaintProperties(s.layer,s.paint),a=s.layer;break;case y.LAYOUT_CHANGED:t.setLayoutProperties(s.layer,s.layout),a=s.layer;break;case y.LAYER_REMOVED:return void t.deleteStyleLayer(s.layer);case y.LAYER_CHANGED:t.setStyleLayer(s.layer,s.index),a=s.layer.id;break;case y.SPRITES_CHANGED:this._vectorTileContainer.setSpriteMosaic(this._tileHandler.setSpriteSource(this._newSpriteSource)),this._newSpriteSource=null,a=null}const l=t.getLayerById(a);l&&r.push(l.uid)}));const l=this._vectorTileContainer.children;if(i.length>0){this._vectorTileContainer.deleteStyleLayers(i);for(const e of l)e.deleteLayerData(i)}if(this._fetchQueue.resume(),this._parseQueue.resume(),r.length>0){const e=[];for(const t of l){const i=this._updatingHandles.addPromise(this._fetchQueue.push(t.key).then((e=>this._parseQueue.push({key:t.key,data:e,styleLayerUIDs:r}))).then((e=>t.setData(e))));e.push(i)}await Promise.all(e)}this._styleChanges=[],this._isTileHandlerReady=!0,this.requestUpdate()}async _loadStyle(){const{style:e}=this.layer.currentStyleInfo,t=i(e);this._isTileHandlerReady=!1,this._fetchQueue.pause(),this._parseQueue.pause(),this._fetchQueue.clear(),this._parseQueue.clear(),this._styleRepository=new m(t),this._vectorTileContainer.destroy(),this._tileManager.clear(),this._tileHandlerAbortController.abort(),this._tileHandlerAbortController=new AbortController;const{signal:s}=this._tileHandlerAbortController;try{this._tileHandlerPromise=this._tileHandler.setStyle(this._styleRepository,t),await this._tileHandlerPromise}catch(l){if(!a(l))throw l}if(s.aborted)return this._fetchQueue.resume(),this._parseQueue.resume(),this._isTileHandlerReady=!0,void this.requestUpdate();const r=await this._tileHandler.spriteMosaic;this._vectorTileContainer.setStyleResources(r,this._tileHandler.glyphMosaic,this._styleRepository),this._fetchQueue.resume(),this._parseQueue.resume(),this._isTileHandlerReady=!0,this.requestUpdate()}_createVectorTile(e){const t=this._tileInfoView.getTileBounds(u(),e),i=this._tileInfoView.getTileResolution(e.level);return new d(e,i,t[0],t[3],512,512,this._styleRepository)}};function S(e){if(null==e)return 0;switch(e.type){case"partial":return Object.keys(e.diff).length;case"complete":return Math.max(Object.keys(e.oldValue).length,Object.keys(e.newValue).length);case"collection":return Object.keys(e.added).length+Object.keys(e.changed).length+Object.keys(e.removed).length}}e([l()],H.prototype,"_isTileHandlerReady",void 0),e([l()],H.prototype,"fading",void 0),H=e([o("esri.views.2d.layers.VectorTileLayerView2D")],H);const D=H;export{D as default};
|
|
5
|
+
import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../Graphic.js";import{clone as i}from"../../../core/lang.js";import s from"../../../core/Logger.js";import{destroyMaybe as r}from"../../../core/maybe.js";import{isAbortError as a}from"../../../core/promiseUtils.js";import{property as l}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import{subclass as o}from"../../../core/accessorSupport/decorators/subclass.js";import{diff as n,hasDiff as h}from"../../../core/accessorSupport/diffUtils.js";import{create as y}from"../../../geometry/support/aaBoundingRect.js";import{equals as u}from"../../../geometry/support/spatialReferenceUtils.js";import{StyleUpdateType as c}from"../engine/vectorTiles/enums.js";import{TileHandler as p}from"../engine/vectorTiles/TileHandler.js";import{TileManager as d}from"../engine/vectorTiles/TileManager.js";import{VectorTile as _}from"../engine/vectorTiles/VectorTile.js";import{VectorTileContainer as f}from"../engine/vectorTiles/VectorTileContainer.js";import{StyleLayerType as m}from"../engine/vectorTiles/style/StyleDefinition.js";import g from"../engine/vectorTiles/style/StyleRepository.js";import{LayerView2DMixin as T}from"./LayerView2D.js";import C from"../tiling/TileInfoViewPOT.js";import H from"../tiling/TileQueue.js";import R from"../../layers/LayerView.js";let v=class extends(T(R)){constructor(){super(...arguments),this._styleChanges=[],this._fetchQueue=null,this._parseQueue=null,this._tileHandlerPromise=null,this._isTileHandlerReady=!1}get fading(){return this._vectorTileContainer?.fading??!1}async hitTest(e,i){if(!this._tileHandlerPromise)return null;await this._tileHandlerPromise;const s=await this._vectorTileContainer.hitTest(i);if(!s||0===s.length)return null;const r=s[0]-1,a=this._styleRepository,l=a.getStyleLayerByUID(r);if(!l)return null;const o=a.getStyleLayerIndex(l.id);return[{type:"graphic",mapPoint:e,layer:this.layer,graphic:new t({attributes:{layerId:o,layerName:l.id,layerUID:r},layer:this.layer,sourceLayer:this.layer})}]}update(e){if(this._tileHandlerPromise&&this._isTileHandlerReady)return e.pixelRatio!==this._tileHandler.devicePixelRatio?(this._start(),void(this._tileHandler.devicePixelRatio=e.pixelRatio)):void(this._styleChanges.length>0?this._tileHandlerPromise=this._applyStyleChanges():(this._fetchQueue.pause(),this._parseQueue.pause(),this._fetchQueue.state=e.state,this._parseQueue.state=e.state,this._tileManager.update(e)||this.requestUpdate(),this._parseQueue.resume(),this._fetchQueue.resume()))}attach(){const{style:e}=this.layer.currentStyleInfo;this._styleRepository=new g(e),this._tileInfoView=new C(this.layer.tileInfo,this.layer.fullExtent),this._vectorTileContainer=new f(this._tileInfoView),this._tileHandler=new p(this.layer,this._styleRepository,window.devicePixelRatio||1),this.container.addChild(this._vectorTileContainer),this._start(),this.addAttachHandles([this.layer.on("paint-change",(e=>{if(e.isDataDriven)this._styleChanges.push({type:c.PAINTER_CHANGED,data:e}),this.requestUpdate();else{const t=this._styleRepository,i=t.getLayerById(e.layer);if(!i)return;const s=i.type===m.SYMBOL;t.setPaintProperties(e.layer,e.paint),s&&this._vectorTileContainer?.restartDeclutter(),this._vectorTileContainer?.requestRender()}})),this.layer.on("layout-change",(e=>{const t=this._styleRepository,i=t.getLayerById(e.layer);if(!i)return;const s=n(i.layout,e.layout);if(null!=s){if(h(s,"visibility")&&1===D(s))return t.setLayoutProperties(e.layer,e.layout),i.type===m.SYMBOL&&this._vectorTileContainer?.restartDeclutter(),void this._vectorTileContainer?.requestRender();this._styleChanges.push({type:c.LAYOUT_CHANGED,data:e}),this.requestUpdate()}})),this.layer.on("style-layer-visibility-change",(e=>{const t=this._styleRepository,i=t.getLayerById(e.layer);i&&(t.setStyleLayerVisibility(e.layer,e.visibility),i.type===m.SYMBOL&&this._vectorTileContainer?.restartDeclutter(),this._vectorTileContainer?.requestRender())})),this.layer.on("style-layer-change",(e=>{this._styleChanges.push({type:c.LAYER_CHANGED,data:e}),this.requestUpdate()})),this.layer.on("delete-style-layer",(e=>{this._styleChanges.push({type:c.LAYER_REMOVED,data:e}),this.requestUpdate()})),this.layer.on("load-style",(()=>this._loadStyle())),this.layer.on("spriteSource-change",(e=>{this._styleChanges.push({type:c.SPRITES_CHANGED,data:e});const t=this._styleRepository.layers;for(const i of t)switch(i.type){case m.SYMBOL:i.getLayoutProperty("icon-image")&&this._styleChanges.push({type:c.LAYOUT_CHANGED,data:{layer:i.id,layout:i.layout}});break;case m.LINE:i.getPaintProperty("line-pattern")&&this._styleChanges.push({type:c.PAINTER_CHANGED,data:{layer:i.id,paint:i.paint,isDataDriven:i.isPainterDataDriven()}});break;case m.FILL:i.getLayoutProperty("fill-pattern")&&this._styleChanges.push({type:c.PAINTER_CHANGED,data:{layer:i.id,paint:i.paint,isDataDriven:i.isPainterDataDriven()}})}this.requestUpdate()}))])}detach(){this._stop(),this.container.removeAllChildren(),this._vectorTileContainer=r(this._vectorTileContainer),this._tileHandler=r(this._tileHandler)}moveStart(){this.requestUpdate()}viewChange(){this.requestUpdate()}moveEnd(){this.requestUpdate()}supportsSpatialReference(e){return u(this.layer.tileInfo?.spatialReference,e)}canResume(){let e=super.canResume();const{currentStyleInfo:t}=this.layer;if(e&&t?.layerDefinition){const i=this.view.scale,{minScale:s,maxScale:r}=t.layerDefinition;t&&t.layerDefinition&&(s&&s<i&&(e=!1),r&&r>i&&(e=!1))}return e}isUpdating(){return this.fading}acquireTile(e){const t=this._createVectorTile(e);return this._updatingHandles.addPromise(this._fetchQueue.push(t.key).then((e=>this._parseQueue.push({key:t.key,data:e}))).then((e=>{t.once("attach",(()=>this.requestUpdate())),t.setData(e),this.requestUpdate()})).catch((e=>{a(e)||s.getLogger(this).error(e)}))),t}releaseTile(e){const t=e.key.id;this._fetchQueue.abort(t),this._parseQueue.abort(t),this.requestUpdate()}_start(){if(this._stop(),this._tileManager=new d({acquireTile:e=>this.acquireTile(e),releaseTile:e=>this.releaseTile(e),tileInfoView:this._tileInfoView},this._vectorTileContainer),!this.layer.currentStyleInfo)return;const e=new AbortController,t=this._tileHandler.start({signal:e.signal}).then((()=>{this._fetchQueue=new H({tileInfoView:this._tileInfoView,process:(e,t)=>this._getTileData(e,t),concurrency:15}),this._parseQueue=new H({tileInfoView:this._tileInfoView,process:(e,t)=>this._parseTileData(e,t),concurrency:8}),this.requestUpdate(),this._isTileHandlerReady=!0}));this._tileHandler.spriteMosaic.then((e=>{this._vectorTileContainer.setStyleResources(e,this._tileHandler.glyphMosaic,this._styleRepository),this.requestUpdate()})),this._tileHandlerAbortController=e,this._tileHandlerPromise=t}_stop(){if(!this._tileHandlerAbortController||!this._vectorTileContainer)return;const e=this._tileHandlerAbortController;e&&e.abort(),this._tileHandlerPromise=null,this._isTileHandlerReady=!1,this._fetchQueue=r(this._fetchQueue),this._parseQueue=r(this._parseQueue),this._tileManager=r(this._tileManager),this._vectorTileContainer.removeAllChildren()}async _getTileData(e,t){return this._tileHandler.fetchTileData(e,t)}async _parseTileData(e,t){return this._tileHandler.parseTileData(e,t)}async _applyStyleChanges(){this._isTileHandlerReady=!1,this._fetchQueue.pause(),this._parseQueue.pause(),this._fetchQueue.clear(),this._parseQueue.clear(),this._tileManager.clearCache();const e=this._styleChanges;try{await this._tileHandler.updateStyle(e)}catch(l){s.getLogger(this).error("error applying vector-tiles style update",l.message),this._fetchQueue.resume(),this._parseQueue.resume(),this._isTileHandlerReady=!0}const t=this._styleRepository,i=new Set;e.forEach((e=>{if(e.type!==c.LAYER_REMOVED)return;const s=e.data,r=t.getLayerById(s.layer);r&&i.add(r.uid)}));const r=new Set;e.forEach((e=>{let i;switch(e.type){case c.PAINTER_CHANGED:t.setPaintProperties(e.data.layer,e.data.paint),i=e.data.layer;break;case c.LAYOUT_CHANGED:t.setLayoutProperties(e.data.layer,e.data.layout),i=e.data.layer;break;case c.LAYER_REMOVED:return void t.deleteStyleLayer(e.data.layer);case c.LAYER_CHANGED:t.setStyleLayer(e.data.layer,e.data.index),i=e.data.layer.id;break;case c.SPRITES_CHANGED:this._vectorTileContainer.setSpriteMosaic(this._tileHandler.setSpriteSource(e.data.spriteSource))}if(i){const e=t.getLayerById(i);e&&r.add(e.uid)}}));const a=this._vectorTileContainer.children;if(i.size>0){const e=Array.from(i);this._vectorTileContainer.deleteStyleLayers(e);for(const t of a)t.deleteLayerData(e)}if(this._fetchQueue.resume(),this._parseQueue.resume(),r.size>0){const e=Array.from(r),t=[];for(const i of a){const s=this._updatingHandles.addPromise(this._fetchQueue.push(i.key).then((t=>this._parseQueue.push({key:i.key,data:t,styleLayerUIDs:e}))).then((e=>i.setData(e))));t.push(s)}await Promise.all(t)}this._styleChanges=[],this._isTileHandlerReady=!0,this.requestUpdate()}async _loadStyle(){const{style:e}=this.layer.currentStyleInfo,t=i(e);this._isTileHandlerReady=!1,this._fetchQueue.pause(),this._parseQueue.pause(),this._fetchQueue.clear(),this._parseQueue.clear(),this._styleRepository=new g(t),this._vectorTileContainer.destroy(),this._tileManager.clear(),this._tileHandlerAbortController.abort(),this._tileHandlerAbortController=new AbortController;const{signal:s}=this._tileHandlerAbortController;try{this._tileHandlerPromise=this._tileHandler.setStyle(this._styleRepository,t),await this._tileHandlerPromise}catch(l){if(!a(l))throw l}if(s.aborted)return this._fetchQueue.resume(),this._parseQueue.resume(),this._isTileHandlerReady=!0,void this.requestUpdate();const r=await this._tileHandler.spriteMosaic;this._vectorTileContainer.setStyleResources(r,this._tileHandler.glyphMosaic,this._styleRepository),this._fetchQueue.resume(),this._parseQueue.resume(),this._isTileHandlerReady=!0,this.requestUpdate()}_createVectorTile(e){const t=this._tileInfoView.getTileBounds(y(),e),i=this._tileInfoView.getTileResolution(e.level);return new _(e,i,t[0],t[3],512,512,this._styleRepository)}};function D(e){if(null==e)return 0;switch(e.type){case"partial":return Object.keys(e.diff).length;case"complete":return Math.max(Object.keys(e.oldValue).length,Object.keys(e.newValue).length);case"collection":return Object.keys(e.added).length+Object.keys(e.changed).length+Object.keys(e.removed).length}}e([l()],v.prototype,"_isTileHandlerReady",void 0),v=e([o("esri.views.2d.layers.VectorTileLayerView2D")],v);const w=v;export{w as default};
|
package/widgets/Daylight/css.js
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.28/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
const e="esri-daylight",i=`${e}__container`,r={base:e,widgetIcon:"esri-icon-environment-settings",widget:"esri-widget",
|
|
5
|
+
const e="esri-daylight",i=`${e}__container`,r={base:e,widgetIcon:"esri-icon-environment-settings",widget:"esri-widget",datePickerCalendarToggle:"esri-date-picker__calendar-toggle",shadowOff:"esri-slider--shadow-off",shadowOn:"esri-slider--shadow-on",sliderDateOn:"esri-slider--date-on",sliderDateOff:"esri-slider--date-off",sliderAmPmOn:"esri-slider--ampm-on",primaryTick:"primary-tick",primaryTickAmPm:"primary-tick__ampm",primaryTickLabel:"primary-tick__label",secondaryTick:"secondary-tick",dayContainer:`${i} ${e}__day-container`,dateContainer:`${i} ${e}__date-container`,containerDisabled:`${i}--disabled`,playPauseButton:`${e}__play-pause-button`,seasonPicker:`${e}__season-picker`,panelError:`${e}__panel--error`,sunLightingCheckbox:`${e}__sun-lighting-checkbox`,shadowsCheckbox:`${e}__shadows-checkbox`};export{r as CSS};
|
package/widgets/Daylight.js
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.28/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../chunks/tslib.es6.js";import t from"../core/Logger.js";import{watch as i,syncAndInitial as s,when as o,sync as l}from"../core/reactiveUtils.js";import{property as a}from"../core/accessorSupport/decorators/property.js";import"../core/accessorSupport/ensureType.js";import"../core/arrayUtils.js";import"../core/has.js";import{subclass as r}from"../core/accessorSupport/decorators/subclass.js";import n from"./Widget.js";import{CSS as d}from"./Daylight/css.js";import c from"./Daylight/DaylightViewModel.js";import p from"./Daylight/VisibleElements.js";import{ORDERED_SEASONS as h}from"./Daylight/support/daylightUtils.js";import g from"./Daylight/support/SliderWithDropdown.js";import{loadCalciteComponents as m}from"./support/componentsUtils.js";import u from"./support/DatePicker.js";import{Heading as y}from"./support/Heading.js";import"./support/widgetUtils.js";import{messageBundle as b}from"./support/decorators/messageBundle.js";import{tsx as v,tsxFragment as w}from"./support/jsxFactory.js";const k=/(.*)\s(.*)/,S="date",_="esri.widgets.Daylight";let M=class extends n{constructor(e,t){super(e,t),this.headingLevel=3,this.iconClass=d.widgetIcon,this.icon=null,this.viewModel=new c,this.visibleElements=new p,this.dateOrSeason=S,this._timeSlider=new g({viewModel:this.viewModel.timeSliderViewModel,steps:this.timeSliderSteps,labelInputsEnabled:!1,visibleElements:{labels:!0},tickConfigs:[{mode:"position",values:[0,360,720,1080,1439],labelsVisible:!0,tickCreatedFunction:this._onPrimaryTickCreated.bind(this)},{mode:"position",values:[120,240,480,600,840,960,1200,1320],tickCreatedFunction:this._onSecondaryTickCreated.bind(this)}]}),this._datePicker=new u({viewModel:this.viewModel.datePickerViewModel,commitOnMonthChange:!0}),this._onPlayDayClick=()=>{this.viewModel.toggleDayPlaying()},this._onYearPlayClick=()=>{this.viewModel.toggleYearPlaying()},this._onSeasonChange=e=>{
|
|
5
|
+
import{_ as e}from"../chunks/tslib.es6.js";import t from"../core/Logger.js";import{watch as i,syncAndInitial as s,when as o,sync as l}from"../core/reactiveUtils.js";import{property as a}from"../core/accessorSupport/decorators/property.js";import"../core/accessorSupport/ensureType.js";import"../core/arrayUtils.js";import"../core/has.js";import{subclass as r}from"../core/accessorSupport/decorators/subclass.js";import n from"./Widget.js";import{CSS as d}from"./Daylight/css.js";import c from"./Daylight/DaylightViewModel.js";import p from"./Daylight/VisibleElements.js";import{ORDERED_SEASONS as h}from"./Daylight/support/daylightUtils.js";import g from"./Daylight/support/SliderWithDropdown.js";import{loadCalciteComponents as m}from"./support/componentsUtils.js";import u from"./support/DatePicker.js";import{Heading as y}from"./support/Heading.js";import"./support/widgetUtils.js";import{messageBundle as b}from"./support/decorators/messageBundle.js";import{tsx as v,tsxFragment as w}from"./support/jsxFactory.js";const k=/(.*)\s(.*)/,S="date",_="esri.widgets.Daylight";let M=class extends n{constructor(e,t){super(e,t),this.headingLevel=3,this.iconClass=d.widgetIcon,this.icon=null,this.viewModel=new c,this.visibleElements=new p,this.dateOrSeason=S,this._timeSlider=new g({viewModel:this.viewModel.timeSliderViewModel,steps:this.timeSliderSteps,labelInputsEnabled:!1,visibleElements:{labels:!0},tickConfigs:[{mode:"position",values:[0,360,720,1080,1439],labelsVisible:!0,tickCreatedFunction:this._onPrimaryTickCreated.bind(this)},{mode:"position",values:[120,240,480,600,840,960,1200,1320],tickCreatedFunction:this._onSecondaryTickCreated.bind(this)}]}),this._datePicker=new u({viewModel:this.viewModel.datePickerViewModel,commitOnMonthChange:!0}),this._onPlayDayClick=()=>{this.viewModel.toggleDayPlaying()},this._onYearPlayClick=()=>{this.viewModel.toggleYearPlaying()},this._onSeasonChange=e=>{this.viewModel.currentSeason=e.target.value},this._onSunLightingCheckboxChange=()=>{this.viewModel.toggleSunLightingEnabled()},this._onShadowCheckboxChange=()=>{this.viewModel.toggleDirectShadowsEnabled()}}get label(){return this.messages?.title??""}set label(e){this._overrideIfSome("label",e)}get playSpeedMultiplier(){return this.viewModel.playSpeedMultiplier}set playSpeedMultiplier(e){this.viewModel.playSpeedMultiplier=e}get timeSliderSteps(){return this._timeSlider?.steps??5}set timeSliderSteps(e){this._timeSlider.steps=e}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}get test(){return{datePicker:this._datePicker}}get _useAmPm(){const e=this._timeSlider.viewModel.getLabelForValue(0,"tick");return null!=e&&k.test(e)}postInitialize(){this.viewModel.isSupported&&this.addHandles([i((()=>this.viewModel.datePickerViewModel),(e=>this._datePicker.viewModel=e),s),i((()=>this.viewModel.timeSliderViewModel),(e=>this._timeSlider.viewModel=e),s),i((()=>this.visibleElements?.timezone),(e=>this._timeSlider.showDropDown=e),s),i((()=>!this.viewModel.sunLightingEnabled),(e=>{this._datePicker.disabled=e,this._timeSlider.disabled=e}),s),o((()=>!this.visible),(()=>this._datePicker?.close(!1)),l)])}destroy(){this._datePicker.destroy(),this._timeSlider.destroy()}render(){const{messages:e,viewModel:t,visibleElements:i}=this,s=t.isSupported;return v("div",{class:this.classes(d.base,d.widget)},s?v(w,null,i.header&&v(y,{level:this.headingLevel},e.title),this._renderTimeOptions(),i.datePicker&&this._renderDateOrSeason(),i.sunLightingToggle&&this._renderSunLightingToggle(),i.shadowsToggle&&this._renderShadowsToggle()):v("div",{key:"unsupported",class:d.panelError},v("p",null,e.unsupported)))}loadDependencies(){return m({button:()=>import("@esri/calcite-components/dist/components/calcite-button.js"),checkbox:()=>import("@esri/calcite-components/dist/components/calcite-checkbox.js"),label:()=>import("@esri/calcite-components/dist/components/calcite-label.js"),option:()=>import("@esri/calcite-components/dist/components/calcite-option.js"),select:()=>import("@esri/calcite-components/dist/components/calcite-select.js")})}_renderTimeOptions(){const{viewModel:e,visibleElements:t,messages:i}=this,{directShadowsEnabled:s,dayPlaying:o}=e,l=!e.sunLightingEnabled;return v("div",{class:this.classes(d.dayContainer,{[d.shadowOn]:s,[d.shadowOff]:!s,[d.sliderDateOn]:t.datePicker,[d.sliderDateOff]:!t.datePicker,[d.sliderAmPmOn]:this._useAmPm,[d.containerDisabled]:l}),key:"daylight-time-options"},this._timeSlider.render(),t.playButtons&&this._renderPlayPauseButton({playing:o,disabled:l,label:i.playDay,onClick:this._onPlayDayClick}))}_renderDateOptions(){const{viewModel:e,visibleElements:t,messages:i}=this,{yearPlaying:s}=e,o=!e.sunLightingEnabled;return v("div",{key:"daylight-date",class:this.classes(d.dateContainer,o&&d.containerDisabled)},this._datePicker.render(),t.playButtons&&this._renderPlayPauseButton({playing:s,disabled:o,label:i.playYear,onClick:this._onYearPlayClick}))}_renderPlayPauseButton({playing:e,disabled:t,label:i,onClick:s}){return v("calcite-button",{appearance:"solid",class:d.playPauseButton,disabled:t,iconStart:e?"pause-f":"play-f",label:i,round:!0,title:i,type:"button",onclick:s})}_renderSeasonSelect(){const{messages:e,viewModel:t}=this,i=!t.sunLightingEnabled;return v("calcite-select",{class:this.classes(d.seasonPicker),disabled:i,label:e.season,onCalciteSelectChange:this._onSeasonChange},h.map((i=>v("calcite-option",{value:i,selected:t.currentSeason===i},e[i]))))}_renderDateOrSeason(){return"date"===this.dateOrSeason?this._renderDateOptions():this._renderSeasonSelect()}_renderSunLightingToggle(){const e=this.messages?.sunLightingToggle;return v("calcite-label",{key:"date-time-toggle",layout:"inline",title:e?.tooltip,scale:"s"},v("calcite-checkbox",{class:d.sunLightingCheckbox,checked:this.viewModel.sunLightingEnabled,onCalciteCheckboxChange:this._onSunLightingCheckboxChange}),e?.label)}_renderShadowsToggle(){const e=this.messages.shadowsToggle;return v("calcite-label",{key:"shadow-toggle",layout:"inline",title:e?.tooltip,scale:"s"},v("calcite-checkbox",{class:d.shadowsCheckbox,checked:this.viewModel.directShadowsEnabled,onCalciteCheckboxChange:this._onShadowCheckboxChange}),e.label)}_onPrimaryTickCreated(e,t,i){t.classList.add(...C,d.primaryTick),i.classList.add(...C,d.primaryTickLabel),i.onclick=t.onclick=this._makeGoToTime(e);const s=i.textContent,o=null!=s&&k.exec(s);o&&(i.innerHTML=`${o[1]}<br><div class=${d.primaryTickAmPm}>${o[2]}</div>`)}_onSecondaryTickCreated(e,t){t.classList.add(...C,d.secondaryTick),t.onclick=this._makeGoToTime(e)}_makeGoToTime(e){return()=>{this.viewModel.timeSliderPosition=e}}};e([a(),b("esri/widgets/Daylight/t9n/Daylight")],M.prototype,"messages",void 0),e([a(),b("esri/widgets/support/t9n/timezone")],M.prototype,"timezoneMessages",void 0),e([a()],M.prototype,"headingLevel",void 0),e([a()],M.prototype,"iconClass",void 0),e([a()],M.prototype,"icon",void 0),e([a()],M.prototype,"label",null),e([a()],M.prototype,"playSpeedMultiplier",null),e([a()],M.prototype,"timeSliderSteps",null),e([a()],M.prototype,"view",null),e([a({type:c})],M.prototype,"viewModel",void 0),e([a({type:p,nonNullable:!0})],M.prototype,"visibleElements",void 0),e([a({cast:e=>"season"===e||"date"===e?e:(t.getLogger(_).warn(`"${e}" is not a valid option. Acceptable values are only "date" or "season". Defaulting to "${S}".`),S)})],M.prototype,"dateOrSeason",void 0),e([a()],M.prototype,"_timeSlider",void 0),e([a()],M.prototype,"_useAmPm",null),e([a()],M.prototype,"_datePicker",void 0),M=e([r(_)],M);const C=["esri-interactive","esri-widget__anchor"],P=M;export{P as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.28/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import e from"../../Graphic.js";import{createTask as t}from"../../core/asyncUtils.js";import"../../core/has.js";import{handlesGroup as r,makeHandle as i}from"../../core/handleUtils.js";import{clone as n}from"../../core/lang.js";import{throwIfAborted as a,whenOrAbort as s}from"../../core/promiseUtils.js";import{watch as l,whenOnce as o}from"../../core/reactiveUtils.js";import{px2pt as c}from"../../core/screenUtils.js";import{diff as u}from"../../core/accessorSupport/diffUtils.js";import{getDisplayFieldName as p}from"../../layers/support/fieldUtils.js";import{calculateTolerance as y}from"../../renderers/support/clickToleranceUtils.js";import{meterIn as d}from"../../renderers/support/lengthUtils.js";import{getTransformationType as f,TransformationType as m}from"../../renderers/visualVariables/support/sizeVariableUtils.js";import{getRotationAngle as h,getSize as g}from"../../renderers/visualVariables/support/visualVariableUtils.js";import{sceneLayerEditingEnabled as b,i3sPatchingEnabled as w}from"../../support/featureFlags.js";import{to3D as v}from"../../symbols/support/symbolConversion.js";import{getDisplayedSymbol as S}from"../../symbols/support/symbolUtils.js";import{GraphicState as j}from"../../views/3d/layers/graphics/GraphicState.js";import{createQueryGeometry as I}from"../../views/support/drapedUtils.js";import{hitTestSelectSimilarDistance as U,filterGraphicHits as V}from"../../views/support/hitTestSelectUtils.js";function F(e){const t=e.sourceLayer;if(!t||"feature"!==t.type||!E(t.renderer))return{rotation:null,size:null};let r=null,i=null;const n=t.renderer.getVisualVariablesForType("rotation").filter((t=>(!t.axis||"heading"===t.axis)&&t.field&&!t.valueExpression&&null!=h(t,e)));1===n.length&&(r=L(n[0],t));const a=t.renderer.getVisualVariablesForType("size").filter((t=>t.field&&!t.useSymbolValue&&!t.valueExpression&&f(t)===m.RealWorldSize&&null!=g(t,e)));return 1===a.length&&(i=x(a[0],t)),{rotation:r,size:i}}function L(e,t){const r="heading"===(e.axis||"heading")&&"arithmetic"===e.rotationType?-1:1,i=e.field,n=t.fields&&t.fields.filter((e=>e.name===i)),a=n&&1===n.length?n[0].type:"double",s={initial:0,current:0};return{field:i,fieldType:a,getDefault:()=>Promise.resolve(0),getValue:e=>(s.current=s.initial-r*e,k((s.current+360)%360,a)),initValue:e=>{s.initial=null!=e?e:s.current,s.current=0},isUpdatingInteractively:!1,rotationType:e.rotationType??"geographic"}}function T(e,t){switch(t){case"width":return e[0];case"depth":return e[1];case"height":return e[2];default:return e[2]||e[1]||e[0]}}async function z(e,t,r){if(null==t)return 0;const{symbol:i}=v(t);if(null==i||"web-style"===i.type||"cim"===i.type)return 0;const n=i.symbolLayers.at(0);if(!n)return 0;switch(n.type){case"icon":{const{computeIconLayerResourceSize:e}=await import("../../symbols/support/symbolLayerUtils.js");return n.size||Math.min(Y.icon,(await e(n,Y.icon))[0])||Y.icon}case"text":return n.size||Y.text;case"line":return n.size||Y.line;case"object":{const{computeObjectLayerResourceSize:t}=await import("../../symbols/support/symbolLayerUtils.js");return T(await t(n,e.scale/Y.viewScaleSizeFactor),r)}case"path":return(null!=n.width?n.width:n.height)||e.scale/Y.viewScaleSizeFactor;case"extrude":return n.size||e.scale/Y.viewScaleSizeFactor;default:return 0}}function x(e,t){const r=e.field,i=e.axis,n=t.fields&&t.fields.filter((e=>e.name===r)),a=n&&1===n.length?n[0].type:"double",s={updating:!1,initial:0,current:0},l=d[e.valueUnit]??1;let o;return o="area"===e.valueRepresentation?e=>(e*l/2)**2*Math.PI:"radius"===e.valueRepresentation||"distance"===e.valueRepresentation?e=>e*l/2:e=>e*l,{field:r,fieldType:a,getDefault:async(e,t)=>k(o(await z(t,e,i)),a),getValue:(e,t)=>(s.initial||(s.initial=t.pixelSizeAt(t.center)),s.current=s.initial*e,k(s.current,a)),initValue:e=>{s.initial=null!=e?e:s.current,s.current=0},isUpdatingInteractively:!1,displayUnit:re(e.valueUnit),axis:e.axis}}function k(e,t){switch(t){case"small-integer":case"integer":case"long":return Math.round(e);case"double":case"single":return e;default:return 0}}function E(e){switch(e?.type){case"class-breaks":case"simple":case"unique-value":case"dot-density":case"dictionary":case"pie-chart":return!0;default:return!1}}async function O(e,t){const r=await S(e,{useSourceLayer:!0,ignoreGraphicSymbol:!0,webStyleCache:t});null!=u(e.symbol,r)&&(e.symbol=r)}function A(e){if(!e)throw new Error("no geometry type");return"multipatch"===e?"mesh":e}async function M(e,t,n,a){await C(e,t,a);const s=e.on("create",(async r=>{if("cancel"===r.state)return C(e,t,a);if("complete"===r.state){const e=r.graphic;e.sourceLayer||(e.sourceLayer=t.layer),e.attributes||(e.attributes={...t.template?.prototype.attributes}),await O(e,a),n(e)}}));return r([s,i((()=>e.cancel()))])}async function C(e,t,r){const i=t.layer,n={...t.template?.prototype.attributes};await G(e,i,n,r),e.layer.elevationInfo=i.elevationInfo,await e.create(A(i.geometryType),{graphicProperties:{attributes:n,sourceLayer:i},hasZ:i.capabilities.data.supportsZ,geometryToPlace:t.geometryToPlace??void 0})}async function G(t,r,i,n){const a=new e({sourceLayer:r,attributes:i}),{rotation:s,size:l}=F(a);let o=await S(a,{useSourceLayer:!0,webStyleCache:n}),c=!1;for(const e of[l,s]){if(null==e)continue;null==i[e.field]&&(i[e.field]=await e.getDefault(o,t.view),c=!0)}switch(c&&(o=await S(a,{useSourceLayer:!0,webStyleCache:n})),o?.type){case"simple-fill":case"polygon-3d":t.polygonSymbol=o;break;case"simple-line":case"line-3d":t.polylineSymbol=o;break;case"simple-marker":case"picture-marker":case"point-3d":case"cim":t.pointSymbol=o;break;case"mesh-3d":t.meshSymbol=o}P(t.tooltipOptions,l,s)}function P(e,t,r){e.visualVariables=null!=t||null!=r?{size:null!=t?{unit:t.displayUnit,axis:t.axis,valueType:t.fieldType}:null,rotation:null!=r?{valueType:r.fieldType,rotationType:r.rotationType??"geographic"}:null}:null}function R(e,t){return e?e.find((e=>e.layer===t)):void 0}async function D(e,t,r,i){if(0===e.length)return[];const{updatable:n,graphicsByLayer:a}=await r.async((async()=>{const{results:n}=await s(U(t,r),i),a=new Map,l=e=>{const t=e.layer,r=a.get(t);if(!r){const e=new Array;return a.set(t,e),e}return r};V(n).forEach((({graphic:e})=>l(e).push(e)));const o=e.filter((({supports:e,layer:t})=>e.includes("update")&&a.has(t)));return 0!==o.length&&r.stopPropagation(),{updatable:o,graphicsByLayer:a}}));return s(Promise.allSettled(n.map((async({layer:e})=>{const{objectIdField:t}=e,r="displayField"in e?e.displayField:null,n=[t];null!=r&&e.fieldsIndex.has(r)&&n.push(r);const s=a.get(e);if(!!s.some((e=>n.some((t=>!(t in e.attributes)))))){const t=e.createQuery();return t.outFields=n,t.returnGeometry=!1,t.objectIds=s.map((e=>e.getObjectId())),e.queryFeatures(t,{signal:i}).then((({features:e})=>e))}return s}))),i)}async function q(e,t,r,i){if(0===e.length)return[];let n=null;const a=await r.async((async()=>{const{results:a}=await s(t.hitTest(r),i);if(0===a.length)return[];const l=new Set;n=V(a),n.forEach((({graphic:e})=>e&&l.add(e.layer)));const o=e.items.filter((({layer:e,supports:t,attachmentsOnUpdateEnabled:r})=>l.has(e)&&(t.includes("update")||t.includes("delete")||r)));return o.length>0&&r.stopPropagation(),o}));return s(Promise.allSettled(a.map((({layer:e})=>{const a=e.objectIdField,s="displayField"in e?e.displayField:null,l=p({displayField:s,fields:e.fields}),o=[a];null!=l&&e.fieldsIndex.has(l)&&o.push(l);const c=e.createQuery();c.outFields=o,c.returnGeometry=!1;const u="renderer"in e?y({renderer:e.renderer,event:r}):0;return c.geometry=I(r.mapPoint,u,t),c.outSpatialReference=t.spatialReference,e.queryFeatures(c,{signal:i}).then((({features:t})=>(n?.forEach((({graphic:r})=>{r.layer!==e||t.some((e=>e.getObjectId()===r.getObjectId()))||t.push(r)})),t)))}))),i)}async function Z(e,t,r,i){switch(t.type){case"3d":return D(e,t,r,i);case"2d":return q(e,t,r,i)}}async function Q(e,t,r){const{sourceLayer:i}=e,n=i.createQuery();n.objectIds=[e.getAttribute(i.objectIdField)],n.outFields=["*"],n.outSpatialReference=t,n.returnM=i.capabilities.data.supportsM,n.returnZ=i.capabilities.data.supportsZ,b()&&w()&&"scene"===i.type&&null!=i.infoFor3D&&(n.returnGeometry=!0,n.formatOf3DObjects="3D_glb");const s=await i.queryFeatures(n,{signal:r});a(r);return s.features[0]}async function B(e){const{graphic:t,sketchViewModel:r,sourceLayer:i,visualVariables:n,webStyleCache:a}=e;let s=!1;const{rotation:l,size:o}=n;[l,o].forEach((async e=>{if(null==e)return;const i=t.getAttribute(e.field);if(null!=i)e.initValue(i);else{const i=await e.getDefault(t.symbol,r.view);e.initValue(i),t.setAttribute(e.field,i),s=!0}})),s&&await O(t,a);const c={multipleSelectionEnabled:!1};return"point"===i.geometryType&&(c.enableRotation=null!=l,c.enableScaling=null!=o),P(r.tooltipOptions,o,l),r.layer.elevationInfo=i.elevationInfo,r.update(t,c)}function W(e){return null==e||"rotate-start"!==e.type&&"rotate"!==e.type&&"rotate-stop"!==e.type?null:e}function _(e){return null==e||"scale-start"!==e.type&&"scale"!==e.type&&"scale-stop"!==e.type?null:e}async function H(e,t,r,i,n){if(null==t.geometry||"point"!==t.geometry?.type)return;const a=i.rotation,s=W(r.toolEventInfo);if(null!=a&&null!=s)if("rotate-stop"===s.type)a.isUpdatingInteractively=!1,a.initValue();else{a.isUpdatingInteractively=!0;const{field:r,getValue:i}=a;t.setAttribute(r,i(s.angle,e))}const l=i.size,o=_(r.toolEventInfo);if(null!=l&&null!=o)if("scale-stop"===o.type)l.isUpdatingInteractively=!1,l.initValue();else{l.isUpdatingInteractively=!0;const{field:r,getValue:i}=l;t.setAttribute(r,i(o.xScale,e))}await O(t,n)}async function J(e,t,n,a,s,o){const c=ue(e);await O(c,o),a.map.add(n.layer),n.layer.add(c);const u=e.sourceLayer,p=se(a,u);await X(a,c),await B({graphic:c,sketchViewModel:n,sourceLayer:u,visualVariables:t,webStyleCache:o});const y=K(n,e,c);let d=null;p.then((e=>d=e)).catch((()=>{}));const f=t.size,m=t.rotation,h=l((()=>e.attributes),(async e=>{let t=!1;for(const r in e){const i=e[r];i!==c.getAttribute(r)&&(c.setAttribute(r,i),null==f||f.isUpdatingInteractively||f.field!==r||f.initValue(i),null==m||m.isUpdatingInteractively||m.field!==r||m.initValue(i),(null==d||d.requiredFields.includes(r))&&(t=!0))}t&&await O(c,o)})),g=n.on("update",(async e=>{const r=e.graphics[0];if("complete"===e.state)return B({graphic:r,sketchViewModel:n,sourceLayer:u,visualVariables:t,webStyleCache:o});await H(a,r,e,t,o),s(ue(r),e)})),b=n.on(["undo","redo"],(async e=>{s(ue(e.graphics[0]),e)})),w=n.updateOnGraphicClick;return{visual:r([y,i((()=>{n.updateOnGraphicClick=w}))]),interactive:r([b,g,i((()=>n.cancel())),h,i((()=>{n.updateOnGraphicClick=!1}))])}}function K(e,n,s){const l=e.view,c=n.sourceLayer,u=n.layer,p=n.getAttribute(u.objectIdField);let y=null;function d(e){y?.abort(),y=t((async t=>{const r=await se(l,c);a(t),r.setVisibility?.(p,e)}))}return d(!1),r([N(l,s,(e=>d(!e))),i((async()=>{d(!0);try{const e=await se(l,c);await o((()=>!e.updating))}finally{e.layer.remove(s)}}))])}function N(e,t,i){if("3d"===e.type){const n=new j({graphic:t});return r([e.trackGraphicState(n),l((()=>n.displaying),i)])}return l((()=>t.visible),i)}async function X(e,t){if("3d"===e.type){const r=new j({graphic:t}),i=e.trackGraphicState(r);await o((()=>r.displaying)),i.remove()}else await o((()=>t.visible))}const Y={icon:c(24),text:c(12),line:c(1),viewScaleSizeFactor:100};function $(e,t,r){let i=!1;return e.filter((e=>!!i||(i=e===t,i))).map((e=>r[e]()))}function ee(e){if(1!==e.length)return null;const t=e[0];if("items"in t){const e=t;return 1===e.items.length?e.items[0]:null}return t}function te(e,t){if(e.viewModel.refreshCreationTemplates(),"awaiting-feature-creation-info"===t[0].id){const r=ee(e.viewModel.featureTemplatesViewModel.items);null==r||r.supportsUpload||(e.creationInfo=r,t.shift())}return t}function re(e){switch(e){case"unknown":case"decimal-degrees":return null;default:return e}}function ie(e){e.filesEnabled=!0,e.mode="view",e.capabilities={editing:!0,operations:{add:!0,update:!0,delete:!0}}}function ne(e){const{creationInfo:t,viewModel:r}=e;if(!t)return!1;const{layer:i}=t,n=r.editableItems.find((e=>e.layer===i));if(n)return n.attachmentsOnCreateEnabled;const a=i.capabilities?.data,s=r.layerInfos?.find((e=>e.layer===i));return!(!(a&&"supportsAttachment"in a&&a.supportsAttachment)||s&&(!1===s.allowAttachments||!1===s.attachmentsOnUpdateEnabled))}const ae=e=>/-stop/.test(e)||/vertex-/.test(e),se=(e,t)=>{const r="subtype-sublayer"===t.type?t.parent:t;return e.whenLayerView(r)};function le(e){return"createInteractiveEditSession"in e}const oe=Symbol();function ce(e){return e&&"object"==typeof e&&oe in e}function ue(e){const t=e.geometry;if("mesh"===t?.type){const r=e.cloneShallow();return r.attributes=n(e.attributes),r.geometry=t.cloneShallow(),r.geometry.transform=t.transform?.clone()??null,r}return e.clone()}function pe(e){const t=e.cursor;return e.cursor="progress",i((()=>e.cursor=t))}export{oe as UsesSketchViewModelSymbol,te as avoidFeatureTemplateSelectionWithOnlyOneItem,le as canCreateInteractiveEditSession,ue as cloneGraphicExceptMesh,$ as createWorkflowSteps,Z as fetchCandidates,Q as fetchFullFeature,R as findLayerInfo,F as getVisualVariableAttributes,ae as isTerminalUpdateEventType,ie as prepareAttachmentsForCreateWorkflow,M as setUpFeatureAdd,J as setUpGeometryUpdate,ne as shouldShowAttachmentsForCreateWorkflow,pe as showProgressCursor,Y as sizeDefaults,re as sizeVariableUnitToLengthUnit,C as startCreatingNewFeature,B as startUpdatingFeature,O as updateGraphicSymbolWhenRequired,H as visualVariableInteractiveUpdate,se as whenEditorLayerView,X as whenGraphicDisplayed,ce as workflowUsesSketchViewModel};
|
|
5
|
+
import e from"../../Graphic.js";import{createTask as t}from"../../core/asyncUtils.js";import"../../core/has.js";import{handlesGroup as r,makeHandle as i}from"../../core/handleUtils.js";import{clone as n}from"../../core/lang.js";import{throwIfAborted as a,whenOrAbort as s}from"../../core/promiseUtils.js";import{watch as l,whenOnce as o}from"../../core/reactiveUtils.js";import{px2pt as c}from"../../core/screenUtils.js";import{diff as u}from"../../core/accessorSupport/diffUtils.js";import{getDisplayFieldName as p}from"../../layers/support/fieldUtils.js";import{calculateTolerance as y}from"../../renderers/support/clickToleranceUtils.js";import{meterIn as d}from"../../renderers/support/lengthUtils.js";import{getTransformationType as f,TransformationType as m}from"../../renderers/visualVariables/support/sizeVariableUtils.js";import{getRotationAngle as h,getSize as g}from"../../renderers/visualVariables/support/visualVariableUtils.js";import{sceneLayerEditingEnabled as b,i3sPatchingEnabled as w}from"../../support/featureFlags.js";import{to3D as v}from"../../symbols/support/symbolConversion.js";import{getDisplayedSymbol as S}from"../../symbols/support/symbolUtils.js";import{GraphicState as j}from"../../views/3d/layers/graphics/GraphicState.js";import{createQueryGeometry as I}from"../../views/support/drapedUtils.js";import{hitTestSelectSimilarDistance as U,filterGraphicHits as V}from"../../views/support/hitTestSelectUtils.js";function F(e){const t=e.sourceLayer;if(!t||"feature"!==t.type||!E(t.renderer))return{rotation:null,size:null};let r=null,i=null;const n=t.renderer.getVisualVariablesForType("rotation").filter((t=>(!t.axis||"heading"===t.axis)&&t.field&&!t.valueExpression&&null!=h(t,e)));1===n.length&&(r=L(n[0],t));const a=t.renderer.getVisualVariablesForType("size").filter((t=>t.field&&!t.useSymbolValue&&!t.valueExpression&&f(t)===m.RealWorldSize&&null!=g(t,e)));return 1===a.length&&(i=x(a[0],t)),{rotation:r,size:i}}function L(e,t){const r="heading"===(e.axis||"heading")&&"arithmetic"===e.rotationType?-1:1,i=e.field,n=t.fields&&t.fields.filter((e=>e.name===i)),a=n&&1===n.length?n[0].type:"double",s={initial:0,current:0};return{field:i,fieldType:a,getDefault:()=>Promise.resolve(0),getValue:e=>(s.current=s.initial-r*e,k((s.current+360)%360,a)),initValue:e=>{s.initial=null!=e?e:s.current,s.current=0},isUpdatingInteractively:!1,rotationType:e.rotationType??"geographic"}}function T(e,t){switch(t){case"width":return e[0];case"depth":return e[1];case"height":return e[2];default:return e[2]||e[1]||e[0]}}async function z(e,t,r){if(null==t)return 0;const{symbol:i}=v(t);if(null==i||"web-style"===i.type||"cim"===i.type)return 0;const n=i.symbolLayers.at(0);if(!n)return 0;switch(n.type){case"icon":{const{computeIconLayerResourceSize:e}=await import("../../symbols/support/symbolLayerUtils.js");return n.size||Math.min(Y.icon,(await e(n,Y.icon))[0])||Y.icon}case"text":return n.size||Y.text;case"line":return n.size||Y.line;case"object":{const{computeObjectLayerResourceSize:t}=await import("../../symbols/support/symbolLayerUtils.js");return T(await t(n,e.scale/Y.viewScaleSizeFactor),r)}case"path":return(null!=n.width?n.width:n.height)||e.scale/Y.viewScaleSizeFactor;case"extrude":return n.size||e.scale/Y.viewScaleSizeFactor;default:return 0}}function x(e,t){const r=e.field,i=e.axis,n=t.fields&&t.fields.filter((e=>e.name===r)),a=n&&1===n.length?n[0].type:"double",s={updating:!1,initial:0,current:0},l=d[e.valueUnit]??1;let o;return o="area"===e.valueRepresentation?e=>(e*l/2)**2*Math.PI:"radius"===e.valueRepresentation||"distance"===e.valueRepresentation?e=>e*l/2:e=>e*l,{field:r,fieldType:a,getDefault:async(e,t)=>k(o(await z(t,e,i)),a),getValue:(e,t)=>(s.initial||(s.initial=t.pixelSizeAt(t.center)),s.current=s.initial*e,k(s.current,a)),initValue:e=>{s.initial=null!=e?e:s.current,s.current=0},isUpdatingInteractively:!1,displayUnit:re(e.valueUnit),axis:e.axis}}function k(e,t){switch(t){case"small-integer":case"integer":case"long":return Math.round(e);case"double":case"single":return e;default:return 0}}function E(e){switch(e?.type){case"class-breaks":case"simple":case"unique-value":case"dot-density":case"dictionary":case"pie-chart":return!0;default:return!1}}async function O(e,t){const r=await S(e,{useSourceLayer:!0,ignoreGraphicSymbol:!0,webStyleCache:t});null!=u(e.symbol,r)&&(e.symbol=r)}function A(e){if(!e)throw new Error("no geometry type");return"multipatch"===e?"mesh":e}async function M(e,t,n,a){await C(e,t,a);const s=e.on("create",(async r=>{if("cancel"===r.state)return C(e,t,a);if("complete"===r.state){const e=r.graphic;e.sourceLayer||(e.sourceLayer=t.layer),e.attributes||(e.attributes={...t.template?.prototype.attributes}),await O(e,a),n(e)}}));return r([s,i((()=>e.cancel()))])}async function C(e,t,r){const i=t.layer,n={...t.template?.prototype.attributes};await G(e,i,n,r),e.layer.elevationInfo=i.elevationInfo,await e.create(A(i.geometryType),{graphicProperties:{attributes:n,sourceLayer:i},hasZ:i.capabilities.data.supportsZ,geometryToPlace:t.geometryToPlace??void 0})}async function G(t,r,i,n){const a=new e({sourceLayer:r,attributes:i}),{rotation:s,size:l}=F(a);let o=await S(a,{useSourceLayer:!0,webStyleCache:n}),c=!1;for(const e of[l,s]){if(null==e)continue;null==i[e.field]&&(i[e.field]=await e.getDefault(o,t.view),c=!0)}switch(c&&(o=await S(a,{useSourceLayer:!0,webStyleCache:n})),o?.type){case"simple-fill":case"polygon-3d":t.polygonSymbol=o;break;case"simple-line":case"line-3d":t.polylineSymbol=o;break;case"simple-marker":case"picture-marker":case"point-3d":case"cim":t.pointSymbol=o;break;case"mesh-3d":t.meshSymbol=o}P(t.tooltipOptions,l,s)}function P(e,t,r){e.visualVariables=null!=t||null!=r?{size:null!=t?{unit:t.displayUnit,axis:t.axis,valueType:t.fieldType}:null,rotation:null!=r?{valueType:r.fieldType,rotationType:r.rotationType??"geographic"}:null}:null}function R(e,t){return e?e.find((e=>e.layer===t)):void 0}async function D(e,t,r,i){if(0===e.length)return[];const{updatable:n,graphicsByLayer:a}=await r.async((async()=>{const{results:n}=await s(U(t,r),i),a=new Map,l=e=>{const t=e.layer,r=a.get(t);if(!r){const e=new Array;return a.set(t,e),e}return r};V(n).forEach((({graphic:e})=>l(e).push(e)));const o=e.filter((({supports:e,layer:t})=>e.includes("update")&&a.has(t)));return 0!==o.length&&r.stopPropagation(),{updatable:o,graphicsByLayer:a}}));return s(Promise.allSettled(n.map((async({layer:e})=>{const{objectIdField:t}=e,r="displayField"in e?e.displayField:null,n=[t];null!=r&&e.fieldsIndex.has(r)&&n.push(r);const s=a.get(e);if(!!s.some((e=>n.some((t=>!(t in e.attributes)))))){const t=e.createQuery();return t.outFields=n,t.returnGeometry=!1,t.objectIds=s.map((e=>e.getObjectId())),e.queryFeatures(t,{signal:i}).then((({features:e})=>e))}return s}))),i)}async function q(e,t,r,i){if(0===e.length)return[];let n=null;const a=await r.async((async()=>{const{results:a}=await s(t.hitTest(r),i);if(0===a.length)return[];const l=new Set;n=V(a),n.forEach((({graphic:e})=>e&&l.add(e.layer)));const o=e.items.filter((({layer:e,supports:t,attachmentsOnUpdateEnabled:r})=>l.has(e)&&(t.includes("update")||t.includes("delete")||r)));return o.length>0&&r.stopPropagation(),o}));return s(Promise.allSettled(a.map((({layer:e})=>{const a=e.objectIdField,s="displayField"in e?e.displayField:null,l=p({displayField:s,fields:e.fields}),o=[a];null!=l&&e.fieldsIndex.has(l)&&o.push(l);const c=e.createQuery();c.outFields=o,c.returnGeometry=!1;const u="renderer"in e?y({renderer:e.renderer,event:r}):0;return c.geometry=I(r.mapPoint,u,t),c.outSpatialReference=t.spatialReference,e.queryFeatures(c,{signal:i}).then((({features:t})=>(n?.forEach((({graphic:r})=>{r.layer!==e||t.some((e=>e.getObjectId()===r.getObjectId()))||t.push(r)})),t)))}))),i)}async function Z(e,t,r,i){switch(t.type){case"3d":return D(e,t,r,i);case"2d":return q(e,t,r,i)}}async function Q(e,t,r){const{sourceLayer:i}=e,n=i.createQuery();n.objectIds=[e.getAttribute(i.objectIdField)],n.outFields=["*"],n.outSpatialReference=t,n.returnM=i.capabilities.data.supportsM,n.returnZ=i.capabilities.data.supportsZ,b()&&w()&&"scene"===i.type&&null!=i.infoFor3D&&(n.returnGeometry=!0,n.formatOf3DObjects="3D_glb");const s=await i.queryFeatures(n,{signal:r});a(r);return s.features[0]}async function B(e){const{graphic:t,sketchViewModel:r,sourceLayer:i,visualVariables:n,webStyleCache:a}=e;let s=!1;const{rotation:l,size:o}=n;[l,o].forEach((async e=>{if(null==e)return;const i=t.getAttribute(e.field);if(null!=i)e.initValue(i);else{const i=await e.getDefault(t.symbol,r.view);e.initValue(i),t.setAttribute(e.field,i),s=!0}})),s&&await O(t,a);const c={multipleSelectionEnabled:!1};return"point"===i.geometryType&&(c.enableRotation=null!=l,c.enableScaling=null!=o),P(r.tooltipOptions,o,l),r.layer.elevationInfo=i.elevationInfo,r.update(t,c)}function W(e){return null==e||"rotate-start"!==e.type&&"rotate"!==e.type&&"rotate-stop"!==e.type?null:e}function _(e){return null==e||"scale-start"!==e.type&&"scale"!==e.type&&"scale-stop"!==e.type?null:e}async function H(e,t,r,i,n){if(null==t.geometry||"point"!==t.geometry?.type)return;const a=i.rotation,s=W(r.toolEventInfo);if(null!=a&&null!=s)if("rotate-stop"===s.type)a.isUpdatingInteractively=!1,a.initValue();else{a.isUpdatingInteractively=!0;const{field:r,getValue:i}=a;t.setAttribute(r,i(s.angle,e))}const l=i.size,o=_(r.toolEventInfo);if(null!=l&&null!=o)if("scale-stop"===o.type)l.isUpdatingInteractively=!1,l.initValue();else{l.isUpdatingInteractively=!0;const{field:r,getValue:i}=l;t.setAttribute(r,i(o.xScale,e))}await O(t,n)}async function J(e,t,n,a,s,o){const c=ce(e);await O(c,o),a.map.add(n.layer),n.layer.add(c);const u=e.sourceLayer,p=se(a,u);await X(a,c),await B({graphic:c,sketchViewModel:n,sourceLayer:u,visualVariables:t,webStyleCache:o});const y=K(n,e,c);let d=null;p.then((e=>d=e)).catch((()=>{}));const f=t.size,m=t.rotation,h=l((()=>e.attributes),(async e=>{let t=!1;for(const r in e){const i=e[r];i!==c.getAttribute(r)&&(c.setAttribute(r,i),null==f||f.isUpdatingInteractively||f.field!==r||f.initValue(i),null==m||m.isUpdatingInteractively||m.field!==r||m.initValue(i),(null==d||d.requiredFields.includes(r))&&(t=!0))}t&&await O(c,o)})),g=n.on("update",(async e=>{const r=e.graphics[0];if("complete"===e.state)return B({graphic:r,sketchViewModel:n,sourceLayer:u,visualVariables:t,webStyleCache:o});await H(a,r,e,t,o),s(ce(r),e)})),b=n.on(["undo","redo"],(async e=>{s(ce(e.graphics[0]),e)})),w=n.updateOnGraphicClick;return{visual:r([y,i((()=>{n.updateOnGraphicClick=w}))]),interactive:r([b,g,i((()=>n.cancel())),h,i((()=>{n.updateOnGraphicClick=!1}))])}}function K(e,n,s){const l=e.view,c=n.sourceLayer,u=n.layer,p=n.getAttribute(u.objectIdField);let y=null;function d(e){y?.abort(),y=t((async t=>{const r=await se(l,c);a(t),r.setVisibility?.(p,e)}))}return d(!1),r([N(l,s,(e=>d(!e))),i((async()=>{d(!0);try{const e=await se(l,c);await o((()=>!e.updating))}finally{e.layer.remove(s)}}))])}function N(e,t,i){if("3d"===e.type){const n=new j({graphic:t});return r([e.trackGraphicState(n),l((()=>n.displaying),i)])}return l((()=>t.visible),i)}async function X(e,t){if("3d"===e.type){const r=new j({graphic:t}),i=e.trackGraphicState(r);await o((()=>r.displaying)),i.remove()}else await o((()=>t.visible))}const Y={icon:c(24),text:c(12),line:c(1),viewScaleSizeFactor:100};function $(e,t,r){let i=!1;return e.filter((e=>!!i||(i=e===t,i))).map((e=>r[e]()))}function ee(e){if(1!==e.length)return null;const t=e[0];if("items"in t){const e=t;return 1===e.items.length?e.items[0]:null}return t}function te(e,t){if(e.viewModel.refreshCreationTemplates(),"awaiting-feature-creation-info"===t[0].id){const r=ee(e.viewModel.featureTemplatesViewModel.items);null==r||r.supportsUpload||(e.creationInfo=r,t.shift())}return t}function re(e){switch(e){case"unknown":case"decimal-degrees":return null;default:return e}}function ie(e){e.filesEnabled=!0,e.mode="view",e.capabilities={editing:!0,operations:{add:!0,update:!0,delete:!0}}}function ne(e){const{creationInfo:t,viewModel:r}=e;if(!t)return!1;const{layer:i}=t,n=r.editableItems.find((e=>e.layer===i));if(n)return n.attachmentsOnCreateEnabled;const a=i.capabilities?.data,s=r.layerInfos?.find((e=>e.layer===i));return!(!(a&&"supportsAttachment"in a&&a.supportsAttachment)||s&&(!1===s.allowAttachments||!1===s.attachmentsOnUpdateEnabled))}const ae=e=>/-stop/.test(e)||/vertex-/.test(e),se=(e,t)=>{const r="subtype-sublayer"===t.type?t.parent:t;return e.whenLayerView(r)};function le(e){return"createInteractiveEditSession"in e}const oe=Symbol();function ce(e){const t=e.geometry;if("mesh"===t?.type){const r=e.cloneShallow();return r.attributes=n(e.attributes),r.geometry=t.cloneShallow(),r.geometry.transform=t.transform?.clone()??null,r}return e.clone()}function ue(e){const t=e.cursor;return e.cursor="progress",i((()=>e.cursor=t))}export{oe as UsesSketchViewModelSymbol,te as avoidFeatureTemplateSelectionWithOnlyOneItem,le as canCreateInteractiveEditSession,ce as cloneGraphicExceptMesh,$ as createWorkflowSteps,Z as fetchCandidates,Q as fetchFullFeature,R as findLayerInfo,F as getVisualVariableAttributes,ae as isTerminalUpdateEventType,ie as prepareAttachmentsForCreateWorkflow,M as setUpFeatureAdd,J as setUpGeometryUpdate,ne as shouldShowAttachmentsForCreateWorkflow,ue as showProgressCursor,Y as sizeDefaults,re as sizeVariableUnitToLengthUnit,C as startCreatingNewFeature,B as startUpdatingFeature,O as updateGraphicSymbolWhenRequired,H as visualVariableInteractiveUpdate,se as whenEditorLayerView,X as whenGraphicDisplayed};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.28/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../chunks/tslib.es6.js";import{property as s}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import"../../../core/arrayUtils.js";import"../../../core/has.js";import{subclass as o}from"../../../core/accessorSupport/decorators/subclass.js";import r from"../../Widget.js";import{LEGEND_CSS as t}from"../css.js";import{LegendItem as
|
|
5
|
+
import{_ as e}from"../../../chunks/tslib.es6.js";import{property as s}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import"../../../core/arrayUtils.js";import"../../../core/has.js";import{subclass as o}from"../../../core/accessorSupport/decorators/subclass.js";import r from"../../Widget.js";import{LEGEND_CSS as t}from"../css.js";import{LegendItem as p}from"./LegendItem.js";import"../../support/widgetUtils.js";import{tsx as i}from"../../support/jsxFactory.js";let n=class extends r{constructor(){super(...arguments),this._expandedLine=null}render(){const{profiles:e,messages:s,effectiveUnits:o,_expandedLine:r}=this;return i("div",{class:t.base},e.map((t=>i(p,{checkboxVisible:e.length>1,effectiveUnits:o,expanded:t===r,line:t,messages:s,onExpandedToggle:()=>this._onExpandedToggle(t)}))))}_onExpandedToggle(e){this._expandedLine=e===this._expandedLine?null:e}};e([s()],n.prototype,"effectiveUnits",void 0),e([s()],n.prototype,"messages",void 0),e([s()],n.prototype,"profiles",void 0),e([s()],n.prototype,"_expandedLine",void 0),n=e([o("esri.widgets.ElevationProfile.components.Legend")],n);export{n as Legend};
|