@arcgis/core 4.28.0-next.20230911 → 4.28.0-next.20230913
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/arcade/Feature.js +1 -1
- package/arcade/arcadeTimeUtils.js +1 -1
- package/arcade/executionError.js +1 -1
- package/arcade/featureSetUtils.js +1 -1
- package/arcade/featureset/actions/Adapted.js +1 -1
- package/arcade/featureset/actions/GroupBy.js +1 -1
- package/arcade/featureset/support/FeatureSet.js +1 -1
- package/arcade/featureset/support/errorsupport.js +1 -1
- package/arcade/functions/featuresetbase.js +1 -1
- package/arcade/functions/featuresetstats.js +1 -1
- package/arcade/functions/string.js +1 -1
- package/arcade.js +1 -1
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/0920312e3c7b63c2e253.js +1 -0
- package/assets/esri/core/workers/chunks/0cb007ab5db0a2a598ec.js +1 -0
- package/assets/esri/core/workers/chunks/0cc61f1b2c0473ded5c2.js +1 -0
- package/assets/esri/core/workers/chunks/0f804e3f888cb4998f46.js +1 -0
- package/assets/esri/core/workers/chunks/189dd81cf95bd8417ee3.js +1 -0
- package/assets/esri/core/workers/chunks/1a723bb4a341f645e5fe.js +1 -0
- package/assets/esri/core/workers/chunks/24c717492ea1b35310d8.js +1 -0
- package/assets/esri/core/workers/chunks/{3ce73dd4113dbc7d11de.js → 2eb58dc339b2bb03d9e3.js} +1 -1
- package/assets/esri/core/workers/chunks/{38c07a8574352a7f2f6d.js → 2ff0dbd5eb7ca57bb7fc.js} +1 -1
- package/assets/esri/core/workers/chunks/{768f3db2705fa9e57641.js → 49dfdc0463450491df9d.js} +1 -1
- package/assets/esri/core/workers/chunks/650a317b6dc245a7060f.js +1 -0
- package/assets/esri/core/workers/chunks/{56ed099745360888604e.js → 67f01c71280fa0759742.js} +1 -1
- package/assets/esri/core/workers/chunks/{f62842807744bdfaced7.js → 67fab13f56b340076763.js} +1 -1
- package/assets/esri/core/workers/chunks/6d94b358e8d1cf79bba3.js +1 -0
- package/assets/esri/core/workers/chunks/718607d7a3b33fc33b0a.js +1 -0
- package/assets/esri/core/workers/chunks/{4c63d6b9460aa6ae9843.js → 860417f4138f53d315ba.js} +2 -2
- package/assets/esri/core/workers/chunks/8aa7e994b74f66522c37.js +1 -0
- package/assets/esri/core/workers/chunks/9fa485b04b997b0a5509.js +1 -0
- package/assets/esri/core/workers/chunks/a047fcf3c7307a69b63c.js +1 -0
- package/assets/esri/core/workers/chunks/a753d9874801cd448946.js +1 -0
- package/assets/esri/core/workers/chunks/c51233ad51823cb98c35.js +1 -0
- package/assets/esri/core/workers/chunks/c61f20d91a5c432b07dc.js +1 -0
- package/assets/esri/core/workers/chunks/d3d11242e5af57ba77f4.js +1 -0
- package/assets/esri/core/workers/chunks/dbf343d1fb746f99bb6e.js +1 -0
- package/assets/esri/core/workers/chunks/{271ec1d1666bf6dc3dda.js → dc74b4ec85e8e3de5b27.js} +1 -1
- package/assets/esri/core/workers/chunks/e8a8791d765ab6c450dd.js +1 -0
- package/assets/esri/core/workers/chunks/{5fe7b5665710ec6d3046.js → eb0d1c5c96f735c162d3.js} +1 -1
- package/assets/esri/themes/base/widgets/_Sketch.scss +0 -5
- package/assets/esri/themes/base/widgets/_SketchTooltipControls.scss +0 -5
- package/assets/esri/themes/dark/main.css +1 -1
- package/assets/esri/themes/light/main.css +1 -1
- package/assets/esri/themes/light/view.css +1 -1
- package/chunks/HUDMaterial.glsl.js +38 -45
- package/chunks/languageUtils.js +1 -1
- package/core/promiseUtils.js +1 -1
- package/core/sql/AggregateFunctions.js +1 -1
- package/core/sql/DateOnly.js +1 -1
- package/core/sql/SqlTimestampOffset.js +1 -1
- package/core/sql/TimeOnly.js +1 -1
- package/core/sql/WhereClause.js +1 -1
- package/core/sql/WhereGrammar.js +1 -1
- package/core/sql/sqlCompareUtils.js +1 -1
- package/geometry/GeometryCursor.js +1 -1
- package/geometry/Mesh.js +1 -1
- package/geometry/support/labelPoint.js +1 -1
- package/geometry/support/meshUtils/bounds.js +1 -1
- package/geometry/support/meshUtils/georeference.js +1 -1
- package/interfaces.d.ts +190 -144
- package/layers/ImageryLayer.js +1 -1
- package/layers/SceneLayer.js +1 -1
- package/layers/graphics/controllers/FeatureTileController3D.js +1 -1
- package/layers/graphics/controllers/I3SOnDemandController.js +1 -1
- package/layers/graphics/sources/csv/csv.js +1 -1
- package/layers/support/FetchAssociatedFeatureLayer.js +1 -1
- package/layers/support/TilemapCache.js +1 -1
- package/layers/support/fieldUtils.js +1 -1
- package/layers/support/rasterDatasets/BaseRaster.js +1 -1
- package/layers/support/wmsUtils.js +1 -1
- package/layers/video/VideoController.js +1 -1
- package/package.json +3 -3
- package/smartMapping/heuristics/sizeRange.js +1 -1
- package/smartMapping/labels/bins.js +1 -1
- package/smartMapping/labels/clusters.js +1 -1
- package/smartMapping/labels/support/utils.js +1 -1
- package/smartMapping/popup/support/clusterUtils.js +1 -1
- package/smartMapping/support/clusterUtils.js +1 -1
- package/support/revision.js +1 -1
- package/views/2d/engine/webgl/DisplayId.js +1 -1
- package/views/2d/engine/webgl/Utils.js +1 -1
- package/views/3d/analysis/AreaMeasurement/support/AreaMeasurementVisualization.js +1 -1
- package/views/3d/analysis/AreaMeasurement/support/MeasurementData.js +1 -1
- package/views/3d/analysis/Dimension/DimensionVisualization.js +1 -1
- package/views/3d/analysis/Dimension/LengthDimensionSubTool.js +1 -1
- package/views/3d/analysis/Dimension/LengthDimensionVisualization.js +1 -1
- package/views/3d/analysis/Dimension/lengthDimensionManipulatorUtils.js +1 -1
- package/views/3d/analysis/Dimension/settings.js +1 -1
- package/views/3d/interactive/Manipulator3D.js +1 -1
- package/views/3d/interactive/editingTools/originGraphicVisualElementUtils.js +1 -1
- package/views/3d/interactive/editingTools/reshapeGraphic/ReshapeOperation.js +1 -1
- package/views/3d/interactive/measurementTools/areaMeasurement3D/AreaMeasurement3DTool.js +1 -1
- package/views/3d/layers/I3SMeshView3D.js +1 -1
- package/views/3d/layers/I3SMeshWorkerHandle.js +1 -1
- package/views/3d/layers/ImageryTileLayerView3D.js +1 -1
- package/views/3d/layers/SceneLayerWorker.js +1 -1
- package/views/3d/layers/i3s/I3SClientNodeLoader.js +1 -1
- package/views/3d/webgl-engine/core/FBOCache.js +1 -1
- package/views/3d/webgl-engine/lib/OffscreenRendering.js +1 -1
- package/views/3d/webgl-engine/materials/HUDMaterial.js +1 -1
- package/views/3d/webgl-engine/shaders/HUDMaterialTechniqueConfiguration.js +1 -1
- package/views/ToolViewManager.js +1 -1
- package/views/View.js +1 -1
- package/views/animation/easing.js +1 -1
- package/views/webgl/FramebufferObject.js +1 -1
- package/views/webgl/RenderingContext.js +1 -1
- package/views/webgl/enums.js +1 -1
- package/views/webgl/renderState.js +1 -1
- package/widgets/BasemapGallery/BasemapGalleryViewModel.js +1 -1
- package/widgets/Feature/FeatureMedia.js +1 -1
- package/widgets/FeatureForm.js +1 -1
- package/widgets/Features.js +1 -1
- package/widgets/Search/SearchViewModel.js +1 -1
- package/widgets/support/SketchTooltipControls/SketchTooltipControlsViewModel.js +1 -1
- package/widgets/support/SketchTooltipControls.js +1 -1
- package/widgets/support/SnappingControls.js +1 -1
- package/assets/esri/core/workers/chunks/055575ed2ab78be0bdb2.js +0 -1
- package/assets/esri/core/workers/chunks/0ee90a0b4d09a56c0d48.js +0 -1
- package/assets/esri/core/workers/chunks/15056f91d87f11b00bcc.js +0 -1
- package/assets/esri/core/workers/chunks/344e40934c98d6fe66ae.js +0 -1
- package/assets/esri/core/workers/chunks/558049fcac3a82a093fc.js +0 -1
- package/assets/esri/core/workers/chunks/5c41eb67d19b8710118a.js +0 -1
- package/assets/esri/core/workers/chunks/5d183ac1a8b68ba9c656.js +0 -1
- package/assets/esri/core/workers/chunks/610d4a5d2511fa81460e.js +0 -1
- package/assets/esri/core/workers/chunks/6755bb1f2a6575a8e082.js +0 -1
- package/assets/esri/core/workers/chunks/84173936b309712ba9b3.js +0 -1
- package/assets/esri/core/workers/chunks/877302d6e39a0d530aab.js +0 -1
- package/assets/esri/core/workers/chunks/a07dc782e69111e2eeaf.js +0 -1
- package/assets/esri/core/workers/chunks/b825019841247d173072.js +0 -1
- package/assets/esri/core/workers/chunks/bed1bc13b168fae46404.js +0 -1
- package/assets/esri/core/workers/chunks/c8dd21a332559c99815c.js +0 -1
- package/assets/esri/core/workers/chunks/ccc3564e76c0ec5c0228.js +0 -1
- package/assets/esri/core/workers/chunks/d0a81c7ec8a84eeadd31.js +0 -1
- package/assets/esri/core/workers/chunks/e7a852b319c1d89eddc5.js +0 -1
- package/assets/esri/core/workers/chunks/ebde11fdccb437954ce7.js +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arcgis/core",
|
|
3
|
-
"version": "4.28.0-next.
|
|
3
|
+
"version": "4.28.0-next.20230913",
|
|
4
4
|
"homepage": "https://js.arcgis.com",
|
|
5
5
|
"description": "ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API",
|
|
6
6
|
"keywords": [
|
|
@@ -29,9 +29,9 @@
|
|
|
29
29
|
"@esri/calcite-colors": "~6.1.0",
|
|
30
30
|
"@esri/calcite-components": "^1.7.0",
|
|
31
31
|
"@popperjs/core": "~2.11.8",
|
|
32
|
-
"@zip.js/zip.js": "~2.7.
|
|
32
|
+
"@zip.js/zip.js": "~2.7.29",
|
|
33
33
|
"focus-trap": "~7.5.2",
|
|
34
|
-
"luxon": "~3.4.
|
|
34
|
+
"luxon": "~3.4.3",
|
|
35
35
|
"sortablejs": "~1.15.0"
|
|
36
36
|
},
|
|
37
37
|
"type": "module"
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.28/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import"../../core/has.js";import e from"../../core/Error.js";import{px2pt as
|
|
5
|
+
import"../../core/has.js";import e from"../../core/Error.js";import{px2pt as l}from"../../core/screenUtils.js";import{getScale as s}from"../../geometry/support/scaleUtils.js";import n from"../../renderers/visualVariables/SizeVariable.js";import i from"./scaleRange.js";import{verifyBinningParams as a}from"../support/binningUtils.js";import{binningCapableLayerTypes as t,featureCapableLayerTypes as o,createLayerAdapter as r,getLayerTypeLabels as c}from"../support/adapters/support/layerUtils.js";const u=1e8,p=1128.497176,m=591657527.591555,v=[10,8,4,2],f=[100,100,60,30],w=[2,1,.75,.5],g=[32,18,12,6],S=[{level:0,resolution:156543.03392800014,scale:591657527.591555},{level:1,resolution:78271.51696399994,scale:295828763.795777},{level:2,resolution:39135.75848200009,scale:147914381.897889},{level:3,resolution:19567.87924099992,scale:73957190.948944},{level:4,resolution:9783.93962049996,scale:36978595.474472},{level:5,resolution:4891.96981024998,scale:18489297.737236},{level:6,resolution:2445.98490512499,scale:9244648.868618},{level:7,resolution:1222.992452562495,scale:4622324.434309},{level:8,resolution:611.4962262813797,scale:2311162.217155},{level:9,resolution:305.74811314055756,scale:1155581.108577},{level:10,resolution:152.87405657041106,scale:577790.554289},{level:11,resolution:76.43702828507324,scale:288895.277144},{level:12,resolution:38.21851414253662,scale:144447.638572},{level:13,resolution:19.10925707126831,scale:72223.819286},{level:14,resolution:9.554628535634155,scale:36111.909643},{level:15,resolution:4.77731426794937,scale:18055.954822},{level:16,resolution:2.388657133974685,scale:9027.977411},{level:17,resolution:1.1943285668550503,scale:4513.988705},{level:18,resolution:.5971642835598172,scale:2256.994353},{level:19,resolution:.29858214164761665,scale:1128.497176}];async function h(l){const{view:s}=l;if(!(l&&s&&l.layer))throw new e("size-range:missing-parameters","'view' and 'layer' parameters are required");l.forBinning&&a(l,"size-range");const{layer:n,...i}=l,u=l.forBinning?t:o,p=r(n,u,l.forBinning);if(!p)throw new e("size-range:invalid-parameters","'layer' must be one of these types: "+c(u).join(", "));const m={layerAdapter:p,...i,view:s};await s.when();const v=null!=m.signal?{signal:m.signal}:null;await p.load(v);const f=p.geometryType;if("point"!==f&&"multipoint"!==f&&"polyline"!==f&&"polygon"!==f)throw new e("size-range:not-supported",`sizeRange is not supported for geometryType: ${f}`);return m}function x(e,l){const s=Math.ceil(e/l);let n=Math.ceil(s/4);n<4?n=4:n>16&&(n=16);const i=5*n;return{min:n,max:i<50?50:i}}function y(l,s){const{view:n}=l;if(!n)throw new e("scale-range:invalid-parameters","'view' is required");const i=s.minScale||u,a=n.constraints&&"effectiveLODs"in n.constraints&&n.constraints.effectiveLODs||S,t=[];for(let e=0;e<a.length;e++){if(a[e].scale>i)continue;const l=Number(e),s=[l-3,l,l+3,l+6];for(const e of s)e>-1&&e<a.length&&t.push(a[e].scale);break}return t.sort(((e,l)=>e-l))}function z(l,n){const{view:i,layerAdapter:a}=l;if(!i)throw new e("scale-range:invalid-parameters","'view' is required");const t=a.fullExtent,o=a.minScale||p,r=a.maxScale||m,c=n.minScale||0,u=n.maxScale||0;let v=null!=t?s(i,t):0;v=v<o&&v>r?v:0;return{scales:[o,r,c,u,v].map(Math.round).sort(((e,l)=>e-l)).filter(((e,l,s)=>!!e&&s.indexOf(e)===l)).filter(((e,l,s)=>!l||Math.abs(e-s[l-1])>5)),fullExtentScale:v}}function d(s,i){const{minScale:a,maxScale:t}=i,o=y(s,{minScale:a,maxScale:t});if(!o.length)throw new e("scale-range:insufficient-info","not enough scale values");return{minSize:new n({valueExpression:"$view.scale",stops:o.map(((e,s)=>({value:e,size:l(v[s])})))}),maxSize:new n({valueExpression:"$view.scale",stops:o.map(((e,s)=>({value:e,size:l(f[s])})))})}}function E(s,i){const{minScale:a,maxScale:t}=i,o=y(s,{minScale:a,maxScale:t});if(!o.length)throw new e("scale-range:insufficient-info","not enough scale values");return{minSize:new n({valueExpression:"$view.scale",stops:o.map(((e,s)=>({value:e,size:l(w[s])})))}),maxSize:new n({valueExpression:"$view.scale",stops:o.map(((e,s)=>({value:e,size:l(g[s])})))})}}function j(s,i){const{spatialStatistics:a,minScale:t,maxScale:o}=i;if(!("avgSize"in a)||!a.avgSize)throw new e("size-range:insufficient-info","average polygon size is invalid");const r=a.avgSize,{view:c}=s;if(!c)throw new e("scale-range:invalid-parameters","'view' is required");const{resolution:u,scale:p}=c,m=u/p,{scales:v,fullExtentScale:f}=z(s,{minScale:t,maxScale:o}),w=[],g=[];v.forEach(((e,s)=>{const{min:n,max:i}=x(r,m*e),a=v.indexOf(f),t=a>-1&&s>a?2:1;w.push({value:e,size:l(n/t)}),g.push({value:e,size:l(i/t)})}));return{minSize:new n({valueExpression:"$view.scale",stops:w}),maxSize:new n({valueExpression:"$view.scale",stops:g})}}async function b(e){const l=await h(e),{view:s,layerAdapter:n,signal:a}=l,t=await i({layer:n,view:s,signal:a});switch(n.geometryType){case"point":case"multipoint":return d(l,t);case"polyline":return E(l,t);case"polygon":return j(l,t);case"mesh":case"multipatch":return null}return null}export{b as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.28/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import"../../intl.js";import e from"../../core/Error.js";import{
|
|
5
|
+
import"../../intl.js";import e from"../../core/Error.js";import{getAggregateFieldInfo as r,createLabelExpressionForAggregateField as n,createLabelClass as t}from"./support/utils.js";import{aggregateCountField as i}from"../support/binningUtils.js";import{fetchMessageBundle as a}from"../../intl/messages.js";async function s(r){const{layer:n,renderer:t}=r;if(await n.load(),"binning"!==n.featureReduction?.type)throw new e("bins-label-schemes:invalid-parameters","featureReduction type of the layer is not valid");const i=t||n.featureReduction.renderer;if(!i)throw new e("bins-label-schemes:invalid-parameters","'renderer' is not valid");return{layer:n,renderer:i}}async function o(e,i,a,s){const o=r(e,i);if(!o)return null;const l=n(i,a,o,s);return{name:`binning-${e}`,labelingInfo:[t(l,!0)],fieldName:e}}function l(e){let r=[];const n=e.featureReduction;return"fields"in n&&(r=n.fields.map((e=>e.name))),r}async function c(r){const[{renderer:n,layer:t},c]=await Promise.all([s(r),a("esri/smartMapping/t9n/smartMapping")]),m=c.clusters.predominantNoneValue;if(r.field){const i=await o(r.field,t,n,m);if(!i)throw new e("bins-label-schemes:invalid-parameters","'field' is not a valid aggregate field");return{primaryScheme:i,secondarySchemes:[]}}const f=await o(i,t),d=[],u=l(t).filter((e=>e.toLowerCase()!==i.toLowerCase()));for(const e of u){const r=await o(e,t,n,m);r&&d.push(r)}return{primaryScheme:f,secondarySchemes:d}}export{c as getLabelSchemes};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.28/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import e from"../../core/Error.js";import{fetchMessageBundle as t}from"../../intl/messages.js";import r from"../heuristics/clusterMinSize.js";import{
|
|
5
|
+
import e from"../../core/Error.js";import{fetchMessageBundle as t}from"../../intl/messages.js";import r from"../heuristics/clusterMinSize.js";import{getAggregateFieldInfo as s,createLabelExpressionForAggregateField as n,createLabelClass as i,createNumericLabelExpression as a}from"./support/utils.js";import{getStatisticInfos as o,getClusterField as l,clusterCountField as c,getClusterFieldHash as u,getPredominantTypeExpression as m}from"../support/clusterUtils.js";import{isClusterCompatibleRenderer as f}from"../../views/2d/layers/support/clusterUtils.js";async function p(t){const{layer:r,renderer:s,view:n}=t;await Promise.all([r.load(),n.when()]);const i=s||r.renderer;if(!f(i))throw new e("clusters-label-schemes:invalid-parameters","'renderer' is not valid");return{layer:r,renderer:i,view:n}}function d(e,t,r){const s="unique-value"===e.type?e.uniqueValueInfos??[]:[];return m(s,t,r)}async function w(e){const{renderer:t,view:s,statInfo:n}=e,o=n?.statisticType,m=n?l(n.attributeInfo,o):c,f="mode"===o?d(t,m,e.noneValueLabel):a(m),p=i(f);return{name:n?`clusters-${o}-${u(m,o)}`:"clusters-count",labelingInfo:[p],clusterMinSize:await r(p.symbol,s),fieldName:m}}function v(e){const t=new Map;for(const r of e)"size"===r.attributeInfo.vvType?t.set(r.statisticHash,r):t.has(r.statisticHash)||t.set(r.statisticHash,r);return[...t.values()]}async function y(a){const[{renderer:l,layer:c,view:u},m]=await Promise.all([p(a),t("esri/smartMapping/t9n/smartMapping")]),f=m.clusters.predominantNoneValue;if(!l)return null;let d=null;const y=[];if(a.field){const t=s(a.field,c);if(!t)throw new e("clusters-label-schemes:invalid-parameters","'field' is not a valid aggregate field");const{name:o}=t,m=n(c,l,t,f),p=i(m);return d={name:`clusters-${o}`,labelingInfo:[p],clusterMinSize:await r(p.symbol,u),fieldName:o},{primaryScheme:d,secondarySchemes:y}}const h=v(o(c,l,!1));for(const e of h){const t=await w({renderer:l,view:u,statInfo:e,noneValueLabel:f});"size"===e.attributeInfo.vvType?d=t:y.push(t)}const b=await w({renderer:l,view:u});return d?y.unshift(b):d=b,{primaryScheme:d,secondarySchemes:y}}export{y as getLabelSchemes};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.28/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import"../../../symbols.js";import e from"../../../layers/support/LabelClass.js";import n from"../../../layers/support/LabelExpressionInfo.js";import o from"../../../renderers/support/UniqueValueInfo.js";import{getPredominantTypeExpression as t}from"../../support/clusterUtils.js";import l from"../../../symbols/TextSymbol.js";function r(e){return`\n $feature["${e}"];\n var value = $feature["${e}"];\n var num = Count(Text(Round(value)));\n var label = When(\n num < 4, Text(value, "#.#"),\n num == 4, Text(value / Pow(10, 3), "#.0k"),\n num <= 6, Text(value / Pow(10, 3), "#k"),\n num == 7, Text(value / Pow(10, 6), "#.0m"),\n num > 7, Text(value / Pow(10, 6), "#m"),\n Text(value, "#,###")\n );\n return label;\n `}function
|
|
5
|
+
import"../../../symbols.js";import e from"../../../layers/support/LabelClass.js";import n from"../../../layers/support/LabelExpressionInfo.js";import o from"../../../renderers/support/UniqueValueInfo.js";import{getPredominantTypeExpression as t}from"../../support/clusterUtils.js";import l from"../../../symbols/TextSymbol.js";function r(e,n){const o=n.featureReduction;if("fields"in o)for(const t of o.fields)if(t.name.toLowerCase()===e.toLowerCase())return t;return null}function a(e){return`\n $feature["${e}"];\n var value = $feature["${e}"];\n var num = Count(Text(Round(value)));\n var label = When(\n num < 4, Text(value, "#.#"),\n num == 4, Text(value / Pow(10, 3), "#.0k"),\n num <= 6, Text(value / Pow(10, 3), "#k"),\n num == 7, Text(value / Pow(10, 6), "#.0m"),\n num > 7, Text(value / Pow(10, 6), "#m"),\n Text(value, "#,###")\n );\n return label;\n `}function u(e,n,l,r){const u=l.name;if("mode"===l.statisticType){const a="getFieldDomain"in e?e.getFieldDomain(l.onStatisticField):null;let s=null;return"coded-value"===a?.type?s=a.codedValues.map((e=>new o({value:e.code,label:e.name}))):"unique-value"===n?.type&&"string"==typeof n.field&&n.field.toLowerCase()===u.toLowerCase()&&(s=(n.uniqueValueInfos??[]).map((e=>e.clone()))),s?t(s,u,r):`Text($feature["${u}"])`}return a(u)}function s(o,t=!1){const r=new l({haloColor:"#373837",haloSize:"1px",color:"#f0f0f0",font:{family:"Noto Sans",size:"12px",weight:"bold"}});return new e({symbol:r,deconflictionStrategy:"none",labelPlacement:t?"always-horizontal":"center-center",labelExpressionInfo:new n({expression:o})})}export{s as createLabelClass,u as createLabelExpressionForAggregateField,a as createNumericLabelExpression,r as getAggregateFieldInfo};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.28/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{substitute as e}from"../../../intl/substitute.js";import{numericTypes as t}from"../../../layers/support/fieldUtils.js";import"../../../popup/content/AttachmentsContent.js";import"../../../popup/content/Content.js";import"../../../popup/content/CustomContent.js";import"../../../popup/content/ExpressionContent.js";import"../../../popup/content/FieldsContent.js";import"../../../popup/content/MediaContent.js";import"../../../popup/content/RelationshipContent.js";import n from"../../../popup/content/TextContent.js";import o from"../../../popup/ExpressionInfo.js";import s from"../../../popup/FieldInfo.js";import i from"../../../popup/support/FieldInfoFormat.js";import{getFieldAndExpressionInfos as r,getContentFromFieldInfos as l}from"./utils.js";import{getStatisticInfos as p,getClusterField as u,getPredominantTypeExpression as a,clusterCountField as
|
|
5
|
+
import{substitute as e}from"../../../intl/substitute.js";import{numericTypes as t}from"../../../layers/support/fieldUtils.js";import"../../../popup/content/AttachmentsContent.js";import"../../../popup/content/Content.js";import"../../../popup/content/CustomContent.js";import"../../../popup/content/ExpressionContent.js";import"../../../popup/content/FieldsContent.js";import"../../../popup/content/MediaContent.js";import"../../../popup/content/RelationshipContent.js";import n from"../../../popup/content/TextContent.js";import o from"../../../popup/ExpressionInfo.js";import s from"../../../popup/FieldInfo.js";import i from"../../../popup/support/FieldInfoFormat.js";import{getFieldAndExpressionInfos as r,getContentFromFieldInfos as l}from"./utils.js";import{getStatisticInfos as p,getClusterField as u,getPredominantTypeExpression as a,clusterCountField as m}from"../../support/clusterUtils.js";import{isClusterCompatibleRenderer as f}from"../../../views/2d/layers/support/clusterUtils.js";function d(e){const{fieldName:n,label:o,type:r}=e,l=null!=r&&t.includes(r),p=new s({fieldName:n,label:o,visible:!0,format:l?{places:"integer"===r||"small-integer"===r?0:2,digitSeparator:!0}:null});return"date"===r&&(p.format=new i({dateFormat:"short-date-short-time"})),p}function c(e,t){const n=e?t.getField(e):null;return null!=n?n.alias||n.name:void 0}function y(t,n,o){const{attributeInfo:s,statisticType:i}=n,{field:r,normalizationField:l}=s;let p,u="";if("avg"===i?p=l?o.clusters.avgNormFieldLabel:o.clusters.avgFieldLabel:"mode"===i&&(p=o.clusters.predominantFieldLabel),p){const n=s.valueExpression?s.valueExpressionTitle:c(r,t),o=l&&c(l,t);u=e(p,{fieldLabel:n||"",normFieldLabel:o||""})}return u}function F(t,n,o,s){const{attributeInfo:i,statisticType:r}=n,{field:l,normalizationField:p}=i;let u,a="";if("avg"===r?u=p?s.clusters.avgNormFieldSummary:s.clusters.avgFieldSummary:"mode"===r&&(u=s.clusters.predominantFieldSummary),u){const n=i.valueExpression?i.valueExpressionTitle:c(l,t),s=p&&c(p,t);a=e(u,{fieldLabel:n||"",normFieldLabel:s||"",fieldValue:"{"+o+"}"})}return a}function I(t){return{fieldInfo:d({fieldName:m,label:t.clusters.numFeatures,type:"integer"}),fieldSummary:new n({text:e(t.clusters.countSummary,{count:`{${m}}`})})}}async function b(e,t,s){if(!f(t))return null;const i=p(e,t),r=s.clusters.predominantNoneValue,l="unique-value"===t.type?t.uniqueValueInfos??[]:[],{fieldInfo:m,fieldSummary:c}=I(s),b=[c],x=[m],j=[];for(const p of i){const{statisticType:t,attributeInfo:i}=p,m=u(i,t),f=y(e,p,s);if("avg"===t)b.push(new n({text:F(e,p,m,s)})),x.push(d({fieldName:m,label:f,type:"double"}));else if("mode"===t){const t=`expression/${m}`;b.push(new n({text:F(e,p,t,s)})),j.push(new o({name:m,title:f,returnType:"string",expression:a(l,m,r)})),x.push(d({fieldName:t}))}}return{fieldInfos:x,expressionInfos:j,content:b}}async function x(e,t,n){if(!f(t))return null;const{fieldInfo:o,fieldSummary:s}=I(n),i=[s],p=[o],u=[],{fieldInfos:a,expressionInfos:m}=await r({renderer:t,layer:e,isFeatureReduction:!0}),d=await l(e,{fieldInfos:a,expressionInfos:m},!0);return i.push(...d),p.push(...a),u.push(...m),{fieldInfos:p,expressionInfos:u,content:i}}export{b as getContentAndInfos,x as getContentAndInfosForPieChart};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.28/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{unique as n}from"../../core/arrayUtils.js";import{createMD5Hash as e}from"../../core/MD5.js";import{isValidNumber as i}from"../../renderers/visualVariables/support/sizeVariableUtils.js";import{getPrimaryVisualVariables as t}from"../popup/support/utils.js";import{getNormalizationType as o}from"./utils.js";const l="cluster_count";function r(n,e){return n.split(`cluster_${e}_`).pop()}function a(n){if(!n)return null;const{field:e,valueExpression:t,normalizationField:l,normalizationType:r,normalizationTotal:a}=n;let s=null;if(t)s=t;else if(e){const n=o({normalizationType:r,normalizationField:l,normalizationTotal:a});if(n){const t=n.toLowerCase();if(s=e.toLowerCase()+",norm:"+t,l)s+=","+l.toLowerCase();else if("percent-of-total"===t){let n=a;i(n)&&0!==n||(n=null),s+=","+n}}}return s}function s(n){return e(n)}function u(n,e){const i=a(n);return`${e}_${null!=i?s(i):n.field}`}function p(n,e){return`cluster_${u(n,e)}`}function f(n,e){const i=e.getField(n);return i&&i.type}function c(n,e){const i="field"in e?e.field:null,t=i?f(i,n):null;return{field:i,fieldType:null!=t?t:null,valueExpression:"valueExpression"in e?e.valueExpression:null,valueExpressionTitle:"valueExpressionTitle"in e?e.valueExpressionTitle:null,normalizationField:"normalizationField"in e?e.normalizationField:null,normalizationType:"normalizationType"in e?e.normalizationType:null,normalizationTotal:"normalizationTotal"in e?e.normalizationTotal:null}}function m(n,e){const i="rotation"===e.type?e.rotationType:null,t=e.legendOptions&&e.legendOptions.title,o=e.field,l=o?f(o,n):null;return{field:o,fieldType:null!=l?l:null,rotationType:i,valueExpression:e.valueExpression,valueExpressionTitle:e.valueExpressionTitle||e.valueExpression&&t,normalizationField:"normalizationField"in e?e.normalizationField:null,vvType:e.type}}function v(n){return n.map((n=>`{\n "value": "${String(n.value)}",\n "label": "${T(String(n.label))}"\n }`))}function T(n){return n?n.replaceAll('"','\\"'):""}function d(n,e,i){return`\n var uvInfos = [${v(n).join(", ")}];\n var predominantType = Text($feature["${e}"]);\n var label = "${T(i)}";\n\n for (var i = 0; i < Count(uvInfos); i++) {\n if (uvInfos[i].value == predominantType) {\n label = uvInfos[i].label;\n break;\n }\n }\n\n return label;\n `}function y(n,e){const i=[u(n,e)];return"date"===n.fieldType&&i.push(n.fieldType.toLowerCase()),n.rotationType&&i.push(n.rotationType.toLowerCase()),i.join("_")}function z(n,e){return{statisticHash:y(n,e),attributeInfo:n,statisticType:e}}function x(e,i,o=!0){const l=[],r=c(e,i);"class-breaks"===i.type?l.push(z(r,"avg")):"unique-value"===i.type&&l.push(z(r,"
|
|
5
|
+
import{unique as n}from"../../core/arrayUtils.js";import{createMD5Hash as e}from"../../core/MD5.js";import{isValidNumber as i}from"../../renderers/visualVariables/support/sizeVariableUtils.js";import{getPrimaryVisualVariables as t}from"../popup/support/utils.js";import{getNormalizationType as o}from"./utils.js";const l="cluster_count";function r(n,e){return n.split(`cluster_${e}_`).pop()}function a(n){if(!n)return null;const{field:e,valueExpression:t,normalizationField:l,normalizationType:r,normalizationTotal:a}=n;let s=null;if(t)s=t;else if(e){const n=o({normalizationType:r,normalizationField:l,normalizationTotal:a});if(n){const t=n.toLowerCase();if(s=e.toLowerCase()+",norm:"+t,l)s+=","+l.toLowerCase();else if("percent-of-total"===t){let n=a;i(n)&&0!==n||(n=null),s+=","+n}}}return s}function s(n){return e(n)}function u(n,e){const i=a(n);return`${e}_${null!=i?s(i):n.field}`}function p(n,e){return`cluster_${u(n,e)}`}function f(n,e){const i=e.getField(n);return i&&i.type}function c(n,e){const i="field"in e?e.field:null,t=i?f(i,n):null;return{field:i,fieldType:null!=t?t:null,valueExpression:"valueExpression"in e?e.valueExpression:null,valueExpressionTitle:"valueExpressionTitle"in e?e.valueExpressionTitle:null,normalizationField:"normalizationField"in e?e.normalizationField:null,normalizationType:"normalizationType"in e?e.normalizationType:null,normalizationTotal:"normalizationTotal"in e?e.normalizationTotal:null}}function m(n,e){const i="rotation"===e.type?e.rotationType:null,t=e.legendOptions&&e.legendOptions.title,o=e.field,l=o?f(o,n):null;return{field:o,fieldType:null!=l?l:null,rotationType:i,valueExpression:e.valueExpression,valueExpressionTitle:e.valueExpressionTitle||e.valueExpression&&t,normalizationField:"normalizationField"in e?e.normalizationField:null,vvType:e.type}}function v(n){return n.map((n=>`{\n "value": "${String(n.value)}",\n "label": "${T(String(n.label))}"\n }`))}function T(n){return n?n.replaceAll('"','\\"'):""}function d(n,e,i){return`\n var uvInfos = [${v(n).join(", ")}];\n var predominantType = Text($feature["${e}"]);\n var label = "${T(i)}";\n\n for (var i = 0; i < Count(uvInfos); i++) {\n if (uvInfos[i].value == predominantType) {\n label = uvInfos[i].label;\n break;\n }\n }\n\n return label;\n `}function y(n,e){const i=[u(n,e)];return"date"===n.fieldType&&i.push(n.fieldType.toLowerCase()),n.rotationType&&i.push(n.rotationType.toLowerCase()),i.join("_")}function z(n,e){return{statisticHash:y(n,e),attributeInfo:n,statisticType:e}}function x(e,i,o=!0){const l=[],r=c(e,i);"class-breaks"===i.type?l.push(z(r,"avg")):"unique-value"===i.type&&l.push(z(r,"mode"));const a=t(i);for(const n of a){const i=m(e,n);l.push(z(i,"avg"))}return o?n(l,((n,e)=>n.statisticHash===e.statisticHash)):l}export{l as clusterCountField,p as getClusterField,r as getClusterFieldHash,d as getPredominantTypeExpression,c as getRendererAttributeInfo,u as getStatisticId,z as getStatisticInfo,x as getStatisticInfos,m as getVariableAttributeInfo};
|
package/support/revision.js
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.28/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
const
|
|
5
|
+
const a="20230913",e="1a1a887651a75a8ef744367d94f4aa732e521e9b";export{a as buildDate,e as commitHash};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.28/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
const n=8388607,t=8388608,r=254,o=255,u=0,c=1,e=n=>(n&t)>>>23,f=t=>t&n,i=n=>e(n)===c?r:o;function p(n){return e(n)===c}function s(n,r){return((r?t:0)|n)>>>0}export{r as aggregateValidFiltersMask,s as createDisplayId,n as displayIdTexelMask,c as displayIdTypeAggregate,u as displayIdTypeFeature,t as displayIdTypeMask,i as getDisplayIdFilterMask,f as getDisplayIdTexel,e as getDisplayIdType,p as isAggregateId,o as
|
|
5
|
+
const n=8388607,t=8388608,r=254,o=255,u=0,c=1,e=n=>(n&t)>>>23,f=t=>t&n,i=n=>e(n)===c?r:o;function p(n){return e(n)===c}function s(n,r){return((r?t:0)|n)>>>0}export{r as aggregateValidFiltersMask,s as createDisplayId,n as displayIdTexelMask,c as displayIdTypeAggregate,u as displayIdTypeFeature,t as displayIdTypeMask,i as getDisplayIdFilterMask,f as getDisplayIdTexel,e as getDisplayIdType,p as isAggregateId,o as nonAggregateValidFiltersMask};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.28/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import e from"../../../../core/Error.js";import t from"../../../../core/Logger.js";import{CapType as n,JoinType as r}from"../../../../symbols/cim/enums.js";import{WGLGeometryType as s,WGLSymbologyType as a,VVType as i}from"./enums.js";import{Usage as c,DataType as o,PixelType as u}from"../../../webgl/enums.js";import{VertexElementDescriptor as l}from"../../../webgl/VertexElementDescriptor.js";const f=t.getLogger("esri.views.2d.engine.webgl.Utils"),m="geometry",d=[{name:m,strideInBytes:12}],p=[{name:m,strideInBytes:36}],y=[{name:m,strideInBytes:24}],I=[{name:m,strideInBytes:12}],S=[{name:m,strideInBytes:40}],T=[{name:m,strideInBytes:36}],g=[{name:m,strideInBytes:36}];function w(e){const t={};for(const n of e)t[n.name]=n.strideInBytes;return t}const E=w([{name:m,strideInBytes:36}]),h=w(d),L=w(p),N=w(y),D=w(I),A=w(S),M=w(T),U=w(g);function R(e,t){switch(e){case s.MARKER:return t===a.HEATMAP?h:E;case s.FILL:switch(t){case a.DOT_DENSITY:return D;case a.SIMPLE:case a.OUTLINE_FILL_SIMPLE:return N;default:return L}case s.LINE:return A;case s.TEXT:return M;case s.LABEL:return U}}const _=[m],B=[m],O=[m],v=[m],C=[m];function b(e){switch(e){case s.MARKER:return _;case s.FILL:return B;case s.LINE:return O;case s.TEXT:return v;case s.LABEL:return C}}function F(e){switch(e%4){case 0:case 2:return 4;case 1:case 3:return 1}}function P(e,t){switch(t%4){case 0:case 2:return new Uint32Array(Math.floor(e*t/4));case 1:case 3:return new Uint8Array(e*t)}}function x(e,t){switch(t%4){case 0:case 2:return new Uint32Array(e);case 1:case 3:return new Uint8Array(e)}}function z(e){return null!=e}function $(e){return"number"==typeof e}function k(t){switch(t){case"butt":return n.BUTT;case"round":return n.ROUND;case"square":return n.SQUARE;default:return f.error(new e("mapview-invalid-type",`Cap type ${t} is not a valid option. Defaulting to round`)),n.ROUND}}function G(t){switch(t){case"miter":return r.MITER;case"bevel":return r.BEVEL;case"round":return r.ROUND;default:return f.error(new e("mapview-invalid-type",`Join type ${t} is not a valid option. Defaulting to round`)),r.ROUND}}function V(e){switch(e){case"opacity":return i.OPACITY;case"color":return i.COLOR;case"rotation":return i.ROTATION;case"size":return i.SIZE;default:return f.error(`Cannot interpret unknown vv: ${e}`),null}}function j(e,t,n,r,s,a,i){for(const c in a){const t=a[c].stride,r=F(t),i=a[c].data,o=n[c].data;if(null==i||null==o)continue;const u=t*s.vertexCount/r,l=t*e/r,f=t*s.vertexFrom/r;for(let e=0;e<u;++e)o[e+l]=i[e+f]}if(null!=i&&null!=r){const n=s.indexCount;for(let a=0;a<n;++a)r[a+t]=i[a+s.indexFrom]-s.vertexFrom+e}}const Y={[m]:c.STATIC_DRAW};function H(e,t){const n=[];for(let r=0;r<5;++r){const s=b(r),a={};for(const e of s)a[e]={data:t(r,e)};n.push({data:e(r),buffers:a})}return n}function q(e){switch(e){case o.BYTE:case o.UNSIGNED_BYTE:return 1;case o.SHORT:case o.UNSIGNED_SHORT:return 2;case o.FLOAT:case o.INT:case o.UNSIGNED_INT:return 4}}function K(t){switch(t){case u.UNSIGNED_BYTE:return 1;case u.UNSIGNED_SHORT_4_4_4_4:return 2;case u.FLOAT:return 4;default:return void f.error(new e("webgl-utils",`Unable to handle type ${t}`))}}function W(t){switch(t){case u.UNSIGNED_BYTE:return Uint8Array;case u.UNSIGNED_SHORT_4_4_4_4:return Uint16Array;case u.FLOAT:return Float32Array;default:return void f.error(new e("webgl-utils",`Unable to handle type ${t}`))}}function X(e){const t={};for(const n in e){const r=e[n];let s=0;t[n]=r.map((e=>{const t=new l(e.name,e.count,e.type,s,0,e.normalized||!1);return s+=e.count*q(e.type),t})),t[n]?.forEach((e=>e.stride=s))}return t}const J=e=>{const t=new Map;for(const n in e)for(const r of e[n])t.set(r.name,r.location);return t},Q=e=>{const t={};for(const n in e){const r=e[n];t[n]=r?.length?r[0].stride:0}return t},Z=new Map,ee=(e,t)=>{if(!Z.has(e)){const n=X(t),r={strides:Q(n),bufferLayouts:n,attributes:J(t)};Z.set(e,r)}return Z.get(e)};function te(e){e(s.FILL),e(s.LINE),e(s.MARKER),e(s.TEXT),e(s.LABEL)}const ne=e=>"path"in e&&pe(e.path),re=e
|
|
5
|
+
import e from"../../../../core/Error.js";import t from"../../../../core/Logger.js";import{CapType as n,JoinType as r}from"../../../../symbols/cim/enums.js";import{WGLGeometryType as s,WGLSymbologyType as a,VVType as i}from"./enums.js";import{Usage as c,DataType as o,PixelType as u}from"../../../webgl/enums.js";import{VertexElementDescriptor as l}from"../../../webgl/VertexElementDescriptor.js";const f=t.getLogger("esri.views.2d.engine.webgl.Utils"),m="geometry",d=[{name:m,strideInBytes:12}],p=[{name:m,strideInBytes:36}],y=[{name:m,strideInBytes:24}],I=[{name:m,strideInBytes:12}],S=[{name:m,strideInBytes:40}],T=[{name:m,strideInBytes:36}],g=[{name:m,strideInBytes:36}];function w(e){const t={};for(const n of e)t[n.name]=n.strideInBytes;return t}const E=w([{name:m,strideInBytes:36}]),h=w(d),L=w(p),N=w(y),D=w(I),A=w(S),M=w(T),U=w(g);function R(e,t){switch(e){case s.MARKER:return t===a.HEATMAP?h:E;case s.FILL:switch(t){case a.DOT_DENSITY:return D;case a.SIMPLE:case a.OUTLINE_FILL_SIMPLE:return N;default:return L}case s.LINE:return A;case s.TEXT:return M;case s.LABEL:return U}}const _=[m],B=[m],O=[m],v=[m],C=[m];function b(e){switch(e){case s.MARKER:return _;case s.FILL:return B;case s.LINE:return O;case s.TEXT:return v;case s.LABEL:return C}}function F(e){switch(e%4){case 0:case 2:return 4;case 1:case 3:return 1}}function P(e,t){switch(t%4){case 0:case 2:return new Uint32Array(Math.floor(e*t/4));case 1:case 3:return new Uint8Array(e*t)}}function x(e,t){switch(t%4){case 0:case 2:return new Uint32Array(e);case 1:case 3:return new Uint8Array(e)}}function z(e){return null!=e}function $(e){return"number"==typeof e}function k(t){switch(t){case"butt":return n.BUTT;case"round":return n.ROUND;case"square":return n.SQUARE;default:return f.error(new e("mapview-invalid-type",`Cap type ${t} is not a valid option. Defaulting to round`)),n.ROUND}}function G(t){switch(t){case"miter":return r.MITER;case"bevel":return r.BEVEL;case"round":return r.ROUND;default:return f.error(new e("mapview-invalid-type",`Join type ${t} is not a valid option. Defaulting to round`)),r.ROUND}}function V(e){switch(e){case"opacity":return i.OPACITY;case"color":return i.COLOR;case"rotation":return i.ROTATION;case"size":return i.SIZE;default:return f.error(`Cannot interpret unknown vv: ${e}`),null}}function j(e,t,n,r,s,a,i){for(const c in a){const t=a[c].stride,r=F(t),i=a[c].data,o=n[c].data;if(null==i||null==o)continue;const u=t*s.vertexCount/r,l=t*e/r,f=t*s.vertexFrom/r;for(let e=0;e<u;++e)o[e+l]=i[e+f]}if(null!=i&&null!=r){const n=s.indexCount;for(let a=0;a<n;++a)r[a+t]=i[a+s.indexFrom]-s.vertexFrom+e}}const Y={[m]:c.STATIC_DRAW};function H(e,t){const n=[];for(let r=0;r<5;++r){const s=b(r),a={};for(const e of s)a[e]={data:t(r,e)};n.push({data:e(r),buffers:a})}return n}function q(e){switch(e){case o.BYTE:case o.UNSIGNED_BYTE:return 1;case o.SHORT:case o.UNSIGNED_SHORT:return 2;case o.FLOAT:case o.INT:case o.UNSIGNED_INT:return 4}}function K(t){switch(t){case u.UNSIGNED_BYTE:return 1;case u.UNSIGNED_SHORT_4_4_4_4:return 2;case u.FLOAT:return 4;default:return void f.error(new e("webgl-utils",`Unable to handle type ${t}`))}}function W(t){switch(t){case u.UNSIGNED_BYTE:return Uint8Array;case u.UNSIGNED_SHORT_4_4_4_4:return Uint16Array;case u.FLOAT:return Float32Array;default:return void f.error(new e("webgl-utils",`Unable to handle type ${t}`))}}function X(e){const t={};for(const n in e){const r=e[n];let s=0;t[n]=r.map((e=>{const t=new l(e.name,e.count,e.type,s,0,e.normalized||!1);return s+=e.count*q(e.type),t})),t[n]?.forEach((e=>e.stride=s))}return t}const J=e=>{const t=new Map;for(const n in e)for(const r of e[n])t.set(r.name,r.location);return t},Q=e=>{const t={};for(const n in e){const r=e[n];t[n]=r?.length?r[0].stride:0}return t},Z=new Map,ee=(e,t)=>{if(!Z.has(e)){const n=X(t),r={strides:Q(n),bufferLayouts:n,attributes:J(t)};Z.set(e,r)}return Z.get(e)};function te(e){e(s.FILL),e(s.LINE),e(s.MARKER),e(s.TEXT),e(s.LABEL)}const ne=e=>"path"in e&&pe(e.path),re=e=>!(!("url"in e)||!e.url)||!(!("imageData"in e)||!e.imageData),se=e=>"imageData"in e&&e.imageData&&"contentType"in e&&e.contentType?`data:${e.contentType};base64,${e.imageData}`:"url"in e?e.url:null,ae=e=>null!=e&&e.startsWith("data:image/gif"),ie=e=>"url"in e&&e.url&&(e.url.includes(".gif")||ae(e.url))||"contentType"in e&&"image/gif"===e.contentType||"imageData"in e&&ae(e.imageData),ce=e=>null!=e&&e.startsWith("data:image/png"),oe=e=>"url"in e&&e.url&&(e.url.includes(".png")||ce(e.url))||"contentType"in e&&"image/png"===e.contentType||"imageData"in e&&ce(e.imageData),ue=e=>e.type&&e.type.toLowerCase().includes("3d");function le(e){switch(e.type){case"line":{const t=e;return"CIMSolidStroke"===t.cim.type&&!t.dashTemplate}case"fill":return"CIMSolidFill"===e.cim.type;case"esriSFS":return"esriSFSSolid"===e.style||"esriSFSNull"===e.style;case"esriSLS":return"esriSLSSolid"===e.style||"esriSLSNull"===e.style;default:return!1}}function fe(e){switch("cim"in e?e.cim.type:e.type){case"esriSMS":case"esriPMS":case"CIMPointSymbol":return!1;case"CIMVectorMarker":case"CIMCharacterMarker":case"CIMPictureMarker":return ye(e);default:return!0}}function me(e){const t="maxVVSize"in e&&e.maxVVSize,n="width"in e&&e.width||"size"in e&&e.size||0;return t||n}function de(e){const t=[];for(let n=0;n<e.length;n++)t.push(e.charCodeAt(n));return t}const pe=e=>!!e&&(e=e.trim(),!!(/^[mzlhvcsqta]\s*[-+.0-9][^mlhvzcsqta]+/i.test(e)&&/[\dz]$/i.test(e)&&e.length>4)),ye=e=>"fill"===e.type&&"CIMMarkerPlacementInsidePolygon"===e?.cim?.markerPlacement?.type;export{P as allocateTypedArrayBuffer,x as allocateTypedArrayBufferwithData,Y as cVboInfo,de as charCodes,j as copyMeshData,H as createGeometryData,ee as createProgramDescriptor,te as forEachGeometryType,q as getBytes,k as getCapType,G as getJoinType,b as getNamedBuffers,me as getPMSResourceSize,W as getPixelArrayCtor,K as getPixelBytes,R as getStrides,se as getUrl,V as getVVType,ue as is3D,z as isDefined,ie as isGIF,ae as isGIFDataUri,re as isImageResource,ye as isMarkerPlacementInsidePolygon,$ as isNumber,oe as isPNG,ce as isPNGDataUri,ne as isSVGResource,le as isSimple,pe as isValidSVG,fe as shouldRepeat,F as strideToPackingFactor};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.28/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../../../chunks/tslib.es6.js";import"../../../../../intl.js";import t from"../../../../../core/Accessor.js";import{unitRGBAFromColor as i,multiplyOpacityToUnitRGBA as s,getContrast as r,multiplyOpacity as a}from"../../../../../core/colorUtils.js";import"../../../../../core/has.js";import{nextHighestPowerOfTen as n}from"../../../../../core/mathUtils.js";import{destroyMaybe as o}from"../../../../../core/maybe.js";import{formatDecimal as l}from"../../../../../core/quantityFormatUtils.js";import{toUnit as h}from"../../../../../core/quantityUtils.js";import{watch as m,syncAndInitial as c,initial as d}from"../../../../../core/reactiveUtils.js";import{convertUnit as g,adaptiveImperialAreaUnit as p,adaptiveMetricAreaUnit as u,adaptiveImperialLengthUnit as _,adaptiveMetricLengthUnit as L}from"../../../../../core/unitUtils.js";import{property as b}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/accessorSupport/ensureType.js";import"../../../../../core/arrayUtils.js";import{subclass as v}from"../../../../../core/accessorSupport/decorators/subclass.js";import{d as f}from"../../../../../chunks/mat4.js";import{a as S}from"../../../../../chunks/mat4f64.js";import{f as w}from"../../../../../chunks/vec3.js";import{c as y}from"../../../../../chunks/vec3f64.js";import{midpoint as C}from"../../support/viewUtils.js";import{LabelVisualElement as j}from"../../../interactive/visualElements/LabelVisualElement.js";import{LineVisualElement as D}from"../../../interactive/visualElements/LineVisualElement.js";import{MeasurementAreaVisualElement as A}from"../../../interactive/visualElements/MeasurementAreaVisualElement.js";import{GeodesicSegment as P,EuclideanSegment as V}from"../../../interactive/visualElements/support/Segment.js";import{RenderOccludedFlag as M}from"../../../webgl-engine/lib/Material.js";import{createStipplePatternSimple as x}from"../../../webgl-engine/materials/lineStippleUtils.js";import{onLocaleChange as U}from"../../../../../intl/locale.js";import{fetchMessageBundle as k}from"../../../../../intl/messages.js";let I=class extends t{get _parameters(){const{accentColor:e,textColor:t}=this.view.effectiveTheme,n=i(e),o=s(e,.5),l=s(r(e),.5),h=r(t);return{accentColor:n,transparentAccentColor:o,transparentContrastColor:l,intersectingLineColor:[1,.2,0,1],textColor:t,textBackgroundColor:a(h,.6),textCalloutColor:a(h,.5),pathLineWidth:3,perimeterLineWidth:2,projectionLineWidth:2,projectionLineStippleSize:5,labelDistance:25}}get visible(){return this.analysisViewData.visible}get testData(){return{labels:{area:this._areaLabel,pathLength:this._pathLengthLabel,stagedSegmentLength:this._stagedSegmentLengthLabel,perimeterLength:this._perimeterLengthLabel}}}constructor(e){super(e),this._path=null,this._intersectedPath=null,this._perimeter=null,this._intersectedPerimeter=null,this._projectionLines=null,this._measurementArea=null,this._areaLabel=null,this._pathLengthLabel=null,this._stagedSegmentLengthLabel=null,this._perimeterLengthLabel=null,this._pathSegments=[],this._perimeterSegments=[],this._stagedSegment=null,this._origin=y(),this._originTransform=S(),this.messages=null,this.viewData=z,this.areaLabel=null,this.perimeterLengthLabel=null,this.loadingMessages=!0}initialize(){const{analysisViewData:e,_parameters:t,view:i}=this;this._path=new D({view:i,attached:!0,width:t.pathLineWidth,polygonOffset:!0,renderOccluded:M.OccludeAndTransparent,isDecoration:!0}),this._intersectedPath=new D({view:i,attached:!0,width:t.pathLineWidth,polygonOffset:!0,renderOccluded:M.OccludeAndTransparent,isDecoration:!0}),this._perimeter=new D({view:i,attached:!0,width:t.perimeterLineWidth,polygonOffset:!0,renderOccluded:M.OccludeAndTransparent,isDecoration:!0}),this._intersectedPerimeter=new D({view:i,attached:!0,width:t.perimeterLineWidth,color:t.intersectingLineColor,polygonOffset:!0,renderOccluded:M.OccludeAndTransparent,isDecoration:!0}),this._projectionLines=new D({view:i,attached:!0,width:t.projectionLineWidth,stipplePattern:x(t.projectionLineStippleSize),polygonOffset:!0,renderOccluded:M.OccludeAndTransparent,isDecoration:!0}),this._measurementArea=new A({view:i,attached:!0,isDecoration:!0});const s={attached:!0,view:i,isDecoration:!0};this._areaLabel=new j({...s,fontSize:O.Large}),this._pathLengthLabel=new j({...s,fontSize:O.Small}),this._stagedSegmentLengthLabel=new j({...s,fontSize:O.Small}),this._perimeterLengthLabel=new j({...s,fontSize:O.Small}),this.addHandles([m((()=>[e.mode,this.visible,e.unit,e.measurementData,e.stagedPoint]),(()=>this._update()),c),m((()=>i.state?.camera),(()=>this._updateLabels()),c),U((()=>this._updateMessageBundle())),m((()=>this._parameters),(({accentColor:e,transparentAccentColor:t,transparentContrastColor:i,textColor:s,textBackgroundColor:r,textCalloutColor:a})=>{const{_path:n,_intersectedPath:o,_perimeter:l,_projectionLines:h,_measurementArea:m,_areaLabel:c,_pathLengthLabel:d,_perimeterLengthLabel:g}=this;n.color=e,o.color=e,l.color=e,h.color=e,m.color1=t,m.color2=i,c.textColor=s,c.backgroundColor=r,c.calloutColor=a,d.textColor=s,d.backgroundColor=r,d.calloutColor=a,g.textColor=s,g.backgroundColor=r,g.calloutColor=a}),d)]),this._updateMessageBundle()}destroy(){this._measurementArea=o(this._measurementArea),this._path=o(this._path),this._intersectedPath=o(this._intersectedPath),this._perimeter=o(this._perimeter),this._intersectedPerimeter=o(this._intersectedPerimeter),this._areaLabel=o(this._areaLabel),this._pathLengthLabel=o(this._pathLengthLabel),this._stagedSegmentLengthLabel=o(this._stagedSegmentLengthLabel),this._perimeterLengthLabel=o(this._perimeterLengthLabel),this._projectionLines=o(this._projectionLines),this.set("view",null)}_update(){if(this.destroyed||!this.view.ready||!this.view.renderCoordsHelper)return;const{analysisViewData:{measurementData:e},analysisViewData:t}=this;null!=e&&(this._updateViewData(e,t.path,t.stagedPoint),this._updateOrigin(),this._updatePathSegments(),this._updatePerimeterSegments(),this._updateArea(),this._updateProjectionLines(),this._updateLabels())}_updateViewData(e,t,i){const s=e.validMeasurement,r="geodesic"===e.actualMeasurementMode,a=r?e.geodesicArea:e.area;let o=1;if(a){const t=this._toPreferredAreaUnit(a,this.analysisViewData.unit);o=n(Math.sqrt(t.value)/Math.sqrt(300)),o*=Math.sqrt(g(1,t.unit,"square-meters")),o/=e.unitNormalizer.normalizeDistance(1)}const l={validMeasurement:s,numVertices:e.numVertices,hasStagedVertex:e.hasStagedVertex,path:t,pathVersion:t.version,stagedPoint:i,measurementData:e,mode:e.actualMeasurementMode,positionsGeographic:e.positionsGeographic,positionsRenderCoords:e.positionsRenderCoords,positionsProjected:e.positionsProjectedWorldCoords,positionsFittedRenderCoords:e.positionsFittedRenderCoords,intersectingSegments:r?e.geodesicIntersectingSegments:e.intersectingSegments,triangleIndices:r?e.geodesicTriangleIndices:e.triangleIndices,fittingMode:e.fittingMode,areaCentroid:r?e.geodesicAreaCentroidRenderCoords:e.areaCentroidRenderCoords,pathLengthLabelSegmentIndex:s?0:t.numVertices-2,perimeterLengthLabelSegmentIndex:0,checkerSize:o};this._set("viewData",l)}_updateOrigin(){const e=this.viewData;C(e.positionsRenderCoords,this._origin),f(this._originTransform,this._origin),this._measurementArea.transform=this._originTransform,this._projectionLines.transform=this._originTransform}_createSegments(e){const t=this.viewData,i=this.view.renderCoordsHelper.spatialReference,s=t.mode,r=[],a=[],n=[],o=t.numVertices,l=t.validMeasurement?o:o-1;for(let m=0;m<l;++m){const l=t[e][m],h=t[e][(m+1)%o];let c=null;switch(s){case"euclidean":c=new V(l,h);break;case"geodesic":c=new P(l,h,i)}t.intersectingSegments.has(m)?n.push(c):a.push(c),r.push(c)}let h=null;return t.validMeasurement&&t.hasStagedVertex&&l>=2?h=r[r.length-2]:t.hasStagedVertex&&l>=1&&(h=r[r.length-1]),{all:r,nonIntersecting:a,intersecting:n,stagedSegment:h}}_updatePathSegments(){const{visible:e}=this,t=this._createSegments("positionsRenderCoords");this._stagedSegment=t.stagedSegment,this._path.setGeometryFromSegments(t.nonIntersecting,this._origin),this._path.visible=e,this._intersectedPath.setGeometryFromSegments(t.intersecting,this._origin),this._intersectedPath.visible=e,this._pathSegments=t.all}_updatePerimeterSegments(){const e=this.visible&&"euclidean"===this.viewData.mode,t=this._createSegments("positionsFittedRenderCoords");this._perimeter.setGeometryFromSegments(t.nonIntersecting,this._origin),this._perimeter.visible=e,this._intersectedPerimeter.setGeometryFromSegments(t.intersecting,this._origin),this._intersectedPerimeter.visible=e,this._perimeterSegments=t.all}_updateArea(){const e=this.viewData;switch(e.mode){case"euclidean":this._updateAreaEuclidean(e);break;case"geodesic":this._updateAreaGeodesic()}}_updateAreaEuclidean(e){const t=this.visible;e.validMeasurement&&0===e.intersectingSegments.size&&e.triangleIndices?(this._measurementArea.geometry={uv:e.positionsProjected,position:e.positionsFittedRenderCoords,triangleIndices:e.triangleIndices},this._measurementArea.size=[e.checkerSize,e.checkerSize],this._measurementArea.visible=t):this._measurementArea.visible=!1}_updateAreaGeodesic(){this._measurementArea.visible=!1}_updateProjectionLines(){const e=this.viewData,t=this.visible,i=e.mode,s=e.numVertices;if(s>0&&e.validMeasurement&&"euclidean"===i){const i=[];for(let t=0;t<s;++t){const s=y();w(s,e.positionsRenderCoords[t],this._origin);const r=y();w(r,e.positionsFittedRenderCoords[t],this._origin),i.push([s,r])}this._projectionLines.geometry=i,this._projectionLines.visible=t}else this._projectionLines.geometry=null,this._projectionLines.visible=!1}_updateLabels(){if(this.destroyed)return;const{viewData:e}=this,{measurementData:t,mode:i,path:s}=e;if(!s)return;const r=!s.isValidPolygon,a=this.visible,n=this._formatAreaLabel(this.messages,"geodesic"===i?t.geodesicArea:t.area,this.analysisViewData.unit);null!=n?(this._areaLabel.geometry={type:"point",point:e.areaCentroid},this._areaLabel.text=n,this._areaLabel.visible=e.validMeasurement&&0===e.intersectingSegments.size&&a):this._areaLabel.visible=!1,this._set("areaLabel",n);const o=this._formatLengthLabel(this.messages,"geodesic"===i?t.geodesicPathLength:t.pathLength,this.analysisViewData.unit);if(null!=o&&e.pathLengthLabelSegmentIndex>=0&&e.pathLengthLabelSegmentIndex<this._pathSegments.length){const t=this._pathSegments[e.pathLengthLabelSegmentIndex],i=null!=this._stagedSegment?this._stagedSegment:q;this._pathLengthLabel.distance=this._parameters.labelDistance,this._pathLengthLabel.geometry={type:"corner",left:t,right:i},this._pathLengthLabel.text=o,this._pathLengthLabel.visible=r&&s.numVertices>0&&a}else this._pathLengthLabel.visible=!1;const l="geodesic"===i?e.measurementData.geodesicStagedSegmentLength:e.measurementData.stagedSegmentLength;if(null!=l){const e=this._formatLengthLabel(this.messages,l,this.analysisViewData.unit);this._stagedSegmentLengthLabel.distance=this._parameters.labelDistance,this._stagedSegmentLengthLabel.geometry=null!=this._stagedSegment?{type:"segment",segment:this._stagedSegment,sampleLocation:"end"}:null,this._stagedSegmentLengthLabel.anchor="bottom",this._stagedSegmentLengthLabel.text=e,this._stagedSegmentLengthLabel.visible=r&&0!==l.value&&a}else this._stagedSegmentLengthLabel.visible=!1;this._stagedSegmentLengthLabel.overlaps(this._pathLengthLabel)&&(this._stagedSegmentLengthLabel.visible=!1),this._pathLengthLabel.overlaps(this._areaLabel)&&(this._pathLengthLabel.visible=!1);const h="geodesic"===e.mode,m=h?t.geodesicPathLength:t.perimeterLength,c=this._formatLengthLabel(this.messages,m,this.analysisViewData.unit);if(this._set("perimeterLengthLabel",c),e.validMeasurement&&0===e.intersectingSegments.size){this._perimeterLengthLabel.distance=this._parameters.labelDistance,this._perimeterLengthLabel.anchor="top",this._perimeterLengthLabel.text=c,this._perimeterLengthLabel.visible=!0;let t=!0;for(let i=0;i<e.numVertices;++i){const s=(e.perimeterLengthLabelSegmentIndex+i)%e.numVertices,r=h?this._pathSegments[s]:this._perimeterSegments[s];if(t=!0,this._perimeterLengthLabel.geometry={type:"segment",segment:r,sampleLocation:"center"},!this._perimeterLengthLabel.overlaps(this._areaLabel))break;t=!1}this._perimeterLengthLabel.visible=t&&a}else this._perimeterLengthLabel.visible=!1}_toPreferredAreaUnit(e,t){return h(e,this._preferredAreaUnit(e,t))}_preferredAreaUnit(e,t){switch(t){case"metric":return u(e.value,e.unit);case"imperial":return p(e.value,e.unit);default:return t}}_preferredLengthUnit(e,t){const i=this._deriveLengthUnitFromAreaUnit(t);switch(i){case"metric":return L(e.value,e.unit);case"imperial":return _(e.value,e.unit);default:return i}}_deriveLengthUnitFromAreaUnit(e){switch(e){case"metric":case"ares":case"hectares":return"metric";case"imperial":case"acres":return"imperial";case"square-inches":return"inches";case"square-feet":return"feet";case"square-yards":return"yards";case"square-miles":return"miles";case"square-us-feet":return"us-feet";case"square-millimeters":return"millimeters";case"square-centimeters":return"centimeters";case"square-decimeters":return"decimeters";case"square-meters":return"meters";case"square-kilometers":return"kilometers"}throw new Error("unhandled area unit")}_formatAreaLabel(e,t,i){return e&&t&&l(e,t,this._preferredAreaUnit(t,i))}_formatLengthLabel(e,t,i){return e&&t&&l(e,t,this._preferredLengthUnit(t,i))}_updateMessageBundle(){this.loadingMessages=!0,k("esri/core/t9n/Units").then((e=>{this.messages=e,this.view&&this._update()})).finally((()=>{this.loadingMessages=!1}))}};var O;e([b()],I.prototype,"_parameters",null),e([b()],I.prototype,"view",void 0),e([b()],I.prototype,"messages",void 0),e([b()],I.prototype,"analysis",void 0),e([b()],I.prototype,"viewData",void 0),e([b()],I.prototype,"analysisViewData",void 0),e([b({readOnly:!0})],I.prototype,"areaLabel",void 0),e([b({readOnly:!0})],I.prototype,"perimeterLengthLabel",void 0),e([b()],I.prototype,"loadingMessages",void 0),e([b()],I.prototype,"visible",null),I=e([v("esri.views.3d.analysis.AreaMeasurement.support.AreaMeasurementVisualization")],I),function(e){e[e.Small=12]="Small",e[e.Large=16]="Large"}(O||(O={}));const z={validMeasurement:!1,numVertices:0,hasStagedVertex:!1,path:null,pathVersion:-1,stagedPoint:null,measurementData:null,mode:null,positionsGeographic:null,positionsRenderCoords:null,positionsProjected:null,positionsFittedRenderCoords:null,intersectingSegments:null,triangleIndices:null,fittingMode:null,areaCentroid:null,pathLengthLabelSegmentIndex:null,perimeterLengthLabelSegmentIndex:null,checkerSize:null},q=new V(y(),y());export{I as AreaMeasurementVisualization};
|
|
5
|
+
import{_ as e}from"../../../../../chunks/tslib.es6.js";import"../../../../../intl.js";import t from"../../../../../core/Accessor.js";import{unitRGBAFromColor as i,multiplyOpacityToUnitRGBA as r,getContrast as s,multiplyOpacity as a}from"../../../../../core/colorUtils.js";import"../../../../../core/has.js";import{nextHighestPowerOfTen as n}from"../../../../../core/mathUtils.js";import{destroyMaybe as o}from"../../../../../core/maybe.js";import{formatDecimal as l}from"../../../../../core/quantityFormatUtils.js";import{toUnit as h}from"../../../../../core/quantityUtils.js";import{watch as c,syncAndInitial as m,initial as d}from"../../../../../core/reactiveUtils.js";import{convertUnit as p,adaptiveImperialAreaUnit as u,adaptiveMetricAreaUnit as g,adaptiveImperialLengthUnit as _,adaptiveMetricLengthUnit as L}from"../../../../../core/unitUtils.js";import{property as v}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/accessorSupport/ensureType.js";import"../../../../../core/arrayUtils.js";import{subclass as b}from"../../../../../core/accessorSupport/decorators/subclass.js";import{d as f}from"../../../../../chunks/mat4.js";import{a as w}from"../../../../../chunks/mat4f64.js";import{f as S}from"../../../../../chunks/vec3.js";import{c as y}from"../../../../../chunks/vec3f64.js";import{midpoint as j}from"../../support/viewUtils.js";import{LabelVisualElement as C}from"../../../interactive/visualElements/LabelVisualElement.js";import{LineVisualElement as A}from"../../../interactive/visualElements/LineVisualElement.js";import{MeasurementAreaVisualElement as D}from"../../../interactive/visualElements/MeasurementAreaVisualElement.js";import{GeodesicSegment as M,EuclideanSegment as P}from"../../../interactive/visualElements/support/Segment.js";import{RenderOccludedFlag as V}from"../../../webgl-engine/lib/Material.js";import{createStipplePatternSimple as x}from"../../../webgl-engine/materials/lineStippleUtils.js";import{onLocaleChange as U}from"../../../../../intl/locale.js";import{fetchMessageBundle as O}from"../../../../../intl/messages.js";let k=class extends t{get _parameters(){const{accentColor:e,textColor:t}=this.view.effectiveTheme,n=i(e),o=r(e,.5),l=r(s(e),.5),h=s(t);return{accentColor:n,transparentAccentColor:o,transparentContrastColor:l,intersectingLineColor:[1,.2,0,1],textColor:t,textBackgroundColor:a(h,.6),textCalloutColor:a(h,.5),pathLineWidth:3,perimeterLineWidth:2,projectionLineWidth:2,projectionLineStippleSize:5,labelDistance:25}}get visible(){return this.analysisViewData.visible}get testData(){return{labels:{area:this._areaLabel,perimeterLength:this._perimeterLengthLabel}}}constructor(e){super(e),this._path=null,this._intersectedPath=null,this._perimeter=null,this._intersectedPerimeter=null,this._projectionLines=null,this._measurementArea=null,this._areaLabel=null,this._perimeterLengthLabel=null,this._pathSegments=[],this._perimeterSegments=[],this._origin=y(),this._originTransform=w(),this.messages=null,this.viewData=z,this.areaLabel=null,this.perimeterLengthLabel=null,this.loadingMessages=!0}initialize(){const{analysisViewData:e,_parameters:t,view:i}=this;this._path=new A({view:i,attached:!0,width:t.pathLineWidth,polygonOffset:!0,renderOccluded:V.OccludeAndTransparent,isDecoration:!0}),this._intersectedPath=new A({view:i,attached:!0,width:t.pathLineWidth,polygonOffset:!0,renderOccluded:V.OccludeAndTransparent,isDecoration:!0}),this._perimeter=new A({view:i,attached:!0,width:t.perimeterLineWidth,polygonOffset:!0,renderOccluded:V.OccludeAndTransparent,isDecoration:!0}),this._intersectedPerimeter=new A({view:i,attached:!0,width:t.perimeterLineWidth,color:t.intersectingLineColor,polygonOffset:!0,renderOccluded:V.OccludeAndTransparent,isDecoration:!0}),this._projectionLines=new A({view:i,attached:!0,width:t.projectionLineWidth,stipplePattern:x(t.projectionLineStippleSize),polygonOffset:!0,renderOccluded:V.OccludeAndTransparent,isDecoration:!0}),this._measurementArea=new D({view:i,attached:!0,isDecoration:!0});const r={attached:!0,view:i,isDecoration:!0};this._areaLabel=new C({...r,fontSize:q.Large}),this._perimeterLengthLabel=new C({...r,fontSize:q.Small}),this.addHandles([c((()=>[e.mode,this.visible,e.unit,e.measurementData,e.stagedPoint]),(()=>this._update()),m),c((()=>i.state?.camera),(()=>this._updateLabels()),m),U((()=>this._updateMessageBundle())),c((()=>this._parameters),(({accentColor:e,transparentAccentColor:t,transparentContrastColor:i,textColor:r,textBackgroundColor:s,textCalloutColor:a})=>{const{_path:n,_intersectedPath:o,_perimeter:l,_projectionLines:h,_measurementArea:c,_areaLabel:m,_perimeterLengthLabel:d}=this;n.color=e,o.color=e,l.color=e,h.color=e,c.color1=t,c.color2=i,m.textColor=r,m.backgroundColor=s,m.calloutColor=a,d.textColor=r,d.backgroundColor=s,d.calloutColor=a}),d)]),this._updateMessageBundle()}destroy(){this._measurementArea=o(this._measurementArea),this._path=o(this._path),this._intersectedPath=o(this._intersectedPath),this._perimeter=o(this._perimeter),this._intersectedPerimeter=o(this._intersectedPerimeter),this._areaLabel=o(this._areaLabel),this._perimeterLengthLabel=o(this._perimeterLengthLabel),this._projectionLines=o(this._projectionLines),this.set("view",null)}_update(){if(this.destroyed||!this.view.ready||!this.view.renderCoordsHelper)return;const{analysisViewData:{measurementData:e},analysisViewData:t}=this;null!=e&&(this._updateViewData(e,t.path,t.stagedPoint),this._updateOrigin(),this._updatePathSegments(),this._updatePerimeterSegments(),this._updateArea(),this._updateProjectionLines(),this._updateLabels())}_updateViewData(e,t,i){const r=e.validMeasurement,s="geodesic"===e.actualMeasurementMode,a=s?e.geodesicArea:e.area;let o=1;if(a){const t=this._toPreferredAreaUnit(a,this.analysisViewData.unit);o=n(Math.sqrt(t.value)/Math.sqrt(300)),o*=Math.sqrt(p(1,t.unit,"square-meters")),o/=e.unitNormalizer.normalizeDistance(1)}const l={validMeasurement:r,numVertices:e.numVertices,hasStagedVertex:e.hasStagedVertex,path:t,pathVersion:t.version,stagedPoint:i,measurementData:e,mode:e.actualMeasurementMode,positionsGeographic:e.positionsGeographic,positionsRenderCoords:e.positionsRenderCoords,positionsProjected:e.positionsProjectedWorldCoords,positionsFittedRenderCoords:e.positionsFittedRenderCoords,intersectingSegments:s?e.geodesicIntersectingSegments:e.intersectingSegments,triangleIndices:s?e.geodesicTriangleIndices:e.triangleIndices,fittingMode:e.fittingMode,areaCentroid:s?e.geodesicAreaCentroidRenderCoords:e.areaCentroidRenderCoords,pathLengthLabelSegmentIndex:r?0:t.numVertices-2,perimeterLengthLabelSegmentIndex:0,checkerSize:o};this._set("viewData",l)}_updateOrigin(){const e=this.viewData;j(e.positionsRenderCoords,this._origin),f(this._originTransform,this._origin),this._measurementArea.transform=this._originTransform,this._projectionLines.transform=this._originTransform}_createSegments(e){const t=this.viewData,i=this.view.renderCoordsHelper.spatialReference,r=t.mode,s=[],a=[],n=[],o=t.numVertices,l=t.validMeasurement?o:o-1;for(let c=0;c<l;++c){const l=t[e][c],h=t[e][(c+1)%o];let m=null;switch(r){case"euclidean":m=new P(l,h);break;case"geodesic":m=new M(l,h,i)}t.intersectingSegments.has(c)?n.push(m):a.push(m),s.push(m)}let h=null;return t.validMeasurement&&t.hasStagedVertex&&l>=2?h=s[s.length-2]:t.hasStagedVertex&&l>=1&&(h=s[s.length-1]),{all:s,nonIntersecting:a,intersecting:n,stagedSegment:h}}_updatePathSegments(){const{visible:e}=this,t=this._createSegments("positionsRenderCoords");this._path.setGeometryFromSegments(t.nonIntersecting,this._origin),this._path.visible=e,this._intersectedPath.setGeometryFromSegments(t.intersecting,this._origin),this._intersectedPath.visible=e,this._pathSegments=t.all}_updatePerimeterSegments(){const e=this.visible&&"euclidean"===this.viewData.mode,t=this._createSegments("positionsFittedRenderCoords");this._perimeter.setGeometryFromSegments(t.nonIntersecting,this._origin),this._perimeter.visible=e,this._intersectedPerimeter.setGeometryFromSegments(t.intersecting,this._origin),this._intersectedPerimeter.visible=e,this._perimeterSegments=t.all}_updateArea(){const e=this.viewData;switch(e.mode){case"euclidean":this._updateAreaEuclidean(e);break;case"geodesic":this._updateAreaGeodesic()}}_updateAreaEuclidean(e){const t=this.visible;e.validMeasurement&&0===e.intersectingSegments.size&&e.triangleIndices?(this._measurementArea.geometry={uv:e.positionsProjected,position:e.positionsFittedRenderCoords,triangleIndices:e.triangleIndices},this._measurementArea.size=[e.checkerSize,e.checkerSize],this._measurementArea.visible=t):this._measurementArea.visible=!1}_updateAreaGeodesic(){this._measurementArea.visible=!1}_updateProjectionLines(){const e=this.viewData,t=this.visible,i=e.mode,r=e.numVertices;if(r>0&&e.validMeasurement&&"euclidean"===i){const i=[];for(let t=0;t<r;++t){const r=y();S(r,e.positionsRenderCoords[t],this._origin);const s=y();S(s,e.positionsFittedRenderCoords[t],this._origin),i.push([r,s])}this._projectionLines.geometry=i,this._projectionLines.visible=t}else this._projectionLines.geometry=null,this._projectionLines.visible=!1}_updateLabels(){if(this.destroyed)return;const{viewData:e}=this,{measurementData:t,mode:i,path:r}=e;if(!r)return;const s=this.visible,a=this._formatAreaLabel(this.messages,"geodesic"===i?t.geodesicArea:t.area,this.analysisViewData.unit);if(null!=a?(this._areaLabel.geometry={type:"point",point:e.areaCentroid},this._areaLabel.text=a,this._areaLabel.visible=e.validMeasurement&&0===e.intersectingSegments.size&&s):this._areaLabel.visible=!1,this._set("areaLabel",a),e.numVertices>=2&&0===e.intersectingSegments.size){const i="geodesic"===e.mode,r=i?t.geodesicPathLength:t.validMeasurement?t.perimeterLength:t.pathLength,a=this._formatLengthLabel(this.messages,r,this.analysisViewData.unit);this._set("perimeterLengthLabel",a),this._perimeterLengthLabel.distance=this._parameters.labelDistance,this._perimeterLengthLabel.anchor="top",this._perimeterLengthLabel.text=a,this._perimeterLengthLabel.visible=!0;let n=!0;for(let s=0;s<e.numVertices;++s){const r=(e.perimeterLengthLabelSegmentIndex+s)%e.numVertices,a=i||!t.validMeasurement?this._pathSegments[r]:this._perimeterSegments[r];if(n=!0,this._perimeterLengthLabel.geometry={type:"segment",segment:a,sampleLocation:"center"},!this._perimeterLengthLabel.overlaps(this._areaLabel))break;n=!1}this._perimeterLengthLabel.visible=n&&s}else this._perimeterLengthLabel.visible=!1}_toPreferredAreaUnit(e,t){return h(e,this._preferredAreaUnit(e,t))}_preferredAreaUnit(e,t){switch(t){case"metric":return g(e.value,e.unit);case"imperial":return u(e.value,e.unit);default:return t}}_preferredLengthUnit(e,t){const i=this._deriveLengthUnitFromAreaUnit(t);switch(i){case"metric":return L(e.value,e.unit);case"imperial":return _(e.value,e.unit);default:return i}}_deriveLengthUnitFromAreaUnit(e){switch(e){case"metric":case"ares":case"hectares":return"metric";case"imperial":case"acres":return"imperial";case"square-inches":return"inches";case"square-feet":return"feet";case"square-yards":return"yards";case"square-miles":return"miles";case"square-us-feet":return"us-feet";case"square-millimeters":return"millimeters";case"square-centimeters":return"centimeters";case"square-decimeters":return"decimeters";case"square-meters":return"meters";case"square-kilometers":return"kilometers"}throw new Error("unhandled area unit")}_formatAreaLabel(e,t,i){return e&&t&&l(e,t,this._preferredAreaUnit(t,i))}_formatLengthLabel(e,t,i){return e&&t&&l(e,t,this._preferredLengthUnit(t,i))}_updateMessageBundle(){this.loadingMessages=!0,O("esri/core/t9n/Units").then((e=>{this.messages=e,this.view&&this._update()})).finally((()=>{this.loadingMessages=!1}))}};var q;e([v()],k.prototype,"_parameters",null),e([v()],k.prototype,"view",void 0),e([v()],k.prototype,"messages",void 0),e([v()],k.prototype,"analysis",void 0),e([v()],k.prototype,"viewData",void 0),e([v()],k.prototype,"analysisViewData",void 0),e([v({readOnly:!0})],k.prototype,"areaLabel",void 0),e([v({readOnly:!0})],k.prototype,"perimeterLengthLabel",void 0),e([v()],k.prototype,"loadingMessages",void 0),e([v()],k.prototype,"visible",null),k=e([b("esri.views.3d.analysis.AreaMeasurement.support.AreaMeasurementVisualization")],k),function(e){e[e.Small=12]="Small",e[e.Large=16]="Large"}(q||(q={}));const z={validMeasurement:!1,numVertices:0,hasStagedVertex:!1,path:null,pathVersion:-1,stagedPoint:null,measurementData:null,mode:null,positionsGeographic:null,positionsRenderCoords:null,positionsProjected:null,positionsFittedRenderCoords:null,intersectingSegments:null,triangleIndices:null,fittingMode:null,areaCentroid:null,pathLengthLabelSegmentIndex:null,perimeterLengthLabelSegmentIndex:null,checkerSize:null};export{k as AreaMeasurementVisualization};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.28/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{deg2rad as e}from"../../../../../core/mathUtils.js";import{createLength as t,createArea as s}from"../../../../../core/quantityUtils.js";import{s as i,d as o}from"../../../../../chunks/vec2.js";import{a as r}from"../../../../../chunks/vec2f64.js";import{m as n,c as h,b as a,E as d,f as g,j as l,i as p,g as c,n as m}from"../../../../../chunks/vec3.js";import{c as u}from"../../../../../chunks/vec3f64.js";import{c as _}from"../../../../../chunks/vec4f64.js";import{getReferenceEllipsoid as f}from"../../../../../geometry/ellipsoidUtils.js";import{canProjectWithoutEngine as S,canProjectToWGS84ComparableLonLat as C}from"../../../../../geometry/projection.js";import L from"../../../../../geometry/SpatialReference.js";import{getSphericalPCPF as P}from"../../../../../geometry/spatialReferenceEllipsoidUtils.js";import{projectDirection as j}from"../../../../../geometry/projection/projectDirection.js";import{projectPointToVector as R}from"../../../../../geometry/projection/projectPointToVector.js";import{projectPointToWGS84ComparableLonLat as M}from"../../../../../geometry/projection/projectPointToWGS84ComparableLonLat.js";import{projectVectorToVector as A}from"../../../../../geometry/projection/projectVectorToVector.js";import{Axis as v}from"../../../../../geometry/support/Axis.js";import{compactIndices as V}from"../../../../../geometry/support/Indices.js";import{segmentIntersects as W}from"../../../../../geometry/support/intersectsBase.js";import{areaPoints2d as I}from"../../../../../geometry/support/triangle.js";import{MeasurementMode as w}from"../../interfaces.js";import{segmentLengthGeodesicVector as z,bestFitPlane as U,fitHemisphere as G,triangleAreaGeodesic as y,planePointDistance as T,boundingSphere as x,segmentLengthGeodesic as E,segmentLengthEuclidean as F}from"../../support/measurementUtils.js";import{midpoint as N}from"../../support/viewUtils.js";import{getElevationAtPoint as q}from"../../../support/ElevationProvider.js";import{makeOrthonormal as b,tangentFrame as k}from"../../../support/mathUtils.js";import{triangulate as D}from"../../../../support/euclideanAreaMeasurementUtils.js";class B{get numVertices(){return this._length}get hasStagedVertex(){return this._hasCursorPoint}constructor(e,t){this.validMeasurement=!1,this.positionsWorldCoords=[],this.positionsRenderCoords=[],this.positionsProjectedWorldCoords=[],this.positionsFittedRenderCoords=[],this.positionsGeographic=[],this.positionsSpherical=[],this.positionsStereographic=[],this.pathSegmentLengths=[],this.geodesicPathSegmentLengths=[],this.perimeterSegmentLengths=[],this.intersectingSegments=new Set,this.geodesicIntersectingSegments=new Set,this.triangleIndices=null,this.geodesicTriangleIndices=null,this.areaCentroidWorldCoords=u(),this.areaCentroidRenderCoords=u(),this.geodesicAreaCentroidRenderCoords=u(),this.area=null,this.geodesicArea=null,this.pathLength=null,this.geodesicPathLength=null,this.perimeterLength=null,this._length=0,this._centroidRenderCoords=u(),this._planeWorldCoords=_(),this._worldUp=u(),this._worldTangent=u(),this._frame=[u(),u(),u()],this._pathVersion=-1,this._hasCursorPoint=!1,this._mode=null,this._tempU=u(),this._tempV=u(),this._tempVec3=u(),this._tempSphere={center:u(),radius:0},this._sceneView=e,this.unitNormalizer=t}update(e,t,s,i,o,r){const n=null!=t,h=this._pathVersion===e.version,a=this._hasCursorPoint===n,d=this._mode===o;return!(h&&!r&&a&&d&&e.isValidPolygon)&&(this._pathVersion=e.version,this._hasCursorPoint=n,this._updateCursorSegmentLength(e,t),this._update(e,t,s,i,o),!0)}_update(e,s,i,o,r){const n=this.unitNormalizer,h=this._sceneView.renderSpatialReference,a=this.unitNormalizer.spatialReference;let d=e.numVertices;const g=!(null==s||s.equals(e.lastPoint)||d>2&&s.equals(e.firstPoint));g&&(d+=1);const l=!e.polygonIsClosed&&d>2,p=e.polygonIsClosed||l;this._resize(d);const c=P(i.spatialReference),u=S(i.spatialReference,c)&&C(i.spatialReference),{positionsGeographic:_,positionsWorldCoords:f,positionsRenderCoords:L,positionsSpherical:j}=this,A=(e,t)=>{H(i.elevationProvider,e),R(e,f[t],a),R(e,L[t],h),u&&(M(e,_[t]),R(e,j[t],c),m(j[t],j[t]))};e.forEachVertexPosition(((e,t)=>A(e,t))),g&&A(s,d-1);const v=this._updatePathLengths(p);if(this.pathLength=this._length>1?t(n.normalizeDistance(v),"meters"):null,u){const e=this._updateGeodesicPathLengths(p,a);this.geodesicPathLength=this._length>1?t(e,"meters"):null}else this.geodesicPathLength=null;if(this._updateMode(r),!p)return this.area=null,this.geodesicArea=null,this.perimeterLength=null,this.triangleIndices=null,this.geodesicTriangleIndices=null,this.intersectingSegments.clear(),this.geodesicIntersectingSegments.clear(),void(this.validMeasurement=!1);this._updateAreaAndPerimeterLength(i,n,h,a,o),u&&this._updateGeodesicArea(i),this.validMeasurement=!0}getData(){return{validMeasurement:this.validMeasurement,numVertices:this.numVertices,hasStagedVertex:this.hasStagedVertex,positionsWorldCoords:this.positionsWorldCoords,positionsRenderCoords:this.positionsRenderCoords,positionsProjectedWorldCoords:this.positionsProjectedWorldCoords,positionsFittedRenderCoords:this.positionsFittedRenderCoords,positionsGeographic:this.positionsGeographic,positionsSpherical:this.positionsSpherical,positionsStereographic:this.positionsStereographic,pathSegmentLengths:this.pathSegmentLengths,geodesicPathSegmentLengths:this.geodesicPathSegmentLengths,perimeterSegmentLengths:this.perimeterSegmentLengths,intersectingSegments:this.intersectingSegments,geodesicIntersectingSegments:this.geodesicIntersectingSegments,triangleIndices:this.triangleIndices,geodesicTriangleIndices:this.geodesicTriangleIndices,areaCentroidWorldCoords:this.areaCentroidWorldCoords,areaCentroidRenderCoords:this.areaCentroidRenderCoords,geodesicAreaCentroidRenderCoords:this.geodesicAreaCentroidRenderCoords,fittingMode:this.fittingMode,area:this.area,geodesicArea:this.geodesicArea,pathLength:this.pathLength,geodesicPathLength:this.geodesicPathLength,perimeterLength:this.perimeterLength,stagedSegmentLength:this.stagedSegmentLength,geodesicStagedSegmentLength:this.geodesicStagedSegmentLength,unitNormalizer:this.unitNormalizer,actualMeasurementMode:this.actualMeasurementMode}}_resize(e){for(e<this._length&&(this.positionsWorldCoords.length=e,this.positionsRenderCoords.length=e,this.positionsProjectedWorldCoords.length=e,this.positionsFittedRenderCoords.length=e,this.positionsGeographic.length=e,this.positionsSpherical.length=e,this.positionsStereographic.length=e,this.pathSegmentLengths.length=e,this.geodesicPathSegmentLengths.length=e,this.perimeterSegmentLengths.length=e,this._length=e);this._length<e;)this.positionsWorldCoords.push(u()),this.positionsRenderCoords.push(u()),this.positionsProjectedWorldCoords.push(r()),this.positionsFittedRenderCoords.push(u()),this.positionsGeographic.push(u()),this.positionsSpherical.push(u()),this.positionsStereographic.push(r()),this.pathSegmentLengths.push(0),this.geodesicPathSegmentLengths.push(0),this.perimeterSegmentLengths.push(0),++this._length}_updatePathLengths(e){const t=this.positionsWorldCoords,s=this.pathSegmentLengths;let i=0;for(let o=0;o<this._length;++o){const r=s[o]=n(t[o],t[(o+1)%this._length]);(o<this._length-1||e)&&(i+=r)}return i}_updateGeodesicPathLengths(e,t){const s=this.positionsGeographic,i=this.geodesicPathSegmentLengths;let o=0;for(let r=0;r<this._length;++r){const n=i[r]=z(s[r],s[(r+1)%this._length],t??void 0);(r<this._length-1||e)&&(o+=n)}return o}_updateAreaAndPerimeterLength(e,o,r,n,m){const u=e.renderCoordsHelper,_=this.positionsWorldCoords,f=this.positionsRenderCoords,S=this.positionsProjectedWorldCoords,C=this.positionsFittedRenderCoords,L=this._planeWorldCoords,P=this._centroidRenderCoords;N(f,P),u.worldUpAtPosition(P,this._worldUp),u.worldBasisAtPosition(P,v.X,this._worldTangent),j(P,this._worldUp,r,this._worldUp,n),j(P,this._worldTangent,r,this._worldTangent,n),_.length>2&&U(_,L),this.fittingMode=this._selectFittingMode(L,_,this._worldUp,m);let R=0;if("horizontal"===this.fittingMode){let e=-1/0;f.forEach(((t,s)=>{const i=u.getAltitude(f[s]);i>e&&(e=i,R=s)}))}const M=_[R];let V=L,W=this._worldTangent;"horizontal"===this.fittingMode?V=this._worldUp:"vertical"===this.fittingMode&&(V=this._tempVec3,W=this._worldUp,b(L,this._worldUp,V)),h(this._frame[2],V),b(W,V,this._frame[0]),a(this._frame[1],this._frame[0],this._frame[2]),d(this._frame[1],this._frame[1]);const I=this._tempVec3,w=this._tempU,z=this._tempV;for(let t=0;t<this._length;++t){const e=S[t],s=C[t];g(I,_[t],M),i(e,l(this._frame[0],I),l(this._frame[1],I)),p(w,this._frame[0],e[0]),p(z,this._frame[1],e[1]),c(I,w,z),c(I,I,M),A(I,n,s,r)}this.perimeterLength=this._length>0?t(o.normalizeDistance(this._updatePerimeterLengths()),"meters"):null,N(C,this.areaCentroidRenderCoords),A(this.areaCentroidRenderCoords,r,this.areaCentroidWorldCoords,n),this._updateIntersectingSegments(),this.area=0===this.intersectingSegments.size?s(o.normalizeArea(this._computeArea()),"square-meters"):null}_updateGeodesicArea(e){const{renderCoordsHelper:t,spatialReference:o}=e,{positionsSpherical:r,positionsStereographic:n}=this,h=this._tempVec3,a=G(r,h);if(!a)return void(this.geodesicArea=null);const d=this._tempU,g=this._tempV;k(h,d,g);for(let s=0;s<this._length;++s){const e=l(r[s],d),t=l(r[s],g),o=l(r[s],h);i(n[s],e/o,t/o)}p(h,h,f(o).radius),t.toRenderCoords(h,P(o),this.geodesicAreaCentroidRenderCoords),this._updateGeodesicIntersectingSegments(),this.geodesicArea=a&&0===this.geodesicIntersectingSegments.size?s(this._computeGeodesicArea(),"square-meters"):null}_updatePerimeterLengths(){const e=this.positionsProjectedWorldCoords,t=this.perimeterSegmentLengths;let s=0;for(let i=0;i<this._length;++i){s+=t[i]=o(e[i],e[(i+1)%this._length])}return s}_updateIntersectingSegments(){const e=this.positionsProjectedWorldCoords,t=this.intersectingSegments;t.clear();for(let s=0;s<this._length;++s)for(let i=s+2;i<this._length;++i){if((i+1)%this._length===s)continue;const o=e[s],r=e[(s+1)%this._length],n=e[i],h=e[(i+1)%this._length];W(o,r,n,h)&&(t.add(s),t.add(i))}}_computeArea(){const e=this.positionsProjectedWorldCoords,t=this.triangleIndices=V(D(e));let s=0;for(let i=0;i<t.length;i+=3)s+=I(e[t[i]],e[t[i+1]],e[t[i+2]]);return s}_updateGeodesicIntersectingSegments(){const e=this.positionsStereographic,t=this.geodesicIntersectingSegments;t.clear();for(let s=0;s<this._length;++s)for(let i=s+2;i<this._length;++i){if((i+1)%this._length===s)continue;const o=e[s],r=e[(s+1)%this._length],n=e[i],h=e[(i+1)%this._length];W(o,r,n,h)&&(t.add(s),t.add(i))}}_computeGeodesicArea(){const e=this.positionsGeographic,t=this.positionsStereographic,s=this.geodesicTriangleIndices=V(D(t));let i=0;for(let o=0;o<s.length;o+=3)i+=y(e[s[o]],e[s[o+1]],e[s[o+2]],L.WGS84);return i}_selectFittingMode(t,s,i,o){const r=s.map((e=>Math.abs(T(t,e)))).reduce(((e,t)=>Math.max(e,t)),0);x(s,this._tempSphere);const n=r/(2*this._tempSphere.radius),h=n<o.maxRelativeErrorCoplanar,a=n<o.maxRelativeErrorAlmostCoplanar;let d="horizontal";if(h)d="oblique";else if(a){d=Math.abs(l(i,t))>Math.cos(e(o.verticalAngleThreshold))?"horizontal":"vertical"}return d}_updateCursorSegmentLength(e,s){const i=e.lastPoint;e.isValidPolygon||null==i||null==s?(this.geodesicStagedSegmentLength=null,this.stagedSegmentLength=null):(this.geodesicStagedSegmentLength=t(E(i,s),"meters"),this.stagedSegmentLength=t(this.unitNormalizer.normalizeDistance(F(i,s,this.unitNormalizer.spatialReference)),"meters"))}_updateMode(e){if(e===w.Auto){this.actualMeasurementMode="euclidean";let e=0;null!=this.geodesicPathLength&&(e+=this.geodesicPathLength.value),e>X&&(this.actualMeasurementMode="geodesic")}else this.actualMeasurementMode=e===w.Euclidean?"euclidean":"geodesic";null==this.geodesicPathLength&&(this.actualMeasurementMode="euclidean"),this._mode=e}}function H(e,t){t.hasZ||(t.z=q(e,t,"ground")??0)}const X=1e5;export{B as MeasurementDataManager};
|
|
5
|
+
import{deg2rad as e}from"../../../../../core/mathUtils.js";import{createLength as t,createArea as s}from"../../../../../core/quantityUtils.js";import{s as i,d as o}from"../../../../../chunks/vec2.js";import{a as r}from"../../../../../chunks/vec2f64.js";import{m as n,c as h,b as a,E as d,f as l,j as g,i as p,g as c,n as m}from"../../../../../chunks/vec3.js";import{c as u}from"../../../../../chunks/vec3f64.js";import{c as _}from"../../../../../chunks/vec4f64.js";import{getReferenceEllipsoid as f}from"../../../../../geometry/ellipsoidUtils.js";import{canProjectWithoutEngine as C,canProjectToWGS84ComparableLonLat as S}from"../../../../../geometry/projection.js";import L from"../../../../../geometry/SpatialReference.js";import{getSphericalPCPF as P}from"../../../../../geometry/spatialReferenceEllipsoidUtils.js";import{projectDirection as j}from"../../../../../geometry/projection/projectDirection.js";import{projectPointToVector as R}from"../../../../../geometry/projection/projectPointToVector.js";import{projectPointToWGS84ComparableLonLat as M}from"../../../../../geometry/projection/projectPointToWGS84ComparableLonLat.js";import{projectVectorToVector as A}from"../../../../../geometry/projection/projectVectorToVector.js";import{Axis as v}from"../../../../../geometry/support/Axis.js";import{compactIndices as V}from"../../../../../geometry/support/Indices.js";import{segmentIntersects as W}from"../../../../../geometry/support/intersectsBase.js";import{areaPoints2d as I}from"../../../../../geometry/support/triangle.js";import{MeasurementMode as w}from"../../interfaces.js";import{segmentLengthGeodesicVector as z,bestFitPlane as U,fitHemisphere as G,triangleAreaGeodesic as y,planePointDistance as T,boundingSphere as x,segmentLengthGeodesic as E,segmentLengthEuclidean as F}from"../../support/measurementUtils.js";import{midpoint as N}from"../../support/viewUtils.js";import{getElevationAtPoint as q}from"../../../support/ElevationProvider.js";import{makeOrthonormal as b,tangentFrame as k}from"../../../support/mathUtils.js";import{triangulate as D}from"../../../../support/euclideanAreaMeasurementUtils.js";class B{get numVertices(){return this._length}get hasStagedVertex(){return this._hasCursorPoint}constructor(e,t){this.validMeasurement=!1,this.positionsWorldCoords=[],this.positionsRenderCoords=[],this.positionsProjectedWorldCoords=[],this.positionsFittedRenderCoords=[],this.positionsGeographic=[],this.positionsSpherical=[],this.positionsStereographic=[],this.pathSegmentLengths=[],this.geodesicPathSegmentLengths=[],this.perimeterSegmentLengths=[],this.intersectingSegments=new Set,this.geodesicIntersectingSegments=new Set,this.triangleIndices=null,this.geodesicTriangleIndices=null,this.areaCentroidWorldCoords=u(),this.areaCentroidRenderCoords=u(),this.geodesicAreaCentroidRenderCoords=u(),this.area=null,this.geodesicArea=null,this.pathLength=null,this.geodesicPathLength=null,this.perimeterLength=null,this._length=0,this._centroidRenderCoords=u(),this._planeWorldCoords=_(),this._worldUp=u(),this._worldTangent=u(),this._frame=[u(),u(),u()],this._pathVersion=-1,this._hasCursorPoint=!1,this._mode=null,this._tempU=u(),this._tempV=u(),this._tempVec3=u(),this._tempSphere={center:u(),radius:0},this._sceneView=e,this.unitNormalizer=t}update(e,t,s,i,o,r){const n=null!=t,h=this._pathVersion===e.version,a=this._hasCursorPoint===n,d=this._mode===o;return!(h&&!r&&a&&d&&e.isValidPolygon)&&(this._pathVersion=e.version,this._hasCursorPoint=n,this._updateCursorSegmentLength(e,t),this._update(e,t,s,i,o),!0)}_update(e,s,i,o,r){const n=this.unitNormalizer,h=this._sceneView.renderSpatialReference,a=this.unitNormalizer.spatialReference;let d=e.numVertices;const l=!(null==s||s.equals(e.lastPoint)||d>2&&s.equals(e.firstPoint));l&&(d+=1);const g=!e.polygonIsClosed&&d>2,p=e.polygonIsClosed||g;this._resize(d);const c=P(i.spatialReference),u=C(i.spatialReference,c)&&S(i.spatialReference),{positionsGeographic:_,positionsWorldCoords:f,positionsRenderCoords:L,positionsSpherical:j}=this,A=(e,t)=>{H(i.elevationProvider,e),R(e,f[t],a),R(e,L[t],h),u&&(M(e,_[t]),R(e,j[t],c),m(j[t],j[t]))};e.forEachVertexPosition(((e,t)=>A(e,t))),l&&A(s,d-1);const v=this._updatePathLengths(p);if(this.pathLength=this._length>1?t(n.normalizeDistance(v),"meters"):null,u){const e=this._updateGeodesicPathLengths(p,a);this.geodesicPathLength=this._length>1?t(e,"meters"):null}else this.geodesicPathLength=null;if(this._updateMode(r),!p)return this.area=null,this.geodesicArea=null,this.perimeterLength=null,this.triangleIndices=null,this.geodesicTriangleIndices=null,this.intersectingSegments.clear(),this.geodesicIntersectingSegments.clear(),void(this.validMeasurement=!1);this._updateAreaAndPerimeterLength(i,n,h,a,o),u&&this._updateGeodesicArea(i),this.validMeasurement=!0}getData(){return{validMeasurement:this.validMeasurement,numVertices:this.numVertices,hasStagedVertex:this.hasStagedVertex,positionsWorldCoords:this.positionsWorldCoords,positionsRenderCoords:this.positionsRenderCoords,positionsProjectedWorldCoords:this.positionsProjectedWorldCoords,positionsFittedRenderCoords:this.positionsFittedRenderCoords,positionsGeographic:this.positionsGeographic,positionsSpherical:this.positionsSpherical,positionsStereographic:this.positionsStereographic,pathSegmentLengths:this.pathSegmentLengths,geodesicPathSegmentLengths:this.geodesicPathSegmentLengths,perimeterSegmentLengths:this.perimeterSegmentLengths,intersectingSegments:this.intersectingSegments,geodesicIntersectingSegments:this.geodesicIntersectingSegments,triangleIndices:this.triangleIndices,geodesicTriangleIndices:this.geodesicTriangleIndices,areaCentroidWorldCoords:this.areaCentroidWorldCoords,areaCentroidRenderCoords:this.areaCentroidRenderCoords,geodesicAreaCentroidRenderCoords:this.geodesicAreaCentroidRenderCoords,fittingMode:this.fittingMode,area:this.area,geodesicArea:this.geodesicArea,pathLength:this.pathLength,geodesicPathLength:this.geodesicPathLength,perimeterLength:this.perimeterLength,unitNormalizer:this.unitNormalizer,actualMeasurementMode:this.actualMeasurementMode}}_resize(e){for(e<this._length&&(this.positionsWorldCoords.length=e,this.positionsRenderCoords.length=e,this.positionsProjectedWorldCoords.length=e,this.positionsFittedRenderCoords.length=e,this.positionsGeographic.length=e,this.positionsSpherical.length=e,this.positionsStereographic.length=e,this.pathSegmentLengths.length=e,this.geodesicPathSegmentLengths.length=e,this.perimeterSegmentLengths.length=e,this._length=e);this._length<e;)this.positionsWorldCoords.push(u()),this.positionsRenderCoords.push(u()),this.positionsProjectedWorldCoords.push(r()),this.positionsFittedRenderCoords.push(u()),this.positionsGeographic.push(u()),this.positionsSpherical.push(u()),this.positionsStereographic.push(r()),this.pathSegmentLengths.push(0),this.geodesicPathSegmentLengths.push(0),this.perimeterSegmentLengths.push(0),++this._length}_updatePathLengths(e){const t=this.positionsWorldCoords,s=this.pathSegmentLengths;let i=0;for(let o=0;o<this._length;++o){const r=s[o]=n(t[o],t[(o+1)%this._length]);(o<this._length-1||e)&&(i+=r)}return i}_updateGeodesicPathLengths(e,t){const s=this.positionsGeographic,i=this.geodesicPathSegmentLengths;let o=0;for(let r=0;r<this._length;++r){const n=i[r]=z(s[r],s[(r+1)%this._length],t??void 0);(r<this._length-1||e)&&(o+=n)}return o}_updateAreaAndPerimeterLength(e,o,r,n,m){const u=e.renderCoordsHelper,_=this.positionsWorldCoords,f=this.positionsRenderCoords,C=this.positionsProjectedWorldCoords,S=this.positionsFittedRenderCoords,L=this._planeWorldCoords,P=this._centroidRenderCoords;N(f,P),u.worldUpAtPosition(P,this._worldUp),u.worldBasisAtPosition(P,v.X,this._worldTangent),j(P,this._worldUp,r,this._worldUp,n),j(P,this._worldTangent,r,this._worldTangent,n),_.length>2&&U(_,L),this.fittingMode=this._selectFittingMode(L,_,this._worldUp,m);let R=0;if("horizontal"===this.fittingMode){let e=-1/0;f.forEach(((t,s)=>{const i=u.getAltitude(f[s]);i>e&&(e=i,R=s)}))}const M=_[R];let V=L,W=this._worldTangent;"horizontal"===this.fittingMode?V=this._worldUp:"vertical"===this.fittingMode&&(V=this._tempVec3,W=this._worldUp,b(L,this._worldUp,V)),h(this._frame[2],V),b(W,V,this._frame[0]),a(this._frame[1],this._frame[0],this._frame[2]),d(this._frame[1],this._frame[1]);const I=this._tempVec3,w=this._tempU,z=this._tempV;for(let t=0;t<this._length;++t){const e=C[t],s=S[t];l(I,_[t],M),i(e,g(this._frame[0],I),g(this._frame[1],I)),p(w,this._frame[0],e[0]),p(z,this._frame[1],e[1]),c(I,w,z),c(I,I,M),A(I,n,s,r)}this.perimeterLength=this._length>0?t(o.normalizeDistance(this._updatePerimeterLengths()),"meters"):null,N(S,this.areaCentroidRenderCoords),A(this.areaCentroidRenderCoords,r,this.areaCentroidWorldCoords,n),this._updateIntersectingSegments(),this.area=0===this.intersectingSegments.size?s(o.normalizeArea(this._computeArea()),"square-meters"):null}_updateGeodesicArea(e){const{renderCoordsHelper:t,spatialReference:o}=e,{positionsSpherical:r,positionsStereographic:n}=this,h=this._tempVec3,a=G(r,h);if(!a)return void(this.geodesicArea=null);const d=this._tempU,l=this._tempV;k(h,d,l);for(let s=0;s<this._length;++s){const e=g(r[s],d),t=g(r[s],l),o=g(r[s],h);i(n[s],e/o,t/o)}p(h,h,f(o).radius),t.toRenderCoords(h,P(o),this.geodesicAreaCentroidRenderCoords),this._updateGeodesicIntersectingSegments(),this.geodesicArea=a&&0===this.geodesicIntersectingSegments.size?s(this._computeGeodesicArea(),"square-meters"):null}_updatePerimeterLengths(){const e=this.positionsProjectedWorldCoords,t=this.perimeterSegmentLengths;let s=0;for(let i=0;i<this._length;++i){s+=t[i]=o(e[i],e[(i+1)%this._length])}return s}_updateIntersectingSegments(){const e=this.positionsProjectedWorldCoords,t=this.intersectingSegments;t.clear();for(let s=0;s<this._length;++s)for(let i=s+2;i<this._length;++i){if((i+1)%this._length===s)continue;const o=e[s],r=e[(s+1)%this._length],n=e[i],h=e[(i+1)%this._length];W(o,r,n,h)&&(t.add(s),t.add(i))}}_computeArea(){const e=this.positionsProjectedWorldCoords,t=this.triangleIndices=V(D(e));let s=0;for(let i=0;i<t.length;i+=3)s+=I(e[t[i]],e[t[i+1]],e[t[i+2]]);return s}_updateGeodesicIntersectingSegments(){const e=this.positionsStereographic,t=this.geodesicIntersectingSegments;t.clear();for(let s=0;s<this._length;++s)for(let i=s+2;i<this._length;++i){if((i+1)%this._length===s)continue;const o=e[s],r=e[(s+1)%this._length],n=e[i],h=e[(i+1)%this._length];W(o,r,n,h)&&(t.add(s),t.add(i))}}_computeGeodesicArea(){const e=this.positionsGeographic,t=this.positionsStereographic,s=this.geodesicTriangleIndices=V(D(t));let i=0;for(let o=0;o<s.length;o+=3)i+=y(e[s[o]],e[s[o+1]],e[s[o+2]],L.WGS84);return i}_selectFittingMode(t,s,i,o){const r=s.map((e=>Math.abs(T(t,e)))).reduce(((e,t)=>Math.max(e,t)),0);x(s,this._tempSphere);const n=r/(2*this._tempSphere.radius),h=n<o.maxRelativeErrorCoplanar,a=n<o.maxRelativeErrorAlmostCoplanar;let d="horizontal";if(h)d="oblique";else if(a){d=Math.abs(g(i,t))>Math.cos(e(o.verticalAngleThreshold))?"horizontal":"vertical"}return d}_updateCursorSegmentLength(e,s){const i=e.lastPoint;e.isValidPolygon||null==i||null==s?(this.geodesicStagedSegmentLength=null,this.stagedSegmentLength=null):(this.geodesicStagedSegmentLength=t(E(i,s),"meters"),this.stagedSegmentLength=t(this.unitNormalizer.normalizeDistance(F(i,s,this.unitNormalizer.spatialReference)),"meters"))}_updateMode(e){if(e===w.Auto){this.actualMeasurementMode="euclidean";let e=0;null!=this.geodesicPathLength&&(e+=this.geodesicPathLength.value),e>X&&(this.actualMeasurementMode="geodesic")}else this.actualMeasurementMode=e===w.Euclidean?"euclidean":"geodesic";null==this.geodesicPathLength&&(this.actualMeasurementMode="euclidean"),this._mode=e}}function H(e,t){t.hasZ||(t.z=q(e,t,"ground")??0)}const X=1e5;export{B as MeasurementDataManager};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.28/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../../chunks/tslib.es6.js";import i from"../../../../Color.js";import"../../../../intl.js";import s from"../../../../core/Accessor.js";import{makeHandle as t,destroyHandle as a}from"../../../../core/handleUtils.js";import{mapCollection as r,watch as n,syncAndInitial as o,when as l,sync as m}from"../../../../core/reactiveUtils.js";import{pt2px as c}from"../../../../core/screenUtils.js";import{property as d}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/accessorSupport/ensureType.js";import"../../../../core/arrayUtils.js";import"../../../../core/has.js";import{subclass as h}from"../../../../core/accessorSupport/decorators/subclass.js";import{Z as p}from"../../../../chunks/vec4f64.js";import{LengthDimensionVisualization as u}from"./LengthDimensionVisualization.js";import{
|
|
5
|
+
import{_ as e}from"../../../../chunks/tslib.es6.js";import i from"../../../../Color.js";import"../../../../intl.js";import s from"../../../../core/Accessor.js";import{makeHandle as t,destroyHandle as a}from"../../../../core/handleUtils.js";import{mapCollection as r,watch as n,syncAndInitial as o,when as l,sync as m}from"../../../../core/reactiveUtils.js";import{pt2px as c}from"../../../../core/screenUtils.js";import{property as d}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/accessorSupport/ensureType.js";import"../../../../core/arrayUtils.js";import"../../../../core/has.js";import{subclass as h}from"../../../../core/accessorSupport/decorators/subclass.js";import{Z as p}from"../../../../chunks/vec4f64.js";import{LengthDimensionVisualization as u}from"./LengthDimensionVisualization.js";import{markerLineSizeFraction as f,offsetLineSizeFraction as g}from"./settings.js";import{RenderOccludedFlag as M}from"../../webgl-engine/lib/Material.js";import{LineMarkerMaterial as _}from"../../webgl-engine/materials/LineMarkerMaterial.js";import{createStipplePatternSimple as y}from"../../webgl-engine/materials/lineStippleUtils.js";import{RibbonLineMaterial as w}from"../../webgl-engine/materials/RibbonLineMaterial.js";import{LineMarkerAnchor as v}from"../../webgl-engine/shaders/LineMarkerTechniqueConfiguration.js";import{onLocaleChange as L}from"../../../../intl/locale.js";import{fetchMessageBundle as j}from"../../../../intl/messages.js";let b=class extends s{get analysis(){return this.analysisViewData.analysis}get visible(){return this.analysisViewData.visible}constructor(e){super(e),this.loadingMessages=!1,this._messages=null}initialize(){const e=this.isDecoration;this._markerMaterial=new _({width:1,anchor:v.Tip,color:p,placement:"begin-end",worldSpace:!0,hideOnShortSegments:!0,hasTip:!0,renderOccluded:M.OccludeAndTransparent,markerPrimitive:"triangle",isDecoration:e}),this._dimensionLineMaterial=new w({width:1,color:p,renderOccluded:M.OccludeAndTransparent,markerParameters:this._markerMaterial.parameters,isDecoration:e}),this._offsetLineMaterial=new w({width:1,color:p,renderOccluded:M.OccludeAndTransparent,stipplePattern:y(5),isDecoration:e}),this._smallDimensionLineMaterial=new w({width:1,color:p,renderOccluded:M.OccludeAndTransparent,isDecoration:e}),this._smallOffsetLineMaterial=new w({width:1,color:p,renderOccluded:M.OccludeAndTransparent,stipplePattern:y(5),isDecoration:e});for(const i of this._lineMaterials())this.view._stage.add(i),this.addHandles(t((()=>{this.view._stage?.remove(i)})));const s=r((()=>this.analysisViewData.computations),(({computation:e})=>this._createVisualization(e)));this._dimensionVisualizations=s,this.addHandles([a(s),n((()=>i.toUnitRGBA(this.analysis.style.color)),(e=>{for(const i of this._lineMaterials())i.setParameters({color:e})}),o),n((()=>this.analysis.style.lineSize),(e=>{const i=c(e);this._markerMaterial.setParameters({width:i*f}),this._dimensionLineMaterial.setParameters({width:i,markerParameters:this._markerMaterial.parameters});const s=Math.max(i*g,1);this._offsetLineMaterial.setParameters({width:s})}),o),n((()=>({camera:this.view.state.camera,style:z(this.analysis)})),(({camera:e,style:i})=>{for(const{visualization:s}of this._dimensionVisualizations)s.updateCameraDependentElements(e,s.computation.geometry,i),s.updateLabelStyle(i)})),n((()=>this.visible),(e=>{for(const{visualization:i}of this._dimensionVisualizations)i.visible=e}))]),this.addHandles([L((()=>this._updateMessageBundle())),l((()=>!this.loadingMessages),(()=>{for(const{visualization:e}of this._dimensionVisualizations)e.updateUnitsMessages(this._messages)}),m)]),this._updateMessageBundle()}get testInfo(){return{visualizations:this._dimensionVisualizations.items.map((({visualization:e})=>e)),disablePartialOcclusion:()=>{for(const e of this._lineMaterials())e.setParameters({renderOccluded:M.Occlude})}}}_createVisualization(e){const i=new u({analysis:this.analysis,computation:e,view:this.view,visible:this.visible,markerMaterial:this._markerMaterial,dimensionLineMaterial:this._dimensionLineMaterial,offsetLineMaterial:this._offsetLineMaterial,smallDimensionLineMaterial:this._smallDimensionLineMaterial,smallOffsetLineMaterial:this._smallOffsetLineMaterial,messages:this._messages,isDecoration:this.isDecoration});return{visualization:i,remove:()=>i.destroy()}}_lineMaterials(){return[this._markerMaterial,this._dimensionLineMaterial,this._offsetLineMaterial,this._smallDimensionLineMaterial,this._smallOffsetLineMaterial]}async _updateMessageBundle(){this.loadingMessages=!0;try{this._messages=await j("esri/core/t9n/Units")}finally{this.loadingMessages=!1}}};function z(e){const{fontSize:i,lineSize:s,textColor:t,textBackgroundColor:a}=e.style;return{fontSize:i,lineSize:s,textBackgroundColor:a.clone(),textColor:t.clone()}}e([d({constructOnly:!0})],b.prototype,"analysisViewData",void 0),e([d({constructOnly:!0,nonNullable:!0})],b.prototype,"view",void 0),e([d({constructOnly:!0})],b.prototype,"isDecoration",void 0),e([d()],b.prototype,"analysis",null),e([d()],b.prototype,"visible",null),e([d()],b.prototype,"loadingMessages",void 0),b=e([h("esri.views.3d.analysis.Dimension.DimensionVisualization")],b);export{b as DimensionVisualization};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.28/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as t}from"../../../../chunks/tslib.es6.js";import e from"../../../../Color.js";import"../../../../geometry.js";import{LengthDimensionMeasureType as i}from"../../../../analysis/dimensionUtils.js";import n from"../../../../analysis/LengthDimension.js";import a from"../../../../core/Accessor.js";import s from"../../../../core/Handles.js";import{destroyHandle as o}from"../../../../core/handleUtils.js";import{equals as r}from"../../../../core/lang.js";import{destroyMaybe as p}from"../../../../core/maybe.js";import{memoize as l}from"../../../../core/memoize.js";import{ignoreAbortErrors as u}from"../../../../core/promiseUtils.js";import{mapCollection as d,watch as c,sync as m,syncAndInitial as h,initial as g,when as f}from"../../../../core/reactiveUtils.js";import{property as _}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/accessorSupport/ensureType.js";import{subclass as M}from"../../../../core/accessorSupport/decorators/subclass.js";import{c as y}from"../../../../chunks/vec3f64.js";import{UpdatingHandles as v}from"../../../../core/support/UpdatingHandles.js";import{clonePoint as S}from"../../../../layers/graphics/hydratedFeatures.js";import{reapplyConstraint as C,LengthDimensionConstraint as w,applyConstraint as b,computeConstraint as D,constraintDependencies as O}from"./lengthDimensionConstraintUtils.js";import{LengthDimensionManipulators as P,createPointManipulator as j,pointManipulatorHandles as H,createOffsetManipulator as T,offsetManipulatorHandles as G,createOrientationManipulator as I,headingManipulatorHandles as z,rotationManipulatorHandles as x,createMeasureTypeManipulator as U,measureTypeManipulatorHandles as V,updateOffsetManipulatorTransform as R,updateHeadingManipulatorTransform as A,updateRotationManipulatorTransform as k,updateMeasureTypeManipulatorTransform as E,updateOrientationManipulator as F,unfocusedOffsetWidth as L,focusedOffsetWidth as q}from"./lengthDimensionManipulatorUtils.js";import{isValidComputation as B,arePointsVerticallyAligned as N,computeGeometryFromDimension as J,computationToGeometryDependencies as K}from"./lengthDimensionUtils.js";import{Settings as Q}from"./settings.js";import{getRotateHeadingTexture as W}from"../images/Factory.js";import{SnappingVisualizer3D as X}from"../../interactive/SnappingVisualizer3D.js";import{LineVisualElement as Y}from"../../interactive/visualElements/LineVisualElement.js";import{VerticesVisualElement as Z}from"../../interactive/visualElements/VerticesVisualElement.js";import{RenderOccludedFlag as $}from"../../webgl-engine/lib/Material.js";import{ImageMaterial as tt}from"../../webgl-engine/materials/ImageMaterial.js";import{createStipplePatternSimple as et}from"../../webgl-engine/materials/lineStippleUtils.js";import{RibbonLineMaterial as it}from"../../webgl-engine/materials/RibbonLineMaterial.js";import{createCoordinateHelper as nt}from"../../../interactive/coordinateHelper.js";import{EditGeometry as at}from"../../../interactive/editGeometry/EditGeometry.js";import{EditGeometryOperations as st}from"../../../interactive/editGeometry/EditGeometryOperations.js";import{acquire as ot}from"../../../interactive/snapping/SceneSnappingManagerPool.js";import{SnappingContext as rt}from"../../../interactive/snapping/SnappingContext.js";import{createSnapDragEventPipelineStep as pt}from"../../../interactive/snapping/SnappingDragPipelineStep.js";import{SnappingOperation as lt}from"../../../interactive/snapping/SnappingOperation.js";import{setupSnappingToggleHandles as ut}from"../../../interactive/snapping/snappingUtils.js";import dt from"../../../../geometry/Point.js";let ct=class extends a{constructor(t){super(t),this._stagedDimension=null,this._computationManipulators=new Map,this._computationHandles=new s,this._updatingHandles=new v,this._getSnappingContext=l((t=>new rt({elevationInfo:{mode:"absolute-height",offset:0},pointer:t,editGeometryOperations:new st(new at("point",nt(!0,!1,this.view.spatialReference))),visualizer:new X})));const{view:i}=t;this._settings=new Q(i.effectiveTheme),this._snappingManagerResult=ot(i),this.addHandles(this._snappingManagerResult),this._unfocusedOffsetManipulatorMaterial=this._createOffsetManipulatorMaterial(),this._focusedOffsetManipulatorMaterial=this._createOffsetManipulatorMaterial(),this._thinOffsetManipulatorMaterial=this._createOffsetManipulatorMaterial(),this._thinOffsetManipulatorMaterial.setParameters({stipplePattern:et(2)}),this._constraintSnappingIndicator=new Y({view:i,attached:!0,width:1,color:e.toUnitRGBA(this._settings.constraint.color),renderOccluded:$.OccludeAndTransparent,stipplePattern:et(5),isDecoration:!0});const n=e.toUnitRGBA(this._settings.disabledPointIndicator.color);this._stagedStartIndicator=new Z({view:i,attached:!1,elevationInfo:{mode:"absolute-height",offset:0},spatialReference:t.view.renderCoordsHelper.spatialReference,color:n,size:2*this._settings.disabledPointIndicator.radius,outlineSize:0,renderOccluded:$.OccludeAndTransparent,isDecoration:!0})}initialize(){this._snappingOperation=new lt({view:this.view});const{color:t,contrastColor:e}=this._settings.orientationManipulator,i=!this.view._stage?.renderView.renderingContext.driverTest.svgPremultipliesAlpha.result;this._orientationManipulatorTexture=W(this.view.toolViewManager.textures,{accentColor:t,contrastColor:e,preMultiplyAlpha:i}),this._orientationManipulatorMaterial=new tt({transparent:!0,writeDepth:!1,textureId:this._orientationManipulatorTexture.texture.id,renderOccluded:$.Opaque,isDecoration:!0});const n=d((()=>this.analysisViewData.computations),(({computation:t})=>this._createManipulators(t)));this.addHandles(o(n)),this.addHandles([c((()=>({stagedPoint:this._snappingOperation.stagedPoint,stagedComputation:this._stagedComputation})),(({stagedPoint:t,stagedComputation:e})=>{if(null==e||null==t)return;const i=S(t,new dt);this._applyPointUpdate(e,{endPoint:i})}),m),c((()=>({stagedDimension:this._stagedDimension,selectedComputation:this.analysisViewData.selectedComputation,firstGrabbedManipulator:this.firstGrabbedManipulator})),((t,e)=>{const{stagedDimension:i,selectedComputation:n,firstGrabbedManipulator:a}=t;if(i===e?.stagedDimension&&a===e?.firstGrabbedManipulator){for(const s of[n,e?.selectedComputation])if(null!=s){const e=this._computationManipulators.get(s);null!=e&&this._updateManipulators(s,e,t)}}else for(const[s,o]of this._computationManipulators)this._updateManipulators(s,o,t)}),h),c((()=>this.analysis.style.lineSize),(t=>{this._updateManipulatorStyle(t)}),g),c((()=>this.view.state.camera),(()=>{null!=this._stagedComputation&&this._updateStagedDimensionOffset(this._stagedComputation)})),c((()=>{const t=this._stagedComputation;if(!t)return null;const e=t.elevationAlignedStartPoint,i=y();return null!=e&&this.view.renderCoordsHelper.toRenderCoords(e,i)?i:null}),(t=>{null!=t?(this._stagedStartIndicator.vertices=[t],this._stagedStartIndicator.attached=!0):this._stagedStartIndicator.attached=!1}))]),this.addHandles(this._constraintHandles),this.addHandles(this._snappingIndicatorHandles),ut(this,(()=>{const t=this._activeComputation,e=this._stagedComputation;if(null==t||null!=e){const t=this.view.inputManager.latestPointerType??"mouse",e=this._getSnappingContext(t);this._updatingHandles.addPromise(u(this._snappingOperation.resnap(this._snappingManager,e)))}if(null!=t){const{start:e,end:i}=this._computationManipulators.get(t);if(e.grabbing||i.grabbing){const i=e.grabbing?"start":"end",n=this._computeConstraint(t);C(t,i,{constraint:n,view:this.view})}}}))}destroy(){this._snappingOperation=p(this._snappingOperation),this._computationHandles.destroy(),this._constraintSnappingIndicator.destroy(),this._stagedStartIndicator.destroy(),this._orientationManipulatorTexture.release()}get updating(){return this._updatingHandles.updating||this._snappingManager.updating}get firstGrabbedManipulator(){return this.parentTool.firstGrabbedManipulator}get hasGrabbedManipulators(){return this.parentTool.hasGrabbedManipulators}get snappingOptions(){return this._snappingManager.options}get _snappingManager(){return this._snappingManagerResult.snappingManager}get _activeComputation(){if(null!=this._stagedComputation)return this._stagedComputation;const{selectedComputation:t}=this.analysisViewData;return this.hasGrabbedManipulators&&null!=t?t:null}get _stagedComputation(){const t=this._stagedDimension,e=this.analysisViewData.computations.at(-1)?.computation;return null==t||null==e||e.dimension!==t?null:e}get _constraintHandles(){return[f((()=>this.analysisViewData.selectedComputation),(t=>{t.previousConstraint=this._computeConstraint(t)}),{...h,equals:r}),c((()=>{const t=this._activeComputation;if(null==t)return null;const{measureType:e,orientation:i}=t.dimension;return{measureType:e,orientation:i,computation:t}}),((t,e)=>{if(null!=t&&null==e){const{measureType:e,orientation:n,computation:a}=t;switch(a.previousConstraint){case w.Horizontal:a.preConstraintProperties={measureType:i.Horizontal,orientation:0};break;case w.Vertical:a.preConstraintProperties={measureType:i.Vertical,orientation:0};break;case w.Direct:a.preConstraintProperties={measureType:i.Direct,orientation:n};break;default:a.preConstraintProperties={measureType:e,orientation:n}}}null==t&&null!=e&&(e.computation.preConstraintProperties=null)}),m)]}get _snappingIndicatorHandles(){const t="snapping-indicator-event-handles";return[c((()=>({stagedComputation:this._stagedComputation,activeComputation:this._activeComputation})),(({stagedComputation:e,activeComputation:i})=>{const n=this._constraintSnappingIndicator;if(this.removeHandles(t),null!=i)if(i===e)n.attached=!0;else{const{start:e,end:a}=this._computationManipulators.get(i),s=()=>{n.attached=e.grabbing||a.grabbing};s(),this.addHandles([e.events.on("grab-changed",s),a.events.on("grab-changed",s)],t)}else n.attached=!1})),c((()=>{const t=this._activeComputation;return null!=t?{geometry:t.geometry,constraint:t.previousConstraint}:{}}),(({geometry:t,constraint:e})=>{const i=this._constraintSnappingIndicator;null!=t&&null!=e&&e!==w.Direct?(i.visible=!0,i.setGeometryFromSegment(t.directSegment)):i.visible=!1}))]}removeStaged(){return null!=this._stagedDimension&&(this.analysis.dimensions.remove(this._stagedDimension),this._stagedDimension=null,!0)}onDeactivate(){this.removeStaged(),this._resetSnappingState()}onClick(t){const{_stagedDimension:e}=this;if(null==e){const e=this._onUnstagedClick(t);return this.analysis.dimensions.add(e),null}return this._onStagedClick(t),e}onPointerMove({mapPoint:t,pointerType:e}){if("touch"===e)return;const i=this._getSnappingContext(e);this._updatingHandles.addPromise(u(this._snappingOperation.snap({point:t},this._snappingManager,i)))}onManipulatorSelectionChanged(){if(null!=this.analysisViewData.selectedComputation){this._computationManipulators.get(this.analysisViewData.selectedComputation).offset.selected||(this.analysisViewData.selectedDimension=null)}}_onUnstagedClick({mapPoint:t,pointerType:e}){let a=t;if("mouse"===e){const i=this._getSnappingContext(e);a=this._snappingManager.update({point:t,context:i})}const s=new n({startPoint:S(a,new dt),endPoint:null,measureType:i.Horizontal});return this._stagedDimension=s,this._resetSnappingState(),s}_onStagedClick({mapPoint:t,pointerType:e}){const i=this._stagedComputation;if(null==i)return;let n=t;if("mouse"===e){const i=this._getSnappingContext(e);n=this._snappingManager.update({point:t,context:i})}const a=S(n,new dt);this._applyPointUpdate(i,{endPoint:a}),this._stagedDimension=null,this._resetSnappingState()}_resetSnappingState(){this._snappingManager.doneSnapping(),this._snappingOperation.abort(),this._snappingOperation.stagedPoint=null}_createManipulators(t){const e=this._setupPointManipulator(t,{isStart:!0}),n=this._setupPointManipulator(t,{isStart:!1}),a=this._setupOffsetManipulator(t),s=this._setupHeadingManipulator(t),o=this._setupRotationManipulator(t),r=this._setupMeasureTypeManipulator(t,i.Direct),p=this._setupMeasureTypeManipulator(t,i.Horizontal),l=this._setupMeasureTypeManipulator(t,i.Vertical),u=new P({start:e,end:n,offset:a,heading:s,rotation:o,direct:r,horizontal:p,vertical:l});return this._setupComputationToManipulatorsSync(t,u),this._computationManipulators.set(t,u),this.manipulators.addMany(u.values()),{manipulators:u,remove:()=>{this._computationHandles.remove(t),this._computationManipulators.delete(t);for(const t of u.values())this.manipulators.remove(t)}}}_setupComputationToManipulatorsSync(t,e){this._computationHandles.add([c((()=>t.geometry),(()=>this._updateManipulators(t,e)),{...h,equals:r})],t)}_setupPointManipulator(t,e){const{view:i}=this,{dimension:n}=t,a=j(i,{metadata:n}),s=H(a,{isStart:e.isStart,createSnappingPipelineStep:t=>pt({snappingContext:this._getSnappingContext(t),snappingManager:this._snappingManager,updatingHandles:this._updatingHandles}),dimension:n,onUpdate:e=>this._applyPointUpdate(t,e),view:i});return this._computationHandles.add(s,t),a}_setupOffsetManipulator(t){const{view:e}=this,i=T(e,{lineSizePt:this.analysis.style.lineSize,unfocusedMaterial:this._unfocusedOffsetManipulatorMaterial,focusedMaterial:this._focusedOffsetManipulatorMaterial,metadata:t.dimension}),n=G(i,{computation:t,view:e});return this._computationHandles.add(n,t),i}_setupHeadingManipulator(t){const{view:e}=this,i=I(e,{lineSizePt:this.analysis.style.lineSize,material:this._orientationManipulatorMaterial,metadata:t.dimension}),n=z(i,{computation:t,view:e});return this._computationHandles.add(n,t),i}_setupRotationManipulator(t){const{view:e}=this,i=I(e,{lineSizePt:this.analysis.style.lineSize,material:this._orientationManipulatorMaterial,metadata:t.dimension}),n=x(i,{computation:t,view:e});return this._computationHandles.add(n,t),i}_setupMeasureTypeManipulator(t,e){const{view:i}=this,n=U(i,{lineSizePt:this.analysis.style.lineSize,unfocusedMaterial:this._unfocusedOffsetManipulatorMaterial,focusedMaterial:this._focusedOffsetManipulatorMaterial,thinOffsetManipulatorMaterial:this._thinOffsetManipulatorMaterial,metadata:t.dimension}),a=V(n,{computation:t,manipulatorMeasureType:e,view:i});return this._computationHandles.add(a,t),n}_updateManipulators(t,e,n={stagedDimension:this._stagedDimension,selectedComputation:this.analysisViewData.selectedComputation,firstGrabbedManipulator:this.firstGrabbedManipulator}){const{stagedDimension:a,selectedComputation:s,firstGrabbedManipulator:o}=n,{start:r,end:p,offset:l,heading:u,rotation:d}=e,c=s===t,m=B(t),{dimension:h}=t;for(const i of e.values()){const t=m&&null==a&&(null==o||i===o);i===l?(i.available=t,i.selected=c):i.available=t&&c}if(!m)return;null!=this._computeConstraint(t)?e.forEachMeasureTypeManipulator((t=>t.available=!1)):e.manipulatorForMeasureType(h.measureType).available=!1;for(const _ of[u,d])h.measureType===i.Direct&&0!==h.offset||(_.available=!1);N(t)?d.available=!1:u.available=!1;const{geometry:g}=t;r.renderLocation=g.directSegment.startRenderSpace,p.renderLocation=g.directSegment.endRenderSpace;const{renderCoordsHelper:f}=this.view;R(l,g,f),u.available&&A(u,t,f),d.available&&k(d,t,f),e.forEachMeasureTypeManipulator(((e,i)=>{e.available&&E(e,t,i,f)}))}_updateManipulatorStyle(t){const e=L(t),i=q(t),n={lineSizePt:t,material:this._orientationManipulatorMaterial};for(const{offset:a,heading:s,rotation:o}of this._computationManipulators.values())a.radius=i/2,F(this.view,s,n),F(this.view,o,n);this._unfocusedOffsetManipulatorMaterial.setParameters({width:e}),this._focusedOffsetManipulatorMaterial.setParameters({width:i})}_applyPointUpdate(t,e){const{view:i}=this,n=K(t);"startPoint"in e&&(n.elevationAlignedStartPoint=e.startPoint),"endPoint"in e&&(n.elevationAlignedEndPoint=e.endPoint);const a=J(n,i.renderCoordsHelper);if(null==a)return;const s=this._computeConstraint({...n,geometry:a});b(t,e,{...n,constraint:s,unconstrainedGeometry:a,view:i}),t===this._stagedComputation&&this._updateStagedDimensionOffset(t)}_updateStagedDimensionOffset(t){if(null==t.geometry)return;t.geometry.directSegment.eval(.5,mt);const e=this.view.state.camera.computeRenderPixelSizeAt(mt);t.dimension.offset=this._settings.initialOffsetPx*e}_computeConstraint(t){return D(O(t,this._snappingManager.options),this.view)}_createOffsetManipulatorMaterial(){const{color:t}=this._settings.offsetManipulator;return new it({color:e.toUnitRGBA(t),width:1,renderOccluded:$.OccludeAndTransparent,writeDepth:!1,hasPolygonOffset:!0,isDecoration:!0})}get testInfo(){const t=t=>this.analysisViewData.computations.find((({computation:e})=>e.dimension===t))?.computation;return{disableManipulatorPartialOcclusion:()=>{this._stagedStartIndicator.renderOccluded=$.Occlude,this.manipulators.forEach((({manipulator:t})=>{for(const{geometry:e}of t.renderObjects)e.material.setParameters({renderOccluded:$.Occlude})}))},getManipulatorsForDimension:e=>this._computationManipulators.get(t(e)),getComputationForDimension:e=>t(e),getConstraintForDimension:e=>{const i=t(e);return null!=i?this._computeConstraint(i):null},stagedDimension:this._stagedDimension,stagedStartIndicator:this._stagedStartIndicator,constraintSnappingIndicator:this._constraintSnappingIndicator,snappingManager:this._snappingManager}}};t([_({constructOnly:!0})],ct.prototype,"analysis",void 0),t([_({constructOnly:!0})],ct.prototype,"analysisViewData",void 0),t([_({constructOnly:!0})],ct.prototype,"manipulators",void 0),t([_({constructOnly:!0})],ct.prototype,"parentTool",void 0),t([_({constructOnly:!0,nonNullable:!0})],ct.prototype,"view",void 0),t([_({readOnly:!0})],ct.prototype,"updating",null),t([_()],ct.prototype,"firstGrabbedManipulator",null),t([_()],ct.prototype,"hasGrabbedManipulators",null),t([_()],ct.prototype,"snappingOptions",null),t([_()],ct.prototype,"_stagedDimension",void 0),t([_()],ct.prototype,"_activeComputation",null),t([_()],ct.prototype,"_stagedComputation",null),ct=t([M("esri.views.3d.analysis.Dimension.LengthDimensionSubTool")],ct);const mt=y();export{ct as LengthDimensionSubTool};
|
|
5
|
+
import{_ as t}from"../../../../chunks/tslib.es6.js";import e from"../../../../Color.js";import"../../../../geometry.js";import{LengthDimensionMeasureType as i}from"../../../../analysis/dimensionUtils.js";import a from"../../../../analysis/LengthDimension.js";import n from"../../../../core/Accessor.js";import s from"../../../../core/Handles.js";import{destroyHandle as o}from"../../../../core/handleUtils.js";import{equals as r}from"../../../../core/lang.js";import{destroyMaybe as p}from"../../../../core/maybe.js";import{memoize as l}from"../../../../core/memoize.js";import{ignoreAbortErrors as u}from"../../../../core/promiseUtils.js";import{watch as d,initial as c,mapCollection as m,sync as h,syncAndInitial as g,when as f}from"../../../../core/reactiveUtils.js";import{property as _}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/accessorSupport/ensureType.js";import{subclass as M}from"../../../../core/accessorSupport/decorators/subclass.js";import{c as y}from"../../../../chunks/vec3f64.js";import{UpdatingHandles as v}from"../../../../core/support/UpdatingHandles.js";import{clonePoint as C}from"../../../../layers/graphics/hydratedFeatures.js";import{reapplyConstraint as S,LengthDimensionConstraint as w,applyConstraint as b,computeConstraint as O,constraintDependencies as P}from"./lengthDimensionConstraintUtils.js";import{LengthDimensionManipulators as D,LengthDimensionPointManipulator as j,pointManipulatorHandles as H,createOffsetManipulator as T,offsetManipulatorHandles as G,LineOfSightOrientationManipulator as z,headingManipulatorHandles as I,rotationManipulatorHandles as x,createMeasureTypeManipulator as V,measureTypeManipulatorHandles as U,updateOffsetManipulatorTransform as R,updateHeadingManipulatorTransform as A,updateRotationManipulatorTransform as k,updateMeasureTypeManipulatorTransform as E,unfocusedOffsetWidth as F,focusedOffsetWidth as L}from"./lengthDimensionManipulatorUtils.js";import{isValidComputation as q,arePointsVerticallyAligned as B,computeGeometryFromDimension as N,computationToGeometryDependencies as J}from"./lengthDimensionUtils.js";import{disabledPointColor as K,pointRadius as Q,getTransparentAccentColor as W,getContrastColor as X,initialOffsetPx as Y}from"./settings.js";import{getRotateHeadingTexture as Z}from"../images/Factory.js";import{SnappingVisualizer3D as $}from"../../interactive/SnappingVisualizer3D.js";import{LineVisualElement as tt}from"../../interactive/visualElements/LineVisualElement.js";import{VerticesVisualElement as et}from"../../interactive/visualElements/VerticesVisualElement.js";import{RenderOccludedFlag as it}from"../../webgl-engine/lib/Material.js";import{ImageMaterial as at}from"../../webgl-engine/materials/ImageMaterial.js";import{createStipplePatternSimple as nt}from"../../webgl-engine/materials/lineStippleUtils.js";import{RibbonLineMaterial as st}from"../../webgl-engine/materials/RibbonLineMaterial.js";import{createCoordinateHelper as ot}from"../../../interactive/coordinateHelper.js";import{EditGeometry as rt}from"../../../interactive/editGeometry/EditGeometry.js";import{EditGeometryOperations as pt}from"../../../interactive/editGeometry/EditGeometryOperations.js";import{acquire as lt}from"../../../interactive/snapping/SceneSnappingManagerPool.js";import{SnappingContext as ut}from"../../../interactive/snapping/SnappingContext.js";import{createSnapDragEventPipelineStep as dt}from"../../../interactive/snapping/SnappingDragPipelineStep.js";import{SnappingOperation as ct}from"../../../interactive/snapping/SnappingOperation.js";import{setupSnappingToggleHandles as mt}from"../../../interactive/snapping/snappingUtils.js";import ht from"../../../../geometry/Point.js";let gt=class extends n{constructor(t){super(t),this._stagedDimension=null,this._computationManipulators=new Map,this._computationHandles=new s,this._orientationManipulatorTexture=null,this._updatingHandles=new v,this._getSnappingContext=l((t=>new ut({elevationInfo:{mode:"absolute-height",offset:0},pointer:t,editGeometryOperations:new pt(new rt("point",ot(!0,!1,this.view.spatialReference))),visualizer:new $})));const{view:i}=t;this._snappingManagerResult=lt(i),this.addHandles(this._snappingManagerResult),this._unfocusedOffsetManipulatorMaterial=this._createOffsetManipulatorMaterial(),this._focusedOffsetManipulatorMaterial=this._createOffsetManipulatorMaterial(),this._thinOffsetManipulatorMaterial=this._createOffsetManipulatorMaterial(),this._thinOffsetManipulatorMaterial.setParameters({stipplePattern:nt(2)}),this._constraintSnappingIndicator=new tt({view:i,attached:!0,width:1,renderOccluded:it.OccludeAndTransparent,stipplePattern:nt(5),isDecoration:!0});const a=e.toUnitRGBA(K);this._stagedStartIndicator=new et({view:i,attached:!1,elevationInfo:{mode:"absolute-height",offset:0},spatialReference:t.view.renderCoordsHelper.spatialReference,color:a,size:2*Q,outlineSize:0,renderOccluded:it.OccludeAndTransparent,isDecoration:!0})}initialize(){const{view:t}=this;this._snappingOperation=new ct({view:t});const i=!t._stage?.renderView.renderingContext.driverTest.svgPremultipliesAlpha.result;this._orientationManipulatorMaterial=new at({transparent:!0,writeDepth:!1,renderOccluded:it.Opaque,isDecoration:!0}),this.addHandles(d((()=>({accentColor:W(t.effectiveTheme),contrastColor:X(t.effectiveTheme)})),(({accentColor:a,contrastColor:n})=>{const s=this._orientationManipulatorTexture,o=Z(t.toolViewManager.textures,{accentColor:a,contrastColor:n,preMultiplyAlpha:i});this._orientationManipulatorMaterial.setParameters({textureId:o.texture.id}),this._orientationManipulatorTexture=o,s?.release();const r=e.toUnitRGBA(a);this._unfocusedOffsetManipulatorMaterial.setParameters({color:r}),this._focusedOffsetManipulatorMaterial.setParameters({color:r}),this._thinOffsetManipulatorMaterial.setParameters({color:r}),this._constraintSnappingIndicator.color=r}),c));const a=m((()=>this.analysisViewData.computations),(({computation:t})=>this._createManipulators(t)));this.addHandles(o(a)),this.addHandles([d((()=>({stagedPoint:this._snappingOperation.stagedPoint,stagedComputation:this._stagedComputation})),(({stagedPoint:t,stagedComputation:e})=>{if(null==e||null==t)return;const i=C(t,new ht);this._applyPointUpdate(e,{endPoint:i})}),h),d((()=>({stagedDimension:this._stagedDimension,selectedComputation:this.analysisViewData.selectedComputation,firstGrabbedManipulator:this.firstGrabbedManipulator})),((t,e)=>{const{stagedDimension:i,selectedComputation:a,firstGrabbedManipulator:n}=t;if(i===e?.stagedDimension&&n===e?.firstGrabbedManipulator){for(const s of[a,e?.selectedComputation])if(null!=s){const e=this._computationManipulators.get(s);null!=e&&this._updateManipulators(s,e,t)}}else for(const[s,o]of this._computationManipulators)this._updateManipulators(s,o,t)}),g),d((()=>this.analysis.style.lineSize),(t=>{this._updateManipulatorStyle(t)}),c),d((()=>this.view.state.camera),(()=>{null!=this._stagedComputation&&this._updateStagedDimensionOffset(this._stagedComputation)})),d((()=>{const t=this._stagedComputation;if(!t)return null;const e=t.elevationAlignedStartPoint,i=y();return null!=e&&this.view.renderCoordsHelper.toRenderCoords(e,i)?i:null}),(t=>{null!=t?(this._stagedStartIndicator.vertices=[t],this._stagedStartIndicator.attached=!0):this._stagedStartIndicator.attached=!1}))]),this.addHandles(this._constraintHandles),this.addHandles(this._snappingIndicatorHandles),mt(this,(()=>{const t=this._activeComputation,e=this._stagedComputation;if(null==t||null!=e){const t=this.view.inputManager.latestPointerType??"mouse",e=this._getSnappingContext(t);this._updatingHandles.addPromise(u(this._snappingOperation.resnap(this._snappingManager,e)))}if(null!=t){const{start:e,end:i}=this._computationManipulators.get(t);if(e.grabbing||i.grabbing){const i=e.grabbing?"start":"end",a=this._computeConstraint(t);S(t,i,{constraint:a,view:this.view})}}}))}destroy(){this._snappingOperation=p(this._snappingOperation),this._computationHandles.destroy(),this._constraintSnappingIndicator.destroy(),this._stagedStartIndicator.destroy(),this._orientationManipulatorTexture?.release()}get updating(){return this._updatingHandles.updating||this._snappingManager.updating}get firstGrabbedManipulator(){return this.parentTool.firstGrabbedManipulator}get hasGrabbedManipulators(){return this.parentTool.hasGrabbedManipulators}get snappingOptions(){return this._snappingManager.options}get _snappingManager(){return this._snappingManagerResult.snappingManager}get _activeComputation(){if(null!=this._stagedComputation)return this._stagedComputation;const{selectedComputation:t}=this.analysisViewData;return this.hasGrabbedManipulators&&null!=t?t:null}get _stagedComputation(){const t=this._stagedDimension,e=this.analysisViewData.computations.at(-1)?.computation;return null==t||null==e||e.dimension!==t?null:e}get _constraintHandles(){return[f((()=>this.analysisViewData.selectedComputation),(t=>{t.previousConstraint=this._computeConstraint(t)}),{...g,equals:r}),d((()=>{const t=this._activeComputation;if(null==t)return null;const{measureType:e,orientation:i}=t.dimension;return{measureType:e,orientation:i,computation:t}}),((t,e)=>{if(null!=t&&null==e){const{measureType:e,orientation:a,computation:n}=t;switch(n.previousConstraint){case w.Horizontal:n.preConstraintProperties={measureType:i.Horizontal,orientation:0};break;case w.Vertical:n.preConstraintProperties={measureType:i.Vertical,orientation:0};break;case w.Direct:n.preConstraintProperties={measureType:i.Direct,orientation:a};break;default:n.preConstraintProperties={measureType:e,orientation:a}}}null==t&&null!=e&&(e.computation.preConstraintProperties=null)}),h)]}get _snappingIndicatorHandles(){const t="snapping-indicator-event-handles";return[d((()=>({stagedComputation:this._stagedComputation,activeComputation:this._activeComputation})),(({stagedComputation:e,activeComputation:i})=>{const a=this._constraintSnappingIndicator;if(this.removeHandles(t),null!=i)if(i===e)a.attached=!0;else{const{start:e,end:n}=this._computationManipulators.get(i),s=()=>{a.attached=e.grabbing||n.grabbing};s(),this.addHandles([e.events.on("grab-changed",s),n.events.on("grab-changed",s)],t)}else a.attached=!1})),d((()=>{const t=this._activeComputation;return null!=t?{geometry:t.geometry,constraint:t.previousConstraint}:{}}),(({geometry:t,constraint:e})=>{const i=this._constraintSnappingIndicator;null!=t&&null!=e&&e!==w.Direct?(i.visible=!0,i.setGeometryFromSegment(t.directSegment)):i.visible=!1}))]}removeStaged(){return null!=this._stagedDimension&&(this.analysis.dimensions.remove(this._stagedDimension),this._stagedDimension=null,!0)}onDeactivate(){this.removeStaged(),this._resetSnappingState()}onClick(t){const{_stagedDimension:e}=this;if(null==e){const e=this._onUnstagedClick(t);return this.analysis.dimensions.add(e),null}return this._onStagedClick(t),e}onPointerMove({mapPoint:t,pointerType:e}){if("touch"===e)return;const i=this._getSnappingContext(e);this._updatingHandles.addPromise(u(this._snappingOperation.snap({point:t},this._snappingManager,i)))}onManipulatorSelectionChanged(){if(null!=this.analysisViewData.selectedComputation){this._computationManipulators.get(this.analysisViewData.selectedComputation).offset.selected||(this.analysisViewData.selectedDimension=null)}}_onUnstagedClick({mapPoint:t,pointerType:e}){let n=t;if("mouse"===e){const i=this._getSnappingContext(e);n=this._snappingManager.update({point:t,context:i})}const s=new a({startPoint:C(n,new ht),endPoint:null,measureType:i.Horizontal});return this._stagedDimension=s,this._resetSnappingState(),s}_onStagedClick({mapPoint:t,pointerType:e}){const i=this._stagedComputation;if(null==i)return;let a=t;if("mouse"===e){const i=this._getSnappingContext(e);a=this._snappingManager.update({point:t,context:i})}const n=C(a,new ht);this._applyPointUpdate(i,{endPoint:n}),this._stagedDimension=null,this._resetSnappingState()}_resetSnappingState(){this._snappingManager.doneSnapping(),this._snappingOperation.abort(),this._snappingOperation.stagedPoint=null}_createManipulators(t){const e=this._setupPointManipulator(t,{isStart:!0}),a=this._setupPointManipulator(t,{isStart:!1}),n=this._setupOffsetManipulator(t),s=this._setupHeadingManipulator(t),o=this._setupRotationManipulator(t),r=this._setupMeasureTypeManipulator(t,i.Direct),p=this._setupMeasureTypeManipulator(t,i.Horizontal),l=this._setupMeasureTypeManipulator(t,i.Vertical),u=new D({start:e,end:a,offset:n,heading:s,rotation:o,direct:r,horizontal:p,vertical:l});return this._setupComputationToManipulatorsSync(t,u),this._computationManipulators.set(t,u),this.manipulators.addMany(u.values()),{manipulators:u,remove:()=>{this._computationHandles.remove(t),this._computationManipulators.delete(t);for(const t of u.values())this.manipulators.remove(t)}}}_setupComputationToManipulatorsSync(t,e){this._computationHandles.add([d((()=>t.geometry),(()=>this._updateManipulators(t,e)),{...g,equals:r})],t)}_setupPointManipulator(t,e){const{view:i}=this,{dimension:a}=t,n=new j(i,{metadata:a}),s=H(n,{isStart:e.isStart,createSnappingPipelineStep:t=>dt({snappingContext:this._getSnappingContext(t),snappingManager:this._snappingManager,updatingHandles:this._updatingHandles}),dimension:a,onUpdate:e=>this._applyPointUpdate(t,e),view:i});return this._computationHandles.add(s,t),n}_setupOffsetManipulator(t){const{view:e}=this,i=T(e,{lineSizePt:this.analysis.style.lineSize,unfocusedMaterial:this._unfocusedOffsetManipulatorMaterial,focusedMaterial:this._focusedOffsetManipulatorMaterial,metadata:t.dimension}),a=G(i,{computation:t,view:e});return this._computationHandles.add(a,t),i}_setupHeadingManipulator(t){const{view:e}=this,i=new z(e,{lineSizePt:this.analysis.style.lineSize,material:this._orientationManipulatorMaterial,metadata:t.dimension}),a=I(i,{computation:t,view:e});return this._computationHandles.add(a,t),i}_setupRotationManipulator(t){const{view:e}=this,i=new z(e,{lineSizePt:this.analysis.style.lineSize,material:this._orientationManipulatorMaterial,metadata:t.dimension}),a=x(i,{computation:t,view:e});return this._computationHandles.add(a,t),i}_setupMeasureTypeManipulator(t,e){const{view:i}=this,a=V(i,{lineSizePt:this.analysis.style.lineSize,unfocusedMaterial:this._unfocusedOffsetManipulatorMaterial,focusedMaterial:this._focusedOffsetManipulatorMaterial,thinOffsetManipulatorMaterial:this._thinOffsetManipulatorMaterial,metadata:t.dimension}),n=U(a,{computation:t,manipulatorMeasureType:e,view:i});return this._computationHandles.add(n,t),a}_updateManipulators(t,e,a={stagedDimension:this._stagedDimension,selectedComputation:this.analysisViewData.selectedComputation,firstGrabbedManipulator:this.firstGrabbedManipulator}){const{stagedDimension:n,selectedComputation:s,firstGrabbedManipulator:o}=a,{start:r,end:p,offset:l,heading:u,rotation:d}=e,c=s===t,m=q(t),{dimension:h}=t;for(const i of e.values()){const t=m&&null==n&&(null==o||i===o);i===l?(i.available=t,i.selected=c):i.available=t&&c}if(!m)return;null!=this._computeConstraint(t)?e.forEachMeasureTypeManipulator((t=>t.available=!1)):e.manipulatorForMeasureType(h.measureType).available=!1;for(const _ of[u,d])h.measureType===i.Direct&&0!==h.offset||(_.available=!1);B(t)?d.available=!1:u.available=!1;const{geometry:g}=t;r.renderLocation=g.directSegment.startRenderSpace,p.renderLocation=g.directSegment.endRenderSpace;const{renderCoordsHelper:f}=this.view;R(l,g,f),u.available&&A(u,t,f),d.available&&k(d,t,f),e.forEachMeasureTypeManipulator(((e,i)=>{e.available&&E(e,t,i,f)}))}_updateManipulatorStyle(t){const e=F(t),i=L(t),a={lineSizePt:t,material:this._orientationManipulatorMaterial};for(const{offset:n,heading:s,rotation:o}of this._computationManipulators.values())n.radius=i/2,s.update(a),o.update(a);this._unfocusedOffsetManipulatorMaterial.setParameters({width:e}),this._focusedOffsetManipulatorMaterial.setParameters({width:i})}_applyPointUpdate(t,e){const{view:i}=this,a=J(t);"startPoint"in e&&(a.elevationAlignedStartPoint=e.startPoint),"endPoint"in e&&(a.elevationAlignedEndPoint=e.endPoint);const n=N(a,i.renderCoordsHelper);if(null==n)return;const s=this._computeConstraint({...a,geometry:n});b(t,e,{...a,constraint:s,unconstrainedGeometry:n,view:i}),t===this._stagedComputation&&this._updateStagedDimensionOffset(t)}_updateStagedDimensionOffset(t){if(null==t.geometry)return;t.geometry.directSegment.eval(.5,ft);const e=this.view.state.camera.computeRenderPixelSizeAt(ft);t.dimension.offset=Y*e}_computeConstraint(t){return O(P(t,this._snappingManager.options),this.view)}_createOffsetManipulatorMaterial(){return new st({width:1,renderOccluded:it.OccludeAndTransparent,writeDepth:!1,hasPolygonOffset:!0,isDecoration:!0})}get testInfo(){const t=t=>this.analysisViewData.computations.find((({computation:e})=>e.dimension===t))?.computation;return{disableManipulatorPartialOcclusion:()=>{this._stagedStartIndicator.renderOccluded=it.Occlude,this.manipulators.forEach((({manipulator:t})=>{for(const{geometry:e}of t.renderObjects)e.material.setParameters({renderOccluded:it.Occlude})}))},getManipulatorsForDimension:e=>this._computationManipulators.get(t(e)),getComputationForDimension:e=>t(e),getConstraintForDimension:e=>{const i=t(e);return null!=i?this._computeConstraint(i):null},stagedDimension:this._stagedDimension,stagedStartIndicator:this._stagedStartIndicator,constraintSnappingIndicator:this._constraintSnappingIndicator,snappingManager:this._snappingManager}}};t([_({constructOnly:!0})],gt.prototype,"analysis",void 0),t([_({constructOnly:!0})],gt.prototype,"analysisViewData",void 0),t([_({constructOnly:!0})],gt.prototype,"manipulators",void 0),t([_({constructOnly:!0})],gt.prototype,"parentTool",void 0),t([_({constructOnly:!0,nonNullable:!0})],gt.prototype,"view",void 0),t([_({readOnly:!0})],gt.prototype,"updating",null),t([_()],gt.prototype,"firstGrabbedManipulator",null),t([_()],gt.prototype,"hasGrabbedManipulators",null),t([_()],gt.prototype,"snappingOptions",null),t([_()],gt.prototype,"_stagedDimension",void 0),t([_()],gt.prototype,"_activeComputation",null),t([_()],gt.prototype,"_stagedComputation",null),gt=t([M("esri.views.3d.analysis.Dimension.LengthDimensionSubTool")],gt);const ft=y();export{gt as LengthDimensionSubTool};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.28/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import e from"../../../../core/Handles.js";import{equals as t}from"../../../../core/lang.js";import{destroyMaybe as s}from"../../../../core/maybe.js";import{formatDecimal as i}from"../../../../core/quantityFormatUtils.js";import{watch as n,initial as l}from"../../../../core/reactiveUtils.js";import{pt2px as a}from"../../../../core/screenUtils.js";import{c as o}from"../../../../chunks/vec3f64.js";import{computeSpanningSegment as m,OffsetSegmentLocation as r,maxScreenLengthSquaredFromGeometry as f,offsetSegment as d}from"./lengthDimensionUtils.js";import{
|
|
5
|
+
import e from"../../../../core/Handles.js";import{equals as t}from"../../../../core/lang.js";import{destroyMaybe as s}from"../../../../core/maybe.js";import{formatDecimal as i}from"../../../../core/quantityFormatUtils.js";import{watch as n,initial as l}from"../../../../core/reactiveUtils.js";import{pt2px as a}from"../../../../core/screenUtils.js";import{c as o}from"../../../../chunks/vec3f64.js";import{computeSpanningSegment as m,OffsetSegmentLocation as r,maxScreenLengthSquaredFromGeometry as f,offsetSegment as d}from"./lengthDimensionUtils.js";import{smallScreenLengthLineSizeFactor as h,minScreenLengthFontSizeFactor as c,labelMarginPx as u}from"./settings.js";import{LabelVisualElement as S}from"../../interactive/visualElements/LabelVisualElement.js";import{LineVisualElement as g}from"../../interactive/visualElements/LineVisualElement.js";import{MarkerVisualElement as v}from"../../interactive/visualElements/MarkerVisualElement.js";import{EuclideanSegment as p}from"../../interactive/visualElements/support/Segment.js";class b{set visible(e){for(const t of this._visualElements.values())t.attached=e}constructor(s){this.destroyed=!1,this._handles=new e,this._messages=null,this._labelSegment=new p;const{analysis:i,computation:o,view:m,messages:r,isDecoration:f}=s;this.analysis=i,this.computation=o,this.view=m,this._messages=r;const d=s.visible,h={view:m,attached:d,isDecoration:f},{fontSize:c,textColor:u,textBackgroundColor:b}=i.style;this._visualElements=new E({marker:new v(h,s.markerMaterial),dimension:new g(h,s.dimensionLineMaterial),startOffset:new g(h,s.offsetLineMaterial),endOffset:new g(h,s.offsetLineMaterial),dimensionSmall:new g(h,s.smallDimensionLineMaterial),startOffsetSmall:new g(h,s.smallOffsetLineMaterial),endOffsetSmall:new g(h,s.smallOffsetLineMaterial),label:new S({view:m,attached:d,distance:0,geometry:{type:"segment",sampleLocation:"center",segment:this._labelSegment,callout:!1},fontSize:a(c),textColor:u.clone(),backgroundColor:b.clone(),isDecoration:f})}),this._handles.add([n((()=>o.geometry),(e=>{this.updateCameraDependentElements(m.state.camera,e,i.style),null!=o.geometry&&this._updateLines(o.geometry)}),{...l,equals:t}),n((()=>o.length),(e=>this._updateLabelContent(e)),l)])}destroy(){this.destroyed=!0,this._handles=s(this._handles);for(const e of this._visualElements.values())e.destroy()}get testInfo(){return{dimensionVisualElement:this._visualElements.dimension,label:this._visualElements.label}}_updateLines(e){const t=m(O,r.Start,e.directSegment,e.dimensionSegment),s=m(_,r.End,e.directSegment,e.dimensionSegment),i=this._visualElements;i.marker.setGeometryFromSegment(e.dimensionSegment,e.primaryOffsetAxis),i.dimension.setGeometryFromSegment(e.dimensionSegment),i.startOffset.setGeometryFromSegment(t),i.endOffset.setGeometryFromSegment(s),i.dimensionSmall.setGeometryFromSegment(e.dimensionSegment),i.startOffsetSmall.setGeometryFromSegment(t),i.endOffsetSmall.setGeometryFromSegment(s)}updateCameraDependentElements(e,t,s){const i=this._visualElements;if(null==t){for(const e of i.values())e.visible=!1;return}const n=e.computeScreenPixelSizeAt(t.dimensionSegment.eval(.5,y)),l=f(t,n),o=l<(a(s.lineSize)*h)**2,m=!o;i.marker.visible=m,i.dimension.visible=m,i.startOffset.visible=m,i.endOffset.visible=m,i.dimensionSmall.visible=o,i.startOffsetSmall.visible=o,i.endOffsetSmall.visible=o;const r=a(s.fontSize)*c,{label:u}=i;if(u.visible=l>=r**2,!u.visible)return;const{dimensionSegment:S,primaryOffsetAxis:g}=t,{offset:v}=this.computation.dimension,p=(Math.sign(v)>=0?1:-1)*this._labelOffsetPx(s)*n;d(this._labelSegment,S,g,p),u.updateLabelPosition()}updateLabelStyle(e){const{label:t}=this._visualElements;t.fontSize=a(e.fontSize),t.textColor=e.textColor,t.backgroundColor=e.textBackgroundColor}updateUnitsMessages(e){this._messages=e;const{length:t}=this.computation;this._updateLabelContent(t)}_updateLabelContent(e){const{label:t}=this._visualElements;null!=e&&null!=this._messages?t.text=i(this._messages,e,e.unit):t.text=""}_labelOffsetPx(e){return 1.5*a(e.fontSize)+u+a(e.lineSize/2)}}const O=new p,_=new p,y=o();class E{constructor(e){this.marker=e.marker,this.dimension=e.dimension,this.startOffset=e.startOffset,this.endOffset=e.endOffset,this.dimensionSmall=e.dimensionSmall,this.startOffsetSmall=e.startOffsetSmall,this.endOffsetSmall=e.endOffsetSmall,this.label=e.label}values(){return[this.marker,this.dimension,this.startOffset,this.endOffset,this.dimensionSmall,this.startOffsetSmall,this.endOffsetSmall,this.label]}}export{E as LengthDimensionVisualElements,b as LengthDimensionVisualization};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.28/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import e from"../../../../Color.js";import"../../../../geometry.js";import{lengthDimensionMeasureType as t,LengthDimensionMeasureType as n}from"../../../../analysis/dimensionUtils.js";import{cyclicalDegrees as r}from"../../../../core/Cyclical.js";import{rad2deg as o}from"../../../../core/mathUtils.js";import{pt2px as i}from"../../../../core/screenUtils.js";import{g as a,b as s}from"../../../../chunks/mat4.js";import{a as c}from"../../../../chunks/mat4f64.js";import{i as m,c as d,f as u,b as l,j as f,h as p,l as g,s as h,r as v}from"../../../../chunks/vec3.js";import{c as y,Z as S,f as j}from"../../../../chunks/vec3f64.js";import{fromPositionAndNormal as w,create as x,signedDistance as H,normal as M}from"../../../../geometry/support/plane.js";import{sv3d as C}from"../../../../geometry/support/vectorStacks.js";import{clonePoint as P}from"../../../../layers/graphics/hydratedFeatures.js";import{isValidComputation as T,computeGeometryFromDimension as b,computationToGeometryDependencies as R,headingFromGeometry as U,computeOffsetForPoint as z,computeSegmentForMeasureType as O,computeOffsetAxis as k,directUp as D,directStartToEnd as E,dimensionStartToEnd as F}from"./lengthDimensionUtils.js";import{PointStyle as A,lengthFraction as L,orientationSnapThresholdDegrees as G,minLengthMeters as B,linePaddingPx as I,focusedLinePaddingPx as W,OrientationManipulatorStyle as N,MarkerStyle as V}from"./settings.js";import{Manipulator3D as Z}from"../../interactive/Manipulator3D.js";import{createSphereManipulator as q,worldScaledManipulatorSettings as J,createRotateManipulator as K,updateRotateManipulator as Q,calculateInputRotationTransform as X,calculateTranslateRotateFromBases as Y}from"../../interactive/manipulatorUtils.js";import{RenderObject as $}from"../../interactive/RenderObject.js";import{screenToMap3D as _,screenToRenderPlane as ee,hideManipulatorWhileDragging as te}from"../../interactive/editingTools/dragEventPipeline3D.js";import{EuclideanSegment as ne}from"../../interactive/visualElements/support/Segment.js";import{markerSizePerLineWidth as re}from"../../support/engineContent/marker.js";import{createPolylineGeometry as oe}from"../../webgl-engine/lib/GeometryUtil.js";import{createManipulatorDragEventPipeline as ie,resetProperties as ae,EventPipeline as se}from"../../../interactive/dragEventPipeline.js";import{ManipulatorStateCustomFlags as ce,ManipulatorStateFlags as me}from"../../../interactive/interfaces.js";import de from"../../../../geometry/Point.js";class ue{constructor(e){this.start=e.start,this.end=e.end,this.offset=e.offset,this.heading=e.heading,this.rotation=e.rotation,this.direct=e.direct,this.horizontal=e.horizontal,this.vertical=e.vertical}manipulatorName(e){return Object.keys(this).find((t=>this.hasOwnProperty(t)&&e===this[t]))}values(){return[this.start,this.end,this.offset,this.heading,this.rotation,this.direct,this.horizontal,this.vertical]}forEachMeasureTypeManipulator(e){for(const n of t)e(this.manipulatorForMeasureType(n),n)}manipulatorForMeasureType(e){switch(e){case n.Direct:return this.direct;case n.Horizontal:return this.horizontal;case n.Vertical:return this.vertical}}}function le(t,n){const r=new A(t.effectiveTheme),o=q(t,e.toUnitRGBA(r.color),We);return o.available=!1,o.grabCursor="crosshair",o.radius=r.radius,o.metadata=n.metadata,o.collisionPriority=1,o}function fe(e,t){const n=[j(-.5,0,0),j(.5,0,0)],r=oe(t.unfocusedMaterial,n.map((e=>m(y(),e,L)))),o=r.instantiate({material:t.focusedMaterial});return new Z({view:e,renderObjects:[new $(r,me.Unfocused|me.Selected|We),new $(o,me.Focused|We)],collisionType:{type:"line",paths:[n]},radius:Ie(t.lineSizePt)/2,metadata:t.metadata,available:!1,...J})}function pe(t,n,{lineSizePt:r,material:o}){const a=new N(t.effectiveTheme),{calloutOffsetPx:s,calloutWidth:c,discScale:m,focusMultiplier:d,color:u}=a,l=new V;return{calloutLength:.25*re*l.lineSizeFraction*i(r)+s,calloutColor:e.toUnitRGBA(u),calloutWidth:c,customStateMask:We,discScale:m,focusMultiplier:d,material:o,metadata:n}}function ge(e,t){return K(e,pe(e,t.metadata,t))}function he(e,t,n){Q(t,pe(e,t.metadata,n))}function ve(e,t){const n=[j(-.5,0,0),j(.5,0,0)],r=oe(t.thinOffsetManipulatorMaterial,n),o=oe(t.unfocusedMaterial,n.map((e=>m(y(),e,L)))),i=o.instantiate({material:t.focusedMaterial});return new Z({view:e,renderObjects:[new $(o,me.Unfocused|We),new $(i,me.Focused|We),new $(r,We)],collisionType:{type:"line",paths:[n]},radius:Ie(t.lineSizePt)/2,available:!1,metadata:t.metadata,...J})}function ye(e,{isStart:t,createSnappingPipelineStep:n,dimension:r,onUpdate:o,view:i}){const a=t?"startPoint":"endPoint",s=ie(e,((e,t,s,c)=>{const m=te(e),{snappingStep:d,cancelSnapping:u}=n(c);s=s.next(m).next(ae(r,[a,"measureType","orientation"])).next(u),t.next(m).next(_(i)).next(...d).next((e=>{const t=P(e.mapEnd,new de);o("startPoint"===a?{startPoint:t}:{endPoint:t})}))}));return[s]}function Se(e,{computation:t,view:n}){return[ie(e,((e,r,o)=>{if(!T(t)||!e.selected)return;const{geometry:i,dimension:a}=t,s=te(e);r.next(s).next(Pe(n,a,i.dimensionSegment,i.primaryOffsetAxis)),o.next(s).next(ae(a,["offset"]))}))]}function je(e,{computation:t,view:n}){return[ie(e,((e,r,o)=>{He({cancel:o,computation:t,settingHeading:!0,steps:r,view:n})}))]}function we(e,{computation:t,view:n}){return[ie(e,((e,r,o)=>{He({cancel:o,computation:t,settingHeading:!1,steps:r,view:n})})),e.events.on("immediate-click",(e=>{xe(e,t,n)}))]}function xe(e,t,n){const{dimension:o,geometry:i}=t;if(90===o.orientation||270===o.orientation)return o.orientation=0,void e.stopPropagation();if(null==i)return;const{renderCoordsHelper:a}=n,s=b({...R(t),orientation:90},a),c=b({...R(t),orientation:270},a);if(null==s||null==c)return;const m=U(s,a),d=U(c,a),u=Te(i,n),l=r.shortestSignedDiff(u,m),f=r.shortestSignedDiff(u,d);o.orientation=Math.abs(l)<Math.abs(f)?90:270,e.stopPropagation()}function He(e){const{cancel:t,computation:n,settingHeading:r,steps:i,view:a}=e;if(!T(n))return;const{renderCoordsHelper:s}=a,{dimension:c,geometry:m}=n,u=y(),l=Ee(y(),m,m.directSegment,s),f=Fe(C.get(),{forHeading:r,geometry:m,renderCoordsHelper:s}),p=w(l,f,x()),g=r?c.orientation??U(m,a.renderCoordsHelper):c.orientation??0;i.next(ee(a,p)).next((e=>{"start"===e.action&&d(u,e.renderStart);const t=M(p),n=X(u,e.renderEnd,l,t);let i=g-o(n);r||(i=Me(i)),c.orientation=i})),t.next(ae(c,["orientation"]))}function Me(e){const t=r.normalize(e)%90;return t<G?e-t:90-t<G?e+(90-t):e}function Ce(e,{computation:t,manipulatorMeasureType:r,view:o}){let i=n.Direct,a=0,s=0;return[e.events.on("grab-changed",(n=>{if("start"!==n.action||!T(t))return;const{dimension:c,geometry:m}=t;i=c.measureType,a=c.offset,s=c.orientation;const u=d(C.get(),e.renderLocation);c.measureType=r,c.offset=z(u,r,m,o.renderCoordsHelper),c.orientation=0})),ie(e,((e,n,c)=>{if(!T(t))return;const{geometry:m,dimension:d}=t,{renderCoordsHelper:u}=o,l=O(qe,r,t,u),f=k(C.get(),{measureType:r,directSegment:m.directSegment,renderCoordsHelper:u}),p=te(e);n.next(p).next(Pe(o,d,l,f)),c.next(p).next((e=>(d.measureType=i,d.offset=a,d.orientation=s,e)))}))]}function Pe(e,t,n,r){const o=u(C.get(),n.endRenderSpace,n.startRenderSpace);l(o,o,r);const i=w(n.startRenderSpace,o,x()),a=w(n.startRenderSpace,r,x()),s=t.offset;let c,m=0;const d=new se;return d.next(ee(e,i)).next((n=>{"start"===n.action&&(m=H(a,n.renderStart));const r=(H(a,n.renderEnd)-m)*e.renderCoordsHelper.unitInMeters;t.offset=s+r,c=n})),e=>(d.execute(e),c)}function Te(e,t){const{directSegment:n}=e,{renderCoordsHelper:r}=t,o=D(C.get(),e,r),i=E(C.get(),e),a=l(C.get(),i,o),{viewForward:s}=t.state.camera;f(a,s)>0&&m(a,a,-1);const c=n.eval(.5,C.get());return r.headingAtPosition(c,a)}function be(e,t,n){const{dimensionSegment:r,primaryOffsetAxis:o}=t,i=F(Ne,t),c=p(i,S)?a(Ze):Y(i,o,S,Ze),m=Math.max(g(i),B/n.unitInMeters);s(c,c,h(Ne,m,m,m)),e.modelTransform=c,e.renderLocation=r.eval(.5,Ne)}function Re(e,t,n){ze(e,t,n,{forHeading:!0})}function Ue(e,t,n){ze(e,t,n,{forHeading:!1})}function ze(e,t,n,{forHeading:r}){const{dimension:o,geometry:i}=t,{primaryOffsetAxis:a}=i,s=m(Oe,a,o.offset>=0?1:-1),c=Fe(ke,{forHeading:r,geometry:i,renderCoordsHelper:n});l(c,c,s);const d=Y(s,c,S,Ze);e.modelTransform=d,e.renderLocation=Ee(Ne,i,i.dimensionSegment,n)}const Oe=y(),ke=y();function De(e,t,n,r){const{geometry:o}=t,i=O(qe,n,t,r),a=k(Ne,{measureType:n,directSegment:o.directSegment,renderCoordsHelper:r}),c=v(Ve,i.endRenderSpace,i.startRenderSpace),m=Y(c,a,S,Ze),d=g(c);s(m,m,h(Ve,d,d,d)),e.modelTransform=m,e.renderLocation=i.eval(.5,Ve)}function Ee(e,t,n,r){const{startRenderSpace:o,endRenderSpace:i}=n,a=Ae(t,r)?o:i;return d(e,a)}function Fe(e,{forHeading:t,geometry:n,renderCoordsHelper:r}){return t?D(e,n,r):F(e,n,{invert:!0})}function Ae(e,t){const n=E(Le,e),r=D(Ge,e,t);return f(n,r)>0}const Le=y(),Ge=y();function Be(e){return i(e)+I}function Ie(e){return i(e)+W}const We=ce.Custom1,Ne=y(),Ve=y(),Ze=c(),qe=new ne;export{We as DidPointerMoveRecentlyFlag,ue as LengthDimensionManipulators,Te as automaticHeadingFromCamera,ve as createMeasureTypeManipulator,fe as createOffsetManipulator,ge as createOrientationManipulator,le as createPointManipulator,Ie as focusedOffsetWidth,je as headingManipulatorHandles,Ce as measureTypeManipulatorHandles,Se as offsetManipulatorHandles,ye as pointManipulatorHandles,we as rotationManipulatorHandles,Me as snapOrientationToNearestRightAngle,Be as unfocusedOffsetWidth,Re as updateHeadingManipulatorTransform,De as updateMeasureTypeManipulatorTransform,be as updateOffsetManipulatorTransform,he as updateOrientationManipulator,Ue as updateRotationManipulatorTransform};
|
|
5
|
+
import e from"../../../../Color.js";import"../../../../geometry.js";import{lengthDimensionMeasureType as t,LengthDimensionMeasureType as n}from"../../../../analysis/dimensionUtils.js";import{cyclicalDegrees as r}from"../../../../core/Cyclical.js";import{rad2deg as o}from"../../../../core/mathUtils.js";import{watch as i,initial as a}from"../../../../core/reactiveUtils.js";import{pt2px as s}from"../../../../core/screenUtils.js";import{g as c,b as m}from"../../../../chunks/mat4.js";import{a as d}from"../../../../chunks/mat4f64.js";import{i as l,c as p,f as u,b as f,j as h,h as g,l as v,s as y,r as S}from"../../../../chunks/vec3.js";import{c as j,Z as w,f as x}from"../../../../chunks/vec3f64.js";import{c as H}from"../../../../chunks/vec4f64.js";import{fromPositionAndNormal as P,create as C,signedDistance as M,normal as T}from"../../../../geometry/support/plane.js";import{sv3d as b}from"../../../../geometry/support/vectorStacks.js";import{clonePoint as z}from"../../../../layers/graphics/hydratedFeatures.js";import{isValidComputation as R,computeGeometryFromDimension as U,computationToGeometryDependencies as O,headingFromGeometry as k,computeOffsetForPoint as _,computeSegmentForMeasureType as A,computeOffsetAxis as D,directUp as E,directStartToEnd as F,dimensionStartToEnd as L}from"./lengthDimensionUtils.js";import{getTransparentAccentColor as G,pointRadius as B,lengthFraction as I,markerLineSizeFraction as N,orientationCalloutOffsetPx as V,orientationCalloutWidth as W,orientationDiscScale as Z,orientationFocusMultiplier as q,orientationSnapThresholdDegrees as J,minLengthMeters as K,linePaddingPx as Q,focusedLinePaddingPx as X}from"./settings.js";import{Manipulator3D as Y}from"../../interactive/Manipulator3D.js";import{createManipulatorMaterial as $,worldScaledManipulatorSettings as ee,updateRotateManipulator as te,calculateInputRotationTransform as ne,calculateTranslateRotateFromBases as re}from"../../interactive/manipulatorUtils.js";import{RenderObject as oe}from"../../interactive/RenderObject.js";import{screenToMap3D as ie,screenToRenderPlane as ae,hideManipulatorWhileDragging as se}from"../../interactive/editingTools/dragEventPipeline3D.js";import{EuclideanSegment as ce}from"../../interactive/visualElements/support/Segment.js";import{markerSizePerLineWidth as me}from"../../support/engineContent/marker.js";import{createSphereGeometry as de,createPolylineGeometry as le}from"../../webgl-engine/lib/GeometryUtil.js";import{createManipulatorDragEventPipeline as pe,resetProperties as ue,EventPipeline as fe}from"../../../interactive/dragEventPipeline.js";import{ManipulatorStateCustomFlags as he,ManipulatorStateFlags as ge}from"../../../interactive/interfaces.js";import ve from"../../../../geometry/Point.js";class ye{constructor(e){this.start=e.start,this.end=e.end,this.offset=e.offset,this.heading=e.heading,this.rotation=e.rotation,this.direct=e.direct,this.horizontal=e.horizontal,this.vertical=e.vertical}manipulatorName(e){return Object.keys(this).find((t=>this.hasOwnProperty(t)&&e===this[t]))}values(){return[this.start,this.end,this.offset,this.heading,this.rotation,this.direct,this.horizontal,this.vertical]}forEachMeasureTypeManipulator(e){for(const n of t)e(this.manipulatorForMeasureType(n),n)}manipulatorForMeasureType(e){switch(e){case n.Direct:return this.direct;case n.Horizontal:return this.horizontal;case n.Vertical:return this.vertical}}}class Se extends Y{constructor(t,n){const r=$(e.toUnitRGBA(G(t.effectiveTheme))),o=[new oe(de(r,1,32,32),Je)];super({view:t,renderObjects:o,metadata:n.metadata,available:!1,grabCursor:"crosshair",radius:B,collisionPriority:1}),this._themeHandle=i((()=>({color:e.toUnitRGBA(G(t.effectiveTheme))})),(e=>{r.setParameters(e)}))}destroy(){this._themeHandle.remove(),super.destroy()}}function je(e,t){const n=[x(-.5,0,0),x(.5,0,0)],r=le(t.unfocusedMaterial,n.map((e=>l(j(),e,I)))),o=r.instantiate({material:t.focusedMaterial});return new Y({view:e,renderObjects:[new oe(r,ge.Unfocused|ge.Selected|Je),new oe(o,ge.Focused|Je)],collisionType:{type:"line",paths:[n]},radius:qe(t.lineSizePt)/2,metadata:t.metadata,available:!1,...ee})}class we extends Y{constructor(t,{lineSizePt:n,material:r,metadata:o}){super({view:t,autoScaleRenderObjects:!1,collisionPriority:1,metadata:o}),this._options={calloutColor:H(),lineSizePt:n,material:r},this._themeHandle=i((()=>e.toUnitRGBA(G(t.effectiveTheme))),(e=>{this._options.calloutColor=e,te(this,xe({...this._options,metadata:this.metadata}))}),a)}update({lineSizePt:e,material:t}){this._options.lineSizePt=e,this._options.material=t,te(this,xe({...this._options,metadata:this.metadata}))}destroy(){this._themeHandle.remove(),super.destroy()}}function xe({calloutColor:e,lineSizePt:t,material:n,metadata:r}){return{calloutLength:.25*me*N*s(t)+V,calloutColor:e,calloutWidth:W,customStateMask:Je,discScale:Z,focusMultiplier:q,material:n,metadata:r}}function He(e,t){const n=[x(-.5,0,0),x(.5,0,0)],r=le(t.thinOffsetManipulatorMaterial,n),o=le(t.unfocusedMaterial,n.map((e=>l(j(),e,I)))),i=o.instantiate({material:t.focusedMaterial});return new Y({view:e,renderObjects:[new oe(o,ge.Unfocused|Je),new oe(i,ge.Focused|Je),new oe(r,Je)],collisionType:{type:"line",paths:[n]},radius:qe(t.lineSizePt)/2,available:!1,metadata:t.metadata,...ee})}function Pe(e,{isStart:t,createSnappingPipelineStep:n,dimension:r,onUpdate:o,view:i}){const a=t?"startPoint":"endPoint",s=pe(e,((e,t,s,c)=>{const m=se(e),{snappingStep:d,cancelSnapping:l}=n(c);s=s.next(m).next(ue(r,[a,"measureType","orientation"])).next(l),t.next(m).next(ie(i)).next(...d).next((e=>{const t=z(e.mapEnd,new ve);o("startPoint"===a?{startPoint:t}:{endPoint:t})}))}));return[s]}function Ce(e,{computation:t,view:n}){return[pe(e,((e,r,o)=>{if(!R(t)||!e.selected)return;const{geometry:i,dimension:a}=t,s=se(e);r.next(s).next(Oe(n,a,i.dimensionSegment,i.primaryOffsetAxis)),o.next(s).next(ue(a,["offset"]))}))]}function Me(e,{computation:t,view:n}){return[pe(e,((e,r,o)=>{ze({cancel:o,computation:t,settingHeading:!0,steps:r,view:n})}))]}function Te(e,{computation:t,view:n}){return[pe(e,((e,r,o)=>{ze({cancel:o,computation:t,settingHeading:!1,steps:r,view:n})})),e.events.on("immediate-click",(e=>{be(e,t,n)}))]}function be(e,t,n){const{dimension:o,geometry:i}=t;if(90===o.orientation||270===o.orientation)return o.orientation=0,void e.stopPropagation();if(null==i)return;const{renderCoordsHelper:a}=n,s=U({...O(t),orientation:90},a),c=U({...O(t),orientation:270},a);if(null==s||null==c)return;const m=k(s,a),d=k(c,a),l=ke(i,n),p=r.shortestSignedDiff(l,m),u=r.shortestSignedDiff(l,d);o.orientation=Math.abs(p)<Math.abs(u)?90:270,e.stopPropagation()}function ze(e){const{cancel:t,computation:n,settingHeading:r,steps:i,view:a}=e;if(!R(n))return;const{renderCoordsHelper:s}=a,{dimension:c,geometry:m}=n,d=j(),l=Be(j(),m,m.directSegment,s),u=Ie(b.get(),{forHeading:r,geometry:m,renderCoordsHelper:s}),f=P(l,u,C()),h=r?c.orientation??k(m,a.renderCoordsHelper):c.orientation??0;i.next(ae(a,f)).next((e=>{"start"===e.action&&p(d,e.renderStart);const t=T(f),n=ne(d,e.renderEnd,l,t);let i=h-o(n);r||(i=Re(i)),c.orientation=i})),t.next(ue(c,["orientation"]))}function Re(e){const t=r.normalize(e)%90;return t<J?e-t:90-t<J?e+(90-t):e}function Ue(e,{computation:t,manipulatorMeasureType:r,view:o}){let i=n.Direct,a=0,s=0;return[e.events.on("grab-changed",(n=>{if("start"!==n.action||!R(t))return;const{dimension:c,geometry:m}=t;i=c.measureType,a=c.offset,s=c.orientation;const d=p(b.get(),e.renderLocation);c.measureType=r,c.offset=_(d,r,m,o.renderCoordsHelper),c.orientation=0})),pe(e,((e,n,c)=>{if(!R(t))return;const{geometry:m,dimension:d}=t,{renderCoordsHelper:l}=o,p=A(Ye,r,t,l),u=D(b.get(),{measureType:r,directSegment:m.directSegment,renderCoordsHelper:l}),f=se(e);n.next(f).next(Oe(o,d,p,u)),c.next(f).next((e=>(d.measureType=i,d.offset=a,d.orientation=s,e)))}))]}function Oe(e,t,n,r){const o=u(b.get(),n.endRenderSpace,n.startRenderSpace);f(o,o,r);const i=P(n.startRenderSpace,o,C()),a=P(n.startRenderSpace,r,C()),s=t.offset;let c,m=0;const d=new fe;return d.next(ae(e,i)).next((n=>{"start"===n.action&&(m=M(a,n.renderStart));const r=(M(a,n.renderEnd)-m)*e.renderCoordsHelper.unitInMeters;t.offset=s+r,c=n})),e=>(d.execute(e),c)}function ke(e,t){const{directSegment:n}=e,{renderCoordsHelper:r}=t,o=E(b.get(),e,r),i=F(b.get(),e),a=f(b.get(),i,o),{viewForward:s}=t.state.camera;h(a,s)>0&&l(a,a,-1);const c=n.eval(.5,b.get());return r.headingAtPosition(c,a)}function _e(e,t,n){const{dimensionSegment:r,primaryOffsetAxis:o}=t,i=L(Ke,t),a=g(i,w)?c(Xe):re(i,o,w,Xe),s=Math.max(v(i),K/n.unitInMeters);m(a,a,y(Ke,s,s,s)),e.modelTransform=a,e.renderLocation=r.eval(.5,Ke)}function Ae(e,t,n){Ee(e,t,n,{forHeading:!0})}function De(e,t,n){Ee(e,t,n,{forHeading:!1})}function Ee(e,t,n,{forHeading:r}){const{dimension:o,geometry:i}=t,{primaryOffsetAxis:a}=i,s=l(Fe,a,o.offset>=0?1:-1),c=Ie(Le,{forHeading:r,geometry:i,renderCoordsHelper:n});f(c,c,s);const m=re(s,c,w,Xe);e.modelTransform=m,e.renderLocation=Be(Ke,i,i.dimensionSegment,n)}const Fe=j(),Le=j();function Ge(e,t,n,r){const{geometry:o}=t,i=A(Ye,n,t,r),a=D(Ke,{measureType:n,directSegment:o.directSegment,renderCoordsHelper:r}),s=S(Qe,i.endRenderSpace,i.startRenderSpace),c=re(s,a,w,Xe),d=v(s);m(c,c,y(Qe,d,d,d)),e.modelTransform=c,e.renderLocation=i.eval(.5,Qe)}function Be(e,t,n,r){const{startRenderSpace:o,endRenderSpace:i}=n,a=Ne(t,r)?o:i;return p(e,a)}function Ie(e,{forHeading:t,geometry:n,renderCoordsHelper:r}){return t?E(e,n,r):L(e,n,{invert:!0})}function Ne(e,t){const n=F(Ve,e),r=E(We,e,t);return h(n,r)>0}const Ve=j(),We=j();function Ze(e){return s(e)+Q}function qe(e){return s(e)+X}const Je=he.Custom1,Ke=j(),Qe=j(),Xe=d(),Ye=new ce;export{Je as DidPointerMoveRecentlyFlag,ye as LengthDimensionManipulators,Se as LengthDimensionPointManipulator,we as LineOfSightOrientationManipulator,ke as automaticHeadingFromCamera,He as createMeasureTypeManipulator,je as createOffsetManipulator,qe as focusedOffsetWidth,Me as headingManipulatorHandles,Ue as measureTypeManipulatorHandles,Ce as offsetManipulatorHandles,Pe as pointManipulatorHandles,Te as rotationManipulatorHandles,Re as snapOrientationToNearestRightAngle,Ze as unfocusedOffsetWidth,Ae as updateHeadingManipulatorTransform,Ge as updateMeasureTypeManipulatorTransform,_e as updateOffsetManipulatorTransform,De as updateRotationManipulatorTransform};
|