@arcgis/core 4.34.0-next.28 → 4.34.0-next.29
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/Components/featureUtils.d.ts +6 -0
- package/applications/Components/featureUtils.js +5 -0
- package/arcade/arcade.js +1 -1
- package/arcade/arcadeAsyncRuntime.js +1 -1
- package/arcade/arcadeCompiler.js +1 -1
- package/arcade/arcadeRuntime.js +1 -1
- package/arcade/functions/feature.js +1 -1
- package/arcade/functions/track.js +5 -0
- package/arcade/treeAnalysis.js +1 -1
- package/arcade.js +1 -1
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/086f3bc5938bf9a37274.js +1 -0
- package/assets/esri/core/workers/chunks/{7e5d3735a9c718591d64.js → 22f38cad0213f2112394.js} +1 -1
- package/assets/esri/core/workers/chunks/{746c78e1c84f9612d69b.js → 2f54776ff86f397adc55.js} +1 -1
- package/assets/esri/core/workers/chunks/{edfd8b482182803b44ca.js → 2fdf457786d2d5d7414f.js} +1 -1
- package/assets/esri/core/workers/chunks/5192f38682f1f9be7da0.js +1 -0
- package/assets/esri/core/workers/chunks/{7ee50f75914d8d650af4.js → 63cb3dcd359e96733b1b.js} +1 -1
- package/assets/esri/core/workers/chunks/{e49a95f2126ef9a994d3.js → 6ccd6171d3c572883034.js} +1 -1
- package/assets/esri/core/workers/chunks/89999baefa341bd3329c.js +1 -0
- package/assets/esri/core/workers/chunks/{629a924e99d5d6eb1998.js → 90a9b618058dc41294de.js} +1 -1
- package/assets/esri/core/workers/chunks/98f6d4ea026ed96fd3f3.js +1 -0
- package/assets/esri/core/workers/chunks/d3b1d1c389d70919fb02.js +1 -0
- package/assets/esri/core/workers/chunks/db81d881805f6f92a2e4.js +1 -0
- package/assets/esri/core/workers/chunks/e89698fc404379627349.js +1 -0
- package/assets/esri/core/workers/chunks/{0254ef9fb7f8ebb25304.js → ecc15622d6c434ea842b.js} +1 -1
- package/assets/esri/core/workers/chunks/{aa781b28dbe457427afc.js → fb71e533995c54cd806f.js} +1 -1
- package/assets/esri/libs/parquet/pkg/bundle_bg.wasm +0 -0
- package/chunks/GeodeticDistanceCalculator-Ce-woMPw.js +1 -1
- package/chunks/OperatorGeodesicBuffer.js +1 -1
- package/chunks/OperatorGeodeticArea.js +1 -1
- package/chunks/OperatorGeodeticLength.js +1 -1
- package/chunks/OperatorProximityGeodesic.js +1 -1
- package/chunks/OperatorShapePreservingLength.js +1 -1
- package/chunks/OperatorShapePreservingProject.js +1 -1
- package/chunks/Terrain.glsl.js +11 -11
- package/chunks/UnitFactory.js +1 -1
- package/chunks/arcade.js +1 -1
- package/chunks/bundle.js +1 -1
- package/config.js +1 -1
- package/geometry/operators/gx/operatorGeodeticDistance.js +1 -1
- package/interfaces.d.ts +80 -2
- package/kernel.js +1 -1
- package/layers/IntegratedMesh3DTilesLayer.js +1 -1
- package/layers/ParquetLayer.js +1 -1
- package/layers/graphics/sources/ParquetSource.js +1 -1
- package/layers/orientedImagery/core/ExposurePoint.js +1 -1
- package/layers/orientedImagery/transformations/imageToWorld.js +1 -1
- package/layers/orientedImagery/transformations/rectifyMapPoint.js +1 -1
- package/layers/orientedImagery/transformations/utils.js +1 -1
- package/layers/orientedImagery/transformations/worldToImage.js +1 -1
- package/layers/support/ParquetEncodingWkb.js +1 -1
- package/layers/support/layerUtils.js +1 -1
- package/layers/support/parquetUtils.js +1 -1
- package/libs/parquet/parquet.js +1 -1
- package/package.json +2 -2
- package/support/arcadeUtils.js +1 -1
- package/support/revision.js +1 -1
- package/views/2d/layers/FeatureLayerView2D.js +1 -1
- package/views/2d/layers/features/layerAdapters/ParquetLayerAdapter.js +1 -1
- package/views/2d/layers/features/processor/FeatureUpdateStrategy.js +1 -1
- package/views/2d/layers/features/sources/FeatureSource.js +1 -1
- package/views/2d/layers/features/sources/strategies/ALoadStrategy.js +1 -1
- package/views/2d/layers/features/sources/strategies/ParquetSnapshotLoadStrategy.js +5 -0
- package/views/2d/layers/features/sources/strategies/ParquetTileLoadStrategy.js +5 -0
- package/views/2d/layers/features/sources/strategies/chunks/FeatureSourceEndChunk.js +5 -0
- package/views/2d/layers/features/sources/strategies/chunks/ParquetSourceChunk.js +5 -0
- package/views/2d/layers/features/sources/strategies/chunks/SourceChunkStore.js +1 -1
- package/views/2d/layers/features/support/FeatureSetReader.js +1 -1
- package/views/2d/layers/features/support/FeatureSetReaderParquet.js +1 -1
- package/views/2d/layers/features/support/XZOrder.js +5 -0
- package/views/3d/terrain/TerrainRenderer.js +1 -1
- package/views/3d/webgl-engine/shaders/{ReadShadowMapConfiguration.js → ReceiveShadowsConfiguration.js} +1 -1
- package/views/draw/support/ConnectedReshapeManager.js +5 -0
- package/views/draw/support/Reshape.js +1 -1
- package/views/draw/support/layerUtils.js +1 -1
- package/widgets/Feature/support/arcadeFeatureUtils.js +1 -1
- package/widgets/Feature/support/featureUtils.js +1 -1
- package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
- package/widgets/OrientedImageryViewer/adapters/view/MapViewAdapter.js +1 -1
- package/widgets/OrientedImageryViewer/components/ImageViewer.js +1 -1
- package/widgets/OrientedImageryViewer/components/ImageViewerViewModel.js +1 -1
- package/widgets/OrientedImageryViewer/constants.js +1 -1
- package/widgets/OrientedImageryViewer/navigation/NavigationManager.js +1 -1
- package/widgets/PanoramicViewer/PanoramicViewerViewModel.js +1 -1
- package/widgets/PanoramicViewer.js +1 -1
- package/widgets/UtilityNetworkTrace/UtilityNetworkTraceViewModel.js +1 -1
- package/assets/esri/core/workers/chunks/16ff0bf4cb74f478ec1e.js +0 -1
- package/assets/esri/core/workers/chunks/1aff43dad2302677b4f4.js +0 -1
- package/assets/esri/core/workers/chunks/c6be02d2dff6e0734dab.js +0 -1
- package/assets/esri/core/workers/chunks/c8719205518e97131375.js +0 -1
- package/views/2d/layers/features/sources/strategies/ParquetLoadStrategy.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.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{ArcadeDate as e}from"../../../../../arcade/ArcadeDate.js";import has from"../../../../../core/has.js";import{DateOnly as t}from"../../../../../core/sql/DateOnly.js";import{TimeOnly as r}from"../../../../../core/sql/TimeOnly.js";import{GeometryCursor as s}from"../../../../../geometry/GeometryCursor.js";import{fromRectValues as i}from"../../../../../geometry/support/aaBoundingBox.js";import{fromJSON as a}from"../../../../../geometry/support/jsonUtils.js";import{getLabelPoint as o}from"../../../../../geometry/support/labelPoint.js";import{quantizeX as n,quantizeY as d}from"../../../../../geometry/support/quantizationUtils.js";import{getCentroidOptimizedGeometry as u}from"../../../../../layers/graphics/centroid.js";import{convertToGeometry as h,generalizeOptimizedGeometry as c,quantizeForDisplay as l,unquantizeOptimizedGeometry as m}from"../../../../../layers/graphics/featureConversionUtils.js";import{OptimizedFeature as y}from"../../../../../layers/graphics/OptimizedFeature.js";import f from"../../../../../layers/graphics/OptimizedGeometry.js";import{system as p,unknown as g}from"../../../../../time/constants.js";import{FeatureSetCache as _}from"./FeatureSetCache.js";const b=has("featurelayer-simplify-thresholds")??[.5,.5,.5,.5],x=b[0],D=b[1],T=b[2],F=b[3],A=has("featurelayer-simplify-payload-size-factors")??[1,2,4],S=A[0],I=A[1],B=A[2],j=has("featurelayer-simplify-mobile-factor")??2,G=has("esri-mobile"),M=4294967295;function C(e,t,r){if(!(e.length>t))for(;e.length<=t;)e.push(r)}class v{constructor(e){this.metadata=e,this.type="FeatureSetReader",this._overrides=null,this._joined=[],this._objectIdToIndex=null,this._boundsBuffer=[],this._caches=new Map,this.arcadeDeclaredClass="esri.arcade.Feature",this._contextTimeZone=null}destroy(){}[Symbol.dispose](){this.destroy()}getAreaSimplificationThreshold(e,t){let r=1;const s=G?j:1;t>4e6?r=B*s:t>1e6?r=I*s:t>5e5?r=S*s:t>1e5&&(r=s);let i=0;return e>4e3?i=F*r:e>2e3?i=T*r:e>100?i=D:e>15&&(i=x),i}getBounds(e){if(C(this._boundsBuffer,4*this.getIndex()+4,0),this.getBoundsXMin()===M)return!1;if(0===this.getBoundsXMin()){const t=this.readGeometryWorldSpace();if(!t)return this.setBoundsXMin(M),!1;let r=1/0,s=1/0,a=-1/0,o=-1/0;return t.forEachVertex((e,t)=>{r=Math.min(r,e),s=Math.min(s,t),a=Math.max(a,e),o=Math.max(o,t)}),this.setBoundsXMin(r),this.setBoundsYMin(s),this.setBoundsXMax(a),this.setBoundsYMax(o),i(e,r,s,a,o),!0}const t=this.getBoundsXMin(),r=this.getBoundsYMin(),s=this.getBoundsXMax(),a=this.getBoundsYMax();return i(e,t,r,s,a),!0}getBoundsXMin(){return this._boundsBuffer[4*this.getIndex()]}setBoundsXMin(e){this._boundsBuffer[4*this.getIndex()]=e}getBoundsYMin(){return this._boundsBuffer[4*this.getIndex()+1]}setBoundsYMin(e){this._boundsBuffer[4*this.getIndex()+1]=e}getBoundsXMax(){return this._boundsBuffer[4*this.getIndex()+2]}setBoundsXMax(e){this._boundsBuffer[4*this.getIndex()+2]=e}getBoundsYMax(){return this._boundsBuffer[4*this.getIndex()+3]}setBoundsYMax(e){this._boundsBuffer[4*this.getIndex()+3]=e}readAttributeAsTimestamp(e){const t=this.readAttribute(e);return"string"==typeof t?new Date(t).getTime():"number"==typeof t||null==t?t:null}readAttribute(e,t=!1){const r=this._readAttribute(e,t);if(void 0!==r)return r;for(const s of this._joined){s.setIndex(this.getIndex());const r=s._readAttribute(e,t);if(void 0!==r)return r}}readAttributes(){const e=this._readAttributes();for(const t of this._joined){t.setIndex(this.getIndex());const r=t._readAttributes();for(const t of Object.keys(r))e[t]=r[t]}return e}joinAttributes(e){this._joined.push(e)}registerOverrides(e){this._overrides=e}withoutOverrides(){const e=this.copy();return e._overrides=null,e}readOptimizedFeatureWorldSpace(){const e=this.readGeometryWorldSpace(),t=this.readAttributes(),r=this.readCentroidWorldSpace();return new y(e,t,r,this.getObjectId(),this.getDisplayId())}readLegacyFeatureForDisplay(){const e=this.readCentroidForDisplay();return{attributes:this.readAttributes(),geometry:this.readLegacyGeometryForDisplay(),centroid:(e&&{x:e.coords[0],y:e.coords[1]})??null}}readLegacyFeatureWorldSpace(){const e=this.readCentroidWorldSpace();return{attributes:this.readAttributes(),geometry:this._readLegacyGeometryWorldSpace(),centroid:(e&&{x:e.coords[0],y:e.coords[1]})??null}}readLegacyGeometryForDisplay(){const e=this.readGeometryForDisplay();return h(e,this.geometryType,!1,!1)}readXForDisplay(){return this._readX()}readYForDisplay(){return this._readY()}readXWorldSpace(){const e=this._readX(),t=this.getInTransform();return null==t?e:e*t.scale[0]+t.translate[0]}readYWorldSpace(){const e=this._readY(),t=this.getInTransform();return null==t?e:t.translate[1]-e*t.scale[1]}readGeometryForDisplay(){const e=this._readGeometryDeltaDecoded(!0);if(!e){const e=this._createDeltaQuantizedGeometryFromServerCentroid();return e?e.deltaDecode():null}return e}readGeometryForDisplayTransformed(e){let t=this.readGeometryForDisplay();if(t&&"esriGeometryPolyline"===this.metadata.geometryType&&(t=c(new f,t,this.hasZ,this.hasM,this.metadata.geometryType,e.scale[0])),t&&(t=l(t,e,this.metadata.geometryType,this.hasZ,this.hasM)),!t){const t=this.readCentroidForDisplay();if(!t)return null;const r=n(e,t.coords[0]),s=d(e,t.coords[1]);return this._createDeltaQuantizedExtrudedGeometry(r,s).deltaDecode()}return t}readGeometryWorldSpace(){let e=this._readGeometry();if(e||(e=this._createDeltaQuantizedGeometryFromServerCentroid()),!e)return null;const t=e.clone(),r=this.getInTransform();return null!=r&&m(t,t,this.hasZ,this.hasM,r),t}readCentroidForDisplay(){const e=this.readGeometryForDisplay();return e?this._computeDisplayCentroid(e):this._readServerCentroid()}readCentroidWorldSpace(){const e=this.readGeometryForDisplay(),t=e?this._computeDisplayCentroid(e):this._readServerCentroid();if(!t)return null;const r=t.clone(),s=this.getInTransform();return null!=s&&m(r,r,this.hasZ,this.hasM,s),r}setCache(e){let t=this._caches.get(e);null==t&&(t=new _(this.getSize()),this._caches.set(e,t)),this._activeCache=t}setCachedValue(e){this._activeCache.set(this.getIndex(),e)}hasCachedValue(){return this._activeCache.has(this.getIndex())}getCachedValue(){return this._activeCache.get(this.getIndex())}_readGeometryDeltaDecoded(e){const t=this._readGeometry(e);return"esriGeometryPoint"!==this.geometryType&&t&&this.getInTransform()?t.deltaDecode():t}get contextTimeZone(){return this._contextTimeZone}set contextTimeZone(e){this._contextTimeZone=e}readArcadeFeature(){return this}hasField(e){return this.fields.has(e)||this._joined.some(t=>t.hasField(e))}geometry(){const e=this.readGeometryWorldSpace(),t=h(e,this.geometryType,this.hasZ,this.hasM),r=a(t);if(r){if(!this.metadata.outSpatialReference)throw new Error("InternalError: Expected spatial reference to be defined");r.spatialReference=this.metadata.outSpatialReference}return r}autocastArcadeDate(t,r){return r&&r instanceof Date?this.isUnknownDateTimeField(t)?e.unknownDateJSToArcadeDate(r):e.dateJSAndZoneToArcadeDate(r,this.contextTimeZone??p):r}isUnknownDateTimeField(e){return this.metadata.fieldsIndex.getTimeZone(e)===g}field(s){let i=this.fields.get(s);if(i)switch(i.type){case"date-only":case"esriFieldTypeDateOnly":return t.fromReader(this.readAttribute(s,!1));case"time-only":case"esriFieldTypeTimeOnly":return r.fromReader(this.readAttribute(s,!1));case"esriFieldTypeTimestampOffset":case"timestamp-offset":return e.fromReaderAsTimeStampOffset(this.readAttribute(s,!1));case"date":case"esriFieldTypeDate":return this.autocastArcadeDate(s,this.readAttribute(s,!0));default:return this.readAttribute(s,!1)}for(const a of this._joined)if(a.setIndex(this.getIndex()),i=a.fields.get(s),i)switch(i.type){case"date-only":case"esriFieldTypeDateOnly":return t.fromReader(a._readAttribute(s,!1));case"time-only":case"esriFieldTypeTimeOnly":return r.fromReader(a._readAttribute(s,!1));case"esriFieldTypeTimestampOffset":case"timestamp-offset":return e.fromReaderAsTimeStampOffset(a._readAttribute(s,!1));case"date":case"esriFieldTypeDate":return this.autocastArcadeDate(s,a._readAttribute(s,!0));default:return this.readAttribute(s,!1)}throw new Error(`Field ${s} does not exist`)}setField(e,t){throw new Error("Unable to update feature attribute values, feature is readonly")}keys(){return this.fields.fields.map(e=>e.name)}castToText(e=!1){if(!e)return JSON.stringify(this.readLegacyFeatureForDisplay());const t=this.readLegacyFeatureForDisplay();if(!t)return JSON.stringify(null);const r={geometry:t.geometry,attributes:{...t.attributes??{}}};for(const s in r.attributes){const e=r.attributes[s];e instanceof Date&&(r.attributes[s]=e.getTime())}return JSON.stringify(r)}gdbVersion(){return null}fullSchema(){return this.metadata.arcadeSchema}castAsJson(e=null){return{attributes:this._readAttributes(),geometry:!0===e?.keepGeometryType?this.geometry():this.geometry()?.toJSON()??null}}castAsJsonAsync(e=null,t=null){return Promise.resolve(this.castAsJson(t))}_getExists(){if(this._overrides){const e=this.getObjectId();return!this._overrides.hasOverride(e)}return!0}_computeDisplayCentroid(e){if(null==this.getInTransform())return u(new f,e,this.hasM,this.hasZ);const t=s.fromOptimized(e,this.geometryType);t.yFactor*=-1;const r=o(t);return r?(r[1]*=-1,new f([],r)):null}copyInto(e){e._joined=this._joined,e._overrides=this._overrides,e._objectIdToIndex=this._objectIdToIndex,e._boundsBuffer=this._boundsBuffer,e._activeCache=this._activeCache,e._caches=this._caches,e._contextTimeZone=this._contextTimeZone}_readLegacyGeometryWorldSpace(){const e=this.readGeometryWorldSpace();return h(e,this.geometryType,!1,!1)}_createDeltaQuantizedGeometryFromServerCentroid(){const e=this._readServerCentroid();if(!e)return null;const[t,r]=e.coords;return this._createDeltaQuantizedExtrudedGeometry(t,r)}_createDeltaQuantizedExtrudedGeometry(e,t){return"esriGeometryPolyline"===this.geometryType?this._createDeltaQuantizedExtrudedLine(e,t):this._createDeltaQuantizedExtrudedQuad(e,t)}_createDeltaQuantizedExtrudedQuad(e,t){return new f([5],[e-1,t,1,-1,1,1,-1,1,-1,-1])}_createDeltaQuantizedExtrudedLine(e,t){return new f([2],[e-1,t+1,1,-1])}}export{v as FeatureSetReader};
|
|
5
|
+
import{ArcadeDate as e}from"../../../../../arcade/ArcadeDate.js";import has from"../../../../../core/has.js";import{DateOnly as t}from"../../../../../core/sql/DateOnly.js";import{TimeOnly as r}from"../../../../../core/sql/TimeOnly.js";import{GeometryCursor as s}from"../../../../../geometry/GeometryCursor.js";import{fromRectValues as i}from"../../../../../geometry/support/aaBoundingBox.js";import{fromJSON as a}from"../../../../../geometry/support/jsonUtils.js";import{getLabelPoint as o}from"../../../../../geometry/support/labelPoint.js";import{quantizeX as n,quantizeY as d}from"../../../../../geometry/support/quantizationUtils.js";import{getCentroidOptimizedGeometry as u}from"../../../../../layers/graphics/centroid.js";import{convertToGeometry as h,generalizeOptimizedGeometry as c,quantizeForDisplay as l,unquantizeOptimizedGeometry as m}from"../../../../../layers/graphics/featureConversionUtils.js";import{OptimizedFeature as y}from"../../../../../layers/graphics/OptimizedFeature.js";import f from"../../../../../layers/graphics/OptimizedGeometry.js";import{system as p,unknown as g}from"../../../../../time/constants.js";import{FeatureSetCache as _}from"./FeatureSetCache.js";const b=has("featurelayer-simplify-thresholds")??[.5,.5,.5,.5],x=b[0],D=b[1],T=b[2],F=b[3],A=has("featurelayer-simplify-payload-size-factors")??[1,2,4],S=A[0],I=A[1],B=A[2],j=has("featurelayer-simplify-mobile-factor")??2,G=has("esri-mobile"),M=4294967295;function C(e,t,r){if(!(e.length>t))for(;e.length<=t;)e.push(r)}class v{constructor(e){this.metadata=e,this.type="FeatureSetReader",this._overrides=null,this._joined=[],this._objectIdToIndex=null,this._boundsBuffer=[],this._caches=new Map,this.arcadeDeclaredClass="esri.arcade.Feature",this._contextTimeZone=null}destroy(){}[Symbol.dispose](){this.destroy()}getAreaSimplificationThreshold(e,t){let r=1;const s=G?j:1;t>4e6?r=B*s:t>1e6?r=I*s:t>5e5?r=S*s:t>1e5&&(r=s);let i=0;return e>4e3?i=F*r:e>2e3?i=T*r:e>100?i=D:e>15&&(i=x),i}getBounds(e){C(this._boundsBuffer,4*this.getIndex()+4,0);const t=this.getBoundsXMin();if(t===M||!isFinite(t))return!1;if(0===this.getBoundsXMin()){const t=this.readGeometryWorldSpace();if(t?.isPoint&&0===t.coords[0]&&0===t.coords[1])return i(e,0,0,0,0),!0;if(!t)return this.setBoundsXMin(M),!1;let r=1/0,s=1/0,a=-1/0,o=-1/0;return t.forEachVertex((e,t)=>{r=Math.min(r,e),s=Math.min(s,t),a=Math.max(a,e),o=Math.max(o,t)}),this.setBoundsXMin(r),this.setBoundsYMin(s),this.setBoundsXMax(a),this.setBoundsYMax(o),i(e,r,s,a,o),!0}const r=this.getBoundsXMin(),s=this.getBoundsYMin(),a=this.getBoundsXMax(),o=this.getBoundsYMax();return i(e,r,s,a,o),!0}getBoundsXMin(){return this._boundsBuffer[4*this.getIndex()]}setBoundsXMin(e){this._boundsBuffer[4*this.getIndex()]=e}getBoundsYMin(){return this._boundsBuffer[4*this.getIndex()+1]}setBoundsYMin(e){this._boundsBuffer[4*this.getIndex()+1]=e}getBoundsXMax(){return this._boundsBuffer[4*this.getIndex()+2]}setBoundsXMax(e){this._boundsBuffer[4*this.getIndex()+2]=e}getBoundsYMax(){return this._boundsBuffer[4*this.getIndex()+3]}setBoundsYMax(e){this._boundsBuffer[4*this.getIndex()+3]=e}readAttributeAsTimestamp(e){const t=this.readAttribute(e);return"string"==typeof t?new Date(t).getTime():"number"==typeof t||null==t?t:null}readAttribute(e,t=!1){const r=this._readAttribute(e,t);if(void 0!==r)return r;for(const s of this._joined){s.setIndex(this.getIndex());const r=s._readAttribute(e,t);if(void 0!==r)return r}}readAttributes(){const e=this._readAttributes();for(const t of this._joined){t.setIndex(this.getIndex());const r=t._readAttributes();for(const t of Object.keys(r))e[t]=r[t]}return e}joinAttributes(e){this._joined.push(e)}registerOverrides(e){this._overrides=e}withoutOverrides(){const e=this.copy();return e._overrides=null,e}readOptimizedFeatureWorldSpace(){const e=this.readGeometryWorldSpace(),t=this.readAttributes(),r=this.readCentroidWorldSpace();return new y(e,t,r,this.getObjectId(),this.getDisplayId())}readLegacyFeatureForDisplay(){const e=this.readCentroidForDisplay();return{attributes:this.readAttributes(),geometry:this.readLegacyGeometryForDisplay(),centroid:(e&&{x:e.coords[0],y:e.coords[1]})??null}}readLegacyFeatureWorldSpace(){const e=this.readCentroidWorldSpace();return{attributes:this.readAttributes(),geometry:this._readLegacyGeometryWorldSpace(),centroid:(e&&{x:e.coords[0],y:e.coords[1]})??null}}readLegacyGeometryForDisplay(){const e=this.readGeometryForDisplay();return h(e,this.geometryType,!1,!1)}readXForDisplay(){return this._readX()}readYForDisplay(){return this._readY()}readXWorldSpace(){const e=this._readX(),t=this.getInTransform();return null==t?e:e*t.scale[0]+t.translate[0]}readYWorldSpace(){const e=this._readY(),t=this.getInTransform();return null==t?e:t.translate[1]-e*t.scale[1]}readGeometryForDisplay(){const e=this._readGeometryDeltaDecoded(!0);if(!e){const e=this._createDeltaQuantizedGeometryFromServerCentroid();return e?e.deltaDecode():null}return e}readGeometryForDisplayTransformed(e){let t=this.readGeometryForDisplay();if(t&&"esriGeometryPolyline"===this.metadata.geometryType&&(t=c(new f,t,this.hasZ,this.hasM,this.metadata.geometryType,e.scale[0])),t&&(t=l(t,e,this.metadata.geometryType,this.hasZ,this.hasM)),!t){const t=this.readCentroidForDisplay();if(!t)return null;const r=n(e,t.coords[0]),s=d(e,t.coords[1]);return this._createDeltaQuantizedExtrudedGeometry(r,s).deltaDecode()}return t}readGeometryWorldSpace(){let e=this._readGeometry();if(e||(e=this._createDeltaQuantizedGeometryFromServerCentroid()),!e)return null;const t=e.clone(),r=this.getInTransform();return null!=r&&m(t,t,this.hasZ,this.hasM,r),t}readCentroidForDisplay(){const e=this.readGeometryForDisplay();return e?this._computeDisplayCentroid(e):this._readServerCentroid()}readCentroidWorldSpace(){const e=this.readGeometryForDisplay(),t=e?this._computeDisplayCentroid(e):this._readServerCentroid();if(!t)return null;const r=t.clone(),s=this.getInTransform();return null!=s&&m(r,r,this.hasZ,this.hasM,s),r}setCache(e){let t=this._caches.get(e);null==t&&(t=new _(this.getSize()),this._caches.set(e,t)),this._activeCache=t}setCachedValue(e){this._activeCache.set(this.getIndex(),e)}hasCachedValue(){return this._activeCache.has(this.getIndex())}getCachedValue(){return this._activeCache.get(this.getIndex())}_readGeometryDeltaDecoded(e){const t=this._readGeometry(e);return"esriGeometryPoint"!==this.geometryType&&t&&this.getInTransform()?t.deltaDecode():t}get contextTimeZone(){return this._contextTimeZone}set contextTimeZone(e){this._contextTimeZone=e}readArcadeFeature(){return this}hasField(e){return this.fields.has(e)||this._joined.some(t=>t.hasField(e))}geometry(){const e=this.readGeometryWorldSpace(),t=h(e,this.geometryType,this.hasZ,this.hasM),r=a(t);if(r){if(!this.metadata.outSpatialReference)throw new Error("InternalError: Expected spatial reference to be defined");r.spatialReference=this.metadata.outSpatialReference}return r}autocastArcadeDate(t,r){return r&&r instanceof Date?this.isUnknownDateTimeField(t)?e.unknownDateJSToArcadeDate(r):e.dateJSAndZoneToArcadeDate(r,this.contextTimeZone??p):r}isUnknownDateTimeField(e){return this.metadata.fieldsIndex.getTimeZone(e)===g}field(s){let i=this.fields.get(s);if(i)switch(i.type){case"date-only":case"esriFieldTypeDateOnly":return t.fromReader(this.readAttribute(s,!1));case"time-only":case"esriFieldTypeTimeOnly":return r.fromReader(this.readAttribute(s,!1));case"esriFieldTypeTimestampOffset":case"timestamp-offset":return e.fromReaderAsTimeStampOffset(this.readAttribute(s,!1));case"date":case"esriFieldTypeDate":return this.autocastArcadeDate(s,this.readAttribute(s,!0));default:return this.readAttribute(s,!1)}for(const a of this._joined)if(a.setIndex(this.getIndex()),i=a.fields.get(s),i)switch(i.type){case"date-only":case"esriFieldTypeDateOnly":return t.fromReader(a._readAttribute(s,!1));case"time-only":case"esriFieldTypeTimeOnly":return r.fromReader(a._readAttribute(s,!1));case"esriFieldTypeTimestampOffset":case"timestamp-offset":return e.fromReaderAsTimeStampOffset(a._readAttribute(s,!1));case"date":case"esriFieldTypeDate":return this.autocastArcadeDate(s,a._readAttribute(s,!0));default:return this.readAttribute(s,!1)}throw new Error(`Field ${s} does not exist`)}setField(e,t){throw new Error("Unable to update feature attribute values, feature is readonly")}keys(){return this.fields.fields.map(e=>e.name)}castToText(e=!1){if(!e)return JSON.stringify(this.readLegacyFeatureForDisplay());const t=this.readLegacyFeatureForDisplay();if(!t)return JSON.stringify(null);const r={geometry:t.geometry,attributes:{...t.attributes??{}}};for(const s in r.attributes){const e=r.attributes[s];e instanceof Date&&(r.attributes[s]=e.getTime())}return JSON.stringify(r)}gdbVersion(){return null}fullSchema(){return this.metadata.arcadeSchema}castAsJson(e=null){return{attributes:this._readAttributes(),geometry:!0===e?.keepGeometryType?this.geometry():this.geometry()?.toJSON()??null}}castAsJsonAsync(e=null,t=null){return Promise.resolve(this.castAsJson(t))}_getExists(){if(this._overrides){const e=this.getObjectId();return!this._overrides.hasOverride(e)}return!0}_computeDisplayCentroid(e){if(null==this.getInTransform())return u(new f,e,this.hasM,this.hasZ);const t=s.fromOptimized(e,this.geometryType);t.yFactor*=-1;const r=o(t);return r?(r[1]*=-1,new f([],r)):null}copyInto(e){e._joined=this._joined,e._overrides=this._overrides,e._objectIdToIndex=this._objectIdToIndex,e._boundsBuffer=this._boundsBuffer,e._activeCache=this._activeCache,e._caches=this._caches,e._contextTimeZone=this._contextTimeZone}_readLegacyGeometryWorldSpace(){const e=this.readGeometryWorldSpace();return h(e,this.geometryType,!1,!1)}_createDeltaQuantizedGeometryFromServerCentroid(){const e=this._readServerCentroid();if(!e)return null;const[t,r]=e.coords;return this._createDeltaQuantizedExtrudedGeometry(t,r)}_createDeltaQuantizedExtrudedGeometry(e,t){return"esriGeometryPolyline"===this.geometryType?this._createDeltaQuantizedExtrudedLine(e,t):this._createDeltaQuantizedExtrudedQuad(e,t)}_createDeltaQuantizedExtrudedQuad(e,t){return new f([5],[e-1,t,1,-1,1,1,-1,1,-1,-1])}_createDeltaQuantizedExtrudedLine(e,t){return new f([2],[e-1,t+1,1,-1])}}export{v as FeatureSetReader};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import"../../../../../core/has.js";import{baseObjectMemory as e}from"../../../../../core/memoryEstimations.js";import t from"../../../../../layers/graphics/OptimizedGeometry.js";import{
|
|
5
|
+
import"../../../../../core/has.js";import{baseObjectMemory as e}from"../../../../../core/memoryEstimations.js";import t from"../../../../../layers/graphics/OptimizedGeometry.js";import{QuantizedGeometryBuffer as r}from"../../../../../chunks/bundle.js";import{FeatureSetReader as n}from"./FeatureSetReader.js";let s;class i extends n{constructor(t,r,n,s,i=new Uint32Array(n.size())){super(t),this._fields=r,this._inner=n,this._chunkId=s,this._displayIds=i,this._index=-1,this.usedMemory=e,this._size=this._inner.size();t.featureIdInfo.type,this._chunkId>65535&&console.error("Exceeded max allowed parquet reader size")}destroy(){super.destroy(),this._inner.free()}get fields(){return this._fields}get geometryType(){return this.metadata.geometryType}get hasFeatures(){return!0}get hasNext(){throw new Error("Method not implemented.")}get exceededTransferLimit(){return!1}get hasZ(){return!1}get hasM(){return!1}getInTransform(){return null}getSize(){return this._size}getCursor(){return this.copy()}getAttributeHash(){let e="";for(const t of this.fields.fields)e+=this._readAttribute(t.name,!1)+".";return e}getObjectId(){return this._inner.rowId(this._index)}getDisplayId(){return this._displayIds[this._index]}setDisplayId(e){this._displayIds[this._index]=e}setIndex(e){this._index=e}getBoundsXMin(){return this._inner.boundsXMin(this._index)}getBoundsYMin(){return this._inner.boundsYMin(this._index)}getBoundsXMax(){return this._inner.boundsXMax(this._index)}getBoundsYMax(){return this._inner.boundsYMax(this._index)}setBoundsXMin(e){throw new Error("InternalError: Setting bounds is unsupported")}setBoundsYMin(e){throw new Error("InternalError: Setting bounds is unsupported")}setBoundsXMax(e){throw new Error("InternalError: Setting bounds is unsupported")}setBoundsYMax(e){throw new Error("InternalError: Setting bounds is unsupported")}getIndex(){return this._index}next(){for(;++this._index<this._size&&!this._getExists(););return this._index<this._size}readGeometryArea(){return this.readGeometryForDisplay()?.area()??0}copy(){const e=new i(this.metadata,this._fields,this._inner,this._chunkId,this._displayIds);return this.copyInto(e),e}copyInto(e){super.copyInto(e),e._index=this._index}readGeometryForDisplayTransformed(e){const[n,i]=e.translate,[d,o]=e.scale;s||(s=r.new());return this._inner.transformGeometry(s,n,i,d,o,this._index)?new t(s.readLengthsUnsafe(),s.readCoordsUnsafe()):null}_readGeometry(e){const r=this._inner.readCoords(this._index),n=this._inner.readLengths(this._index);return r&&n?new t(n,r):null}_readX(){return this._inner.readX(this._index)}_readY(){return this._inner.readY(this._index)}_readServerCentroid(){return null}_readAttribute(e,t){const r=this.fields.get(e);if(!r)return;if(null==r.attributeId)return this.getObjectId();const n=this._inner.readAttribute(this._index,r.attributeId);if(null==n)return n;const s=this.fields.isDateField(r.name);return t?null==n?n:s?new Date(n):n:n}_readAttributes(){const e={};for(const t of this._fields.fields)null!=t.attributeId&&(this._inner.isEmpty(t.attributeId)||(e[t.name]=this._readAttribute(t.name,!1)));return e.__OBJECTID=this.getObjectId(),e}}export{i as FeatureSetReaderParquet};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/*
|
|
2
|
+
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
|
+
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
|
+
*/
|
|
5
|
+
function n(n,t,e){return h(o(n,t,e))}function t(n,t,e,m=e){return h(a(n,t,e,Math.min(m,e)))}function e(n,t,e){const x=n.xmax-n.xmin,i=n.ymax-n.ymin,o=t.xmax-t.xmin,r=t.ymax-t.ymin,a=Math.log2(x/o),u=Math.log2(i/r),c=Math.floor(Math.min(a,u))+1;let s=Math.min(c,e);const f=x/2**s,y=i/2**s,h=Math.floor(t.xmin/f),l=Math.floor(t.xmax/f),d=Math.floor(t.ymin/y),p=Math.floor(t.ymax/y);return(l-h+1>2||p-d+1>2)&&(s-=1),m(n,t.xmin,t.ymin,e,s)}function m(n,t,e,m,x=m){let i=0,o=0n,{xmin:r,ymin:a,xmax:c,ymax:s}=n;for(;i!==x;){const n=(r+c)/2;let x=0;t>n?(x=1,r=n):c=n;const f=(a+s)/2;let y=0;e>f?(y=1,a=f):s=f;o+=u(x|y<<1,i,m),i+=1}return o}function x(n,t){let e=0n;for(let m=0;m<n.length;m++)e+=u(n[m],m,t);return e}function i(n,t){const e=[...n];for(let m=n.length;m<t;m++)e.push(3);return{start:x(n,t),end:x(e,t)}}function o(n,t,e){const m=[],x=[{extent:n,codeSum:0n,depth:0}];for(;x.length;){const{extent:n,codeSum:i,depth:o}=x.pop();if(!c(n,t))continue;if(s(t,n)){const n=i;let t=i;for(let m=o;m<e;m++)t+=u(3,m,e);m.push({start:n,end:t});continue}if(o===e){m.push({start:i,end:i});continue}const r=f(n);for(let t=0;t<r.length;t++)x.push({extent:r[t],codeSum:i+u(t,o,e),depth:o+1})}return m}function r(n){const t=n.xmax-n.xmin,e=n.ymax-n.ymin;return{xmin:n.xmin,ymin:n.ymin,xmax:n.xmax+t,ymax:n.ymax+e}}function a(n,t,e,m){const x=[],i=[{extent:n,codeSum:0n,depth:0}];for(;i.length;){const{extent:n,codeSum:o,depth:a}=i.pop();if(!c(r(n),t))continue;if(s(t,r(n))){const n=o;let t=o;for(let m=a;m<e;m++)t+=u(3,m,e);x.push({start:n,end:t});continue}if(x.push({start:o,end:o}),a===m)continue;const y=f(n);for(let t=0;t<y.length;t++)i.push({extent:y[t],codeSum:o+u(t,a,e),depth:a+1})}return x}function u(n,t,e){return BigInt(n)*y(e,t)+1n}function c(n,t){return!(n.xmax<=t.xmin||n.xmin>=t.xmax||n.ymax<=t.ymin||n.ymin>=t.ymax)}function s(n,t){return t.xmin>=n.xmin&&t.xmax<=n.xmax&&t.ymin>=n.ymin&&t.ymax<=n.ymax}function f(n){const t=(n.xmin+n.xmax)/2,e=(n.ymin+n.ymax)/2;return[{xmin:n.xmin,xmax:t,ymin:n.ymin,ymax:e},{xmin:t,xmax:n.xmax,ymin:n.ymin,ymax:e},{xmin:n.xmin,xmax:t,ymin:e,ymax:n.ymax},{xmin:t,xmax:n.xmax,ymin:e,ymax:n.ymax}]}function y(n,t){return(4n**(BigInt(n)-BigInt(t))-1n)/3n}function h(n){if(0===n.length)return[];n.sort((n,t)=>n.start===t.start?n.end<t.end?-1:1:n.start<t.start?-1:1);const t=[];let e=n[0];for(let m=1;m<n.length;m++){const x=n[m];e.end+1n>=x.start?e={start:e.start,end:e.end>x.end?e.end:x.end}:(t.push(e),e=x)}return t.push(e),t}export{e as getExtentXZCode,m as getPointXZCode,n as getQueryXZCodeRanges,t as getQueryXZCodeRangesExpanded,x as getXZCodeForSequence,i as getXZInterval};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as e}from"tslib";import t from"../../../Color.js";import has from"../../../core/has.js";import{disposeMaybe as i}from"../../../core/maybe.js";import{MemCachePool as r}from"../../../core/MemCachePool.js";import s from"../../../core/ObjectPool.js";import{watch as n,sync as a}from"../../../core/reactiveUtils.js";import{property as o}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as l}from"../../../core/accessorSupport/decorators/subclass.js";import{d as c,i as d,e as h}from"../../../chunks/vec32.js";import{ZEROS as u,create as _,fromValues as g}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{fromValues as p,ZEROS as f}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{create as m,set as y}from"../../../geometry/support/aaBoundingBox.js";import{BufferViewVec3f as b}from"../../../geometry/support/buffer/BufferView.js";import{overlayRenderOccludedFlag as x}from"./OverlayRenderer.js";import{PatchRenderData as T}from"./PatchRenderData.js";import{TerrainAttributesCache as v}from"./TerrainAttributesCache.js";import{enableTerrainInternalChecks as R}from"./terrainUtils.js";import{TileRenderer as O}from"./TileRenderer.js";import{IteratorPreorder as P,sortTiles as w,compareTiles as S}from"./tileUtils.js";import{componentMinimalSizeForIntersectionData as D,ComponentIntersectionData as B}from"../webgl-engine/collections/Component/ComponentIntersectionData.js";import{getOverlayContentForOutputTerrain as C}from"../webgl-engine/core/shaderLibrary/terrain/Overlay.glsl.js";import{SyncRenderPlugin as j,ConsumesDepth as E,ConsumesNone as q}from"../webgl-engine/effects/RenderPlugin.js";import{Vertices as F}from"../webgl-engine/lib/Attribute.js";import{IntersectorResult as k}from"../webgl-engine/lib/IntersectorResult.js";import{intersectAabbInvDirBefore as A,MeshIntersectionOptions as M,intersectTriangles as N}from"../webgl-engine/lib/RayIntersections.js";import{getSettings as G}from"../webgl-engine/lib/screenSizePerspectiveUtils.js";import{terrainId as z,getVerticalOffsetTerrain as U}from"../webgl-engine/lib/verticalOffsetUtils.js";import{DrawParameters as I}from"../webgl-engine/materials/DrawParameters.js";import{T as L}from"../../../chunks/Terrain.glsl.js";import{TerrainTechnique as V}from"../webgl-engine/shaders/TerrainTechnique.js";import{TerrainTechniqueConfiguration as H}from"../webgl-engine/shaders/TerrainTechniqueConfiguration.js";import{PrimitiveType as W}from"../../webgl/enums.js";const Y=7,Q=10,Z=m();let J=class extends j{get _isGlobal(){return 1===this._stage.viewingMode}get _techniques(){return this._context.techniques}get _rctx(){return this._context.renderContext.rctx}constructor(e,t,i,n,a,o){super({}),this._overlayRenderer=e,this._stage=t,this._allTiles=i,this._ellipsoidRadius=n,this._compressionTracker=a,this.type=2,this.isGround=!0,this._passParameters=new L,this._drawParameters=new I,this._renderDataPool=new s(T),this._visiblePatchesByOrigin=new Map,this._allPatchesByOrigin=new Map,this._patchesByOriginDirty=!0,this._patchSortingDirty=!0,this._tileIterator=new P,this._castShadows=!1,this._inViewshed=!1,this._tileRenderer=null,this._stencilEnabledLayerExtents=new Array,this._numTilesRendered=0,this._numTilesCulled=0,this._numOriginsRendered=0,this.renderOccludedFlags=1,this.produces=new Map([[1,()=>this._produces()&&0===this.transparency],[6,()=>this._produces()&&(1===this.transparency||2===this.transparency)],[8,()=>this._produces()&&this.renderOccludedFlags===x]]),this._tileSize=256,this._configuration=new H(1===t.viewingMode),this._tileTextureCache=new r((e,t)=>o.newCache(e,t),"TileTexture"),this.tileGeometryCache=new v(o)}normalizeCtorArgs(){return{}}initialize(){this._stage.addRenderPlugin(this),this.addHandles(n(()=>this._overlayRenderer.renderOccludedFlags,e=>{this.renderOccludedFlags=e,this.setNeedsRender()},a))}destroy(){this._stage.removeRenderPlugin(this),this._tileTextureCache.destroy(),this.tileGeometryCache.destroy(),this._allTiles.prune(),this._tileRenderer=null}_produces(){return this.visible&&!!this._rootTiles&&!this.renderingDisabled}consumes(){return this._overlayRenderer.hasWater?E:q}set renderingDisabled(e){this._set("renderingDisabled",!!e),this.setDirty()}set visible(e){this._set("visible",!!e),this.setDirty()}updateHeading(e){this._tileRenderer?.updateHeading(e)}set transparency(e){this._configuration.transparencyMode!==e&&(this._configuration.transparencyMode=e,this.setNeedsRender())}get transparency(){return this._configuration.transparencyMode}get renderPatchBorders(){return this._configuration.tileBorders}set renderPatchBorders(e){this._configuration.tileBorders!==e&&(this._configuration.tileBorders=e,this.setNeedsRender(),this.notifyChange("renderPatchBorders"))}get visualizeNormals(){return this._configuration.visualizeNormals}set visualizeNormals(e){this._configuration.visualizeNormals!==e&&(this._configuration.visualizeNormals=e,this.setNeedsRender(),this.notifyChange("visualizeNormals"))}get cullBackFaces(){return this._configuration.backfaceCullingEnabled}set cullBackFaces(e){this._configuration.backfaceCullingEnabled!==e&&(this._configuration.backfaceCullingEnabled=e,this.notifyChange("cullBackFaces"),this.setNeedsRender())}set renderOrder(e){this._set("renderOrder",e),this._setSortingDirty()}get layerViewUid(){return z}get slicePlaneEnabled(){return this._configuration.hasSlicePlane}set slicePlaneEnabled(e){this._configuration.hasSlicePlane!==e&&(this._configuration.hasSlicePlane=e,this.setNeedsRender())}set textureFadingEnabled(e){this._configuration.textureFadingEnabled!==e&&(this._configuration.textureFadingEnabled=e,this.setNeedsRender())}set pbrMode(e){this._configuration.pbrMode!==e&&(this._configuration.pbrMode=e,this.setNeedsRender())}setDebugScreenSizePerspective(e){this._configuration.screenSizePerspective!==e&&(this._configuration.screenSizePerspective=e,this.setNeedsRender())}setRootTiles(e){this._rootTiles=e,this.setDirty()}setStencilEnabledLayerExtents(e){this._stencilEnabledLayerExtents=e,this._setSortingDirty()}set tileSize(e){this._tileSize=e,null!=this._tileRenderer&&(this._tileRenderer.tileSize=e),this.setDirty()}get tileSize(){return this._tileSize}_ensureRenderData(e){e.renderData||(e.renderData=this._renderDataPool.acquire(),e.renderData.init(e,this._getLocalOriginOfTile(e)))}loadTile(e){this._ensureRenderData(e),this.updateTileGeometryState(e),this.reuseTextureFromParent(e)||this.updateTileTexture(e,32)}reuseTextureFromParent(e){const t=e.parent;if(!t)return!1;const i=p(1&e.lij[2]?.5:0,1&e.lij[1]?0:.5,.5,.5);return t.renderData?.reuseTexture(e.renderData,i)??!1}updateTileTexture(e,t){null!=this._tileRenderer&&(this._tileRenderer.updateTileTexture(e,32===t?0:2),this.setNeedsRender(),e.resetPendingUpdate(t))}updateTileGeometryState(e){for(const i of e.layerInfo[0])i.pendingUpdates&=-9;e.resetPendingUpdate(8);const t=e.renderData.updateGeometryState();return t&&this.setDirty(),t}updateGeometryIfNeeded(e){e.loaded&&e.renderData.updateGeometryIfNeeded(this._rctx)}unloadTile(e){const t=e.renderData;t&&(t.releaseGeometry(),this._renderDataPool.release(t),t.clear(),e.renderData=null,e.setMemoryDirty(),this.setDirty())}_getLocalOriginOfTile(e){const t=Q-Y,i=Math.max(0,Math.floor((e.level-t)/Y)*Y);if(this._isGlobal&&0===i)return u;for(;e.parent&&e.level>i;)e=e.parent;return e.centerAtSeaLevel}getStats(){return{numTilesRendered:this._numTilesRendered,numTilesCulled:this._numTilesCulled,numOriginsRendered:this._numOriginsRendered}}set wireframe(e){this._get("wireframe")!==e&&(this._set("wireframe",e),this.setNeedsRender())}setDirty(e=1){this._patchesByOriginDirty=!0,this._context.requestRender(e)}_setSortingDirty(e=1){this._patchSortingDirty=!0,this._context.requestRender(e)}setNeedsRender(e=1){this._context.requestRender(e)}initializeRenderContext(e){this._context=e,this._tileRenderer=new O(this._rctx,this._tileSize,this._techniques,this._tileTextureCache,this._compressionTracker),this.updateTileBackground()}uninitializeRenderContext(){this._tileRenderer=i(this._tileRenderer)}intersect(e,t,i,r){if(!this._rootTiles||e.options.selectOpaqueTerrainOnly&&e.options.selectionMode&&0!==this.transparency)return;const s=K,n=X;c(s,r,i),d(n,1/s[0],1/s[1],1/s[2]);const a=e.results.min,o=e.results.max,l=e.results.ground,u=0===e.options.store,_=!!e.results.ground.target,g=U(e.verticalOffset),p=e.tolerance;let f,m=u&&null!=a.distance?a.distance:1/0;const x=e.options,T=x.normalRequired||!x.backfacesTerrain,v=new M(!1,T),R=d=>{const _=d.renderData;if(!_?.vao)return;const R=_.geometry;y(Z,R.boundingBox);const O=_.localOrigin;null!=g&&(g.localOrigin=O,g.applyToAabb(Z));const P=Z;if($[0]=i[0]-O[0],$[1]=i[1]-O[1],$[2]=i[2]-O[2],!A(P,$,n,p,m))return;const w=(e,t,i)=>{e.set(this.type,d,t,i),m=u&&null!=a.distance?a.distance:1/0},S=(n,c,d)=>{if((!T||null!=d)&&n>=0&&(x.backfacesTerrain||h(d,s)<0)&&(x.invisibleTerrain||!x.selectionMode||null==t||t(i,r,n))){if((null==l.distance||n<l.distance)&&w(l,n,d),x.isFiltered)return;2===x.store&&(null==f?(f=new k(e.ray),w(f,n,d),e.results.all.push(f)):n<f.distance&&w(f,n,d)),(null==a.distance||n<a.distance)&&w(a,n,d),0!==x.store&&(null==o.distance||n>o.distance)&&w(o,n,d)}},C=ee;c(C,r,O);const{indices:j,indexCount:E}=R,q=R.vertexAttributes,M=q.getField("position",b),G=new F(M.typedBuffer,3,q.stride/4),z=E/3;if(!g&&z>D){const e=d.renderData;null==e.intersectionData&&(e.intersectionData=new B(j,0,z,G)),e.intersectionData.intersectRay($,C,v,S)}else N($,C,0,z,j,G,g,v,S)},O=this._rootTiles;if(null!=O){(()=>{const t=this._tileIterator;t.reset(O);const r=e.options.invisibleTerrain;for(let e=t.next();e;e=t.next())!(e.visible||r&&e.intersectsClippingArea)||null==g&&!e.intersectsRay(i,s,p,m)||_&&this._useStencilForTile(e)?t.skipSubtree():R(e)})()}}processScaleRangeQueries(e,t){if(!t.done&&e)for(this._updatePatchGroups();e.updating&&!t.done;){e.prepare();for(const t of this._visiblePatchesByOrigin.values())for(const i of t)null!=i.renderData?.textureReference&&e.queriesForTile(i);e.process(),t.madeProgress()}}acquireTechniques(e){const t=!!has("enable-feature:terrain-shadows")&&e.bind.shadowMap.enabled;t!==this._castShadows&&(this._castShadows=t,this._patchesByOriginDirty=!0);const i=e.bind.viewshedEnabled;if(this._inViewshed!==i&&(this._inViewshed=i,this._patchesByOriginDirty=!0),8===e.bind.slot){if(0===(e.renderOccludedMask&x))return null}else{const t=0===this.transparency?1:6;if(e.bind.slot!==t)return null}if(3===this.transparency)return null;const r=this._configuration;switch(r.screenSpaceReflections=r.cloudReflections=r.receiveShadows=r.receiveAmbientOcclusion=r.renderOccluded=r.hasHighlightMixTexture=!1,r.overlayMode=this._overlayRenderer.mode,e.output){case 0:case 1:{r.screenSpaceReflections=null!=e.bind.ssr.lastFrameColor,r.cloudReflections=null!=e.bind.clouds.data,r.receiveShadows=e.bind.shadowMap.ready;const t=8===e.bind.slot;return r.renderOccluded=t,r.receiveAmbientOcclusion=!t&&null!=e.bind.ssao,this._acquireTechnique(e.output)}case 4:case 6:return this._castShadows?this._acquireTechnique(4):null;case 7:return this._inViewshed?this._acquireTechnique(7):null;case 2:case 3:return this._acquireTechnique(e.output);case 9:return this._acquireTechnique(9);case 8:return r.hasHighlightMixTexture=null!=e.bind.highlightMixTexture,this._overlayRenderer.hasHighlights?this._acquireTechnique(8):null}return null}render(e,t){switch(this._updatePatchGroups(),t.useStencil=!1,this._passParameters.overlayContent=C(e.output,e.bind),e.output){case 0:case 1:this._renderMaterialPass(e,t);break;case 2:case 3:case 9:this._renderAuxiliaryPass(e,t,this._visiblePatchesByOrigin);break;case 8:{const i=e.bind.highlight?.name;i&&this._overlayRenderer.hasHighlights&&this._overlayRenderer.renders(2)&&this._overlayRenderer.hasHighlight(i)&&this._renderAuxiliaryPass(e,t,this._visiblePatchesByOrigin);break}case 4:case 6:case 7:this._renderAuxiliaryPass(e,t,this._allPatchesByOrigin)}}updateTileBackground(e){if(null==this._tileRenderer)return;const i=this._tileRenderer;let r;if(null!=e){const i=t.toUnitRGBA(e);r=g(i[0]||0,i[1]||0,i[2]||0)}i.setBackground(r),this._allTiles.forAll(e=>i.updateTileTexture(e,0)),this._configuration.tileBlendInput=i.backgroundIsGrid?2:null!=i.backgroundColor?1:0,this.setNeedsRender()}_updatePatchGroups(){if(this._patchesByOriginDirty&&(this._rebuildPatchGroups(),this._patchesByOriginDirty=!1,this._patchSortingDirty=!0),this._patchSortingDirty&&0!==this.renderOrder){const e=Array.from(this._visiblePatchesByOrigin.values()),t=this._stencilEnabledLayerExtents;for(const i of e)w(this.renderOrder,i,t);e.sort((e,t)=>S(e[0],t[0],this.renderOrder)),this._visiblePatchesByOrigin=new Map(e.map(e=>[e[0].renderData.localOrigin,e])),this._patchSortingDirty=!1}}_rebuildPatchGroups(){const e=this._rootTiles;if(null!=e){e[0]?.surface.checkAllTilesWaterproofness(),this._visiblePatchesByOrigin.clear(),this._allPatchesByOrigin.clear();for(const t of e)this._rebuildPatchGroupsForRootTile(t)}}_rebuildPatchGroupsForRootTile(e){const t=this._tileIterator;for(t.resetOne(e);!t.done;){const e=t.next(),i=e.renderData;if(!i){this._numTilesCulled++;continue}const r=i.localOrigin;if(this._castShadows||this._inViewshed){let t=this._allPatchesByOrigin.get(r);t||(t=[],this._allPatchesByOrigin.set(r,t)),t.push(e)}if(!e.visible){this._numTilesCulled++,t.skipSubtree();continue}let s=this._visiblePatchesByOrigin.get(r);s||(s=[],this._visiblePatchesByOrigin.set(r,s)),s.push(e),t.skipSubtree()}}_useStencilForTile(e){for(const t of this._stencilEnabledLayerExtents)if(e.intersectsExtent(t))return!0;return!1}_renderAuxiliaryPass(e,t,i){const{rctx:r,bind:s}=e;r.bindTechnique(t,s,this._passParameters);const n=this._stencilEnabledLayerExtents.length>0;i.forEach(e=>{this._drawParameters.origin=e[0].renderData.localOrigin,t.program.bindDraw(s,this._passParameters,this._drawParameters);for(let i=0;i<e.length;i++)this._renderPatch(r,t,e[i],W.TRIANGLES,n,null===this._passParameters.overlayContent)}),r.bindVAO(null)}_renderMaterialPass(e,t){const{rctx:i,bind:r}=e;i.bindTechnique(t,r,this._passParameters),this._numTilesRendered=0,this._numTilesCulled=0,this._numOriginsRendered=0;const s=r.camera,n=t.program;if(this._configuration.screenSizePerspective&&this.pointsOfInterest){const e=G(this._stage.viewingMode,this._ellipsoidRadius),t=this.pointsOfInterest.centerOnSurfaceFrequent.distance;e.update({distance:t,fovY:s.fovY})}const a=this._stencilEnabledLayerExtents.length>0,o=8===r.slot;o&&(n.bindTexture("tex",i.emptyTexture),n.setUniform3fv("textureOpacities",u),n.setUniform4fv("texOffsetAndScale",f));const l=null!=this._tileRenderer?.backgroundColor?this._tileRenderer.backgroundColor:u;1===this._configuration.tileBlendInput&&n.setUniform3fv("backgroundColor",l);const c=this.wireframe?W.LINES:W.TRIANGLES;this._configuration.textureFadingEnabled&&n.bindTexture("texNext",i.emptyTexture);const d=this._visiblePatchesByOrigin;for(const h of d.values()){const e=h[0].renderData.localOrigin;this._drawParameters.origin=e,t.program.bindDraw(r,this._passParameters,this._drawParameters),this._numOriginsRendered++;for(const r of h){const e=r.renderData,s=e.textureReference;if(null!=s){if(!o){n.setUniform4fv("texOffsetAndScale",s.offsetAndScale),n.bindTexture("tex",s.texture.texture);const t=e.textureFadeFactor,i=t<1?e.nextTextureReference:null;this._configuration.textureFadingEnabled&&i&&t<1?(n.setUniform1f("fadeFactor",t),n.setUniform4fv("nextTexOffsetAndScale",i.offsetAndScale),n.setUniform3fv("nextTexOpacities",i.opacities),n.bindTexture("texNext",i.texture.texture)):n.setUniform1f("fadeFactor",1),e.textureIsFading&&this.setNeedsRender(),n.setUniform3fv("textureOpacities",s.opacities)}this._renderPatch(i,t,r,c,a),r.renderOrder=this._numTilesRendered,this._numTilesRendered++}}}i.bindVAO(null)}_renderPatch(e,t,i,r,s,n=!1){const a=i.renderData,o=a.vao,l=o?.indexBuffer;if(!o||null==l)return void(R&&console.error("Rendered tile with no indices: ",i.lij," : ",a));const c=t.program;n||this._overlayRenderer.isEmpty||this._bindOverlayPatchData(c,a.overlay),s&&(t.useStencil=this._useStencilForTile(i),e.setPipelineState(t.getPipeline()));const d=a.geometry.indexCount;e.bindVAO(o),c.assertCompatibleVertexAttributeLocations(o),e.drawElements(r,d,l.indexType,0)}_bindOverlayPatchData(e,t){e.setUniform4fv("overlayTexOffset",t.offsets),e.setUniform4fv("overlayTexScale",t.scales)}_acquireTechnique(e){return this._configuration.output=e,this._techniques.get(V,this._configuration)}get test(){}hasHighlight(e){return this._overlayRenderer.hasHighlight(e)}};e([o({readOnly:!0})],J.prototype,"_isGlobal",null),e([o()],J.prototype,"renderOccludedFlags",void 0),e([o({value:!1})],J.prototype,"renderingDisabled",null),e([o({value:!0})],J.prototype,"visible",null),e([o()],J.prototype,"renderPatchBorders",null),e([o()],J.prototype,"visualizeNormals",null),e([o()],J.prototype,"cullBackFaces",null),e([o({value:1})],J.prototype,"renderOrder",null),e([o()],J.prototype,"wireframe",null),J=e([l("esri.views.3d.terrain.TerrainRenderer")],J);const K=_(),X=_(),$=_(),ee=_();export{J as TerrainRenderer};
|
|
5
|
+
import{__decorate as e}from"tslib";import t from"../../../Color.js";import has from"../../../core/has.js";import{disposeMaybe as i}from"../../../core/maybe.js";import{MemCachePool as r}from"../../../core/MemCachePool.js";import s from"../../../core/ObjectPool.js";import{watch as n,sync as a}from"../../../core/reactiveUtils.js";import{property as o}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as l}from"../../../core/accessorSupport/decorators/subclass.js";import{d as c,i as d,e as h}from"../../../chunks/vec32.js";import{ZEROS as u,create as _,fromValues as g}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{fromValues as p,ZEROS as f}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{create as m,set as y}from"../../../geometry/support/aaBoundingBox.js";import{BufferViewVec3f as b}from"../../../geometry/support/buffer/BufferView.js";import{overlayRenderOccludedFlag as x}from"./OverlayRenderer.js";import{PatchRenderData as T}from"./PatchRenderData.js";import{TerrainAttributesCache as v}from"./TerrainAttributesCache.js";import{enableTerrainInternalChecks as R}from"./terrainUtils.js";import{TileRenderer as O}from"./TileRenderer.js";import{IteratorPreorder as P,sortTiles as w,compareTiles as S}from"./tileUtils.js";import{componentMinimalSizeForIntersectionData as D,ComponentIntersectionData as B}from"../webgl-engine/collections/Component/ComponentIntersectionData.js";import{getOverlayContentForOutputTerrain as C}from"../webgl-engine/core/shaderLibrary/terrain/Overlay.glsl.js";import{SyncRenderPlugin as j,ConsumesDepth as E,ConsumesNone as q}from"../webgl-engine/effects/RenderPlugin.js";import{Vertices as F}from"../webgl-engine/lib/Attribute.js";import{IntersectorResult as k}from"../webgl-engine/lib/IntersectorResult.js";import{intersectAabbInvDirBefore as A,MeshIntersectionOptions as M,intersectTriangles as N}from"../webgl-engine/lib/RayIntersections.js";import{getSettings as G}from"../webgl-engine/lib/screenSizePerspectiveUtils.js";import{terrainId as z,getVerticalOffsetTerrain as U}from"../webgl-engine/lib/verticalOffsetUtils.js";import{DrawParameters as I}from"../webgl-engine/materials/DrawParameters.js";import{T as L}from"../../../chunks/Terrain.glsl.js";import{TerrainTechnique as V}from"../webgl-engine/shaders/TerrainTechnique.js";import{TerrainTechniqueConfiguration as H}from"../webgl-engine/shaders/TerrainTechniqueConfiguration.js";import{PrimitiveType as W}from"../../webgl/enums.js";const Y=7,Q=10,Z=m();let J=class extends j{get _isGlobal(){return 1===this._stage.viewingMode}get _techniques(){return this._context.techniques}get _rctx(){return this._context.renderContext.rctx}constructor(e,t,i,n,a,o){super({}),this._overlayRenderer=e,this._stage=t,this._allTiles=i,this._ellipsoidRadius=n,this._compressionTracker=a,this.type=2,this.isGround=!0,this._passParameters=new L,this._drawParameters=new I,this._renderDataPool=new s(T),this._visiblePatchesByOrigin=new Map,this._allPatchesByOrigin=new Map,this._patchesByOriginDirty=!0,this._patchSortingDirty=!0,this._tileIterator=new P,this._castShadows=!1,this._inViewshed=!1,this._tileRenderer=null,this._stencilEnabledLayerExtents=new Array,this._numTilesRendered=0,this._numTilesCulled=0,this._numOriginsRendered=0,this.renderOccludedFlags=1,this.produces=new Map([[1,()=>this._produces()&&0===this.transparency],[6,()=>this._produces()&&(1===this.transparency||2===this.transparency)],[8,()=>this._produces()&&this.renderOccludedFlags===x]]),this._tileSize=256,this._configuration=new H(1===t.viewingMode),this._tileTextureCache=new r((e,t)=>o.newCache(e,t),"TileTexture"),this.tileGeometryCache=new v(o)}normalizeCtorArgs(){return{}}initialize(){this._stage.addRenderPlugin(this),this.addHandles(n(()=>this._overlayRenderer.renderOccludedFlags,e=>{this.renderOccludedFlags=e,this.setNeedsRender()},a))}destroy(){this._stage.removeRenderPlugin(this),this._tileTextureCache.destroy(),this.tileGeometryCache.destroy(),this._allTiles.prune(),this._tileRenderer=null}_produces(){return this.visible&&!!this._rootTiles&&!this.renderingDisabled}consumes(){return this._overlayRenderer.hasWater?E:q}set renderingDisabled(e){this._set("renderingDisabled",!!e),this.setDirty()}set visible(e){this._set("visible",!!e),this.setDirty()}updateHeading(e){this._tileRenderer?.updateHeading(e)}set transparency(e){this._configuration.transparencyMode!==e&&(this._configuration.transparencyMode=e,this.setNeedsRender())}get transparency(){return this._configuration.transparencyMode}get renderPatchBorders(){return this._configuration.tileBorders}set renderPatchBorders(e){this._configuration.tileBorders!==e&&(this._configuration.tileBorders=e,this.setNeedsRender(),this.notifyChange("renderPatchBorders"))}get visualizeNormals(){return this._configuration.visualizeNormals}set visualizeNormals(e){this._configuration.visualizeNormals!==e&&(this._configuration.visualizeNormals=e,this.setNeedsRender(),this.notifyChange("visualizeNormals"))}get cullBackFaces(){return this._configuration.backfaceCullingEnabled}set cullBackFaces(e){this._configuration.backfaceCullingEnabled!==e&&(this._configuration.backfaceCullingEnabled=e,this.notifyChange("cullBackFaces"),this.setNeedsRender())}set renderOrder(e){this._set("renderOrder",e),this._setSortingDirty()}get layerViewUid(){return z}get slicePlaneEnabled(){return this._configuration.hasSlicePlane}set slicePlaneEnabled(e){this._configuration.hasSlicePlane!==e&&(this._configuration.hasSlicePlane=e,this.setNeedsRender())}set textureFadingEnabled(e){this._configuration.textureFadingEnabled!==e&&(this._configuration.textureFadingEnabled=e,this.setNeedsRender())}set pbrMode(e){this._configuration.pbrMode!==e&&(this._configuration.pbrMode=e,this.setNeedsRender())}setDebugScreenSizePerspective(e){this._configuration.screenSizePerspective!==e&&(this._configuration.screenSizePerspective=e,this.setNeedsRender())}setRootTiles(e){this._rootTiles=e,this.setDirty()}setStencilEnabledLayerExtents(e){this._stencilEnabledLayerExtents=e,this._setSortingDirty()}set tileSize(e){this._tileSize=e,null!=this._tileRenderer&&(this._tileRenderer.tileSize=e),this.setDirty()}get tileSize(){return this._tileSize}_ensureRenderData(e){e.renderData||(e.renderData=this._renderDataPool.acquire(),e.renderData.init(e,this._getLocalOriginOfTile(e)))}loadTile(e){this._ensureRenderData(e),this.updateTileGeometryState(e),this.reuseTextureFromParent(e)||this.updateTileTexture(e,32)}reuseTextureFromParent(e){const t=e.parent;if(!t)return!1;const i=p(1&e.lij[2]?.5:0,1&e.lij[1]?0:.5,.5,.5);return t.renderData?.reuseTexture(e.renderData,i)??!1}updateTileTexture(e,t){null!=this._tileRenderer&&(this._tileRenderer.updateTileTexture(e,32===t?0:2),this.setNeedsRender(),e.resetPendingUpdate(t))}updateTileGeometryState(e){for(const i of e.layerInfo[0])i.pendingUpdates&=-9;e.resetPendingUpdate(8);const t=e.renderData.updateGeometryState();return t&&this.setDirty(),t}updateGeometryIfNeeded(e){e.loaded&&e.renderData.updateGeometryIfNeeded(this._rctx)}unloadTile(e){const t=e.renderData;t&&(t.releaseGeometry(),this._renderDataPool.release(t),t.clear(),e.renderData=null,e.setMemoryDirty(),this.setDirty())}_getLocalOriginOfTile(e){const t=Q-Y,i=Math.max(0,Math.floor((e.level-t)/Y)*Y);if(this._isGlobal&&0===i)return u;for(;e.parent&&e.level>i;)e=e.parent;return e.centerAtSeaLevel}getStats(){return{numTilesRendered:this._numTilesRendered,numTilesCulled:this._numTilesCulled,numOriginsRendered:this._numOriginsRendered}}set wireframe(e){this._get("wireframe")!==e&&(this._set("wireframe",e),this.setNeedsRender())}setDirty(e=1){this._patchesByOriginDirty=!0,this._context.requestRender(e)}_setSortingDirty(e=1){this._patchSortingDirty=!0,this._context.requestRender(e)}setNeedsRender(e=1){this._context.requestRender(e)}initializeRenderContext(e){this._context=e,this._tileRenderer=new O(this._rctx,this._tileSize,this._techniques,this._tileTextureCache,this._compressionTracker),this.updateTileBackground()}uninitializeRenderContext(){this._tileRenderer=i(this._tileRenderer)}intersect(e,t,i,r){if(!this._rootTiles||e.options.selectOpaqueTerrainOnly&&e.options.selectionMode&&0!==this.transparency)return;const s=K,n=X;c(s,r,i),d(n,1/s[0],1/s[1],1/s[2]);const a=e.results.min,o=e.results.max,l=e.results.ground,u=0===e.options.store,_=!!e.results.ground.target,g=U(e.verticalOffset),p=e.tolerance;let f,m=u&&null!=a.distance?a.distance:1/0;const x=e.options,T=x.normalRequired||!x.backfacesTerrain,v=new M(!1,T),R=d=>{const _=d.renderData;if(!_?.vao)return;const R=_.geometry;y(Z,R.boundingBox);const O=_.localOrigin;null!=g&&(g.localOrigin=O,g.applyToAabb(Z));const P=Z;if($[0]=i[0]-O[0],$[1]=i[1]-O[1],$[2]=i[2]-O[2],!A(P,$,n,p,m))return;const w=(e,t,i)=>{e.set(this.type,d,t,i),m=u&&null!=a.distance?a.distance:1/0},S=(n,c,d)=>{if((!T||null!=d)&&n>=0&&(x.backfacesTerrain||h(d,s)<0)&&(x.invisibleTerrain||!x.selectionMode||null==t||t(i,r,n))){if((null==l.distance||n<l.distance)&&w(l,n,d),x.isFiltered)return;2===x.store&&(null==f?(f=new k(e.ray),w(f,n,d),e.results.all.push(f)):n<f.distance&&w(f,n,d)),(null==a.distance||n<a.distance)&&w(a,n,d),0!==x.store&&(null==o.distance||n>o.distance)&&w(o,n,d)}},C=ee;c(C,r,O);const{indices:j,indexCount:E}=R,q=R.vertexAttributes,M=q.getField("position",b),G=new F(M.typedBuffer,3,q.stride/4),z=E/3;if(!g&&z>D){const e=d.renderData;null==e.intersectionData&&(e.intersectionData=new B(j,0,z,G)),e.intersectionData.intersectRay($,C,v,S)}else N($,C,0,z,j,G,g,v,S)},O=this._rootTiles;if(null!=O){(()=>{const t=this._tileIterator;t.reset(O);const r=e.options.invisibleTerrain;for(let e=t.next();e;e=t.next())!(e.visible||r&&e.intersectsClippingArea)||null==g&&!e.intersectsRay(i,s,p,m)||_&&this._useStencilForTile(e)?t.skipSubtree():R(e)})()}}processScaleRangeQueries(e,t){if(!t.done&&e)for(this._updatePatchGroups();e.updating&&!t.done;){e.prepare();for(const t of this._visiblePatchesByOrigin.values())for(const i of t)null!=i.renderData?.textureReference&&e.queriesForTile(i);e.process(),t.madeProgress()}}acquireTechniques(e){const t=!!has("enable-feature:terrain-shadows")&&e.bind.shadowMap.enabled;t!==this._castShadows&&(this._castShadows=t,this._patchesByOriginDirty=!0);const i=e.bind.viewshedEnabled;if(this._inViewshed!==i&&(this._inViewshed=i,this._patchesByOriginDirty=!0),8===e.bind.slot){if(0===(e.renderOccludedMask&x))return null}else{const t=0===this.transparency?1:6;if(e.bind.slot!==t)return null}if(3===this.transparency)return null;const r=this._configuration;switch(r.screenSpaceReflections=r.cloudReflections=r.receiveShadows=r.receiveAmbientOcclusion=r.renderOccluded=r.hasHighlightMixTexture=!1,r.overlayMode=this._overlayRenderer.mode,e.output){case 0:case 1:{r.screenSpaceReflections=null!=e.bind.ssr.lastFrameColor,r.cloudReflections=null!=e.bind.clouds.data;const t=8===e.bind.slot;return r.receiveShadows=e.bind.shadowMap.ready&&!t,r.renderOccluded=t,r.receiveAmbientOcclusion=!t&&null!=e.bind.ssao,this._acquireTechnique(e.output)}case 4:case 6:return this._castShadows?this._acquireTechnique(4):null;case 7:return this._inViewshed?this._acquireTechnique(7):null;case 2:case 3:return this._acquireTechnique(e.output);case 9:return this._acquireTechnique(9);case 8:return r.hasHighlightMixTexture=null!=e.bind.highlightMixTexture,this._overlayRenderer.hasHighlights?this._acquireTechnique(8):null}return null}render(e,t){switch(this._updatePatchGroups(),t.useStencil=!1,this._passParameters.overlayContent=C(e.output,e.bind),e.output){case 0:case 1:this._renderMaterialPass(e,t);break;case 2:case 3:case 9:this._renderAuxiliaryPass(e,t,this._visiblePatchesByOrigin);break;case 8:{const i=e.bind.highlight?.name;i&&this._overlayRenderer.hasHighlights&&this._overlayRenderer.renders(2)&&this._overlayRenderer.hasHighlight(i)&&this._renderAuxiliaryPass(e,t,this._visiblePatchesByOrigin);break}case 4:case 6:case 7:this._renderAuxiliaryPass(e,t,this._allPatchesByOrigin)}}updateTileBackground(e){if(null==this._tileRenderer)return;const i=this._tileRenderer;let r;if(null!=e){const i=t.toUnitRGBA(e);r=g(i[0]||0,i[1]||0,i[2]||0)}i.setBackground(r),this._allTiles.forAll(e=>i.updateTileTexture(e,0)),this._configuration.tileBlendInput=i.backgroundIsGrid?2:null!=i.backgroundColor?1:0,this.setNeedsRender()}_updatePatchGroups(){if(this._patchesByOriginDirty&&(this._rebuildPatchGroups(),this._patchesByOriginDirty=!1,this._patchSortingDirty=!0),this._patchSortingDirty&&0!==this.renderOrder){const e=Array.from(this._visiblePatchesByOrigin.values()),t=this._stencilEnabledLayerExtents;for(const i of e)w(this.renderOrder,i,t);e.sort((e,t)=>S(e[0],t[0],this.renderOrder)),this._visiblePatchesByOrigin=new Map(e.map(e=>[e[0].renderData.localOrigin,e])),this._patchSortingDirty=!1}}_rebuildPatchGroups(){const e=this._rootTiles;if(null!=e){e[0]?.surface.checkAllTilesWaterproofness(),this._visiblePatchesByOrigin.clear(),this._allPatchesByOrigin.clear();for(const t of e)this._rebuildPatchGroupsForRootTile(t)}}_rebuildPatchGroupsForRootTile(e){const t=this._tileIterator;for(t.resetOne(e);!t.done;){const e=t.next(),i=e.renderData;if(!i){this._numTilesCulled++;continue}const r=i.localOrigin;if(this._castShadows||this._inViewshed){let t=this._allPatchesByOrigin.get(r);t||(t=[],this._allPatchesByOrigin.set(r,t)),t.push(e)}if(!e.visible){this._numTilesCulled++,t.skipSubtree();continue}let s=this._visiblePatchesByOrigin.get(r);s||(s=[],this._visiblePatchesByOrigin.set(r,s)),s.push(e),t.skipSubtree()}}_useStencilForTile(e){for(const t of this._stencilEnabledLayerExtents)if(e.intersectsExtent(t))return!0;return!1}_renderAuxiliaryPass(e,t,i){const{rctx:r,bind:s}=e;r.bindTechnique(t,s,this._passParameters);const n=this._stencilEnabledLayerExtents.length>0;i.forEach(e=>{this._drawParameters.origin=e[0].renderData.localOrigin,t.program.bindDraw(s,this._passParameters,this._drawParameters);for(let i=0;i<e.length;i++)this._renderPatch(r,t,e[i],W.TRIANGLES,n,null===this._passParameters.overlayContent)}),r.bindVAO(null)}_renderMaterialPass(e,t){const{rctx:i,bind:r}=e;i.bindTechnique(t,r,this._passParameters),this._numTilesRendered=0,this._numTilesCulled=0,this._numOriginsRendered=0;const s=r.camera,n=t.program;if(this._configuration.screenSizePerspective&&this.pointsOfInterest){const e=G(this._stage.viewingMode,this._ellipsoidRadius),t=this.pointsOfInterest.centerOnSurfaceFrequent.distance;e.update({distance:t,fovY:s.fovY})}const a=this._stencilEnabledLayerExtents.length>0,o=8===r.slot;o&&(n.bindTexture("tex",i.emptyTexture),n.setUniform3fv("textureOpacities",u),n.setUniform4fv("texOffsetAndScale",f));const l=null!=this._tileRenderer?.backgroundColor?this._tileRenderer.backgroundColor:u;1===this._configuration.tileBlendInput&&n.setUniform3fv("backgroundColor",l);const c=this.wireframe?W.LINES:W.TRIANGLES;this._configuration.textureFadingEnabled&&n.bindTexture("texNext",i.emptyTexture);const d=this._visiblePatchesByOrigin;for(const h of d.values()){const e=h[0].renderData.localOrigin;this._drawParameters.origin=e,t.program.bindDraw(r,this._passParameters,this._drawParameters),this._numOriginsRendered++;for(const r of h){const e=r.renderData,s=e.textureReference;if(null!=s){if(!o){n.setUniform4fv("texOffsetAndScale",s.offsetAndScale),n.bindTexture("tex",s.texture.texture);const t=e.textureFadeFactor,i=t<1?e.nextTextureReference:null;this._configuration.textureFadingEnabled&&i&&t<1?(n.setUniform1f("fadeFactor",t),n.setUniform4fv("nextTexOffsetAndScale",i.offsetAndScale),n.setUniform3fv("nextTexOpacities",i.opacities),n.bindTexture("texNext",i.texture.texture)):n.setUniform1f("fadeFactor",1),e.textureIsFading&&this.setNeedsRender(),n.setUniform3fv("textureOpacities",s.opacities)}this._renderPatch(i,t,r,c,a),r.renderOrder=this._numTilesRendered,this._numTilesRendered++}}}i.bindVAO(null)}_renderPatch(e,t,i,r,s,n=!1){const a=i.renderData,o=a.vao,l=o?.indexBuffer;if(!o||null==l)return void(R&&console.error("Rendered tile with no indices: ",i.lij," : ",a));const c=t.program;n||this._overlayRenderer.isEmpty||this._bindOverlayPatchData(c,a.overlay),s&&(t.useStencil=this._useStencilForTile(i),e.setPipelineState(t.getPipeline()));const d=a.geometry.indexCount;e.bindVAO(o),c.assertCompatibleVertexAttributeLocations(o),e.drawElements(r,d,l.indexType,0)}_bindOverlayPatchData(e,t){e.setUniform4fv("overlayTexOffset",t.offsets),e.setUniform4fv("overlayTexScale",t.scales)}_acquireTechnique(e){return this._configuration.output=e,this._techniques.get(V,this._configuration)}get test(){}hasHighlight(e){return this._overlayRenderer.hasHighlight(e)}};e([o({readOnly:!0})],J.prototype,"_isGlobal",null),e([o()],J.prototype,"renderOccludedFlags",void 0),e([o({value:!1})],J.prototype,"renderingDisabled",null),e([o({value:!0})],J.prototype,"visible",null),e([o()],J.prototype,"renderPatchBorders",null),e([o()],J.prototype,"visualizeNormals",null),e([o()],J.prototype,"cullBackFaces",null),e([o({value:1})],J.prototype,"renderOrder",null),e([o()],J.prototype,"wireframe",null),J=e([l("esri.views.3d.terrain.TerrainRenderer")],J);const K=_(),X=_(),$=_(),ee=_();export{J as TerrainRenderer};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as e}from"tslib";import{parameter as o,ShaderTechniqueConfiguration as r}from"../core/shaderTechnique/ShaderTechniqueConfiguration.js";class i extends r{constructor(){super(...arguments),this.receiveShadows=!0}}e([o()],i.prototype,"receiveShadows",void 0);export{i as
|
|
5
|
+
import{__decorate as e}from"tslib";import{parameter as o,ShaderTechniqueConfiguration as r}from"../core/shaderTechnique/ShaderTechniqueConfiguration.js";class i extends r{constructor(){super(...arguments),this.receiveShadows=!0}}e([o()],i.prototype,"receiveShadows",void 0);export{i as ReceiveShadowsConfiguration};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/*
|
|
2
|
+
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
|
+
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
|
+
*/
|
|
5
|
+
import{__decorate as e}from"tslib";import i from"../../../core/Accessor.js";import{createTask as t}from"../../../core/asyncUtils.js";import{makeHandle as r,handlesGroup as s}from"../../../core/handleUtils.js";import a from"../../../core/Logger.js";import{getOrCreateMapValue as o}from"../../../core/MapUtils.js";import{throwIfAborted as n}from"../../../core/promiseUtils.js";import{whenOnce as p,watch as d}from"../../../core/reactiveUtils.js";import{addMaybe as c}from"../../../core/SetUtils.js";import{property as h}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/RandomLCG.js";import{subclass as u}from"../../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as l}from"../../../core/support/UpdatingHandles.js";import m from"../../../layers/GraphicsLayer.js";import{isSubtypeSublayer as y,isKnowledgeGraphSublayer as v}from"../../../layers/support/layerUtils.js";import{getDisplayedSymbol as g}from"../../../symbols/support/symbolUtils.js";import{GraphicState as f}from"../../3d/layers/graphics/GraphicState.js";var _;!function(e){e[e.FeatureMove=0]="FeatureMove",e[e.VertexMove=1]="VertexMove"}(_||(_={}));const w=()=>a.getLogger("esri.views.draw.support.ConnectedReshapeManager"),G=Symbol();let L=class extends i{constructor(e){super(e),this.activeOperationType=null,this.providerFactories=[],this.view=null,this._activeProviders=new Set,this._graphics=new Map,this._modifiedFeatures=new Map,this._modifiedGraphicsLayer=new m({listMode:"hide",internal:!0,title:"Connected Reshape Modified Graphics (Internal)"}),this._pendingGraphicsLayer=new m({listMode:"hide",internal:!0,title:"Connected Reshape Pending Graphics (Internal)"}),this._pendingFeatures=new Map,this._updatingHandles=new l}initialize(){this.view.map.addMany([this._modifiedGraphicsLayer,this._pendingGraphicsLayer])}destroy(){this.view.destroyed||this.view.map.removeMany([this._modifiedGraphicsLayer,this._pendingGraphicsLayer]),this._modifiedGraphicsLayer.destroy(),this._pendingGraphicsLayer.destroy(),this._updatingHandles.destroy()}get updating(){return this._updatingHandles.updating||Array.from(this._activeProviders).some(e=>e.updating)}startFeatureMove(e){this.activeOperationType=_.FeatureMove,this._activeProviders.clear();for(const i of this.providerFactories)c(this._activeProviders,i.getFeatureReshapeProvider(e))}startVertexMove(e,i){this.activeOperationType=_.VertexMove,this._activeProviders.clear();for(const t of this.providerFactories)c(this._activeProviders,t.getVertexReshapeProvider(e,i))}finish(){this.activeOperationType=null,this._activeProviders.clear();for(const[e,i]of this._pendingFeatures){this._pendingFeatures.delete(e),this._modifiedFeatures.set(e,i);const t=this._graphics.get(e);t&&(this._modifiedGraphicsLayer.add(t),this._pendingGraphicsLayer.remove(t))}}translate(e,i,t=0){if(null===this.activeOperationType)return;const r=P(e),s=P(i),a=P(t);for(const o of this._activeProviders){const e=o.translate(r,s,a);this._update(e)}}async _initializeGraphic(e,i){e.symbol??=await this._updatingHandles.addPromise(g(e,{scale:this.view.scale,useSourceLayer:!0})),this._pendingFeatures.has(i.uniqueId)?this._pendingGraphicsLayer.add(e):this._modifiedFeatures.has(i.uniqueId)&&this._modifiedGraphicsLayer.add(e),this.addHandles(await F(i.originalGraphic,e,this.view),G)}_update(e){for(const i of e){const e=this._modifiedFeatures.delete(i.uniqueId);this._pendingFeatures.set(i.uniqueId,i);const t=o(this._graphics,i.uniqueId,()=>{const e=i.graphic.cloneShallow();return this._initializeGraphic(e,i),e});t.geometry=i.graphic.geometry,e&&(this._modifiedGraphicsLayer.remove(t),this._pendingGraphicsLayer.add(t))}}get test(){return{activeProviders:this._activeProviders,modifiedFeatures:this._modifiedFeatures,modifiedGraphicsLayer:this._modifiedGraphicsLayer,pendingFeatures:this._pendingFeatures,pendingGraphicsLayer:this._pendingGraphicsLayer}}};async function F(e,i,a){const o=e.sourceLayer,d=e.getObjectId();if(null==d)return w().error("editing:cannot-hide-graphic","Unable to hide original graphic because it has no objectId."),r();let c=null;function h(e){c?.abort(),c=t(async i=>{const t=await b(a,o);n(i),t&&t.setVisibility?.(d,e)})}return await M(a,i),h(!1),s([j(a,i,e=>h(!e)),r(async()=>{h(!0);const e=await b(a,o);await p(()=>!e?.updating)})])}function j(e,i,t){if("3d"===e.type){const r=new f({graphic:i});return s([e.trackGraphicState(r),d(()=>r.displaying,t)])}return d(()=>i.visible,t)}async function M(e,i){if("3d"===e.type){const t=new f({graphic:i}),r=e.trackGraphicState(t);await p(()=>t.displaying||t.error),r.remove()}else await p(()=>i.visible)}async function b(e,i){const t=y(i)||v(i)?i.parent:i;return t?e.whenLayerView(t):null}function P(e){return isNaN(e)?0:e}e([h()],L.prototype,"activeOperationType",void 0),e([h()],L.prototype,"providerFactories",void 0),e([h()],L.prototype,"updating",null),e([h({constructOnly:!0})],L.prototype,"view",void 0),L=e([u("esri.views.draw.support.ConnectedReshapeManager")],L);export{L as ConnectedReshapeManager,_ as ConnectedReshapeOperationType,F as swapForEditingSession,j as watchGraphicVisibility,M 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.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as t}from"tslib";import e from"../../../Graphic.js";import{createTask as i}from"../../../core/asyncUtils.js";import s from"../../../core/Collection.js";import o from"../../../core/Error.js";import r from"../../../core/Evented.js";import n from"../../../core/Logger.js";import{destroyMaybe as h,assertIsSome as a,abortMaybe as p}from"../../../core/maybe.js";import{pausable as c,when as l,watch as d,initial as m,sync as v}from"../../../core/reactiveUtils.js";import{property as y}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/RandomLCG.js";import{subclass as _}from"../../../core/accessorSupport/decorators/subclass.js";import g from"../../../geometry/Point.js";import u from"../../../geometry/Polyline.js";import{closeRingsAndFixWinding as f,getMidpoint as x,geometryToCoordinates as G}from"../../../geometry/support/coordsUtils.js";import b from"../../../layers/GraphicsLayer.js";import M from"../../../symbols/SimpleMarkerSymbol.js";import{SnappingVisualizer2D as V}from"../../2d/interactive/SnappingVisualizer2D.js";import{cloneMove as S}from"./drawUtils.js";import w from"./GraphicMover.js";import E from"./HighlightHelper.js";import{addUniqueLayer as O}from"./layerUtils.js";import{createTooltipInfos as I,connectTooltip as k,updateTranslateTooltipInfo as C,updateTranslateVertexTooltipInfo as T}from"./reshapeTooltipUtils.js";import{settings as H}from"./settings.js";import{ViewEventPriorities as R}from"../../input/InputManager.js";import{createCoordinateHelper as j}from"../../interactive/coordinateHelper.js";import{sketchKeys as A}from"../../interactive/keybindings.js";import{EditGeometryOperations as U}from"../../interactive/editGeometry/EditGeometryOperations.js";import L from"../../interactive/sketch/SketchOptions.js";import{SnappingContext as z}from"../../interactive/snapping/SnappingContext.js";import{makeTooltip as D,enterInputModeIfAvailable as F}from"../../interactive/tooltip/tooltipCommonUtils.js";class P{constructor(t,e,i){this.graphic=t,this.mover=e,this.selected=i,this.type="reshape-start"}}class N{constructor(t,e,i){this.graphic=t,this.mover=e,this.selected=i,this.type="reshape"}}class Z{constructor(t,e,i){this.graphic=t,this.mover=e,this.selected=i,this.type="reshape-stop"}}class X{constructor(t,e,i){this.mover=t,this.dx=e,this.dy=i,this.type="move-start"}}class Y{constructor(t,e,i){this.mover=t,this.dx=e,this.dy=i,this.type="move"}}class K{constructor(t,e,i){this.mover=t,this.dx=e,this.dy=i,this.type="move-stop"}}class q{constructor(t){this.added=t,this.type="vertex-select"}}class B{constructor(t){this.removed=t,this.type="vertex-deselect"}}class J{constructor(t,e,i,s){this.added=t,this.graphic=e,this.oldGraphic=i,this.vertices=s,this.type="vertex-add"}}class Q{constructor(t,e,i,s){this.removed=t,this.graphic=e,this.oldGraphic=i,this.vertices=s,this.type="vertex-remove"}}const W=H.reshapeGraphics,$={vertices:{default:new M({style:"circle",size:W.vertex.size,color:W.vertex.color,outline:{color:W.vertex.outlineColor,width:1}}),hover:new M({style:"circle",size:W.vertex.hoverSize,color:W.vertex.hoverColor,outline:{color:W.vertex.hoverOutlineColor,width:1}}),selected:new M({style:"circle",size:W.selected.size,color:W.selected.color,outline:{color:W.selected.outlineColor,width:1}})},midpoints:{default:new M({style:"circle",size:W.midpoint.size,color:W.midpoint.color,outline:{color:W.midpoint.outlineColor,width:1}}),hover:new M({style:"circle",size:W.midpoint.size,color:W.midpoint.color,outline:{color:W.midpoint.outlineColor,width:1}})}};let tt=class extends r.EventedAccessor{constructor(t){super(t),this._updateHandlesOnExternalGeometryChange=null,this._activeOperationInfo=null,this._editGeometryOperations=null,this._graphicAttributes={esriSketchTool:"box"},this._mover=null,this._snappingContext=null,this._snappingGraphicsLayer=null,this._hoverGraphic=null,this._snappingTask=null,this._stagedVertex=null,this.tooltip=null,this.activeTooltipInfo=null,this.callbacks={onReshapeStart(){},onReshape(){},onReshapeStop(){},onMoveStart(){},onMove(){},onMoveStop(){},onGraphicClick(){}},this.enableMidpoints=!0,this.enableMovement=!0,this.enableVertices=!0,this.graphic=null,this.highlightName=null,this.highlightsEnabled=!0,this.layer=null,this.midpointGraphics=new s,this.midpointSymbol=new M({style:"circle",size:6,color:[200,200,200],outline:{color:[100,100,100],width:1}}),this.selectedVertices=new s,this.snappingManager=null,this.symbols=$,this.sketchOptions=new L,this.type="reshape",this.vertexGraphics=new s,this.view=null}initialize(){const t=this.view;this._highlightHelper=new E({view:t}),this._setup(),this._updateHandlesOnExternalGeometryChange=c(()=>this.graphic?.geometry,t=>{if(!t)return;const e=new Set(this.selectedVertices.map(t=>t.attributes?.pointIndex));this._highlightHelper.removeAll(),this._setUpHighlights(),this._setupGraphics(),this._clearSelection(),this.vertexGraphics.filter(t=>e.has(t.attributes.pointIndex)).forEach(t=>this._addToSelection(t));const{enableMovement:i,_mover:s,graphic:o,midpointGraphics:r,vertexGraphics:n}=this,h=n.concat(r).items;i&&h.push(o),s?.set("graphics",h)},v),this.tooltip=D(()=>({view:t,options:this.sketchOptions.tooltips})),this.tooltipInfos=I(this.sketchOptions),this.addHandles([l(()=>t?.ready,()=>{const{layer:t,view:e}=this;O(e,t),this.addHandles(e.on("key-down",t=>this._keyDownHandler(t),R.TOOL))},{once:!0,initial:!0}),d(()=>this.graphic,()=>this.refresh()),d(()=>this.layer,(t,e)=>{e&&(this._clearSelection(),this._resetGraphics(e)),this.refresh()}),d(()=>[this.highlightsEnabled,this.highlightName],()=>{this._highlightHelper?.removeAll(),this._setUpHighlights()}),d(()=>this.enableMidpoints,()=>this.refresh()),k(this.tooltip,()=>this._tooltipsContext),d(()=>this.view.effectiveTheme.accentColor,()=>this._updateSymbolsForTheme(),m),this._updateHandlesOnExternalGeometryChange]),this._updateTooltip()}destroy(){this._reset(),this._mover?.destroy(),this._mover=null,this.tooltip=h(this.tooltip)}get _coordinateHelper(){return this._editGeometryOperations?.data.coordinateHelper??j(!!this.graphic.geometry?.hasZ,!!this.graphic.geometry?.hasM,this.view.spatialReference)}get _selectedVertex(){return 1===this.selectedVertices.length?this.selectedVertices.at(0):void 0}get _tooltipsContext(){const{automaticAreaMeasurementUtils:t,automaticLengthMeasurementUtils:e,sketchOptions:i,activeTooltipInfo:s,graphic:o}=this;return{sketchOptions:i,activeTooltipInfo:s,graphic:o,selectedVertex:this._selectedVertex,automaticAreaMeasurementUtils:t,automaticLengthMeasurementUtils:e,updateGeometry:(t,e,i,s,o)=>{this._setUpGeometryHelper();const r=t===this.graphic;r?this._emitMoveStartEvent(0,0):this._emitReshapeStartEvent(t);const n=!0;if(this._syncGeometryAfterVertexMove(t,e,s,o,n),r){const{view:t}=this,s=t.toScreen(i),o=t.toScreen(e),r=(o?.x??0)-(s?.x??0),n=(o?.y??0)-(s?.y??0);this._emitMoveEvent(r,n),this._emitMoveStopEvent(r,n)}else this._emitReshapeEvent(t),this._emitReshapeStopEvent(t);this._editGeometryOperations=h(this._editGeometryOperations)}}}get state(){const t=this.view.ready,e=!(!this.graphic||!this.layer);return t&&e?"active":t?"ready":"disabled"}isUIGraphic(t){const e=[];return this.graphic&&e.push(this.graphic),e.concat(this.vertexGraphics.items,this.midpointGraphics.items),e.length>0&&e.includes(t)}refresh(){this._reset(),this._setup()}reset(){this.graphic=null}clearSelection(){this._clearSelection()}removeSelectedVertices(){const{selectedVertices:t}=this;t.length&&this._removeVertices(t)}_setup(){const{graphic:t,layer:e}=this;if(!e||null==t?.geometry)return;const i=t.geometry;"mesh"!==i.type&&"extent"!==i.type?("polygon"===i.type&&f(i),this._setUpHighlights(),this._setupGraphics(),this._setupMover()):this._logGeometryTypeError()}_setUpHighlights(){this.highlightsEnabled&&this.graphic&&this._highlightHelper?.add(this.graphic,this.highlightName)}_setUpGeometryHelper(){const t=this.graphic.geometry;if(null==t||"mesh"===t.type||"extent"===t.type)return void this._logGeometryTypeError();const e="multipoint"===t.type?new u({paths:[t.points],spatialReference:t.spatialReference}):t;this._editGeometryOperations=U.fromGeometry(e,2)}_saveSnappingContextForHandle(t,e){this._snappingGraphicsLayer=new b({listMode:"hide",internal:!0,title:"Reshape snapping layer"}),this.view.map.layers.add(this._snappingGraphicsLayer);const i=this._editGeometryOperations;a(i),this._snappingContext=new z({editGeometryOperations:i,elevationInfo:{mode:"on-the-ground",offset:0},pointer:e.viewEvent?.pointerType||"mouse",excludeFeature:this.graphic,feature:this.graphic,visualizer:new V(this._snappingGraphicsLayer),vertexHandle:this._getVertexFromEditGeometry(t)})}_reset(){this._clearSelection(),this._highlightHelper?.removeAll(),this._updateTooltip(),this._resetGraphics(),this._resetSnappingStateVars(),this._activeOperationInfo=null,this._mover&&this._mover.destroy(),this._mover=null,this.view.cursor="default"}_resetSnappingStateVars(){null!=this.snappingManager&&this.snappingManager.doneSnapping(),null!=this._snappingGraphicsLayer&&(this.view?.map&&this.view.map.layers.remove(this._snappingGraphicsLayer),this._snappingGraphicsLayer.destroy()),this._editGeometryOperations=h(this._editGeometryOperations),this._snappingTask=p(this._snappingTask),this._snappingTask=null,this._snappingContext=null,this._stagedVertex=null}_resetGraphics(t){this._removeMidpointGraphics(t),this._removeVertexGraphics(t),this.selectedVertices.removeAll(),this._updateTooltip()}_removeMidpointGraphics(t){const e=t||this.layer;e&&e.removeMany(this.midpointGraphics.items),this.midpointGraphics.items.forEach(t=>t.destroy()),this.midpointGraphics.removeAll()}_removeVertexGraphics(t){const e=t||this.layer;e&&e.removeMany(this.vertexGraphics.items),this.vertexGraphics.items.forEach(t=>t.destroy()),this.vertexGraphics.removeAll()}_setupGraphics(){const t=this.graphic.geometry;if(null!=t&&("polyline"===t.type||"polygon"===t.type)){const e=et(t);this.enableMidpoints&&this._setUpMidpointGraphics(e),this.enableVertices&&this._setUpVertexGraphics(e)}}_setUpMidpointGraphics(t){this._removeMidpointGraphics();const e=this._createMidpointGraphics(t);this.midpointGraphics.addMany(e),this.layer.addMany(e)}_setUpVertexGraphics(t){this._removeVertexGraphics();const e=this._createVertexGraphics(t);this.vertexGraphics.addMany(e),this._storeRelatedVertexIndices(),this.layer.addMany(e)}_createVertexGraphics(t){const{_graphicAttributes:i,symbols:s}=this,o=[];return t?.forEach((t,r)=>{t.forEach((t,n)=>{o.push(new e({geometry:this._coordinateHelper.arrayToPoint(t),symbol:s?.vertices?.default,attributes:{...i,pathIndex:r,pointIndex:n}}))})}),o}_createMidpointGraphics(t){const{_graphicAttributes:i,symbols:s}=this,o=[];for(let r=0;r<t.length;r++){const n=t[r];for(let t=0;t<n.length;t++){const h=(t+1)%n.length;if("polyline"===this.graphic.geometry?.type&&0===h)continue;const a=n[t],p=n[h],c=this._getMidpoint(a,p);o.push(new e({geometry:c,symbol:s.midpoints.default,attributes:{...i,pathIndex:r,pointIndexStart:t,pointIndexEnd:h}}))}}return o}_updateSymbolsForTheme(){const t=this.view.effectiveTheme.accentColor;this.symbols={vertices:{...this.symbols.vertices,default:this.symbols.vertices.default.clone().set("color",t),hover:this.symbols.vertices.hover?.clone().set("color",t)},midpoints:{...this.symbols.midpoints}};for(const e of this.vertexGraphics)this._isSelected(e)?e.symbol=this.symbols.vertices.selected:this._hoverGraphic===e?e.symbol=this.symbols.vertices.hover:e.symbol=this.symbols.vertices.default}_storeRelatedVertexIndices(){const t=this.vertexGraphics.items;if(!t)return;const e=t.map(({geometry:t})=>({x:t.x,y:t.y}));for(let i=0;i<e.length;i++){const s=[];for(let t=0;t<e.length;t++){if(i===t)continue;const o=e[i],r=e[t];o.x===r.x&&o.y===r.y&&s.push(t)}t[i].attributes.relatedGraphicIndices=s}}_setupMover(){const{enableMovement:t,graphic:e,midpointGraphics:i,vertexGraphics:s,view:o}=this,r=s.concat(i).items;t&&r.push(e),this._mover=new w({enableMoveAllGraphics:!1,highlightsEnabled:!1,indicatorsEnabled:!1,graphics:r,view:o,callbacks:{onGraphicClick:t=>this._onGraphicClickCallback(t),onGraphicMoveStart:t=>this._onGraphicMoveStartCallback(t),onGraphicMove:t=>this._onGraphicMoveCallback(t),onGraphicMoveStop:t=>this._onGraphicMoveStopCallback(t),onGraphicPointerOver:t=>this._onGraphicPointerOverCallback(t),onGraphicPointerOut:t=>this._onGraphicPointerOutCallback(t)}})}_onGraphicClickCallback(t){t.viewEvent.stopPropagation();const e=t.graphic;if(e===this.graphic)this.clearSelection(),this.emit("graphic-click",t),this.callbacks.onGraphicClick?.(t);else if(this._isMidpoint(e)){if(2===t.viewEvent.button)return;const i=this.graphic.clone(),s=this._createVertexFromMidpoint(e);this.refresh(),this._emitVertexAddEvent([e],i,s)}else if(this._isVertex(e))if(t.viewEvent.stopPropagation(),2===t.viewEvent.button)this._removeVertices(e);else{t.viewEvent.native.shiftKey||this._clearSelection(),this.selectedVertices.includes(e)?this._removeFromSelection(e,!0):this._addToSelection(e)}}_setUpOperation(t){const{graphic:e,dx:i,dy:s}=t,o=e===this.graphic;this._resetSnappingStateVars(),this._setUpGeometryHelper(),this._saveSnappingContextForHandle(e,t),this._activeOperationInfo={target:this.graphic,mover:e,operationType:o?"move":"reshape",totalDx:i,totalDy:s}}_onGraphicMoveStartCallback(t){const{dx:e,dy:i,graphic:s}=t;if(s===this.graphic){const{geometry:o}=s;return this._setUpOperation(t),this._emitMoveStartEvent(e,i),void(null!=o&&"point"===o.type&&this._onHandleMove(s,e,i,t,()=>{this._updateTooltip(this.graphic,t.viewEvent),this._emitMoveEvent(e,i)}))}if(!this.selectedVertices.includes(s)){if(this._clearSelection(),this._isMidpoint(s)){const t=this.graphic.clone(),e=this._createVertexFromMidpoint(s);this._emitVertexAddEvent([s],t,e)}this._addToSelection(s)}this._setUpOperation(t),this._emitReshapeStartEvent(s),this._onHandleMove(s,e,i,t,()=>{this._updateTooltip(s,t.viewEvent),this._emitReshapeEvent(s)})}_onGraphicMoveCallback(t){const e=this._activeOperationInfo;if(!e)return;const{dx:i,dy:s,graphic:o}=t;e.totalDx+=i,e.totalDy+=s;const{operationType:r}=e,{geometry:n}=o;if(null!=n)if("move"!==r)this._onHandleMove(o,i,s,t,()=>{this._updateTooltip(o,t.viewEvent),this._emitReshapeEvent(o)});else if("point"===n.type)this._onHandleMove(o,i,s,t,()=>{this._updateTooltip(this.graphic,t.viewEvent),this._emitMoveEvent(i,s)});else if("polyline"===n.type||"polygon"===n.type){const e=et(n);this._updateVertexGraphicLocations(e),this._updateTooltip(this.graphic,t.viewEvent),this._emitMoveEvent(i,s)}}_onGraphicMoveStopCallback(t){const e=this._activeOperationInfo;if(!e)return;const{dx:i,dy:s,graphic:o}=t,{operationType:r}=e;e.totalDx+=i,e.totalDy+=s,this._onHandleMove(o,i,s,t,()=>"move"===r?this._emitMoveStopEvent():this._emitReshapeStopEvent(o)),this._isMidpoint(o)?this.refresh():(this._updateTooltip(this._isVertex(o)?o:null),this._resetSnappingStateVars(),this._activeOperationInfo=null)}_updateVertexGraphicLocations(t){const{_coordinateHelper:e}=this;for(const i of this.vertexGraphics){const{pathIndex:s,pointIndex:o}=i.attributes;i.geometry=e.arrayToPoint(t[s][o])}this._updateMidpointGraphicLocations(t)}_updateMidpointGraphicLocations(t){for(const e of this.midpointGraphics){const{pathIndex:i,pointIndexStart:s,pointIndexEnd:o}=e.attributes,r=t[i];e.geometry=this._getMidpoint(r[s],r[o])}}_getMidpoint(t,e){const{_coordinateHelper:i}=this,s=i.arrayToVector(t),o=i.arrayToVector(e),r=i.toXYZ(s),n=i.toXYZ(o),[h,a,p]=x(r,n),c=i.hasM()?0:void 0;return new g({x:h,y:a,z:p,m:c,spatialReference:i.spatialReference})}_getVertexFromEditGeometry(t){const[e,i]=it(t);return a(this._editGeometryOperations),this._editGeometryOperations.data.components[e].vertices[i]}_onHandleMove(t,e,s,o,r){p(this._snappingTask);const n=this._snappingContext;if(!n)return;const h=t.geometry,a="graphic-move-stop"===o.type;if(null!=this.snappingManager&&this.selectedVertices.length<2&&!a){const o=this.snappingManager;this._stagedVertex=o.update({point:h,context:n}),this._syncGeometryAfterVertexMove(t,new g(this._stagedVertex),e,s,a),r(),this._snappingTask=i(async i=>{const p=await o.snap({point:h,context:n,signal:i});p.valid&&(this._stagedVertex=p.apply(),this._syncGeometryAfterVertexMove(t,new g(this._stagedVertex),e,s,a),r())})}else{const i=null!=this._stagedVertex?new g(this._stagedVertex):h;this._syncGeometryAfterVertexMove(t,i,e,s,a),r()}}_syncGeometryAfterVertexMove(t,e,i,s,o=!1){const r=this._editGeometryOperations?.data.geometry;if(r)if("point"===r.type)t.geometry=e;else if("mesh"===r.type)t.geometry=r.centerAt(e);else{const{_coordinateHelper:n}=this,[h,a]=it(t);let p=G(r);const c=p[h].length-1,l=n.pointToArray(e);p[h][a]=l,"polygon"===r.type&&(0===a?p[h][c]=l:a===c&&(p[h][0]=l)),this._isVertex(t)&&(p=this._moveRelatedCoordinates(p,t,l),p=this._moveSelectedHandleCoordinates(p,t,i,s,"polygon"===r.type),this._updateMidpointGraphicLocations(p)),this._updateGraphicGeometry(r.clone());const d=n.pointToVector(e),m=this._getVertexFromEditGeometry(t),v=n.getZ(d),y=d[0]-m.pos[0],_=d[1]-m.pos[1],g=null!=v?v-m.pos[2]:0;this._editGeometryOperations?.moveVertices([m],y,_,g),o&&(this._mover?this._mover.updateGeometry(this._mover.graphics.indexOf(t),e):t.geometry=e)}}_moveRelatedCoordinates(t,e,i){const{relatedGraphicIndices:s}=e.attributes;for(const o of s){const s=this.vertexGraphics.at(o),{pathIndex:r,pointIndex:n}=s.attributes;t[r][n]=i,s.geometry=e.geometry}return t}_moveSelectedHandleCoordinates(t,e,i,s,o){for(const r of this.selectedVertices)if(r!==e){const{pathIndex:e,pointIndex:n,relatedGraphicIndices:h}=r.attributes,a=S(r.geometry,i,s,this.view),p=G(a),c=t[e].length-1;t[e][n]=p,r.geometry=a,o&&(0===n?t[e][c]=p:n===c&&(t[e][0]=p));for(const i of h){const e=this.vertexGraphics.at(i),{pathIndex:s,pointIndex:o}=e.attributes;t[s][o]=p,e.geometry=a}}return t}_onGraphicPointerOverCallback(t){const e=t.graphic;this._hoverGraphic=e;const i=this._isVertex(e);i&&!this._isSelected(e)&&(e.symbol=this.symbols.vertices.hover),this._updateTooltip(i?e:null),this._updateHoverCursor(e)}_onGraphicPointerOutCallback(t){const e=t.graphic;this._hoverGraphic=null,this._isVertex(e)&&!this._isSelected(e)&&(e.symbol=this.symbols.vertices.default),this.view.cursor="default",this._updateTooltip()}_createVertexFromMidpoint(t){const{_graphicAttributes:e,graphic:i}=this,s=i.geometry;if(null==s||"polygon"!==s.type&&"polyline"!==s.type)return[];const o=s.clone(),r=[],{pathIndex:n,pointIndexStart:h,pointIndexEnd:a}=t.attributes,p=G(t.geometry),c=0===a?h+1:a,l=G(o);return l[n].splice(c,0,p),t.attributes={...e,pathIndex:n,pointIndex:c,relatedGraphicIndices:[]},r.push({coordinates:l[n][c],componentIndex:n,vertexIndex:c}),this._updateGraphicGeometry(o),r}_addToSelection(t){const e=st(t);for(const i of e)i.symbol=this.symbols.vertices.selected,this.selectedVertices.add(i),this._updateTooltip(i);this._emitSelectEvent(e)}_removeFromSelection(t,e){const{vertices:i}=this.symbols,s=e?i.hover:i.default;this.selectedVertices.remove(t),t.symbol=s,this._emitDeselectEvent([t]),this._updateTooltip()}_clearSelection(){const t=this.selectedVertices.toArray();if(t.length>0){for(const e of t)e.set("symbol",this.symbols.vertices.default);this.selectedVertices.removeAll(),this._emitDeselectEvent(t),this._updateTooltip()}}_keyDownHandler(t){null==this._activeOperationInfo&&F(t,this.tooltip)||A.delete.includes(t.key)&&!t.repeat&&this.selectedVertices.length&&this._removeVertices(this.selectedVertices)}_removeVertices(t){const e=this.graphic.geometry;if(null==e||"polygon"!==e.type&&"polyline"!==e.type)return;if("polygon"===e.type&&this.vertexGraphics.length<4||this.vertexGraphics.length<3)return;const i=this.graphic.clone(),s=e.clone();let o=G(s);const r=[],n=st(t);for(const h of n){const{x:t,y:e}=h.geometry;for(let i=0;i<o.length;i++){const s=o[i];for(let n=0;n<s.length;n++){const[h,a]=s[n];t===h&&e===a&&(r.push({coordinates:o[i][n],componentIndex:i,vertexIndex:n}),o[i].splice(Number(n),1))}}}if("polygon"===s.type)o=o.filter(t=>{if(t.length<2)return!1;const[e,i]=t[0],[s,o]=t[t.length-1];return(2!==t.length||e!==s||i!==o)&&(e===s&&i===o||t.push(t[0]),!0)}),s.rings=o;else{for(const t of o)1===t.length&&o.splice(o.indexOf(t),1);s.paths=o}this._updateGraphicGeometry(s),this.refresh(),this._emitVertexRemoveEvent(n,i,r)}_isVertex(t){return this.vertexGraphics.includes(t)}_isSelected(t){return this._isVertex(t)&&this.selectedVertices.includes(t)}_isMidpoint(t){return this.midpointGraphics.includes(t)}_updateHoverCursor(t){this.view.cursor=this._isMidpoint(t)?"copy":"move"}_updateTooltip(t,e){let i=null;const{graphic:s,view:o,tooltipInfos:r}=this,n=s?.geometry;"point"===n?.type?i=r.movePoint:this._selectedVertex?i=r.selectedVertex:t===this.graphic?(i=r.translateGraphic,C(i,o,this._tooltipsContext,e)):t&&this.selectedVertices.length>1&&(i=r.translateVertices,T(i,o,n,this._tooltipsContext,e)),this.activeTooltipInfo=i}_updateGraphicGeometry(t){this._updateHandlesOnExternalGeometryChange?.pause(),this.graphic.geometry=t,this._updateHandlesOnExternalGeometryChange?.resume()}_emitMoveStartEvent(t,e){const i=new X(this.graphic,t,e);this.emit("move-start",i),this.callbacks.onMoveStart?.(i)}_emitMoveEvent(t,e){const i=new Y(this.graphic,t,e);this.emit("move",i),this.callbacks.onMove?.(i)}_emitMoveStopEvent(t,e){if(null==t||null==e){const i=this._activeOperationInfo;if(!i)return;t=i.totalDx,e=i.totalDy}const i=new K(this.graphic,t,e);this.emit("move-stop",i),this.callbacks.onMoveStop?.(i)}_emitReshapeStartEvent(t){const e=new P(this.graphic,t,this.selectedVertices.toArray());this.emit("reshape-start",e),this.callbacks.onReshapeStart?.(e)}_emitReshapeEvent(t){const e=new N(this.graphic,t,this.selectedVertices.toArray());this.emit("reshape",e),this.callbacks.onReshape?.(e)}_emitReshapeStopEvent(t){const e=new Z(this.graphic,t,this.selectedVertices.toArray());this.emit("reshape-stop",e),this.callbacks.onReshapeStop?.(e)}_emitSelectEvent(t){const e=new q(t);this.emit("select",e),this.callbacks.onVertexSelect?.(e)}_emitDeselectEvent(t){const e=new B(t);this.emit("deselect",e),this.callbacks.onVertexDeselect?.(e)}_emitVertexAddEvent(t,e,i){const s=new J(t,this.graphic,e,i);this.emit("vertex-add",s),this.callbacks.onVertexAdd?.(s)}_emitVertexRemoveEvent(t,e,i){const s=new Q(t,this.graphic,e,i);this.emit("vertex-remove",s),this.callbacks.onVertexRemove?.(s)}_logGeometryTypeError(){n.getLogger(this).error(new o("reshape:invalid-geometry","Reshape operation not supported for the provided graphic. The geometry type is not supported."))}};function et(t){const e=G(t.clone());if("polygon"===t.type)for(const i of e){const t=i[i.length-1];i[0][0]===t[0]&&i[0][1]===t[1]&&i.length>2&&i.pop()}return e}function it({attributes:t}){return[t?.pathIndex||0,t?.pointIndex||0]}function st(t){return t instanceof e?[t]:[...t]}t([y()],tt.prototype,"_activeOperationInfo",void 0),t([y()],tt.prototype,"_coordinateHelper",null),t([y()],tt.prototype,"_editGeometryOperations",void 0),t([y()],tt.prototype,"tooltip",void 0),t([y()],tt.prototype,"tooltipInfos",void 0),t([y()],tt.prototype,"activeTooltipInfo",void 0),t([y({constructOnly:!0})],tt.prototype,"automaticAreaMeasurementUtils",void 0),t([y({constructOnly:!0})],tt.prototype,"automaticLengthMeasurementUtils",void 0),t([y()],tt.prototype,"_selectedVertex",null),t([y()],tt.prototype,"_tooltipsContext",null),t([y()],tt.prototype,"callbacks",void 0),t([y()],tt.prototype,"enableMidpoints",void 0),t([y()],tt.prototype,"enableMovement",void 0),t([y()],tt.prototype,"enableVertices",void 0),t([y()],tt.prototype,"graphic",void 0),t([y()],tt.prototype,"highlightName",void 0),t([y()],tt.prototype,"highlightsEnabled",void 0),t([y()],tt.prototype,"layer",void 0),t([y({readOnly:!0})],tt.prototype,"midpointGraphics",void 0),t([y()],tt.prototype,"midpointSymbol",void 0),t([y({readOnly:!0})],tt.prototype,"selectedVertices",void 0),t([y()],tt.prototype,"snappingManager",void 0),t([y({readOnly:!0})],tt.prototype,"state",null),t([y()],tt.prototype,"symbols",void 0),t([y({type:L})],tt.prototype,"sketchOptions",void 0),t([y({readOnly:!0})],tt.prototype,"type",void 0),t([y({readOnly:!0})],tt.prototype,"vertexGraphics",void 0),t([y()],tt.prototype,"view",void 0),tt=t([_("esri.views.draw.support.Reshape")],tt);const ot=tt;export{ot as default};
|
|
5
|
+
import{__decorate as e}from"tslib";import t from"../../../Graphic.js";import{createTask as i}from"../../../core/asyncUtils.js";import s from"../../../core/Collection.js";import o from"../../../core/Error.js";import r from"../../../core/Evented.js";import n from"../../../core/Logger.js";import{destroyMaybe as h,assertIsSome as a,abortMaybe as p}from"../../../core/maybe.js";import{pausable as c,when as l,watch as d,initial as m,sync as v}from"../../../core/reactiveUtils.js";import{property as y}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/RandomLCG.js";import{subclass as _}from"../../../core/accessorSupport/decorators/subclass.js";import g from"../../../geometry/Point.js";import u from"../../../geometry/Polyline.js";import{closeRingsAndFixWinding as f,getMidpoint as x,geometryToCoordinates as G}from"../../../geometry/support/coordsUtils.js";import M from"../../../layers/GraphicsLayer.js";import b from"../../../symbols/SimpleMarkerSymbol.js";import{SnappingVisualizer2D as V}from"../../2d/interactive/SnappingVisualizer2D.js";import{ConnectedReshapeManager as w}from"./ConnectedReshapeManager.js";import{cloneMove as S}from"./drawUtils.js";import E from"./GraphicMover.js";import I from"./HighlightHelper.js";import{addUniqueLayer as O,isConnectedReshapeSupportedLayer as C}from"./layerUtils.js";import{createTooltipInfos as k,connectTooltip as T,updateTranslateTooltipInfo as R,updateTranslateVertexTooltipInfo as H}from"./reshapeTooltipUtils.js";import{settings as j}from"./settings.js";import{ViewEventPriorities as A}from"../../input/InputManager.js";import{createCoordinateHelper as U}from"../../interactive/coordinateHelper.js";import{sketchKeys as L}from"../../interactive/keybindings.js";import{EditGeometryOperations as P}from"../../interactive/editGeometry/EditGeometryOperations.js";import z from"../../interactive/sketch/SketchOptions.js";import{SnappingContext as D}from"../../interactive/snapping/SnappingContext.js";import{makeTooltip as F,enterInputModeIfAvailable as N}from"../../interactive/tooltip/tooltipCommonUtils.js";class Z{constructor(e,t,i){this.graphic=e,this.mover=t,this.selected=i,this.type="reshape-start"}}class X{constructor(e,t,i){this.graphic=e,this.mover=t,this.selected=i,this.type="reshape"}}class Y{constructor(e,t,i){this.graphic=e,this.mover=t,this.selected=i,this.type="reshape-stop"}}class K{constructor(e,t,i){this.mover=e,this.dx=t,this.dy=i,this.type="move-start"}}class q{constructor(e,t,i){this.mover=e,this.dx=t,this.dy=i,this.type="move"}}class B{constructor(e,t,i){this.mover=e,this.dx=t,this.dy=i,this.type="move-stop"}}class J{constructor(e){this.added=e,this.type="vertex-select"}}class Q{constructor(e){this.removed=e,this.type="vertex-deselect"}}class W{constructor(e,t,i,s){this.added=e,this.graphic=t,this.oldGraphic=i,this.vertices=s,this.type="vertex-add"}}class ${constructor(e,t,i,s){this.removed=e,this.graphic=t,this.oldGraphic=i,this.vertices=s,this.type="vertex-remove"}}const ee=j.reshapeGraphics,te={vertices:{default:new b({style:"circle",size:ee.vertex.size,color:ee.vertex.color,outline:{color:ee.vertex.outlineColor,width:1}}),hover:new b({style:"circle",size:ee.vertex.hoverSize,color:ee.vertex.hoverColor,outline:{color:ee.vertex.hoverOutlineColor,width:1}}),selected:new b({style:"circle",size:ee.selected.size,color:ee.selected.color,outline:{color:ee.selected.outlineColor,width:1}})},midpoints:{default:new b({style:"circle",size:ee.midpoint.size,color:ee.midpoint.color,outline:{color:ee.midpoint.outlineColor,width:1}}),hover:new b({style:"circle",size:ee.midpoint.size,color:ee.midpoint.color,outline:{color:ee.midpoint.outlineColor,width:1}})}};let ie=class extends r.EventedAccessor{constructor(e){super(e),this._updateHandlesOnExternalGeometryChange=null,this._activeOperationInfo=null,this._connectedReshapeManager=null,this._editGeometryOperations=null,this._graphicAttributes={esriSketchTool:"box"},this._mover=null,this._snappingContext=null,this._snappingGraphicsLayer=null,this._hoverGraphic=null,this._snappingTask=null,this._stagedVertex=null,this.tooltip=null,this.activeTooltipInfo=null,this.callbacks={onReshapeStart(){},onReshape(){},onReshapeStop(){},onMoveStart(){},onMove(){},onMoveStop(){},onGraphicClick(){}},this.connectedReshapeProviders=[],this.enableMidpoints=!0,this.enableMovement=!0,this.enableVertices=!0,this.graphic=null,this.highlightName=null,this.highlightsEnabled=!0,this.layer=null,this.midpointGraphics=new s,this.midpointSymbol=new b({style:"circle",size:6,color:[200,200,200],outline:{color:[100,100,100],width:1}}),this.selectedVertices=new s,this.snappingManager=null,this.symbols=te,this.sketchOptions=new z,this.type="reshape",this.vertexGraphics=new s,this.view=null}initialize(){const e=this.view;this._highlightHelper=new I({view:e}),this._setup(),this._updateHandlesOnExternalGeometryChange=c(()=>this.graphic?.geometry,e=>{if(!e)return;const t=new Set(this.selectedVertices.map(e=>e.attributes?.pointIndex));this._highlightHelper.removeAll(),this._setUpHighlights(),this._setupGraphics(),this._clearSelection(),this.vertexGraphics.filter(e=>t.has(e.attributes.pointIndex)).forEach(e=>this._addToSelection(e));const{enableMovement:i,_mover:s,graphic:o,midpointGraphics:r,vertexGraphics:n}=this,h=n.concat(r).items;i&&h.push(o),s?.set("graphics",h)},v),this.tooltip=F(()=>({view:e,options:this.sketchOptions.tooltips})),this.tooltipInfos=k(this.sketchOptions),this.addHandles([l(()=>e?.ready,()=>{const{layer:e,view:t}=this;O(t,e),this.addHandles(t.on("key-down",e=>this._keyDownHandler(e),A.TOOL))},{once:!0,initial:!0}),d(()=>this.graphic,()=>this.refresh()),d(()=>this.layer,(e,t)=>{t&&(this._clearSelection(),this._resetGraphics(t)),this.refresh()}),d(()=>[this.highlightsEnabled,this.highlightName],()=>{this._highlightHelper?.removeAll(),this._setUpHighlights()}),d(()=>this.enableMidpoints,()=>this.refresh()),T(this.tooltip,()=>this._tooltipsContext),d(()=>this.view.effectiveTheme.accentColor,()=>this._updateSymbolsForTheme(),m),this._updateHandlesOnExternalGeometryChange]),this._updateTooltip()}destroy(){this._reset(),this._mover?.destroy(),this._mover=null,this._connectedReshapeManager=h(this._connectedReshapeManager),this.tooltip=h(this.tooltip)}get _coordinateHelper(){return this._editGeometryOperations?.data.coordinateHelper??U(!!this.graphic.geometry?.hasZ,!!this.graphic.geometry?.hasM,this.view.spatialReference)}get _selectedVertex(){return 1===this.selectedVertices.length?this.selectedVertices.at(0):void 0}get _tooltipsContext(){const{automaticAreaMeasurementUtils:e,automaticLengthMeasurementUtils:t,sketchOptions:i,activeTooltipInfo:s,graphic:o}=this;return{sketchOptions:i,activeTooltipInfo:s,graphic:o,selectedVertex:this._selectedVertex,automaticAreaMeasurementUtils:e,automaticLengthMeasurementUtils:t,updateGeometry:(e,t,i,s,o)=>{this._setUpGeometryHelper();const r=e===this.graphic;r?this._emitMoveStartEvent(0,0):this._emitReshapeStartEvent(e);const n=!0;if(this._syncGeometryAfterVertexMove(e,t,s,o,n),r){const{view:e}=this,s=e.toScreen(i),o=e.toScreen(t),r=(o?.x??0)-(s?.x??0),n=(o?.y??0)-(s?.y??0);this._emitMoveEvent(r,n),this._emitMoveStopEvent(r,n)}else this._emitReshapeEvent(e),this._emitReshapeStopEvent(e);this._editGeometryOperations=h(this._editGeometryOperations)}}}get state(){const e=this.view.ready,t=!(!this.graphic||!this.layer);return e&&t?"active":e?"ready":"disabled"}isUIGraphic(e){const t=[];return this.graphic&&t.push(this.graphic),t.concat(this.vertexGraphics.items,this.midpointGraphics.items),t.length>0&&t.includes(e)}refresh(){this._reset(),this._setup()}reset(){this.graphic=null}clearSelection(){this._clearSelection()}removeSelectedVertices(){const{selectedVertices:e}=this;e.length&&this._removeVertices(e)}_setup(){const{graphic:e,layer:t}=this;if(!t||null==e?.geometry)return;const i=e.geometry;"mesh"!==i.type&&"extent"!==i.type?("polygon"===i.type&&f(i),this._setUpHighlights(),this._setupGraphics(),this._setupMover(),this._setupConnectedReshapeManager()):this._logGeometryTypeError()}_setUpHighlights(){this.highlightsEnabled&&this.graphic&&this._highlightHelper?.add(this.graphic,this.highlightName)}_setUpGeometryHelper(){const e=this.graphic.geometry;if(null==e||"mesh"===e.type||"extent"===e.type)return void this._logGeometryTypeError();const t="multipoint"===e.type?new u({paths:[e.points],spatialReference:e.spatialReference}):e;this._editGeometryOperations=P.fromGeometry(t,2)}_saveSnappingContextForHandle(e,t){this._snappingGraphicsLayer=new M({listMode:"hide",internal:!0,title:"Reshape snapping layer"}),this.view.map.layers.add(this._snappingGraphicsLayer);const i=this._editGeometryOperations;a(i),this._snappingContext=new D({editGeometryOperations:i,elevationInfo:{mode:"on-the-ground",offset:0},pointer:t.viewEvent?.pointerType||"mouse",excludeFeature:this.graphic,feature:this.graphic,visualizer:new V(this._snappingGraphicsLayer),vertexHandle:this._getVertexFromEditGeometry(e)})}_reset(){this._clearSelection(),this._highlightHelper?.removeAll(),this._updateTooltip(),this._resetGraphics(),this._resetSnappingStateVars(),this._activeOperationInfo=null,this._mover&&this._mover.destroy(),this._mover=null,this.view.cursor="default"}_resetSnappingStateVars(){null!=this.snappingManager&&this.snappingManager.doneSnapping(),null!=this._snappingGraphicsLayer&&(this.view?.map&&this.view.map.layers.remove(this._snappingGraphicsLayer),this._snappingGraphicsLayer.destroy()),this._editGeometryOperations=h(this._editGeometryOperations),this._snappingTask=p(this._snappingTask),this._snappingTask=null,this._snappingContext=null,this._stagedVertex=null}_resetGraphics(e){this._removeMidpointGraphics(e),this._removeVertexGraphics(e),this.selectedVertices.removeAll(),this._updateTooltip()}_removeMidpointGraphics(e){const t=e||this.layer;t&&t.removeMany(this.midpointGraphics.items),this.midpointGraphics.items.forEach(e=>e.destroy()),this.midpointGraphics.removeAll()}_removeVertexGraphics(e){const t=e||this.layer;t&&t.removeMany(this.vertexGraphics.items),this.vertexGraphics.items.forEach(e=>e.destroy()),this.vertexGraphics.removeAll()}_setupGraphics(){const e=this.graphic.geometry;if(null!=e&&("polyline"===e.type||"polygon"===e.type)){const t=se(e);this.enableMidpoints&&this._setUpMidpointGraphics(t),this.enableVertices&&this._setUpVertexGraphics(t)}}_setUpMidpointGraphics(e){this._removeMidpointGraphics();const t=this._createMidpointGraphics(e);this.midpointGraphics.addMany(t),this.layer.addMany(t)}_setUpVertexGraphics(e){this._removeVertexGraphics();const t=this._createVertexGraphics(e);this.vertexGraphics.addMany(t),this._storeRelatedVertexIndices(),this.layer.addMany(t)}_createVertexGraphics(e){const{_graphicAttributes:i,symbols:s}=this,o=[];return e?.forEach((e,r)=>{e.forEach((e,n)=>{o.push(new t({geometry:this._coordinateHelper.arrayToPoint(e),symbol:s?.vertices?.default,attributes:{...i,pathIndex:r,pointIndex:n}}))})}),o}_createMidpointGraphics(e){const{_graphicAttributes:i,symbols:s}=this,o=[];for(let r=0;r<e.length;r++){const n=e[r];for(let e=0;e<n.length;e++){const h=(e+1)%n.length;if("polyline"===this.graphic.geometry?.type&&0===h)continue;const a=n[e],p=n[h],c=this._getMidpoint(a,p);o.push(new t({geometry:c,symbol:s.midpoints.default,attributes:{...i,pathIndex:r,pointIndexStart:e,pointIndexEnd:h}}))}}return o}_updateSymbolsForTheme(){const e=this.view.effectiveTheme.accentColor;this.symbols={vertices:{...this.symbols.vertices,default:this.symbols.vertices.default.clone().set("color",e),hover:this.symbols.vertices.hover?.clone().set("color",e)},midpoints:{...this.symbols.midpoints}};for(const t of this.vertexGraphics)this._isSelected(t)?t.symbol=this.symbols.vertices.selected:this._hoverGraphic===t?t.symbol=this.symbols.vertices.hover:t.symbol=this.symbols.vertices.default}_storeRelatedVertexIndices(){const e=this.vertexGraphics.items;if(!e)return;const t=e.map(({geometry:e})=>({x:e.x,y:e.y}));for(let i=0;i<t.length;i++){const s=[];for(let e=0;e<t.length;e++){if(i===e)continue;const o=t[i],r=t[e];o.x===r.x&&o.y===r.y&&s.push(e)}e[i].attributes.relatedGraphicIndices=s}}_setupMover(){const{enableMovement:e,graphic:t,midpointGraphics:i,vertexGraphics:s,view:o}=this,r=s.concat(i).items;e&&r.push(t),this._mover=new E({enableMoveAllGraphics:!1,highlightsEnabled:!1,indicatorsEnabled:!1,graphics:r,view:o,callbacks:{onGraphicClick:e=>this._onGraphicClickCallback(e),onGraphicMoveStart:e=>this._onGraphicMoveStartCallback(e),onGraphicMove:e=>this._onGraphicMoveCallback(e),onGraphicMoveStop:e=>this._onGraphicMoveStopCallback(e),onGraphicPointerOver:e=>this._onGraphicPointerOverCallback(e),onGraphicPointerOut:e=>this._onGraphicPointerOutCallback(e)}})}_setupConnectedReshapeManager(){const{connectedReshapeProviders:e}=this;0!==e.length&&(this._connectedReshapeManager=new w({providerFactories:e,view:this.view}))}_onGraphicClickCallback(e){e.viewEvent.stopPropagation();const t=e.graphic;if(t===this.graphic)this.clearSelection(),this.emit("graphic-click",e),this.callbacks.onGraphicClick?.(e);else if(this._isMidpoint(t)){if(2===e.viewEvent.button)return;const i=this.graphic.clone(),s=this._createVertexFromMidpoint(t);this.refresh(),this._emitVertexAddEvent([t],i,s)}else if(this._isVertex(t))if(e.viewEvent.stopPropagation(),2===e.viewEvent.button)this._removeVertices(t);else{e.viewEvent.native.shiftKey||this._clearSelection(),this.selectedVertices.includes(t)?this._removeFromSelection(t,!0):this._addToSelection(t)}}_setUpOperation(e){const{graphic:t,dx:i,dy:s}=e,o=t===this.graphic;this._resetSnappingStateVars(),this._setUpGeometryHelper(),this._saveSnappingContextForHandle(t,e),this._activeOperationInfo={target:this.graphic,mover:t,operationType:o?"move":"reshape",totalDx:i,totalDy:s}}_onGraphicMoveStartCallback(e){const{dx:t,dy:i,graphic:s}=e,o=this._connectedReshapeManager,r=o?ne(this.graphic):null;if(s===this.graphic){const{geometry:n}=s;return this._setUpOperation(e),this._emitMoveStartEvent(t,i),r&&o?.startFeatureMove([r]),void(null!=n&&"point"===n.type&&this._onHandleMove(s,t,i,e,()=>{this._updateTooltip(this.graphic,e.viewEvent),this._emitMoveEvent(t,i)}))}const{selectedVertices:n}=this;if(!n.includes(s)){if(this._clearSelection(),this._isMidpoint(s)){const e=this.graphic.clone(),t=this._createVertexFromMidpoint(s);this._emitVertexAddEvent([s],e,t)}this._addToSelection(s)}this._setUpOperation(e),r&&o?.startVertexMove(r,he(n)),this._emitReshapeStartEvent(s),this._onHandleMove(s,t,i,e,()=>{this._updateTooltip(s,e.viewEvent),this._emitReshapeEvent(s)})}_onGraphicMoveCallback(e){const t=this._activeOperationInfo;if(!t)return;const{dx:i,dy:s,graphic:o}=e;t.totalDx+=i,t.totalDy+=s;const{operationType:r}=t,{geometry:n}=o;if(null!=n)if("move"!==r)this._onHandleMove(o,i,s,e,()=>{this._updateTooltip(o,e.viewEvent),this._emitReshapeEvent(o)});else if("point"===n.type)this._onHandleMove(o,i,s,e,()=>{this._updateTooltip(this.graphic,e.viewEvent),this._emitMoveEvent(i,s)});else if("polyline"===n.type||"polygon"===n.type){const t=se(n);this._updateVertexGraphicLocations(t);const{dxMap:o,dyMap:r}=ae(i,s,this.view);this._connectedReshapeManager?.translate(o,r,0),this._updateTooltip(this.graphic,e.viewEvent),this._emitMoveEvent(i,s)}}_onGraphicMoveStopCallback(e){const t=this._activeOperationInfo;if(!t)return;const{dx:i,dy:s,graphic:o}=e,{operationType:r}=t;t.totalDx+=i,t.totalDy+=s,this._onHandleMove(o,i,s,e,()=>"move"===r?this._emitMoveStopEvent():this._emitReshapeStopEvent(o)),this._isMidpoint(o)?this.refresh():(this._updateTooltip(this._isVertex(o)?o:null),this._resetSnappingStateVars(),this._connectedReshapeManager?.finish(),this._activeOperationInfo=null)}_updateVertexGraphicLocations(e){const{_coordinateHelper:t}=this;for(const i of this.vertexGraphics){const{pathIndex:s,pointIndex:o}=i.attributes;i.geometry=t.arrayToPoint(e[s][o])}this._updateMidpointGraphicLocations(e)}_updateMidpointGraphicLocations(e){for(const t of this.midpointGraphics){const{pathIndex:i,pointIndexStart:s,pointIndexEnd:o}=t.attributes,r=e[i];t.geometry=this._getMidpoint(r[s],r[o])}}_getMidpoint(e,t){const{_coordinateHelper:i}=this,s=i.arrayToVector(e),o=i.arrayToVector(t),r=i.toXYZ(s),n=i.toXYZ(o),[h,a,p]=x(r,n),c=i.hasM()?0:void 0;return new g({x:h,y:a,z:p,m:c,spatialReference:i.spatialReference})}_getVertexFromEditGeometry(e){const[t,i]=oe(e);return a(this._editGeometryOperations),this._editGeometryOperations.data.components[t].vertices[i]}_onHandleMove(e,t,s,o,r){p(this._snappingTask);const n=this._snappingContext;if(!n)return;const h=e.geometry,a="graphic-move-stop"===o.type;if(null!=this.snappingManager&&this.selectedVertices.length<2&&!a){const o=this.snappingManager;this._stagedVertex=o.update({point:h,context:n}),this._syncGeometryAfterVertexMove(e,new g(this._stagedVertex),t,s,a),r(),this._snappingTask=i(async i=>{const p=await o.snap({point:h,context:n,signal:i});p.valid&&(this._stagedVertex=p.apply(),this._syncGeometryAfterVertexMove(e,new g(this._stagedVertex),t,s,a),r())})}else{const i=null!=this._stagedVertex?new g(this._stagedVertex):h;this._syncGeometryAfterVertexMove(e,i,t,s,a),r()}}_syncGeometryAfterVertexMove(e,t,i,s,o=!1){const r=this._editGeometryOperations?.data.geometry;if(r)if("point"===r.type)e.geometry=t;else if("mesh"===r.type)e.geometry=r.centerAt(t);else{const{_coordinateHelper:n}=this,[h,a]=oe(e);let p=G(r);const c=p[h].length-1,l=n.pointToArray(t);p[h][a]=l,"polygon"===r.type&&(0===a?p[h][c]=l:a===c&&(p[h][0]=l)),this._isVertex(e)&&(p=this._moveRelatedCoordinates(p,e,l),p=this._moveSelectedHandleCoordinates(p,e,i,s,"polygon"===r.type),this._updateMidpointGraphicLocations(p)),this._updateGraphicGeometry(r.clone());const d=n.pointToVector(t),m=this._getVertexFromEditGeometry(e),v=n.getZ(d),y=d[0]-m.pos[0],_=d[1]-m.pos[1],g=null!=v?v-m.pos[2]:0;this._editGeometryOperations?.moveVertices([m],y,_,g),this._connectedReshapeManager?.translate(y,_,g),o&&(this._mover?this._mover.updateGeometry(this._mover.graphics.indexOf(e),t):e.geometry=t)}}_moveRelatedCoordinates(e,t,i){const{relatedGraphicIndices:s}=t.attributes;for(const o of s){const s=this.vertexGraphics.at(o),{pathIndex:r,pointIndex:n}=s.attributes;e[r][n]=i,s.geometry=t.geometry}return e}_moveSelectedHandleCoordinates(e,t,i,s,o){for(const r of this.selectedVertices)if(r!==t){const{pathIndex:t,pointIndex:n,relatedGraphicIndices:h}=r.attributes,a=S(r.geometry,i,s,this.view),p=G(a),c=e[t].length-1;e[t][n]=p,r.geometry=a,o&&(0===n?e[t][c]=p:n===c&&(e[t][0]=p));for(const i of h){const t=this.vertexGraphics.at(i),{pathIndex:s,pointIndex:o}=t.attributes;e[s][o]=p,t.geometry=a}}return e}_onGraphicPointerOverCallback(e){const t=e.graphic;this._hoverGraphic=t;const i=this._isVertex(t);i&&!this._isSelected(t)&&(t.symbol=this.symbols.vertices.hover),this._updateTooltip(i?t:null),this._updateHoverCursor(t)}_onGraphicPointerOutCallback(e){const t=e.graphic;this._hoverGraphic=null,this._isVertex(t)&&!this._isSelected(t)&&(t.symbol=this.symbols.vertices.default),this.view.cursor="default",this._updateTooltip()}_createVertexFromMidpoint(e){const{_graphicAttributes:t,graphic:i}=this,s=i.geometry;if(null==s||"polygon"!==s.type&&"polyline"!==s.type)return[];const o=s.clone(),r=[],{pathIndex:n,pointIndexStart:h,pointIndexEnd:a}=e.attributes,p=G(e.geometry),c=0===a?h+1:a,l=G(o);return l[n].splice(c,0,p),e.attributes={...t,pathIndex:n,pointIndex:c,relatedGraphicIndices:[]},r.push({coordinates:l[n][c],componentIndex:n,vertexIndex:c}),this._updateGraphicGeometry(o),r}_addToSelection(e){const t=re(e);for(const i of t)i.symbol=this.symbols.vertices.selected,this.selectedVertices.add(i),this._updateTooltip(i);this._emitSelectEvent(t)}_removeFromSelection(e,t){const{vertices:i}=this.symbols,s=t?i.hover:i.default;this.selectedVertices.remove(e),e.symbol=s,this._emitDeselectEvent([e]),this._updateTooltip()}_clearSelection(){const e=this.selectedVertices.toArray();if(e.length>0){for(const t of e)t.set("symbol",this.symbols.vertices.default);this.selectedVertices.removeAll(),this._emitDeselectEvent(e),this._updateTooltip()}}_keyDownHandler(e){null==this._activeOperationInfo&&N(e,this.tooltip)||L.delete.includes(e.key)&&!e.repeat&&this.selectedVertices.length&&this._removeVertices(this.selectedVertices)}_removeVertices(e){const t=this.graphic.geometry;if(null==t||"polygon"!==t.type&&"polyline"!==t.type)return;if("polygon"===t.type&&this.vertexGraphics.length<4||this.vertexGraphics.length<3)return;const i=this.graphic.clone(),s=t.clone();let o=G(s);const r=[],n=re(e);for(const h of n){const{x:e,y:t}=h.geometry;for(let i=0;i<o.length;i++){const s=o[i];for(let n=0;n<s.length;n++){const[h,a]=s[n];e===h&&t===a&&(r.push({coordinates:o[i][n],componentIndex:i,vertexIndex:n}),o[i].splice(Number(n),1))}}}if("polygon"===s.type)o=o.filter(e=>{if(e.length<2)return!1;const[t,i]=e[0],[s,o]=e[e.length-1];return(2!==e.length||t!==s||i!==o)&&(t===s&&i===o||e.push(e[0]),!0)}),s.rings=o;else{for(const e of o)1===e.length&&o.splice(o.indexOf(e),1);s.paths=o}this._updateGraphicGeometry(s),this.refresh(),this._emitVertexRemoveEvent(n,i,r)}_isVertex(e){return this.vertexGraphics.includes(e)}_isSelected(e){return this._isVertex(e)&&this.selectedVertices.includes(e)}_isMidpoint(e){return this.midpointGraphics.includes(e)}_updateHoverCursor(e){this.view.cursor=this._isMidpoint(e)?"copy":"move"}_updateTooltip(e,t){let i=null;const{graphic:s,view:o,tooltipInfos:r}=this,n=s?.geometry;"point"===n?.type?i=r.movePoint:this._selectedVertex?i=r.selectedVertex:e===this.graphic?(i=r.translateGraphic,R(i,o,this._tooltipsContext,t)):e&&this.selectedVertices.length>1&&(i=r.translateVertices,H(i,o,n,this._tooltipsContext,t)),this.activeTooltipInfo=i}_updateGraphicGeometry(e){this._updateHandlesOnExternalGeometryChange?.pause(),this.graphic.geometry=e,this._updateHandlesOnExternalGeometryChange?.resume()}_emitMoveStartEvent(e,t){const i=new K(this.graphic,e,t);this.emit("move-start",i),this.callbacks.onMoveStart?.(i)}_emitMoveEvent(e,t){const i=new q(this.graphic,e,t);this.emit("move",i),this.callbacks.onMove?.(i)}_emitMoveStopEvent(e,t){if(null==e||null==t){const i=this._activeOperationInfo;if(!i)return;e=i.totalDx,t=i.totalDy}const i=new B(this.graphic,e,t);this.emit("move-stop",i),this.callbacks.onMoveStop?.(i)}_emitReshapeStartEvent(e){const t=new Z(this.graphic,e,this.selectedVertices.toArray());this.emit("reshape-start",t),this.callbacks.onReshapeStart?.(t)}_emitReshapeEvent(e){const t=new X(this.graphic,e,this.selectedVertices.toArray());this.emit("reshape",t),this.callbacks.onReshape?.(t)}_emitReshapeStopEvent(e){const t=new Y(this.graphic,e,this.selectedVertices.toArray());this.emit("reshape-stop",t),this.callbacks.onReshapeStop?.(t)}_emitSelectEvent(e){const t=new J(e);this.emit("select",t),this.callbacks.onVertexSelect?.(t)}_emitDeselectEvent(e){const t=new Q(e);this.emit("deselect",t),this.callbacks.onVertexDeselect?.(t)}_emitVertexAddEvent(e,t,i){const s=new W(e,this.graphic,t,i);this.emit("vertex-add",s),this.callbacks.onVertexAdd?.(s)}_emitVertexRemoveEvent(e,t,i){const s=new $(e,this.graphic,t,i);this.emit("vertex-remove",s),this.callbacks.onVertexRemove?.(s)}_logGeometryTypeError(){n.getLogger(this).error(new o("reshape:invalid-geometry","Reshape operation not supported for the provided graphic. The geometry type is not supported."))}};function se(e){const t=G(e.clone());if("polygon"===e.type)for(const i of t){const e=i[i.length-1];i[0][0]===e[0]&&i[0][1]===e[1]&&i.length>2&&i.pop()}return t}function oe({attributes:e}){return[e?.pathIndex||0,e?.pointIndex||0]}function re(e){return e instanceof t?[e]:[...e]}function ne(e){const t=e.sourceLayer??e.layer;return C(t)?{graphic:e,layer:t}:null}function he(e){return e.toArray().map(e=>({pathIndex:e.attributes.pathIndex,vertexIndex:e.attributes.pointIndex}))}function ae(e,t,i){const s=i.state.inverseTransform;return{dxMap:s[0]*e+s[2]*t,dyMap:s[1]*e+s[3]*t}}e([y()],ie.prototype,"_activeOperationInfo",void 0),e([y()],ie.prototype,"_connectedReshapeManager",void 0),e([y()],ie.prototype,"_coordinateHelper",null),e([y()],ie.prototype,"_editGeometryOperations",void 0),e([y()],ie.prototype,"tooltip",void 0),e([y()],ie.prototype,"tooltipInfos",void 0),e([y()],ie.prototype,"activeTooltipInfo",void 0),e([y({constructOnly:!0})],ie.prototype,"automaticAreaMeasurementUtils",void 0),e([y({constructOnly:!0})],ie.prototype,"automaticLengthMeasurementUtils",void 0),e([y()],ie.prototype,"_selectedVertex",null),e([y()],ie.prototype,"_tooltipsContext",null),e([y()],ie.prototype,"callbacks",void 0),e([y()],ie.prototype,"connectedReshapeProviders",void 0),e([y()],ie.prototype,"enableMidpoints",void 0),e([y()],ie.prototype,"enableMovement",void 0),e([y()],ie.prototype,"enableVertices",void 0),e([y()],ie.prototype,"graphic",void 0),e([y()],ie.prototype,"highlightName",void 0),e([y()],ie.prototype,"highlightsEnabled",void 0),e([y()],ie.prototype,"layer",void 0),e([y({readOnly:!0})],ie.prototype,"midpointGraphics",void 0),e([y()],ie.prototype,"midpointSymbol",void 0),e([y({readOnly:!0})],ie.prototype,"selectedVertices",void 0),e([y()],ie.prototype,"snappingManager",void 0),e([y({readOnly:!0})],ie.prototype,"state",null),e([y()],ie.prototype,"symbols",void 0),e([y({type:z})],ie.prototype,"sketchOptions",void 0),e([y({readOnly:!0})],ie.prototype,"type",void 0),e([y({readOnly:!0})],ie.prototype,"vertexGraphics",void 0),e([y()],ie.prototype,"view",void 0),ie=e([_("esri.views.draw.support.Reshape")],ie);const pe=ie;export{pe 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.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
function
|
|
5
|
+
import{isEditableLayer as r}from"../../../layers/support/editableLayers.js";import{isSubtypeSublayer as e,isGraphicsLayer as s,isKnowledgeGraphSublayer as n}from"../../../layers/support/layerUtils.js";function t(r,e,s){if(!e||!r?.map)return;const{map:n}=r,t=n.layers.find(r=>r===e);t||n.add(e,s),t&&null!=s&&n.layers.reorder(t,s)}function l(r,e){const s="subtype-sublayer"===e?.type?e.parent:e;return r.allLayerViews.find(r=>{const e=r.layer;return e===s||"sublayers"in e&&null!=e.sublayers&&e.sublayers.includes(s)})}function a(t){return r(t)||e(t)||s(t)||n(t)}export{t as addUniqueLayer,l as findLayerView,a as isConnectedReshapeSupportedLayer};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{
|
|
5
|
+
import{__addDisposableResource as e,__disposeResources as r}from"tslib";import{isSupportedLayer as t}from"../../../arcade/featureset/support/shared.js";import a from"../../../core/Logger.js";import{sqlAnd as n}from"../../../core/sql.js";import i from"../../../layers/FeatureLayer.js";import{internalTimeReceivedField as s}from"../../../layers/support/streamLayerUtils.js";import{isDate as o}from"../../../support/guards.js";import{applyTextFormattingHTML as c,htmlEntities as u}from"./featureUtils.js";const l="esri.widgets.Feature.support.arcadeFeatureUtils",p=()=>a.getLogger(l);function d(e){return c(u(e))}function f(e){return"createQuery"in e&&"queryFeatures"in e}async function y({graphic:e,view:r,options:t}){const{isAggregate:a}=e,n=e.layer??e.sourceLayer;if(!a||!n||"2d"!==r?.type)return[];const i=await r.whenLayerView(n);if(!f(i))return[];const s=i.createQuery(),o=e.getObjectId();s.aggregateIds=null!=o?[o]:[];const{features:c}=await i.queryFeatures(s,t);return c}function m({layer:e,aggregatedFeatures:r,interceptor:t}){const{fields:a,objectIdField:n,geometryType:s,spatialReference:o,displayField:c}=e;return new i({fields:a,objectIdField:n,geometryType:s,spatialReference:o,displayField:c,interceptor:t,..."feature"===e.type?{templates:e.templates,typeIdField:e.typeIdField,types:e.types}:null,source:r})}function w(e){const r="esri.views.3d.layers.VoxelGraphic"===e.declaredClass;return e.isAggregate?"popup-feature-reduction":r?"popup-voxel":"popup"}function g(e){return{scale:e?.scale,timeProperties:{currentStart:e?.timeExtent?.start,currentEnd:e?.timeExtent?.end,startIncluded:!0,endIncluded:!0}}}function v(e){return{$voxel:e}}async function x(e,r,t,a,n,i,s){let o=null;if(i.has("$aggregatedfeatures")){const e=await y({graphic:r,view:t,options:a}),i=r.sourceLayer||r.layer;o=m({layer:i,aggregatedFeatures:e,interceptor:n})}return{vars:{$feature:r,$aggregatedFeatures:o,$view:g(t)},track:s?await F(e,r,t):null,[Symbol.dispose]:()=>o?.[Symbol.dispose]()}}function h(e){if(o(e))return e.getTime();if("number"==typeof e)return e;if("string"==typeof e)return new Date(e).getTime();throw new Error(`Unexpected time value: ${e}`)}async function F(e,r,t){const a=r.sourceLayer||r.layer;if(null==a||!("timeInfo"in a))return null;const i=a.timeInfo?.trackIdField;if(null==i)return null;const o=r.getAttribute(i);if(null==o)return null;let c,u;if("string"==typeof o)c=`"${i.replaceAll('"','""')}" = '${o.replaceAll("'","''")}'`;else{if("number"!=typeof o)return p().warn("Expected track id to be a string or number"),null;c=`"${i.replaceAll('"','""')}" = ${o}`}if("stream"===a.type&&null!=t){const e=await t.whenLayerView(a),r=e.createQuery();r.returnGeometry=!0,r.where=n(r.where,c),u=(await e.queryFeatures(r)).features}else{if(!("queryFeatures"in a))return null;{const e=a.createQuery();e.returnGeometry=!0,e.where=n(e.where,c),u=(await a.queryFeatures(e)).features}}const l=a.fieldsIndex.normalizeFieldName(a.timeInfo.startField)??s,d=a.timeInfo.endField?a.fieldsIndex.normalizeFieldName(a.timeInfo.endField):null,f=u.map(r=>{const a=r.getObjectId();if(null==a)throw new Error("Cannot identify observation");const n=e.ArcadeFeature.createFromGraphic(r,t?.timeZone),i=h(r.getAttribute(l));return{id:a,feature:n,startTime:i,endTime:null!=d?h(r.getAttribute(d)):i,stats:{totalDistance:void 0,distance:void 0,speed:void 0,acceleration:void 0}}}).sort((e,r)=>e.startTime-r.startTime),y="esri.TrackGraphic"===r.declaredClass?f.length-1:f.findIndex(e=>r.getObjectId()===e.id);if(y<0)throw new Error("Couldn't locate feature in observations");return{observations:f,currentObservationIndex:y}}async function b(e,r,a,n,i,s){const o=(r.sourceLayer||r.layer)??void 0;return{vars:{$feature:r,$layer:null!=o&&t(o)?o:"scene"===o?.type&&null!=o.associatedLayer?o.associatedLayer:void 0,$map:a,$datastore:o?.url,$userInput:n,$graph:"knowledge-graph-sublayer"===o?.type?o.parentCompositeLayer?.knowledgeGraph:void 0,$view:g(i)},track:s?await F(e,r,i):null}}async function I(e,{arcade:r,graphic:t,map:a,location:n,view:i,options:s,interceptor:o,arcadeExecutor:c,usesTrack:u}){switch(e){case"popup":return{...await b(r,t,a,n,i,u),[Symbol.dispose](){}};case"popup-feature-reduction":{const e=new Set(c.variablesUsed);return await x(r,t,i,s,o,e,u)}case"popup-voxel":return{vars:v(t),track:null,[Symbol.dispose](){}};default:throw new Error(`Unexpected profile name ${e}`)}}async function $(){const[e,r,{default:t}]=await Promise.all([import("../../../arcade.js"),import("../../../arcade/arcade.js"),import("../../../arcade/Feature.js")]);return{executor:e,syntaxUtils:r,ArcadeFeature:t}}async function j(t,a,n){const{executor:{createArcadeProfile:i,createArcadeExecutor:s},syntaxUtils:o}=n,c=w(a),u=i(c);let l;try{l=await s(t,u)}catch(y){return p().error("arcade-executor-error",{error:y,expression:t}),null}const d=new Set;l.variablesUsed.includes("$view")&&(o.scriptUsesViewProperties(l.syntaxTree,["scale"])&&d.add("view-scale"),o.scriptUsesViewProperties(l.syntaxTree,["timeProperties"])&&d.add("view-time-extent"));const f=o.scriptUsesTrack(l.syntaxTree);return{dependencies:d,async evaluate({graphic:a,interceptor:i,location:s,map:o,options:u,spatialReference:d,view:m}){const w={stack:[],error:void 0,hasError:!1};try{const r=e(w,await I(c,{arcade:n,graphic:a,map:o,location:s,view:m,options:u,interceptor:i,arcadeExecutor:l,usesTrack:f}),!1),g={abortSignal:u?.signal??void 0,interceptor:i??void 0,rawOutput:!0,spatialReference:d??void 0,timeZone:m?.timeZone,track:r.track,console(...e){p().info(...e)}};try{return await l.executeAsync(r.vars,g)}catch(y){if(u?.signal?.aborted)return;return void p().error("arcade-execution-error",{error:y,graphic:a,expression:t})}}catch(g){w.error=g,w.hasError=!0}finally{r(w)}}}}async function T({expression:e,graphic:r}){return e?j(e,r,await $()):null}async function k(e,r){if(!e?.length)return{dependencies:new Set,expressions:new Map};const t=await $(),a=new Set,n=new Map;for(const i of e){const e=await j(i.expression,r,t);n.set(`expression/${i.name}`,e),e?.dependencies.forEach(e=>a.add(e))}return{dependencies:a,expressions:n}}export{T as compileExpression,k as compileExpressionInfos,d as formatArcadeValue};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import has from"../../../core/has.js";import e from"../../../core/Logger.js";import{replace as t}from"../../../core/string.js";import{convertDateFormatToIntlOptions as r,formatDate as n}from"../../../intl/date.js";import{formatNumber as i,convertNumberFormatToIntlOptions as o}from"../../../intl/number.js";import{isRasterPixelValueField as a,featureHasFields as l,isTimeOnlyField as u}from"../../../layers/support/fieldUtils.js";import{getEffectiveLayerCapabilities as s}from"../../../layers/support/layerUtils.js";import{formatAnyDate as f,isAnyDateField as c}from"../../../smartMapping/support/utils.js";import{loadArcade as d}from"../../../support/loadArcade.js";import{getTimeZoneFormattingOptions as p}from"../../../time/timeZoneUtils.js";const y="esri.widgets.Feature.support.featureUtils",m=()=>e.getLogger(y),b=/href=(""|'')/gi,g=/(\{([^{\r\n]+)\})/g,h=/'/g,I=/^\s*expression\//i,w=/(\n)/gi,T=/[\u00A0-\u9999<>&]/gim,F=/href\s*=\s*(?:"([^"]+)"|'([^']+)')/gi,N=/^(?:mailto:|tel:)/,j="relationships/",Z=r("short-date-short-time");function L(e){if(null!=e)return(e.sourceLayer||e.layer)??void 0}async function q({type:e,value:t,event:r}){try{return"function"==typeof t?t(r):await t}catch(n){return void m().error("error",`An error occurred when calling the "${e}" function`,{error:n,graphic:r.graphic,value:t})}}function x(e=""){if(e)return!N.test(e.trim().toLowerCase())}function E(e){return!!e&&I.test(e)}function v(e,t){if(!t||!E(t)||!e)return;const r=t.replace(I,"").toLowerCase();return e.find(({name:e})=>e.toLowerCase()===r)}function A(e,t){const r=v(t,e?.fieldName);return r?r.title||null:e?e.label||e.fieldName:null}function C(e,t){const r=t.get(e.toLowerCase());return`{${r?.fieldName||e}}`}function U(e){return e.replaceAll(b,"")}function M(e,t){const r=k(t,e);return r?r.name:e}function R(e,t){return e&&e.map(e=>M(e,t))}function k(e,t){return e&&"function"==typeof e.getField&&t?e.getField(t)??null:null}function $(e){return`${e}`.trim()}function D({attributes:e,globalAttributes:t,layer:r,text:n,expressionAttributes:i,fieldInfoMap:o}){return n?z({formattedAttributes:t,template:P(n,{...t,...i,...e},r),fieldInfoMap:o}):""}function z({formattedAttributes:e,template:r,fieldInfoMap:n}){return $(U(t(t(r,e=>C(e,n)),e)))}function O(e,t,r=!1){const n=t[e];if("string"==typeof n){const i="%27",o=(r?encodeURIComponent(n):n).replaceAll(h,i);t[e]=o}}function G(e,t=!1){const r={...e};return Object.keys(r).forEach(e=>O(e,r,t)),r}function S(e,r,n){const i=(r=$(r))&&"{"!==r[0];return t(e,G(n,i||!1))}function Q(e,t){return e.replaceAll(g,(e,r,n)=>{const i=k(t,n);return i?`{${i.name}}`:r})}function P(e,t,r){const n=Q(e,r);return n?n.replaceAll(F,(e,r,n)=>S(e,r||n,t)):n}function _(e,t){if("string"==typeof e&&t&&null==t.dateFormat&&(null!=t.places||null!=t.digitSeparator)){const t=Number(e);if(!isNaN(t))return t}return e}function H(e){return null!=e&&"object"==typeof e&&"fieldsIndex"in e&&"geometryType"in e&&"getField"in e&&"load"in e&&"loaded"in e&&"objectIdField"in e&&"spatialReference"in e&&"type"in e&&("feature"===e.type||"scene"===e.type||"subtype-group"===e.type||"subtype-sublayer"===e.type||"sublayer"===e.type)&&"when"in e}function B(e){return null!=e&&"object"==typeof e&&"createQuery"in e&&"queryFeatureCount"in e&&"queryObjectIds"in e&&"queryRelatedFeatures"in e&&"queryRelatedFeaturesCount"in e&&"relationships"in e}function J(e){return H(e)&&B(e)}function K(e){return!(!(e&&"object"==typeof e&&"createQuery"in e&&"getField"in e&&"queryFeatureCount"in e&&"queryFeatures"in e&&"queryObjectIds"in e&&"capabilities"in e&&"fields"in e&&"fieldsIndex"in e&&"type"in e)||"feature"!==e.type&&"subtype-group"!==e.type&&"subtype-sublayer"!==e.type&&"sublayer"!==e.type||!("when"in e))&&("subtype-sublayer"===e.type&&"parent"in e&&e.parent&&"object"==typeof e.parent?"globalIdField"in e.parent:"globalIdField"in e)}function V(e){return!!e&&"object"==typeof e&&"sourceLayer"in e&&J(e.sourceLayer)}function W(e,t){const{fieldInfos:r,fieldName:n,preventPlacesFormatting:l,layer:u,timeZone:s}=t,c=ee(r,n),d=k(u,n);if(c&&!a(n)){const t=d?.type,r=c.format?.dateFormat;if("date"===t||"date-only"===t||"time-only"===t||"timestamp-offset"===t||r)return f(e,{format:r,fieldType:t,timeZoneOptions:{layerTimeZone:u&&"preferredTimeZone"in u?u.preferredTimeZone:null,viewTimeZone:s,datesInUnknownTimezone:!(!u||!("datesInUnknownTimezone"in u))&&!!u.datesInUnknownTimezone}})}const p=c?.format;return"string"==typeof e&&a(n)&&p?X(e,p):"string"==typeof(e=_(e,p))||null==e||null==p?le(e):i(e,l?{...o(p),minimumFractionDigits:0,maximumFractionDigits:20}:o(p))}function X(e,t){return e=e.trim(),/\d{2}-\d{2}/.test(e)?e:e.includes(",")?Y(e,",",", ",t):e.includes(";")?Y(e,";","; ",t):e.includes(" ")?Y(e," "," ",t):i(Number(e),o(t))}function Y(e,t,r,n){return e.trim().split(t).map(e=>i(Number(e),o(n))).join(r)}function ee(e,t){if(e?.length&&t)return e.find(e=>e.fieldName?.toLowerCase()===t.toLowerCase())}function te({fieldName:e,graphic:t,layer:r}){if(pe(e))return null;if(!r||"function"!=typeof r.getFeatureType)return null;const{typeIdField:n}=r;if(!n||e!==n)return null;const i=r.getFeatureType(t);return i?i.name:null}function re({fieldName:e,value:t,graphic:r,layer:n}){if(pe(e))return null;if(!n||"function"!=typeof n.getFieldDomain)return null;const i=r&&n.getFieldDomain(e,{feature:r,excludeImpliedDomains:has("esri-widget-legacy-field-domain-calculation")});return i&&"coded-value"===i.type?i.getName(t):null}function ne(e,t,r,i){const{creatorField:o,creationDateField:a,editorField:l,editDateField:u}=e;if(!t)return;const s=p(i&&"preferredTimeZone"in i?i.preferredTimeZone:null,!(!i||!("datesInUnknownTimezone"in i))&&!!i.datesInUnknownTimezone,r,Z,"date"),f={...Z,...s},c=t[u];if("number"==typeof c){const e=t[l];return{type:"edit",date:n(c,f),user:e}}const d=t[a];if("number"==typeof d){const e=t[o];return{type:"create",date:n(d,f),user:e}}return null}function ie(e,t){const r=new Map;if(!e)return r;for(const n of e){if(!n.fieldName)continue;const e=M(n.fieldName,t);n.fieldName=e,r.set(e.toLowerCase(),n)}return r}function oe(e){const t=[];if(!e)return t;const{fieldInfos:r,content:n}=e;return r&&t.push(...r),n&&Array.isArray(n)?(n.forEach(e=>{if("fields"===e.type){const r=e?.fieldInfos;r&&t.push(...r)}}),t):t}function ae(e){return e.replaceAll(T,e=>`&#${e.charCodeAt(0)};`)}function le(e){return"string"==typeof e?e.replaceAll(w,'<br class="esri-text-new-line" />'):e}function ue(e){const{value:t,fieldName:r,fieldInfos:n,fieldInfoMap:i,layer:o,graphic:a,timeZone:l}=e;if(null==t)return"";const s=re({fieldName:r,value:t,graphic:a,layer:o});if(s)return s;const d=te({fieldName:r,graphic:a,layer:o});if(d)return d;if(i.get(r.toLowerCase()))return W(t,{fieldInfos:n||Array.from(i.values()),fieldName:r,layer:o,timeZone:l});const p=o?.fieldsIndex?.get(r);return p&&(c(p)||u(p))?f(t,{fieldType:p.type,timeZoneOptions:{layerTimeZone:o&&"preferredTimeZone"in o?o.preferredTimeZone:null,viewTimeZone:l,datesInUnknownTimezone:!(!o||!("datesInUnknownTimezone"in o))&&!!o.datesInUnknownTimezone}}):le(t)}function se({fieldInfos:e,attributes:t,layer:r,graphic:n,fieldInfoMap:i,relatedInfos:o,timeZone:a}){const l={};return o?.forEach(t=>be({attributes:l,relatedInfo:t,fieldInfoMap:i,fieldInfos:e,layer:r,timeZone:a})),t&&Object.keys(t).forEach(o=>{const u=t[o];l[o]=ue({fieldName:o,fieldInfos:e,fieldInfoMap:i,layer:r,value:u,graphic:n,timeZone:a})}),l}async function fe(e,t){const{layer:r,graphic:n,outFields:i,objectIds:o,returnGeometry:a,spatialReference:l}=e,u=o[0];if("number"!=typeof u&&"string"!=typeof u){const e="Could not query required fields for the specified feature. The feature's ID is invalid.",t={layer:r,graphic:n,objectId:u,requiredFields:i};return m().warn(e,t),null}if(!s(r)?.operations?.supportsQuery){const e="The specified layer cannot be queried. The following fields will not be available.",t={layer:r,graphic:n,requiredFields:i,returnGeometry:a};return m().warn(e,t),null}const f=r.createQuery();f.objectIds=o,f.outFields=i?.length?i:[r.objectIdField],f.returnGeometry=!!a,f.returnZ=!!a,f.returnM=!!a,f.outSpatialReference=l;return(await r.queryFeatures(f,t)).features[0]}async function ce(e){if(!e.expressionInfos?.length)return!1;const t=await d(),{arcadeUtils:{hasGeometryFunctions:r}}=t;return r(e)}async function de({graphic:e,popupTemplate:t,layer:r,spatialReference:n},i){if(!r||!t)return;if("function"==typeof r.load&&await r.load(i),!e.attributes)return;const o=r.objectIdField,a=e.attributes[o];if(null==a)return;const u=[a],s=await t.getRequiredFields(r.fieldsIndex),f=l(e,s),c=f?[]:s.includes(o)?s:[...s,o],d=t.returnGeometry||await ce(t);if(f&&!d)return;const p=await fe({layer:r,graphic:e,outFields:c,objectIds:u,returnGeometry:d,spatialReference:n},i);p&&(p.geometry&&(e.geometry=p.geometry),p.attributes&&(e.attributes={...e.attributes,...p.attributes}))}function pe(e=""){return!!e&&e.includes(j)}function ye(e){return e?`${j}${e.layerId}/${e.fieldName}`:""}function me({attributes:e,graphic:t,relatedInfo:r,fieldInfos:n,fieldInfoMap:i,layer:o,timeZone:a}){e&&t&&r&&Object.keys(t.attributes).forEach(l=>{const u=ye({layerId:r.relation.id.toString(),fieldName:l}),s=t.attributes[l];e[u]=ue({fieldName:u,fieldInfos:n,fieldInfoMap:i,layer:o,value:s,graphic:t,timeZone:a})})}function be({attributes:e,relatedInfo:t,fieldInfoMap:r,fieldInfos:n,layer:i,timeZone:o}){e&&t&&(t.relatedFeatures?.forEach(a=>me({attributes:e,graphic:a,relatedInfo:t,fieldInfoMap:r,fieldInfos:n,layer:i,timeZone:o})),t.relatedStatsFeatures?.forEach(a=>me({attributes:e,graphic:a,relatedInfo:t,fieldInfoMap:r,fieldInfos:n,layer:i,timeZone:o})))}const ge=e=>{if(!e)return!1;const t=e.toUpperCase();return t.includes("CURRENT_TIMESTAMP")||t.includes("CURRENT_DATE")||t.includes("CURRENT_TIME")},he=({layer:e,method:t,query:r,definitionExpression:n})=>{if(!e.capabilities?.query?.supportsCacheHint||"attachments"===t)return;const i=null!=r.where?r.where:null,o=null!=r.geometry?r.geometry:null;ge(n)||ge(i)||"extent"===o?.type||"tile"===r.resultType||(r.cacheHint=!0)},Ie=({query:e,layer:t,method:r})=>{he({layer:t,method:r,query:e,definitionExpression:`${t.definitionExpression} ${t.serviceDefinitionExpression??""}`})},we=({queryPayload:e,layer:t,method:r})=>{he({layer:t,method:r,query:e,definitionExpression:`${t.definitionExpression} ${t.serviceDefinitionExpression??""}`})};function Te(e,t,r){return e&&t&&r?"sublayer"===t.type?je({layers:t.layer?.allSublayers,map:e,relatedLayer:t,relationship:r})||je({layers:t.layer?.subtables,map:e,relatedLayer:t,relationship:r}):je({layers:e.allLayers,map:e,relatedLayer:t,relationship:r})||je({layers:e.allTables,map:e,relatedLayer:t,relationship:r}):null}function Fe(e,t){return e&&"utilityNetworks"in e&&t?e.utilityNetworks?.find(e=>e.isUtilityLayer(t)):null}function Ne(e,t){return e?.allTables.find(e=>"feature"===e.type&&e.layerId===t.id&&e.url===t.layer?.url)}function je({map:e,relationship:t,relationship:{relatedTableId:r},relatedLayer:n,layers:i}){if(!i)return null;for(const o of i){if("map-image"===o.type){const r=je({layers:o.sublayers,map:e,relatedLayer:n,relationship:t})||je({layers:o.subtables,map:e,relatedLayer:n,relationship:t});if(r)return r;continue}if(!J(o))continue;if("sublayer"===n.type){if(o!==n&&o.id===r)return o.isTable?Ne(e,o):o;continue}const i="scene"===n.type&&n.associatedLayer?n.associatedLayer.url:n.url;if(!i)return null;if("sublayer"!==o.type){if(o!==n&&o.url===i&&o.layerId===r)return o}else if(o!==n&&o.layer?.url===i&&o.id===r)return o.isTable?Ne(e,o):o}return null}export{le as applyTextFormattingHTML,ie as createFieldInfoMap,Te as findRelatedLayer,Fe as findUtilityNetwork,Q as fixTokens,se as formatAttributes,ne as formatEditInfo,W as formatValueToFieldInfo,oe as getAllFieldInfos,ee as getFieldInfo,A as getFieldInfoLabel,M as getFixedFieldName,R as getFixedFieldNames,L as getSourceLayer,q as graphicCallback,ae as htmlEntities,K as isAssociatedFeatureSupportedLayer,E as isExpressionField,H as isFeatureSupportedLayer,V as isGraphicForRelatableFeatureSupportedLayer,J as isRelatableFeatureSupportedLayer,B as isRelatableLayer,pe as isRelatedField,Ie as preLayerQueryCallback,we as preRequestCallback,fe as querySourceLayer,de as queryUpdatedFeature,x as shouldOpenInNewTab,z as substituteAttributes,D as substituteFieldsInLinksAndAttributes};
|
|
5
|
+
import has from"../../../core/has.js";import e from"../../../core/Logger.js";import{replace as t}from"../../../core/string.js";import{convertDateFormatToIntlOptions as n,formatDate as r}from"../../../intl/date.js";import{formatNumber as i,convertNumberFormatToIntlOptions as o}from"../../../intl/number.js";import{isRasterPixelValueField as a,featureHasFields as l,isTimeOnlyField as u}from"../../../layers/support/fieldUtils.js";import{getEffectiveLayerCapabilities as s}from"../../../layers/support/layerUtils.js";import{formatAnyDate as f,isAnyDateField as c}from"../../../smartMapping/support/utils.js";import{loadArcade as d}from"../../../support/loadArcade.js";import{getTimeZoneFormattingOptions as p}from"../../../time/timeZoneUtils.js";const y="esri.widgets.Feature.support.featureUtils",m=()=>e.getLogger(y),b=/href=(""|'')/gi,g=/(\{([^{\r\n]+)\})/g,I=/'/g,h=/^\s*expression\//i,w=/(\n)/gi,F=/[\u00A0-\u9999<>&]/gim,T=/href\s*=\s*(?:"([^"]+)"|'([^']+)')/gi,N=/^(?:mailto:|tel:)/,j="relationships/",Z=n("short-date-short-time");function L(e){if(null!=e)return(e.sourceLayer||e.layer)??void 0}async function q({type:e,value:t,event:n}){try{return"function"==typeof t?t(n):await t}catch(r){return void m().error("error",`An error occurred when calling the "${e}" function`,{error:r,graphic:n.graphic,value:t})}}function x(e=""){if(e)return!N.test(e.trim().toLowerCase())}function E(e){return!!e&&h.test(e)}function U(e,t){if(!t||!E(t)||!e)return;const n=t.replace(h,"").toLowerCase();return e.find(({name:e})=>e.toLowerCase()===n)}function v(e,t){const n=U(t,e?.fieldName);return n?n.title||null:e?e.label||e.fieldName:null}function A(e,t){const n=t.get(e.toLowerCase());return`{${n?.fieldName||e}}`}function C(e){return e.replaceAll(b,"")}function M(e,t){const n=R(t,e);return n?n.name:e}function k(e,t){return e&&e.map(e=>M(e,t))}function R(e,t){return e&&"function"==typeof e.getField&&t?e.getField(t)??null:null}function $(e){return`${e}`.trim()}function D({attributes:e,globalAttributes:t,layer:n,text:r,expressionAttributes:i,fieldInfoMap:o}){return r?z({formattedAttributes:t,template:P(r,{...t,...i,...e},n),fieldInfoMap:o}):""}function z({formattedAttributes:e,template:n,fieldInfoMap:r}){return $(C(t(t(n,e=>A(e,r)),e)))}function O(e,t,n=!1){const r=t[e];if("string"==typeof r){const i="%27",o=(n?encodeURIComponent(r):r).replaceAll(I,i);t[e]=o}}function S(e,t=!1){const n={...e};return Object.keys(n).forEach(e=>O(e,n,t)),n}function G(e,n,r){const i=(n=$(n))&&"{"!==n[0];return t(e,S(r,i||!1))}function Q(e,t){return e.replaceAll(g,(e,n,r)=>{const i=R(t,r);return i?`{${i.name}}`:n})}function P(e,t,n){const r=Q(e,n);return r?r.replaceAll(T,(e,n,r)=>G(e,n||r,t)):r}function _(e,t){if("string"==typeof e&&t&&null==t.dateFormat&&(null!=t.places||null!=t.digitSeparator)){const t=Number(e);if(!isNaN(t))return t}return e}function H(e){return null!=e&&"object"==typeof e&&"fieldsIndex"in e&&"geometryType"in e&&"getField"in e&&"load"in e&&"loaded"in e&&"objectIdField"in e&&"spatialReference"in e&&"type"in e&&("feature"===e.type||"scene"===e.type||"subtype-group"===e.type||"subtype-sublayer"===e.type||"sublayer"===e.type)&&"when"in e}function B(e){return null!=e&&"object"==typeof e&&"createQuery"in e&&"queryFeatureCount"in e&&"queryObjectIds"in e&&"queryRelatedFeatures"in e&&"queryRelatedFeaturesCount"in e&&"relationships"in e}function J(e){return H(e)&&B(e)}function K(e){return!(!(e&&"object"==typeof e&&"createQuery"in e&&"getField"in e&&"queryFeatureCount"in e&&"queryFeatures"in e&&"queryObjectIds"in e&&"capabilities"in e&&"fields"in e&&"fieldsIndex"in e&&"type"in e)||"feature"!==e.type&&"subtype-group"!==e.type&&"subtype-sublayer"!==e.type&&"sublayer"!==e.type||!("when"in e))&&("subtype-sublayer"===e.type&&"parent"in e&&e.parent&&"object"==typeof e.parent?"globalIdField"in e.parent:"globalIdField"in e)}function V(e){return!!e&&"object"==typeof e&&"sourceLayer"in e&&J(e.sourceLayer)}function W(e,t){const{fieldInfos:n,fieldName:r,preventPlacesFormatting:l,layer:u,timeZone:s}=t,c=ee(n,r),d=R(u,r);if(c&&!a(r)){const t=d?.type,n=c.format?.dateFormat;if("date"===t||"date-only"===t||"time-only"===t||"timestamp-offset"===t||n)return f(e,{format:n,fieldType:t,timeZoneOptions:{layerTimeZone:u&&"preferredTimeZone"in u?u.preferredTimeZone:null,viewTimeZone:s,datesInUnknownTimezone:!(!u||!("datesInUnknownTimezone"in u))&&!!u.datesInUnknownTimezone}})}const p=c?.format;return"string"==typeof e&&a(r)&&p?X(e,p):"string"==typeof(e=_(e,p))||null==e||null==p?le(e):i(e,l?{...o(p),minimumFractionDigits:0,maximumFractionDigits:20}:o(p))}function X(e,t){return e=e.trim(),/\d{2}-\d{2}/.test(e)?e:e.includes(",")?Y(e,",",", ",t):e.includes(";")?Y(e,";","; ",t):e.includes(" ")?Y(e," "," ",t):i(Number(e),o(t))}function Y(e,t,n,r){return e.trim().split(t).map(e=>i(Number(e),o(r))).join(n)}function ee(e,t){if(e?.length&&t)return e.find(e=>e.fieldName?.toLowerCase()===t.toLowerCase())}function te({fieldName:e,graphic:t,layer:n}){if(ye(e))return null;if(!n||"function"!=typeof n.getFeatureType)return null;const{typeIdField:r}=n;if(!r||e!==r)return null;const i=n.getFeatureType(t);return i?i.name:null}function ne({fieldName:e,value:t,graphic:n,layer:r}){if(ye(e))return null;if(!r||"function"!=typeof r.getFieldDomain)return null;const i=n&&r.getFieldDomain(e,{feature:n,excludeImpliedDomains:has("esri-widget-legacy-field-domain-calculation")});return i&&"coded-value"===i.type?i.getName(t):null}function re(e,t,n,i){const{creatorField:o,creationDateField:a,editorField:l,editDateField:u}=e;if(!t)return;const s=p(i&&"preferredTimeZone"in i?i.preferredTimeZone:null,!(!i||!("datesInUnknownTimezone"in i))&&!!i.datesInUnknownTimezone,n,Z,"date"),f={...Z,...s},c=t[u];if("number"==typeof c){const e=t[l];return{type:"edit",date:r(c,f),user:e}}const d=t[a];if("number"==typeof d){const e=t[o];return{type:"create",date:r(d,f),user:e}}return null}function ie(e,t){const n=new Map;if(!e)return n;for(const r of e){if(!r.fieldName)continue;const e=M(r.fieldName,t);r.fieldName=e,n.set(e.toLowerCase(),r)}return n}function oe(e){const t=[];if(!e)return t;const{fieldInfos:n,content:r}=e;return n&&t.push(...n),r&&Array.isArray(r)?(r.forEach(e=>{if("fields"===e.type){const n=e?.fieldInfos;n&&t.push(...n)}}),t):t}function ae(e){return e.replaceAll(F,e=>`&#${e.charCodeAt(0)};`)}function le(e){return"string"==typeof e?e.replaceAll(w,'<br class="esri-text-new-line" />'):e}function ue(e){const{value:t,fieldName:n,fieldInfos:r,fieldInfoMap:i,layer:o,graphic:a,timeZone:l}=e;if(null==t)return"";const s=ne({fieldName:n,value:t,graphic:a,layer:o});if(s)return s;const d=te({fieldName:n,graphic:a,layer:o});if(d)return d;if(i.get(n.toLowerCase()))return W(t,{fieldInfos:r||Array.from(i.values()),fieldName:n,layer:o,timeZone:l});const p=o?.fieldsIndex?.get(n);return p&&(c(p)||u(p))?f(t,{fieldType:p.type,timeZoneOptions:{layerTimeZone:o&&"preferredTimeZone"in o?o.preferredTimeZone:null,viewTimeZone:l,datesInUnknownTimezone:!(!o||!("datesInUnknownTimezone"in o))&&!!o.datesInUnknownTimezone}}):le(t)}function se({fieldInfos:e,attributes:t,layer:n,graphic:r,fieldInfoMap:i,relatedInfos:o,timeZone:a}){const l={};return o?.forEach(t=>ge({attributes:l,relatedInfo:t,fieldInfoMap:i,fieldInfos:e,layer:n,timeZone:a})),t&&Object.keys(t).forEach(o=>{const u=t[o];l[o]=ue({fieldName:o,fieldInfos:e,fieldInfoMap:i,layer:n,value:u,graphic:r,timeZone:a})}),l}async function fe(e,t){const{layer:n,graphic:r,outFields:i,objectIds:o,returnGeometry:a,spatialReference:l}=e,u=o[0];if("number"!=typeof u&&"string"!=typeof u){const e="Could not query required fields for the specified feature. The feature's ID is invalid.",t={layer:n,graphic:r,objectId:u,requiredFields:i};return m().warn(e,t),null}if(!s(n)?.operations?.supportsQuery){const e="The specified layer cannot be queried. The following fields will not be available.",t={layer:n,graphic:r,requiredFields:i,returnGeometry:a};return m().warn(e,t),null}const f=n.createQuery();f.objectIds=o,f.outFields=i?.length?i:[n.objectIdField],f.returnGeometry=!!a,f.returnZ=!!a,f.returnM=!!a,f.outSpatialReference=l;return(await n.queryFeatures(f,t)).features[0]}async function ce(e){if(!e.expressionInfos?.length)return!1;const t=await d(),{arcadeUtils:{hasGeometryFunctions:n}}=t;return n(e)}async function de(e){if(!e.expressionInfos?.length)return!1;const t=await d(),{arcadeUtils:{requiresTrack:n}}=t;return n(e)}async function pe({graphic:e,popupTemplate:t,layer:n,spatialReference:r},i){if(!n||!t)return;if("function"==typeof n.load&&await n.load(i),!e.attributes)return;const o=n.objectIdField,a=e.attributes[o];if(null==a)return;const u=[a],s=new Set(await t.getRequiredFields(n.fieldsIndex));null==n.timeInfo?.trackIdField||s.has(n.timeInfo.trackIdField)||await de(t)&&s.add(n.timeInfo.trackIdField);const f=l(e,s),c=f?[]:s.has(o)?[...s]:[...s,o],d=t.returnGeometry||await ce(t);if(f&&!d)return;const p=await fe({layer:n,graphic:e,outFields:c,objectIds:u,returnGeometry:d,spatialReference:r},i);p&&(p.geometry&&(e.geometry=p.geometry),p.attributes&&(e.attributes={...e.attributes,...p.attributes}))}function ye(e=""){return!!e&&e.includes(j)}function me(e){return e?`${j}${e.layerId}/${e.fieldName}`:""}function be({attributes:e,graphic:t,relatedInfo:n,fieldInfos:r,fieldInfoMap:i,layer:o,timeZone:a}){e&&t&&n&&Object.keys(t.attributes).forEach(l=>{const u=me({layerId:n.relation.id.toString(),fieldName:l}),s=t.attributes[l];e[u]=ue({fieldName:u,fieldInfos:r,fieldInfoMap:i,layer:o,value:s,graphic:t,timeZone:a})})}function ge({attributes:e,relatedInfo:t,fieldInfoMap:n,fieldInfos:r,layer:i,timeZone:o}){e&&t&&(t.relatedFeatures?.forEach(a=>be({attributes:e,graphic:a,relatedInfo:t,fieldInfoMap:n,fieldInfos:r,layer:i,timeZone:o})),t.relatedStatsFeatures?.forEach(a=>be({attributes:e,graphic:a,relatedInfo:t,fieldInfoMap:n,fieldInfos:r,layer:i,timeZone:o})))}const Ie=e=>{if(!e)return!1;const t=e.toUpperCase();return t.includes("CURRENT_TIMESTAMP")||t.includes("CURRENT_DATE")||t.includes("CURRENT_TIME")},he=({layer:e,method:t,query:n,definitionExpression:r})=>{if(!e.capabilities?.query?.supportsCacheHint||"attachments"===t)return;const i=null!=n.where?n.where:null,o=null!=n.geometry?n.geometry:null;Ie(r)||Ie(i)||"extent"===o?.type||"tile"===n.resultType||(n.cacheHint=!0)},we=({query:e,layer:t,method:n})=>{he({layer:t,method:n,query:e,definitionExpression:`${t.definitionExpression} ${t.serviceDefinitionExpression??""}`})},Fe=({queryPayload:e,layer:t,method:n})=>{he({layer:t,method:n,query:e,definitionExpression:`${t.definitionExpression} ${t.serviceDefinitionExpression??""}`})};function Te(e,t,n){return e&&t&&n?"sublayer"===t.type?Ze({layers:t.layer?.allSublayers,map:e,relatedLayer:t,relationship:n})||Ze({layers:t.layer?.subtables,map:e,relatedLayer:t,relationship:n}):Ze({layers:e.allLayers,map:e,relatedLayer:t,relationship:n})||Ze({layers:e.allTables,map:e,relatedLayer:t,relationship:n}):null}function Ne(e,t){return e&&"utilityNetworks"in e&&t?e.utilityNetworks?.find(e=>e.isUtilityLayer(t)):null}function je(e,t){return e?.allTables.find(e=>"feature"===e.type&&e.layerId===t.id&&e.url===t.layer?.url)}function Ze({map:e,relationship:t,relationship:{relatedTableId:n},relatedLayer:r,layers:i}){if(!i)return null;for(const o of i){if("map-image"===o.type){const n=Ze({layers:o.sublayers,map:e,relatedLayer:r,relationship:t})||Ze({layers:o.subtables,map:e,relatedLayer:r,relationship:t});if(n)return n;continue}if(!J(o))continue;if("sublayer"===r.type){if(o!==r&&o.id===n)return o.isTable?je(e,o):o;continue}const i="scene"===r.type&&r.associatedLayer?r.associatedLayer.url:r.url;if(!i)return null;if("sublayer"!==o.type){if(o!==r&&o.url===i&&o.layerId===n)return o}else if(o!==r&&o.layer?.url===i&&o.id===n)return o.isTable?je(e,o):o}return null}export{le as applyTextFormattingHTML,ie as createFieldInfoMap,Te as findRelatedLayer,Ne as findUtilityNetwork,Q as fixTokens,se as formatAttributes,re as formatEditInfo,W as formatValueToFieldInfo,oe as getAllFieldInfos,ee as getFieldInfo,v as getFieldInfoLabel,M as getFixedFieldName,k as getFixedFieldNames,L as getSourceLayer,q as graphicCallback,ae as htmlEntities,K as isAssociatedFeatureSupportedLayer,E as isExpressionField,H as isFeatureSupportedLayer,V as isGraphicForRelatableFeatureSupportedLayer,J as isRelatableFeatureSupportedLayer,B as isRelatableLayer,ye as isRelatedField,we as preLayerQueryCallback,Fe as preRequestCallback,fe as querySourceLayer,pe as queryUpdatedFeature,x as shouldOpenInNewTab,z as substituteAttributes,D as substituteFieldsInLinksAndAttributes};
|