@arcgis/core 5.2.0-next.48 → 5.2.0-next.49
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/applications/Components/OrientedImageryViewer/PanoramicViewer/utils.d.ts +33 -0
- package/applications/Components/OrientedImageryViewer/PanoramicViewer/utils.js +2 -0
- package/arcgisGlobal.d.ts +2 -0
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/031ccf2e1583beebdf24.js +1 -0
- package/assets/esri/core/workers/chunks/0474af7687466d8befd2.js +1 -0
- package/assets/esri/core/workers/chunks/{f9b2727b41943d83d4ca.js → 0a413d917f3d19440fc1.js} +1 -1
- package/assets/esri/core/workers/chunks/0b2ca406761c63529a6a.js +1 -0
- package/assets/esri/core/workers/chunks/{c369d4266f38e9ea6592.js → 1119a33245138e7b3914.js} +1 -1
- package/assets/esri/core/workers/chunks/{6fbcf1b85461c6c6c127.js → 172571397c66f992d08c.js} +1 -1
- package/assets/esri/core/workers/chunks/18edf2846d7546285e5e.js +1 -0
- package/assets/esri/core/workers/chunks/{7759a489205a874e13bb.js → 1b0557fcb058fc450230.js} +1 -1
- package/assets/esri/core/workers/chunks/{7d0ff52748fd4eb0334d.js → 1bc45872d22d61dbd7d1.js} +1 -1
- package/assets/esri/core/workers/chunks/{835643f716f7058a2722.js → 1cf8fb704c48ac3d3b15.js} +1 -1
- package/assets/esri/core/workers/chunks/25cb56c3b538d00e7693.js +1 -0
- package/assets/esri/core/workers/chunks/{2c0d92c0e3511775401a.js → 35cbf00f0c37a86517af.js} +1 -1
- package/assets/esri/core/workers/chunks/382d9491c2a56c1925fe.js +1 -0
- package/assets/esri/core/workers/chunks/3af2b9d6d5466cb2b957.js +256 -0
- package/assets/esri/core/workers/chunks/{c3766d98f0a70897647f.js → 3bc2943035391b44d4cf.js} +1 -1
- package/assets/esri/core/workers/chunks/{bd8b180c61a80e60568c.js → 40f7bb0ebd918d76f078.js} +1 -1
- package/assets/esri/core/workers/chunks/43b39abd49c4a8ce891f.js +1 -0
- package/assets/esri/core/workers/chunks/{821176ee3be724621bb0.js → 461c2de938bf4c9b1442.js} +1 -1
- package/assets/esri/core/workers/chunks/4ee7232ea41fa41c5ed4.js +29 -0
- package/assets/esri/core/workers/chunks/50674ba5f24129d61d89.js +1 -0
- package/assets/esri/core/workers/chunks/547a2fe53139f705f95e.js +1 -0
- package/assets/esri/core/workers/chunks/5ce09c4d06e98b1e9251.js +1 -0
- package/assets/esri/core/workers/chunks/{4d9433f127aef76f3449.js → 5dbd28fce73751d2d1aa.js} +1 -1
- package/assets/esri/core/workers/chunks/5ec8b02e097cf6718462.js +1 -0
- package/assets/esri/core/workers/chunks/5f54d927dc77e92cf145.js +1 -0
- package/assets/esri/core/workers/chunks/63e3d338751240479335.js +1 -0
- package/assets/esri/core/workers/chunks/6ccd5fa5e35dc70fcd5d.js +1 -0
- package/assets/esri/core/workers/chunks/6e520ef645c5edcd499a.js +1 -0
- package/assets/esri/core/workers/chunks/{68d898037feb0aee3138.js → 78add8e6b54b51eaa299.js} +1 -1
- package/assets/esri/core/workers/chunks/7b61f56d0f766421eaef.js +1 -0
- package/assets/esri/core/workers/chunks/7f2f2a92dce3f68e579b.js +1 -0
- package/assets/esri/core/workers/chunks/{e7e3ea7af928b49b226c.js → 801a664f21e0218bc705.js} +1 -1
- package/assets/esri/core/workers/chunks/8d21e2dabc5165f1c8ca.js +1 -0
- package/assets/esri/core/workers/chunks/9008090a5d8431ddfa22.js +1 -0
- package/assets/esri/core/workers/chunks/{71ce1009dadcae8f8094.js → 95b3b8fe45ef4ac6b277.js} +1 -1
- package/assets/esri/core/workers/chunks/{78918035144c3c76df71.js → 96cec8a02ca96175d602.js} +1 -1
- package/assets/esri/core/workers/chunks/{bab71e1b8b93d09d4809.js → 99eccf9ce53582cfa5b5.js} +1 -1
- package/assets/esri/core/workers/chunks/9b7cb96acea388d86fa4.js +1 -0
- package/assets/esri/core/workers/chunks/{ff2c4f648f77850922d5.js → 9e474465d069cb9e94f5.js} +1 -1
- package/assets/esri/core/workers/chunks/{ae9f9e975d7a9d442fa5.js → ab5aa4280ed0cb7fcbe9.js} +1 -1
- package/assets/esri/core/workers/chunks/b49952541d189b4b9f7e.js +1 -0
- package/assets/esri/core/workers/chunks/{fed6c75485601cd3afa1.js → baac90da0703891d59c4.js} +1 -1
- package/assets/esri/core/workers/chunks/bb552089b34d6811fb03.js +1 -0
- package/assets/esri/core/workers/chunks/{b30237361d87cf982e41.js → d1af0bd611a3dc549858.js} +64 -59
- package/assets/esri/core/workers/chunks/d2cb3d5ef0a9285afb78.js +1 -0
- package/assets/esri/core/workers/chunks/d560ed96dde5ca3a5583.js +1 -0
- package/assets/esri/core/workers/chunks/dc1787d88b11ed985159.js +1 -0
- package/assets/esri/core/workers/chunks/{399e23d777a043efa9f1.js → dd95f50dac3f33cdb6d2.js} +1 -1
- package/assets/esri/core/workers/chunks/ddb92c815d17c67a45e6.js +1 -0
- package/assets/esri/core/workers/chunks/{52efa4ded11c1e71f04f.js → e2e2162adbfb9b46bede.js} +1 -1
- package/assets/esri/core/workers/chunks/e4353f0792f45aa6a62f.js +1 -0
- package/assets/esri/core/workers/chunks/eac8cae89da9ce2f4946.js +1 -0
- package/assets/esri/core/workers/chunks/edf87407dd20685c82ab.js +1 -0
- package/assets/esri/core/workers/chunks/{be6caade351e89f84251.js → ee7c8a7f384ea6393487.js} +107 -82
- package/assets/esri/core/workers/chunks/f1299b4fc760ccca1518.js +1 -0
- package/assets/esri/core/workers/chunks/f244632f7934a4b72c91.js +1 -0
- package/assets/esri/core/workers/chunks/fc639c730115e07a4a1a.js +1 -0
- package/assets/esri/libs/dxtEncoder/dxt_encoder.wasm +0 -0
- package/chunks/Component.glsl.js +104 -67
- package/chunks/LineMarker.glsl.js +31 -31
- package/chunks/RibbonLine.glsl.js +60 -49
- package/chunks/dxt_encoder.js +1 -1
- package/chunks/vec3.js +1 -1
- package/config.js +1 -1
- package/core/has.js +1 -1
- package/geometry/support/aaBoundingBox.js +1 -1
- package/geometry/support/buffer/math/vec3.js +1 -1
- package/geometry/support/frustum.js +1 -1
- package/geometry/support/meshUtils/extent.js +1 -1
- package/geometry/support/meshUtils/vertexSpaceConversion.js +1 -1
- package/kernel.js +1 -1
- package/layers/orientedImagery/transformations/imageToWorld.js +1 -1
- package/layers/orientedImagery/transformations/utils.js +1 -1
- package/package.json +1 -1
- package/support/revision.js +1 -1
- package/symbols/cim/CIMSymbolDrawHelper.js +1 -1
- package/symbols/cim/CIMSymbolHelper.js +1 -1
- package/symbols/cim/TextRasterizer.js +1 -1
- package/symbols/cim/cimAnalyzer.js +1 -1
- package/symbols/cim/richTextUtils.js +2 -0
- package/views/2d/engine/webgl/TextureManager.js +1 -1
- package/views/2d/engine/webgl/definitions.js +1 -1
- package/views/2d/engine/webgl/mesh/templates/shapingUtils.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/labels/LabelMeshWriter.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/text/TextMeshWriter.js +1 -1
- package/views/2d/engine/webgl/util/DimensionMatcher.js +1 -1
- package/views/2d/layers/FeatureLikeLayerView2D.js +1 -1
- package/views/2d/layers/features/schema/processor/symbols/SymbolSchema.js +1 -1
- package/views/2d/layers/support/annodime/DimensionInfo.js +1 -1
- package/views/2d/layers/support/annodime/dimensionUtils.js +1 -1
- package/views/3d/analysis/LineOfSight/LineOfSightReshapeTool3D.js +1 -1
- package/views/3d/analysis/Viewshed/ViewshedConfiguration.js +1 -1
- package/views/3d/analysis/Viewshed/ViewshedEditTool.js +1 -1
- package/views/3d/analysis/Viewshed/ViewshedSubTool.js +1 -1
- package/views/3d/analysis/Viewshed/ViewshedSubVisualization.js +1 -1
- package/views/3d/analysis/Viewshed/ViewshedTool.js +1 -1
- package/views/3d/analysis/ViewshedAnalysisView3D.js +1 -1
- package/views/3d/analysis/VolumeMeasurement/VolumeMeasurementCutFillController.js +1 -1
- package/views/3d/analysis/VolumeMeasurement/VolumeMeasurementCutFillVisualization.js +1 -1
- package/views/3d/focusAreaUtils.js +1 -1
- package/views/3d/layers/graphics/Graphics3DExtrudeSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/Graphics3DMeshFillSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/objectResourceUtils.js +1 -1
- package/views/3d/layers/graphics/wosrLoader.js +1 -1
- package/views/3d/layers/i3s/meshUtils.js +1 -1
- package/views/3d/webgl/RenderCamera.js +1 -1
- package/views/3d/webgl/RenderNode.js +1 -1
- package/views/3d/webgl-engine/collections/Component/Material/Component.glsl.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/TextureBackedBuffer.glsl.js +2 -2
- package/views/3d/webgl-engine/core/shaderLibrary/TextureBackedBufferFields.glsl.js +2 -2
- package/views/3d/webgl-engine/core/shaderLibrary/attributes/RibbonVertexPosition.glsl.js +36 -25
- package/views/3d/webgl-engine/core/shaderLibrary/terrain/Overlay.glsl.js +17 -10
- package/views/3d/webgl-engine/lib/BoundingInfo.js +1 -1
- package/views/3d/webgl-engine/lib/Object3D.js +1 -1
- package/views/3d/webgl-engine/lib/PolygonIntersections2D.js +1 -1
- package/views/3d/webgl-engine/lib/RayIntersections.js +1 -1
- package/views/3d/webgl-engine/lib/RenderGeometry.js +1 -1
- package/views/3d/webgl-engine/lib/depthRangeUtils.js +1 -1
- package/views/3d/webgl-engine/lib/lodRendering/LodLevel.js +1 -1
- package/views/3d/webgl-engine/lib/screenPolygonOverlapUtils.js +1 -1
- package/views/3d/webgl-engine/lib/screenPolygonTriangleIntersections.js +1 -1
- package/views/3d/webgl-engine/materials/PathMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/RibbonLineMaterial.js +1 -1
- package/views/3d/webgl-engine/shaders/AnimatedLine.glsl.js +8 -5
- package/views/3d/webgl-engine/shaders/RibbonLine.glsl.js +1 -1
- package/views/3d/webgl-engine/shaders/RibbonLineLayouts.js +1 -1
- package/views/3d/webgl-engine/shaders/RibbonLineTechnique.js +1 -1
- package/views/3d/webgl-engine/shaders/RibbonLineTextureBuffer.glsl.js +1 -1
- package/views/SceneView.js +1 -1
- package/views/interactive/snapping/featureSources/FeatureServiceSnappingSource.js +1 -1
- package/views/interactive/snapping/featureSources/featureServiceSource/FeatureServiceSnappingSourceWorkerHandle.js +1 -1
- package/views/interactive/snapping/featureSources/featureServiceSource/FeatureServiceTiledFetcher.js +1 -1
- package/views/selection/SelectionOperation.js +1 -1
- package/views/support/DefaultsFromMap.js +1 -1
- package/views/support/LayerViewManager.js +1 -1
- package/views/support/TextureCompressionWorker.js +1 -1
- package/views/webgl/RenderingContext.js +1 -1
- package/widgets/Editor.js +1 -1
- package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
- package/widgets/OrientedImageryViewer/services/SuperimposeService.js +1 -1
- package/widgets/OrientedImageryViewer/support/superimposeUtils.js +1 -1
- package/widgets/PanoramicViewer/support/PanoramicTileNode.d.ts +63 -0
- package/widgets/PanoramicViewer/support/PanoramicTileNode.js +1 -1
- package/widgets/PanoramicViewer/support/PanoramicTilePyramid.d.ts +66 -0
- package/widgets/PanoramicViewer/support/PanoramicTilePyramid.js +1 -1
- package/widgets/PanoramicViewer/utils.js +1 -1
- package/widgets/Sketch/VisibleElements.d.ts +0 -10
- package/widgets/Sketch.js +1 -1
- package/widgets/support/SelectionToolbar/SelectionToolbarViewModel.js +1 -1
- package/widgets/support/SelectionToolbar.js +1 -1
- package/widgets/support/Selector3D/selectorUtils.js +2 -0
- package/assets/esri/core/workers/chunks/0e64e20fedfe01a1985f.js +0 -1
- package/assets/esri/core/workers/chunks/0f674c625f24ac73e25a.js +0 -1
- package/assets/esri/core/workers/chunks/15351354afcbf840a23d.js +0 -29
- package/assets/esri/core/workers/chunks/1843a762f7051f61af43.js +0 -1
- package/assets/esri/core/workers/chunks/1d1f5578c7d8619f7a46.js +0 -1
- package/assets/esri/core/workers/chunks/2015f4def2ef201bdab8.js +0 -1
- package/assets/esri/core/workers/chunks/20c363a113dc068de9e0.js +0 -1
- package/assets/esri/core/workers/chunks/24d936d459c538187af6.js +0 -1
- package/assets/esri/core/workers/chunks/272c8ab189217240d05f.js +0 -1
- package/assets/esri/core/workers/chunks/2e121eac97ae72a8b49a.js +0 -1
- package/assets/esri/core/workers/chunks/327899182a4dace428eb.js +0 -1
- package/assets/esri/core/workers/chunks/32ca15d928d51b380068.js +0 -1
- package/assets/esri/core/workers/chunks/3e1a7e4c674057807e3a.js +0 -1
- package/assets/esri/core/workers/chunks/4e2baa60c5d5197b2271.js +0 -1
- package/assets/esri/core/workers/chunks/519c0b51b1ba42fb71d7.js +0 -1
- package/assets/esri/core/workers/chunks/57fa3c0e7892c2eef3ee.js +0 -261
- package/assets/esri/core/workers/chunks/68b615bbd27fadcfcb66.js +0 -1
- package/assets/esri/core/workers/chunks/69d740ab18510156f5d6.js +0 -1
- package/assets/esri/core/workers/chunks/8d21f3d6edbcd7b335d0.js +0 -1
- package/assets/esri/core/workers/chunks/9a97f6cda2f36941efae.js +0 -1
- package/assets/esri/core/workers/chunks/9ceeae787dc7c194d60e.js +0 -1
- package/assets/esri/core/workers/chunks/a90f7b1c6c69b6033b4c.js +0 -1
- package/assets/esri/core/workers/chunks/b32bdf5730953c2fb16b.js +0 -1
- package/assets/esri/core/workers/chunks/b5d23efa584c74955d5b.js +0 -1
- package/assets/esri/core/workers/chunks/b83f2bbd634f57a5e8f9.js +0 -1
- package/assets/esri/core/workers/chunks/bb8e9b8343b83dd1ba3c.js +0 -1
- package/assets/esri/core/workers/chunks/bef1990159c0e49e7d27.js +0 -1
- package/assets/esri/core/workers/chunks/bf287f0e2ecb4532dc00.js +0 -1
- package/assets/esri/core/workers/chunks/c5e36544b2d1792e4c5f.js +0 -1
- package/assets/esri/core/workers/chunks/cba3316910ff088f4d77.js +0 -1
- package/assets/esri/core/workers/chunks/de9573871f64c01e9f01.js +0 -1
- package/assets/esri/core/workers/chunks/e232459f0b00110e07ac.js +0 -1
- package/assets/esri/core/workers/chunks/ee6bb6cd16f99421c76b.js +0 -1
- package/assets/esri/core/workers/chunks/fd2ba6f76645ba503cbb.js +0 -1
- package/views/3d/analysis/Viewshed/ViewshedTool2.js +0 -2
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
const t=8,e=t-2,c=1e-30,h=64,i=4294967295,o=512,a=256,d=256/360,n=128,p=16777216,r=!1,s=128,f=8,g=10,l=29,m=10,
|
|
2
|
+
const t=8,e=t-2,c=1e-30,h=64,i=4294967295,o=512,a=256,d=256/360,n=128,p=16777216,r=!1,s=128,f=8,g=10,l=29,m=.25,v=4,w=10,x=1,b=16,j=16,k=o/s,q=8,u=50,y=10,z=24,A=3,B=24,C=8,D=3,E=24,F=8,G=4,H={metrics:{width:15,height:17,left:0,top:-7,advance:14}},I=1024,J=0,K=0,L=0,M=1,N=2,O=3,P=4,Q=5,R=6,S=12,T=13,U=5,V=6,W=5,X=6,Y=6,Z=1<<Y,$=Z<<1,_=!1,tt=1.05,et=3,ct=1,ht=3,it=3,ot=5,at=6,dt=1.15,nt=2,pt=4,rt=128,st=256,ft=st-2*pt,gt=2,lt=128,mt=1,vt=8,wt=500,xt=4,bt=128,jt=1024,kt=2,qt=0,ut=1,yt=4,zt=8,At=16,Bt=4,Ct=1,Dt=4,Et=8,Ft=32,Gt=64,Ht=128,It=4,Jt=1,Kt=1<<20,Lt=.75,Mt=10,Nt=.75,Ot=12,Pt=256,Qt=32,Rt=512,St=0,Tt=1;export{Jt as MAX_TILE_RESHUFFLES_PER_FRAME,Mt as RESHUFFLING_EXEMPT_DRAW_CALLS,Kt as RESHUFFLING_EXEMPT_MEMORY_BYTES,Nt as RESHUFFLING_TARGET_DRAW_EFFICIENCY,Lt as RESHUFFLING_TARGET_MEMORY_EFFICIENCY,N as animationUnit,Pt as attributeStoreInitialSize,I as attributeStoreTextureSize,H as averageGlyphMosaicItem,Tt as backbufferStencilClipped,St as backbufferStencilVisible,Ft as bitsetFillHasPatternHeightPrecisionFactor,Gt as bitsetFillHasPatternWidthPrecisionFactor,Et as bitsetFillHasUnresolvedReplacementColor,Dt as bitsetFillRandomPatternOffset,At as bitsetGenericConsiderAlphaOnly,kt as bitsetGenericLockColor,Bt as bitsetLineScaleDash,ut as bitsetMarkerAlignmentMap,qt as bitsetMarkerAlignmentScreen,yt as bitsetMarkerOutlineAllowColorOverride,zt as bitsetMarkerScaleSymbolsProportionally,Ct as bitsetTypeFillOutline,bt as bufferDataMinimumSize,xt as bufferDataPoolSize,g as chartMaxFields,j as collisionBoxPadding,s as collisionBucketSize,b as collisionEarlyRejectBucketSize,x as collisionMaxZoomDelta,q as collisionPlacementPadding,k as collisionTileBoxSize,n as compressionFactorForU16,P as dataDrivenUnit0,Q as dataDrivenUnit1,R as dataDrivenUnit2,r as debugLabels,rt as defaultSdfTextureSize,vt as displayRecordIntPerElement,f as dotDensityMaxFields,$ as effectFlag0,_ as enableEarlyLabelDiscard,h as extrudeScale,Z as filterFlag0,M as filterFlagsUnit,z as glyphSize,S as gpgpuUnit,mt as gradientTextureExternalPadding,y as heuristicGlyphsPerFeature,u as heuristicGlyphsPerLine,it as hittestSmallSymbolThreshold,ct as hittestToleranceDesktop,et as hittestToleranceMobile,ht as hittestToleranceSmallSymbol,G as labelPlacementOffsetPadding,w as labelU16ZoomPrecisionFactor,T as localTimeOriginUnit,l as magicLabelLineHeight,Ot as maxGeohashLevel,nt as maxGpuUploadsPerFrame,Y as maxHighlightReasons,v as maxLineHeightRatio,p as maxRepresentableInt,Rt as maxTextLineWidth,m as minLineHeightRatio,Qt as minTextLineWidth,c as nanMagicNumber,d as packDegreesU8,wt as patchPixelBufferAllocSize,gt as patternFillRasterizationScale,i as pictureFillColor,jt as randomInsidePolygonTextureSize,a as rasterTileSize,lt as rasterizedVectorMarkerMinSize,D as sdfBufferGlyphSDFCreator,A as sdfBufferServer,F as sdfRadiusComplex,C as sdfRadiusSimple,E as sdfSizeComplex,B as sdfSizeSimple,pt as spritePadding,ft as svgSdfTextureInnerSize,st as svgSdfTextureSize,L as textureBindingBitmap,K as textureBindingGlyphAtlas,U as textureBindingHighlight0,V as textureBindingHighlight1,W as textureBindingRenderer0,X as textureBindingRenderer1,J as textureBindingSpriteAtlas,It as textureUploadManagerBudget,Ht as textureUploadManagerChunkSize,tt as thinLineHalfWidthThreshold,o as tileSize,O as visualVariableUnit,dt as vtlHighResCutoff,at as vtlTextureBindingUnitGlyphs,ot as vtlTextureBindingUnitSprites,e as webglMaxInnerStops,t as webglMaxStops};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
import{fromRotation as t,multiply as e,translate as i,rotate as s}from"../../../../../../core/libs/gl-matrix-2/math/mat2d.js";import{create as n}from"../../../../../../core/libs/gl-matrix-2/factories/mat2df32.js";import{transformMat2d as o,set as h}from"../../../../../../core/libs/gl-matrix-2/math/vec2.js";import{create as r}from"../../../../../../core/libs/gl-matrix-2/factories/vec2f32.js";import{getXAnchorDirection as a,getYAnchorDirection as f}from"../../alignmentUtils.js";import c from"../../Rect.js";import d from"../../collisions/BoundingBox.js";const l=22,g=4,m=l+g,u=l-6,x=Math.PI/180,p=8,w=1.5;class _{constructor(t,e,i,s){this._rotationT=n(),this._transform=n(),this._angle=0,this._bounds=null;const{mosaicItem:o,rect:h,shaping:r,code:a}=i,f=o.rect;this.width=0===a?h.width:f.width*s,this.height=0===a?h.height:f.height*s,this.x=s*(t+r.xOffset+h.left),this.y=s*(e+r.yOffset-h.top),this.textureBinding=o.textureBinding,this.texcoords={topLeft:[f.x,f.y],topRight:[f.x+f.width,f.y],bottomLeft:[f.x,f.y+f.height],bottomRight:[f.x+f.width,f.y+f.height]}}set angle(e){this._angle=e,t(this._rotationT,-e),this._offsets=this._bounds=null}get angle(){return this._angle}get offsets(){if(!this._offsets){const{x:i,y:s,width:h,height:r}=this,a=t(n(),-this.angle),f=e(n(),a,this._transform);this._offsets={topLeft:o([0,0],[i,s],f),topRight:o([0,0],[i+h,s],f),bottomLeft:o([0,0],[i,s+r],f),bottomRight:o([0,0],[i+h,s+r],f)}}return this._offsets}get bounds(){if(this.width<=0)return null;if(!this._bounds){const t=this.offsets;let e=1/0,i=1/0,s=-1/0,n=-1/0;for(const[f,c]of[t.topLeft,t.topRight,t.bottomLeft,t.bottomRight])e=Math.min(e,f),i=Math.min(i,c),s=Math.max(s,f),n=Math.max(n,c);const o=s-e,h=n-i,r=e+o/2,a=i+h/2;this._bounds=new d(r,a,o,h)}return this._bounds}setTransform(t){this._transform=t,this._offsets=null}}const y=(t,e)=>({code:0,mosaicItem:{rect:new c(0,0,11,8),sdf:!0,page:0,textureBinding:e},rect:{height:4,width:t,left:0,top:0},shaping:{xOffset:0,yOffset:0,xAdvance:0,yAdvance:0}});function b(t,e){return t.forEach(t=>o(t,t,e)),{topLeft:t[0],topRight:t[1],bottomLeft:t[2],bottomRight:t[3]}}class M{constructor(t,e,i,s){this._rotation=0,this._decorate(t,e,i,s),this.glyphs=t,this.bounds=this._createBounds(t),this.isMultiline=e.length>1,this._hasRotation=0!==i.angle,this._transform=this._createGlyphTransform(this.bounds,i),this._borderLineSizePx=i.borderLineSizePx,(i.borderLineSizePx||i.hasBackground)&&([this.bounds,this.textBox]=this.shapeBackground(this._transform));for(const n of t)n.setTransform(this._transform)}setRotation(i){if(0===i&&0===this._rotation)return;this._rotation=i;const s=this._transform,o=t(n(),i);e(s,o,s);for(const t of this.glyphs)t.setTransform(this._transform)}_decorate(t,e,i,s){if(!i.decoration||"none"===i.decoration||!t.length)return;const n=i.scale,o="underline"===i.decoration?s?.baseline??m:s?.midline??u,h=t[0].textureBinding;for(const r of e){const e=r.startX*n,i=r.startY*n,s=(r.width+r.glyphWidthEnd)*n;t.push(new _(e,i+o*n,y(s,h),1))}}shapeBackground(t){const e=this._borderLineSizePx||0,i=(w+e)/2,s=this._borderLineSizePx?i:0,{xmin:n,ymin:o,xmax:h,ymax:r,x:a,y:f,width:c,height:l}=this.bounds,g=[n-p,o-p],m=[h+p,o-p],u=[n-p,r+p],x=[h+p,r+p],_=b([[g[0]-i,g[1]-i],[m[0]+i,m[1]-i],[g[0]+s,g[1]+s],[m[0]-s,m[1]+s]],t),y=b([[u[0]+s,u[1]-s],[x[0]-s,x[1]-s],[u[0]-i,u[1]+i],[x[0]+i,x[1]+i]],t),M=b([[g[0]-i,g[1]-i],[g[0]+s,g[1]+s],[u[0]-i,u[1]+i],[u[0]+s,u[1]-s]],t),L=b([[m[0]-s,m[1]+s],[m[0]+i,m[1]-i],[x[0]-s,x[1]-s],[x[0]+i,x[1]+i]],t),A={main:b([g,m,u,x],t),top:_,bot:y,left:M,right:L};return[new d(a,f,c+2*i,l+2*i),A]}get boundsT(){const t=this.bounds,e=h(r(),t.x,t.y);if(o(e,e,this._transform),this._hasRotation){const i=Math.max(t.width,t.height);return new d(e[0],e[1],i,i)}return new d(e[0],e[1],t.width,t.height)}_createBounds(t){let e=1/0,i=1/0,s=0,n=0;for(const r of t)e=Math.min(e,r.offsets.topLeft[0]),i=Math.min(i,r.offsets.topLeft[1]),s=Math.max(s,r.offsets.bottomRight[0]),n=Math.max(n,r.offsets.bottomRight[1]);const o=s-e,h=n-i;return new d(e+o/2,i+h/2,o,h)}_createGlyphTransform(t,e){const o=x*e.angle,a=n(),f=r();return i(a,a,h(f,e.xOffset,-e.yOffset)),e.useCIMAngleBehavior?s(a,a,o):(i(a,a,h(f,t.x,t.y)),s(a,a,o),i(a,a,h(f,-t.x,-t.y))),a}}class L{constructor(t,e,i,s,n,o){this.glyphWidthEnd=0,this.startX=0,this.startY=0,this.start=Math.max(0,Math.min(e,i)),this.end=Math.max(0,Math.max(e,i)),this.end<t.length&&(this.glyphWidthEnd=t[this.end].rect.width),this.width=s,this.yMin=n,this.yMax=o}}const A=t=>10===t,R=t=>32===t;function v(t,e,i){const s=new Array,n=1/i.scale,o=i.maxLineWidth*n,h=e?t.length-1:0,r=e?-1:t.length,a=e?-1:1;let f=h,c=0,d=0,l=f,g=l,m=0,u=1/0,x=0;for(;f!==r;){const{code:e,rect:i,shaping:n}=t[f],r=Math.abs(i.top);if(A(e)||R(e)||(u=Math.min(u,r),x=Math.max(x,r+i.height)),A(e))f!==h&&(s.push(new L(t,l,f-a,c,u===1/0?0:u,x)),u=1/0,x=0),c=0,l=f+a,g=f+a,d=0;else if(R(e))g=f+a,d=0,m=n.xAdvance,c+=n.xAdvance;else if(c>o){if(g!==l){const e=g-2*a;c-=m,s.push(new L(t,l,e,c-d,u,x)),u=1/0,x=0,l=g,c=d}else s.push(new L(t,l,f-a,c,u,x)),u=1/0,x=0,l=f,g=f,c=0;c+=n.xAdvance,d+=n.xAdvance}else c+=n.xAdvance,d+=n.xAdvance;f+=a}const p=new L(t,l,f-a,c,u,x);return p.start>=0&&p.end<t.length&&s.push(p),s}function B(t,e){let i=0;for(let o=0;o<t.length;o++){const{width:e}=t[o];i=Math.max(e,i)}const s="underline"===e.decoration?g:0,n=t[0].yMin;return{x:0,y:n,height:t[t.length-1].yMax+e.lineHeight*(t.length-1)+s-n,width:i}}function T(t,e,i){let s=0;for(let n=e;n<i;n++)R(t[n].code)&&!A(t[n+1].code)&&s++;return s}function j(t,e){const i=e.scale,s=new Array,n=t.sdfPadding,{faceInfo:o,glyphs:h,isRightToLeft:r}=t,c="justify"===e.horizontalAlignment||"Justify"===e.horizontalAlignment,d=v(h,r,e),g=d.length?B(d,e):{y:0,height:0,width:0},m=c?r?1:-1:a(e.horizontalAlignment),u=f(e.verticalAlignment),x=2===u?1:0,p=x?0:u-1,w=o?.baseline??l,y=d.length>1,b=x?y?-g.y-g.height:-w:-g.y+p*(g.height/2);for(let a=0;a<d.length;a++){const{start:o,end:r,width:f}=d[a],l=c&&a<d.length-1?T(h,o,r):0,u=l>0?(g.width-f)/l:0;let x=-1*(m+1)*((u>0?g.width:f)/2)-n;const p=(t.isRightToLeft?d.length-1-a:a)*e.lineHeight+b-n;d[a].startX=x,d[a].startY=p;for(let t=o;t<=r;t++){const e=h[t];if(A(e.code))continue;const n=new _(x,p,e,i);x+=e.shaping.xAdvance,u>0&&R(e.code)&&(x+=u),s.push(n)}}return new M(s,d,e,o)}function z(t,e){const i=e.scale,{faceInfo:s,glyphs:n}=t,o=n.reduce((t,e)=>Math.max(t,e.rect.height),0),h=n.map(t=>new _(-t.rect.width/2,-o,t,i));return new M(h,[],e,s)}export{_ as ShapedGlyph,M as ShapingInfo,j as shapeGlyphs,z as shapeGlyphsForMultipoint};
|
|
2
|
+
import{pt2px as t}from"../../../../../../core/screenUtils.js";import{fromRotation as e,multiply as n,translate as i,rotate as s}from"../../../../../../core/libs/gl-matrix-2/math/mat2d.js";import{create as o}from"../../../../../../core/libs/gl-matrix-2/factories/mat2df32.js";import{transformMat2d as h,set as r}from"../../../../../../core/libs/gl-matrix-2/math/vec2.js";import{create as a}from"../../../../../../core/libs/gl-matrix-2/factories/vec2f32.js";import{getXAnchorDirection as l,getYAnchorDirection as c}from"../../alignmentUtils.js";import{magicLabelLineHeight as f}from"../../definitions.js";import d from"../../Rect.js";import g from"../../collisions/BoundingBox.js";const m=22,u=4,p=m+u,y=m-6,x=Math.PI/180,w=8,b=1.5;class M{static fromGlyph(t,e,n,i,s){const{mosaicItem:o,rect:h,shaping:r,code:a}=n,l=o.rect;return new M({width:0===a?h.width:l.width*i,height:0===a?h.height:l.height*i,x:i*(t+r.xOffset+h.left),y:i*(e+r.yOffset-h.top),textureBinding:o.textureBinding,texcoords:{topLeft:[l.x,l.y],topRight:[l.x+l.width,l.y],bottomLeft:[l.x,l.y+l.height],bottomRight:[l.x+l.width,l.y+l.height]},fontSize:s?.fontSize,color:s?.color})}constructor(t){this._rotationT=o(),this._transform=o(),this._angle=0,this._bounds=null,this.width=t.width,this.height=t.height,this.x=t.x,this.y=t.y,this.textureBinding=t.textureBinding,this.texcoords=t.texcoords,this.fontSize=t.fontSize,this.color=t.color}set angle(t){this._angle=t,e(this._rotationT,-t),this._offsets=this._bounds=null}get angle(){return this._angle}get offsets(){if(!this._offsets){const{x:t,y:i,width:s,height:r}=this,a=e(o(),-this.angle),l=n(o(),a,this._transform);this._offsets={topLeft:h([0,0],[t,i],l),topRight:h([0,0],[t+s,i],l),bottomLeft:h([0,0],[t,i+r],l),bottomRight:h([0,0],[t+s,i+r],l)}}return this._offsets}get bounds(){if(this.width<=0)return null;if(!this._bounds){const t=this.offsets;let e=1/0,n=1/0,i=-1/0,s=-1/0;for(const[l,c]of[t.topLeft,t.topRight,t.bottomLeft,t.bottomRight])e=Math.min(e,l),n=Math.min(n,c),i=Math.max(i,l),s=Math.max(s,c);const o=i-e,h=s-n,r=e+o/2,a=n+h/2;this._bounds=new g(r,a,o,h)}return this._bounds}setTransform(t){this._transform=t,this._offsets=null}}const _=(t,e)=>({code:0,mosaicItem:{rect:new d(0,0,11,8),sdf:!0,page:0,textureBinding:e},rect:{height:4,width:t,left:0,top:0},shaping:{xOffset:0,yOffset:0,xAdvance:0,yAdvance:0}});function A(t,e){return t.forEach(t=>h(t,t,e)),{topLeft:t[0],topRight:t[1],bottomLeft:t[2],bottomRight:t[3]}}class v{constructor(t,e,n,i){this._rotation=0,this._decorate(t,e,n,i),this.glyphs=t,this.bounds=this._createBounds(t),this.isMultiline=e.length>1,this._hasRotation=0!==n.angle,this._transform=this._createGlyphTransform(this.bounds,n),this._borderLineSizePx=n.borderLineSizePx,(n.borderLineSizePx||n.hasBackground)&&([this.bounds,this.textBox]=this.shapeBackground(this._transform));for(const s of t)s.setTransform(this._transform)}setRotation(t){if(0===t&&0===this._rotation)return;this._rotation=t;const i=this._transform,s=e(o(),t);n(i,s,i);for(const e of this.glyphs)e.setTransform(this._transform)}_decorate(t,e,n,i){if(!n.decoration||"none"===n.decoration||!t.length)return;const s=n.scale,o=t[0].textureBinding;for(const h of e){const e=h.scale??s,r="underline"===n.decoration?h.baseline??i?.baseline??p:h.midline??i?.midline??y,a=h.startX*e,l=h.startY*e,c=(h.width+h.glyphWidthEnd)*e;t.push(M.fromGlyph(a,l+r*e,_(c,o),1))}}shapeBackground(t){const e=this._borderLineSizePx||0,n=(b+e)/2,i=this._borderLineSizePx?n:0,{xmin:s,ymin:o,xmax:h,ymax:r,x:a,y:l,width:c,height:f}=this.bounds,d=[s-w,o-w],m=[h+w,o-w],u=[s-w,r+w],p=[h+w,r+w],y=A([[d[0]-n,d[1]-n],[m[0]+n,m[1]-n],[d[0]+i,d[1]+i],[m[0]-i,m[1]+i]],t),x=A([[u[0]+i,u[1]-i],[p[0]-i,p[1]-i],[u[0]-n,u[1]+n],[p[0]+n,p[1]+n]],t),M=A([[d[0]-n,d[1]-n],[d[0]+i,d[1]+i],[u[0]-n,u[1]+n],[u[0]+i,u[1]-i]],t),_=A([[m[0]-i,m[1]+i],[m[0]+n,m[1]-n],[p[0]-i,p[1]-i],[p[0]+n,p[1]+n]],t),v={main:A([d,m,u,p],t),top:y,bot:x,left:M,right:_};return[new g(a,l,c+2*n,f+2*n),v]}get boundsT(){const t=this.bounds,e=r(a(),t.x,t.y);if(h(e,e,this._transform),this._hasRotation){const n=Math.max(t.width,t.height);return new g(e[0],e[1],n,n)}return new g(e[0],e[1],t.width,t.height)}_createBounds(t){let e=1/0,n=1/0,i=0,s=0;for(const r of t)e=Math.min(e,r.offsets.topLeft[0]),n=Math.min(n,r.offsets.topLeft[1]),i=Math.max(i,r.offsets.bottomRight[0]),s=Math.max(s,r.offsets.bottomRight[1]);const o=i-e,h=s-n;return new g(e+o/2,n+h/2,o,h)}_createGlyphTransform(t,e){const n=x*e.angle,h=o(),l=a();return i(h,h,r(l,e.xOffset,-e.yOffset)),e.useCIMAngleBehavior?s(h,h,n):(i(h,h,r(l,t.x,t.y)),s(h,h,n),i(h,h,r(l,-t.x,-t.y))),h}}class z{constructor(t,e,n,i,s,o){this.glyphWidthEnd=0,this.startX=0,this.startY=0,this.start=Math.max(0,Math.min(e,n)),this.end=Math.max(0,Math.max(e,n)),this.end<t.length&&(this.glyphWidthEnd=t[this.end].rect.width),this.width=i,this.yMin=s,this.yMax=o}}const L=t=>10===t,R=t=>32===t;function S(t,e,n){const i=new Array,s=1/n.scale,o=n.maxLineWidth*s,h=e?t.length-1:0,r=e?-1:t.length,a=e?-1:1;let l=h,c=0,f=0,d=l,g=d,m=0,u=1/0,p=0;for(;l!==r;){const{code:e,rect:n,shaping:s}=t[l],r=Math.abs(n.top);if(L(e)||R(e)||(u=Math.min(u,r),p=Math.max(p,r+n.height)),L(e))l!==h&&(i.push(new z(t,d,l-a,c,u===1/0?0:u,p)),u=1/0,p=0),c=0,d=l+a,g=l+a,f=0;else if(R(e))g=l+a,f=0,m=s.xAdvance,c+=s.xAdvance;else if(c>o){if(g!==d){const e=g-2*a;c-=m,i.push(new z(t,d,e,c-f,u,p)),u=1/0,p=0,d=g,c=f}else i.push(new z(t,d,l-a,c,u,p)),u=1/0,p=0,d=l,g=l,c=0;c+=s.xAdvance,f+=s.xAdvance}else c+=s.xAdvance,f+=s.xAdvance;l+=a}const y=new z(t,d,l-a,c,u,p);return y.start>=0&&y.end<t.length&&i.push(y),i}function B(t,e){let n=0;for(let o=0;o<t.length;o++){const{width:e}=t[o];n=Math.max(e,n)}const i="underline"===e.decoration?u:0,s=t[0].yMin;return{x:0,y:s,height:t[t.length-1].yMax+e.lineHeight*(t.length-1)+i-s,width:n}}function Y(t,e,n){let i=0;for(let s=e;s<n;s++)R(t[s].code)&&!L(t[s+1].code)&&i++;return i}function j(t,e){const n=e.scale,i=new Array,s=t.sdfPadding,{faceInfo:o,glyphs:h,isRightToLeft:r}=t,a="justify"===e.horizontalAlignment||"Justify"===e.horizontalAlignment,f=S(h,r,e),d=f.length?B(f,e):{y:0,height:0,width:0},g=a?r?1:-1:l(e.horizontalAlignment),u=c(e.verticalAlignment),p=2===u?1:0,y=p?0:u-1,x=o?.baseline??m,w=f.length>1,b=p?w?-d.y-d.height:-x:-d.y+y*(d.height/2);for(let l=0;l<f.length;l++){const{start:o,end:r,width:c}=f[l],m=a&&l<f.length-1?Y(h,o,r):0,u=m>0?(d.width-c)/m:0;let p=-1*(g+1)*((u>0?d.width:c)/2)-s;const y=(t.isRightToLeft?f.length-1-l:l)*e.lineHeight+b-s;f[l].startX=p,f[l].startY=y;for(let t=o;t<=r;t++){const e=h[t];if(L(e.code))continue;const s=M.fromGlyph(p,y,e,n);p+=e.shaping.xAdvance,u>0&&R(e.code)&&(p+=u),i.push(s)}}return new v(i,f,e,o)}function H(t,e){const n=e.scale,{faceInfo:i,glyphs:s}=t,o=s.reduce((t,e)=>Math.max(t,e.rect.height),0),h=s.map(t=>M.fromGlyph(-t.rect.width/2,-o,t,n));return new v(h,[],e,i)}function T(t,e){return"glyphs"===t.type?j(t,e):E(t,e)}function W(t,e){return"glyphs"===t.type?H(t,e):G(t,e)}function E(t,e){const n=I(t,e),i=X(n,e),s=i.length?O(i):{width:0},o=new Array,h="justify"===e.horizontalAlignment||"Justify"===e.horizontalAlignment,r=h?-1:l(e.horizontalAlignment),a=c(e.verticalAlignment),f=2===a,d=i.length?i[0].yMin:0,g=i.length?i[i.length-1].startY+i[i.length-1].yMax:0,m=g-d,u=f?i.length>1?-g:-(i[0]?.baseline??0):1===a?-d:-1===a?-g:-(d+m/2);for(let l=0;l<i.length;l++){const t=i[l],e=h&&l<i.length-1?k(n,t.start,t.end):0,a=e>0?(s.width-t.width)/e:0;let c=-1*(r+1)*((a>0?s.width:t.width)/2);const f=t.startY+u;t.startX=c,t.startY=f;for(let i=t.start;i<=t.end;i++){const e=n[i],{glyph:s,scale:h,fontSize:r}=e;if(L(s.code))continue;const l=f+t.baseline-e.baseline;o.push(M.fromGlyph(c/h,l/h,s,h,{fontSize:r,color:e.color})),c+=e.xAdvance,a>0&&R(s.code)&&(c+=a)}}return new v(o,i,e)}function G(t,e){const n=I(t,e),i=n.reduce((t,e)=>Math.max(t,e.glyph.rect.height*e.scale),0),s=n.filter(t=>!L(t.glyph.code)).map(t=>M.fromGlyph(-t.glyph.rect.width/2,-i/t.scale,t.glyph,t.scale,{fontSize:t.fontSize,color:t.color}));return new v(s,[],e)}function I(e,n){const i=n.lineHeightRatio??1,s=[];for(const o of e.runs){const e=t(o.fontSize),n=e/o.glyphs.sdfSize,h=e*(f/24)*i,r=(o.glyphs.faceInfo?.baseline??m)*n,a=(o.glyphs.faceInfo?.midline??y)*n;for(const t of o.glyphs.glyphs){const i=Math.abs(t.rect.top)*n,l=i+t.rect.height*n;s.push({glyph:t,scale:n,fontSize:e,color:o.color,xAdvance:t.shaping.xAdvance*n,top:i,bottom:l,lineHeight:h,baseline:r,midline:a})}}return s}function X(t,e){const n=[],i=e.maxLineWidth;let s=0,o=0,h=0,r=0,a=0,l=0;for(;s<t.length;){const e=t[s],{glyph:c}=e;if(L(c.code))0!==s&&n.push({width:o,start:r,end:s-1,glyphWidthEnd:t[s-1]?.glyph.rect.width*t[s-1]?.scale||0,yMin:0,yMax:0,lineHeight:0,baseline:0,midline:0,startX:0,startY:0,scale:1}),o=0,r=s+1,a=r,h=0,l=0;else if(R(c.code))a=s+1,h=0,l=e.xAdvance,o+=e.xAdvance;else if(o>i){if(a!==r){const e=a-2;o-=l,n.push({width:o-h,start:r,end:e,glyphWidthEnd:t[e]?.glyph.rect.width*t[e]?.scale||0,yMin:0,yMax:0,lineHeight:0,baseline:0,midline:0,startX:0,startY:0,scale:1}),r=a,o=h}else n.push({width:o,start:r,end:s-1,glyphWidthEnd:t[s-1]?.glyph.rect.width*t[s-1]?.scale||0,yMin:0,yMax:0,lineHeight:0,baseline:0,midline:0,startX:0,startY:0,scale:1}),r=s,a=s,o=0;o+=e.xAdvance,h+=e.xAdvance}else o+=e.xAdvance,h+=e.xAdvance;s++}if(r<t.length){const e=t.length-1;n.push({width:o,start:r,end:e,glyphWidthEnd:t[e]?.glyph.rect.width*t[e]?.scale||0,yMin:0,yMax:0,lineHeight:0,baseline:0,midline:0,startX:0,startY:0,scale:1})}return P(t,n)}function P(t,e){for(let n=0;n<e.length;n++){const i=e[n];let s=0,o=1/0,h=0;for(let e=i.start;e<=i.end;e++){const n=t[e];L(n.glyph.code)||R(n.glyph.code)||(s=Math.max(s,n.baseline),h=Math.max(h,n.lineHeight))}let r=1/0,a=-1/0;for(let e=i.start;e<=i.end;e++){const n=t[e];L(n.glyph.code)||R(n.glyph.code)||(r=Math.min(r,s-n.baseline+n.top),a=Math.max(a,s-n.baseline+n.bottom),o=Math.min(o,s-n.baseline+n.midline))}i.baseline=s,i.midline=o===1/0?s:o,i.lineHeight=h||Math.max(0,a-r),i.yMin=r===1/0?0:r,i.yMax=a===-1/0?0:a,i.startY=n>0?e[n-1].startY+e[n-1].lineHeight:0}return e}function O(t){let e=0;for(const s of t)e=Math.max(s.width+s.glyphWidthEnd,e);const n=t[0].yMin,i=t[t.length-1];return{x:0,y:n,height:i.startY+i.yMax-n,width:e}}function k(t,e,n){let i=0;for(let s=e;s<n;s++)R(t[s].glyph.code)&&!L(t[s+1].glyph.code)&&i++;return i}export{M as ShapedGlyph,v as ShapingInfo,j as shapeGlyphs,H as shapeGlyphsForMultipoint,E as shapeRichText,G as shapeRichTextForMultipoint,T as shapeTextResource,W as shapeTextResourceForMultipoint};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
import{memoize as e}from"../../../../../../../core/MapUtils.js";import{pt2px as t}from"../../../../../../../core/screenUtils.js";import{numericHash as i}from"../../../../../../../core/string.js";import{fromRotation as r,translate as s}from"../../../../../../../core/libs/gl-matrix-2/math/mat2d.js";import{create as o}from"../../../../../../../core/libs/gl-matrix-2/factories/mat2df32.js";import{transformMat2d as n,set as a,sub as l,normalize as c,add as h,scale as m}from"../../../../../../../core/libs/gl-matrix-2/math/vec2.js";import{fromValues as u}from"../../../../../../../core/libs/gl-matrix-2/factories/vec2f32.js";import{create as d}from"../../../../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{convertGeometryToFlat as f,convertOptimizedGeometryToFlat as g,convertFlatToOptimizedGeometry as p,FlatGeometry as _}from"../../../../../../../geometry/FlatGeometry.js";import{GeometryCursor as y}from"../../../../../../../geometry/GeometryCursor.js";import{getLabelPoint as x}from"../../../../../../../geometry/support/labelPoint.js";import{generalizeOptimizedGeometry as P,convertToGeometry as v}from"../../../../../../../layers/graphics/featureConversionUtils.js";import b from"../../../../../../../layers/graphics/OptimizedGeometry.js";import{importLazily as M}from"../../../../../../../symbols/cim/utils.js";import{tileSize as w}from"../../../definitions.js";import L from"../../../collisions/BoundingBox.js";import{LabelMetric as I}from"../../../collisions/LabelMetric.js";import{smoothPaths as B,pathDivide as S}from"../../../mesh/templates/segmentUtils.js";import{getMinMaxZoom as z,processColorInput as G}from"../fill/meshWriterUtils.js";import{TextMeshWriter as j,maxLabelZoom as D}from"../text/TextMeshWriter.js";const A=1,F=0,R=128,$=w*w/16,k=M(()=>import("../../../../../../../geometry/operators/gx/operatorIntersection.js")),C=M(()=>import("../../../../../../../chunks/FlatGeometry.js"));function E(e,t,r){return i(`${e}${t}${r}`)}function O(e,t,r,s,o){return i(`${e}${t}${r}${s*2**(D-o)}`)}function T(e,t,r){return i(`${e}${t}${r}`)}function X(e,t,r,s,o){return i(`${e}${o}${t}${r*2**(D-s)}`)}const Y=e(e=>{let t=0;if(0===e)return 1/0;for(;!(e%2);)t++,e/=2;return t});class W extends j{constructor(){super(...arguments),this._zoomLevel=0}async loadDependencies(){await Promise.all([super.loadDependencies(),k.getImportPromise(),C.getImportPromise()])}_write(e,{target:t,effectGeometry:i,level:r,viewExtent:s}){if(this._zoomLevel=r,null!=i)throw new Error("InternalError: EffectGeometry not support for LabelMeshWriter");switch(t.geometryType){case"esriGeometryPoint":{const i=t.readXForDisplay(),r=t.readYForDisplay();this._writePoint(e,i,r,0,t);break}case"esriGeometryEnvelope":case"esriGeometryPolygon":this._writePolygon(e,t,s);break;case"esriGeometryMultipoint":{let i=0;const r=y.fromFeatureSetReader(t);if(r?.nextPath())for(;r.nextPoint();)this._writePoint(e,r.x,r.y,i++,t);break}case"esriGeometryPolyline":this._writeLines(e,t)}}_getMetricDir(){const{horizontalAlignment:e,verticalAlignment:t}=this.evaluatedMeshParams;return["center"===e?0:"right"===e?-1:1,"middle"===t?0:"bottom"===t?-1:1]}_createLineLabelMetric(e,t,i,r,s,o){const[n,a]=this._getMetricDir(),l=this.evaluatedMeshParams.scaleInfo?.maxScale??0,c=this.evaluatedMeshParams.scaleInfo?.minScale??0,h=this.evaluatedMeshParams.labelClassId;return new I(e,h,t,i,r,s,n,a,l,c,o)}_writePolygon(e,t,i){const r=k.module,s=C.module.constructFromFlatGeometry,o=t.readGeometryForDisplay()?.justXY(),n=t.readCentroidForDisplay()?.coords,a=o?.area()||0;if(!n)return;const l=a>=$;e.requiresRefresh||=l;const c=s(f(i)),h=s(f({x:n[0],y:n[1]})),m=!!r.execute(h,c,null);if(!o||!l||!m)return void this._writePoint(e,n[0],n[1],0,t);const u=s(g("polygon",o,null)),d=r.execute(u,c,null);if(!d)return void this._writePoint(e,n[0],n[1],0,t);const P=p(new _(d.toFlatGeometry())),v=y.fromOptimized(P,"esriGeometryPolygon",1),b=x(v)??n;this._writePoint(e,b[0],b[1],0,t)}_writePoint(e,t,i,r,s){if(t<0||t>w||i<0||i>w)return;const o=this._getShaping();if(!o)return;const n=s.getDisplayId(),a=this.evaluatedMeshParams.labelClassId,l=E(this.evaluatedMeshParams.layerId,s.getObjectId(),r),c=T(s.getObjectId(),a,r),[h,m]=this._getMetricDir(),u=this.evaluatedMeshParams.scaleInfo?.maxScale??0,d=this.evaluatedMeshParams.scaleInfo?.minScale??0,f=this._getPointReferenceBounds()||{offsetX:0,offsetY:0,size:0};e.metricStart(new I(n,a,l,c,t,i,h,m,u,d,f)),this._writeGlyphs(e,n,t,i,o,0,f,void 0,!1),e.metricBoxWrite(o.boundsT),e.metricEnd()}_getPointReferenceBounds(){if(!this._references)return null;for(const e of this._references){const t=e.getBoundsInfo();if(t)return t}return null}_writeLines(e,t){const{scaleInfo:i,verticalAlignment:r}=this.evaluatedMeshParams,s=this.evaluatedMeshParams.repeatLabelDistance||128,o=this._getShaping("middle");if(!o)return;const n=(e,t,i,r)=>this._placeSubdivGlyphs(e,t,i,r),a=(o.bounds.width+s)/(1<<A);this._current={out:e,id:t.getDisplayId(),objId:t.getObjectId(),shaping:o,zoomRange:z(i,this.getTileInfo()),referenceBounds:this._getPointReferenceBounds()||{offsetX:0,offsetY:0,size:0},offsetDirection:null,pathIndex:0},this._verticalPlacement="bottom"===r?"above":"top"===r?"below":null,this._verticalPlacement?this._writeAboveAndBelowAlong(t,n,a):this._writeCenterAlong(t,n,a)}_writeAboveAndBelowAlong(e,t,i){const{repeatLabel:r}=this.evaluatedMeshParams,{shaping:s}=this._current,o=s.bounds.halfHeight,n=e.readGeometryForDisplay()?.justXY();if(!n)return;const a=P(n,"esriGeometryPolyline",1)??new b,l=Z(a,o),c=Z(a,-o),h=v(c,"esriGeometryPolyline",!1,!1),m=v(l,"esriGeometryPolyline",!1,!1),u=B(m.paths,s.bounds.width),d=B(h.paths,s.bounds.width);this._current.offsetDirection="above";for(let f=0;f<u.length;f++)this._current.pathIndex=f,S(u[f],i,t,!!r);this._current.offsetDirection="below";for(let f=0;f<d.length;f++)this._current.pathIndex=f,S(d[f],i,t,!!r)}_writeCenterAlong(e,t,i){const{repeatLabel:r}=this.evaluatedMeshParams,{shaping:s}=this._current,o=B(e.readLegacyGeometryForDisplay().paths,s.bounds.width);for(let n=0;n<o.length;n++)this._current.pathIndex=n,S(o[n],i,t,!!r)}_placeSubdivGlyphs(e,t,i,r){const{allowOverrun:s,labelPosition:o,repeatLabelDistance:n,layerId:a,labelClassId:l}=this.evaluatedMeshParams,{objId:c,shaping:h,pathIndex:m}=this._current,u=this._current.zoomRange[0],d=Y(t),f=this._current.shaping.bounds.width/(1<<A),g=Math.sqrt(n||R)/(1<<A),p=Math.min(i,r-i),_=h.isMultiline?D:Math.log2(p/(g+f/2)),y=0===t?_:Math.min(d,_),x=Math.max(u,this._zoomLevel+A-y),P=this._zoomLevel-x,v=h.bounds.width/2*2**P,b=O(a,c,m,t,this._zoomLevel),M=X(c,m,t,this._zoomLevel,l);this._current.shaping.isMultiline?0===t&&this._placeStraight(e,x,b,M):s&&P<0?this._placeStraightAlong(e,u,b,M):"parallel"===o?this._placeStraightAlong(e,x,b,M):"curved"===o&&this._placeCurved(e,x,v,b,M)}_placeStraight(e,t,i,r){const{out:s,id:o,shaping:n,referenceBounds:a}=this._current,{x:l,y:c}=e;s.metricStart(this._createLineLabelMetric(o,i,r,l,c)),s.metricBoxWrite(n.boundsT);const h=e.angle*(180/Math.PI)%360,m=(e.angle*(180/Math.PI)+180)%360;if(!this._verticalPlacement||this._verticalPlacement===this._current.offsetDirection){const e={clipAngle:h,mapAligned:!0,isLineLabel:!0,minZoom:t};this._writeGlyphs(s,o,l,c,n,0,a,e,!1)}if(!this._verticalPlacement||this._verticalPlacement!==this._current.offsetDirection){const e={clipAngle:m,mapAligned:!0,isLineLabel:!0,minZoom:t};this._writeGlyphs(s,o,l,c,n,0,a,e,!1)}s.metricEnd()}_placeCurved(e,t,i,r,s){const{out:o,id:n}=this._current;o.metricStart(this._createLineLabelMetric(n,r,s,e.x,e.y));const a=e.clone(),l=e.angle*(180/Math.PI)%360,c=(e.angle*(180/Math.PI)+180)%360;this._verticalPlacement&&this._verticalPlacement!==this._current.offsetDirection||(this._placeFirst(a,t,1,l),this._placeBack(e,a,t,i,1,l),this._placeForward(e,a,t,i,1,l)),this._verticalPlacement&&this._verticalPlacement===this._current.offsetDirection||(this._placeFirst(a,t,0,c),this._placeBack(e,a,t,i,0,c),this._placeForward(e,a,t,i,0,c)),o.metricEnd()}_placeStraightAlong(e,i,n,a){const{out:l,id:c,shaping:h,zoomRange:m,referenceBounds:d}=this._current,{boxBorderLineColor:f,boxBackgroundColor:g}=this.evaluatedMeshParams,p=e.clone(),_=e.angle*(180/Math.PI)%360,y=(e.angle*(180/Math.PI)+180)%360,x=h.glyphs.length>0&&!(!f&&!g);if(l.metricStart(this._createLineLabelMetric(c,n,a,e.x,e.y)),x){const n=Math.max(i,m[0],0),a=Math.min(D,m[1]),f=r(o(),-e.angle),g={minZoom:n,maxZoom:a,clipAngle:_,mapAligned:!0,isLineLabel:!0},p=t(this.evaluatedMeshParams.offsetX),x=t(this.evaluatedMeshParams.offsetY);if(!this._verticalPlacement||this._verticalPlacement===this._current.offsetDirection){const t=u(p,-1*x),[i,r]=h.shapeBackground(s(o(),f,t));l.recordStart(this.instanceId,this.attributeLayout,h.glyphs[0].textureBinding),this._writeTextBox(l,c,e.x,e.y,r,d,g),l.recordEnd()}if(!this._verticalPlacement||this._verticalPlacement!==this._current.offsetDirection){const t=u(p,x),[i,r]=h.shapeBackground(s(o(),f,t));g.clipAngle=y,l.recordStart(this.instanceId,this.attributeLayout,h.glyphs[0].textureBinding),this._writeTextBox(l,c,e.x,e.y,r,d,g),l.recordEnd()}}this._verticalPlacement&&this._verticalPlacement!==this._current.offsetDirection||this._placeFirst(p,i,1,_,!0),this._verticalPlacement&&this._verticalPlacement===this._current.offsetDirection||this._placeFirst(p,i,0,y,!0),l.metricEnd()}_placeBack(e,t,i,r,s,o){const n=e.clone();let a=e.backwardLength+F;for(;n.prev()&&!(a>=r);)this._placeOnSegment(n,t,a,i,-1,s,o),a+=n.length+F}_placeForward(e,t,i,r,s,o){const n=e.clone();let a=e.remainingLength+F;for(;n.next()&&!(a>=r);)this._placeOnSegment(n,t,a,i,1,s,o),a+=n.length+F}_placeFirst(e,t,i,r,s=!1){const{out:o,id:n,shaping:a,zoomRange:l,referenceBounds:c}=this._current,h=a.glyphs,m=this._getBoundsOffset(e.angle);for(const u of h){const h=u.x>a.bounds.x?i:1-i,d=h*e.remainingLength+(1-h)*e.backwardLength,f=Math.abs(u.x+u.width/2-a.bounds.x),g=Math.max(0,this._zoomLevel+Math.log2(f/(d+F))),p=Math.max(t,s?0:g);u.angle=e.angle+(1-i)*Math.PI;const _=[Math.max(l[0],p),Math.min(l[1],D)];this._writeLineGlyph(o,n,e.x,e.y,u,_,r,c),this._writeLineGlyphBox(o,u,i,_,m)}}_placeOnSegment(e,t,i,r,s,o,n){const{out:a,id:l,shaping:c,referenceBounds:h}=this._current,m=c.glyphs,u=e.dx/e.length,d=e.dy/e.length,f={x:e.x+i*-s*u,y:e.y+i*-s*d},g=this._getBoundsOffset(e.angle);for(const p of m){const t=p.x>c.bounds.x?o:1-o;if(!(t&&1===s||!t&&-1===s))continue;const m=Math.abs(p.x+p.width/2-c.bounds.x),u=Math.max(0,this._zoomLevel+Math.log2(m/i)-.1),d=Math.max(r,this._zoomLevel+Math.log2(m/(i+e.length+F)));if(0===u)continue;p.angle=e.angle+(1-o)*Math.PI;const _=[d,u];this._writeLineGlyph(a,l,f.x,f.y,p,_,n,h),this._writeLineGlyphBox(a,p,o,_,g)}}_getBoundsOffset(e){const i=t(this.evaluatedMeshParams.offsetX),s=t(this.evaluatedMeshParams.offsetY),a=u(i,s),l=r(o(),-e);return n(a,a,l)}_writeLineGlyph(e,t,i,r,s,o,n,a){if(i<0||i>w||r<0||r>w)return;e.recordStart(this.instanceId,this.attributeLayout,s.textureBinding);const{texcoords:l,offsets:c}=s,{fontSize:h,haloSize:m,outlineSize:u}=this._textMeshTransformProps,{sdfSize:d,sdfRadius:f}=this.evaluatedMeshParams.glyphs;this._writeQuad(e,t,i,r,{sdfSize:d,sdfRadius:f,texcoords:l,offsets:c,fontSize:h,haloSize:m,outlineSize:u,color:G(this.evaluatedMeshParams.color),isBackground:!1,referenceBounds:a,minZoom:Math.max(this._current.zoomRange[0],o[0]),maxZoom:Math.min(this._current.zoomRange[1],o[1]),clipAngle:n,mapAligned:!0,isLineLabel:!0}),e.recordEnd()}_writeLineGlyphBox(e,t,i,r,s){if((i||this._current.offsetDirection)&&this._isVisible(r)&&t.bounds){const i=t.bounds,r=new L(i.x+s[0],i.y+s[1],i.width,i.height);e.metricBoxWrite(r)}}_isVisible(e){const t=Math.max(this._current.zoomRange[0],e[0]),i=Math.min(this._current.zoomRange[1],e[1]),r=this._zoomLevel;return t<=r&&r<=i}}function Z(e,t){const i=new b,{coords:r,lengths:s}=e,o=d(),n=d(),u=d(),f=d(),g=d(),p=d(),_=2;let y=0;for(let d=0;d<s.length;d++){const e=s[d];for(let s=0;s<e;s++){const d=_*(s+y-1),x=_*(s+y),P=_*(s+y+1);s>0?a(o,r[d],r[d+1]):a(o,0,0),a(n,r[x],r[x+1]),s<e-1?a(u,r[P],r[P+1]):a(u,0,0),0===s?a(f,0,0):(l(f,n,o),c(f,f),a(f,f[1],-f[0])),s===e-1?a(g,0,0):(l(g,u,n),c(g,g),a(g,g[1],-g[0])),h(p,f,g),c(p,p);const v=p[0]*g[0]+p[1]*g[1];0!==v&&m(p,p,v),m(p,p,t),i.coords.push(n[0]+p[0],n[1]+p[1])}i.lengths.push(e),y+=e}return i}export{W as LabelMeshWriter,E as labelIdHash,T as labelMetricHash,O as lineLabelIdHash,X as lineLabelMetricHash};
|
|
2
|
+
import{memoize as e}from"../../../../../../../core/MapUtils.js";import{pt2px as t}from"../../../../../../../core/screenUtils.js";import{numericHash as i}from"../../../../../../../core/string.js";import{fromRotation as r,translate as s}from"../../../../../../../core/libs/gl-matrix-2/math/mat2d.js";import{create as o}from"../../../../../../../core/libs/gl-matrix-2/factories/mat2df32.js";import{transformMat2d as n,set as a,sub as l,normalize as c,add as h,scale as m}from"../../../../../../../core/libs/gl-matrix-2/math/vec2.js";import{fromValues as u}from"../../../../../../../core/libs/gl-matrix-2/factories/vec2f32.js";import{create as d}from"../../../../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{convertGeometryToFlat as f,convertOptimizedGeometryToFlat as g,convertFlatToOptimizedGeometry as p,FlatGeometry as _}from"../../../../../../../geometry/FlatGeometry.js";import{GeometryCursor as y}from"../../../../../../../geometry/GeometryCursor.js";import{getLabelPoint as x}from"../../../../../../../geometry/support/labelPoint.js";import{generalizeOptimizedGeometry as P,convertToGeometry as v}from"../../../../../../../layers/graphics/featureConversionUtils.js";import b from"../../../../../../../layers/graphics/OptimizedGeometry.js";import{importLazily as M}from"../../../../../../../symbols/cim/utils.js";import{tileSize as w}from"../../../definitions.js";import L from"../../../collisions/BoundingBox.js";import{LabelMetric as I}from"../../../collisions/LabelMetric.js";import{smoothPaths as B,pathDivide as S}from"../../../mesh/templates/segmentUtils.js";import{getMinMaxZoom as z,processColorInput as G}from"../fill/meshWriterUtils.js";import{TextMeshWriter as j,maxLabelZoom as D}from"../text/TextMeshWriter.js";const A=1,F=0,R=128,$=w*w/16,k=M(()=>import("../../../../../../../geometry/operators/gx/operatorIntersection.js")),C=M(()=>import("../../../../../../../chunks/FlatGeometry.js"));function E(e,t,r){return i(`${e}${t}${r}`)}function O(e,t,r,s,o){return i(`${e}${t}${r}${s*2**(D-o)}`)}function T(e,t,r){return i(`${e}${t}${r}`)}function X(e,t,r,s,o){return i(`${e}${o}${t}${r*2**(D-s)}`)}const Y=e(e=>{let t=0;if(0===e)return 1/0;for(;!(e%2);)t++,e/=2;return t});class W extends j{constructor(){super(...arguments),this._zoomLevel=0}async loadDependencies(){await Promise.all([super.loadDependencies(),k.getImportPromise(),C.getImportPromise()])}_write(e,{target:t,effectGeometry:i,level:r,viewExtent:s}){if(this._zoomLevel=r,null!=i)throw new Error("InternalError: EffectGeometry not support for LabelMeshWriter");switch(t.geometryType){case"esriGeometryPoint":{const i=t.readXForDisplay(),r=t.readYForDisplay();this._writePoint(e,i,r,0,t);break}case"esriGeometryEnvelope":case"esriGeometryPolygon":this._writePolygon(e,t,s);break;case"esriGeometryMultipoint":{let i=0;const r=y.fromFeatureSetReader(t);if(r?.nextPath())for(;r.nextPoint();)this._writePoint(e,r.x,r.y,i++,t);break}case"esriGeometryPolyline":this._writeLines(e,t)}}_getMetricDir(){const{horizontalAlignment:e,verticalAlignment:t}=this.evaluatedMeshParams;return["center"===e?0:"right"===e?-1:1,"middle"===t?0:"bottom"===t?-1:1]}_createLineLabelMetric(e,t,i,r,s,o){const[n,a]=this._getMetricDir(),l=this.evaluatedMeshParams.scaleInfo?.maxScale??0,c=this.evaluatedMeshParams.scaleInfo?.minScale??0,h=this.evaluatedMeshParams.labelClassId;return new I(e,h,t,i,r,s,n,a,l,c,o)}_writePolygon(e,t,i){const r=k.module,s=C.module.constructFromFlatGeometry,o=t.readGeometryForDisplay()?.justXY(),n=t.readCentroidForDisplay()?.coords,a=o?.area()||0;if(!n)return;const l=a>=$;e.requiresRefresh||=l;const c=s(f(i)),h=s(f({x:n[0],y:n[1]})),m=!!r.execute(h,c,null);if(!o||!l||!m)return void this._writePoint(e,n[0],n[1],0,t);const u=s(g("polygon",o,null)),d=r.execute(u,c,null);if(!d)return void this._writePoint(e,n[0],n[1],0,t);const P=p(new _(d.toFlatGeometry())),v=y.fromOptimized(P,"esriGeometryPolygon",1),b=x(v)??n;this._writePoint(e,b[0],b[1],0,t)}_writePoint(e,t,i,r,s){if(t<0||t>w||i<0||i>w)return;const o=this._getShaping();if(!o)return;const n=s.getDisplayId(),a=this.evaluatedMeshParams.labelClassId,l=E(this.evaluatedMeshParams.layerId,s.getObjectId(),r),c=T(s.getObjectId(),a,r),[h,m]=this._getMetricDir(),u=this.evaluatedMeshParams.scaleInfo?.maxScale??0,d=this.evaluatedMeshParams.scaleInfo?.minScale??0,f=this._getPointReferenceBounds()||{offsetX:0,offsetY:0,size:0};e.metricStart(new I(n,a,l,c,t,i,h,m,u,d,f)),this._writeGlyphs(e,n,t,i,o,0,f,void 0,!1),e.metricBoxWrite(o.boundsT),e.metricEnd()}_getPointReferenceBounds(){if(!this._references)return null;for(const e of this._references){const t=e.getBoundsInfo();if(t)return t}return null}_writeLines(e,t){const{scaleInfo:i,verticalAlignment:r}=this.evaluatedMeshParams,s=this.evaluatedMeshParams.repeatLabelDistance||128,o=this._getShaping("middle");if(!o)return;const n=(e,t,i,r)=>this._placeSubdivGlyphs(e,t,i,r),a=(o.bounds.width+s)/(1<<A);this._current={out:e,id:t.getDisplayId(),objId:t.getObjectId(),shaping:o,zoomRange:z(i,this.getTileInfo()),referenceBounds:this._getPointReferenceBounds()||{offsetX:0,offsetY:0,size:0},offsetDirection:null,pathIndex:0},this._verticalPlacement="bottom"===r?"above":"top"===r?"below":null,this._verticalPlacement?this._writeAboveAndBelowAlong(t,n,a):this._writeCenterAlong(t,n,a)}_writeAboveAndBelowAlong(e,t,i){const{repeatLabel:r}=this.evaluatedMeshParams,{shaping:s}=this._current,o=s.bounds.halfHeight,n=e.readGeometryForDisplay()?.justXY();if(!n)return;const a=P(n,"esriGeometryPolyline",1)??new b,l=Z(a,o),c=Z(a,-o),h=v(c,"esriGeometryPolyline",!1,!1),m=v(l,"esriGeometryPolyline",!1,!1),u=B(m.paths,s.bounds.width),d=B(h.paths,s.bounds.width);this._current.offsetDirection="above";for(let f=0;f<u.length;f++)this._current.pathIndex=f,S(u[f],i,t,!!r);this._current.offsetDirection="below";for(let f=0;f<d.length;f++)this._current.pathIndex=f,S(d[f],i,t,!!r)}_writeCenterAlong(e,t,i){const{repeatLabel:r}=this.evaluatedMeshParams,{shaping:s}=this._current,o=B(e.readLegacyGeometryForDisplay().paths,s.bounds.width);for(let n=0;n<o.length;n++)this._current.pathIndex=n,S(o[n],i,t,!!r)}_placeSubdivGlyphs(e,t,i,r){const{allowOverrun:s,labelPosition:o,repeatLabelDistance:n,layerId:a,labelClassId:l}=this.evaluatedMeshParams,{objId:c,shaping:h,pathIndex:m}=this._current,u=this._current.zoomRange[0],d=Y(t),f=this._current.shaping.bounds.width/(1<<A),g=Math.sqrt(n||R)/(1<<A),p=Math.min(i,r-i),_=h.isMultiline?D:Math.log2(p/(g+f/2)),y=0===t?_:Math.min(d,_),x=Math.max(u,this._zoomLevel+A-y),P=this._zoomLevel-x,v=h.bounds.width/2*2**P,b=O(a,c,m,t,this._zoomLevel),M=X(c,m,t,this._zoomLevel,l);this._current.shaping.isMultiline?0===t&&this._placeStraight(e,x,b,M):s&&P<0?this._placeStraightAlong(e,u,b,M):"parallel"===o?this._placeStraightAlong(e,x,b,M):"curved"===o&&this._placeCurved(e,x,v,b,M)}_placeStraight(e,t,i,r){const{out:s,id:o,shaping:n,referenceBounds:a}=this._current,{x:l,y:c}=e;s.metricStart(this._createLineLabelMetric(o,i,r,l,c)),s.metricBoxWrite(n.boundsT);const h=e.angle*(180/Math.PI)%360,m=(e.angle*(180/Math.PI)+180)%360;if(!this._verticalPlacement||this._verticalPlacement===this._current.offsetDirection){const e={clipAngle:h,mapAligned:!0,isLineLabel:!0,minZoom:t};this._writeGlyphs(s,o,l,c,n,0,a,e,!1)}if(!this._verticalPlacement||this._verticalPlacement!==this._current.offsetDirection){const e={clipAngle:m,mapAligned:!0,isLineLabel:!0,minZoom:t};this._writeGlyphs(s,o,l,c,n,0,a,e,!1)}s.metricEnd()}_placeCurved(e,t,i,r,s){const{out:o,id:n}=this._current;o.metricStart(this._createLineLabelMetric(n,r,s,e.x,e.y));const a=e.clone(),l=e.angle*(180/Math.PI)%360,c=(e.angle*(180/Math.PI)+180)%360;this._verticalPlacement&&this._verticalPlacement!==this._current.offsetDirection||(this._placeFirst(a,t,1,l),this._placeBack(e,a,t,i,1,l),this._placeForward(e,a,t,i,1,l)),this._verticalPlacement&&this._verticalPlacement===this._current.offsetDirection||(this._placeFirst(a,t,0,c),this._placeBack(e,a,t,i,0,c),this._placeForward(e,a,t,i,0,c)),o.metricEnd()}_placeStraightAlong(e,i,n,a){const{out:l,id:c,shaping:h,zoomRange:m,referenceBounds:d}=this._current,{boxBorderLineColor:f,boxBackgroundColor:g}=this.evaluatedMeshParams,p=e.clone(),_=e.angle*(180/Math.PI)%360,y=(e.angle*(180/Math.PI)+180)%360,x=h.glyphs.length>0&&!(!f&&!g);if(l.metricStart(this._createLineLabelMetric(c,n,a,e.x,e.y)),x){const n=Math.max(i,m[0],0),a=Math.min(D,m[1]),f=r(o(),-e.angle),g={minZoom:n,maxZoom:a,clipAngle:_,mapAligned:!0,isLineLabel:!0},p=t(this.evaluatedMeshParams.offsetX),x=t(this.evaluatedMeshParams.offsetY);if(!this._verticalPlacement||this._verticalPlacement===this._current.offsetDirection){const t=u(p,-1*x),[i,r]=h.shapeBackground(s(o(),f,t));l.recordStart(this.instanceId,this.attributeLayout,h.glyphs[0].textureBinding),this._writeTextBox(l,c,e.x,e.y,r,d,g),l.recordEnd()}if(!this._verticalPlacement||this._verticalPlacement!==this._current.offsetDirection){const t=u(p,x),[i,r]=h.shapeBackground(s(o(),f,t));g.clipAngle=y,l.recordStart(this.instanceId,this.attributeLayout,h.glyphs[0].textureBinding),this._writeTextBox(l,c,e.x,e.y,r,d,g),l.recordEnd()}}this._verticalPlacement&&this._verticalPlacement!==this._current.offsetDirection||this._placeFirst(p,i,1,_,!0),this._verticalPlacement&&this._verticalPlacement===this._current.offsetDirection||this._placeFirst(p,i,0,y,!0),l.metricEnd()}_placeBack(e,t,i,r,s,o){const n=e.clone();let a=e.backwardLength+F;for(;n.prev()&&!(a>=r);)this._placeOnSegment(n,t,a,i,-1,s,o),a+=n.length+F}_placeForward(e,t,i,r,s,o){const n=e.clone();let a=e.remainingLength+F;for(;n.next()&&!(a>=r);)this._placeOnSegment(n,t,a,i,1,s,o),a+=n.length+F}_placeFirst(e,t,i,r,s=!1){const{out:o,id:n,shaping:a,zoomRange:l,referenceBounds:c}=this._current,h=a.glyphs,m=this._getBoundsOffset(e.angle);for(const u of h){const h=u.x>a.bounds.x?i:1-i,d=h*e.remainingLength+(1-h)*e.backwardLength,f=Math.abs(u.x+u.width/2-a.bounds.x),g=Math.max(0,this._zoomLevel+Math.log2(f/(d+F))),p=Math.max(t,s?0:g);u.angle=e.angle+(1-i)*Math.PI;const _=[Math.max(l[0],p),Math.min(l[1],D)];this._writeLineGlyph(o,n,e.x,e.y,u,_,r,c),this._writeLineGlyphBox(o,u,i,_,m)}}_placeOnSegment(e,t,i,r,s,o,n){const{out:a,id:l,shaping:c,referenceBounds:h}=this._current,m=c.glyphs,u=e.dx/e.length,d=e.dy/e.length,f={x:e.x+i*-s*u,y:e.y+i*-s*d},g=this._getBoundsOffset(e.angle);for(const p of m){const t=p.x>c.bounds.x?o:1-o;if(!(t&&1===s||!t&&-1===s))continue;const m=Math.abs(p.x+p.width/2-c.bounds.x),u=Math.max(0,this._zoomLevel+Math.log2(m/i)-.1),d=Math.max(r,this._zoomLevel+Math.log2(m/(i+e.length+F)));if(0===u)continue;p.angle=e.angle+(1-o)*Math.PI;const _=[d,u];this._writeLineGlyph(a,l,f.x,f.y,p,_,n,h),this._writeLineGlyphBox(a,p,o,_,g)}}_getBoundsOffset(e){const i=t(this.evaluatedMeshParams.offsetX),s=t(this.evaluatedMeshParams.offsetY),a=u(i,s),l=r(o(),-e);return n(a,a,l)}_writeLineGlyph(e,t,i,r,s,o,n,a){if(i<0||i>w||r<0||r>w)return;e.recordStart(this.instanceId,this.attributeLayout,s.textureBinding);const{texcoords:l,offsets:c}=s,{fontSize:h,haloSize:m,outlineSize:u}=this._textMeshTransformProps,d=this._getDefaultGlyphMetrics(this.evaluatedMeshParams.glyphs),f=s.fontSize??h;this._writeQuad(e,t,i,r,{sdfSize:d.sdfSize,sdfRadius:d.sdfRadius,texcoords:l,offsets:c,fontSize:f,haloSize:m,outlineSize:u,color:s.color?G(s.color):G(this.evaluatedMeshParams.color),isBackground:!1,referenceBounds:a,minZoom:Math.max(this._current.zoomRange[0],o[0]),maxZoom:Math.min(this._current.zoomRange[1],o[1]),clipAngle:n,mapAligned:!0,isLineLabel:!0}),e.recordEnd()}_writeLineGlyphBox(e,t,i,r,s){if((i||this._current.offsetDirection)&&this._isVisible(r)&&t.bounds){const i=t.bounds,r=new L(i.x+s[0],i.y+s[1],i.width,i.height);e.metricBoxWrite(r)}}_isVisible(e){const t=Math.max(this._current.zoomRange[0],e[0]),i=Math.min(this._current.zoomRange[1],e[1]),r=this._zoomLevel;return t<=r&&r<=i}}function Z(e,t){const i=new b,{coords:r,lengths:s}=e,o=d(),n=d(),u=d(),f=d(),g=d(),p=d(),_=2;let y=0;for(let d=0;d<s.length;d++){const e=s[d];for(let s=0;s<e;s++){const d=_*(s+y-1),x=_*(s+y),P=_*(s+y+1);s>0?a(o,r[d],r[d+1]):a(o,0,0),a(n,r[x],r[x+1]),s<e-1?a(u,r[P],r[P+1]):a(u,0,0),0===s?a(f,0,0):(l(f,n,o),c(f,f),a(f,f[1],-f[0])),s===e-1?a(g,0,0):(l(g,u,n),c(g,g),a(g,g[1],-g[0])),h(p,f,g),c(p,p);const v=p[0]*g[0]+p[1]*g[1];0!==v&&m(p,p,v),m(p,p,t),i.coords.push(n[0]+p[0],n[1]+p[1])}i.lengths.push(e),y+=e}return i}export{W as LabelMeshWriter,E as labelIdHash,T as labelMetricHash,O as lineLabelIdHash,X as lineLabelMetricHash};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
import{clamp as t}from"../../../../../../../core/mathUtils.js";import{pt2px as e}from"../../../../../../../core/screenUtils.js";import{GeometryCursor as o}from"../../../../../../../geometry/GeometryCursor.js";import{asCIMGeometryCursor as i}from"../../../../../../../symbols/cim/utils.js";import{CIMMarkerPlacementHelper as r}from"../../../../../../../symbols/cim/placements/CIMMarkerPlacementHelper.js";import{getXDirection as s,getYDirection as n}from"../../../alignmentUtils.js";import{labelU16ZoomPrecisionFactor as a,maxTextLineWidth as l,minTextLineWidth as c,magicLabelLineHeight as d,packDegreesU8 as h}from"../../../definitions.js";import{shapeGlyphs as f,shapeGlyphsForMultipoint as u}from"../../../mesh/templates/shapingUtils.js";import{getMinMaxZoom as p,processColorInput as m,packBitset as g}from"../fill/meshWriterUtils.js";import{MeshWriter as x}from"../mesh/MeshWriter.js";import{bitsetTextIsBackground as y,bitsetTextIsMapAligned as S}from"../shaders/constants.js";import{TextMeshTransformProps as z}from"./TextParams.js";import{DataType as b}from"../../../../../../webgl/enums.js";const _=28,P=[4,4],M=[16,4],R={topLeft:M,topRight:M,bottomLeft:M,bottomRight:M},B=[4,2],L=[4,6],T={topLeft:B,topRight:B,bottomLeft:L,bottomRight:L},k={topLeft:B,topRight:L,bottomLeft:B,bottomRight:L},v={topLeft:L,topRight:L,bottomLeft:P,bottomRight:P},A={topLeft:P,topRight:P,bottomLeft:L,bottomRight:L},w={topLeft:L,topRight:P,bottomLeft:L,bottomRight:P},I={topLeft:P,topRight:L,bottomLeft:P,bottomRight:L};function C(t){return{backgroundColor:t.boxBackgroundColor??t.backgroundColor??null,borderLineColor:t.boxBorderLineColor??t.borderLineColor??null,borderLineSize:t.boxBorderLineSize>0?t.boxBorderLineSize:t.borderLineWidth??0}}const G={createComputedParams:t=>t,optionalAttributes:{zoomRange:{type:b.UNSIGNED_SHORT,count:2,packPrecisionFactor:a,packTessellation:({minZoom:t,maxZoom:e})=>[t||0,e||_]},clipAngle:{type:b.UNSIGNED_BYTE,count:1,packTessellation:({clipAngle:t})=>N(t||0)},referenceSymbol:{type:b.BYTE,count:4,packTessellation:(t,o)=>{const i=t.isLineLabel||!t.referenceBounds,r=s(i?"center":o.horizontalAlignment),a=n(i?"middle":o.verticalAlignment),{offsetX:l,offsetY:c,size:d}=i?{offsetX:0,offsetY:0,size:0}:t.referenceBounds;return[e(l),-e(c),Math.round(e(d)),r+1<<2|a+1]}},visibility:{type:b.FLOAT,count:1,otherSource:!0}},attributes:{pos:{type:b.SHORT,count:2,pack:"position",packPrecisionFactor:10},id:{type:b.UNSIGNED_BYTE,count:3,pack:"id"},bitset:{type:b.UNSIGNED_BYTE,count:1,packTessellation:({isBackground:t,mapAligned:e})=>g([[y,t],[S,!!e]])},offset:{type:b.SHORT,count:2,packPrecisionFactor:8,packAlternating:{count:4,packTessellation:({offsets:t})=>{const{bottomLeft:e,bottomRight:o,topLeft:i,topRight:r}=t;return[i,r,e,o]}}},textureUV:{type:b.UNSIGNED_SHORT,count:2,packAlternating:{count:4,packTessellation:({texcoords:t})=>{const{bottomLeft:e,bottomRight:o,topLeft:i,topRight:r}=t;return[i,r,e,o]}}},color:{type:b.UNSIGNED_BYTE,count:4,normalized:!0,packTessellation:({color:t})=>t},fontAndReferenceSize:{type:b.UNSIGNED_SHORT,count:4,packPrecisionFactor:4,packTessellation:({fontSize:t,sdfSize:o,sdfRadius:i},{referenceSize:r})=>[Math.round(e(t)),Math.round(e(r||t)),o,i]},outlineColor:{type:b.UNSIGNED_BYTE,count:4,normalized:!0,pack:({outlineColor:t})=>m(t)},haloColor:{type:b.UNSIGNED_BYTE,count:4,normalized:!0,pack:({haloColor:t})=>m(t)},outlineAndHaloSize:{type:b.UNSIGNED_SHORT,count:2,packPrecisionFactor:4,packTessellation:({outlineSize:t,haloSize:o})=>[Math.round(e(t)),Math.round(e(o))]}}};class E extends x{constructor(){super(...arguments),this.vertexSpec=G,this._textMeshParamsPropsInitialized=!1}ensurePacked(t,e,o){super.ensurePacked(t,e,o),this._textMeshParamsPropsInitialized&&!this._evaluator.hasDynamicProperties||(this._textMeshTransformProps=new z(this.evaluatedMeshParams),this._textMeshParamsPropsInitialized=!0)}_write(t,{target:e,effectGeometry:o}){const r=this._getShaping();if(!r)return;const s=1===this.evaluatedMeshParams.alignment,n=e.getDisplayId(),{placement:a}=this.evaluatedMeshParams;if(null!=a){if("PrivatePlacementMultipoint"!==a.type)this._writePlacedTextMarkers(t,e,r,i(o));else{const r=this._getMultipointShaping();r&&this._writeMultipointText(t,e,r,i(o))}return}if(o?.nextPath())return o.nextPoint(),this._writeGlyphs(t,n,o.x,o.y,r,0,void 0,{mapAligned:s});if("esriGeometryPolygon"===e.geometryType){const o=e.readCentroidForDisplay();if(!o)return;const[i,a]=o.coords;return this._writeGlyphs(t,n,i,a,r,0,void 0,{mapAligned:s})}if("esriGeometryMultipoint"===e.geometryType){const o=e.readGeometryForDisplay();return void o?.forEachVertex((e,o)=>this._writeGlyphs(t,n,e,o,r,0,void 0,{mapAligned:s}))}const l=e.readXForDisplay(),c=e.readYForDisplay();return this._writeGlyphs(t,n,l,c,r,0,void 0,{mapAligned:s})}_writePlacedTextMarkers(t,i,s,n){const a=n??o.fromFeatureSetReaderCIM(i);if(!a)return;const l=-1,c=r.getPlacement(a,l,this.evaluatedMeshParams.placement,e(1),t.id);if(!c)return;const d=i.getDisplayId();let h=c.next();for(;null!=h;){const e=-h.getAngle(),o=h.tx,i=-h.ty;this._writeGlyphs(t,d,o,i,s,e,void 0,{mapAligned:1===this.evaluatedMeshParams.alignment}),h=c.next()}}_writeMultipointText(t,i,s,n){const a=n??o.fromFeatureSetReaderCIM(i);if(!a)return;const l=-1,c=r.getPlacement(a,l,this.evaluatedMeshParams.placement,e(1),t.id);if(!c)return;const d=i.getDisplayId();let h=c.next(),f=0;for(;null!=h;){const e=h.tx,o=-h.ty,i=-h.getAngle();if(f>=s.glyphs.length)break;this._writeGlyph(t,d,e,o,s,f,i,void 0,{mapAligned:1===this.evaluatedMeshParams.alignment}),h=c.next(),f++}}_getShaping(o){const i=this._textMeshTransformProps,r=this.evaluatedMeshParams;if(!r.glyphs?.glyphs.length)return null;const s=e(i.fontSize),n=e(i.offsetX),a=e(i.offsetY),h=r.glyphs.sdfSize,u=t(e(r.lineWidth),c,l),p=h/24*d*t(r.lineHeightRatio,.25,4),{backgroundColor:m,borderLineSize:g}=C(r);return f(r.glyphs,{scale:s/h,angle:i.postAngle,xOffset:n,yOffset:a,horizontalAlignment:r.horizontalAlignment,verticalAlignment:o||r.verticalAlignment,maxLineWidth:u,lineHeight:p,decoration:r.decoration,borderLineSizePx:e(g),hasBackground:!!m,useCIMAngleBehavior:r.useCIMAngleBehavior})}_getMultipointShaping(){const o=this._textMeshTransformProps,i=this.evaluatedMeshParams;if(!i.glyphs?.glyphs.length)return null;const r=e(o.fontSize),s=e(o.offsetX),n=e(o.offsetY),a=i.glyphs.sdfSize,h=t(e(i.lineWidth),c,l),f=a/24*d*t(i.lineHeightRatio,.25,4),{backgroundColor:p,borderLineSize:m}=C(i);return u(i.glyphs,{scale:r/a,angle:o.postAngle,xOffset:s,yOffset:n,horizontalAlignment:i.horizontalAlignment,verticalAlignment:i.verticalAlignment,maxLineWidth:h,lineHeight:f,decoration:i.decoration,borderLineSizePx:e(m),hasBackground:!!p,useCIMAngleBehavior:i.useCIMAngleBehavior})}_writeGlyphs(t,o,i,r,s,n,a,l,c=!0){const d=this.evaluatedMeshParams,h=this._textMeshTransformProps,f=e(h.fontSize),u=h.haloSize,g=h.outlineSize,x=e(h.offsetX),y=e(h.offsetY),{sdfSize:S,sdfRadius:z}=d.glyphs,[b,_]=p(d.scaleInfo,this.getTileInfo());0!==n&&s.setRotation(n);const P=s.bounds,M=i+P.x+x,R=r+P.y-y,B=2*(d.minPixelBuffer?d.minPixelBuffer/f:1),L=Math.max(P.width,P.height)*B;s.textBox&&(t.recordStart(this.instanceId,this.attributeLayout,s.glyphs[0].textureBinding),c&&t.recordBounds(M,R,L,L),this._writeTextBox(t,o,i,r,s.textBox,a,l),t.recordEnd());for(const e of s.glyphs){t.recordStart(this.instanceId,this.attributeLayout,e.textureBinding),c&&t.recordBounds(M,R,L,L);const{texcoords:s,offsets:n}=e;this._writeQuad(t,o,i,r,{texcoords:s,offsets:n,fontSize:f,haloSize:u,outlineSize:g,sdfSize:S,sdfRadius:z,color:m(d.color),isBackground:!1,referenceBounds:a,minZoom:b,maxZoom:_,...l}),t.recordEnd()}0!==n&&s.setRotation(-n)}_writeGlyph(t,o,i,r,s,n,a,l,c,d=!0){const h=this.evaluatedMeshParams,f=this._textMeshTransformProps,u=e(f.fontSize),p=f.haloSize,g=f.outlineSize,x=e(f.offsetX),y=e(f.offsetY),{sdfSize:S,sdfRadius:z}=h.glyphs;0!==a&&s.setRotation(a);const b=s.bounds,_=i+b.x+x,P=r+b.y-y,M=2*(h.minPixelBuffer?h.minPixelBuffer/u:1),R=Math.max(b.width,b.height)*M,B=s.glyphs[n];t.recordStart(this.instanceId,this.attributeLayout,B.textureBinding),d&&t.recordBounds(_,P,R,R);const{texcoords:L,offsets:T}=B;this._writeQuad(t,o,i,r,{texcoords:L,offsets:T,fontSize:u,haloSize:p,outlineSize:g,sdfSize:S,sdfRadius:z,color:m(h.color),isBackground:!1,referenceBounds:l,minZoom:0,maxZoom:30,...c}),t.recordEnd(),0!==a&&s.setRotation(-a)}_writeTextBox(t,e,o,i,r,s,n){const a=this.evaluatedMeshParams,{fontSize:l,haloSize:c,outlineSize:d}=this._textMeshTransformProps,{backgroundColor:h,borderLineColor:f,borderLineSize:u}=C(a),{sdfSize:p,sdfRadius:g}=a.glyphs,x=!!f&&u>0,y={isBackground:!0,fontSize:l,haloSize:c,outlineSize:d,referenceBounds:s,sdfSize:p,sdfRadius:g,...n};h&&(this._writeQuad(t,e,o,i,{texcoords:R,offsets:r.main,color:m(h),...y}),x||(this._writeQuad(t,e,o,i,{texcoords:v,offsets:r.top,color:m(h),...y}),this._writeQuad(t,e,o,i,{texcoords:A,offsets:r.bot,color:m(h),...y}),this._writeQuad(t,e,o,i,{texcoords:w,offsets:r.left,color:m(h),...y}),this._writeQuad(t,e,o,i,{texcoords:I,offsets:r.right,color:m(h),...y}))),x&&(this._writeQuad(t,e,o,i,{texcoords:T,offsets:r.top,color:m(f),...y}),this._writeQuad(t,e,o,i,{texcoords:T,offsets:r.bot,color:m(f),...y}),this._writeQuad(t,e,o,i,{texcoords:k,offsets:r.left,color:m(f),...y}),this._writeQuad(t,e,o,i,{texcoords:k,offsets:r.right,color:m(f),...y}))}_writeQuad(t,e,o,i,r){const s=t.vertexCount();this._writeVertex(t,e,o,i,r),t.indexWrite(s+0),t.indexWrite(s+1),t.indexWrite(s+2),t.indexWrite(s+1),t.indexWrite(s+3),t.indexWrite(s+2)}}const N=t=>Math.round(t*h);export{E as TextMeshWriter,G as TextVertexSpec,C as getTextBoxStyle,_ as maxLabelZoom};
|
|
2
|
+
import{clamp as t}from"../../../../../../../core/mathUtils.js";import{pt2px as e}from"../../../../../../../core/screenUtils.js";import{GeometryCursor as o}from"../../../../../../../geometry/GeometryCursor.js";import{asCIMGeometryCursor as i}from"../../../../../../../symbols/cim/utils.js";import{CIMMarkerPlacementHelper as s}from"../../../../../../../symbols/cim/placements/CIMMarkerPlacementHelper.js";import{getXDirection as r,getYDirection as n}from"../../../alignmentUtils.js";import{labelU16ZoomPrecisionFactor as a,maxLineHeightRatio as l,minLineHeightRatio as h,maxTextLineWidth as c,minTextLineWidth as d,magicLabelLineHeight as f,packDegreesU8 as u}from"../../../definitions.js";import{shapeTextResource as p,shapeTextResourceForMultipoint as m}from"../../../mesh/templates/shapingUtils.js";import{processColorInput as g,getMinMaxZoom as y,packBitset as x}from"../fill/meshWriterUtils.js";import{MeshWriter as S}from"../mesh/MeshWriter.js";import{bitsetTextIsBackground as z,bitsetTextIsMapAligned as _}from"../shaders/constants.js";import{TextMeshTransformProps as b}from"./TextParams.js";import{DataType as M}from"../../../../../../webgl/enums.js";const P=28,R=[4,4],B=[16,4],L={topLeft:B,topRight:B,bottomLeft:B,bottomRight:B};function T(o){return null==o?c:t(e(o),d,c)}function k(e,o){return e/24*f*t(o,h,l)}const v=[4,2],A=[4,6],w={topLeft:v,topRight:v,bottomLeft:A,bottomRight:A},G={topLeft:v,topRight:A,bottomLeft:v,bottomRight:A},I={topLeft:A,topRight:A,bottomLeft:R,bottomRight:R},C={topLeft:R,topRight:R,bottomLeft:A,bottomRight:A},D={topLeft:A,topRight:R,bottomLeft:A,bottomRight:R},E={topLeft:R,topRight:A,bottomLeft:R,bottomRight:A};function N(t){return{backgroundColor:t.boxBackgroundColor??t.backgroundColor??null,borderLineColor:t.boxBorderLineColor??t.borderLineColor??null,borderLineSize:t.boxBorderLineSize>0?t.boxBorderLineSize:t.borderLineWidth??0}}const H={createComputedParams:t=>t,optionalAttributes:{zoomRange:{type:M.UNSIGNED_SHORT,count:2,packPrecisionFactor:a,packTessellation:({minZoom:t,maxZoom:e})=>[t||0,e||P]},clipAngle:{type:M.UNSIGNED_BYTE,count:1,packTessellation:({clipAngle:t})=>Y(t||0)},referenceSymbol:{type:M.BYTE,count:4,packTessellation:(t,o)=>{const i=t.isLineLabel||!t.referenceBounds,s=r(i?"center":o.horizontalAlignment),a=n(i?"middle":o.verticalAlignment),{offsetX:l,offsetY:h,size:c}=i?{offsetX:0,offsetY:0,size:0}:t.referenceBounds;return[e(l),-e(h),Math.round(e(c)),s+1<<2|a+1]}},visibility:{type:M.FLOAT,count:1,otherSource:!0}},attributes:{pos:{type:M.SHORT,count:2,pack:"position",packPrecisionFactor:10},id:{type:M.UNSIGNED_BYTE,count:3,pack:"id"},bitset:{type:M.UNSIGNED_BYTE,count:1,packTessellation:({isBackground:t,mapAligned:e})=>x([[z,t],[_,!!e]])},offset:{type:M.SHORT,count:2,packPrecisionFactor:8,packAlternating:{count:4,packTessellation:({offsets:t})=>{const{bottomLeft:e,bottomRight:o,topLeft:i,topRight:s}=t;return[i,s,e,o]}}},textureUV:{type:M.UNSIGNED_SHORT,count:2,packAlternating:{count:4,packTessellation:({texcoords:t})=>{const{bottomLeft:e,bottomRight:o,topLeft:i,topRight:s}=t;return[i,s,e,o]}}},color:{type:M.UNSIGNED_BYTE,count:4,normalized:!0,packTessellation:({color:t})=>t},fontAndReferenceSize:{type:M.UNSIGNED_SHORT,count:4,packPrecisionFactor:4,packTessellation:({fontSize:t,sdfSize:o,sdfRadius:i},{referenceSize:s})=>[Math.round(e(t)),Math.round(e(s||t)),o,i]},outlineColor:{type:M.UNSIGNED_BYTE,count:4,normalized:!0,pack:({outlineColor:t})=>g(t)},haloColor:{type:M.UNSIGNED_BYTE,count:4,normalized:!0,pack:({haloColor:t})=>g(t)},outlineAndHaloSize:{type:M.UNSIGNED_SHORT,count:2,packPrecisionFactor:4,packTessellation:({outlineSize:t,haloSize:o})=>[Math.round(e(t)),Math.round(e(o))]}}};class U extends S{constructor(){super(...arguments),this.vertexSpec=H,this._textMeshParamsPropsInitialized=!1}ensurePacked(t,e,o){super.ensurePacked(t,e,o),this._textMeshParamsPropsInitialized&&!this._evaluator.hasDynamicProperties||(this._textMeshTransformProps=new b(this.evaluatedMeshParams),this._textMeshParamsPropsInitialized=!0)}_write(t,{target:e,effectGeometry:o}){const s=this._getShaping();if(!s)return;const r=1===this.evaluatedMeshParams.alignment,n=e.getDisplayId(),{placement:a}=this.evaluatedMeshParams;if(null!=a){if("PrivatePlacementMultipoint"!==a.type)this._writePlacedTextMarkers(t,e,s,i(o));else{const s=this._getMultipointShaping();s&&this._writeMultipointText(t,e,s,i(o))}return}if(o?.nextPath())return o.nextPoint(),this._writeGlyphs(t,n,o.x,o.y,s,0,void 0,{mapAligned:r});if("esriGeometryPolygon"===e.geometryType){const o=e.readCentroidForDisplay();if(!o)return;const[i,a]=o.coords;return this._writeGlyphs(t,n,i,a,s,0,void 0,{mapAligned:r})}if("esriGeometryMultipoint"===e.geometryType){const o=e.readGeometryForDisplay();return void o?.forEachVertex((e,o)=>this._writeGlyphs(t,n,e,o,s,0,void 0,{mapAligned:r}))}const l=e.readXForDisplay(),h=e.readYForDisplay();return this._writeGlyphs(t,n,l,h,s,0,void 0,{mapAligned:r})}_writePlacedTextMarkers(t,i,r,n){const a=n??o.fromFeatureSetReaderCIM(i);if(!a)return;const l=-1,h=s.getPlacement(a,l,this.evaluatedMeshParams.placement,e(1),t.id);if(!h)return;const c=i.getDisplayId();let d=h.next();for(;null!=d;){const e=-d.getAngle(),o=d.tx,i=-d.ty;this._writeGlyphs(t,c,o,i,r,e,void 0,{mapAligned:1===this.evaluatedMeshParams.alignment}),d=h.next()}}_writeMultipointText(t,i,r,n){const a=n??o.fromFeatureSetReaderCIM(i);if(!a)return;const l=-1,h=s.getPlacement(a,l,this.evaluatedMeshParams.placement,e(1),t.id);if(!h)return;const c=i.getDisplayId();let d=h.next(),f=0;for(;null!=d;){const e=d.tx,o=-d.ty,i=-d.getAngle();if(f>=r.glyphs.length)break;this._writeGlyph(t,c,e,o,r,f,i,void 0,{mapAligned:1===this.evaluatedMeshParams.alignment}),d=h.next(),f++}}_getShaping(o){const i=this._textMeshTransformProps,s=this.evaluatedMeshParams;if(!this._hasGlyphs(s.glyphs))return null;const r=e(i.fontSize),n=e(i.offsetX),a=e(i.offsetY),{sdfSize:c}=this._getDefaultGlyphMetrics(s.glyphs),d=T(s.lineWidth),f=k(c,s.lineHeightRatio),{backgroundColor:u,borderLineSize:m}=N(s);return p(s.glyphs,{scale:r/c,angle:i.postAngle,xOffset:n,yOffset:a,horizontalAlignment:s.horizontalAlignment,verticalAlignment:o||s.verticalAlignment,maxLineWidth:d,lineHeight:f,lineHeightRatio:t(s.lineHeightRatio,h,l),decoration:s.decoration,borderLineSizePx:e(m),hasBackground:!!u,useCIMAngleBehavior:s.useCIMAngleBehavior})}_getMultipointShaping(){const o=this._textMeshTransformProps,i=this.evaluatedMeshParams;if(!this._hasGlyphs(i.glyphs))return null;const s=e(o.fontSize),r=e(o.offsetX),n=e(o.offsetY),{sdfSize:a}=this._getDefaultGlyphMetrics(i.glyphs),c=T(i.lineWidth),d=k(a,i.lineHeightRatio),{backgroundColor:f,borderLineSize:u}=N(i);return m(i.glyphs,{scale:s/a,angle:o.postAngle,xOffset:r,yOffset:n,horizontalAlignment:i.horizontalAlignment,verticalAlignment:i.verticalAlignment,maxLineWidth:c,lineHeight:d,lineHeightRatio:t(i.lineHeightRatio,h,l),decoration:i.decoration,borderLineSizePx:e(u),hasBackground:!!f,useCIMAngleBehavior:i.useCIMAngleBehavior})}_hasGlyphs(t){return!!t&&("glyphs"===t.type?t.glyphs.length>0:t.runs.some(t=>t.glyphs.glyphs.length>0))}_getDefaultGlyphMetrics(t){if("glyphs"===t.type)return{sdfSize:t.sdfSize,sdfRadius:t.sdfRadius};const[e]=t.runs;return{sdfSize:e?.glyphs.sdfSize??24,sdfRadius:e?.glyphs.sdfRadius??8}}_writeGlyphs(t,o,i,s,r,n,a,l,h=!0){const c=this.evaluatedMeshParams,d=this._textMeshTransformProps,f=e(d.fontSize),u=d.haloSize,p=d.outlineSize,m=e(d.offsetX),x=e(d.offsetY),S=this._getDefaultGlyphMetrics(c.glyphs),z=g(c.color),[_,b]=y(c.scaleInfo,this.getTileInfo());0!==n&&r.setRotation(n);const M=r.bounds,P=i+M.x+m,R=s+M.y-x,B=2*(c.minPixelBuffer?c.minPixelBuffer/f:1),L=Math.max(M.width,M.height)*B;r.textBox&&(t.recordStart(this.instanceId,this.attributeLayout,r.glyphs[0].textureBinding),h&&t.recordBounds(P,R,L,L),this._writeTextBox(t,o,i,s,r.textBox,a,l),t.recordEnd());for(const e of r.glyphs){t.recordStart(this.instanceId,this.attributeLayout,e.textureBinding),h&&t.recordBounds(P,R,L,L);const{texcoords:r,offsets:n}=e,c=e.fontSize??f;this._writeQuad(t,o,i,s,{texcoords:r,offsets:n,fontSize:c,haloSize:u,outlineSize:p,sdfSize:S.sdfSize,sdfRadius:S.sdfRadius,color:e.color?g(e.color):z,isBackground:!1,referenceBounds:a,minZoom:_,maxZoom:b,...l}),t.recordEnd()}0!==n&&r.setRotation(-n)}_writeGlyph(t,o,i,s,r,n,a,l,h,c=!0){const d=this.evaluatedMeshParams,f=this._textMeshTransformProps,u=e(f.fontSize),p=f.haloSize,m=f.outlineSize,y=e(f.offsetX),x=e(f.offsetY),S=this._getDefaultGlyphMetrics(d.glyphs),z=g(d.color);0!==a&&r.setRotation(a);const _=r.bounds,b=i+_.x+y,M=s+_.y-x,P=2*(d.minPixelBuffer?d.minPixelBuffer/u:1),R=Math.max(_.width,_.height)*P,B=r.glyphs[n];t.recordStart(this.instanceId,this.attributeLayout,B.textureBinding),c&&t.recordBounds(b,M,R,R);const{texcoords:L,offsets:T}=B,k=B.fontSize??u;this._writeQuad(t,o,i,s,{texcoords:L,offsets:T,fontSize:k,haloSize:p,outlineSize:m,sdfSize:S.sdfSize,sdfRadius:S.sdfRadius,color:B.color?g(B.color):z,isBackground:!1,referenceBounds:l,minZoom:0,maxZoom:30,...h}),t.recordEnd(),0!==a&&r.setRotation(-a)}_writeTextBox(t,e,o,i,s,r,n){const a=this.evaluatedMeshParams,{fontSize:l,haloSize:h,outlineSize:c}=this._textMeshTransformProps,{backgroundColor:d,borderLineColor:f,borderLineSize:u}=N(a),{sdfSize:p,sdfRadius:m}=this._getDefaultGlyphMetrics(a.glyphs),y=!!f&&u>0,x={isBackground:!0,fontSize:l,haloSize:h,outlineSize:c,referenceBounds:r,sdfSize:p,sdfRadius:m,...n};d&&(this._writeQuad(t,e,o,i,{texcoords:L,offsets:s.main,color:g(d),...x}),y||(this._writeQuad(t,e,o,i,{texcoords:I,offsets:s.top,color:g(d),...x}),this._writeQuad(t,e,o,i,{texcoords:C,offsets:s.bot,color:g(d),...x}),this._writeQuad(t,e,o,i,{texcoords:D,offsets:s.left,color:g(d),...x}),this._writeQuad(t,e,o,i,{texcoords:E,offsets:s.right,color:g(d),...x}))),y&&(this._writeQuad(t,e,o,i,{texcoords:w,offsets:s.top,color:g(f),...x}),this._writeQuad(t,e,o,i,{texcoords:w,offsets:s.bot,color:g(f),...x}),this._writeQuad(t,e,o,i,{texcoords:G,offsets:s.left,color:g(f),...x}),this._writeQuad(t,e,o,i,{texcoords:G,offsets:s.right,color:g(f),...x}))}_writeQuad(t,e,o,i,s){const r=t.vertexCount();this._writeVertex(t,e,o,i,s),t.indexWrite(r+0),t.indexWrite(r+1),t.indexWrite(r+2),t.indexWrite(r+1),t.indexWrite(r+3),t.indexWrite(r+2)}}const Y=t=>Math.round(t*u);export{U as TextMeshWriter,H as TextVertexSpec,N as getTextBoxStyle,P as maxLabelZoom};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
import has from"../../../../../core/has.js";import{OverrideHelper as e}from"../../../../../symbols/cim/OverrideHelper.js";import{
|
|
2
|
+
import has from"../../../../../core/has.js";import{OverrideHelper as e}from"../../../../../symbols/cim/OverrideHelper.js";import{hasRichTextFormattingTags as t}from"../../../../../symbols/cim/richTextUtils.js";import{FeatureMatcher as r}from"./Matcher.js";import{createDebugWriters as s}from"../../../layers/support/annodime/debugUtils.js";import i from"../../../layers/support/annodime/DimensionInfo.js";import{dimensionSymbols as o}from"../../../layers/support/annodime/dimensionSymbols.js";import{getFontForCIMTextSymbol as n}from"../../../layers/support/annodime/dimensionUtils.js";import{createDimensionMatcherFeatureInfo as m,mixFeature as a}from"../../../layers/support/annodime/MatcherGeometryOverride.js";import{createTileObjectId as c}from"../../../layers/support/annodime/TileObjectId.js";class h extends r{constructor(e,t){super(),this._context=e,this._schema=t,this._meshWriters=new Map,this._dimensionInfos=new Map,this._matcherGeometryOverrides=new Map}static async fromDimensionSchema(e,t){return new h(e,t)}hasArcadeDependency(){return!1}doMatch(e,t,r){return this._meshWriters.get(c(r,e.getObjectId()))}async fetchResources(e,t,r,i){this._meshWriters.clear(),this._dimensionInfos.clear(),this._matcherGeometryOverrides.clear();const o=t.metadata.outSpatialReference,n=t.getCursor();for(;n.next();){const r=m(n);if(!r)continue;const h=a(n,r);if(!h)continue;const l=c(i,n.getObjectId()),y=this._readStyleId(n),p=this._getStyle(y);if(!p){let r=this._meshWriters.get(l);r||(r=await s(this._context,e,t.geometryType),this._meshWriters.set(l,r));continue}const d=await this._createDimensionInfo(p,h,o);await this._cacheGlyphs(d,h,e),this._dimensionInfos.set(l,d),this._matcherGeometryOverrides.set(l,r.geometryOverride);let u=this._meshWriters.get(l);u||(u=await this._createGroup(p,n,h,e,t.geometryType),this._meshWriters.set(l,u))}}async _createDimensionInfo(e,t,r){return await i.create(e,t,r)}async _createGroup(e,t,r,i,n){const m=o.processDimensionStyle(e),[a,c,h,l,y]=await Promise.all([this._createMeshesForSymbol(m.beginDimensionLineSymbol,m.primitiveOverrides,t,r,i),this._createMeshesForSymbol(m.endDimensionLineSymbol,m.primitiveOverrides,t,r,i),this._createMeshesForSymbol(m.beginExtensionLineSymbol,m.primitiveOverrides,t,r,i),this._createMeshesForSymbol(m.endExtensionLineSymbol,m.primitiveOverrides,t,r,i),this._createMeshesForSymbol(m.textSymbol,m.primitiveOverrides,t,r,i)]),p=await this._context.createMeshWriters([...a,...c,...h,...l,...y]);if(has("esri-2d-annotation-dimension-debug")){const e=await s(this._context,i,n);return e.length?[...p,...e]:p}return p}async _createMeshesForSymbol(t,r,s,i,o){if(!t)return[];const n=await e.resolveSymbolOverrides({type:"CIMSymbolReference",primitiveOverrides:r,symbol:t},i,s.metadata.outSpatialReference,null,s.geometryType);if(!n)return[];const m=await o.fetchMeshResourceImmediate({type:"mesh-request",symbolReference:{type:"CIMSymbolReference",symbol:n}});return m?.meshes??[]}_readStyleId(e){return parseInt(`${e.readAttribute("STYLEID")}`,10)}_getStyle(e){return this._schema.styleCollection.find(t=>(t.iD??0)===e)}async _cacheGlyphs(e,r,s){const i=e.getTextString(r);if(!i)return;const o=await s.fetchResourceImmediate({type:"cim-rasterization-info",resource:{type:"text",textString:i||"",font:n(e.textSymbol),symbol:e.textSymbol,supportsRichText:t(i)}});"glyphs"!==o?.type&&"rich-glyphs"!==o?.type||e.setTextResource(o)}cleanup(e,t,r){const s=t.getObjectId(),i=c(r,s);this._meshWriters.delete(i),this._dimensionInfos.delete(i),this._matcherGeometryOverrides.delete(i)}getAnalyzedGraphic(e){return this._dimensionInfos.get(e)||null}getMatcherGeometryOverride(e){return this._matcherGeometryOverrides.get(e)??null}}export{h as DimensionMatcher};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
import{__decorate as e}from"tslib";import t from"../../../AggregateGraphic.js";import r from"../../../Graphic.js";import s from"../../../TrackGraphic.js";import{isSome as i}from"../../../core/arrayUtils.js";import a from"../../../core/Collection.js";import o from"../../../core/Error.js";import{makeHandle as n,handlesGroup as l}from"../../../core/handleUtils.js";import has from"../../../core/has.js";import u from"../../../core/Logger.js";import{destroyMaybe as h}from"../../../core/maybe.js";import{notDeepEqual as c}from"../../../core/object.js";import{createAbortError as p,ignoreAbortErrors as d,throwIfNotAbortError as y,isAbortError as m}from"../../../core/promiseUtils.js";import{watch as g,sync as f}from"../../../core/reactiveUtils.js";import{isScreenRect as w}from"../../../core/screenUtils.js";import{sqlAnd as v}from"../../../core/sql.js";import{getMetersPerUnitForSR as _}from"../../../core/units.js";import{property as b,subclass as S}from"../../../core/accessorSupport/decorators.js";import{UpdatingHandles as A}from"../../../core/support/UpdatingHandles.js";import F from"../../../geometry/Extent.js";import{fromJSON as j}from"../../../geometry/support/jsonUtils.js";import x from"../../../geometry/support/rotate.js";import{isCurvedGeometry as E}from"../../../geometry/support/curves/curveUtils.js";import{densifyCurvedGeometry as I}from"../../../geometry/support/curves/densifyCurvedGeometry.js";import k from"../../../layers/effects/FeatureEffectView.js";import{convertFromFeature as O}from"../../../layers/graphics/featureConversionUtils.js";import U from"../../../layers/support/FeatureFilter.js";import{checkServiceCurrentUserSupport as R}from"../../../layers/support/featureLayerUtils.js";import{packFields as V}from"../../../layers/support/fieldUtils.js";import{getEffectiveLayerCapabilities as C}from"../../../layers/support/layerUtils.js";import{combineTimeExtent as Q}from"../../../layers/support/timeSupport.js";import q from"../../../rest/support/AggregateFeatureSet.js";import M from"../../../rest/support/AttributeBinsFeatureSet.js";import H from"../../../rest/support/AttributeBinsQuery.js";import P from"../../../rest/support/FeatureSet.js";import L from"../../../rest/support/Query.js";import{HittestDrawHelper as T}from"../../../symbols/cim/CIMSymbolDrawHelper.js";import{symbolToCIM as W}from"../../../symbols/cim/CIMSymbolHelper.js";import{getDisplayedSymbol as D}from"../../../symbols/support/symbolUtils.js";import{LayerView2D as G}from"./LayerView2D.js";import{FeatureContainer as N}from"./features/FeatureContainer.js";import{createFeaturePipelineWorkerProxy as J}from"./features/FeaturePipelineWorkerProxy.js";import{FeatureSourceEventLog as z}from"./features/FeatureSourceEventLog.js";import{AnnotationLayerAdapter as B}from"./features/layerAdapters/AnnotationLayerAdapter.js";import{CatalogFootprintLayerAdapter as Z}from"./features/layerAdapters/CatalogFootprintLayerAdapter.js";import{DimensionLayerAdapter as K}from"./features/layerAdapters/DimensionLayerAdapter.js";import{FeatureLayerAdapter as $}from"./features/layerAdapters/FeatureLayerAdapter.js";import{createFeatureIdInfo as X}from"./features/layerAdapters/featureServiceUtils.js";import{InMemoryLayerAdapter as Y}from"./features/layerAdapters/InMemoryLayerAdapter.js";import{KnowledgeGraphSublayerAdapter as ee}from"./features/layerAdapters/KnowledgeGraphSublayerAdapter.js";import{OGCFeatureLayerAdapter as te}from"./features/layerAdapters/OGCFeatureLayerAdapter.js";import{OrientedImageryLayerAdapter as re}from"./features/layerAdapters/OrientedImageryLayerAdapter.js";import{ParquetLayerAdapter as se}from"./features/layerAdapters/ParquetLayerAdapter.js";import{StreamLayerAdapter as ie}from"./features/layerAdapters/StreamLayerAdapter.js";import{SubtypeGroupLayerAdapter as ae}from"./features/layerAdapters/SubtypeGroupLayerAdapter.js";import{createComplexSymbolInstances as oe}from"./features/schema/processor/symbols/ComplexSymbolSchema.js";import{DebouncedFeatureOverride as ne}from"./support/DebouncedFeatureOverride.js";import{FeatureCommandQueue as le}from"./support/FeatureCommandQueue.js";import{handleNoEngineError as ue}from"./support/handleNoEngineError.js";import{toJSONGeometryType as he}from"./support/util.js";import{getMapPointsFromScreen as ce}from"../support/hitTestUtils.js";import{FeatureTileSubscriptionManager as pe}from"../tiling/FeatureTileSubscriptionManager.js";import{RefreshableLayerView as de}from"../../layers/RefreshableLayerView.js";import{getHighlightName as ye}from"../../support/highlightOptionsUtils.js";function me(e,t){const r=new Set;return e&&e.forEach(e=>r.add(e)),t&&t.forEach(e=>r.add(e)),r.has("*")?["*"]:Array.from(r)}const ge=4294967294;function fe(e,t){return l(e.map(e=>g(()=>{const t=e();return t&&"object"==typeof t?"getTime"in t&&"function"==typeof t.getTime?t.getTime():JSON.stringify(t):t},t,f)))}function we(e){if(!e.geometry)return e;if(!E(e.geometry))return e;const t=.001/_(e.geometry.spatialReference),r=100;return{geometry:I(e.geometry,{maxSegmentsPerCurve:12e3,maxSegmentLength:r*t,maxDeviation:0}),attributes:e.attributes}}const ve=l=>{const f=de(G(l));let _=class extends f{constructor(){super(...arguments),this._commandsQueue=new le({process:e=>{switch(e.type){case"override-batch":return this._doOverride(e);case"update":return this._doUpdate();case"highlight":return this._updateHighlights()}}}),this._visibilityOverrides=new Set,this._lastAvailableFields=[],this._lastTargetState=null,this.eventLog=new z,this._sourceRefreshVersion=1,this._displayRefreshVersion=1,this._pipelineUpdating=!1,this._editUpdatingHandles=new A,this._fields=null,this._hittestDrawHelper=null,this._sourceUpdating=!1,this.featureEffectView=new k}destroy(){this._editUpdatingHandles.destroy(),this._workerProxy?.destroy(),this._workerAttached.reject(p()),this._commandsQueue.destroy(),this._hittestDrawHelper?.destroy()}initialize(){this._workerAttached=Promise.withResolvers(),d(this._workerAttached.promise),this.addResolvingPromise(this._initProxy()),this.featureEffectView.featureEffect=this.featureEffect,this.featureEffectView.endTransition()}async _initProxy(){const e=this.layer;if("isTable"in e&&e.isTable)throw new o("featurelayerview:table-not-supported","table feature layer can't be displayed",{layer:e});if(("feature"===e.type||"subtype-group"===e.type)&&!1===C(e)?.operations.supportsQuery)throw new o("featurelayerview:query-not-supported","layer view requires a layer with query capability",{layer:e});this._workerProxy&&this._workerProxy.destroy();const t=this._createClientOptions();this._workerProxy=await J(t)}async _attachProxy(){const e=x(this.view.extent,this.view.rotation,this.view.center),t={tileInfoJSON:this.view?.featuresTilingScheme?.tileInfo?.toJSON(),initialViewExtent:e.toJSON()};try{await this._workerProxy.pipeline.onAttach(t),this._workerAttached.resolve()}catch(r){this._workerAttached.reject(p()),y(r)}}async _detachProxy(){return this._workerProxy.pipeline.onDetach()}async getWorker(){return await this._workerAttached.promise,this._workerProxy}get dataUpdating(){return this._sourceUpdating||this._editUpdatingHandles.updating}get hasAllFeatures(){return this.layer.visible&&!this.suspended&&this.eventLog.hasAllData&&this.eventLog.willQueryAllFeatures}get hasAllFeaturesInView(){const e=this.effectiveDisplayFilter?.where||null,t=!this.eventLog.willQueryAllFeatures&&null!=e&&"1=1"!==e;return this.layer.visible&&!this.suspended&&this.eventLog.hasAllData&&!t}get hasFullGeometries(){return this.layer.visible&&!this.suspended&&this.eventLog.hasAllData&&this.eventLog.willQueryFullResolutionGeometry}get layerAdapter(){switch(this.layer.type){case"annotation-feature":return new B(this.layer);case"dimension-feature":return new K(this.layer);case"feature":return"memory"===this.layer.source.type?new Y(this.layer):new $(this.layer);case"geojson":case"csv":case"wfs":return new Y(this.layer);case"parquet":return new se(this.layer);case"subtype-group":return new ae(this.layer);case"ogc-feature":return new te(this.layer);case"stream":return new ie(this.layer);case"oriented-imagery":return new re(this.layer);case"knowledge-graph-sublayer":return new ee(this.layer);case"catalog-footprint":return new Z(this.layer);default:this.layer}return null}get timeExtent(){return Q(this.layerAdapter.timeOptions,this.view?.timeExtent,this._get("timeExtent"))}get usedMemory(){return this.container.usedMemory+this.eventLog.pipelineStatistics.usedMemory}getDisplayStatistics(e,t){return this.featureContainer?.getDisplayStatistics(e,t)}highlight(e,t){let s;e instanceof r?s=[e.getObjectId()]:"number"==typeof e||"string"==typeof e?s=[e]:a.isCollection(e)&&e.length>0?s=e.map(e=>e?.getObjectId()).toArray():Array.isArray(e)&&e.length>0&&(s="number"==typeof e[0]||"string"==typeof e[0]?e:e.map(e=>e?.getObjectId()));const o=s?.filter(i);if(!o?.length)return n();const l=ye(t);return this._addHighlights(o,l),n(()=>!this.destroyed&&this._removeHighlights(o,l))}async hitTest(e,i){const a=w(i),{trueHitIds:o,candidateHitIds:n}=await this.featureContainer.hitTest(i),l=await this.getWorker(),[u,h]=await Promise.all([l.pipeline.getDisplayFeatures(n),l.pipeline.getDisplayFeatures(o)]),{features:c,aggregates:p,tracks:d}=u,{features:y,aggregates:g,tracks:f}=h,v=[];if(a&&this.hasRenderer()){const e=new Map,t=new r;for(const r of c){t.attributes=r.attributes,t.geometry=j(r.geometry),t.symbol=null;const s=this.layerAdapter.getRenderer(t);if(!s){v.push(r);continue}const i=await D(t,{renderer:s,scale:this.view.scale,resolution:this.view.resolution,spatialReference:this.view.spatialReference,viewingMode:"2d",timeZone:this.view.timeZone});if(!i)continue;let a=null;const o=W(i);if("web-style"===o.type)try{const e=W(await o.fetchSymbol({acceptedFormats:["cim","web"]}));a="web-style"===e.type?null:e}catch(x){m(x),0;continue}else a=o;const n=a?.symbol;if(!n)continue;const l=this.view.stage.cimAnalyzer.analyzeSymbolReference(a,!1).some(e=>"alignment"in e&&0===e.alignment);e.set(r,{cimSymbol:n,isScreenAligned:l})}e.size>0&&!this._hittestDrawHelper&&(this._hittestDrawHelper=new T(this.view.stage.painter.textureManager.resourceManager));const{resolution:s,rotation:a}=this.view.state,o=ce(this.view,i);for(const[r,{cimSymbol:i,isScreenAligned:n}]of e){if(!r)continue;const e={hittestType:"rect",textInfo:null,mapRotation:a,resolution:s,searchDist:0,isScreenAligned:n};this._hittestDrawHelper.hitTest(o,i,r.geometry,e)&&v.push(r)}}else v.push(...c);const _=[...y,...v],b=[...g,...p],S=[...f,...d],A=this.featureContainer.getSortKeys(_.map(e=>e.displayId)),F=({displayId:e},{displayId:t})=>A.has(e)&&A.has(t)?A.get(e)-A.get(t):e-t;return _.sort(F).reverse(),b.sort(F).reverse(),[...b.map(r=>this._createAggregateGraphicHit(e,t.fromJSON(r))),...S.map(t=>this._createTrackGraphicHit(e,s.fromJSON(t))),..._.map(t=>this._createFeatureGraphicHit(a?null:e,r.fromJSON(t)))]}async queryAggregateSummaryStatistics(e,t,r){const s={...t,scale:this.view.scale},i=(await this.getWorker()).aggregates.executeQueryForSummaryStatistics(this._cleanUpAggregateQuery(e),s,r);return ue(i,{})}async queryUniqueValues(e,t,r){const s=await this.getWorker(),i={...t,scale:this.view.scale},a=s.features.executeQueryForUniqueValues(this._cleanUpQuery(e),i,r);return ue(a,{uniqueValueInfos:[]})}async queryAggregateUniqueValues(e,t,r){const s=await this.getWorker(),i={...t,scale:this.view.scale},a=s.aggregates.executeQueryForUniqueValues(this._cleanUpAggregateQuery(e),i,r);return ue(a,{uniqueValueInfos:[]})}async queryAggregateClassBreaks(e,t,r){const s=await this.getWorker(),i={...t,scale:this.view.scale},a=s.aggregates.executeQueryForClassBreaks(this._cleanUpAggregateQuery(e),i,r);return ue(a,{classBreakInfos:[]})}async queryHistogram(e,t,r){const s=await this.getWorker(),i={...t,scale:this.view.scale},a=s.features.executeQueryForHistogram(this._cleanUpQuery(e),i,r);return ue(a,{bins:[],maxValue:null,minValue:null,normalizationTotal:null})}async queryAggregateCount(e,t){const r=(await this.getWorker()).aggregates.executeQueryForCount(this._cleanUpAggregateQuery(e),t);return ue(r,0)}async queryAggregateHistogram(e,t,r){const s=await this.getWorker(),i={...t,scale:this.view.scale},a=s.aggregates.executeQueryForHistogram(this._cleanUpAggregateQuery(e),i,r);return ue(a,{bins:[],maxValue:null,minValue:null,normalizationTotal:null})}async queryAggregateIds(e,t){const r=(await this.getWorker()).aggregates.executeQueryForIds(this._cleanUpAggregateQuery(e),t);return ue(r,[])}async queryAggregateJSON(e,t){const r=(await this.getWorker()).aggregates.executeQuery(this._cleanUpAggregateQuery(e),t);return ue(r,{features:[]})}async queryAttributeBins(e,t){const r=(await this.getWorker()).features.executeAttributeBinsQuery(this._cleanUpAttributeBinsQuery(e),t),s=await ue(r,{features:[]});return M.fromJSON(s)}async queryAggregates(e,t){const r=(await this.getWorker()).aggregates.executeQuery(this._cleanUpAggregateQuery(e),t),s=await ue(r,{features:[]}),i=q.fromJSON(s);return i.features.forEach(e=>this.layerAdapter.setAggregateGraphicOrigin?.(e)),i}async queryClassBreaks(e,t,r){const s=await this.getWorker(),i={...t,scale:this.view.scale},a=s.features.executeQueryForClassBreaks(this._cleanUpQuery(e),i,r);return ue(a,{classBreakInfos:[]})}async queryExtent(e,t){const r=(await this.getWorker()).features.executeQueryForExtent(this._cleanUpQuery(e),t),s=await ue(r,{count:0,extent:null});return{count:s.count,extent:F.fromJSON(s.extent)}}async queryFeatureCount(e,t){const r=(await this.getWorker()).features.executeQueryForCount(this._cleanUpQuery(e),t);return ue(r,0)}queryFeatures(e,t){return this.queryFeaturesJSON(e,t).then(e=>{const t=P.fromJSON(e);return t.features.forEach(e=>this._setOriginForFeature(e)),t})}async queryFeaturesJSON(e,t){const r=(await this.getWorker()).features.executeQuery(this._cleanUpQuery(e),t);return ue(r,{features:[]})}async queryHeatmapStatistics(e){return(await this.getWorker()).pipeline.queryHeatmapStatistics(e)}async queryObjectIds(e,t){const r=(await this.getWorker()).features.executeQueryForIds(this._cleanUpQuery(e),t);return ue(r,[])}async queryStatistics(){const e=await this.getWorker();return ue(e.pipeline.queryStatistics(),{featureCount:0,ringCount:0,vertexCount:0})}async querySummaryStatistics(e,t,r){const s=await this.getWorker(),i={...t,scale:this.view.scale},a=s.features.executeQueryForSummaryStatistics(this._cleanUpQuery(e),i,r);return ue(a,{})}async queryVisibleFeatures(e,t){const r=(await this.getWorker()).pipeline.queryVisibleFeatures(this._cleanUpQuery(e),t),s=await ue(r,{features:[]}),i=P.fromJSON(s);return i.features.forEach(e=>this._setOriginForFeature(e)),i}async getSampleFeatures(e){return(await this.getWorker()).pipeline.getSampleFeatures(e)}setVisibility(e,t){t?this._visibilityOverrides.delete(e):this._visibilityOverrides.add(e),this._update()}update(e){if(!this._subscriptions)return;this.view.animation&&!this._lastTargetState&&(this._lastTargetState=e.state.clone()),!this.view.animation&&this._lastTargetState&&(this._lastTargetState=null);const t=this.featureContainer.getPresenting(),r=this._subscriptions.update(e.targetState,this._lastTargetState,t);r&&(this.featureContainer.updateSubscriptions(r),d(this._updatingHandles.addPromise(this.getWorker().then(e=>e.pipeline.updateSubscriptions(r))))),this._subscriptions.coverage&&this.featureContainer.setCoverage(this._subscriptions.coverage)}attach(){has("esri-2d-update-debug")&&console.debug("FeatureLayerView2D.attach"),d(this._updatingHandles.addPromise(this._workerAttached.promise)),d(this._attachProxy()),this.featureContainer=new N(this),this.container.addChild(this.featureContainer),this.view.timeline.record(`${this.layer.title} (FeatureLayer) Attach`),this._subscriptions=new pe(this.view.featuresTilingScheme),this.requestUpdate(),this.addAttachHandles([fe([()=>this._displayRefreshVersion,()=>"displayFilterInfo"in this.layer&&this.layer.displayFilterInfo,()=>this.timeExtent,()=>this.clips,()=>this.filter,()=>this.effectiveDisplayFilterClause,()=>this.featureEffect,()=>this._sourceRefreshVersion,()=>this.view.timeZone,()=>this.view.timeExtent,...this.layerAdapter.getUpdateHashProperties(this.view)],()=>this._update()),g(()=>this.updateSuspended,e=>{e||this._subscriptions.resume(this.featureContainer.getPresenting())}),g(()=>this.view.stationary,async e=>{if(e){const e=await this.getWorker(),t=x(this.view.extent,this.view.rotation,this.view.center);e.pipeline.updateStationaryExtent(t.toJSON(),this.featureContainer.requiresRefresh).catch(()=>{})}})]),this._update(),"stream"!==this.layer.type&&"parquet"!==this.layer.type&&"catalog-footprint"!==this.layer.type&&this.addAttachHandles(this.layer.on("edits",e=>this._editUpdatingHandles.addPromise(this._edit(e))))}detach(){has("esri-2d-update-debug")&&console.debug("FeatureLayerView2D.detach"),this._detachProxy(),this._fields=null,this.featureContainer.destroy(),this.featureContainer=null,this._commandsQueue.clear(),this.container.removeAllChildren(),this._subscriptions=h(this._subscriptions),this._workerProxy.pipeline.onDetach(),this._workerAttached=Promise.withResolvers(),d(this._workerAttached.promise),this._lastAvailableFields=[],this._lastSchema=null}viewChange(){this.requestUpdate()}moveEnd(){this.requestUpdate()}addOverrides(e){return this._commandsQueue.push({type:"override",options:{...e,release:[]}})}removeOverrides(e){for(const r of e)if(null==r)throw new o("featurelayerview:bad-override","Tried to remove an override for an invalid objectId",{objectId:r});const t={added:[],updated:[],removed:[],release:e,isWeak:!1,historicMoment:null};return this._commandsQueue.push({type:"override",options:t})}onProxyClientEvent(e){}hasRenderer(){return"renderer"in this.layer&&null!=this.layer.renderer}isUpdating(){const e=this.hasRenderer(),t=this._commandsQueue.updateTracking.updating,r=null!=this._updatingRequiredPromise,s=this.featureContainer.updating;return this.updateRequested||e&&(t||r)||s||this._pipelineUpdating||this.dataUpdating}_createClientOptions(){const e=this;return{updateSchemaStart:()=>e.updateSchemaStart(),updateSchemaEnd:t=>e.updateSchemaEnd(t),openMemoryPorts:async()=>{if(this.layerAdapter?.openMessagePorts){const e=await this.layerAdapter.openMessagePorts();return{result:e,transferList:e}}throw new Error("InternalError: Layer adapter does not support opening message ports")},get container(){return e.featureContainer},setUpdating:e=>{this._set("_pipelineUpdating",e.pipeline),this._set("_sourceUpdating",e.source)},emitEvent:e=>{this.onProxyClientEvent(e)},get eventLog(){return e.eventLog},fetch:async t=>{if(has("esri-2d-stabilize-glyphs")){const r=[];for(const s of t)r.push(await e.view.stage.painter.textureManager.rasterizeItem(s));return r}return Promise.all(t.map(t=>e.view.stage.painter.textureManager.rasterizeItem(t)))},fetchDictionary:e=>Promise.all(e.map(e=>this._fetchDictionaryRequest(e))),fetchMesh:e=>Promise.all(e.map(e=>this._fetchMeshRequest(e)))}}async _fetchDictionaryRequest(e){try{if(!("renderer"in this.layer)||!this.layer.renderer||"dictionary"!==this.layer.renderer.type)throw new Error("InternalError: Expected renderer to be of type 'dictionary'");const t=this.layer.renderer,r=this._lastSchema.processor.mesh.factory.symbology;if("dictionary"!==r.type)throw new Error("InternalError: Expected schema to be of type 'dictionary'");const s={cimAnalyzer:this.view.stage.cimAnalyzer,cimResourceManager:this.view.stage.painter.textureManager.resourceManager,store:this.featureContainer.instanceStore,scaleExpression:r.scaleExpression};this._fields||(this._fields=this.layer.fields.map(e=>e.toJSON()));const i=r.visualVariableUniforms,a=he(this.layer.geometryType),o=await t.getSymbolForControlString(e.controlString,a,!1);if(!o||!o.data)return{type:"dictionary-response",meshes:[]};return{type:"dictionary-response",meshes:await oe({...o.data,hasTextStringTemplates:!0},{uniforms:i,path:"renderer",schemaOptions:s})}}catch(t){return{type:"dictionary-response",meshes:[]}}}async _fetchMeshRequest(e){const{layer:t}=this;try{const r={cimAnalyzer:this.view.stage.cimAnalyzer,cimResourceManager:this.view.stage.painter.textureManager.resourceManager,store:this.featureContainer.instanceStore,scaleExpression:null};this._fields||(this._fields=t.fields.map(e=>e.toJSON()));return{type:"mesh-response",meshes:await oe({...e.symbolReference,hasTextStringTemplates:!0},{path:"anno-like",schemaOptions:r,uniforms:{visualVariableColor:null,visualVariableOpacity:null,visualVariableRotation:null,visualVariableSizeStops:null,visualVariableSizeScaleStops:null,visualVariableSizeOutlineScaleStops:null,visualVariableSizeUnitValue:null,visualVariableSizeMinMaxValue:null}})}}catch(r){return{type:"mesh-response",meshes:[]}}}_cleanUpQuery(e){const t=L.from(e)||this.createQuery();return t.outSpatialReference||(t.outSpatialReference=this.view.spatialReference),"returnZ"in this.layer&&(t.returnZ??=this.layer.returnZ),"returnM"in this.layer&&(t.returnM??=this.layer.returnM),t.toJSON()}_cleanUpAttributeBinsQuery(e){const t=H.from(e);return t.outSpatialReference||(t.outSpatialReference=this.view.spatialReference),t.toJSON()}_cleanUpAggregateQuery(e){const t=L.from(e)||this.createAggregateQuery();t.outSpatialReference||(t.outSpatialReference=this.view.spatialReference);const r=t.objectIds??[];for(const s of t.aggregateIds??[])r.push(s);return t.objectIds=r,t.aggregateIds=[],t.toJSON()}async _update(){return this._commandsQueue.push({type:"update"})}_edit(e){return this._commandsQueue.push({type:"edit",event:e})}async doRefresh(e){this.attached&&(this.updateSuspended&&e||(e?this.incrementSourceRefreshVersion():this.incrementDisplayRefreshVersion()))}incrementSourceRefreshVersion(){this._sourceRefreshVersion=(this._sourceRefreshVersion+1)%ge+1}incrementDisplayRefreshVersion(){this._displayRefreshVersion=(this._displayRefreshVersion+1)%ge+1}async _resolveIdenifiers(e){const t=[],r=[];for(const a of e)null==a.objectId||-1===a.objectId?null==a.globalId?u.getLogger(this).warn("mapview-apply-edits","A feature identifier must contain either a GlobalId or ObjectId. Ignoring",{identifier:a}):r.push(a.globalId):t.push(a.objectId);const s="globalIdField"in this.layer&&this.layer.globalIdField,i=s&&this.availableFields.includes(s);if(r.length&&!i)return u.getLogger(this).error(new o("mapview-apply-edits",`Editing the specified service requires the layer's globalIdField, ${s} to be included the layer's outFields for updates to be reflected on the map`)),t;if(r.length){const e=await this._workerProxy.pipeline.getObjectIdsFromGlobalIds(r);for(const r of e)t.push(r)}return t}_resolveOverrides(e){const t=!1,r=!1,s=he(this.layer.geometryType),i=X(this.layer),a=[];for(const n of e.added){const e=O(we(n),s,t,r,i);if(null==e.objectId)throw new o("featurelayerview:bad-override","Feature does not have an objectId",{feature:n});a.push(e)}for(const n of e.updated){const e=O(we(n),s,t,r,i);if(null==e.objectId)throw new o("featurelayerview:bad-override","Feature does not have an objectId",{feature:n});a.push(e)}for(const n of e.removed)if(null==n)throw new o("featurelayerview:bad-override","Tried to remove an invalid objectId",{objectId:n});return{type:"override",updates:a,removed:e.removed,release:e.release,isWeak:e.isWeak??!1,historicMoment:e.historicMoment??null}}async _resolveEdit(e){const t=this.layer,r=e.historicMoment?.getTime()??null,s="layerId"in t&&e.editedFeatures?.find(e=>e.layerId===t.layerId);if(s&&this._canEditByFeature(s)){const{adds:e,deletes:t,updates:i}=s.editedFeatures,a=this.layer.objectIdField,o=i.map(e=>e.current),n=t.map(e=>"attributes"in e?{objectId:a?e.attributes[a]:null}:e),l=await this._resolveIdenifiers(n);return this._resolveOverrides({added:e,updated:o,removed:l,historicMoment:r,isWeak:!0,release:[]})}const[i,a,o]=await Promise.all([this._resolveIdenifiers(e.addedFeatures),this._resolveIdenifiers(e.updatedFeatures),this._resolveIdenifiers(e.deletedFeatures)]);return{type:"override-by-id",updates:[...i,...a],removed:o,historicMoment:r,isWeak:!0}}_canEditByFeature(e){const{adds:t,updates:r}=e.editedFeatures;return t.every(e=>this.view.spatialReference.equals(e.geometry?.spatialReference))&&r.every(e=>this.view.spatialReference.equals(e.current.geometry?.spatialReference))}async updateSchemaStart(){const e=this.layer;"featureReduction"in e&&e.featureReduction&&e.featureReduction!==this._lastFeatureReduction&&(e.featureReduction=e.featureReduction?.clone(),this._lastFeatureReduction=e.featureReduction);try{if(await Promise.allSettled([this._handleChange(),R(e)]),this.destroyed||!this.layerAdapter?.hasRequiredSupport||!this._subscriptions)return null;const t=this.featureContainer.updateStart("subtype-group"===e.type);this._lastFeatureEffect=this.featureEffect;const r={store:t,cimAnalyzer:this.view.stage.cimAnalyzer,cimResourceManager:this.view.stage.painter.textureManager.resourceManager,scaleExpression:void 0},s=await this._createViewSchemaConfig(),i={source:await this.layerAdapter.createSourceSchema(s,this._sourceRefreshVersion),processor:await this.layerAdapter.createProcessorSchema(r,s,this._displayRefreshVersion)};return c(this._lastSchema?.source.strategy,i.source.strategy)||c(this._lastSchema?.processor,i.processor)?(this._lastSchema=i,this._fields=null,i):null}catch(t){}return null}async updateSchemaEnd(e){try{this.featureEffectView.featureEffect=this._lastFeatureEffect,e&&this.featureEffectView.endTransition(),await this.featureContainer.updateEnd(this._lastSchema.processor,this.layerAdapter.getLabelingDeconflictionInfo(),e),has("esri-2d-update-debug")&&console.debug("FeatureLayerView2D.updateEnd")}catch(t){}}async _doUpdate(){const e=Math.round(performance.now()),t=await this.getWorker();await t.pipeline.updateSchema(e),this.requestUpdate()}async _doOverride(e){const t=await this.getWorker();try{let r=new ne;for(const s of e.messages)switch(s.type){case"edit":r.tryAdd(await this._resolveEdit(s.event))||(await t.pipeline.onOverride(r.toMessage()),r=new ne,r.tryAdd(await this._resolveEdit(s.event)));break;case"override":r.tryAdd(this._resolveOverrides(s.options))||(await t.pipeline.onOverride(r.toMessage()),r=new ne,r.tryAdd(this._resolveOverrides(s.options)));break}await t.pipeline.onOverride(r.toMessage())}catch(r){m(r),0}}_getEffectiveAvailableFields(e){const t=me(this._lastAvailableFields,e);return this._lastAvailableFields=t,V(this.layer.fieldsIndex,t)}async _createViewSchemaConfig(){const e=this.requiresCurrentUser?await this.signedInUser:null,t=[E(this.view,this.layerAdapter,this.timeExtent,this._visibilityOverrides,this.filter,this.effectiveDisplayFilterClause),this.featureEffect?.filter?.toJSON()??null];return{availableFields:this._getEffectiveAvailableFields(this.availableFields),displayFilterEnabled:this.displayFilterEnabled,filters:t,scale:this.view.scale,timeZone:this.view.timeZone,timeExtent:this.view.timeExtent,currentUser:e,spatialReference:this.view.spatialReference,extent:this.view.extent,returnZ:this.hasZ,returnM:this.hasM}}_processHighlight(){this._commandsQueue.push({type:"highlight"})}async _updateHighlights(){const e=this._getHighlights(),t=await this.getWorker();if(this.destroyed)return;const r=t.pipeline.updateHighlight({highlights:e}).catch(e=>{m(e)||u.getLogger(this).error(e)});this._updatingHandles.consumePromise(r)}_setOriginForFeature(e){e.layer=e.sourceLayer=this.layer,this.layerAdapter.setGraphicOrigin(e)}_createFeatureGraphicHit(e,t){return this._setOriginForFeature(t),this._createGraphicHit(e,t)}_createTrackGraphicHit(e,t){return t.layer=t.sourceLayer=this.layer,this.layerAdapter.setTrackGraphicOrigin?.(t),this._createGraphicHit(e,t)}_createAggregateGraphicHit(e,t){return t.layer=t.sourceLayer=this.layer,this.layerAdapter.setAggregateGraphicOrigin?.(t),this._createGraphicHit(e,t)}_createGraphicHit(e,t){return null!=t.geometry&&(t.geometry.spatialReference=this.view.spatialReference),{type:"graphic",graphic:t,layer:this.layer,mapPoint:e}}};function E(e,t,r,s,i,a){i&&(i=i.clone());const o=null!=i?i.timeExtent:null,n=null!=r&&null!=o?r.intersection(o):r||o;n&&(i??=new U,i.timeExtent=n),i=t.addFilters?.(i,e)??i,a&&(i??=new U,i.where=v(i.where,a));let l=i?.toJSON()??null;return s.size&&(l??=(new U).toJSON(),l.hiddenIds=Array.from(s)),l}return e([b()],_.prototype,"_commandsQueue",void 0),e([b()],_.prototype,"_sourceRefreshVersion",void 0),e([b()],_.prototype,"_displayRefreshVersion",void 0),e([b({readOnly:!0})],_.prototype,"_pipelineUpdating",void 0),e([b()],_.prototype,"_sourceUpdating",void 0),e([b({readOnly:!0})],_.prototype,"dataUpdating",null),e([b({readOnly:!0})],_.prototype,"hasAllFeatures",null),e([b({readOnly:!0})],_.prototype,"hasAllFeaturesInView",null),e([b({readOnly:!0})],_.prototype,"hasFullGeometries",null),e([b()],_.prototype,"featureEffectView",void 0),e([b()],_.prototype,"layerAdapter",null),e([b({readOnly:!0})],_.prototype,"timeExtent",null),_=e([S("esri.views.2d.layers.FeatureLikeLayerView2D")],_),_};export{ve as FeatureLikeLayerView2D};
|
|
2
|
+
import{__decorate as e}from"tslib";import t from"../../../AggregateGraphic.js";import r from"../../../Graphic.js";import s from"../../../TrackGraphic.js";import{isSome as i}from"../../../core/arrayUtils.js";import a from"../../../core/Collection.js";import o from"../../../core/Error.js";import{makeHandle as n,handlesGroup as l}from"../../../core/handleUtils.js";import has from"../../../core/has.js";import u from"../../../core/Logger.js";import{destroyMaybe as h}from"../../../core/maybe.js";import{notDeepEqual as c}from"../../../core/object.js";import{createAbortError as p,ignoreAbortErrors as d,throwIfNotAbortError as y,isAbortError as m}from"../../../core/promiseUtils.js";import{watch as g,sync as f}from"../../../core/reactiveUtils.js";import{isScreenRect as w}from"../../../core/screenUtils.js";import{sqlAnd as v}from"../../../core/sql.js";import{getMetersPerUnitForSR as _}from"../../../core/units.js";import{property as b,subclass as S}from"../../../core/accessorSupport/decorators.js";import{UpdatingHandles as A}from"../../../core/support/UpdatingHandles.js";import F from"../../../geometry/Extent.js";import{fromJSON as j}from"../../../geometry/support/jsonUtils.js";import x from"../../../geometry/support/rotate.js";import{isCurvedGeometry as E}from"../../../geometry/support/curves/curveUtils.js";import{densifyCurvedGeometry as I}from"../../../geometry/support/curves/densifyCurvedGeometry.js";import k from"../../../layers/effects/FeatureEffectView.js";import{convertFromFeature as O}from"../../../layers/graphics/featureConversionUtils.js";import U from"../../../layers/support/FeatureFilter.js";import{checkServiceCurrentUserSupport as R}from"../../../layers/support/featureLayerUtils.js";import{packFields as V}from"../../../layers/support/fieldUtils.js";import{getEffectiveLayerCapabilities as C}from"../../../layers/support/layerUtils.js";import{combineTimeExtent as Q}from"../../../layers/support/timeSupport.js";import q from"../../../rest/support/AggregateFeatureSet.js";import M from"../../../rest/support/AttributeBinsFeatureSet.js";import H from"../../../rest/support/AttributeBinsQuery.js";import P from"../../../rest/support/FeatureSet.js";import L from"../../../rest/support/Query.js";import{HittestDrawHelper as T}from"../../../symbols/cim/CIMSymbolDrawHelper.js";import{symbolToCIM as W}from"../../../symbols/cim/CIMSymbolHelper.js";import{getDisplayedSymbol as D}from"../../../symbols/support/symbolUtils.js";import{LayerView2D as G}from"./LayerView2D.js";import{FeatureContainer as N}from"./features/FeatureContainer.js";import{createFeaturePipelineWorkerProxy as J}from"./features/FeaturePipelineWorkerProxy.js";import{FeatureSourceEventLog as z}from"./features/FeatureSourceEventLog.js";import{AnnotationLayerAdapter as B}from"./features/layerAdapters/AnnotationLayerAdapter.js";import{CatalogFootprintLayerAdapter as Z}from"./features/layerAdapters/CatalogFootprintLayerAdapter.js";import{DimensionLayerAdapter as K}from"./features/layerAdapters/DimensionLayerAdapter.js";import{FeatureLayerAdapter as $}from"./features/layerAdapters/FeatureLayerAdapter.js";import{createFeatureIdInfo as X}from"./features/layerAdapters/featureServiceUtils.js";import{InMemoryLayerAdapter as Y}from"./features/layerAdapters/InMemoryLayerAdapter.js";import{KnowledgeGraphSublayerAdapter as ee}from"./features/layerAdapters/KnowledgeGraphSublayerAdapter.js";import{OGCFeatureLayerAdapter as te}from"./features/layerAdapters/OGCFeatureLayerAdapter.js";import{OrientedImageryLayerAdapter as re}from"./features/layerAdapters/OrientedImageryLayerAdapter.js";import{ParquetLayerAdapter as se}from"./features/layerAdapters/ParquetLayerAdapter.js";import{StreamLayerAdapter as ie}from"./features/layerAdapters/StreamLayerAdapter.js";import{SubtypeGroupLayerAdapter as ae}from"./features/layerAdapters/SubtypeGroupLayerAdapter.js";import{createComplexSymbolInstances as oe}from"./features/schema/processor/symbols/ComplexSymbolSchema.js";import{DebouncedFeatureOverride as ne}from"./support/DebouncedFeatureOverride.js";import{FeatureCommandQueue as le}from"./support/FeatureCommandQueue.js";import{handleNoEngineError as ue}from"./support/handleNoEngineError.js";import{toJSONGeometryType as he}from"./support/util.js";import{getMapPointsFromScreen as ce}from"../support/hitTestUtils.js";import{FeatureTileSubscriptionManager as pe}from"../tiling/FeatureTileSubscriptionManager.js";import{RefreshableLayerView as de}from"../../layers/RefreshableLayerView.js";import{getHighlightName as ye}from"../../support/highlightOptionsUtils.js";function me(e,t){const r=new Set;return e&&e.forEach(e=>r.add(e)),t&&t.forEach(e=>r.add(e)),r.has("*")?["*"]:Array.from(r)}const ge=4294967294;function fe(e,t){return l(e.map(e=>g(()=>{const t=e();return t&&"object"==typeof t?"getTime"in t&&"function"==typeof t.getTime?t.getTime():JSON.stringify(t):t},t,f)))}function we(e){if(!e.geometry)return e;if(!E(e.geometry))return e;const t=.001/_(e.geometry.spatialReference),r=100;return{geometry:I(e.geometry,{maxSegmentsPerCurve:12e3,maxSegmentLength:r*t,maxDeviation:0}),attributes:e.attributes}}const ve=l=>{const f=de(G(l));let _=class extends f{constructor(){super(...arguments),this._commandsQueue=new le({process:e=>{switch(e.type){case"override-batch":return this._doOverride(e);case"update":return this._doUpdate();case"highlight":return this._updateHighlights()}}}),this._visibilityOverrides=new Set,this._lastAvailableFields=[],this._lastTargetState=null,this.eventLog=new z,this._sourceRefreshVersion=1,this._displayRefreshVersion=1,this._pipelineUpdating=!1,this._editUpdatingHandles=new A,this._fields=null,this._hittestDrawHelper=null,this._sourceUpdating=!1,this.featureEffectView=new k}destroy(){this._editUpdatingHandles.destroy(),this._workerProxy?.destroy(),this._workerAttached.reject(p()),this._commandsQueue.destroy(),this._hittestDrawHelper?.destroy()}initialize(){this._workerAttached=Promise.withResolvers(),d(this._workerAttached.promise),this.addResolvingPromise(this._initProxy()),this.featureEffectView.featureEffect=this.featureEffect,this.featureEffectView.endTransition()}async _initProxy(){const e=this.layer;if("isTable"in e&&e.isTable)throw new o("featurelayerview:table-not-supported","table feature layer can't be displayed",{layer:e});if(("feature"===e.type||"subtype-group"===e.type)&&!1===C(e)?.operations.supportsQuery)throw new o("featurelayerview:query-not-supported","layer view requires a layer with query capability",{layer:e});this._workerProxy&&this._workerProxy.destroy();const t=this._createClientOptions();this._workerProxy=await J(t)}async _attachProxy(){const e=x(this.view.extent,this.view.rotation,this.view.center),t={tileInfoJSON:this.view?.featuresTilingScheme?.tileInfo?.toJSON(),initialViewExtent:e.toJSON()};try{await this._workerProxy.pipeline.onAttach(t),this._workerAttached.resolve()}catch(r){this._workerAttached.reject(p()),y(r)}}async _detachProxy(){return this._workerProxy.pipeline.onDetach()}async getWorker(){return await this._workerAttached.promise,this._workerProxy}get dataUpdating(){return this._sourceUpdating||this._editUpdatingHandles.updating}get hasAllFeatures(){return this.layer.visible&&!this.suspended&&this.eventLog.hasAllData&&this.eventLog.willQueryAllFeatures}get hasAllFeaturesInView(){const e=this.effectiveDisplayFilter?.where||null,t=!this.eventLog.willQueryAllFeatures&&null!=e&&"1=1"!==e;return this.layer.visible&&!this.suspended&&this.eventLog.hasAllData&&!t}get hasFullGeometries(){return this.layer.visible&&!this.suspended&&this.eventLog.hasAllData&&this.eventLog.willQueryFullResolutionGeometry}get layerAdapter(){switch(this.layer.type){case"annotation-feature":return new B(this.layer);case"dimension-feature":return new K(this.layer);case"feature":return"memory"===this.layer.source.type?new Y(this.layer):new $(this.layer);case"geojson":case"csv":case"wfs":return new Y(this.layer);case"parquet":return new se(this.layer);case"subtype-group":return new ae(this.layer);case"ogc-feature":return new te(this.layer);case"stream":return new ie(this.layer);case"oriented-imagery":return new re(this.layer);case"knowledge-graph-sublayer":return new ee(this.layer);case"catalog-footprint":return new Z(this.layer);default:this.layer}return null}get timeExtent(){return Q(this.layerAdapter.timeOptions,this.view?.timeExtent,this._get("timeExtent"))}get usedMemory(){return this.container.usedMemory+this.eventLog.pipelineStatistics.usedMemory}getDisplayStatistics(e,t){return this.featureContainer?.getDisplayStatistics(e,t)}highlight(e,t){let s;e instanceof r?s=[e.getObjectId()]:"number"==typeof e||"string"==typeof e?s=[e]:a.isCollection(e)&&e.length>0?s=e.map(e=>e?.getObjectId()).toArray():Array.isArray(e)&&e.length>0&&(s="number"==typeof e[0]||"string"==typeof e[0]?e:e.map(e=>e?.getObjectId()));const o=s?.filter(i);if(!o?.length)return n();const l=ye(t);return this._addHighlights(o,l),n(()=>!this.destroyed&&this._removeHighlights(o,l))}async hitTest(e,i){const a=w(i),{trueHitIds:o,candidateHitIds:n}=await this.featureContainer.hitTest(i),l=await this.getWorker(),[u,h]=await Promise.all([l.pipeline.getDisplayFeatures(n),l.pipeline.getDisplayFeatures(o)]),{features:c,aggregates:p,tracks:d}=u,{features:y,aggregates:g,tracks:f}=h,v=[];if(a&&this.hasRenderer()){const e=new Map,t=new r;for(const r of c){t.attributes=r.attributes,t.geometry=j(r.geometry),t.symbol=null;const s=this.layerAdapter.getRenderer(t);if(!s){v.push(r);continue}const i=await D(t,{renderer:s,scale:this.view.scale,resolution:this.view.resolution,spatialReference:this.view.spatialReference,viewingMode:"2d",timeZone:this.view.timeZone});if(!i)continue;let a=null;const o=W(i);if("web-style"===o.type)try{const e=W(await o.fetchSymbol({acceptedFormats:["cim","web"]}));a="web-style"===e.type?null:e}catch(x){m(x),0;continue}else a=o;const n=a?.symbol;if(!n)continue;const l=this.view.stage.cimAnalyzer.analyzeSymbolReference(a,!1).some(e=>"alignment"in e&&0===e.alignment);e.set(r,{cimSymbol:n,isScreenAligned:l})}e.size>0&&!this._hittestDrawHelper&&(this._hittestDrawHelper=new T(this.view.stage.painter.textureManager.resourceManager));const{resolution:s,rotation:a}=this.view.state,o=ce(this.view,i);for(const[r,{cimSymbol:i,isScreenAligned:n}]of e){if(!r)continue;const e={hittestType:"rect",textInfo:null,mapRotation:a,resolution:s,searchDist:0,isScreenAligned:n};this._hittestDrawHelper.hitTest(o,i,r.geometry,e)&&v.push(r)}}else v.push(...c);const _=[...y,...v],b=[...g,...p],S=[...f,...d],A=this.featureContainer.getSortKeys(_.map(e=>e.displayId)),F=({displayId:e},{displayId:t})=>A.has(e)&&A.has(t)?A.get(e)-A.get(t):e-t;return _.sort(F).reverse(),b.sort(F).reverse(),[...b.map(r=>this._createAggregateGraphicHit(e,t.fromJSON(r))),...S.map(t=>this._createTrackGraphicHit(e,s.fromJSON(t))),..._.map(t=>this._createFeatureGraphicHit(a?null:e,r.fromJSON(t)))]}async queryAggregateSummaryStatistics(e,t,r){const s={...t,scale:this.view.scale},i=(await this.getWorker()).aggregates.executeQueryForSummaryStatistics(this._cleanUpAggregateQuery(e),s,r);return ue(i,{})}async queryUniqueValues(e,t,r){const s=await this.getWorker(),i={...t,scale:this.view.scale},a=s.features.executeQueryForUniqueValues(this._cleanUpQuery(e),i,r);return ue(a,{uniqueValueInfos:[]})}async queryAggregateUniqueValues(e,t,r){const s=await this.getWorker(),i={...t,scale:this.view.scale},a=s.aggregates.executeQueryForUniqueValues(this._cleanUpAggregateQuery(e),i,r);return ue(a,{uniqueValueInfos:[]})}async queryAggregateClassBreaks(e,t,r){const s=await this.getWorker(),i={...t,scale:this.view.scale},a=s.aggregates.executeQueryForClassBreaks(this._cleanUpAggregateQuery(e),i,r);return ue(a,{classBreakInfos:[]})}async queryHistogram(e,t,r){const s=await this.getWorker(),i={...t,scale:this.view.scale},a=s.features.executeQueryForHistogram(this._cleanUpQuery(e),i,r);return ue(a,{bins:[],maxValue:null,minValue:null,normalizationTotal:null})}async queryAggregateCount(e,t){const r=(await this.getWorker()).aggregates.executeQueryForCount(this._cleanUpAggregateQuery(e),t);return ue(r,0)}async queryAggregateHistogram(e,t,r){const s=await this.getWorker(),i={...t,scale:this.view.scale},a=s.aggregates.executeQueryForHistogram(this._cleanUpAggregateQuery(e),i,r);return ue(a,{bins:[],maxValue:null,minValue:null,normalizationTotal:null})}async queryAggregateIds(e,t){const r=(await this.getWorker()).aggregates.executeQueryForIds(this._cleanUpAggregateQuery(e),t);return ue(r,[])}async queryAggregateJSON(e,t){const r=(await this.getWorker()).aggregates.executeQuery(this._cleanUpAggregateQuery(e),t);return ue(r,{features:[]})}async queryAttributeBins(e,t){const r=(await this.getWorker()).features.executeAttributeBinsQuery(this._cleanUpAttributeBinsQuery(e),t),s=await ue(r,{features:[]});return M.fromJSON(s)}async queryAggregates(e,t){const r=(await this.getWorker()).aggregates.executeQuery(this._cleanUpAggregateQuery(e),t),s=await ue(r,{features:[]}),i=q.fromJSON(s);return i.features.forEach(e=>this.layerAdapter.setAggregateGraphicOrigin?.(e)),i}async queryClassBreaks(e,t,r){const s=await this.getWorker(),i={...t,scale:this.view.scale},a=s.features.executeQueryForClassBreaks(this._cleanUpQuery(e),i,r);return ue(a,{classBreakInfos:[]})}async queryExtent(e,t){const r=(await this.getWorker()).features.executeQueryForExtent(this._cleanUpQuery(e),t),s=await ue(r,{count:0,extent:null});return{count:s.count,extent:F.fromJSON(s.extent)}}async queryFeatureCount(e,t){const r=(await this.getWorker()).features.executeQueryForCount(this._cleanUpQuery(e),t);return ue(r,0)}queryFeatures(e,t){return this.queryFeaturesJSON(e,t).then(e=>{const t=P.fromJSON(e);return t.features.forEach(e=>this._setOriginForFeature(e)),t})}async queryFeaturesJSON(e,t){const r=(await this.getWorker()).features.executeQuery(this._cleanUpQuery(e),t);return ue(r,{features:[]})}async queryHeatmapStatistics(e){return(await this.getWorker()).pipeline.queryHeatmapStatistics(e)}async queryObjectIds(e,t){const r=(await this.getWorker()).features.executeQueryForIds(this._cleanUpQuery(e),t);return ue(r,[])}async queryStatistics(){const e=await this.getWorker();return ue(e.pipeline.queryStatistics(),{featureCount:0,ringCount:0,vertexCount:0})}async querySummaryStatistics(e,t,r){const s=await this.getWorker(),i={...t,scale:this.view.scale},a=s.features.executeQueryForSummaryStatistics(this._cleanUpQuery(e),i,r);return ue(a,{})}async queryVisibleFeatures(e,t){const r=(await this.getWorker()).pipeline.queryVisibleFeatures(this._cleanUpQuery(e),t),s=await ue(r,{features:[]}),i=P.fromJSON(s);return i.features.forEach(e=>this._setOriginForFeature(e)),i}async getSampleFeatures(e){return(await this.getWorker()).pipeline.getSampleFeatures(e)}setVisibility(e,t){t?this._visibilityOverrides.delete(e):this._visibilityOverrides.add(e),this._update()}update(e){if(!this._subscriptions)return;this.view.animation&&!this._lastTargetState&&(this._lastTargetState=e.state.clone()),!this.view.animation&&this._lastTargetState&&(this._lastTargetState=null);const t=this.featureContainer.getPresenting(),r=this._subscriptions.update(e.targetState,this._lastTargetState,t);r&&(this.featureContainer.updateSubscriptions(r),d(this._updatingHandles.addPromise(this.getWorker().then(e=>e.pipeline.updateSubscriptions(r))))),this._subscriptions.coverage&&this.featureContainer.setCoverage(this._subscriptions.coverage)}attach(){has("esri-2d-update-debug")&&console.debug("FeatureLayerView2D.attach"),d(this._updatingHandles.addPromise(this._workerAttached.promise)),d(this._attachProxy()),this.featureContainer=new N(this),this.container.addChild(this.featureContainer),this.view.timeline.record(`${this.layer.title} (FeatureLayer) Attach`),this._subscriptions=new pe(this.view.featuresTilingScheme),this.requestUpdate(),this.addAttachHandles([fe([()=>this._displayRefreshVersion,()=>"displayFilterInfo"in this.layer&&this.layer.displayFilterInfo,()=>this.timeExtent,()=>this.clips,()=>this.filter,()=>this.effectiveDisplayFilterClause,()=>this.featureEffect,()=>this._sourceRefreshVersion,()=>this.view.timeZone,()=>this.view.timeExtent,...this.layerAdapter.getUpdateHashProperties(this.view)],()=>this._update()),g(()=>this.updateSuspended,e=>{e||this._subscriptions.resume(this.featureContainer.getPresenting())}),g(()=>this.view.stationary,e=>{e&&this.getWorker().then(e=>{if(this.destroyed)return;const t=x(this.view.extent,this.view.rotation,this.view.center);return e.pipeline.updateStationaryExtent(t.toJSON(),this.featureContainer.requiresRefresh)}).catch(()=>{})})]),this._update(),"stream"!==this.layer.type&&"parquet"!==this.layer.type&&"catalog-footprint"!==this.layer.type&&this.addAttachHandles(this.layer.on("edits",e=>this._editUpdatingHandles.addPromise(this._edit(e))))}detach(){has("esri-2d-update-debug")&&console.debug("FeatureLayerView2D.detach"),this._detachProxy(),this._fields=null,this.featureContainer.destroy(),this.featureContainer=null,this._commandsQueue.clear(),this.container.removeAllChildren(),this._subscriptions=h(this._subscriptions),this._workerProxy.pipeline.onDetach(),this._workerAttached=Promise.withResolvers(),d(this._workerAttached.promise),this._lastAvailableFields=[],this._lastSchema=null}viewChange(){this.requestUpdate()}moveEnd(){this.requestUpdate()}addOverrides(e){return this._commandsQueue.push({type:"override",options:{...e,release:[]}})}removeOverrides(e){for(const r of e)if(null==r)throw new o("featurelayerview:bad-override","Tried to remove an override for an invalid objectId",{objectId:r});const t={added:[],updated:[],removed:[],release:e,isWeak:!1,historicMoment:null};return this._commandsQueue.push({type:"override",options:t})}onProxyClientEvent(e){}hasRenderer(){return"renderer"in this.layer&&null!=this.layer.renderer}isUpdating(){const e=this.hasRenderer(),t=this._commandsQueue.updateTracking.updating,r=null!=this._updatingRequiredPromise,s=this.featureContainer.updating;return this.updateRequested||e&&(t||r)||s||this._pipelineUpdating||this.dataUpdating}_createClientOptions(){const e=this;return{updateSchemaStart:()=>e.updateSchemaStart(),updateSchemaEnd:t=>e.updateSchemaEnd(t),openMemoryPorts:async()=>{if(this.layerAdapter?.openMessagePorts){const e=await this.layerAdapter.openMessagePorts();return{result:e,transferList:e}}throw new Error("InternalError: Layer adapter does not support opening message ports")},get container(){return e.featureContainer},setUpdating:e=>{this._set("_pipelineUpdating",e.pipeline),this._set("_sourceUpdating",e.source)},emitEvent:e=>{this.onProxyClientEvent(e)},get eventLog(){return e.eventLog},fetch:async t=>{if(has("esri-2d-stabilize-glyphs")){const r=[];for(const s of t)r.push(await e.view.stage.painter.textureManager.rasterizeItem(s));return r}return Promise.all(t.map(t=>e.view.stage.painter.textureManager.rasterizeItem(t)))},fetchDictionary:e=>Promise.all(e.map(e=>this._fetchDictionaryRequest(e))),fetchMesh:e=>Promise.all(e.map(e=>this._fetchMeshRequest(e)))}}async _fetchDictionaryRequest(e){try{if(!("renderer"in this.layer)||!this.layer.renderer||"dictionary"!==this.layer.renderer.type)throw new Error("InternalError: Expected renderer to be of type 'dictionary'");const t=this.layer.renderer,r=this._lastSchema.processor.mesh.factory.symbology;if("dictionary"!==r.type)throw new Error("InternalError: Expected schema to be of type 'dictionary'");const s={cimAnalyzer:this.view.stage.cimAnalyzer,cimResourceManager:this.view.stage.painter.textureManager.resourceManager,store:this.featureContainer.instanceStore,scaleExpression:r.scaleExpression};this._fields||(this._fields=this.layer.fields.map(e=>e.toJSON()));const i=r.visualVariableUniforms,a=he(this.layer.geometryType),o=await t.getSymbolForControlString(e.controlString,a,!1);if(!o||!o.data)return{type:"dictionary-response",meshes:[]};return{type:"dictionary-response",meshes:await oe({...o.data,hasTextStringTemplates:!0},{uniforms:i,path:"renderer",schemaOptions:s})}}catch(t){return{type:"dictionary-response",meshes:[]}}}async _fetchMeshRequest(e){const{layer:t}=this;try{const r={cimAnalyzer:this.view.stage.cimAnalyzer,cimResourceManager:this.view.stage.painter.textureManager.resourceManager,store:this.featureContainer.instanceStore,scaleExpression:null};this._fields||(this._fields=t.fields.map(e=>e.toJSON()));return{type:"mesh-response",meshes:await oe({...e.symbolReference,hasTextStringTemplates:!0},{path:"anno-like",schemaOptions:r,uniforms:{visualVariableColor:null,visualVariableOpacity:null,visualVariableRotation:null,visualVariableSizeStops:null,visualVariableSizeScaleStops:null,visualVariableSizeOutlineScaleStops:null,visualVariableSizeUnitValue:null,visualVariableSizeMinMaxValue:null}})}}catch(r){return{type:"mesh-response",meshes:[]}}}_cleanUpQuery(e){const t=L.from(e)||this.createQuery();return t.outSpatialReference||(t.outSpatialReference=this.view.spatialReference),"returnZ"in this.layer&&(t.returnZ??=this.layer.returnZ),"returnM"in this.layer&&(t.returnM??=this.layer.returnM),t.toJSON()}_cleanUpAttributeBinsQuery(e){const t=H.from(e);return t.outSpatialReference||(t.outSpatialReference=this.view.spatialReference),t.toJSON()}_cleanUpAggregateQuery(e){const t=L.from(e)||this.createAggregateQuery();t.outSpatialReference||(t.outSpatialReference=this.view.spatialReference);const r=t.objectIds??[];for(const s of t.aggregateIds??[])r.push(s);return t.objectIds=r,t.aggregateIds=[],t.toJSON()}async _update(){return this._commandsQueue.push({type:"update"})}_edit(e){return this._commandsQueue.push({type:"edit",event:e})}async doRefresh(e){this.attached&&(this.updateSuspended&&e||(e?this.incrementSourceRefreshVersion():this.incrementDisplayRefreshVersion()))}incrementSourceRefreshVersion(){this._sourceRefreshVersion=(this._sourceRefreshVersion+1)%ge+1}incrementDisplayRefreshVersion(){this._displayRefreshVersion=(this._displayRefreshVersion+1)%ge+1}async _resolveIdenifiers(e){const t=[],r=[];for(const a of e)null==a.objectId||-1===a.objectId?null==a.globalId?u.getLogger(this).warn("mapview-apply-edits","A feature identifier must contain either a GlobalId or ObjectId. Ignoring",{identifier:a}):r.push(a.globalId):t.push(a.objectId);const s="globalIdField"in this.layer&&this.layer.globalIdField,i=s&&this.availableFields.includes(s);if(r.length&&!i)return u.getLogger(this).error(new o("mapview-apply-edits",`Editing the specified service requires the layer's globalIdField, ${s} to be included the layer's outFields for updates to be reflected on the map`)),t;if(r.length){const e=await this._workerProxy.pipeline.getObjectIdsFromGlobalIds(r);for(const r of e)t.push(r)}return t}_resolveOverrides(e){const t=!1,r=!1,s=he(this.layer.geometryType),i=X(this.layer),a=[];for(const n of e.added){const e=O(we(n),s,t,r,i);if(null==e.objectId)throw new o("featurelayerview:bad-override","Feature does not have an objectId",{feature:n});a.push(e)}for(const n of e.updated){const e=O(we(n),s,t,r,i);if(null==e.objectId)throw new o("featurelayerview:bad-override","Feature does not have an objectId",{feature:n});a.push(e)}for(const n of e.removed)if(null==n)throw new o("featurelayerview:bad-override","Tried to remove an invalid objectId",{objectId:n});return{type:"override",updates:a,removed:e.removed,release:e.release,isWeak:e.isWeak??!1,historicMoment:e.historicMoment??null}}async _resolveEdit(e){const t=this.layer,r=e.historicMoment?.getTime()??null,s="layerId"in t&&e.editedFeatures?.find(e=>e.layerId===t.layerId);if(s&&this._canEditByFeature(s)){const{adds:e,deletes:t,updates:i}=s.editedFeatures,a=this.layer.objectIdField,o=i.map(e=>e.current),n=t.map(e=>"attributes"in e?{objectId:a?e.attributes[a]:null}:e),l=await this._resolveIdenifiers(n);return this._resolveOverrides({added:e,updated:o,removed:l,historicMoment:r,isWeak:!0,release:[]})}const[i,a,o]=await Promise.all([this._resolveIdenifiers(e.addedFeatures),this._resolveIdenifiers(e.updatedFeatures),this._resolveIdenifiers(e.deletedFeatures)]);return{type:"override-by-id",updates:[...i,...a],removed:o,historicMoment:r,isWeak:!0}}_canEditByFeature(e){const{adds:t,updates:r}=e.editedFeatures;return t.every(e=>this.view.spatialReference.equals(e.geometry?.spatialReference))&&r.every(e=>this.view.spatialReference.equals(e.current.geometry?.spatialReference))}async updateSchemaStart(){const e=this.layer;"featureReduction"in e&&e.featureReduction&&e.featureReduction!==this._lastFeatureReduction&&(e.featureReduction=e.featureReduction?.clone(),this._lastFeatureReduction=e.featureReduction);try{if(await Promise.allSettled([this._handleChange(),R(e)]),this.destroyed||!this.layerAdapter?.hasRequiredSupport||!this._subscriptions)return null;const t=this.featureContainer.updateStart("subtype-group"===e.type);this._lastFeatureEffect=this.featureEffect;const r={store:t,cimAnalyzer:this.view.stage.cimAnalyzer,cimResourceManager:this.view.stage.painter.textureManager.resourceManager,scaleExpression:void 0},s=await this._createViewSchemaConfig(),i={source:await this.layerAdapter.createSourceSchema(s,this._sourceRefreshVersion),processor:await this.layerAdapter.createProcessorSchema(r,s,this._displayRefreshVersion)};return c(this._lastSchema?.source.strategy,i.source.strategy)||c(this._lastSchema?.processor,i.processor)?(this._lastSchema=i,this._fields=null,i):null}catch(t){}return null}async updateSchemaEnd(e){try{this.featureEffectView.featureEffect=this._lastFeatureEffect,e&&this.featureEffectView.endTransition(),await this.featureContainer.updateEnd(this._lastSchema.processor,this.layerAdapter.getLabelingDeconflictionInfo(),e),has("esri-2d-update-debug")&&console.debug("FeatureLayerView2D.updateEnd")}catch(t){}}async _doUpdate(){const e=Math.round(performance.now()),t=await this.getWorker();await t.pipeline.updateSchema(e),this.requestUpdate()}async _doOverride(e){const t=await this.getWorker();try{let r=new ne;for(const s of e.messages)switch(s.type){case"edit":r.tryAdd(await this._resolveEdit(s.event))||(await t.pipeline.onOverride(r.toMessage()),r=new ne,r.tryAdd(await this._resolveEdit(s.event)));break;case"override":r.tryAdd(this._resolveOverrides(s.options))||(await t.pipeline.onOverride(r.toMessage()),r=new ne,r.tryAdd(this._resolveOverrides(s.options)));break}await t.pipeline.onOverride(r.toMessage())}catch(r){m(r),0}}_getEffectiveAvailableFields(e){const t=me(this._lastAvailableFields,e);return this._lastAvailableFields=t,V(this.layer.fieldsIndex,t)}async _createViewSchemaConfig(){const e=this.requiresCurrentUser?await this.signedInUser:null,t=[E(this.view,this.layerAdapter,this.timeExtent,this._visibilityOverrides,this.filter,this.effectiveDisplayFilterClause),this.featureEffect?.filter?.toJSON()??null];return{availableFields:this._getEffectiveAvailableFields(this.availableFields),displayFilterEnabled:this.displayFilterEnabled,filters:t,scale:this.view.scale,timeZone:this.view.timeZone,timeExtent:this.view.timeExtent,currentUser:e,spatialReference:this.view.spatialReference,extent:this.view.extent,returnZ:this.hasZ,returnM:this.hasM}}_processHighlight(){this._commandsQueue.push({type:"highlight"})}async _updateHighlights(){const e=this._getHighlights(),t=await this.getWorker();if(this.destroyed)return;const r=t.pipeline.updateHighlight({highlights:e}).catch(e=>{m(e)||u.getLogger(this).error(e)});this._updatingHandles.consumePromise(r)}_setOriginForFeature(e){e.layer=e.sourceLayer=this.layer,this.layerAdapter.setGraphicOrigin(e)}_createFeatureGraphicHit(e,t){return this._setOriginForFeature(t),this._createGraphicHit(e,t)}_createTrackGraphicHit(e,t){return t.layer=t.sourceLayer=this.layer,this.layerAdapter.setTrackGraphicOrigin?.(t),this._createGraphicHit(e,t)}_createAggregateGraphicHit(e,t){return t.layer=t.sourceLayer=this.layer,this.layerAdapter.setAggregateGraphicOrigin?.(t),this._createGraphicHit(e,t)}_createGraphicHit(e,t){return null!=t.geometry&&(t.geometry.spatialReference=this.view.spatialReference),{type:"graphic",graphic:t,layer:this.layer,mapPoint:e}}};function E(e,t,r,s,i,a){i&&(i=i.clone());const o=null!=i?i.timeExtent:null,n=null!=r&&null!=o?r.intersection(o):r||o;n&&(i??=new U,i.timeExtent=n),i=t.addFilters?.(i,e)??i,a&&(i??=new U,i.where=v(i.where,a));let l=i?.toJSON()??null;return s.size&&(l??=(new U).toJSON(),l.hiddenIds=Array.from(s)),l}return e([b()],_.prototype,"_commandsQueue",void 0),e([b()],_.prototype,"_sourceRefreshVersion",void 0),e([b()],_.prototype,"_displayRefreshVersion",void 0),e([b({readOnly:!0})],_.prototype,"_pipelineUpdating",void 0),e([b()],_.prototype,"_sourceUpdating",void 0),e([b({readOnly:!0})],_.prototype,"dataUpdating",null),e([b({readOnly:!0})],_.prototype,"hasAllFeatures",null),e([b({readOnly:!0})],_.prototype,"hasAllFeaturesInView",null),e([b({readOnly:!0})],_.prototype,"hasFullGeometries",null),e([b()],_.prototype,"featureEffectView",void 0),e([b()],_.prototype,"layerAdapter",null),e([b({readOnly:!0})],_.prototype,"timeExtent",null),_=e([S("esri.views.2d.layers.FeatureLikeLayerView2D")],_),_};export{ve as FeatureLikeLayerView2D};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
import e from"../../../../../../../core/Logger.js";import{pt2px as a}from"../../../../../../../core/screenUtils.js";import{generateGradient as i}from"../../../../../../../renderers/support/heatmapUtils.js";import l from"../../../../../../../symbols/SimpleFillSymbol.js";import r from"../../../../../../../symbols/SimpleLineSymbol.js";import t from"../../../../../../../symbols/SimpleMarkerSymbol.js";import{CIMSymbolHelper as o,slsDashToTemplateArray as s}from"../../../../../../../symbols/cim/CIMSymbolHelper.js";import{getSDFInfo as n}from"../../../../../../../symbols/cim/SDFHelper.js";import{getAlignmentFromPlacement as u}from"../../../../../engine/webgl/alignmentUtils.js";import{writeColor as c}from"../../../../../engine/webgl/color.js";import{dotDensityMaxFields as p}from"../../../../../engine/webgl/definitions.js";import{Techniques as f}from"../../../../../engine/webgl/shaderGraph/techniques/TechniqueRegistry.js";import{maxPieChartFields as b}from"../../../../../engine/webgl/shaderGraph/techniques/pieChart/PieChartShader.js";import{premultiplyColor as m}from"../schemaUtils.js";import{createVisualVariableUniforms as S,getMaxSizeVVSize as V,noVisualVariables as y}from"../VisualVariablesSchema.js";import{createComplexSymbolInstances as v}from"./ComplexSymbolSchema.js";import{hasSizeVVUniform as h,hasRotationVVUniform as z}from"./utils.js";async function d(a,i){if(!a)return[];switch(a.type){case"simple-fill":return U(a,i);case"picture-fill":return F(a,i);case"simple-marker":return I(a,i);case"picture-marker":return w(a,i);case"simple-line":return P(a,i,!1);case"text":return A(a,i);case"label":return L(a,i);case"cim":return v(a.data,i);case"web-style":return d(await a.fetchSymbol({acceptedFormats:["cim","web"]}),i);case"line-3d":return e.getLogger("esri.views.layers.FeatureLayerView").warn("unsupported-symbol",`Symbol of type "${a.type}" unsupported in MapView. Defaulting to simple-line`),P(new r,i,!1);case"point-3d":return e.getLogger("esri.views.layers.FeatureLayerView").warn("unsupported-symbol",`Symbol of type "${a.type}" unsupported in MapView. Defaulting to simple-marker`),I(new t,i);case"polygon-3d":return e.getLogger("esri.views.layers.FeatureLayerView").warn("unsupported-symbol",`Symbol of type "${a.type}" unsupported in MapView. Defaulting to simple-fill`),U(new l,i);case"mesh-3d":case"label-3d":return e.getLogger("esri.views.layers.FeatureLayerView").warn("unsupported-symbol",`Symbol of type "${a.type}" unsupported in MapView. Ignoring`),[];case"CIMSymbolReference":throw new Error("InternalError: CIMSymbolReference should already be resolved")}}async function g(e,a){const{schemaOptions:i}=a,{store:r}=i,t=new Array(p),o=new Array(p/4);for(let l=0;l<p;l++){const a=l<e.attributes.length?e.attributes[l].color:null;t[l]=[0,0,0,0],c(t[l],a)}for(let l=0;l<p/4;l++)o[l]=[0,0,0,0],o[l][0]=4*l<e.attributes.length?1:0,o[l][1]=4*l+1<e.attributes.length?1:0,o[l][2]=4*l+2<e.attributes.length?1:0,o[l][3]=4*l+3<e.attributes.length?1:0;const s={uniforms:{isActive:o,colors:t,dotValue:e.dotValue,dotScale:e.referenceScale,blending:e.dotBlendingEnabled,dotSize:e.dotSize,seed:e.seed},optionalAttributes:{}},n=r.ensureInstance(f.dotDensity,s).createMeshInfo({effects:null}),u=[],b=new l({color:e.backgroundColor??[0,0,0,0],outline:null}),m=await d(b,a);if(u.push(...m),u.push(n),e.outline){const i=P(e.outline,a,!0);u.push(...i)}return u}async function M(e,l){const{store:r}=l,{radius:t,minDensity:o,maxDensity:s,referenceScale:n,field:u,valueExpression:c,colorStops:p}=e,b=i(p);return[r.ensureInstance(f.heatmap,{uniforms:{radius:a(t),minDensity:o,maxDensity:s,referenceScale:n,isFieldActive:!(!u&&!c),gradient:b,gradientHash:b.join(",")},optionalAttributes:{}}).createMeshInfo({effects:null})]}async function C(e,i){const{store:l}=i,r=e.outline?.width||0,t=S(e),o=Math.min(e.attributes.length,b),s=e.attributes.slice(0,o).map(e=>m(e.color));for(;s.length<b;)s.push([0,0,0,0]);const n=l.ensureInstance(f.pieChart,{uniforms:{shader:{chart:{outlineWidth:Math.round(a(r)),defaultColor:m(e.defaultColor),outlineColor:m(e.outline?.color),othersColor:m(e.othersCategory?.color),donutRatio:e.holePercentage,sectorThreshold:e.othersCategory?.threshold||0,colors:s,fieldCount:o},visualVariableOpacity:t.visualVariableOpacity,visualVariableSizeMinMaxValue:t.visualVariableSizeMinMaxValue,visualVariableSizeScaleStops:t.visualVariableSizeScaleStops,visualVariableSizeStops:t.visualVariableSizeStops,visualVariableSizeUnitValue:t.visualVariableSizeUnitValue}},optionalAttributes:{zoomRange:!0}}).createMeshInfo({size:e.size,outlineWidth:r,effects:null,scaleInfo:null,minPixelBuffer:V(t)});return[...e.backgroundFillSymbol?await U(e.backgroundFillSymbol,{schemaOptions:i,uniforms:y}):[],n]}function x(e){if("path"===e.style){if(null==e.path)throw new Error("Symbol with a style of type path must define a path");return{type:"sprite-rasterization-param",overrides:[],resource:{type:"path",path:e.path,asFill:!0}}}const a=o.fromSimpleMarker(e);if("outline"in e&&e.outline&&"none"!==e.outline.style){if("solid"!==e.outline.style){if(!a||!a.symbolLayers)throw new Error("Error handling marker! ");return{type:"sprite-rasterization-param",resource:a.symbolLayers[0],overrides:[]}}}return{type:"sprite-rasterization-param",resource:n(a),overrides:[]}}async function I(e,a){const{uniforms:i,schemaOptions:l}=a,{store:r}=l;if("path"===e.style||e.outline&&"solid"!==e.outline.style&&"none"!==e.outline.style){const l=o.fromSimpleMarker(e);if(!l||!l.symbolLayers)throw new Error("Error handling marker! ");if(i.visualVariableRotation&&(l.angleAlignment="Map"),"path"!==e.style){const e=l.symbolLayers[0];if(h(a.uniforms)){const i=V(a.uniforms,0,1);if(i>e.size){const a=i/e.size;e.size=i;const l=e.markerGraphics?.[0].symbol;(l.symbolLayers&&l.symbolLayers[0]).width*=a}}}return v({type:"CIMSymbolReference",symbol:l},a)}const t=r.ensureInstance(f.marker,{uniforms:{visualVariableColor:i.visualVariableColor,visualVariableOpacity:i.visualVariableOpacity,visualVariableSizeMinMaxValue:i.visualVariableSizeMinMaxValue,visualVariableSizeScaleStops:i.visualVariableSizeScaleStops,visualVariableSizeStops:i.visualVariableSizeStops,visualVariableSizeUnitValue:i.visualVariableSizeUnitValue,visualVariableRotation:i.visualVariableRotation},optionalAttributes:{zoomRange:!1}}),s=x(e);let n=e.color?.toArray()??[0,0,0,0];"CIMVectorMarker"===s.resource.type&&(n=[255,255,255,255]);const u="triangle"===e.style?124/116:1,c=e.size,p=c*u,b=null!=i.visualVariableColor&&("cross"===e.style||"x"===e.style);return[t.createMeshInfo({type:"simple",color:n,height:c,width:p,offsetX:e.xoffset,offsetY:e.yoffset,angle:e.angle,alignment:z(i)?1:0,outlineColor:e.outline?.color?.toArray()??[0,0,0,0],outlineSize:e.outline?.width??1,referenceSize:c,sprite:s,overrideOutlineColor:b,hasSizeVV:h(i),placement:null,effects:null,transforms:null,scaleInfo:null,minPixelBuffer:V(i)})]}function w(e,a){const{uniforms:i,schemaOptions:l}=a,{store:r}=l,t=r.ensureInstance(f.marker,{uniforms:{visualVariableColor:i.visualVariableColor,visualVariableOpacity:i.visualVariableOpacity,visualVariableSizeMinMaxValue:i.visualVariableSizeMinMaxValue,visualVariableSizeScaleStops:i.visualVariableSizeScaleStops,visualVariableSizeStops:i.visualVariableSizeStops,visualVariableSizeUnitValue:i.visualVariableSizeUnitValue,visualVariableRotation:i.visualVariableRotation},optionalAttributes:{zoomRange:!1}}),s=o.createPictureMarkerRasterizationParam(e);if(!s)return[];return[t.createMeshInfo({type:"picture",color:[255,255,255,255],height:e.height,width:e.width,offsetX:e.xoffset,offsetY:e.yoffset,angle:e.angle,alignment:z(i)?1:0,outlineColor:null,outlineSize:0,referenceSize:e.height,sprite:s,overrideOutlineColor:!1,hasSizeVV:h(i),placement:null,effects:null,transforms:null,scaleInfo:null,minPixelBuffer:V(i)})]}function O(e,a,i){const{uniforms:l,schemaOptions:r}=i,{store:t}=r,o=t.ensureInstance(f.marker,{uniforms:{visualVariableColor:l.visualVariableColor,visualVariableOpacity:l.visualVariableOpacity,visualVariableSizeMinMaxValue:l.visualVariableSizeMinMaxValue,visualVariableSizeScaleStops:l.visualVariableSizeScaleStops,visualVariableSizeStops:l.visualVariableSizeStops,visualVariableSizeUnitValue:l.visualVariableSizeUnitValue,visualVariableRotation:l.visualVariableRotation},optionalAttributes:{zoomRange:!1}}),s=x(e),n=6,u=n*a.width,c=u,p=e.color?.toArray()??a.color?.toArray()??[0,0,0,0],b="cross"===e.style||"x"===e.style;let m;switch(e.placement){case"begin-end":m="Both";break;case"begin":m="JustBegin";break;case"end":m="JustEnd";break;default:m="None"}const S={type:"cim-marker-placement-param",placement:{type:"CIMMarkerPlacementAtExtremities",angleToLine:!0,offset:0,extremityPlacement:m,offsetAlongLine:0},overrides:[]};return[o.createMeshInfo({type:"simple",color:p,height:c,width:u,offsetX:0,offsetY:0,angle:0,alignment:z(l)?1:0,outlineColor:p,outlineSize:b?a.width:0,referenceSize:c/n,sprite:s,overrideOutlineColor:b&&null!=l.visualVariableColor,hasSizeVV:h(l),placement:S,transforms:null,effects:null,scaleInfo:null,minPixelBuffer:V(l)})]}function A(e,a){const{uniforms:i,schemaOptions:l}=a,{store:r}=l;return[r.ensureInstance(f.text,{uniforms:{visualVariableColor:i.visualVariableColor,visualVariableOpacity:i.visualVariableOpacity,visualVariableRotation:i.visualVariableRotation,visualVariableSizeMinMaxValue:i.visualVariableSizeMinMaxValue,visualVariableSizeScaleStops:i.visualVariableSizeScaleStops,visualVariableSizeStops:i.visualVariableSizeStops,visualVariableSizeUnitValue:i.visualVariableSizeUnitValue},optionalAttributes:{zoomRange:!1,clipAngle:!1,referenceSymbol:!1,visibility:!1}}).createMeshInfo({alignment:0,boxBackgroundColor:e.backgroundColor?.toArray(),boxBorderLineColor:e.borderLineColor?.toArray(),boxBorderLineSize:e.borderLineSize??0,color:e.color?.toArray()??[0,0,0,0],offsetX:e.xoffset,offsetY:e.yoffset,postAngle:e.angle,fontSize:e.font.size,decoration:e.font.decoration,haloColor:e.haloColor?.toArray()??[0,0,0,0],haloSize:e.haloSize??0,outlineColor:[0,0,0,0],outlineSize:0,lineWidth:e.lineWidth,lineHeightRatio:e.lineHeight,horizontalAlignment:e.horizontalAlignment,verticalAlignment:e.verticalAlignment,useCIMAngleBehavior:!1,glyphs:{type:"text-rasterization-param",resource:{type:"text",font:e.font.toJSON(),textString:e.text,symbol:o.createCIMTextSymbolfromTextSymbol(e)},overrides:[]},referenceSize:null,effects:null,placement:null,scaleInfo:null,transforms:null,scaleFactor:1,minPixelBuffer:V(i),repeatLabel:null,repeatLabelDistance:null,allowOverrun:null,labelPosition:null,layerId:null,labelClassId:null})]}function L(e,i){const{schemaOptions:l,uniforms:r}=i,{store:t}=l,s=e.symbol,{allowOverrun:n,repeatLabel:c,repeatLabelDistance:p}=e,b={maxScale:e.maxScale??0,minScale:e.minScale??0},m=t.ensureInstance(f.label,{uniforms:{visualVariableColor:null,visualVariableOpacity:null,visualVariableRotation:r.visualVariableRotation,visualVariableSizeMinMaxValue:r.visualVariableSizeMinMaxValue,visualVariableSizeScaleStops:r.visualVariableSizeScaleStops,visualVariableSizeStops:r.visualVariableSizeStops,visualVariableSizeUnitValue:r.visualVariableSizeUnitValue},optionalAttributes:{zoomRange:!0,clipAngle:!0,referenceSymbol:!0,visibility:!0}}),S=e.labelPlacement,[y,v]=u(S);return[m.createMeshInfo({alignment:0,boxBackgroundColor:s.backgroundColor?.toArray(),boxBorderLineColor:s.borderLineColor?.toArray(),boxBorderLineSize:s.borderLineSize??0,color:s.color?.toArray()??[0,0,0,0],offsetX:s.xoffset,offsetY:s.yoffset,postAngle:s.angle,fontSize:s.font.size,decoration:s.font.decoration,outlineColor:[0,0,0,0],outlineSize:0,haloColor:s.haloColor?.toArray()??[0,0,0,0],haloSize:s.haloSize??0,lineWidth:s.lineWidth,lineHeightRatio:s.lineHeight,horizontalAlignment:y,verticalAlignment:v,repeatLabel:c,repeatLabelDistance:a(p),allowOverrun:n,labelPosition:e.labelPosition,scaleInfo:b,minPixelBuffer:V(r),useCIMAngleBehavior:!1,glyphs:{type:"text-rasterization-param",resource:{type:"text",font:s.font.toJSON(),textString:s.text,symbol:o.createCIMTextSymbolfromTextSymbol(s),primitiveName:"label-override"},useLegacyLabelEvaluationRules:null==e.labelExpressionInfo?.expression,overrides:[{valueExpressionInfo:{type:"CIMExpressionInfo",expression:e.labelExpressionInfo?.expression??e.labelExpression,returnType:"String"},primitiveName:"label-override",propertyName:"textString",defaultValue:""}]},referenceSize:null,effects:null,placement:null,transforms:null,scaleFactor:1,layerId:i.layerId,labelClassId:i.labelClassId})]}function R(e,a){const i=e.width;return{outlineColor:e.color?.toArray()||[0,0,0,1],width:i,referenceWidth:i,capType:e.cap??"round",joinType:e.join??"round",miterLimit:e.miterLimit,hasSizeVV:a,outlineUsesColorVV:!1}}function k(e,a){const{uniforms:i,schemaOptions:l}=a,{store:r}=l,t=e.color?.toArray()??[0,0,0,0],o={type:"sprite-rasterization-param",resource:{type:"fill-style",style:e.style},overrides:[]};if("solid"===e.outline?.style){return[r.ensureInstance(f.patternOutlineFill,{uniforms:{visualVariableColor:i.visualVariableColor,visualVariableOpacity:i.visualVariableOpacity,visualVariableSizeScaleStops:i.visualVariableSizeOutlineScaleStops,visualVariableSizeMinMaxValue:null,visualVariableSizeStops:null,visualVariableSizeUnitValue:null},optionalAttributes:{zoomRange:!1}}).createMeshInfo({color:t,...R(e.outline,!!i.visualVariableSizeOutlineScaleStops),sprite:o,scaleInfo:null,effects:null})]}const s=[],n=r.ensureInstance(f.patternFill,{uniforms:{visualVariableColor:i.visualVariableColor,visualVariableOpacity:i.visualVariableOpacity},optionalAttributes:{zoomRange:!1}}).createMeshInfo({color:e.color?.toArray()??[0,0,0,0],sprite:o,scaleInfo:null,effects:null});return s.push(n),e.outline&&s.push(...P(e.outline,a,!0)),s}function j(e,a){const{uniforms:i,schemaOptions:l}=a,{store:r}=l,t=e.color?.toArray()??[0,0,0,0];if("none"!==e.style&&"solid"===e.outline?.style){return[r.ensureInstance(f.outlineFill,{uniforms:{visualVariableColor:i.visualVariableColor,visualVariableOpacity:i.visualVariableOpacity,visualVariableSizeScaleStops:i.visualVariableSizeOutlineScaleStops,visualVariableSizeMinMaxValue:null,visualVariableSizeStops:null,visualVariableSizeUnitValue:null},optionalAttributes:{zoomRange:!1}}).createMeshInfo({color:t,...R(e.outline,!!i.visualVariableSizeOutlineScaleStops),scaleInfo:null,effects:null})]}const o=[];if("none"!==e.style){const e=r.ensureInstance(f.fill,{uniforms:{visualVariableColor:i.visualVariableColor,visualVariableOpacity:i.visualVariableOpacity},optionalAttributes:{zoomRange:!1}}).createMeshInfo({color:t,scaleInfo:null,effects:null});o.push(e)}return e.outline&&o.push(...P(e.outline,a,!0)),o}async function U(e,a){if("cim"===e.type)return v(e.data,a);const{style:i}=e;return i&&"none"!==i&&"solid"!==i?k(e,a):j(e,a)}function F(e,a){const{outline:i}=e,{uniforms:l,schemaOptions:r}=a,{store:t}=r,s=[],n=o.createPictureFillRasterizationParam(e);if(!n)return[];const{width:u,height:c,xoffset:p,yoffset:b,xscale:m,yscale:S}=e,V={color:[255,255,255,255],sprite:n,height:c,aspectRatio:u/c,offsetX:p,offsetY:b,scaleX:m,scaleY:S,angle:0,applyRandomOffset:!1,sampleAlphaOnly:!1,scaleProportionally:!1,effects:null,scaleInfo:null};if("solid"===i?.style){return[t.ensureInstance(f.complexOutlineFill,{uniforms:{visualVariableColor:l.visualVariableColor,visualVariableOpacity:l.visualVariableOpacity,visualVariableSizeScaleStops:l.visualVariableSizeOutlineScaleStops,visualVariableSizeMinMaxValue:null,visualVariableSizeStops:null,visualVariableSizeUnitValue:null},optionalAttributes:{zoomRange:!1}}).createMeshInfo({...V,...R(i,!!l.visualVariableSizeOutlineScaleStops)})]}const y=t.ensureInstance(f.complexFill,{uniforms:{visualVariableColor:l.visualVariableColor,visualVariableOpacity:l.visualVariableOpacity},optionalAttributes:{zoomRange:!1}});return s.push(y.createMeshInfo(V)),i&&s.push(...P(i,a,!0)),s}function P(e,a,i){const{color:l,style:r,width:t,cap:o,join:n}=e,{schemaOptions:u}=a,{store:c}=u,p=[],b=i?{...y,visualVariableSizeScaleStops:a.uniforms.visualVariableSizeOutlineScaleStops}:a.uniforms,m={uniforms:{visualVariableColor:b.visualVariableColor,visualVariableOpacity:b.visualVariableOpacity,visualVariableSizeMinMaxValue:b.visualVariableSizeMinMaxValue,visualVariableSizeScaleStops:b.visualVariableSizeScaleStops,visualVariableSizeStops:b.visualVariableSizeStops,visualVariableSizeUnitValue:b.visualVariableSizeUnitValue},optionalAttributes:{zoomRange:!1}},S={color:l?.toArray()??[0,0,0,0],width:t,referenceWidth:t,capType:o,joinType:n,miterLimit:e.miterLimit,hasSizeVV:h(b),effects:null,scaleInfo:null};if(null==r||"solid"===r){const e=c.ensureInstance(f.line,m).createMeshInfo(S);p.push(e)}else if("none"!==r){const e=c.ensureInstance(f.texturedLine,m).createMeshInfo({...S,offsetAlongLine:0,shouldScaleDash:!0,shouldSampleAlphaOnly:!1,isSDF:!0,sprite:{type:"sprite-rasterization-param",resource:{type:"dash",dashTemplate:s(r,o)},overrides:[]}});p.push(e)}return null!=e.marker&&p.push(...O(e.marker,e,a)),p}export{g as createDotDensityMeshSchemas,M as createHeatmapMeshSchemas,P as createLineInstance,C as createPieChartMeshSchemas,d as createSymbolMeshSchemas};
|
|
2
|
+
import e from"../../../../../../../core/Logger.js";import{pt2px as i}from"../../../../../../../core/screenUtils.js";import{generateGradient as a}from"../../../../../../../renderers/support/heatmapUtils.js";import l from"../../../../../../../symbols/SimpleFillSymbol.js";import r from"../../../../../../../symbols/SimpleLineSymbol.js";import t from"../../../../../../../symbols/SimpleMarkerSymbol.js";import{CIMSymbolHelper as o,slsDashToTemplateArray as s}from"../../../../../../../symbols/cim/CIMSymbolHelper.js";import{hasRichTextFormattingTags as n}from"../../../../../../../symbols/cim/richTextUtils.js";import{getSDFInfo as u}from"../../../../../../../symbols/cim/SDFHelper.js";import{getAlignmentFromPlacement as c}from"../../../../../engine/webgl/alignmentUtils.js";import{writeColor as p}from"../../../../../engine/webgl/color.js";import{dotDensityMaxFields as f}from"../../../../../engine/webgl/definitions.js";import{Techniques as b}from"../../../../../engine/webgl/shaderGraph/techniques/TechniqueRegistry.js";import{maxPieChartFields as m}from"../../../../../engine/webgl/shaderGraph/techniques/pieChart/PieChartShader.js";import{premultiplyColor as S}from"../schemaUtils.js";import{createVisualVariableUniforms as y,getMaxSizeVVSize as V,noVisualVariables as v}from"../VisualVariablesSchema.js";import{createComplexSymbolInstances as h}from"./ComplexSymbolSchema.js";import{hasSizeVVUniform as z,hasRotationVVUniform as d}from"./utils.js";async function g(i,a){if(!i)return[];switch(i.type){case"simple-fill":return F(i,a);case"picture-fill":return P(i,a);case"simple-marker":return w(i,a);case"picture-marker":return O(i,a);case"simple-line":return B(i,a,!1);case"text":return L(i,a);case"label":return R(i,a);case"cim":return h(i.data,a);case"web-style":return g(await i.fetchSymbol({acceptedFormats:["cim","web"]}),a);case"line-3d":return e.getLogger("esri.views.layers.FeatureLayerView").warn("unsupported-symbol",`Symbol of type "${i.type}" unsupported in MapView. Defaulting to simple-line`),B(new r,a,!1);case"point-3d":return e.getLogger("esri.views.layers.FeatureLayerView").warn("unsupported-symbol",`Symbol of type "${i.type}" unsupported in MapView. Defaulting to simple-marker`),w(new t,a);case"polygon-3d":return e.getLogger("esri.views.layers.FeatureLayerView").warn("unsupported-symbol",`Symbol of type "${i.type}" unsupported in MapView. Defaulting to simple-fill`),F(new l,a);case"mesh-3d":case"label-3d":return e.getLogger("esri.views.layers.FeatureLayerView").warn("unsupported-symbol",`Symbol of type "${i.type}" unsupported in MapView. Ignoring`),[];case"CIMSymbolReference":throw new Error("InternalError: CIMSymbolReference should already be resolved")}}async function x(e,i){const{schemaOptions:a}=i,{store:r}=a,t=new Array(f),o=new Array(f/4);for(let l=0;l<f;l++){const i=l<e.attributes.length?e.attributes[l].color:null;t[l]=[0,0,0,0],p(t[l],i)}for(let l=0;l<f/4;l++)o[l]=[0,0,0,0],o[l][0]=4*l<e.attributes.length?1:0,o[l][1]=4*l+1<e.attributes.length?1:0,o[l][2]=4*l+2<e.attributes.length?1:0,o[l][3]=4*l+3<e.attributes.length?1:0;const s={uniforms:{isActive:o,colors:t,dotValue:e.dotValue,dotScale:e.referenceScale,blending:e.dotBlendingEnabled,dotSize:e.dotSize,seed:e.seed},optionalAttributes:{}},n=r.ensureInstance(b.dotDensity,s).createMeshInfo({effects:null}),u=[],c=new l({color:e.backgroundColor??[0,0,0,0],outline:null}),m=await g(c,i);if(u.push(...m),u.push(n),e.outline){const a=B(e.outline,i,!0);u.push(...a)}return u}async function M(e,l){const{store:r}=l,{radius:t,minDensity:o,maxDensity:s,referenceScale:n,field:u,valueExpression:c,colorStops:p}=e,f=a(p);return[r.ensureInstance(b.heatmap,{uniforms:{radius:i(t),minDensity:o,maxDensity:s,referenceScale:n,isFieldActive:!(!u&&!c),gradient:f,gradientHash:f.join(",")},optionalAttributes:{}}).createMeshInfo({effects:null})]}async function C(e,a){const{store:l}=a,r=e.outline?.width||0,t=y(e),o=Math.min(e.attributes.length,m),s=e.attributes.slice(0,o).map(e=>S(e.color));for(;s.length<m;)s.push([0,0,0,0]);const n=l.ensureInstance(b.pieChart,{uniforms:{shader:{chart:{outlineWidth:Math.round(i(r)),defaultColor:S(e.defaultColor),outlineColor:S(e.outline?.color),othersColor:S(e.othersCategory?.color),donutRatio:e.holePercentage,sectorThreshold:e.othersCategory?.threshold||0,colors:s,fieldCount:o},visualVariableOpacity:t.visualVariableOpacity,visualVariableSizeMinMaxValue:t.visualVariableSizeMinMaxValue,visualVariableSizeScaleStops:t.visualVariableSizeScaleStops,visualVariableSizeStops:t.visualVariableSizeStops,visualVariableSizeUnitValue:t.visualVariableSizeUnitValue}},optionalAttributes:{zoomRange:!0}}).createMeshInfo({size:e.size,outlineWidth:r,effects:null,scaleInfo:null,minPixelBuffer:V(t)});return[...e.backgroundFillSymbol?await F(e.backgroundFillSymbol,{schemaOptions:a,uniforms:v}):[],n]}function I(e){if("path"===e.style){if(null==e.path)throw new Error("Symbol with a style of type path must define a path");return{type:"sprite-rasterization-param",overrides:[],resource:{type:"path",path:e.path,asFill:!0}}}const i=o.fromSimpleMarker(e);if("outline"in e&&e.outline&&"none"!==e.outline.style){if("solid"!==e.outline.style){if(!i||!i.symbolLayers)throw new Error("Error handling marker! ");return{type:"sprite-rasterization-param",resource:i.symbolLayers[0],overrides:[]}}}return{type:"sprite-rasterization-param",resource:u(i),overrides:[]}}async function w(e,i){const{uniforms:a,schemaOptions:l}=i,{store:r}=l;if("path"===e.style||e.outline&&"solid"!==e.outline.style&&"none"!==e.outline.style){const l=o.fromSimpleMarker(e);if(!l||!l.symbolLayers)throw new Error("Error handling marker! ");if(a.visualVariableRotation&&(l.angleAlignment="Map"),"path"!==e.style){const e=l.symbolLayers[0];if(z(i.uniforms)){const a=V(i.uniforms,0,1);if(a>e.size){const i=a/e.size;e.size=a;const l=e.markerGraphics?.[0].symbol;(l.symbolLayers&&l.symbolLayers[0]).width*=i}}}return h({type:"CIMSymbolReference",symbol:l},i)}const t=r.ensureInstance(b.marker,{uniforms:{visualVariableColor:a.visualVariableColor,visualVariableOpacity:a.visualVariableOpacity,visualVariableSizeMinMaxValue:a.visualVariableSizeMinMaxValue,visualVariableSizeScaleStops:a.visualVariableSizeScaleStops,visualVariableSizeStops:a.visualVariableSizeStops,visualVariableSizeUnitValue:a.visualVariableSizeUnitValue,visualVariableRotation:a.visualVariableRotation},optionalAttributes:{zoomRange:!1}}),s=I(e);let n=e.color?.toArray()??[0,0,0,0];"CIMVectorMarker"===s.resource.type&&(n=[255,255,255,255]);const u="triangle"===e.style?124/116:1,c=e.size,p=c*u,f=null!=a.visualVariableColor&&("cross"===e.style||"x"===e.style);return[t.createMeshInfo({type:"simple",color:n,height:c,width:p,offsetX:e.xoffset,offsetY:e.yoffset,angle:e.angle,alignment:d(a)?1:0,outlineColor:e.outline?.color?.toArray()??[0,0,0,0],outlineSize:e.outline?.width??1,referenceSize:c,sprite:s,overrideOutlineColor:f,hasSizeVV:z(a),placement:null,effects:null,transforms:null,scaleInfo:null,minPixelBuffer:V(a)})]}function O(e,i){const{uniforms:a,schemaOptions:l}=i,{store:r}=l,t=r.ensureInstance(b.marker,{uniforms:{visualVariableColor:a.visualVariableColor,visualVariableOpacity:a.visualVariableOpacity,visualVariableSizeMinMaxValue:a.visualVariableSizeMinMaxValue,visualVariableSizeScaleStops:a.visualVariableSizeScaleStops,visualVariableSizeStops:a.visualVariableSizeStops,visualVariableSizeUnitValue:a.visualVariableSizeUnitValue,visualVariableRotation:a.visualVariableRotation},optionalAttributes:{zoomRange:!1}}),s=o.createPictureMarkerRasterizationParam(e);if(!s)return[];return[t.createMeshInfo({type:"picture",color:[255,255,255,255],height:e.height,width:e.width,offsetX:e.xoffset,offsetY:e.yoffset,angle:e.angle,alignment:d(a)?1:0,outlineColor:null,outlineSize:0,referenceSize:e.height,sprite:s,overrideOutlineColor:!1,hasSizeVV:z(a),placement:null,effects:null,transforms:null,scaleInfo:null,minPixelBuffer:V(a)})]}function A(e,i,a){const{uniforms:l,schemaOptions:r}=a,{store:t}=r,o=t.ensureInstance(b.marker,{uniforms:{visualVariableColor:l.visualVariableColor,visualVariableOpacity:l.visualVariableOpacity,visualVariableSizeMinMaxValue:l.visualVariableSizeMinMaxValue,visualVariableSizeScaleStops:l.visualVariableSizeScaleStops,visualVariableSizeStops:l.visualVariableSizeStops,visualVariableSizeUnitValue:l.visualVariableSizeUnitValue,visualVariableRotation:l.visualVariableRotation},optionalAttributes:{zoomRange:!1}}),s=I(e),n=6,u=n*i.width,c=u,p=e.color?.toArray()??i.color?.toArray()??[0,0,0,0],f="cross"===e.style||"x"===e.style;let m;switch(e.placement){case"begin-end":m="Both";break;case"begin":m="JustBegin";break;case"end":m="JustEnd";break;default:m="None"}const S={type:"cim-marker-placement-param",placement:{type:"CIMMarkerPlacementAtExtremities",angleToLine:!0,offset:0,extremityPlacement:m,offsetAlongLine:0},overrides:[]};return[o.createMeshInfo({type:"simple",color:p,height:c,width:u,offsetX:0,offsetY:0,angle:0,alignment:d(l)?1:0,outlineColor:p,outlineSize:f?i.width:0,referenceSize:c/n,sprite:s,overrideOutlineColor:f&&null!=l.visualVariableColor,hasSizeVV:z(l),placement:S,transforms:null,effects:null,scaleInfo:null,minPixelBuffer:V(l)})]}function L(e,i){const{uniforms:a,schemaOptions:l}=i,{store:r}=l;return[r.ensureInstance(b.text,{uniforms:{visualVariableColor:a.visualVariableColor,visualVariableOpacity:a.visualVariableOpacity,visualVariableRotation:a.visualVariableRotation,visualVariableSizeMinMaxValue:a.visualVariableSizeMinMaxValue,visualVariableSizeScaleStops:a.visualVariableSizeScaleStops,visualVariableSizeStops:a.visualVariableSizeStops,visualVariableSizeUnitValue:a.visualVariableSizeUnitValue},optionalAttributes:{zoomRange:!1,clipAngle:!1,referenceSymbol:!1,visibility:!1}}).createMeshInfo({alignment:0,boxBackgroundColor:e.backgroundColor?.toArray(),boxBorderLineColor:e.borderLineColor?.toArray(),boxBorderLineSize:e.borderLineSize??0,color:e.color?.toArray()??[0,0,0,0],offsetX:e.xoffset,offsetY:e.yoffset,postAngle:e.angle,fontSize:e.font.size,decoration:e.font.decoration,haloColor:e.haloColor?.toArray()??[0,0,0,0],haloSize:e.haloSize??0,outlineColor:[0,0,0,0],outlineSize:0,lineWidth:e.lineWidth,lineHeightRatio:e.lineHeight,horizontalAlignment:e.horizontalAlignment,verticalAlignment:e.verticalAlignment,useCIMAngleBehavior:!1,glyphs:{type:"text-rasterization-param",resource:{type:"text",font:e.font.toJSON(),textString:e.text,symbol:o.createCIMTextSymbolfromTextSymbol(e),supportsRichText:n(e.text)},overrides:[]},referenceSize:null,effects:null,placement:null,scaleInfo:null,transforms:null,scaleFactor:1,minPixelBuffer:V(a),repeatLabel:null,repeatLabelDistance:null,allowOverrun:null,labelPosition:null,layerId:null,labelClassId:null})]}function R(e,a){const{schemaOptions:l,uniforms:r}=a,{store:t}=l,s=e.symbol,{allowOverrun:n,repeatLabel:u,repeatLabelDistance:p}=e,f={maxScale:e.maxScale??0,minScale:e.minScale??0},m=t.ensureInstance(b.label,{uniforms:{visualVariableColor:null,visualVariableOpacity:null,visualVariableRotation:r.visualVariableRotation,visualVariableSizeMinMaxValue:r.visualVariableSizeMinMaxValue,visualVariableSizeScaleStops:r.visualVariableSizeScaleStops,visualVariableSizeStops:r.visualVariableSizeStops,visualVariableSizeUnitValue:r.visualVariableSizeUnitValue},optionalAttributes:{zoomRange:!0,clipAngle:!0,referenceSymbol:!0,visibility:!0}}),S=e.labelPlacement,[y,v]=c(S);return[m.createMeshInfo({alignment:0,boxBackgroundColor:s.backgroundColor?.toArray(),boxBorderLineColor:s.borderLineColor?.toArray(),boxBorderLineSize:s.borderLineSize??0,color:s.color?.toArray()??[0,0,0,0],offsetX:s.xoffset,offsetY:s.yoffset,postAngle:s.angle,fontSize:s.font.size,decoration:s.font.decoration,outlineColor:[0,0,0,0],outlineSize:0,haloColor:s.haloColor?.toArray()??[0,0,0,0],haloSize:s.haloSize??0,lineWidth:s.lineWidth,lineHeightRatio:s.lineHeight,horizontalAlignment:y,verticalAlignment:v,repeatLabel:u,repeatLabelDistance:i(p),allowOverrun:n,labelPosition:e.labelPosition,scaleInfo:f,minPixelBuffer:V(r),useCIMAngleBehavior:!1,glyphs:{type:"text-rasterization-param",resource:{type:"text",font:s.font.toJSON(),textString:s.text,symbol:o.createCIMTextSymbolfromTextSymbol(s),primitiveName:"label-override",supportsRichText:!0},useLegacyLabelEvaluationRules:null==e.labelExpressionInfo?.expression,overrides:[{valueExpressionInfo:{type:"CIMExpressionInfo",expression:e.labelExpressionInfo?.expression??e.labelExpression,returnType:"String"},primitiveName:"label-override",propertyName:"textString",defaultValue:""}]},referenceSize:null,effects:null,placement:null,transforms:null,scaleFactor:1,layerId:a.layerId,labelClassId:a.labelClassId})]}function k(e,i){const a=e.width;return{outlineColor:e.color?.toArray()||[0,0,0,1],width:a,referenceWidth:a,capType:e.cap??"round",joinType:e.join??"round",miterLimit:e.miterLimit,hasSizeVV:i,outlineUsesColorVV:!1}}function j(e,i){const{uniforms:a,schemaOptions:l}=i,{store:r}=l,t=e.color?.toArray()??[0,0,0,0],o={type:"sprite-rasterization-param",resource:{type:"fill-style",style:e.style},overrides:[]};if("solid"===e.outline?.style){return[r.ensureInstance(b.patternOutlineFill,{uniforms:{visualVariableColor:a.visualVariableColor,visualVariableOpacity:a.visualVariableOpacity,visualVariableSizeScaleStops:a.visualVariableSizeOutlineScaleStops,visualVariableSizeMinMaxValue:null,visualVariableSizeStops:null,visualVariableSizeUnitValue:null},optionalAttributes:{zoomRange:!1}}).createMeshInfo({color:t,...k(e.outline,!!a.visualVariableSizeOutlineScaleStops),sprite:o,scaleInfo:null,effects:null})]}const s=[],n=r.ensureInstance(b.patternFill,{uniforms:{visualVariableColor:a.visualVariableColor,visualVariableOpacity:a.visualVariableOpacity},optionalAttributes:{zoomRange:!1}}).createMeshInfo({color:e.color?.toArray()??[0,0,0,0],sprite:o,scaleInfo:null,effects:null});return s.push(n),e.outline&&s.push(...B(e.outline,i,!0)),s}function U(e,i){const{uniforms:a,schemaOptions:l}=i,{store:r}=l,t=e.color?.toArray()??[0,0,0,0];if("none"!==e.style&&"solid"===e.outline?.style){return[r.ensureInstance(b.outlineFill,{uniforms:{visualVariableColor:a.visualVariableColor,visualVariableOpacity:a.visualVariableOpacity,visualVariableSizeScaleStops:a.visualVariableSizeOutlineScaleStops,visualVariableSizeMinMaxValue:null,visualVariableSizeStops:null,visualVariableSizeUnitValue:null},optionalAttributes:{zoomRange:!1}}).createMeshInfo({color:t,...k(e.outline,!!a.visualVariableSizeOutlineScaleStops),scaleInfo:null,effects:null})]}const o=[];if("none"!==e.style){const e=r.ensureInstance(b.fill,{uniforms:{visualVariableColor:a.visualVariableColor,visualVariableOpacity:a.visualVariableOpacity},optionalAttributes:{zoomRange:!1}}).createMeshInfo({color:t,scaleInfo:null,effects:null});o.push(e)}return e.outline&&o.push(...B(e.outline,i,!0)),o}async function F(e,i){if("cim"===e.type)return h(e.data,i);const{style:a}=e;return a&&"none"!==a&&"solid"!==a?j(e,i):U(e,i)}function P(e,i){const{outline:a}=e,{uniforms:l,schemaOptions:r}=i,{store:t}=r,s=[],n=o.createPictureFillRasterizationParam(e);if(!n)return[];const{width:u,height:c,xoffset:p,yoffset:f,xscale:m,yscale:S}=e,y={color:[255,255,255,255],sprite:n,height:c,aspectRatio:u/c,offsetX:p,offsetY:f,scaleX:m,scaleY:S,angle:0,applyRandomOffset:!1,sampleAlphaOnly:!1,scaleProportionally:!1,effects:null,scaleInfo:null};if("solid"===a?.style){return[t.ensureInstance(b.complexOutlineFill,{uniforms:{visualVariableColor:l.visualVariableColor,visualVariableOpacity:l.visualVariableOpacity,visualVariableSizeScaleStops:l.visualVariableSizeOutlineScaleStops,visualVariableSizeMinMaxValue:null,visualVariableSizeStops:null,visualVariableSizeUnitValue:null},optionalAttributes:{zoomRange:!1}}).createMeshInfo({...y,...k(a,!!l.visualVariableSizeOutlineScaleStops)})]}const V=t.ensureInstance(b.complexFill,{uniforms:{visualVariableColor:l.visualVariableColor,visualVariableOpacity:l.visualVariableOpacity},optionalAttributes:{zoomRange:!1}});return s.push(V.createMeshInfo(y)),a&&s.push(...B(a,i,!0)),s}function B(e,i,a){const{color:l,style:r,width:t,cap:o,join:n}=e,{schemaOptions:u}=i,{store:c}=u,p=[],f=a?{...v,visualVariableSizeScaleStops:i.uniforms.visualVariableSizeOutlineScaleStops}:i.uniforms,m={uniforms:{visualVariableColor:f.visualVariableColor,visualVariableOpacity:f.visualVariableOpacity,visualVariableSizeMinMaxValue:f.visualVariableSizeMinMaxValue,visualVariableSizeScaleStops:f.visualVariableSizeScaleStops,visualVariableSizeStops:f.visualVariableSizeStops,visualVariableSizeUnitValue:f.visualVariableSizeUnitValue},optionalAttributes:{zoomRange:!1}},S={color:l?.toArray()??[0,0,0,0],width:t,referenceWidth:t,capType:o,joinType:n,miterLimit:e.miterLimit,hasSizeVV:z(f),effects:null,scaleInfo:null};if(null==r||"solid"===r){const e=c.ensureInstance(b.line,m).createMeshInfo(S);p.push(e)}else if("none"!==r){const e=c.ensureInstance(b.texturedLine,m).createMeshInfo({...S,offsetAlongLine:0,shouldScaleDash:!0,shouldSampleAlphaOnly:!1,isSDF:!0,sprite:{type:"sprite-rasterization-param",resource:{type:"dash",dashTemplate:s(r,o)},overrides:[]}});p.push(e)}return null!=e.marker&&p.push(...A(e.marker,e,i)),p}export{x as createDotDensityMeshSchemas,M as createHeatmapMeshSchemas,B as createLineInstance,C as createPieChartMeshSchemas,g as createSymbolMeshSchemas};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
import i from"../../../../../core/Error.js";import n from"../../../../../core/Logger.js";import{deg2rad as t,rad2deg as e}from"../../../../../core/mathUtils.js";import{dist as s,set as o,equals as r,subtract as h,len as l,scale as m}from"../../../../../core/libs/gl-matrix-2/math/vec2.js";import{fromValues as _,create as d}from"../../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{isPolygon as a}from"../../../../../geometry/support/jsonTypeUtils.js";import g from"../../../../../layers/support/FieldsIndex.js";import{createRendererExpression as u}from"../../../../../support/ArcadeExpression.js";import{fromCIMHorizontalAlignment as c,fromCIMVerticalAlignment as x,fromCIMFontDecoration as P}from"../../../../../symbols/cim/utils.js";import p from"../../../arcade/callExpressionWithFeature.js";import{glyphSize as b,magicLabelLineHeight as f}from"../../../engine/webgl/definitions.js";import y from"../../../engine/webgl/Rect.js";import{shapeGlyphs as D}from"../../../engine/webgl/mesh/templates/shapingUtils.js";import{roundPtToWholePixel as L,getLineWidth as S}from"../../graphics/graphicsUtils.js";import{initializeDimensionStyleDefaults as M}from"./dimensionStyleDefaults.js";import{DimensionRealFieldName as T,rectsOverlap as R,queryPointOnLine as w,angleFromXAxis as E,intersectLinesByPointsAndAngles as k,measureMarkerSymbolSize as N,translateRect as v,scaleRect as A,rotatePoint as B,rectsOverlapOnAxis as F}from"./dimensionUtils.js";import{getAttributeValue as I}from"./utils.js";class j{static async create(i,n,t,e){const s=e(i.textSymbol),o=new j(i,s);return await o.initialize(n,t),o}constructor(i,n){if(this._dimensionStyle=i,this._mosaicItems=n,this._textString=null,this._displayExtLines=!0,this._systemLength=0,this._dimensionAngleRad=0,this._dimensionLength=0,this._dimensionDirection=null,this._textSize=null,this._extAngleRad=Math.PI/2,this._compiledExpression=null,this._fieldsIndex=null,this._beginBaselinePoint=null,this._endBaselinePoint=null,this._dimensionLinePoint=null,this._beginDimensionPoint=null,this._endDimensionPoint=null,this._beginMarkerRect=null,this._endMarkerRect=null,this._textRect=null,this._textPoint=null,this._dimensionPolyline=null,this._dimensionExtensionLines=null,this._hasTextPoint=!1,this._doMarkersFit=!0,this._dimensionIsEvaluated=!1,null==i)throw new Error("dimension syle must be defined!");M(i)}async initialize(t,e){if(!this._dimensionStyle)return;const{attributes:s}=t;if("Expression"===(this._dimensionStyle.textOption??"None")){const{expression:s,expressionParserName:o}=this._dimensionStyle;s&&o&&"arcade"===o.toLowerCase()?(this._compiledExpression=await u(s,e),this._fieldsIndex=O(t)):n.getLogger("esri.layers.DimensionFeatureLayer").warn(new i("dimension-layer:unsupported-expression","Only Arcade expressions are supported",{expressionType:o,expression:s}))}const o=Number(I(T.extAngle,s));this._extAngleRad=isNaN(o)?Math.PI/2:o,this._systemLength=Number(I("__SYSTEM_LENGTH__",s));const{geometry:r}=t;if(r&&!a(r))throw new i("dimension-layer","processed geometry must be a valid 'polygon'.");const h=r?.rings[0];if(!h||h.length<3)throw new i("dimension-layer","processed geometry must have at least 3 points.");this._hasTextPoint=0!==h[3][0]&&0!==h[3][1]&&void 0!==h[3][0]&&void 0!==h[3][1],this._hasTextPoint&&(this._textPoint=h[3]);const l=this._dimensionStyle.textSymbol;s.__DIMENSION_ANGLE__+=l?.angle??0}getTextString(i){return null==this._textString&&(this._textString=this._getDimensionText(i)),this._textString}get textSymbol(){return this._dimensionStyle.textSymbol??null}get beginBaselinePoint(){return this._beginBaselinePoint}get endBaselinePoint(){return this._endBaselinePoint}get beginDimensionPoint(){return this._beginDimensionPoint}get endDimensionPoint(){return this._endDimensionPoint}get textPoint(){return this._textPoint}get dimensionLine(){return this._dimensionPolyline}get extensionLines(){return this._displayExtLines?this._dimensionExtensionLines:null}evaluateWithGeometry(i,n){this._dimensionIsEvaluated||(this._computeDimensionLineInfo(i,n),this._evaluateDefaultPlacement(n),this._updateExtensionLines(n),this._updateTextPoint(n),this._offsetTextPoint(n),this._dimensionIsEvaluated=!0)}_updateTextPoint(i){if(this._hasTextPoint)return;const{textFit:n}=this._dimensionStyle;let t=!0;if(!this._doMarkersFit){if(this._hasTextPoint)return;if("None"===n||!this._beginMarkerRect||!this._endMarkerRect||!this._textRect)return void(t=!0);if((R(this._beginMarkerRect,this._textRect)||R(this._endMarkerRect,this._textRect))&&(t=!1),!t){const i=this._textRect.width/2,t=this._beginMarkerRect.width/2,e=this._endMarkerRect.width/2;"MoveBegin"===n?(this._textPoint=w(this._beginDimensionPoint,this._endDimensionPoint,-(i+t)),this._extendDimensionLineForMovedText("begin",t+this._textRect.width)):"MoveEnd"===n&&(this._textPoint=w(this._endDimensionPoint,this._beginDimensionPoint,-(i+e)),this._extendDimensionLineForMovedText("end",e+this._textRect.width))}}}_extendDimensionLineForMovedText(i,n){if(this._dimensionPolyline?.length)if("begin"===i){const i=w(this._beginDimensionPoint,this._endDimensionPoint,-n);this._dimensionPolyline[0]=[i,this._beginDimensionPoint]}else{const i=w(this._beginDimensionPoint,this._endDimensionPoint,this._dimensionLength+n);this._dimensionPolyline[1]=[i,this._endDimensionPoint]}}_offsetTextPoint(i){if(this._hasTextPoint)return;const n=this._textPoint;if(!n)return;const t=.5*this._textSize*i,e=-t*this._dimensionDirection[1],s=t*this._dimensionDirection[0];n[0]+=e,n[1]+=s}_updateExtensionLines(i){if(!(this._displayExtLines&&this._beginDimensionPoint&&this._dimensionLinePoint&&this._endDimensionPoint))return;const{extensionLineOvershot:n,extensionLineOffset:t}=this._dimensionStyle;let e=this._dimensionLinePoint,o=this._endDimensionPoint;null==n||isNaN(n)||0===n||(e=w(this._dimensionLinePoint,this._beginBaselinePoint,-n*i),o=w(this._endDimensionPoint,this._endBaselinePoint,-n*i));let r=this._beginBaselinePoint,h=this._endBaselinePoint;if(null!=t&&!isNaN(t)&&0!==t){const i=s(e,this._beginBaselinePoint),n=s(o,this._endBaselinePoint);r=w(e,this._beginBaselinePoint,i-t),h=w(o,this._endBaselinePoint,n-t)}this._dimensionExtensionLines=[[e,r],[o,h]]}_computeDimensionLineInfo(n,s){if(!n||!a(n)||n.rings[0].length<3)throw new i("DimensionLayerView: bad geometry","Dimension cann't be applied to an empty geometry!");const g=n.rings[0],u=_(g[0][0],g[0][1]),c=_(g[1][0],g[1][1]),x=_(g[2][0],g[2][1]);this._beginBaselinePoint=o(d(),u[0],u[1]),this._endBaselinePoint=o(d(),c[0],c[1]),this._dimensionLinePoint=x;let P=this._extAngleRad;if(r(u,x))this._beginDimensionPoint=o(d(),u[0],u[1]),this._endDimensionPoint=o(d(),c[0],c[1]),this._displayExtLines=!1;else{const n=E([c[0]-u[0],c[1]-u[1]]),s=e(P);s>=-1&&s<=1?P+=t(1):s>=179&&s<=181&&(P-=t(1));const r=k(x,n,c,n+P);if(!r)throw new i("DimensionLayerView: bad geometry","Failed to construct dimension extension lines!");this._beginDimensionPoint=o(d(),x[0],x[1]),this._endDimensionPoint=o(d(),r[0],r[1])}this._dimensionDirection=h(d(),this._endDimensionPoint,this._beginDimensionPoint),this._dimensionAngleRad=E(this._dimensionDirection),this._dimensionLength=l(this._dimensionDirection),this._dimensionDirection=m(this._dimensionDirection,this._dimensionDirection,1/this._dimensionLength),this._hasTextPoint||(this._textPoint=w(this._beginDimensionPoint,this._endDimensionPoint,this._dimensionLength/2))}_evaluateDefaultPlacement(i){const{beginMarkerSymbol:n,endMarkerSymbol:t}=this._dimensionStyle,e=N(n,this._dimensionAngleRad),s=N(t,this._dimensionAngleRad+Math.PI),o=this._measureDimensionText(this._textString||"",this._textPoint,i);this._textRect=o;const r=i*((e?.width??0)/2),h=i*((s?.width??0)/2),l=e&&this._beginDimensionPoint?v(A(e,i),this._beginDimensionPoint[0],this._beginDimensionPoint[1]):null,m=s&&this._endDimensionPoint?v(A(s,i),this._endDimensionPoint[0],this._endDimensionPoint[1]):null;if(this._beginMarkerRect=l,this._endMarkerRect=m,this._doMarkersFit=this._checkMarkerFit(l,m,o,i),this._doMarkersFit){const i=w(this._beginDimensionPoint,this._endDimensionPoint,this._dimensionLength/2);this._dimensionPolyline=[[i,this._beginDimensionPoint],[i,this._endDimensionPoint]]}else{const i=w(this._beginDimensionPoint,this._endDimensionPoint,-4*r),n=w(this._beginDimensionPoint,this._endDimensionPoint,this._dimensionLength+4*h);this._dimensionPolyline=[[i,this._beginDimensionPoint],[n,this._endDimensionPoint]]}}_checkMarkerFit(i,n,t,e){if(!i||!n)return!1;const{markerFit:s,markerOption:o,markerFitTolerance:r}=this._dimensionStyle;if("None"===s)return!0;let h=!0;const l=(i,n)=>R(i,n)||F(i,n,this._dimensionDirection);if("Tolerance"===s)r*e>=this._dimensionLength&&(h=!1);else{if(this._hasTextPoint&&"Both"!==o)return!0;this._hasTextPoint&&"Both"===o?l(i,n)&&(h=!1):(l(i,n)&&(h=!1),h&&t&&(l(t,i)||l(t,n))&&(h=!1))}return h}_measureDimensionText(i,n,t){if(null==this._textString||null==n||null==this._mosaicItems)return null;const e=[];for(const c of i)c.codePointAt(0),e.push(this._mosaicItems.glyphs[c.codePointAt(0)]);const s=this._dimensionStyle.textSymbol;if(!s)return null;const o=c(s.horizontalAlignment),r=x(s.verticalAlignment),h=P(s),l=L(s.height||10);this._textSize=l;const m=!0,_=s.angle||0,d=l/b,a=S(s.lineWidth),g=f*Math.max(.25,Math.min(l||1,4)),u={...this._mosaicItems,glyphs:e.filter(i=>null!=i)},p=D(u,{scale:d,angle:_,xOffset:0,yOffset:0,horizontalAlignment:o,verticalAlignment:r,decoration:h,lineHeight:g,useCIMAngleBehavior:m,maxLineWidth:a,hasBackground:!1}),M=n;if(!M)return null;const T=t,R=[p.bounds.blX,p.bounds.trY],w=[p.bounds.trX,p.bounds.trY],E=[p.bounds.blX,p.bounds.blY],k=[p.bounds.trX,p.bounds.blY];R[0]-=p.bounds.x,R[1]-=p.bounds.y,w[0]-=p.bounds.x,w[1]-=p.bounds.y,E[0]-=p.bounds.x,E[1]-=p.bounds.y,k[0]-=p.bounds.x,k[1]-=p.bounds.y,R[0]*=T,R[1]*=T,w[0]*=T,w[1]*=T,E[0]*=T,E[1]*=T,k[0]*=T,k[1]*=T,this._dimensionAngleRad&&(B(R,this._dimensionAngleRad),B(w,this._dimensionAngleRad),B(E,this._dimensionAngleRad),B(k,this._dimensionAngleRad)),R[0]+=M[0],R[1]+=M[1],w[0]+=M[0],w[1]+=M[1],E[0]+=M[0],E[1]+=M[1],k[0]+=M[0],k[1]+=M[1];const N=Math.min(R[0],w[0],E[0],k[0]),v=Math.min(R[1],w[1],E[1],k[1]),A=Math.max(R[0],w[0],E[0],k[0]),F=Math.max(R[1],w[1],E[1],k[1]);return new y(N,v,1.1*(A-N),1.1*(F-v))}_getDimensionText(i){const{attributes:n}=i;let t=null;const e=1===Number(I(T.useCustomLength,n));t=Number(I(e?T.customLength:T.dimLength,n)),(0===t||isNaN(t)||null==t)&&(t=this._systemLength);let s=this._getDimensionString(t,i);return"number"==typeof s&&(s=s.toString()),n.__COMPUTED_TEXT_STRING__=s,s||""}_getDimensionString(i,n){const{convertUnits:t,displayUnits:e,displayPrecision:s,prefix:o,suffix:r,textOption:h}=this._dimensionStyle;if("None"===h)return null;if("Expression"===h&&this._compiledExpression&&n)return p(this._compiledExpression,n,{},"esriGeometryPolyline",this._fieldsIndex);let l=(i=null==s||isNaN(s)?parseFloat(i.toString()):parseFloat(i.toFixed(s))).toString();return"Suffix"===h&&(o&&(l=`${o} ${l}`),r&&(l=`${l} ${r}`)),l}}function O(i){const{attributes:n}=i,t=Object.keys(T).map(i=>({name:i,alias:i,type:"string"==typeof n[i]?"esriFieldTypeString":"esriFieldTypeDouble"}));return new g(t)}export{j as default};
|
|
2
|
+
import i from"../../../../../core/Error.js";import e from"../../../../../core/Logger.js";import{deg2rad as n,rad2deg as t}from"../../../../../core/mathUtils.js";import{dist as s,set as o,equals as r,subtract as h,len as l,scale as m}from"../../../../../core/libs/gl-matrix-2/math/vec2.js";import{fromValues as _,create as d}from"../../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{isPolygon as a}from"../../../../../geometry/support/jsonTypeUtils.js";import u from"../../../../../layers/support/FieldsIndex.js";import{createRendererExpression as g}from"../../../../../support/ArcadeExpression.js";import{fromCIMHorizontalAlignment as c,fromCIMVerticalAlignment as x,fromCIMFontDecoration as P}from"../../../../../symbols/cim/utils.js";import p from"../../../arcade/callExpressionWithFeature.js";import{magicLabelLineHeight as b}from"../../../engine/webgl/definitions.js";import f from"../../../engine/webgl/Rect.js";import{shapeTextResource as y}from"../../../engine/webgl/mesh/templates/shapingUtils.js";import{roundPtToWholePixel as D,getLineWidth as L}from"../../graphics/graphicsUtils.js";import{initializeDimensionStyleDefaults as R}from"./dimensionStyleDefaults.js";import{DimensionRealFieldName as S,rectsOverlap as M,queryPointOnLine as T,angleFromXAxis as w,intersectLinesByPointsAndAngles as E,measureMarkerSymbolSize as k,translateRect as N,scaleRect as v,rotatePoint as A,rectsOverlapOnAxis as B}from"./dimensionUtils.js";import{getAttributeValue as F}from"./utils.js";class j{static async create(i,e,n){const t=new j(i);return await t.initialize(e,n),t}constructor(i){if(this._dimensionStyle=i,this._textString=null,this._displayExtLines=!0,this._systemLength=0,this._dimensionAngleRad=0,this._dimensionLength=0,this._dimensionDirection=null,this._textSize=null,this._extAngleRad=Math.PI/2,this._compiledExpression=null,this._fieldsIndex=null,this._textResource=null,this._beginBaselinePoint=null,this._endBaselinePoint=null,this._dimensionLinePoint=null,this._beginDimensionPoint=null,this._endDimensionPoint=null,this._beginMarkerRect=null,this._endMarkerRect=null,this._textRect=null,this._textPoint=null,this._dimensionPolyline=null,this._dimensionExtensionLines=null,this._hasTextPoint=!1,this._doMarkersFit=!0,this._dimensionIsEvaluated=!1,null==i)throw new Error("dimension syle must be defined!");R(i)}async initialize(n,t){if(!this._dimensionStyle)return;const{attributes:s}=n;if("Expression"===(this._dimensionStyle.textOption??"None")){const{expression:s,expressionParserName:o}=this._dimensionStyle;s&&o&&"arcade"===o.toLowerCase()?(this._compiledExpression=await g(s,t),this._fieldsIndex=I(n)):e.getLogger("esri.layers.DimensionFeatureLayer").warn(new i("dimension-layer:unsupported-expression","Only Arcade expressions are supported",{expressionType:o,expression:s}))}const o=Number(F(S.extAngle,s));this._extAngleRad=isNaN(o)?Math.PI/2:o,this._systemLength=Number(F("__SYSTEM_LENGTH__",s));const{geometry:r}=n;if(r&&!a(r))throw new i("dimension-layer","processed geometry must be a valid 'polygon'.");const h=r?.rings[0];if(!h||h.length<3)throw new i("dimension-layer","processed geometry must have at least 3 points.");this._hasTextPoint=0!==h[3][0]&&0!==h[3][1]&&void 0!==h[3][0]&&void 0!==h[3][1],this._hasTextPoint&&(this._textPoint=h[3]);const l=this._dimensionStyle.textSymbol;s.__DIMENSION_ANGLE__+=l?.angle??0}getTextString(i){return null==this._textString&&(this._textString=this._getDimensionText(i)),this._textString}get textSymbol(){return this._dimensionStyle.textSymbol??null}setTextResource(i){this._textResource=i??null}get beginBaselinePoint(){return this._beginBaselinePoint}get endBaselinePoint(){return this._endBaselinePoint}get beginDimensionPoint(){return this._beginDimensionPoint}get endDimensionPoint(){return this._endDimensionPoint}get textPoint(){return this._textPoint}get dimensionLine(){return this._dimensionPolyline}get extensionLines(){return this._displayExtLines?this._dimensionExtensionLines:null}evaluateWithGeometry(i,e){this._dimensionIsEvaluated||(this._computeDimensionLineInfo(i,e),this._evaluateDefaultPlacement(e),this._updateExtensionLines(e),this._updateTextPoint(e),this._offsetTextPoint(e),this._dimensionIsEvaluated=!0)}_updateTextPoint(i){if(this._hasTextPoint)return;const{textFit:e}=this._dimensionStyle;let n=!0;if(!this._doMarkersFit){if(this._hasTextPoint)return;if("None"===e||!this._beginMarkerRect||!this._endMarkerRect||!this._textRect)return void(n=!0);if((M(this._beginMarkerRect,this._textRect)||M(this._endMarkerRect,this._textRect))&&(n=!1),!n){const i=this._textRect.width/2,n=this._beginMarkerRect.width/2,t=this._endMarkerRect.width/2;"MoveBegin"===e?(this._textPoint=T(this._beginDimensionPoint,this._endDimensionPoint,-(i+n)),this._extendDimensionLineForMovedText("begin",n+this._textRect.width)):"MoveEnd"===e&&(this._textPoint=T(this._endDimensionPoint,this._beginDimensionPoint,-(i+t)),this._extendDimensionLineForMovedText("end",t+this._textRect.width))}}}_extendDimensionLineForMovedText(i,e){if(this._dimensionPolyline?.length)if("begin"===i){const i=T(this._beginDimensionPoint,this._endDimensionPoint,-e);this._dimensionPolyline[0]=[i,this._beginDimensionPoint]}else{const i=T(this._beginDimensionPoint,this._endDimensionPoint,this._dimensionLength+e);this._dimensionPolyline[1]=[i,this._endDimensionPoint]}}_offsetTextPoint(i){if(this._hasTextPoint)return;const e=this._textPoint;if(!e)return;const n=.5*this._textSize*i,t=-n*this._dimensionDirection[1],s=n*this._dimensionDirection[0];e[0]+=t,e[1]+=s}_updateExtensionLines(i){if(!(this._displayExtLines&&this._beginDimensionPoint&&this._dimensionLinePoint&&this._endDimensionPoint))return;const{extensionLineOvershot:e,extensionLineOffset:n}=this._dimensionStyle;let t=this._dimensionLinePoint,o=this._endDimensionPoint;null==e||isNaN(e)||0===e||(t=T(this._dimensionLinePoint,this._beginBaselinePoint,-e*i),o=T(this._endDimensionPoint,this._endBaselinePoint,-e*i));let r=this._beginBaselinePoint,h=this._endBaselinePoint;if(null!=n&&!isNaN(n)&&0!==n){const i=s(t,this._beginBaselinePoint),e=s(o,this._endBaselinePoint);r=T(t,this._beginBaselinePoint,i-n),h=T(o,this._endBaselinePoint,e-n)}this._dimensionExtensionLines=[[t,r],[o,h]]}_computeDimensionLineInfo(e,s){if(!e||!a(e)||e.rings[0].length<3)throw new i("DimensionLayerView: bad geometry","Dimension cann't be applied to an empty geometry!");const u=e.rings[0],g=_(u[0][0],u[0][1]),c=_(u[1][0],u[1][1]),x=_(u[2][0],u[2][1]);this._beginBaselinePoint=o(d(),g[0],g[1]),this._endBaselinePoint=o(d(),c[0],c[1]),this._dimensionLinePoint=x;let P=this._extAngleRad;if(r(g,x))this._beginDimensionPoint=o(d(),g[0],g[1]),this._endDimensionPoint=o(d(),c[0],c[1]),this._displayExtLines=!1;else{const e=w([c[0]-g[0],c[1]-g[1]]),s=t(P);s>=-1&&s<=1?P+=n(1):s>=179&&s<=181&&(P-=n(1));const r=E(x,e,c,e+P);if(!r)throw new i("DimensionLayerView: bad geometry","Failed to construct dimension extension lines!");this._beginDimensionPoint=o(d(),x[0],x[1]),this._endDimensionPoint=o(d(),r[0],r[1])}this._dimensionDirection=h(d(),this._endDimensionPoint,this._beginDimensionPoint),this._dimensionAngleRad=w(this._dimensionDirection),this._dimensionLength=l(this._dimensionDirection),this._dimensionDirection=m(this._dimensionDirection,this._dimensionDirection,1/this._dimensionLength),this._hasTextPoint||(this._textPoint=T(this._beginDimensionPoint,this._endDimensionPoint,this._dimensionLength/2))}_evaluateDefaultPlacement(i){const{beginMarkerSymbol:e,endMarkerSymbol:n}=this._dimensionStyle,t=k(e,this._dimensionAngleRad),s=k(n,this._dimensionAngleRad+Math.PI),o=this._measureDimensionText(this._textString||"",this._textPoint,i);this._textRect=o;const r=i*((t?.width??0)/2),h=i*((s?.width??0)/2),l=t&&this._beginDimensionPoint?N(v(t,i),this._beginDimensionPoint[0],this._beginDimensionPoint[1]):null,m=s&&this._endDimensionPoint?N(v(s,i),this._endDimensionPoint[0],this._endDimensionPoint[1]):null;if(this._beginMarkerRect=l,this._endMarkerRect=m,this._doMarkersFit=this._checkMarkerFit(l,m,o,i),this._doMarkersFit){const i=T(this._beginDimensionPoint,this._endDimensionPoint,this._dimensionLength/2);this._dimensionPolyline=[[i,this._beginDimensionPoint],[i,this._endDimensionPoint]]}else{const i=T(this._beginDimensionPoint,this._endDimensionPoint,-4*r),e=T(this._beginDimensionPoint,this._endDimensionPoint,this._dimensionLength+4*h);this._dimensionPolyline=[[i,this._beginDimensionPoint],[e,this._endDimensionPoint]]}}_checkMarkerFit(i,e,n,t){if(!i||!e)return!1;const{markerFit:s,markerOption:o,markerFitTolerance:r}=this._dimensionStyle;if("None"===s)return!0;let h=!0;const l=(i,e)=>M(i,e)||B(i,e,this._dimensionDirection);if("Tolerance"===s)r*t>=this._dimensionLength&&(h=!1);else{if(this._hasTextPoint&&"Both"!==o)return!0;this._hasTextPoint&&"Both"===o?l(i,e)&&(h=!1):(l(i,e)&&(h=!1),h&&n&&(l(n,i)||l(n,e))&&(h=!1))}return h}_measureDimensionText(i,e,n){if(null==this._textString||null==e||null==this._textResource)return null;const t=this._dimensionStyle.textSymbol;if(!t)return null;const s=c(t.horizontalAlignment),o=x(t.verticalAlignment),r=P(t),h=D(t.height||10);this._textSize="glyphs"===this._textResource.type?h:Math.max(h,...this._textResource.runs.map(i=>D(i.fontSize||0)));const l=!0,m=t.angle||0,_="glyphs"===this._textResource.type?this._textResource.sdfSize:this._textResource.runs[0]?.glyphs.sdfSize;if(!_)return null;const d=h/_,a=L(t.lineWidth),u=Math.max(.25,Math.min(h||1,4)),g=b*u,p=y(this._textResource,{scale:d,angle:m,xOffset:0,yOffset:0,horizontalAlignment:s,verticalAlignment:o,decoration:r,lineHeight:g,lineHeightRatio:u,useCIMAngleBehavior:l,maxLineWidth:a,hasBackground:!1}),R=e;if(!R)return null;const S=n,M=[p.bounds.blX,p.bounds.trY],T=[p.bounds.trX,p.bounds.trY],w=[p.bounds.blX,p.bounds.blY],E=[p.bounds.trX,p.bounds.blY];M[0]-=p.bounds.x,M[1]-=p.bounds.y,T[0]-=p.bounds.x,T[1]-=p.bounds.y,w[0]-=p.bounds.x,w[1]-=p.bounds.y,E[0]-=p.bounds.x,E[1]-=p.bounds.y,M[0]*=S,M[1]*=S,T[0]*=S,T[1]*=S,w[0]*=S,w[1]*=S,E[0]*=S,E[1]*=S,this._dimensionAngleRad&&(A(M,this._dimensionAngleRad),A(T,this._dimensionAngleRad),A(w,this._dimensionAngleRad),A(E,this._dimensionAngleRad)),M[0]+=R[0],M[1]+=R[1],T[0]+=R[0],T[1]+=R[1],w[0]+=R[0],w[1]+=R[1],E[0]+=R[0],E[1]+=R[1];const k=Math.min(M[0],T[0],w[0],E[0]),N=Math.min(M[1],T[1],w[1],E[1]),v=Math.max(M[0],T[0],w[0],E[0]),B=Math.max(M[1],T[1],w[1],E[1]);return new f(k,N,1.1*(v-k),1.1*(B-N))}_getDimensionText(i){const{attributes:e}=i;let n=null;const t=1===Number(F(S.useCustomLength,e));n=Number(F(t?S.customLength:S.dimLength,e)),(0===n||isNaN(n)||null==n)&&(n=this._systemLength);let s=this._getDimensionString(n,i);return"number"==typeof s&&(s=s.toString()),e.__COMPUTED_TEXT_STRING__=s,s||""}_getDimensionString(i,e){const{convertUnits:n,displayUnits:t,displayPrecision:s,prefix:o,suffix:r,textOption:h}=this._dimensionStyle;if("None"===h)return null;if("Expression"===h&&this._compiledExpression&&e)return p(this._compiledExpression,e,{},"esriGeometryPolyline",this._fieldsIndex);let l=(i=null==s||isNaN(s)?parseFloat(i.toString()):parseFloat(i.toFixed(s))).toString();return"Suffix"===h&&(o&&(l=`${o} ${l}`),r&&(l=`${l} ${r}`)),l}}function I(i){const{attributes:e}=i,n=Object.keys(S).map(i=>({name:i,alias:i,type:"string"==typeof e[i]?"esriFieldTypeString":"esriFieldTypeDouble"}));return new u(n)}export{j as default};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
import{getFontFamily as t}from"../../../../../core/fontUtils.js";import{set as n,len as o,scaleAndAdd as e,dot as i}from"../../../../../core/libs/gl-matrix-2/math/vec2.js";import{create as r}from"../../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{create as a}from"../../../../../geometry/support/aaBoundingRect.js";import{getBoundsXY as c}from"../../../../../geometry/support/boundsUtils.js";import{fromCIMFontDecoration as s,fromCIMFontStyle as u}from"../../../../../symbols/cim/utils.js";import f from"../../../engine/webgl/Rect.js";function m(n){const
|
|
2
|
+
import{getFontFamily as t}from"../../../../../core/fontUtils.js";import{set as n,len as o,scaleAndAdd as e,dot as i}from"../../../../../core/libs/gl-matrix-2/math/vec2.js";import{create as r}from"../../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{create as a}from"../../../../../geometry/support/aaBoundingRect.js";import{getBoundsXY as c}from"../../../../../geometry/support/boundsUtils.js";import{fromCIMFontDecoration as s,fromCIMFontStyle as u}from"../../../../../symbols/cim/utils.js";import f from"../../../engine/webgl/Rect.js";function m(n){const o=s(n),{style:e,weight:i}=u(n.fontStyleName);return{family:t(n.fontFamilyName),decoration:o,style:e,weight:i}}function h(t){const n=(t.symbolLayers||[]).map(t=>{if("CIMVectorMarker"===t.type){const n=t.frame.xmax-t.frame.xmin;return{...t,frame:{xmin:t.frame.xmin,ymin:t.frame.ymin,xmax:t.frame.xmax+n,ymax:t.frame.ymax}}}return t});return{...t,symbolLayers:n}}function l(t,n,o){if(!t?.symbolLayers?.length)return null;const e=h(t);let i=null;for(const a of e.symbolLayers||[]){const t=x(a,n);t&&(i=i?L(i,t):t)}const r=new f(-16,-16,32,32);return i?L(i,r):r}function x(t,n){switch(t.type){case"CIMVectorMarker":return y(t,n);case"CIMPictureMarker":return M(t,n);default:return g(t,n)}}function y(t,n){const o=p(t.markerGraphics),e=t.frame,i=e?new f(e.xmin,e.ymin,e.xmax-e.xmin,e.ymax-e.ymin):null,r=o??i??w(t.size);if(!r)return null;const a=P(r),c=null!=e?.xmax&&null!=e?.xmin?e.xmax-e.xmin:r.width,s=null!=e?.ymax&&null!=e?.ymin?e.ymax-e.ymin:r.height,u=t.size&&s?t.size/s:1;if(i&&E(a,.5*-(e.xmax+e.xmin),.5*-(e.ymax+e.ymin)),t.anchorPoint){let n=t.anchorPoint.x,o=t.anchorPoint.y;"Absolute"!==t.anchorPointUnits?(n*=c,o*=s):0!==u&&(n/=u,o/=u),E(a,-n,-o)}return 1!==u&&b(a,u,u),d(a,t,n),I(a)}function M(t,n){const o=t.size;if(!o)return null;const e=o*(t.scaleX??1),i=P(new f(-e/2,-o/2,e,o));if(t.anchorPoint){let n=t.anchorPoint.x,r=t.anchorPoint.y;"Absolute"!==t.anchorPointUnits&&(n*=e,r*=o),E(i,-n,-r)}return d(i,t,n),I(i)}function g(t,n){const o=w(t.size);if(!o)return null;const e=P(o);if(t.anchorPoint){let n=t.anchorPoint.x,i=t.anchorPoint.y;"Absolute"!==t.anchorPointUnits&&(n*=o.width,i*=o.height),E(e,-n,-i)}return d(e,t,n),I(e)}function p(t){let n=null;for(const o of t||[]){if(!o.geometry)continue;const t=c(a(),o.geometry),e=new f(t[0],t[1],t[2]-t[0],t[3]-t[1]);n=n?L(n,e):e}return n}function w(t){return t?new f(-t/2,-t/2,t,t):null}function d(t,n,o){const e=n.rotation??0,i=(n.rotateClockwise?-e:e)*(Math.PI/180);i&&T(t,i),(n.offsetX||n.offsetY)&&E(t,n.offsetX??0,n.offsetY??0),o&&T(t,o)}function P(t){return[[t.x,t.y],[t.x+t.width,t.y],[t.x+t.width,t.y+t.height],[t.x,t.y+t.height]]}function I(t){let n=1/0,o=1/0,e=-1/0,i=-1/0;for(const[r,a]of t)n=Math.min(n,r),o=Math.min(o,a),e=Math.max(e,r),i=Math.max(i,a);return new f(n,o,e-n,i-o)}function E(t,n,o){for(const e of t)e[0]+=n,e[1]+=o}function b(t,n,o){for(const e of t)e[0]*=n,e[1]*=o}function T(t,n){for(const o of t)G(o,n)}function L(t,n){const o=Math.min(t.x,n.x),e=Math.min(t.y,n.y),i=Math.max(t.x+t.width,n.x+n.width),r=Math.max(t.y+t.height,n.y+n.height);return new f(o,e,i-o,r-e)}var X;function D(t,i,a){const c=n(r(),i[0]-t[0],i[1]-t[1]),s=o(c);return 0===s?[t[0],t[1]]:e(r(),t,c,a/s)}function Y(t){return{left:t.x,right:t.x+t.width,top:t.y+t.height,bottom:t.y}}function A(t,n){const o=Y(t),e=Y(n),i=o.left<=e.right&&e.left<=o.right,r=o.bottom<=e.top&&e.bottom<=o.top;return i&&r}function N(t,n,o){const e=S(t,o),i=S(n,o);return e[0]<=i[1]&&i[0]<=e[1]}function S(t,n){const o=[[t.x,t.y],[t.x+t.width,t.y],[t.x+t.width,t.y+t.height],[t.x,t.y+t.height]];let e=1/0,r=-1/0;for(const[a,c]of o){const t=i([a,c],n);e=Math.min(e,t),r=Math.max(r,t)}return[e,r]}function j(t,n){return new f(t.x*n,t.y*n,t.width*n,t.height*n)}function C(t,n,o){return new f(t.x+n,t.y+o,t.width,t.height)}function G(t,n){const o=t[0],e=t[1];t[0]=o*Math.cos(n)-e*Math.sin(n),t[1]=o*Math.sin(n)+e*Math.cos(n)}!function(t){t.objectId="OBJECTID",t.shape="SHAPE",t.dimLength="DIMLENGTH",t.beginX="BEGINX",t.beginY="BEGINY",t.endX="ENDX",t.endY="ENDY",t.textX="TEXTX",t.textY="TEXTY",t.styleId="STYLEID",t.dimX="DIMX",t.dimY="DIMY",t.customLength="CUSTOMLENGTH",t.useCustomLength="USECUSTOMLENGTH",t.dimDisplay="DIMDISPLAY",t.extDisplay="EXTDISPLAY",t.markerDisplay="MARKERDISPLAY",t.extAngle="EXTANGLE",t.dimType="DIMTYPE",t.textAngle="TEXTANGLE"}(X||(X={}));const U=1e-9;function k(t,n){return t[0]*n[1]-t[1]*n[0]}function z(t,n,o,e){return B(t,n,o,e)?.point??null}function B(t,o,i,a){const c=n(r(),Math.cos(o),Math.sin(o)),s=n(r(),Math.cos(a),Math.sin(a)),u=n(r(),i[0]-t[0],i[1]-t[1]),f=k(c,s);if(Math.abs(f)<=U)return null;const m=k(u,s)/f,h=k(u,c)/f;return{point:e(r(),t,c,m),t1:m,t2:h}}function H(t){const n=t[0],o=t[1];if(0===n&&0===o)return 0;if(0===n&&o>0)return Math.PI/2;if(0===n&&o<0)return 3*Math.PI/2;if(n<0&&0===o)return Math.PI;if(n>0&&0===o)return 0;let e=Math.atan2(o,n);return e<0&&(e+=2*Math.PI),e}export{X as DimensionRealFieldName,H as angleFromXAxis,m as getFontForCIMTextSymbol,z as intersectLinesByPointsAndAngles,l as measureMarkerSymbolSize,S as projectRectToAxis,D as queryPointOnLine,A as rectsOverlap,N as rectsOverlapOnAxis,h as repositionMarkerSymbol,G as rotatePoint,j as scaleRect,Y as toBounds,C as translateRect};
|