@arcgis/core 4.34.1 → 4.34.3
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/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/{fdaf8fb5a3cc7abea44b.js → 1a206387dc9f5f1b0f79.js} +1 -1
- package/assets/esri/core/workers/chunks/{7010d1eb303a13c72f81.js → 999da9a02ecdf6129c69.js} +1 -1
- package/assets/esri/core/workers/chunks/e7689eb3c45be276acfb.js +1 -0
- package/assets/esri/themes/base/widgets/_FeatureTable.scss +0 -1
- package/assets/esri/themes/dark/main.css +1 -1
- package/assets/esri/themes/light/main.css +1 -1
- package/assets/esri/themes/light/view.css +1 -1
- package/interfaces.d.ts +10 -10
- package/kernel.js +1 -1
- package/layers/support/vectorTileLayerLoader.js +1 -1
- package/package.json +1 -1
- package/support/revision.js +1 -1
- package/symbols/cim/CIMSymbolDrawHelper.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/shaders/GradientStrokeShader.js +1 -1
- package/views/2d/layers/features/processor/TrackStrategy.js +1 -1
- package/views/2d/layers/features/sources/FeatureSource.js +1 -1
- package/views/2d/layers/features/sources/strategies/AFeatureLoadStrategy.js +1 -1
- package/views/2d/layers/features/sources/strategies/ALoadStrategy.js +1 -1
- package/views/2d/layers/features/sources/strategies/chunks/Overrides.js +1 -1
- package/widgets/FeatureTable/support/templateUtils.js +1 -1
- package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
- package/widgets/OrientedImageryViewer/adapters/sketch/TriangulatedMeasurementAdapter.js +1 -1
- package/widgets/OrientedImageryViewer/imageMeasurementUtils.js +1 -1
- package/widgets/OrientedImageryViewer/mixins/TriangulatedImageMeasurementMixin.js +1 -1
- package/widgets/VideoPlayer/VideoPlayerViewModel.js +1 -1
- package/widgets/support/SelectionToolbar.js +1 -1
- package/assets/esri/core/workers/chunks/4a38b1402cd48ced5d0f.js +0 -1
package/interfaces.d.ts
CHANGED
|
@@ -1074,8 +1074,8 @@ declare namespace __esri {
|
|
|
1074
1074
|
*/
|
|
1075
1075
|
readonly valid: boolean;
|
|
1076
1076
|
/**
|
|
1077
|
-
* The `ElevationProfileAnalysis` class enables programmatic creation and management of elevation profiles in both
|
|
1078
|
-
* {@link https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html SceneView} and {@link https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html MapView}.
|
|
1077
|
+
* The `ElevationProfileAnalysis` class enables programmatic creation and management of elevation profiles in both,
|
|
1078
|
+
* a {@link https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html SceneView} and a {@link https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html MapView}.
|
|
1079
1079
|
*
|
|
1080
1080
|
* {@link https://developers.arcgis.com/javascript/latest/api-reference/esri-analysis-ElevationProfileAnalysis.html Read more...}
|
|
1081
1081
|
*/
|
|
@@ -96954,13 +96954,13 @@ declare namespace __esri {
|
|
|
96954
96954
|
*/
|
|
96955
96955
|
readonly error: ElevationProfileError | nullish;
|
|
96956
96956
|
/**
|
|
96957
|
-
* Points
|
|
96957
|
+
* Points in the view that are computed from the {@link https://developers.arcgis.com/javascript/latest/api-reference/esri-views-2d-analysis-ElevationProfileAnalysisView2D.html#hoveredPosition hoveredPosition} property (in the view's spatial reference).
|
|
96958
96958
|
*
|
|
96959
96959
|
* {@link https://developers.arcgis.com/javascript/latest/api-reference/esri-views-2d-analysis-ElevationProfileAnalysisView2D.html#hoveredPoints Read more...}
|
|
96960
96960
|
*/
|
|
96961
96961
|
readonly hoveredPoints: (Point | nullish)[];
|
|
96962
96962
|
/**
|
|
96963
|
-
* Property
|
|
96963
|
+
* Property that indicates a relative position along a {@link https://developers.arcgis.com/javascript/latest/api-reference/esri-views-analysis-ElevationProfile-ElevationProfileResult.html result's} profile line, in [0, 1].
|
|
96964
96964
|
*
|
|
96965
96965
|
* @default null
|
|
96966
96966
|
*
|
|
@@ -97733,13 +97733,13 @@ declare namespace __esri {
|
|
|
97733
97733
|
*/
|
|
97734
97734
|
readonly error: ElevationProfileError | nullish;
|
|
97735
97735
|
/**
|
|
97736
|
-
* Points
|
|
97736
|
+
* Points in the view that are computed from the {@link https://developers.arcgis.com/javascript/latest/api-reference/esri-views-3d-analysis-ElevationProfileAnalysisView3D.html#hoveredPosition hoveredPosition} property (in the view's spatial reference).
|
|
97737
97737
|
*
|
|
97738
97738
|
* {@link https://developers.arcgis.com/javascript/latest/api-reference/esri-views-3d-analysis-ElevationProfileAnalysisView3D.html#hoveredPoints Read more...}
|
|
97739
97739
|
*/
|
|
97740
97740
|
readonly hoveredPoints: (Point | nullish)[];
|
|
97741
97741
|
/**
|
|
97742
|
-
* Property
|
|
97742
|
+
* Property that indicates a relative position along a {@link https://developers.arcgis.com/javascript/latest/api-reference/esri-views-analysis-ElevationProfile-ElevationProfileResult.html result's} profile line, in [0, 1].
|
|
97743
97743
|
*
|
|
97744
97744
|
* @default null
|
|
97745
97745
|
*
|
|
@@ -115859,7 +115859,7 @@ declare namespace __esri {
|
|
|
115859
115859
|
*/
|
|
115860
115860
|
label: string;
|
|
115861
115861
|
/**
|
|
115862
|
-
* Controls the speed of the daytime
|
|
115862
|
+
* Controls the speed of the daytime animation.
|
|
115863
115863
|
*
|
|
115864
115864
|
* @default 1.0
|
|
115865
115865
|
*
|
|
@@ -115930,7 +115930,7 @@ declare namespace __esri {
|
|
|
115930
115930
|
*/
|
|
115931
115931
|
label?: string;
|
|
115932
115932
|
/**
|
|
115933
|
-
* Controls the speed of the daytime
|
|
115933
|
+
* Controls the speed of the daytime animation.
|
|
115934
115934
|
*
|
|
115935
115935
|
* {@link https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Daylight.html#playSpeedMultiplier Read more...}
|
|
115936
115936
|
*/
|
|
@@ -115987,7 +115987,7 @@ declare namespace __esri {
|
|
|
115987
115987
|
*/
|
|
115988
115988
|
directShadowsEnabled: boolean;
|
|
115989
115989
|
/**
|
|
115990
|
-
* Controls the daytime
|
|
115990
|
+
* Controls the daytime animation speed.
|
|
115991
115991
|
*
|
|
115992
115992
|
* @default 1.0
|
|
115993
115993
|
*
|
|
@@ -116087,7 +116087,7 @@ declare namespace __esri {
|
|
|
116087
116087
|
*/
|
|
116088
116088
|
localDate?: DateProperties;
|
|
116089
116089
|
/**
|
|
116090
|
-
* Controls the daytime
|
|
116090
|
+
* Controls the daytime animation speed.
|
|
116091
116091
|
*
|
|
116092
116092
|
* {@link https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Daylight-DaylightViewModel.html#playSpeedMultiplier Read more...}
|
|
116093
116093
|
*/
|
package/kernel.js
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import has from"./core/has.js";import{addQueryParameter as o}from"./core/urlUtils.js";export{buildDate,commitHash as revision}from"./support/revision.js";Symbol.dispose??=Symbol("Symbol.dispose"),Symbol.asyncDispose??=Symbol("Symbol.asyncDispose");const e="4.34";let s,r=e;function i(o){s=o}function t(e){const r=s?.findCredential(e);return r?.token?o(e,"token",r.token):e}r="4.34.
|
|
5
|
+
import has from"./core/has.js";import{addQueryParameter as o}from"./core/urlUtils.js";export{buildDate,commitHash as revision}from"./support/revision.js";Symbol.dispose??=Symbol("Symbol.dispose"),Symbol.asyncDispose??=Symbol("Symbol.asyncDispose");const e="4.34";let s,r=e;function i(o){s=o}function t(e){const r=s?.findCredential(e);return r?.token?o(e,"token",r.token):e}r="4.34.3",has("host-webworker")||globalThis.$arcgis||Object.defineProperty(globalThis,"$arcgis",{configurable:!1,enumerable:!0,writable:!1,value:{}}),has("host-webworker");export{t as addTokenParameter,r as fullVersion,s as id,i as setId,e as version};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import e from"../../request.js";import{clone as t}from"../../core/lang.js";import{throwIfAborted as o}from"../../core/promiseUtils.js";import{normalize as
|
|
5
|
+
import e from"../../request.js";import{clone as t}from"../../core/lang.js";import{throwIfAborted as o}from"../../core/promiseUtils.js";import{normalize as l,removeFile as r,getAppBaseUrl as s,removeTrailingSlash as n,addQueryParameters as i,isProtocolRelative as u,isAbsolute as c,join as a}from"../../core/urlUtils.js";import{wgs84 as f,webMercator as y}from"../../geometry/support/spatialReferenceUtils.js";import{geographicToWebMercator as p}from"../../geometry/support/webMercatorUtils.js";import m from"../../views/2d/engine/vectorTiles/style/VectorTileSource.js";async function d(e,t){const o={source:null,sourceBase:null,sourceUrl:null,validatedSource:null,style:null,styleBase:null,styleUrl:null,sourceNameToSource:{},primarySourceName:"",spriteFormat:"png"},[l,r]="string"==typeof e?[e,null]:[null,e.jsonUrl];await S(o,"esri",e,r,t);return{layerDefinition:o.validatedSource,url:l,serviceUrl:o.sourceUrl,style:o.style,styleUrl:o.styleUrl,spriteUrl:o.style&&o.style.sprite&&h(o.styleBase,o.style.sprite),spriteFormat:o.spriteFormat,glyphsUrl:o.style&&o.style.glyphs&&h(o.styleBase,o.style.glyphs),sourceNameToSource:o.sourceNameToSource,primarySourceName:o.primarySourceName}}function h(...e){let t;for(const o of e)if(null!=o)if(u(o)){if(t){const e=t.split("://")[0];t=e+":"+o.trim()}}else t=c(o)?o:a(t,o);return t?n(t):void 0}async function S(t,r,s,n,i){let u,c,a;if(o(i),"string"==typeof s){const t=l(s);a=await e(t,{...i,responseType:"json",query:{f:"json",...i?.query}}),a.ssl&&(u&&(u=u.replace(/^http:/i,"https:")),c&&(c=c.replace(/^http:/i,"https:"))),u=t,c=t}else null!=s&&(a={data:s},u=s.jsonUrl||null,c=n);const f=a?.data;if(g(f))return t.styleUrl=u||null,j(t,f,c,i);if(w(f))return t.sourceUrl?U(t,f,c,!1,r,i):(t.sourceUrl=u||null,x(f)&&null==t.style&&(r="tilejson"),U(t,f,c,!0,r,i));throw new Error("You must specify the URL or the JSON for a service or for a style.")}function x(e){return"object"==typeof e&&!!e&&"tilejson"in e&&null!=e.tilejson}function g(e){return!!e&&"sources"in e&&!!e.sources}function w(e){return!g(e)}async function j(e,t,o,l){const n=o?r(o):s();e.styleBase=n,e.style=t,t["sprite-format"]&&"webp"===t["sprite-format"].toLowerCase()&&(e.spriteFormat="webp");const i=[];if(t.sources&&t.sources.esri){const o=t.sources.esri;o.url?await S(e,"esri",h(n,o.url),void 0,l):i.push(S(e,"esri",o,n,l))}for(const r of Object.keys(t.sources))"esri"!==r&&"tilejson"!==r&&"vector"===t.sources[r].type&&(t.sources[r].url?i.push(S(e,r,h(n,t.sources[r].url),void 0,l)):t.sources[r].tiles&&i.push(S(e,r,t.sources[r],n,l)));await Promise.all(i)}async function U(e,t,o,l,r,u){const c=o?n(o)+"/":s(),a=v(t,e),f=new m(r,i(c,u?.query??{}),a);if(!l&&e.primarySourceName in e.sourceNameToSource){const t=e.sourceNameToSource[e.primarySourceName];if(!t.isCompatibleWith(f))return;null!=f.fullExtent&&(null!=t.fullExtent?t.fullExtent.union(f.fullExtent):t.fullExtent=f.fullExtent.clone()),t.tileInfo&&f.tileInfo&&t.tileInfo.lods.length<f.tileInfo.lods.length&&(t.tileInfo=f.tileInfo)}if(l&&(e.sourceBase=c,e.source=t,e.validatedSource=a,e.primarySourceName=r),e.sourceNameToSource[r]=f,!x(e)&&"defaultStyles"in t&&!e.style){if(null==t.defaultStyles)throw new Error;return"string"==typeof t.defaultStyles?S(e,"",h(c,t.defaultStyles,"root.json"),void 0,u):S(e,"",t.defaultStyles,h(c,"root.json"),u)}if(x(t)&&null==e.style&&a.defaultStyles)return S(e,"",a.defaultStyles,h(c,"root.json"),u)}function v(e,o){const l=512;if(N(e)){const t=e?.tileInfo;return null!=t&&(null==t.rows&&(t.rows=l),null==t.cols&&(t.cols=l)),e}const r={xmin:-20037507.067161843,ymin:-20037507.067161843,xmax:20037507.067161843,ymax:20037507.067161843,spatialReference:{wkid:102100,latestWkid:3857}};let s,n=null;if(x(e)){const{bounds:l,vector_layers:r}=e;if(l){const e=p({x:l[0],y:l[1],spatialReference:t(f)}),o=p({x:l[2],y:l[3],spatialReference:t(f)});n={xmin:e.x,ymin:e.y,xmax:o.x,ymax:o.y,spatialReference:t(y)}}if(r&&r.length>0)s={version:8,sprite:"",glyphs:"",sources:{tilejson:{type:"vector",url:e.tilejson}},layers:T(r)};else if(null==o.style)throw new Error("The TileJSON source does not contain any vector_layers. This VectorTileLayer cannot be loaded.")}null===n&&(n=r);let i=78271.51696400007,u=295828763.7957775;const c=[],a=e.hasOwnProperty("maxzoom")&&null!=e.maxzoom?Math.abs(+e.maxzoom):22,m=0,d=0;for(let t=0;t<=a;t++)c.push({level:t,scale:u,resolution:i}),i/=2,u/=2;return{capabilities:"TilesOnly",initialExtent:n,fullExtent:r,minScale:m,maxScale:d,tiles:e.tiles,tileInfo:{rows:l,cols:l,dpi:96,format:"pbf",origin:{x:-20037508.342787,y:20037508.342787},lods:c,spatialReference:t(y)},defaultStyles:s}}function N(e){return e.hasOwnProperty("tileInfo")}function T(e){const t=[];for(const o of e)o.geometry_type?t.push(b(o.geometry_type.toLowerCase(),o,!1)):(t.push(b("polygon",o,!0)),t.push(b("line",o,!0)),t.push(b("circle",o,!0)));return t}function b(e,t,o){const{id:l,minzoom:r,maxzoom:s}=t,n={type:"polygon"===e||"polygons"===e?"fill":"line"===e||"lines"===e?"line":"circle",id:l,source:"tilejson","source-layer":l,minzoom:r,maxzoom:s};switch(e){case"fill":o&&(n.id+="_polygon",n.filter='(["==", "$type", "Polygon"])'),n.paint={"fill-color":"#808080"};break;case"line":o&&(n.id+="_line",n.filter='(["==", "$type", "LineString"])');break;case"circle":o&&(n.id+="_point",n.filter='(["==", "$type", "Point"])')}return n}export{d as loadMetadata};
|
package/package.json
CHANGED
package/support/revision.js
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
const
|
|
5
|
+
const e="20251024",b="b3bf5e867e72e81e18e50509bd6e0bd0d4bb4746";export{e as buildDate,b as commitHash};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{defaultFontFamily as t}from"../../core/fontUtils.js";import has from"../../core/has.js";import{clone as e}from"../../core/lang.js";import r from"../../core/Logger.js";import{deg2rad as i}from"../../core/mathUtils.js";import s from"../../core/ObjectPool.js";import{px2pt as o,pt2px as n}from"../../core/screenUtils.js";import{GeometryCursor as a}from"../../geometry/GeometryCursor.js";import{create as l,fromValues as h,empty as c,expandPointInPlace as m,center as f,width as u,height as d,diagonal as p}from"../../geometry/support/aaBoundingRect.js";import{getBoundsXY as g}from"../../geometry/support/boundsUtils.js";import{polygonCentroid as _}from"../../geometry/support/centroid.js";import{isExtent as y,isPolygon as P,isPolyline as S,isMultipoint as w,isPoint as x}from"../../geometry/support/jsonUtils.js";import{SimpleEffectCursor as M}from"./CIMEffects.js";import b from"./CIMImageColorSubstitutionHelper.js";import{getEffectOperator as k,getPlacementOperator as C}from"./CIMOperators.js";import{Placement as v}from"./CIMPlacements.js";import{defaultCIMValues as I}from"./defaultCIMValues.js";import{getFirstFrame as T}from"./imageUtils.js";import{rotate as R}from"./mathUtils.js";import{addColorStops as z}from"./rasterizingUtils.js";import L from"./Rect.js";import F from"./TextRasterizer.js";import{isCIMFill as A,getSize as U,getNumericValue as j,isSVGImage as G,getRelativeGradientSize as D,fromCIMFontDecoration as H,fromCIMFontStyle as B,fromCIMHorizontalAlignment as E,fromCIMVerticalAlignment as X,getFillColor as J,getStrokeColor as N,getStrokeWidth as O,getFontWeight as q,getFontStyle as V}from"./utils.js";import{destroyHiddenSvg as W,createHiddenSvg as Y,createSvgElement as $}from"../../views/2d/engine/svgUtils.js";import{magicLabelLineHeight as K,glyphSize as Q,hittestToleranceSmallSymbol as Z,hittestSmallSymbolThreshold as tt}from"../../views/2d/engine/webgl/definitions.js";import{shapeGlyphs as et}from"../../views/2d/engine/webgl/mesh/templates/shapingUtils.js";import{roundPtToWholePixel as rt,getLineWidth as it}from"../../views/2d/layers/graphics/graphicsUtils.js";const st=Math.PI/180,ot=.5,nt=()=>r.getLogger("esri.symbols.cim.CIMSymbolDrawHelper");class at{constructor(t){this._t=t}static createIdentity(){return new at([1,0,0,0,1,0])}clone(){const t=this._t;return new at(t.slice())}transform(t){const e=this._t;return[e[0]*t[0]+e[1]*t[1]+e[2],e[3]*t[0]+e[4]*t[1]+e[5]]}static createScale(t,e){return new at([t,0,0,0,e,0])}scale(t,e){const r=this._t;return r[0]*=t,r[1]*=t,r[2]*=t,r[3]*=e,r[4]*=e,r[5]*=e,this}scaleRatio(){return Math.sqrt(this._t[0]*this._t[0]+this._t[1]*this._t[1])}static createTranslate(t,e){return new at([0,0,t,0,0,e])}translate(t,e){const r=this._t;return r[2]+=t,r[5]+=e,this}static createRotate(t){const e=Math.cos(t),r=Math.sin(t);return new at([e,-r,0,r,e,0])}rotate(t){return at.multiply(this,at.createRotate(t),this)}angle(){const t=this._t[0],e=this._t[3],r=Math.sqrt(t*t+e*e);return[t/r,e/r]}static multiply(t,e,r){const i=t._t,s=e._t,o=i[0]*s[0]+i[3]*s[1],n=i[1]*s[0]+i[4]*s[1],a=i[2]*s[0]+i[5]*s[1]+s[2],l=i[0]*s[3]+i[3]*s[4],h=i[1]*s[3]+i[4]*s[4],c=i[2]*s[3]+i[5]*s[4]+s[5],m=r._t;return m[0]=o,m[1]=n,m[2]=a,m[3]=l,m[4]=h,m[5]=c,r}invert(){const t=this._t;let e=t[0]*t[4]-t[1]*t[3];if(0===e)return new at([0,0,0,0,0,0]);e=1/e;const r=(t[1]*t[5]-t[2]*t[4])*e,i=(t[2]*t[3]-t[0]*t[5])*e,s=t[4]*e,o=-t[1]*e,n=-t[3]*e,a=t[0]*e;return new at([s,o,r,n,a,i])}}class lt{constructor(t,e){this._resourceManager=t,this._transfos=[],this._sizeTransfos=[],this._geomUnitsPerPoint=1,this._placementPool=new s(()=>new v,void 0,void 0,100),this._earlyReturn=!1,this._mapRotation=0,this._transfos.push(e||at.createIdentity()),this._sizeTransfos.push(e?e.scaleRatio():1)}setTransform(t,e){this._transfos=[t||at.createIdentity()],this._sizeTransfos=[e||(t?t.scaleRatio():1)]}setGeomUnitsPerPoint(t){this._geomUnitsPerPoint=t}transformPt(t){return this._transfos[this._transfos.length-1].transform(t)}transformSize(t){return t*this._sizeTransfos[this._sizeTransfos.length-1]}reverseTransformPt(t){return this._transfos[this._transfos.length-1].invert().transform(t)}reverseTransformSize(t){return t/this._sizeTransfos[this._sizeTransfos.length-1]}reverseTransformScalar(t){return t/this._transfos[this._transfos.length-1].scaleRatio()}getTransformAngle(){return this._transfos[this._transfos.length-1].angle()}geomUnitsPerPoint(){return this.isEmbedded()?1:this._geomUnitsPerPoint}prevGeomUnitsPerPoint(){return this._transfos.length>2?1:this._geomUnitsPerPoint}isEmbedded(){return this._transfos.length>1}back(){return this._transfos[this._transfos.length-1]}push(t,e){const r=e?t.scaleRatio():1;at.multiply(t,this.back(),t),this._transfos.push(t),this._sizeTransfos.push(this._sizeTransfos[this._sizeTransfos.length-1]*r)}pop(){this._transfos.splice(-1,1),this._sizeTransfos.splice(-1,1)}drawSymbol(t,e,r){if(t)switch(t.type){case"CIMPointSymbol":case"CIMLineSymbol":case"CIMPolygonSymbol":this.drawMultiLayerSymbol(t,e);break;case"CIMTextSymbol":this.drawTextSymbol(t,e,r)}}drawMultiLayerSymbol(t,e){if(!t||!e)return;const r=t.symbolLayers;if(!r)return;const i=t.effects;if(i&&i.length>0){const t=this.executeEffects(i,e);if(t){let e=t.next();for(;e;)this.drawSymbolLayers(r,e.asJSON()),e=t.next()}}else this.drawSymbolLayers(r,e)}executeEffects(t,e){let r=new M(a.fromJSONCIM(e));for(const i of t){const t=k(i);t&&(r=t.execute(r,i,this.geomUnitsPerPoint(),null))}return r}drawSymbolLayers(t,e){let r=t.length;for(;r--;){const i=t[r];if(!i||!1===i.enable)continue;const s=i.effects;if(s&&s.length>0){const t=this.executeEffects(s,e);if(t){let e=null;for(;(e=t.next())&&(this.drawSymbolLayer(i,e.asJSON()),!this._earlyReturn););}}else this.drawSymbolLayer(i,e);if(this._earlyReturn)return}}drawSymbolLayer(t,e){switch(t.type){case"CIMSolidFill":this.drawSolidFill(e,t.color,t.path);break;case"CIMHatchFill":this.drawHatchFill(e,t);break;case"CIMPictureFill":this.drawPictureFill(e,t);break;case"CIMGradientFill":this.drawGradientFill(e,t);break;case"CIMSolidStroke":this.drawSolidStroke(e,t.color,t.width,t.capStyle,t.joinStyle,t.miterLimit,t.path);break;case"CIMPictureStroke":this.drawPictureStroke(e,t);break;case"CIMGradientStroke":this.drawGradientStroke(e,t);break;case"CIMCharacterMarker":case"CIMPictureMarker":case"CIMVectorMarker":this.drawMarkerLayer(t,e)}}drawHatchFill(t,e){const r=ft(e,t,this.geomUnitsPerPoint());r&&(this.pushClipPath(t),this.drawMultiLayerSymbol(e.lineSymbol,r),this.popClipPath())}drawPictureFill(t,e){}drawGradientFill(t,e){}drawPictureStroke(t,e){}drawGradientStroke(t,e){}drawMarkerLayer(t,e){const r=t.markerPlacement;if(r){const i=C(r);if(i){const s="CIMMarkerPlacementInsidePolygon"===r.type||"CIMMarkerPlacementPolygonCenter"===r.type&&r.clipAtBoundary;s&&this.pushClipPath(e);const o=i.execute(a.fromJSONCIM(e),r,this.geomUnitsPerPoint(),null);if(o){let e=null;for(;(e=o.next())&&(this.drawMarker(t,e),!this._earlyReturn););}s&&this.popClipPath()}}else{const r=this._placementPool.acquire();if(x(e))r.tx=e.x,r.ty=e.y,this.drawMarker(t,r);else if(P(e)){const i=_(e);i&&([r.tx,r.ty]=i,this.drawMarker(t,r))}else if(S(e)){for(const i of e.paths)for(const e of i)if(r.tx=e[0],r.ty=e[1],this.drawMarker(t,r),this._earlyReturn)break}else for(const i of e.points)if(r.tx=i[0],r.ty=i[1],this.drawMarker(t,r),this._earlyReturn)break;this._placementPool.release(r)}}drawMarker(t,e){switch(t.type){case"CIMCharacterMarker":case"CIMPictureMarker":this.drawPictureMarker(t,e);break;case"CIMVectorMarker":this.drawVectorMarker(t,e)}}drawPictureMarker(t,e){if(!t)return;const r=this._resourceManager.getResource(t.url),i=j(t.size,I.CIMPictureMarker.size);if(null==r||i<=0)return;const s=r.width,o=r.height;if(!s||!o)return;const n=s/o,a=j(t.scaleX,1),l=at.createIdentity(),h=t.anchorPoint;if(h){let e=h.x,r=h.y;"Absolute"!==t.anchorPointUnits&&(e*=i*n*a,r*=i),l.translate(-e,-r)}let c=j(t.rotation);t.rotateClockwise&&(c=-c),this._mapRotation&&(c+=this._mapRotation),c&&l.rotate(c*st);let m=j(t.offsetX),f=j(t.offsetY);if(m||f){if(this._mapRotation){const t=st*this._mapRotation,e=Math.cos(t),r=Math.sin(t),i=m*r+f*e;m=m*e-f*r,f=i}l.translate(m,f)}const u=this.geomUnitsPerPoint();1!==u&&l.scale(u,u);const d=e.getAngle();d&&l.rotate(d),l.translate(e.tx,e.ty),this.push(l,!1),this.drawImage(t,i),this.pop()}drawVectorMarker(t,e){if(!t)return;const r=t.markerGraphics;if(!r)return;const i=j(t.size,I.CIMVectorMarker.size),s=t.frame,o=s?s.ymax-s.ymin:0,n=i&&o?i/o:1,a=at.createIdentity();s&&a.translate(.5*-(s.xmax+s.xmin),.5*-(s.ymax+s.ymin));const l=t.anchorPoint;if(l){let e=l.x,r=l.y;"Absolute"!==t.anchorPointUnits?s&&(e*=s.xmax-s.xmin,r*=s.ymax-s.ymin):(e/=n,r/=n),a.translate(-e,-r)}1!==n&&a.scale(n,n);let h=j(t.rotation);t.rotateClockwise&&(h=-h),this._mapRotation&&(h+=this._mapRotation),h&&a.rotate(h*st);let c=j(t.offsetX),m=j(t.offsetY);if(c||m){if(this._mapRotation){const t=st*this._mapRotation,e=Math.cos(t),r=Math.sin(t),i=c*r+m*e;c=c*e-m*r,m=i}a.translate(c,m)}const f=this.geomUnitsPerPoint();1!==f&&a.scale(f,f);const u=e.getAngle();u&&a.rotate(u),a.translate(e.tx,e.ty),this.push(a,t.scaleSymbolsProportionally);for(const d of r){d?.symbol&&d.geometry||nt().error("Invalid marker graphic",d);let t=d.textString;if("number"==typeof t&&(t=t.toString()),this.drawSymbol(d.symbol,d.geometry,t),this._earlyReturn)break}this.pop()}drawTextSymbol(t,e,r){if(!t)return;if(!x(e))return;if(j(t.height,I.CIMTextSymbol.height)<=0)return;const i=at.createIdentity();let s=j(t.angle);s=-s,s&&i.rotate(s*st);const o=j(t.offsetX),n=j(t.offsetY);(o||n)&&i.translate(o,n);const a=this.geomUnitsPerPoint();1!==a&&i.scale(a,a),i.translate(e.x,e.y),this.push(i,!1),this.drawText(t,r),this.pop()}}class ht extends lt{constructor(t,e){super(t,e),this.reset()}reset(){this._xmin=this._ymin=1/0,this._xmax=this._ymax=-1/0,this._clipCount=0}envelope(){return new L(this._xmin,this._ymin,this._xmax-this._xmin,this._ymax-this._ymin)}bounds(){return h(this._xmin,this._ymin,this._xmax,this._ymax)}drawSolidFill(t){if(t&&!(this._clipCount>0))if(P(t))this._processPath(t.rings,0);else if(S(t))this._processPath(t.paths,0);else if(y(t)){const e=gt(t);e&&this._processPath(e.rings,0)}else console.error("drawSolidFill Unexpected geometry type!")}drawSolidStroke(t,e,r){if(!t||this._clipCount>0||null==r||r<=0)return;const i=Math.max(.5*this.transformSize(j(r,I.CIMSolidStroke.width)),.5*ot);if(P(t))this._processPath(t.rings,i);else if(S(t))this._processPath(t.paths,i);else if(y(t)){const e=gt(t);e&&this._processPath(e.rings,i)}else console.error("drawSolidStroke unexpected geometry type!")}drawMarkerLayer(t,e){P(e)&&t.markerPlacement&&("CIMMarkerPlacementInsidePolygon"===t.markerPlacement.type||"CIMMarkerPlacementPolygonCenter"===t.markerPlacement.type&&t.markerPlacement.clipAtBoundary)?this._processPath(e.rings,0):super.drawMarkerLayer(t,e)}drawHatchFill(t,e){this.drawSolidFill(t)}drawPictureFill(t,e){this.drawSolidFill(t)}drawGradientFill(t,e){this.drawSolidFill(t)}drawPictureStroke(t,e){this.drawSolidStroke(t,null,e.width)}drawGradientStroke(t,e){this.drawSolidStroke(t,null,e.width)}pushClipPath(t){this.drawSolidFill(t),this._clipCount++}popClipPath(){this._clipCount--}drawImage(t,e){const{url:r}=t,i=j(t.scaleX,1);let s=i*e,o=e;const n=this._resourceManager.getResource(r);if(null!=n){const t=n.height/n.width;s=i*(e?t>1?e:e/t:n.width),o=e?t>1?e*t:e:n.height}this._merge(this.transformPt([-s/2,-o/2]),0),this._merge(this.transformPt([-s/2,o/2]),0),this._merge(this.transformPt([s/2,-o/2]),0),this._merge(this.transformPt([s/2,o/2]),0)}drawText(t,e){if(!e||0===e.length)return;this._textRasterizer||(this._textRasterizer=new F);const r=yt(t);let[i,s]=this._textRasterizer.computeTextSize(e,r);i=o(i),s=o(s);const n=this.transformSize(1)*this.reverseTransformScalar(1);i*=n,s*=n;let a=0;switch(t.horizontalAlignment){case"Left":a=i/2;break;case"Right":a=-i/2}let l=0;switch(t.verticalAlignment){case"Bottom":l=s/2;break;case"Top":l=-s/2;break;case"Baseline":l=s/6}this._merge(this.transformPt([-i/2+a,-s/2+l]),0),this._merge(this.transformPt([-i/2+a,s/2+l]),0),this._merge(this.transformPt([i/2+a,-s/2+l]),0),this._merge(this.transformPt([i/2+a,s/2+l]),0)}_processPath(t,e){if(t)for(const r of t){const t=r?r.length:0;if(t>1){this._merge(this.transformPt(r[0]),e);for(let i=1;i<t;i++)this._merge(this.transformPt(r[i]),e)}}}_merge(t,e){t[0]-e<this._xmin&&(this._xmin=t[0]-e),t[0]+e>this._xmax&&(this._xmax=t[0]+e),t[1]-e<this._ymin&&(this._ymin=t[1]-e),t[1]+e>this._ymax&&(this._ymax=t[1]+e)}}class ct extends lt{constructor(){super(...arguments),this._searchPoint=[0,0],this._searchDistPoint=0,this._textInfo=null,this._svg=null,this._path=null,this._canvas=null}destroy(){this._svg=W(this._svg),this._path=null,this._canvas=null}hitTest(t,e,r,i,s,a){const l=a*n(1);this.setTransform(),this.setGeomUnitsPerPoint(l),this._searchPoint=[(t[0]+t[2])/2,(t[1]+t[3])/2],this._searchDistPoint=(t[2]-t[0])/2/l,this._textInfo=i;const h=e&&("CIMPointSymbol"===e.type&&"Map"!==e.angleAlignment||"CIMTextSymbol"===e.type);if(this._mapRotation=h?s:0,!has("esri-mobile")){const t=o(Z*window.devicePixelRatio),r=o(tt);!(("CIMLineSymbol"===e?.type||"CIMPolygonSymbol"===e?.type)&&e.symbolLayers?.some(A))&&"CIMMeshSymbol"!==e?.type&&(U(e)??0)<r&&(this._searchDistPoint=t)}return this._earlyReturn=!1,this.drawSymbol(e,r),this._earlyReturn}executeEffects(t,e){return"CIMGeometricEffectDashes"===t.at(-1)?.type&&(t=t.slice(0,-1)),super.executeEffects(t,e)}drawSolidFill(t,e,r){null!=r?this._hittestSvgPath(t,r,!0):this._hitTestFill(t)}drawHatchFill(t,e){this._hitTestFill(t)}drawPictureFill(t,e){this._hitTestFill(t)}drawGradientFill(t,e){this._hitTestFill(t)}drawSolidStroke(t,e,r,i,s,o,n){null!=n?this._hittestSvgPath(t,n,!1,r):this._hitTestStroke(t,r)}drawPictureStroke(t,e){this._hitTestStroke(t,e.width)}drawGradientStroke(t,e){this._hitTestStroke(t,e.width)}drawMarkerLayer(t,e){t.markerPlacement&&("CIMMarkerPlacementInsidePolygon"===t.markerPlacement.type||"CIMMarkerPlacementPolygonCenter"===t.markerPlacement.type&&t.markerPlacement.clipAtBoundary)?this._hitTestFill(e):super.drawMarkerLayer(t,e)}pushClipPath(t){}popClipPath(){}drawImage(t,e){const{url:r}=t,i=j(t.scaleX,1),s=this._resourceManager.getResource(r);if(null==s||0===s.height||0===e)return;const o=e*this.geomUnitsPerPoint(),n=o*i*(s.width/s.height),a=this.reverseTransformPt(this._searchPoint),l=this._searchDistPoint;Math.abs(a[0])<n/2+l&&Math.abs(a[1])<o/2+l&&(this._earlyReturn=!0)}drawText(t,e){const r=this._textInfo;if(!r)return;const i=r.get(t);if(!i)return;if(!i.glyphMosaicItems.glyphs.length)return;const s=rt(j(t.height,I.CIMTextSymbol.height)),{lineGapType:o,lineGap:n}=t,a=o?_t(o,j(n),s):0,l="CIMBackgroundCallout"===t.callout?.type,h=et(i.glyphMosaicItems,{scale:s/Q,angle:0,xOffset:0,yOffset:0,horizontalAlignment:t.horizontalAlignment,verticalAlignment:t.verticalAlignment,maxLineWidth:it(t.lineWidth),lineHeight:K*Math.max(.25,Math.min(a||1,4)),decoration:t.font.decoration||"none",useCIMAngleBehavior:!0,hasBackground:l}),c=this.reverseTransformPt(this._searchPoint),m=c[0],f=c[1];for(const u of h.glyphs)if(m>u.xTopLeft&&m<u.xBottomRight&&f>-u.yBottomRight&&f<-u.yTopLeft){this._earlyReturn=!0;break}}_hitTestFill(t){let e=null;if(y(t)){const r=t;e=[[[r.xmin,r.ymin],[r.xmin,r.ymax],[r.xmax,r.ymax],[r.xmax,r.ymin],[r.xmin,r.ymin]]]}else if(P(t))e=t.rings;else{if(!S(t))return;e=t.paths}const r=this.reverseTransformPt(this._searchPoint);if(ut(r,e)&&(this._earlyReturn=!0),!this._earlyReturn){dt(r,e,this.reverseTransformScalar(this._searchDistPoint)*this.prevGeomUnitsPerPoint())&&(this._earlyReturn=!0)}}_getSvgPath(){return null!=this._svg&&null!=this._path||(this._svg??=Y(),this._path??=$("path"),this._svg.appendChild(this._path)),this._path}_getCanvasContext(t,e){return this._canvas??=document.createElement("canvas"),this._canvas.width=t,this._canvas.height=e,this._canvas.getContext("2d",{willReadFrequently:!0})}_hittestSvgPath(t,e,r,i=0){const s=this.reverseTransformScalar(this._searchDistPoint)*this.prevGeomUnitsPerPoint(),o=this.reverseTransformPt(this._searchPoint),n=l();g(n,t);const a={x:n[0],y:n[1],width:n[2]-n[0],height:n[3]-n[1]},h=this._getSvgPath();h.setAttribute("d",e);const c=h.getBBox();let m=Math.max(c.width/a.width,c.height/a.height),f=1;const u=2*s*m;u<1&&(f=2/u,m*=f,c.x*=f,c.y*=f,c.width*=f,c.height*=f);const d=1+i*m/2,p=this._getCanvasContext(c.width+2*d,c.height+2*d);p.setTransform(f,0,0,f,-c.x+d,-c.y+d);const _=new Path2D(e);r?p.fill(_):(p.lineWidth=i*(m/f),p.stroke(_));const y=(a.width*m-c.width)/2,P=(a.height*m-c.height)/2,S=Math.floor((o[0]-a.x-s)*m-y+d),w=Math.floor((a.height-(o[1]-a.y)-s)*m+P+d),x=Math.ceil(2*s*m),M=Math.ceil(2*s*m),b=p.getImageData(S,w,x,M).data;for(let l=3;l<b.length;l+=4)if(b[l]>127.5)return void(this._earlyReturn=!0)}_hitTestStroke(t,e){let r=null;if(y(t)){const e=t;r=[[[e.xmin,e.ymin],[e.xmin,e.ymax],[e.xmax,e.ymax],[e.xmax,e.ymin],[e.xmin,e.ymin]]]}else if(P(t))r=t.rings;else{if(!S(t))return;r=t.paths}dt(this.reverseTransformPt(this._searchPoint),r,j(e,I.CIMSolidStroke.width)*this.geomUnitsPerPoint()/2+this.reverseTransformScalar(this._searchDistPoint)*this.prevGeomUnitsPerPoint())&&(this._earlyReturn=!0)}}class mt extends lt{constructor(t,e,r,i){super(e,r),this._applyAdditionalRenderProps=i,this._colorSubstitutionHelper=new b,this._ctx=t}drawSolidFill(t,e){if(!t)return;if(P(t))this._buildPath(t.rings,!0);else if(S(t))this._buildPath(t.paths,!0);else if(y(t))this._buildPath(gt(t).rings,!0);else{if(!w(t))return;console.log("CanvasDrawHelper.drawSolidFill - No implementation!")}const r=this._ctx;r.fillStyle="string"==typeof e?e:"rgba("+Math.round(e[0])+","+Math.round(e[1])+","+Math.round(e[2])+","+(e[3]??255)/255+")",r.fill("evenodd")}drawSolidStroke(t,e,r,i,s,o){if(!t||!e||0===r)return;if(P(t))this._buildPath(t.rings,!0);else if(S(t))this._buildPath(t.paths,!1);else{if(!y(t))return void console.log("CanvasDrawHelper.drawSolidStroke isn't implemented!");this._buildPath(gt(t).rings,!0)}const n=this._ctx;n.strokeStyle="string"==typeof e?e:"rgba("+Math.round(e[0])+","+Math.round(e[1])+","+Math.round(e[2])+","+(e[3]??255)/255+")",n.lineWidth=Math.max(this.transformSize(r),ot),this._setCapStyle(i),this._setJoinStyle(s),n.miterLimit=o,n.stroke()}pushClipPath(t){if(this._ctx.save(),P(t))this._buildPath(t.rings,!0);else if(S(t))this._buildPath(t.paths,!0);else{if(!y(t))return;this._buildPath(gt(t).rings,!0)}this._ctx.clip("evenodd")}popClipPath(){this._ctx.restore()}drawImage(t,e){const{colorSubstitutions:r,url:i,tintColor:s}=t,o=j(t.scaleX,1),n=this._resourceManager.getResource(i);if(null==n)return;let a=e*(n.width/n.height),l=e;e||(a=n.width,l=n.height);const h=G(i)||"src"in n&&G(n.src);let c="getFrame"in n?T(n):n;r&&(c=this._colorSubstitutionHelper.applyColorSubstitution(c,r)),this._applyAdditionalRenderProps&&!h&&s&&(c=this._colorSubstitutionHelper.tintImageData(c,s));const m=this.transformPt([0,0]),[f,u]=this.getTransformAngle(),d=this.transformSize(1),p=this._ctx;p.save(),p.setTransform({m11:o*d*f,m12:o*d*u,m21:-d*u,m22:d*f,m41:m[0],m42:m[1]}),p.drawImage(c,-a/2,-l/2,a,l),p.restore()}drawText(t,e){if(!e||0===e.length)return;this._textRasterizer||(this._textRasterizer=new F);const r=yt(t,this.transformSize(o(1))),i=this._textRasterizer.rasterizeText(e,r);if(!i)return;const{size:s,anchorX:n,anchorY:a,canvas:l}=i,h=s[0]*(n+.5),c=s[1]*(a-.5),m=this._ctx,f=this.transformPt([0,0]),[u,d]=this.getTransformAngle(),p=1;m.save(),m.setTransform({m11:p*u,m12:p*d,m21:-p*d,m22:p*u,m41:f[0]-p*h,m42:f[1]+p*c}),m.drawImage(l,0,0),m.restore()}drawPictureFill(t,e){if(!t)return;let{colorSubstitutions:r,height:i,offsetX:s,offsetY:o,rotation:n,scaleX:a,tintColor:l,url:h}=e;const c=this._resourceManager.getResource(h);if(null==c)return;if(P(t))this._buildPath(t.rings,!0);else if(S(t))this._buildPath(t.paths,!0);else if(y(t))this._buildPath(gt(t).rings,!0);else{if(!w(t))return;console.log("CanvasDrawHelper.drawPictureFill - No implementation!")}const m=this._ctx,f=G(h)||"src"in c&&G(c.src);let u,d="getFrame"in c?T(c):c;if(r&&(d=this._colorSubstitutionHelper.applyColorSubstitution(d,r)),this._applyAdditionalRenderProps){f||l&&(d=this._colorSubstitutionHelper.tintImageData(d,l)),u=m.createPattern(d,"repeat");const t=this.transformSize(1);n||(n=0),s?s*=t:s=0,o?o*=t:o=0,i&&(i*=t);const e=i?i/c.height:1,r=a&&i?a*i/c.width:1;if(0!==n||1!==e||1!==r||0!==s||0!==o){const t=new DOMMatrix;t.rotateSelf(0,0,-n).translateSelf(s,o).scaleSelf(r,e,1),u.setTransform(t)}}else u=m.createPattern(d,"repeat");m.save(),m.fillStyle=u,m.fill("evenodd"),m.restore()}drawPictureStroke(t,r){if(!t)return;let{colorSubstitutions:i,capStyle:s,joinStyle:o,miterLimit:a,tintColor:l,url:h,width:c}=r;const m=this._resourceManager.getResource(h);if(null==m)return;let f;if(P(t))f=t.rings;else if(S(t))f=t.paths;else{if(!y(t))return w(t)?void console.log("CanvasDrawHelper.drawPictureStroke - No implementation!"):void 0;f=gt(t).rings}c||(c=m.width);const u=G(h)||"src"in m&&G(m.src);let d="getFrame"in m?T(m):m;i&&(d=this._colorSubstitutionHelper.applyColorSubstitution(d,i)),this._applyAdditionalRenderProps&&(u||l&&(d=this._colorSubstitutionHelper.tintImageData(d,l)));const p=Math.max(this.transformSize(n(c)),.5),g=p/d.width,_=this._ctx,x=_.createPattern(d,"repeat-y");let M,b;_.save(),this._setCapStyle(s),this._setJoinStyle(o),void 0!==a&&(_.miterLimit=a),_.lineWidth=p;for(let n of f)if(n=e(n),St(n),n&&!(n.length<=1)){M=this.transformPt(n[0]);for(let t=1;t<n.length;t++){b=this.transformPt(n[t]);const e=pt(M,b),r=new DOMMatrix;r.translateSelf(0,M[1]-p/2).scaleSelf(g,g,1).rotateSelf(0,0,90-e),x.setTransform(r),_.strokeStyle=x,_.beginPath(),_.moveTo(M[0],M[1]),_.lineTo(b[0],b[1]),_.stroke(),M=b}}_.restore()}drawGradientFill(t,e){if(!t)return;let r;if(P(t))r=t.rings;else if(S(t))r=t.paths;else{if(!y(t))return void nt().error("Unable to draw gradient fill");r=gt(t).rings}this._buildPath(r,!0);const{angle:s,gradientMethod:o,gradientSize:a,gradientSizeUnits:l}=e,h=I.CIMGradientFill,g=e.gradientType??h.gradientType,_=-i(s??0),w=c();for(const i of r){const t=i?i.length:0;if(t>1)for(let e=0;e<t;e++){let t=this.transformPt(i[e]);"Linear"!==o&&"Rectangular"!==o||(t=R(t,-_)),m(w,t)}}const[x,M,b,k]=w,C=this._ctx;switch(C.save(),o){case"Buffered":nt().error(`Gradient method "${o}" currently unsupported.`);break;case"Linear":{const t=(M+k)/2,r="Absolute"===l?this.transformSize(n(a)):D(a,h.gradientSize)*(b-x),[i,s]="Discrete"===g?[b,b-r]:[x+r,x],o=R([i,t],_),c=R([s,t],_),m=C.createLinearGradient(o[0],o[1],c[0],c[1]);z(m,e),C.fillStyle=m,C.fill("evenodd");break}case"Circular":{const t=f(w),r=p(w)/2,i="Absolute"===l?this.transformSize(n(a)):D(a,h.gradientSize)*r,[s,o]="Discrete"===g?[r,r-i]:[i,0],c=C.createRadialGradient(t[0],t[1],s,t[0],t[1],o);z(c,e),C.fillStyle=c,C.fill("evenodd");break}case"Rectangular":{const r=f(w),i=r[0],s=r[1],o=R(r,_),c=(r,i,s,n,a,l,h,c)=>{C.save(),this.pushClipPath(t);const m=R([a,l],_),f=R([h,c],_);C.beginPath(),C.moveTo(o[0],o[1]),C.lineTo(m[0],m[1]),C.lineTo(f[0],f[1]),C.lineTo(o[0],o[1]),C.clip();const u=R([r,i],_),d=R([s,n],_),p=C.createLinearGradient(u[0],u[1],d[0],d[1]);z(p,e),C.fillStyle=p,C.fill("evenodd"),C.restore()};let m="Absolute"===l?this.transformSize(n(a)):D(a,h.gradientSize)*(u(w)/2),[p,y]="Discrete"===g?[b,b-m]:[i+m,i];c(p,s,y,s,b,M,b,k),[p,y]="Discrete"===g?[x,x+m]:[i-m,i],c(p,s,y,s,x,k,x,M),m="Absolute"===l?this.transformSize(n(a)):D(a,h.gradientSize)*(d(w)/2);let[P,S]="Discrete"===g?[k,k-m]:[s+m,s];c(i,P,i,S,b,k,x,k),[P,S]="Discrete"===g?[M,M+m]:[s-m,s],c(i,P,i,S,x,M,b,M);break}}C.restore()}drawGradientStroke(t,r){const{capStyle:i,gradientMethod:s,gradientSize:o,gradientSizeUnits:a,joinStyle:l,miterLimit:h,width:c}=r;if(!t||0===c)return;let m;if(P(t))m=t.rings;else if(S(t))m=t.paths;else{if(!y(t))return void nt().error("Unable to draw gradient stroke");m=gt(t).rings}const f=r.gradientType??I.CIMGradientStroke.gradientType,u=Math.max(this.transformSize(n(c)),.5),d=this._ctx;let p,g;d.save(),this._setCapStyle(i),this._setJoinStyle(l),void 0!==h&&(d.miterLimit=h),d.lineWidth=u;for(let _ of m){if(_=e(_),St(_),!_||_.length<=1)continue;let t=0;p=this.transformPt(_[0]);for(let e=1;e<_.length;e++){g=this.transformPt(_[e]);const r=g[0]-p[0],i=g[1]-p[1];t+=Math.sqrt(r*r+i*i),p=g}const i="Absolute"===a?this.transformSize(n(o)):D(o,I.CIMGradientStroke.gradientSize)*("AcrossLine"===s?u:t);let l=0;p=this.transformPt(_[0]);for(let e=1;e<_.length;e++){g=this.transformPt(_[e]);const o=g[0]-p[0],n=g[1]-p[1],a=Math.sqrt(o*o+n*n);let h,c,m,y;switch(s){case"AcrossLine":{const[t,e]=R([o/a,n/a],-Math.PI/2),r=u/2,s="Discrete"===f?r:i-r;h=(p[0]+g[0])/2+t*s,c=(p[1]+g[1])/2+e*s,m=h-t*i,y=c-e*i;break}case"AlongLine":{const e=o/a,r=n/a;"Discrete"===f?(h=p[0]-e*l,c=p[1]-r*l,m=h+e*i,y=c+r*i):(m=p[0]+e*(t-l),y=p[1]+r*(t-l),h=m-e*i,c=y-r*i);break}default:return nt().error("Unrecognized gradient method:",s),void d.restore()}if(this._applyAdditionalRenderProps){const t=h,e=c;h=m,c=y,m=t,y=e}const P=d.createLinearGradient(h,c,m,y);z(P,r),d.strokeStyle=P,d.beginPath(),d.moveTo(p[0],p[1]),d.lineTo(g[0],g[1]),d.stroke(),l+=a,p=g}}d.restore()}_buildPath(t,e){const r=this._ctx;if(r.beginPath(),t)for(const i of t){const t=i?i.length:0;if(t>1){let s=this.transformPt(i[0]);r.moveTo(s[0],s[1]);for(let e=1;e<t;e++)s=this.transformPt(i[e]),r.lineTo(s[0],s[1]);e&&r.closePath()}}}_setCapStyle(t){switch(t){case"Butt":this._ctx.lineCap="butt";break;case"Round":this._ctx.lineCap="round";break;case"Square":this._ctx.lineCap="square"}}_setJoinStyle(t){switch(t){case"Bevel":this._ctx.lineJoin="bevel";break;case"Round":this._ctx.lineJoin="round";break;case"Miter":this._ctx.lineJoin="miter"}}}function ft(t,e,r){let i=j(t.separation,I.CIMHatchFill.separation)*r,s=j(t.rotation);if(0===i)return null;i<0&&(i=-i);let o=0;const n=.5*i;for(;o>n;)o-=i;for(;o<-n;)o+=i;const a=l();g(a,e),a[0]-=n,a[1]-=n,a[2]+=n,a[3]+=n;const h=[[a[0],a[1]],[a[0],a[3]],[a[2],a[3]],[a[2],a[1]]];for(;s>180;)s-=180;for(;s<0;)s+=180;const c=Math.cos(s*st),m=Math.sin(s*st),f=-i*m,u=i*c;let d,p,_,y;o=j(t.offsetX)*r*m-j(t.offsetY)*r*c,d=_=Number.MAX_VALUE,p=y=-Number.MAX_VALUE;for(const l of h){const t=l[0],e=l[1],r=c*t+m*e,i=-m*t+c*e;d=Math.min(d,r),_=Math.min(_,i),p=Math.max(p,r),y=Math.max(y,i)}_=Math.floor(_/i)*i;let P=c*d-m*_-f*o/i,S=m*d+c*_-u*o/i,w=c*p-m*_-f*o/i,x=m*p+c*_-u*o/i;const M=1+Math.round((y-_)/i),b=[];for(let l=0;l<M;l++)P+=f,S+=u,w+=f,x+=u,b.push([[P,S],[w,x]]);return{paths:b}}function ut(t,e){let r=0;for(const i of e){const e=i.length;for(let s=1;s<e;s++){const e=i[s-1],o=i[s];if(e[1]>t[1]==o[1]>t[1])continue;(o[0]-e[0])*(t[1]-e[1])-(o[1]-e[1])*(t[0]-e[0])>0?r++:r--}}return 0!==r}function dt(t,e,r){for(const i of e){const e=i.length;for(let s=1;s<e;s++){const e=i[s-1],o=i[s];let n=(o[0]-e[0])*(o[0]-e[0])+(o[1]-e[1])*(o[1]-e[1]);if(0===n)continue;n=Math.sqrt(n);const a=((o[0]-e[0])*(t[1]-e[1])-(o[1]-e[1])*(t[0]-e[0]))/n;if(Math.abs(a)<r){const i=((o[0]-e[0])*(t[0]-e[0])+(o[1]-e[1])*(t[1]-e[1]))/n;if(i>-r&&i<n+r)return!0}}}return!1}function pt(t,e){const r=e[0]-t[0],i=e[1]-t[1];return 180/Math.PI*Math.atan2(i,r)}const gt=t=>t?{spatialReference:t.spatialReference,rings:[[[t.xmin,t.ymin],[t.xmin,t.ymax],[t.xmax,t.ymax],[t.xmax,t.ymin],[t.xmin,t.ymin]]]}:null,_t=(t,e,r)=>{switch(t){case"ExtraLeading":return 1+e/r;case"Multiple":return e;case"Exact":return e/r}};function yt(e,r=1){const i=H(e),s=B(e.fontStyleName),o=e.fontFamilyName??t,{weight:n,style:a}=s,l=r*(e.height||5),h=E(e.horizontalAlignment),c=X(e.verticalAlignment),m=J(e),f=J(e.haloSymbol),u=null!=f?r*(e.haloSize??0):0,d=N(e.symbol),p=r*(O(e.symbol)||0),g="CIMBackgroundCallout"===e.callout?.type?e.callout.backgroundSymbol:null,_=J(g),y=O(g),P=N(g);return{color:m,size:l,horizontalAlignment:h,verticalAlignment:c,font:{family:o,style:V(a),weight:q(n),decoration:i},outline:{size:p||0,color:d},halo:{size:u||0,color:f,style:a},backgroundColor:_,borderLine:null!=y&&null!=P?{size:y,color:P}:null,pixelRatio:1,premultiplyColors:!0}}const Pt=1e-4;function St(t){let e,r,i,s,o,n=t[0],a=1;for(;a<t.length;)e=t[a][0]-n[0],r=t[a][1]-n[1],s=0!==e?r/e:Math.PI/2,void 0!==i&&Math.abs(s-i)<=Pt?(t.splice(a-1,1),n=o):(o=n,n=t[a],a++),i=s}export{lt as CIMSymbolDrawHelper,mt as CanvasDrawHelper,ht as EnvDrawHelper,ct as HittestDrawHelper,at as Transformation,st as cDegToRad,_t as lineGapType2LineHeight};
|
|
5
|
+
import{defaultFontFamily as t}from"../../core/fontUtils.js";import has from"../../core/has.js";import{clone as e}from"../../core/lang.js";import r from"../../core/Logger.js";import{deg2rad as i}from"../../core/mathUtils.js";import s from"../../core/ObjectPool.js";import{px2pt as o,pt2px as n}from"../../core/screenUtils.js";import{GeometryCursor as a}from"../../geometry/GeometryCursor.js";import{create as l,fromValues as h,empty as c,expandPointInPlace as m,center as f,width as u,height as d,diagonal as g}from"../../geometry/support/aaBoundingRect.js";import{getBoundsXY as p}from"../../geometry/support/boundsUtils.js";import{polygonCentroid as _}from"../../geometry/support/centroid.js";import{isExtent as y,isPolygon as P,isPolyline as S,isMultipoint as w,isPoint as x}from"../../geometry/support/jsonUtils.js";import{SimpleEffectCursor as M}from"./CIMEffects.js";import b from"./CIMImageColorSubstitutionHelper.js";import{getEffectOperator as k,getPlacementOperator as C}from"./CIMOperators.js";import{Placement as v}from"./CIMPlacements.js";import{defaultCIMValues as I}from"./defaultCIMValues.js";import{getFirstFrame as T}from"./imageUtils.js";import{rotate as R}from"./mathUtils.js";import{addColorStops as z}from"./rasterizingUtils.js";import L from"./Rect.js";import F from"./TextRasterizer.js";import{isCIMFill as U,getSize as A,getNumericValue as j,isSVGImage as G,getRelativeGradientSize as D,fromCIMFontDecoration as H,fromCIMFontStyle as B,fromCIMHorizontalAlignment as E,fromCIMVerticalAlignment as X,getFillColor as J,getStrokeColor as N,getStrokeWidth as O,getFontWeight as q,getFontStyle as V}from"./utils.js";import{destroyHiddenSvg as W,createHiddenSvg as Y,createSvgElement as $}from"../../views/2d/engine/svgUtils.js";import{magicLabelLineHeight as K,glyphSize as Q,hittestToleranceSmallSymbol as Z,hittestSmallSymbolThreshold as tt}from"../../views/2d/engine/webgl/definitions.js";import{shapeGlyphs as et}from"../../views/2d/engine/webgl/mesh/templates/shapingUtils.js";import{roundPtToWholePixel as rt,getLineWidth as it}from"../../views/2d/layers/graphics/graphicsUtils.js";const st=Math.PI/180,ot=.5,nt=()=>r.getLogger("esri.symbols.cim.CIMSymbolDrawHelper");class at{constructor(t){this._t=t}static createIdentity(){return new at([1,0,0,0,1,0])}clone(){const t=this._t;return new at(t.slice())}transform(t){const e=this._t;return[e[0]*t[0]+e[1]*t[1]+e[2],e[3]*t[0]+e[4]*t[1]+e[5]]}static createScale(t,e){return new at([t,0,0,0,e,0])}scale(t,e){const r=this._t;return r[0]*=t,r[1]*=t,r[2]*=t,r[3]*=e,r[4]*=e,r[5]*=e,this}scaleRatio(){return Math.sqrt(this._t[0]*this._t[0]+this._t[1]*this._t[1])}static createTranslate(t,e){return new at([0,0,t,0,0,e])}translate(t,e){const r=this._t;return r[2]+=t,r[5]+=e,this}static createRotate(t){const e=Math.cos(t),r=Math.sin(t);return new at([e,-r,0,r,e,0])}rotate(t){return at.multiply(this,at.createRotate(t),this)}angle(){const t=this._t[0],e=this._t[3],r=Math.sqrt(t*t+e*e);return[t/r,e/r]}static multiply(t,e,r){const i=t._t,s=e._t,o=i[0]*s[0]+i[3]*s[1],n=i[1]*s[0]+i[4]*s[1],a=i[2]*s[0]+i[5]*s[1]+s[2],l=i[0]*s[3]+i[3]*s[4],h=i[1]*s[3]+i[4]*s[4],c=i[2]*s[3]+i[5]*s[4]+s[5],m=r._t;return m[0]=o,m[1]=n,m[2]=a,m[3]=l,m[4]=h,m[5]=c,r}invert(){const t=this._t;let e=t[0]*t[4]-t[1]*t[3];if(0===e)return new at([0,0,0,0,0,0]);e=1/e;const r=(t[1]*t[5]-t[2]*t[4])*e,i=(t[2]*t[3]-t[0]*t[5])*e,s=t[4]*e,o=-t[1]*e,n=-t[3]*e,a=t[0]*e;return new at([s,o,r,n,a,i])}}class lt{constructor(t,e){this._resourceManager=t,this._transfos=[],this._sizeTransfos=[],this._geomUnitsPerPoint=1,this._placementPool=new s(()=>new v,void 0,void 0,100),this._earlyReturn=!1,this._mapRotation=0,this._transfos.push(e||at.createIdentity()),this._sizeTransfos.push(e?e.scaleRatio():1)}setTransform(t,e){this._transfos=[t||at.createIdentity()],this._sizeTransfos=[e||(t?t.scaleRatio():1)]}setGeomUnitsPerPoint(t){this._geomUnitsPerPoint=t}transformPt(t){return this._transfos[this._transfos.length-1].transform(t)}transformSize(t){return t*this._sizeTransfos[this._sizeTransfos.length-1]}reverseTransformPt(t){return this._transfos[this._transfos.length-1].invert().transform(t)}reverseTransformSize(t){return t/this._sizeTransfos[this._sizeTransfos.length-1]}reverseTransformScalar(t){return t/this._transfos[this._transfos.length-1].scaleRatio()}getTransformAngle(){return this._transfos[this._transfos.length-1].angle()}geomUnitsPerPoint(){return this.isEmbedded()?1:this._geomUnitsPerPoint}prevGeomUnitsPerPoint(){return this._transfos.length>2?1:this._geomUnitsPerPoint}isEmbedded(){return this._transfos.length>1}back(){return this._transfos[this._transfos.length-1]}push(t,e){const r=e?t.scaleRatio():1;at.multiply(t,this.back(),t),this._transfos.push(t),this._sizeTransfos.push(this._sizeTransfos[this._sizeTransfos.length-1]*r)}pop(){this._transfos.splice(-1,1),this._sizeTransfos.splice(-1,1)}drawSymbol(t,e,r){if(t)switch(t.type){case"CIMPointSymbol":case"CIMLineSymbol":case"CIMPolygonSymbol":this.drawMultiLayerSymbol(t,e);break;case"CIMTextSymbol":this.drawTextSymbol(t,e,r)}}drawMultiLayerSymbol(t,e){if(!t||!e)return;const r=t.symbolLayers;if(!r)return;const i=t.effects;if(i&&i.length>0){const t=this.executeEffects(i,e);if(t){let e=t.next();for(;e;)this.drawSymbolLayers(r,e.asJSON()),e=t.next()}}else this.drawSymbolLayers(r,e)}executeEffects(t,e){let r=new M(a.fromJSONCIM(e));for(const i of t){const t=k(i);t&&(r=t.execute(r,i,this.geomUnitsPerPoint(),null))}return r}drawSymbolLayers(t,e){let r=t.length;for(;r--;){const i=t[r];if(!i||!1===i.enable)continue;const s=i.effects;if(s&&s.length>0){const t=this.executeEffects(s,e);if(t){let e=null;for(;(e=t.next())&&(this.drawSymbolLayer(i,e.asJSON()),!this._earlyReturn););}}else this.drawSymbolLayer(i,e);if(this._earlyReturn)return}}drawSymbolLayer(t,e){switch(t.type){case"CIMSolidFill":this.drawSolidFill(e,t.color,t.path);break;case"CIMHatchFill":this.drawHatchFill(e,t);break;case"CIMPictureFill":this.drawPictureFill(e,t);break;case"CIMGradientFill":this.drawGradientFill(e,t);break;case"CIMSolidStroke":this.drawSolidStroke(e,t.color,t.width,t.capStyle,t.joinStyle,t.miterLimit,t.path);break;case"CIMPictureStroke":this.drawPictureStroke(e,t);break;case"CIMGradientStroke":this.drawGradientStroke(e,t);break;case"CIMCharacterMarker":case"CIMPictureMarker":case"CIMVectorMarker":this.drawMarkerLayer(t,e)}}drawHatchFill(t,e){const r=ft(e,t,this.geomUnitsPerPoint());r&&(this.pushClipPath(t),this.drawMultiLayerSymbol(e.lineSymbol,r),this.popClipPath())}drawPictureFill(t,e){}drawGradientFill(t,e){}drawPictureStroke(t,e){}drawGradientStroke(t,e){}drawMarkerLayer(t,e){const r=t.markerPlacement;if(r){const i=C(r);if(i){const s="CIMMarkerPlacementInsidePolygon"===r.type||"CIMMarkerPlacementPolygonCenter"===r.type&&r.clipAtBoundary;s&&this.pushClipPath(e);const o=i.execute(a.fromJSONCIM(e),r,this.geomUnitsPerPoint(),null);if(o){let e=null;for(;(e=o.next())&&(this.drawMarker(t,e),!this._earlyReturn););}s&&this.popClipPath()}}else{const r=this._placementPool.acquire();if(x(e))r.tx=e.x,r.ty=e.y,this.drawMarker(t,r);else if(P(e)){const i=_(e);i&&([r.tx,r.ty]=i,this.drawMarker(t,r))}else if(S(e)){for(const i of e.paths)for(const e of i)if(r.tx=e[0],r.ty=e[1],this.drawMarker(t,r),this._earlyReturn)break}else for(const i of e.points)if(r.tx=i[0],r.ty=i[1],this.drawMarker(t,r),this._earlyReturn)break;this._placementPool.release(r)}}drawMarker(t,e){switch(t.type){case"CIMCharacterMarker":case"CIMPictureMarker":this.drawPictureMarker(t,e);break;case"CIMVectorMarker":this.drawVectorMarker(t,e)}}drawPictureMarker(t,e){if(!t)return;const r=this._resourceManager.getResource(t.url),i=j(t.size,I.CIMPictureMarker.size);if(null==r||i<=0)return;const s=r.width,o=r.height;if(!s||!o)return;const n=s/o,a=j(t.scaleX,1),l=at.createIdentity(),h=t.anchorPoint;if(h){let e=h.x,r=h.y;"Absolute"!==t.anchorPointUnits&&(e*=i*n*a,r*=i),l.translate(-e,-r)}let c=j(t.rotation);t.rotateClockwise&&(c=-c),this._mapRotation&&(c+=this._mapRotation),c&&l.rotate(c*st);let m=j(t.offsetX),f=j(t.offsetY);if(m||f){if(this._mapRotation){const t=st*this._mapRotation,e=Math.cos(t),r=Math.sin(t),i=m*r+f*e;m=m*e-f*r,f=i}l.translate(m,f)}const u=this.geomUnitsPerPoint();1!==u&&l.scale(u,u);const d=e.getAngle();d&&l.rotate(d),l.translate(e.tx,e.ty),this.push(l,!1),this.drawImage(t,i),this.pop()}drawVectorMarker(t,e){if(!t)return;const r=t.markerGraphics;if(!r)return;const i=j(t.size,I.CIMVectorMarker.size),s=t.frame,o=s?s.ymax-s.ymin:0,n=i&&o?i/o:1,a=at.createIdentity();s&&a.translate(.5*-(s.xmax+s.xmin),.5*-(s.ymax+s.ymin));const l=t.anchorPoint;if(l){let e=l.x,r=l.y;"Absolute"!==t.anchorPointUnits?s&&(e*=s.xmax-s.xmin,r*=s.ymax-s.ymin):(e/=n,r/=n),a.translate(-e,-r)}1!==n&&a.scale(n,n);let h=j(t.rotation);t.rotateClockwise&&(h=-h),this._mapRotation&&(h+=this._mapRotation),h&&a.rotate(h*st);let c=j(t.offsetX),m=j(t.offsetY);if(c||m){if(this._mapRotation){const t=st*this._mapRotation,e=Math.cos(t),r=Math.sin(t),i=c*r+m*e;c=c*e-m*r,m=i}a.translate(c,m)}const f=this.geomUnitsPerPoint();1!==f&&a.scale(f,f);const u=e.getAngle();u&&a.rotate(u),a.translate(e.tx,e.ty),this.push(a,t.scaleSymbolsProportionally);for(const d of r){d?.symbol&&d.geometry||nt().error("Invalid marker graphic",d);let t=d.textString;if("number"==typeof t&&(t=t.toString()),this.drawSymbol(d.symbol,d.geometry,t),this._earlyReturn)break}this.pop()}drawTextSymbol(t,e,r){if(!t)return;if(!x(e))return;if(j(t.height,I.CIMTextSymbol.height)<=0)return;const i=at.createIdentity();let s=j(t.angle);s=-s,s&&i.rotate(s*st);const o=j(t.offsetX),n=j(t.offsetY);(o||n)&&i.translate(o,n);const a=this.geomUnitsPerPoint();1!==a&&i.scale(a,a),i.translate(e.x,e.y),this.push(i,!1),this.drawText(t,r),this.pop()}}class ht extends lt{constructor(t,e){super(t,e),this.reset()}reset(){this._xmin=this._ymin=1/0,this._xmax=this._ymax=-1/0,this._clipCount=0}envelope(){return new L(this._xmin,this._ymin,this._xmax-this._xmin,this._ymax-this._ymin)}bounds(){return h(this._xmin,this._ymin,this._xmax,this._ymax)}drawSolidFill(t){if(t&&!(this._clipCount>0))if(P(t))this._processPath(t.rings,0);else if(S(t))this._processPath(t.paths,0);else if(y(t)){const e=pt(t);e&&this._processPath(e.rings,0)}else console.error("drawSolidFill Unexpected geometry type!")}drawSolidStroke(t,e,r){if(!t||this._clipCount>0||null==r||r<=0)return;const i=Math.max(.5*this.transformSize(j(r,I.CIMSolidStroke.width)),.5*ot);if(P(t))this._processPath(t.rings,i);else if(S(t))this._processPath(t.paths,i);else if(y(t)){const e=pt(t);e&&this._processPath(e.rings,i)}else console.error("drawSolidStroke unexpected geometry type!")}drawMarkerLayer(t,e){P(e)&&t.markerPlacement&&("CIMMarkerPlacementInsidePolygon"===t.markerPlacement.type||"CIMMarkerPlacementPolygonCenter"===t.markerPlacement.type&&t.markerPlacement.clipAtBoundary)?this._processPath(e.rings,0):super.drawMarkerLayer(t,e)}drawHatchFill(t,e){this.drawSolidFill(t)}drawPictureFill(t,e){this.drawSolidFill(t)}drawGradientFill(t,e){this.drawSolidFill(t)}drawPictureStroke(t,e){this.drawSolidStroke(t,null,e.width)}drawGradientStroke(t,e){this.drawSolidStroke(t,null,e.width)}pushClipPath(t){this.drawSolidFill(t),this._clipCount++}popClipPath(){this._clipCount--}drawImage(t,e){const{url:r}=t,i=j(t.scaleX,1);let s=i*e,o=e;const n=this._resourceManager.getResource(r);if(null!=n){const t=n.height/n.width;s=i*(e?t>1?e:e/t:n.width),o=e?t>1?e*t:e:n.height}this._merge(this.transformPt([-s/2,-o/2]),0),this._merge(this.transformPt([-s/2,o/2]),0),this._merge(this.transformPt([s/2,-o/2]),0),this._merge(this.transformPt([s/2,o/2]),0)}drawText(t,e){if(!e||0===e.length)return;this._textRasterizer||(this._textRasterizer=new F);const r=yt(t);let[i,s]=this._textRasterizer.computeTextSize(e,r);i=o(i),s=o(s);const n=this.transformSize(1)*this.reverseTransformScalar(1);i*=n,s*=n;let a=0;switch(t.horizontalAlignment){case"Left":a=i/2;break;case"Right":a=-i/2}let l=0;switch(t.verticalAlignment){case"Bottom":l=s/2;break;case"Top":l=-s/2;break;case"Baseline":l=s/6}this._merge(this.transformPt([-i/2+a,-s/2+l]),0),this._merge(this.transformPt([-i/2+a,s/2+l]),0),this._merge(this.transformPt([i/2+a,-s/2+l]),0),this._merge(this.transformPt([i/2+a,s/2+l]),0)}_processPath(t,e){if(t)for(const r of t){const t=r?r.length:0;if(t>1){this._merge(this.transformPt(r[0]),e);for(let i=1;i<t;i++)this._merge(this.transformPt(r[i]),e)}}}_merge(t,e){t[0]-e<this._xmin&&(this._xmin=t[0]-e),t[0]+e>this._xmax&&(this._xmax=t[0]+e),t[1]-e<this._ymin&&(this._ymin=t[1]-e),t[1]+e>this._ymax&&(this._ymax=t[1]+e)}}class ct extends lt{constructor(){super(...arguments),this._searchPoint=[0,0],this._searchDistPoint=0,this._textInfo=null,this._svg=null,this._path=null,this._canvas=null}destroy(){this._svg=W(this._svg),this._path=null,this._canvas=null}hitTest(t,e,r,i,s,a){const l=a*n(1);this.setTransform(),this.setGeomUnitsPerPoint(l),this._searchPoint=[(t[0]+t[2])/2,(t[1]+t[3])/2],this._searchDistPoint=(t[2]-t[0])/2/l,this._textInfo=i;const h=e&&("CIMPointSymbol"===e.type&&"Map"!==e.angleAlignment||"CIMTextSymbol"===e.type);if(this._mapRotation=h?s:0,!has("esri-mobile")){const t=o(Z*window.devicePixelRatio),r=o(tt);!(("CIMLineSymbol"===e?.type||"CIMPolygonSymbol"===e?.type)&&e.symbolLayers?.some(U))&&"CIMMeshSymbol"!==e?.type&&(A(e)??0)<r&&(this._searchDistPoint=t)}return this._earlyReturn=!1,this.drawSymbol(e,r),this._earlyReturn}executeEffects(t,e){return"CIMGeometricEffectDashes"===t.at(-1)?.type&&(t=t.slice(0,-1)),super.executeEffects(t,e)}drawSolidFill(t,e,r){null!=r?this._hittestSvgPath(t,r,!0):this._hitTestFill(t)}drawHatchFill(t,e){this._hitTestFill(t)}drawPictureFill(t,e){this._hitTestFill(t)}drawGradientFill(t,e){this._hitTestFill(t)}drawSolidStroke(t,e,r,i,s,o,n){null!=n?this._hittestSvgPath(t,n,!1,r):this._hitTestStroke(t,r)}drawPictureStroke(t,e){this._hitTestStroke(t,e.width)}drawGradientStroke(t,e){this._hitTestStroke(t,e.width)}drawMarkerLayer(t,e){t.markerPlacement&&("CIMMarkerPlacementInsidePolygon"===t.markerPlacement.type||"CIMMarkerPlacementPolygonCenter"===t.markerPlacement.type&&t.markerPlacement.clipAtBoundary)?this._hitTestFill(e):super.drawMarkerLayer(t,e)}pushClipPath(t){}popClipPath(){}drawImage(t,e){const{url:r}=t,i=j(t.scaleX,1),s=this._resourceManager.getResource(r);if(null==s||0===s.height||0===e)return;const o=e*this.geomUnitsPerPoint(),n=o*i*(s.width/s.height),a=this.reverseTransformPt(this._searchPoint),l=this._searchDistPoint;Math.abs(a[0])<n/2+l&&Math.abs(a[1])<o/2+l&&(this._earlyReturn=!0)}drawText(t,e){const r=this._textInfo;if(!r)return;const i=r.get(t);if(!i)return;if(!i.glyphMosaicItems.glyphs.length)return;const s=rt(j(t.height,I.CIMTextSymbol.height)),{lineGapType:o,lineGap:n}=t,a=o?_t(o,j(n),s):0,l="CIMBackgroundCallout"===t.callout?.type,h=et(i.glyphMosaicItems,{scale:s/Q,angle:0,xOffset:0,yOffset:0,horizontalAlignment:t.horizontalAlignment,verticalAlignment:t.verticalAlignment,maxLineWidth:it(t.lineWidth),lineHeight:K*Math.max(.25,Math.min(a||1,4)),decoration:t.font.decoration||"none",useCIMAngleBehavior:!0,hasBackground:l}),c=this.reverseTransformPt(this._searchPoint),m=c[0],f=c[1];for(const u of h.glyphs)if(m>u.xTopLeft&&m<u.xBottomRight&&f>-u.yBottomRight&&f<-u.yTopLeft){this._earlyReturn=!0;break}}_hitTestFill(t){let e=null;if(y(t)){const r=t;e=[[[r.xmin,r.ymin],[r.xmin,r.ymax],[r.xmax,r.ymax],[r.xmax,r.ymin],[r.xmin,r.ymin]]]}else if(P(t))e=t.rings;else{if(!S(t))return;e=t.paths}const r=this.reverseTransformPt(this._searchPoint);if(ut(r,e)&&(this._earlyReturn=!0),!this._earlyReturn){dt(r,e,this.reverseTransformScalar(this._searchDistPoint)*this.prevGeomUnitsPerPoint())&&(this._earlyReturn=!0)}}_getSvgPath(){return null!=this._svg&&null!=this._path||(this._svg??=Y(),this._path??=$("path"),this._svg.appendChild(this._path)),this._path}_getCanvasContext(t,e){return this._canvas??=document.createElement("canvas"),this._canvas.width=t,this._canvas.height=e,this._canvas.getContext("2d",{willReadFrequently:!0})}_hittestSvgPath(t,e,r,i=0){const s=this.reverseTransformScalar(this._searchDistPoint)*this.prevGeomUnitsPerPoint(),o=this.reverseTransformPt(this._searchPoint),n=l();p(n,t);const a={x:n[0],y:n[1],width:n[2]-n[0],height:n[3]-n[1]},h=this._getSvgPath();h.setAttribute("d",e);const c=h.getBBox();let m=Math.max(c.width/a.width,c.height/a.height),f=1;const u=2*s*m;u<1&&(f=2/u,m*=f,c.x*=f,c.y*=f,c.width*=f,c.height*=f);const d=1+i*m/2,g=this._getCanvasContext(c.width+2*d,c.height+2*d);g.setTransform(f,0,0,f,-c.x+d,-c.y+d);const _=new Path2D(e);r?g.fill(_):(g.lineWidth=i*(m/f),g.stroke(_));const y=(a.width*m-c.width)/2,P=(a.height*m-c.height)/2,S=Math.floor((o[0]-a.x-s)*m-y+d),w=Math.floor((a.height-(o[1]-a.y)-s)*m+P+d),x=Math.ceil(2*s*m),M=Math.ceil(2*s*m),b=g.getImageData(S,w,x,M).data;for(let l=3;l<b.length;l+=4)if(b[l]>127.5)return void(this._earlyReturn=!0)}_hitTestStroke(t,e){let r=null;if(y(t)){const e=t;r=[[[e.xmin,e.ymin],[e.xmin,e.ymax],[e.xmax,e.ymax],[e.xmax,e.ymin],[e.xmin,e.ymin]]]}else if(P(t))r=t.rings;else{if(!S(t))return;r=t.paths}dt(this.reverseTransformPt(this._searchPoint),r,j(e,I.CIMSolidStroke.width)*this.geomUnitsPerPoint()/2+this.reverseTransformScalar(this._searchDistPoint)*this.prevGeomUnitsPerPoint())&&(this._earlyReturn=!0)}}class mt extends lt{constructor(t,e,r,i){super(e,r),this._applyAdditionalRenderProps=i,this._colorSubstitutionHelper=new b,this._ctx=t}drawSolidFill(t,e){if(!t)return;if(P(t))this._buildPath(t.rings,!0);else if(S(t))this._buildPath(t.paths,!0);else if(y(t))this._buildPath(pt(t).rings,!0);else{if(!w(t))return;console.log("CanvasDrawHelper.drawSolidFill - No implementation!")}const r=this._ctx;r.fillStyle="string"==typeof e?e:"rgba("+Math.round(e[0])+","+Math.round(e[1])+","+Math.round(e[2])+","+(e[3]??255)/255+")",r.fill("evenodd")}drawSolidStroke(t,e,r,i,s,o){if(!t||!e||0===r)return;if(P(t))this._buildPath(t.rings,!0);else if(S(t))this._buildPath(t.paths,!1);else{if(!y(t))return void console.log("CanvasDrawHelper.drawSolidStroke isn't implemented!");this._buildPath(pt(t).rings,!0)}const n=this._ctx;n.strokeStyle="string"==typeof e?e:"rgba("+Math.round(e[0])+","+Math.round(e[1])+","+Math.round(e[2])+","+(e[3]??255)/255+")",n.lineWidth=Math.max(this.transformSize(r),ot),this._setCapStyle(i),this._setJoinStyle(s),n.miterLimit=o,n.stroke()}pushClipPath(t){if(this._ctx.save(),P(t))this._buildPath(t.rings,!0);else if(S(t))this._buildPath(t.paths,!0);else{if(!y(t))return;this._buildPath(pt(t).rings,!0)}this._ctx.clip("evenodd")}popClipPath(){this._ctx.restore()}drawImage(t,e){const{colorSubstitutions:r,url:i,tintColor:s}=t,o=j(t.scaleX,1),n=this._resourceManager.getResource(i);if(null==n)return;let a=e*(n.width/n.height),l=e;e||(a=n.width,l=n.height);const h=G(i)||"src"in n&&G(n.src);let c="getFrame"in n?T(n):n;r&&(c=this._colorSubstitutionHelper.applyColorSubstitution(c,r)),this._applyAdditionalRenderProps&&!h&&s&&(c=this._colorSubstitutionHelper.tintImageData(c,s));const m=this.transformPt([0,0]),[f,u]=this.getTransformAngle(),d=this.transformSize(1),g=this._ctx;g.save(),g.setTransform({m11:o*d*f,m12:o*d*u,m21:-d*u,m22:d*f,m41:m[0],m42:m[1]}),g.drawImage(c,-a/2,-l/2,a,l),g.restore()}drawText(t,e){if(!e||0===e.length)return;this._textRasterizer||(this._textRasterizer=new F);const r=yt(t,this.transformSize(o(1))),i=this._textRasterizer.rasterizeText(e,r);if(!i)return;const{size:s,anchorX:n,anchorY:a,canvas:l}=i,h=s[0]*(n+.5),c=s[1]*(a-.5),m=this._ctx,f=this.transformPt([0,0]),[u,d]=this.getTransformAngle(),g=1;m.save(),m.setTransform({m11:g*u,m12:g*d,m21:-g*d,m22:g*u,m41:f[0]-g*h,m42:f[1]+g*c}),m.drawImage(l,0,0),m.restore()}drawPictureFill(t,e){if(!t)return;let{colorSubstitutions:r,height:i,offsetX:s,offsetY:o,rotation:n,scaleX:a,tintColor:l,url:h}=e;const c=this._resourceManager.getResource(h);if(null==c)return;if(P(t))this._buildPath(t.rings,!0);else if(S(t))this._buildPath(t.paths,!0);else if(y(t))this._buildPath(pt(t).rings,!0);else{if(!w(t))return;console.log("CanvasDrawHelper.drawPictureFill - No implementation!")}const m=this._ctx,f=G(h)||"src"in c&&G(c.src);let u,d="getFrame"in c?T(c):c;if(r&&(d=this._colorSubstitutionHelper.applyColorSubstitution(d,r)),this._applyAdditionalRenderProps){f||l&&(d=this._colorSubstitutionHelper.tintImageData(d,l)),u=m.createPattern(d,"repeat");const t=this.transformSize(1);n||(n=0),s?s*=t:s=0,o?o*=t:o=0,i&&(i*=t);const e=i?i/c.height:1,r=a&&i?a*i/c.width:1;if(0!==n||1!==e||1!==r||0!==s||0!==o){const t=new DOMMatrix;t.rotateSelf(0,0,-n).translateSelf(s,o).scaleSelf(r,e,1),u.setTransform(t)}}else u=m.createPattern(d,"repeat");m.save(),m.fillStyle=u,m.fill("evenodd"),m.restore()}drawPictureStroke(t,r){if(!t)return;let{colorSubstitutions:i,capStyle:s,joinStyle:o,miterLimit:a,tintColor:l,url:h,width:c}=r;const m=this._resourceManager.getResource(h);if(null==m)return;let f;if(P(t))f=t.rings;else if(S(t))f=t.paths;else{if(!y(t))return w(t)?void console.log("CanvasDrawHelper.drawPictureStroke - No implementation!"):void 0;f=pt(t).rings}c||(c=m.width);const u=G(h)||"src"in m&&G(m.src);let d="getFrame"in m?T(m):m;i&&(d=this._colorSubstitutionHelper.applyColorSubstitution(d,i)),this._applyAdditionalRenderProps&&(u||l&&(d=this._colorSubstitutionHelper.tintImageData(d,l)));const g=Math.max(this.transformSize(n(c)),.5),p=g/d.width,_=this._ctx,x=_.createPattern(d,"repeat-y");let M,b;_.save(),this._setCapStyle(s),this._setJoinStyle(o),void 0!==a&&(_.miterLimit=a),_.lineWidth=g;for(let n of f)if(n=e(n),St(n),n&&!(n.length<=1)){M=this.transformPt(n[0]);for(let t=1;t<n.length;t++){b=this.transformPt(n[t]);const e=gt(M,b),r=new DOMMatrix;r.translateSelf(0,M[1]-g/2).scaleSelf(p,p,1).rotateSelf(0,0,90-e),x.setTransform(r),_.strokeStyle=x,_.beginPath(),_.moveTo(M[0],M[1]),_.lineTo(b[0],b[1]),_.stroke(),M=b}}_.restore()}drawGradientFill(t,e){if(!t)return;let r;if(P(t))r=t.rings;else if(S(t))r=t.paths;else{if(!y(t))return void nt().error("Unable to draw gradient fill");r=pt(t).rings}this._buildPath(r,!0);const{angle:s,gradientMethod:o,gradientSize:a,gradientSizeUnits:l}=e,h=I.CIMGradientFill,p=e.gradientType??h.gradientType,_=-i(s??0),w=c();for(const i of r){const t=i?i.length:0;if(t>1)for(let e=0;e<t;e++){let t=this.transformPt(i[e]);"Linear"!==o&&"Rectangular"!==o||(t=R(t,-_)),m(w,t)}}const[x,M,b,k]=w,C=this._ctx;switch(C.save(),o){case"Buffered":nt().error(`Gradient method "${o}" currently unsupported.`);break;case"Linear":{const t=(M+k)/2,r="Absolute"===l?this.transformSize(n(a)):D(a,h.gradientSize)*(b-x),[i,s]="Discrete"===p?[b,b-r]:[x+r,x],o=R([i,t],_),c=R([s,t],_),m=C.createLinearGradient(o[0],o[1],c[0],c[1]);z(m,e),C.fillStyle=m,C.fill("evenodd");break}case"Circular":{const t=f(w),r=g(w)/2,i="Absolute"===l?this.transformSize(n(a)):D(a,h.gradientSize)*r,[s,o]="Discrete"===p?[r,r-i]:[i,0],c=C.createRadialGradient(t[0],t[1],s,t[0],t[1],o);z(c,e),C.fillStyle=c,C.fill("evenodd");break}case"Rectangular":{const r=f(w),i=r[0],s=r[1],o=R(r,_),c=(r,i,s,n,a,l,h,c)=>{C.save(),this.pushClipPath(t);const m=R([a,l],_),f=R([h,c],_);C.beginPath(),C.moveTo(o[0],o[1]),C.lineTo(m[0],m[1]),C.lineTo(f[0],f[1]),C.lineTo(o[0],o[1]),C.clip();const u=R([r,i],_),d=R([s,n],_),g=C.createLinearGradient(u[0],u[1],d[0],d[1]);z(g,e),C.fillStyle=g,C.fill("evenodd"),C.restore()};let m="Absolute"===l?this.transformSize(n(a)):D(a,h.gradientSize)*(u(w)/2),[g,y]="Discrete"===p?[b,b-m]:[i+m,i];c(g,s,y,s,b,M,b,k),[g,y]="Discrete"===p?[x,x+m]:[i-m,i],c(g,s,y,s,x,k,x,M),m="Absolute"===l?this.transformSize(n(a)):D(a,h.gradientSize)*(d(w)/2);let[P,S]="Discrete"===p?[k,k-m]:[s+m,s];c(i,P,i,S,b,k,x,k),[P,S]="Discrete"===p?[M,M+m]:[s-m,s],c(i,P,i,S,x,M,b,M);break}}C.restore()}drawGradientStroke(t,r){const{capStyle:i,gradientMethod:s,gradientSize:o,gradientSizeUnits:a,joinStyle:l,miterLimit:h,width:c}=r;if(!t||0===c)return;let m;if(P(t))m=t.rings;else if(S(t))m=t.paths;else{if(!y(t))return void nt().error("Unable to draw gradient stroke");m=pt(t).rings}const f=r.gradientType??I.CIMGradientStroke.gradientType,u=Math.max(this.transformSize(n(c)),.5),d=this._ctx;let g,p;d.save(),this._setCapStyle(i),this._setJoinStyle(l),void 0!==h&&(d.miterLimit=h),d.lineWidth=u;for(let _ of m){if(_=e(_),St(_),!_||_.length<=1)continue;let t=0;g=this.transformPt(_[0]);for(let e=1;e<_.length;e++){p=this.transformPt(_[e]);const r=p[0]-g[0],i=p[1]-g[1];t+=Math.sqrt(r*r+i*i),g=p}const i="Absolute"===a?this.transformSize(n(o)):D(o,I.CIMGradientStroke.gradientSize)*("AcrossLine"===s?u:t);let l=0;g=this.transformPt(_[0]);for(let e=1;e<_.length;e++){p=this.transformPt(_[e]);const o=p[0]-g[0],n=p[1]-g[1],a=Math.sqrt(o*o+n*n);let h,c,m,y;switch(s){case"AcrossLine":{const[t,e]=R([o/a,n/a],-Math.PI/2),r=u/2,s="Discrete"===f?r:i-r;h=(g[0]+p[0])/2+t*s,c=(g[1]+p[1])/2+e*s,m=h-t*i,y=c-e*i;break}case"AlongLine":{const e=o/a,r=n/a;"Discrete"===f?(h=g[0]-e*l,c=g[1]-r*l,m=h+e*i,y=c+r*i):(m=g[0]+e*(t-l),y=g[1]+r*(t-l),h=m-e*i,c=y-r*i);break}default:return nt().error("Unrecognized gradient method:",s),void d.restore()}const P=d.createLinearGradient(h,c,m,y);z(P,r),d.strokeStyle=P,d.beginPath(),d.moveTo(g[0],g[1]),d.lineTo(p[0],p[1]),d.stroke(),l+=a,g=p}}d.restore()}_buildPath(t,e){const r=this._ctx;if(r.beginPath(),t)for(const i of t){const t=i?i.length:0;if(t>1){let s=this.transformPt(i[0]);r.moveTo(s[0],s[1]);for(let e=1;e<t;e++)s=this.transformPt(i[e]),r.lineTo(s[0],s[1]);e&&r.closePath()}}}_setCapStyle(t){switch(t){case"Butt":this._ctx.lineCap="butt";break;case"Round":this._ctx.lineCap="round";break;case"Square":this._ctx.lineCap="square"}}_setJoinStyle(t){switch(t){case"Bevel":this._ctx.lineJoin="bevel";break;case"Round":this._ctx.lineJoin="round";break;case"Miter":this._ctx.lineJoin="miter"}}}function ft(t,e,r){let i=j(t.separation,I.CIMHatchFill.separation)*r,s=j(t.rotation);if(0===i)return null;i<0&&(i=-i);let o=0;const n=.5*i;for(;o>n;)o-=i;for(;o<-n;)o+=i;const a=l();p(a,e),a[0]-=n,a[1]-=n,a[2]+=n,a[3]+=n;const h=[[a[0],a[1]],[a[0],a[3]],[a[2],a[3]],[a[2],a[1]]];for(;s>180;)s-=180;for(;s<0;)s+=180;const c=Math.cos(s*st),m=Math.sin(s*st),f=-i*m,u=i*c;let d,g,_,y;o=j(t.offsetX)*r*m-j(t.offsetY)*r*c,d=_=Number.MAX_VALUE,g=y=-Number.MAX_VALUE;for(const l of h){const t=l[0],e=l[1],r=c*t+m*e,i=-m*t+c*e;d=Math.min(d,r),_=Math.min(_,i),g=Math.max(g,r),y=Math.max(y,i)}_=Math.floor(_/i)*i;let P=c*d-m*_-f*o/i,S=m*d+c*_-u*o/i,w=c*g-m*_-f*o/i,x=m*g+c*_-u*o/i;const M=1+Math.round((y-_)/i),b=[];for(let l=0;l<M;l++)P+=f,S+=u,w+=f,x+=u,b.push([[P,S],[w,x]]);return{paths:b}}function ut(t,e){let r=0;for(const i of e){const e=i.length;for(let s=1;s<e;s++){const e=i[s-1],o=i[s];if(e[1]>t[1]==o[1]>t[1])continue;(o[0]-e[0])*(t[1]-e[1])-(o[1]-e[1])*(t[0]-e[0])>0?r++:r--}}return 0!==r}function dt(t,e,r){for(const i of e){const e=i.length;for(let s=1;s<e;s++){const e=i[s-1],o=i[s];let n=(o[0]-e[0])*(o[0]-e[0])+(o[1]-e[1])*(o[1]-e[1]);if(0===n)continue;n=Math.sqrt(n);const a=((o[0]-e[0])*(t[1]-e[1])-(o[1]-e[1])*(t[0]-e[0]))/n;if(Math.abs(a)<r){const i=((o[0]-e[0])*(t[0]-e[0])+(o[1]-e[1])*(t[1]-e[1]))/n;if(i>-r&&i<n+r)return!0}}}return!1}function gt(t,e){const r=e[0]-t[0],i=e[1]-t[1];return 180/Math.PI*Math.atan2(i,r)}const pt=t=>t?{spatialReference:t.spatialReference,rings:[[[t.xmin,t.ymin],[t.xmin,t.ymax],[t.xmax,t.ymax],[t.xmax,t.ymin],[t.xmin,t.ymin]]]}:null,_t=(t,e,r)=>{switch(t){case"ExtraLeading":return 1+e/r;case"Multiple":return e;case"Exact":return e/r}};function yt(e,r=1){const i=H(e),s=B(e.fontStyleName),o=e.fontFamilyName??t,{weight:n,style:a}=s,l=r*(e.height||5),h=E(e.horizontalAlignment),c=X(e.verticalAlignment),m=J(e),f=J(e.haloSymbol),u=null!=f?r*(e.haloSize??0):0,d=N(e.symbol),g=r*(O(e.symbol)||0),p="CIMBackgroundCallout"===e.callout?.type?e.callout.backgroundSymbol:null,_=J(p),y=O(p),P=N(p);return{color:m,size:l,horizontalAlignment:h,verticalAlignment:c,font:{family:o,style:V(a),weight:q(n),decoration:i},outline:{size:g||0,color:d},halo:{size:u||0,color:f,style:a},backgroundColor:_,borderLine:null!=y&&null!=P?{size:y,color:P}:null,pixelRatio:1,premultiplyColors:!0}}const Pt=1e-4;function St(t){let e,r,i,s,o,n=t[0],a=1;for(;a<t.length;)e=t[a][0]-n[0],r=t[a][1]-n[1],s=0!==e?r/e:Math.PI/2,void 0!==i&&Math.abs(s-i)<=Pt?(t.splice(a-1,1),n=o):(o=n,n=t[a],a++),i=s}export{lt as CIMSymbolDrawHelper,mt as CanvasDrawHelper,ht as EnvDrawHelper,ct as HittestDrawHelper,at as Transformation,st as cDegToRad,_t as lineGapType2LineHeight};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as t,__param as e}from"tslib";import has from"../../../../../../../core/has.js";import{location as i,uniform as o,input as r,UniformGroup as s}from"../../GraphShaderModule.js";import{ifElse as n,greaterThan as a,Float as l,dot as d,min as p,length as m,mix as c,Vec2 as u,clamp as h,texture2D as y,step as g,Vec4 as v}from"../../graph/glsl.js";import{bitset as f}from"../line/gradientStrokeConstants.js";import{BaseHittestVertexInput as w}from"./AFeatureShader.js";import{LineShader as b,getLineVertexData as x,getLineAntialiasing as S,LineVertexInput as L,LineFragmentInput as j}from"./LineShader.js";import{MosaicInfo as A}from"./MosaicInfo.js";import{getBit as D,getBitBool as z,oneMinus as C}from"./utils.js";function F(t){return g(new l(0),t).multiply(2).subtract(1)}class G extends L{}t([i(9,l)],G.prototype,"accumulatedDistance",void 0),t([i(10,l)],G.prototype,"totalLength",void 0),t([i(11,l)],G.prototype,"gradientSize",void 0),t([i(12,u)],G.prototype,"segmentDirection",void 0),t([i(13,v)],G.prototype,"tlbr",void 0);class I extends j{}class P extends s{}t([o(l)],P.prototype,"isColorPass",void 0);class k extends b{constructor(){super(...arguments),this.type="GradientStrokeShader"}vertex(t,e){const{totalLength:i,gradientSize:o,segmentDirection:r,tlbr:s}=t,p=x(this,t),m=D(t.bitset,f.isAlongLine),c=i.divide(this.view.displayZoomFactor),u=n(z(t.bitset,f.isAbsoluteSize),()=>{const t=n(a(m,new l(.5)),c,p.halfWidth);return o.divide(t)},o),h=t.accumulatedDistance.add(d(r,p.scaledOffset).divide(c)),y=s.divide(this.mosaicInfo.size.xyxy);return{...p,tlbr:y,relativePositionAlongLine:h,relativeGradientSize:u,isAlongLine:D(t.bitset,f.isAlongLine),isDiscrete:D(t.bitset,f.isDiscrete),...this.maybeRunHittest(t,e,p.halfWidth)}}fragment(t){const{isAlongLine:e,isDiscrete:i,relativePositionAlongLine:o,relativeGradientSize:r,normal:s,tlbr:d}=t,v=S(t,this.antialiasingControls.blur),f=F(s.y).multiply(p(m(s),new l(1))),w=new l(.5).multiply(f).add(new l(.5)),b=n(a(e,new l(.5)),o,w),x=n(a(i,new l(.5)),r.subtract(1),new l(0))
|
|
5
|
+
import{__decorate as t,__param as e}from"tslib";import has from"../../../../../../../core/has.js";import{location as i,uniform as o,input as r,UniformGroup as s}from"../../GraphShaderModule.js";import{ifElse as n,greaterThan as a,Float as l,dot as d,min as p,length as m,mix as c,Vec2 as u,clamp as h,texture2D as y,step as g,Vec4 as v}from"../../graph/glsl.js";import{bitset as f}from"../line/gradientStrokeConstants.js";import{BaseHittestVertexInput as w}from"./AFeatureShader.js";import{LineShader as b,getLineVertexData as x,getLineAntialiasing as S,LineVertexInput as L,LineFragmentInput as j}from"./LineShader.js";import{MosaicInfo as A}from"./MosaicInfo.js";import{getBit as D,getBitBool as z,oneMinus as C}from"./utils.js";function F(t){return g(new l(0),t).multiply(2).subtract(1)}class G extends L{}t([i(9,l)],G.prototype,"accumulatedDistance",void 0),t([i(10,l)],G.prototype,"totalLength",void 0),t([i(11,l)],G.prototype,"gradientSize",void 0),t([i(12,u)],G.prototype,"segmentDirection",void 0),t([i(13,v)],G.prototype,"tlbr",void 0);class I extends j{}class P extends s{}t([o(l)],P.prototype,"isColorPass",void 0);class k extends b{constructor(){super(...arguments),this.type="GradientStrokeShader"}vertex(t,e){const{totalLength:i,gradientSize:o,segmentDirection:r,tlbr:s}=t,p=x(this,t),m=D(t.bitset,f.isAlongLine),c=i.divide(this.view.displayZoomFactor),u=n(z(t.bitset,f.isAbsoluteSize),()=>{const t=n(a(m,new l(.5)),c,p.halfWidth);return o.divide(t)},o),h=t.accumulatedDistance.add(d(r,p.scaledOffset).divide(c)),y=s.divide(this.mosaicInfo.size.xyxy);return{...p,tlbr:y,relativePositionAlongLine:h,relativeGradientSize:u,isAlongLine:D(t.bitset,f.isAlongLine),isDiscrete:D(t.bitset,f.isDiscrete),...this.maybeRunHittest(t,e,p.halfWidth)}}fragment(t){const{isAlongLine:e,isDiscrete:i,relativePositionAlongLine:o,relativeGradientSize:r,normal:s,tlbr:d}=t,v=S(t,this.antialiasingControls.blur),f=F(s.y).multiply(p(m(s),new l(1))),w=new l(.5).multiply(f).add(new l(.5)),b=n(a(e,new l(.5)),o,w),x=n(a(i,new l(.5)),r.subtract(1),new l(0));let L=b.add(x).divide(r);L=n(a(e,new l(.5)),L,C(L));const j=c(d.xy,d.zw,new u(h(L,new l(0),new l(1)),.5)),A=y(this.mosaicInfo.texture,j),D=t.opacity.multiply(v),z=this.getFragmentOutput(A.multiply(D),t),G=g(new l(.5),this.technique.isColorPass).multiply(has("gradient-depth-epsilon")),I=g(new l(0),s.y).multiply(new l(has("gradient-depth-bias")).subtract(G));return z.glFragDepth=h(m(s).add(I),new l(0),new l(1)),z}}t([o(A)],k.prototype,"mosaicInfo",void 0),t([o(P)],k.prototype,"technique",void 0),t([e(0,r(G)),e(1,r(w))],k.prototype,"vertex",null);export{I as GradientStrokeFragmentInput,k as GradientStrokeShader,G as GradientStrokeVertexInput};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{isSome as t}from"../../../../../core/arrayUtils.js";import e from"../../../../../core/Logger.js";import{assertIsSome as s}from"../../../../../core/maybe.js";import{isLoaded as r,load as i,execute as a}from"../../../../../geometry/operators/gx/operatorGeodeticDensify.js";import{geodeticCurveType as o}from"../../../../../geometry/operators/support/geodeticCurveType.js";import{intersectsWithMargin as n,fromValues as l,intersects as c,empty as d,expandPointInPlace as u}from"../../../../../geometry/support/aaBoundingRect.js";import{getClosestDenormalizedXToReference as h}from"../../../../../geometry/support/normalizeUtils.js";import{normalizeCentralMeridianForDisplay as p}from"../../../../../geometry/support/normalizeUtilsSync.js";import{quantizeOptimizedGeometry as m,convertToGeometry as f,convertFromNestedArray as b}from"../../../../../layers/graphics/featureConversionUtils.js";import{OptimizedFeature as _}from"../../../../../layers/graphics/OptimizedFeature.js";import g from"../../../../../layers/graphics/OptimizedGeometry.js";import{internalTrackPartField as y,externalTrackLineOidPrefix as I,internalTimeReceivedField as v}from"../../../../../layers/support/streamLayerUtils.js";import{tileSize as k}from"../../../engine/webgl/definitions.js";import{AccumulatedStatistics as F}from"../aggregation/AccumulatedStatistics.js";import{ComputedAggregateField as O}from"../aggregation/ComputedAggregateField.js";import{AAggregateStrategy as j}from"./AAggregateStrategy.js";import{ASendState as x}from"./AProcessorStrategy.js";import{FeatureTileAppendMessage as S}from"../sources/FeatureSourceMessage.js";import{createArcadeEvaluationOptions as T}from"../support/arcadeUtils.js";import{ComputedAttributeStorage as R}from"../support/ComputedAttributeStorage.js";import D from"../support/FeatureFilterEvaluator.js";import{FeatureMetadata as w}from"../support/FeatureMetadata.js";import{FeatureSetReaderIndirect as L}from"../support/FeatureSetReaderIndirect.js";import{FeatureSetReaderJSON as A}from"../support/FeatureSetReaderJSON.js";let G;const C=()=>e.getLogger("esri.views.2d.layers.features.processor.TrackStrategy"),P=32;class W{constructor(t,e,s,r,i){this.chunkIndex=t,this.featureIndex=e,this.objectId=s,this.displayId=r,this.time=i}}class z{static getOid(t){return I+t}constructor(t,e,s,r,i,a,o,n){this._schema=t,this.trackId=e,this.objectId=s,this.displayId=r,this._fields=i,this._spatialReference=a,this._metadata=o,this._isStream=n,this._maxDisplayDuration=this._schema.maxDisplayDuration>0?this._schema.maxDisplayDuration:1/0,this._maxDisplayObservationsPerTrack=this._schema.maxDisplayObservationsPerTrack>=1?this._schema.maxDisplayObservationsPerTrack:1/0,this._observationRecords=[],this._nextObservationRecords=[],this._trackLinePath=[],this._bounds=[],this._trackLineGeometry=new g}get _trackLineAttributes(){const t={...this._latestObservationFeature?.attributes,aggregateId:this.objectId,[y]:0};if(null!=this._statistics)for(const e of this._statistics.values())t[e.field.name]=e.value;return t}get _startTimeField(){return this._metadata.timeInfo?.startTimeField}get length(){return this._observationRecords.length}*observations(){yield*this._observationRecords}*previousObservations(){for(let t=0;t<this._observationRecords.length-1;t++)yield this._observationRecords[t]}get latestObservationFeature(){return this._latestObservationFeature}get latestObservationRecord(){return this._latestObservationRecord}stageObservation(t,e){this._nextObservationRecords.push(new W(t,e.getIndex(),e.getObjectId(),e.getDisplayId(),null!=this._startTimeField?e.readAttributeAsTimestamp(this._startTimeField):null))}commitObservations(t,e,r){const i=new Set(this._nextObservationRecords.map(t=>t.objectId)),a=this._observationRecords.filter(t=>!i.has(t.objectId)).map(t=>t.objectId);let o,n;switch(this._observationRecords=[],this._trackLinePath=[],this._isStream||null==this._startTimeField||this._nextObservationRecords.sort((t,e)=>{const s=t.time,r=e.time;return null!=s&&null!=r?s-r:0}),this._schema.timeField){case"startTimeField":o=this._metadata.timeInfo?.startTimeField;break;case"endTimeField":o=this._metadata.timeInfo?.endTimeField;break;case"timeReceived":o=this._isStream?v:null}n=this._isStream?r?.end??Date.now():r?.end??-1/0;const l=e.map(t=>t.reader.getCursor());let c;for(let d=this._nextObservationRecords.length-1;d>=0&&!(this._observationRecords.length>=this._maxDisplayObservationsPerTrack);d--){const t=this._nextObservationRecords[d],e=l[t.chunkIndex];s(e),e.setIndex(t.featureIndex);const r=null!=o?e.readAttributeAsTimestamp(o):null;(null!=r?n-r:0)>=this._maxDisplayDuration||(this._commitObservation(t,e),c??=t)}if(null!=c){const{chunkIndex:e,featureIndex:r}=c,i=`${c.objectId}.latest`,o=t.createDisplayIdForObjectId(i),n=l[e];s(n),n.setIndex(r);const d=new _(n.readGeometryWorldSpace(),{...n.readAttributes(),[y]:1},null,i,o);this._latestObservationFeature&&a.push(this._latestObservationFeature.objectId),this._latestObservationFeature=d,this._latestObservationRecord=c}else this._latestObservationFeature=null;return this._trackLineGeometry=q(this._trackLineGeometry,this._trackLinePath,this._spatialReference),this._bounds=N(this._trackLineGeometry),this._nextObservationRecords=[],a}updateStatistics(t,e){this._statistics=F.create(this._fields);const r=t.map(t=>t.reader.getCursor());for(const{chunkIndex:i,featureIndex:a}of this._observationRecords){const t=r[i];s(t),t.setIndex(a),this._statistics.insert(t,e)}}overlapsTile(t){for(const e of this._bounds)if(n(e,t.bounds,P))return!0;return!1}getLatestObservationFeatureForTile(t){if(null==this._latestObservationFeature)return null;const{objectId:e,displayId:s,geometry:r,attributes:i}=this._latestObservationFeature,a=new g;m(a,r,!1,!1,this._metadata.geometryType,t.subscription.tile.transform);const o=l(1/0,1/0,-1/0,-1/0);E(a,(t,e)=>u(o,[t,e]));if(!c(o,l(0,0,k,k)))return null;return new _(a,i,null,e,s)}getTrackLineFeatureForTile(t){const e=new g;m(e,this._trackLineGeometry,!1,!1,"esriGeometryPolyline",t.subscription.tile.transform);return new _(e,this._trackLineAttributes,null,this.objectId,this.displayId)}getTrackLineOptimizedFeature(){return new _(this._trackLineGeometry,this._trackLineAttributes,null,this.objectId,this.displayId)}getTrackLineDisplayFeature(){const{_trackLineGeometry:t,_trackLineAttributes:e,displayId:s}=this;return{geometry:f(t,"esriGeometryPolyline",!1,!1),attributes:e,displayId:s}}_commitObservation(t,e){const s=e.readCentroidWorldSpace();let r=s?.coords[0],i=s?.coords[1];null==s&&(r=e.readXWorldSpace(),i=e.readYWorldSpace()),null!=r&&null!=i&&(this._observationRecords.unshift(t),this._trackLinePath.unshift([r,i]))}}class M extends x{constructor(t){super(t),this.done=!1}}class U extends j{static async create(t,e,s,a,o){const n=e.metadata.outSpatialReference,l=new R({spatialReference:n}),c=await Promise.all(t.fields.map(async t=>O.create(l,t))),d=t.featureFilter?await D.create({geometryType:e.metadata.geometryType,hasM:!1,hasZ:!1,timeInfo:e.metadata.timeInfo,fieldsIndex:e.metadata.fieldsIndex,spatialReference:n,filterJSON:t.featureFilter}):null;return n.isWrappable||r()||await Promise.all([import("../../../../../geometry/operators/support/apiConverter.js"),import("../../../../../geometry/operators/support/jsonConverter.js"),i()]).then(([t,e,s])=>{G={fromGeometryToGXGeometry:e.fromGeometryToGXGeometry,toGeometry:e.toGeometry,fromSpatialReference:t.fromSpatialReference}}),new U(t,e,s,n,c,d,a,o)}constructor(t,e,s,r,i,a,o,n){super(e,s,r,i,n),this._schema=t,this._featureFilter=a,this._arcadeContextInfo=o,this._tracks=new Map,this._handledChunks=new Set,this._metadata=e.metadata.weakCloneWithAdditionalFields([{name:y,alias:"trackPart",type:"esriFieldTypeSmallInteger"}]),this._trackLineMetadata=w.createFeature({geometryType:"esriGeometryPolyline",featureIdInfo:{type:"object-id",fieldName:"aggregateId"},fieldsIndex:{fields:[...this._source.metadata.fieldsIndex.fields,...this.aggregateFields,{name:y,alias:"trackPart",type:"esriFieldTypeSmallInteger"},{name:"aggregateId",alias:"aggregateId",type:"esriFieldTypeOID"}],timeZoneByFieldName:null},globalIdField:null,spatialReference:e.metadata.spatialReference,outSpatialReference:e.metadata.outSpatialReference,subtypeField:null,subtypes:null,timeInfo:e.metadata.timeInfo,timeReferenceUnknownClient:null,dateFieldsTimeZone:null,typeIdField:null,types:null})}destroy(){super.destroy();for(const t of this._tracks.values())this._removeTrack(t);this._tracks.clear()}get _isStream(){return this._source.isStream}get enablePixelBuffering(){return!0}get isAggregate(){return!1}requiresInvalidation(){return!0}invalidate(){this._handledChunks.clear(),super.invalidate()}createState(t){return new M(t)}async*applyOverrideUpdate(t){C().error("Applying override to tracks is not supported")}displayMap(t,e,s){const r=new Map(t.map(t=>[e(t),t])),i=[];for(const a of this._tracks.values()){const t=r.get(a.objectId);if(null!=t){const e=s(a.displayId,t,a.objectId);i.push(e),r.delete(a.objectId);continue}const e=a.latestObservationFeature;if(e?.objectId){const t=r.get(e.objectId);if(null!=t){const a=s(e.displayId,t,e.objectId);i.push(a),r.delete(e.objectId);continue}}for(const o of a.observations()){const t=r.get(o.objectId);if(null!=t){const e=s(o.displayId,t,o.objectId);i.push(e),r.delete(o.objectId)}}}return i}getDisplayFeatures(t){const e=new Set(t),s=[],r=[],i=this._source.chunks().map(t=>t.reader.getCursor());for(const a of this._tracks.values()){if(e.has(a.displayId)&&r.push(a.getTrackLineDisplayFeature()),null!=a.latestObservationFeature&&e.has(a.latestObservationFeature.displayId)){const{displayId:t,chunkIndex:e,featureIndex:r}=a.latestObservationRecord,o=i[e];o.setIndex(r),s.push({displayId:t,...o.readLegacyFeatureWorldSpace()})}for(const{displayId:t,chunkIndex:r,featureIndex:o}of a.observations())if(e.has(t)){const e=i[r];e.setIndex(o),s.push({displayId:t,...e.readLegacyFeatureWorldSpace()})}}return{features:s,aggregates:[],tracks:r}}getFeatureObjectIdsForAggregate(t){for(const e of this._tracks.values())if(e.objectId===t)return Array.from(e.observations(),t=>t.objectId);return[]}async*updateChunks(){0===this._handledChunks.size&&this._rebuildTracks();for(const t of this._sendStates.values())yield*this._update(t)}forEachAggregateWorldSpace(t){for(const e of this._tracks.values())t(e.getTrackLineOptimizedFeature())}_rebuildTracks(){const t=this._source.chunks();if(!t.length)return;const e=this._metadata.timeInfo?.trackIdField;if(null==e)return;const s=new Set;for(let r=0;r<t.length;r++){const i=t[r];this._handledChunks.add(i.chunkId);const a=i.reader.getCursor();for(;a.next();){const t=a.readAttribute(e),i=a.getObjectId();if(null!=t&&null!=i&&(null===this._featureFilter||this._featureFilter.check(a,this._sqlOptions))){if(a.getDisplayId()||a.setDisplayId(this._attributeStore.createDisplayIdForObjectId(i)),!this._tracks.has(t)){const e=z.getOid(t),s=this._attributeStore.createDisplayIdForObjectId(e),r=new z(this._schema,t,e,s,this.aggregateFields,this.spatialReference,this._source.metadata,this._isStream);this._tracks.set(t,r)}this._tracks.get(t).stageObservation(r,a),s.add(t)}}}for(const r of this._tracks.values())if(s.has(r.trackId)){const e=r.commitObservations(this._attributeStore,t,this._featureFilter?.timeExtent);for(const t of e)this._attributeStore.releaseDisplayIdForObjectId(t);r.updateStatistics(t,T(1,this._arcadeContextInfo))}else this._removeTrack(r)}_removeTrack(t){this._tracks.delete(t.trackId),this._attributeStore.releaseDisplayIdForObjectId(t.objectId);for(const{objectId:e}of t.observations())this._attributeStore.releaseDisplayIdForObjectId(e);null!=t.latestObservationFeature&&this._attributeStore.releaseDisplayIdForObjectId(t.latestObservationFeature.objectId)}*_update(e){if(e.done)return;e.done=!this._source.updateTracking.updating;const s=[],r=[];for(const t of this._tracks.values())if(t.length>0){if(this._schema.showLatestObservation){const r=t.getLatestObservationFeatureForTile(e);null!=r&&s.push(r)}this._schema.showTrackLine&&t.overlapsTile(e.subscription.tile)&&r.push(t.getTrackLineFeatureForTile(e))}const i=A.fromOptimizedFeatures(s,this._metadata,e.subscription.tile.transform),a=A.fromOptimizedFeatures(r,this._trackLineMetadata,e.subscription.tile.transform);let o=[];if(this._schema.showPreviousObservations){const s=this._source.chunks().map(()=>[]);for(const t of this._tracks.values())for(const{chunkIndex:e,featureIndex:r}of t.previousObservations())s[e].push(r);o=this._source.chunks().map((t,r)=>{const i=t.getTileReader(e.subscription.tile);if(null==i)return null;const a=L.from(i,s[r]);return a.setProcessorAttributes({[y]:2}),"esriGeometryPoint"!==a.geometryType&&null!=a.getInTransform()||a.setTransformForDisplay(e.subscription.tile.transform),a}).filter(t)}this.events.emit("changed");const n=e.subscription.tile.createArcadeEvaluationOptions(this._arcadeContextInfo),l=a.getCursor();for(;l.next();)this._attributeStore.setAttributeData(l.getDisplayId(),l,n,this._sqlOptions);for(const t of o){const e=t.getCursor();for(;e.next();)this._attributeStore.setAttributeData(e.getDisplayId(),e,n,this._sqlOptions)}const c=i.getCursor();for(;c.next();)this._attributeStore.setAttributeData(c.getDisplayId(),c,n,this._sqlOptions);yield new S(e.subscription,a,!1,!1,{});for(const t of o)yield new S(e.subscription,t,!1,!1,{});yield new S(e.subscription,i,!1,e.done,{})}}function q(t,e,s){if(e.length<2)return b(t,[e],!1,!1);if(s.isWrappable){let r=!1;for(let t=1;t<e.length;t++){const i=e[t][0],a=h(i,e[t-1][0],s);i!==a&&(e[t][0]=a,r=!0)}if(r){const r=p({paths:[e],spatialReference:s});if(null!=r)return b(t,r.paths,!1,!1)}return b(t,[e],!1,!1)}const r=G.fromGeometryToGXGeometry({hasM:!1,hasZ:!1,paths:[e]}),i=G.fromSpatialReference(s);if(null!=i){const e=a(r,1e6,i,o.geodesic);if(null!=e){const s=G.toGeometry(e,i);if(null!=s&&"paths"in s)return b(t,s.paths,!1,!1)}}return b(t,[e],!1,!1)}function E(t,e){const s=2,{coords:r,lengths:i}=t;if(!i.length)return void e(r[0],r[1]);let a=0;for(let o=0;o<i.length;o++){const t=i[o];let n=0,l=0;for(let i=0;i<t;i++)n+=r[s*(i+a)],l+=r[s*(i+a)+1],e(n,l);a+=t}}function N(t){const{lengths:e,coords:s}=t,r=2;if(!e.length)return[d()];const i=[];let a=0;for(let o=0;o<e.length;o++){const t=e[o],n=d();i.push(n);for(let e=0;e<t;e++){const t=s[r*(e+a)],i=s[r*(e+a)+1];u(n,[t,i])}a+=t}return i}export{U as TrackStrategy};
|
|
5
|
+
import{isSome as t}from"../../../../../core/arrayUtils.js";import e from"../../../../../core/Logger.js";import{assertIsSome as s}from"../../../../../core/maybe.js";import{isLoaded as r,load as i,execute as a}from"../../../../../geometry/operators/gx/operatorGeodeticDensify.js";import{geodeticCurveType as o}from"../../../../../geometry/operators/support/geodeticCurveType.js";import{intersectsWithMargin as n,fromValues as l,intersects as c,empty as d,expandPointInPlace as u}from"../../../../../geometry/support/aaBoundingRect.js";import{getClosestDenormalizedXToReference as h}from"../../../../../geometry/support/normalizeUtils.js";import{normalizeCentralMeridianForDisplay as p}from"../../../../../geometry/support/normalizeUtilsSync.js";import{quantizeOptimizedGeometry as m,convertToGeometry as f,convertFromNestedArray as _}from"../../../../../layers/graphics/featureConversionUtils.js";import{OptimizedFeature as b}from"../../../../../layers/graphics/OptimizedFeature.js";import g from"../../../../../layers/graphics/OptimizedGeometry.js";import{internalTrackPartField as y,externalTrackLineOidPrefix as I,internalTimeReceivedField as v}from"../../../../../layers/support/streamLayerUtils.js";import{tileSize as k}from"../../../engine/webgl/definitions.js";import{AccumulatedStatistics as F}from"../aggregation/AccumulatedStatistics.js";import{ComputedAggregateField as O}from"../aggregation/ComputedAggregateField.js";import{AAggregateStrategy as j}from"./AAggregateStrategy.js";import{ASendState as x}from"./AProcessorStrategy.js";import{FeatureTileAppendMessage as S}from"../sources/FeatureSourceMessage.js";import{createArcadeEvaluationOptions as T}from"../support/arcadeUtils.js";import{ComputedAttributeStorage as R}from"../support/ComputedAttributeStorage.js";import D from"../support/FeatureFilterEvaluator.js";import{FeatureMetadata as w}from"../support/FeatureMetadata.js";import{FeatureSetReaderIndirect as L}from"../support/FeatureSetReaderIndirect.js";import{FeatureSetReaderJSON as A}from"../support/FeatureSetReaderJSON.js";let C;const G=()=>e.getLogger("esri.views.2d.layers.features.processor.TrackStrategy"),P=32;class W{constructor(t,e,s,r,i){this.chunkIndex=t,this.featureIndex=e,this.objectId=s,this.displayId=r,this.time=i}}class z{static getOid(t){return I+t}constructor(t,e,s,r,i,a,o,n){this._schema=t,this.trackId=e,this.objectId=s,this.displayId=r,this._fields=i,this._spatialReference=a,this._metadata=o,this._isStream=n,this._maxDisplayDuration=this._schema.maxDisplayDuration>0?this._schema.maxDisplayDuration:1/0,this._maxDisplayObservationsPerTrack=this._schema.maxDisplayObservationsPerTrack>=1?this._schema.maxDisplayObservationsPerTrack:1/0,this._observationRecords=[],this._nextObservationRecords=[],this._trackLinePath=[],this._bounds=[],this._trackLineGeometry=new g}get _trackLineAttributes(){const t={...this._latestObservationFeature?.attributes,aggregateId:this.objectId,[y]:0};if(null!=this._statistics)for(const e of this._statistics.values())t[e.field.name]=e.value;return t}get _startTimeField(){return this._metadata.timeInfo?.startTimeField}get length(){return this._observationRecords.length}*observations(){yield*this._observationRecords}*previousObservations(){for(let t=0;t<this._observationRecords.length-1;t++)yield this._observationRecords[t]}get latestObservationFeature(){return this._latestObservationFeature}get latestObservationRecord(){return this._latestObservationRecord}stageObservation(t,e){this._nextObservationRecords.push(new W(t,e.getIndex(),e.getObjectId(),e.getDisplayId(),null!=this._startTimeField?e.readAttributeAsTimestamp(this._startTimeField):null))}commitObservations(t,e,r){const i=new Set(this._nextObservationRecords.map(t=>t.objectId)),a=this._observationRecords.filter(t=>!i.has(t.objectId)).map(t=>t.objectId);let o,n;switch(this._observationRecords=[],this._trackLinePath=[],this._isStream||null==this._startTimeField||this._nextObservationRecords.sort((t,e)=>{const s=t.time,r=e.time;return null!=s&&null!=r?s-r:0}),this._schema.timeField){case"startTimeField":o=this._metadata.timeInfo?.startTimeField;break;case"endTimeField":o=this._metadata.timeInfo?.endTimeField;break;case"timeReceived":o=this._isStream?v:null}n=this._isStream?r?.end??Date.now():r?.end??-1/0;const l=e.map(t=>t.reader.getCursor());let c;for(let d=this._nextObservationRecords.length-1;d>=0&&!(this._observationRecords.length>=this._maxDisplayObservationsPerTrack);d--){const t=this._nextObservationRecords[d],e=l[t.chunkIndex];s(e),e.setIndex(t.featureIndex);const r=null!=o?e.readAttributeAsTimestamp(o):null;(null!=r?n-r:0)>=this._maxDisplayDuration||(this._commitObservation(t,e),c??=t)}if(null!=c){const{chunkIndex:e,featureIndex:r}=c,i=`${c.objectId}.latest`,o=t.createDisplayIdForObjectId(i),n=l[e];s(n),n.setIndex(r);const d=new b(n.readGeometryWorldSpace(),{...n.readAttributes(),[y]:1},null,i,o);this._latestObservationFeature&&a.push(this._latestObservationFeature.objectId),this._latestObservationFeature=d,this._latestObservationRecord=c}else this._latestObservationFeature=null;return this._trackLineGeometry=q(this._trackLineGeometry,this._trackLinePath,this._spatialReference),this._bounds=N(this._trackLineGeometry),this._nextObservationRecords=[],a}updateStatistics(t,e){this._statistics=F.create(this._fields);const r=t.map(t=>t.reader.getCursor());for(const{chunkIndex:i,featureIndex:a}of this._observationRecords){const t=r[i];s(t),t.setIndex(a),this._statistics.insert(t,e)}}overlapsTile(t){for(const e of this._bounds)if(n(e,t.bounds,P))return!0;return!1}getLatestObservationFeatureForTile(t){if(null==this._latestObservationFeature)return null;const{objectId:e,displayId:s,geometry:r,attributes:i}=this._latestObservationFeature,a=new g;m(a,r,!1,!1,this._metadata.geometryType,t.subscription.tile.transform);const o=l(1/0,1/0,-1/0,-1/0);E(a,(t,e)=>u(o,[t,e]));if(!c(o,l(0,0,k,k)))return null;return new b(a,i,null,e,s)}getTrackLineFeatureForTile(t){const e=new g;m(e,this._trackLineGeometry,!1,!1,"esriGeometryPolyline",t.subscription.tile.transform);return new b(e,this._trackLineAttributes,null,this.objectId,this.displayId)}getTrackLineOptimizedFeature(){return new b(this._trackLineGeometry,this._trackLineAttributes,null,this.objectId,this.displayId)}getTrackLineDisplayFeature(){const{_trackLineGeometry:t,_trackLineAttributes:e,displayId:s}=this;return{geometry:f(t,"esriGeometryPolyline",!1,!1),attributes:e,displayId:s}}_commitObservation(t,e){const s=e.readCentroidWorldSpace();let r=s?.coords[0],i=s?.coords[1];null==s&&(r=e.readXWorldSpace(),i=e.readYWorldSpace()),null!=r&&null!=i&&(this._observationRecords.unshift(t),this._trackLinePath.unshift([r,i]))}}class M extends x{constructor(t){super(t),this.done=!1}}class U extends j{static async create(t,e,s,a,o){const n=e.metadata.outSpatialReference,l=new R({spatialReference:n}),c=await Promise.all(t.fields.map(async t=>O.create(l,t))),d=t.featureFilter?await D.create({geometryType:e.metadata.geometryType,hasM:!1,hasZ:!1,timeInfo:e.metadata.timeInfo,fieldsIndex:e.metadata.fieldsIndex,spatialReference:n,filterJSON:t.featureFilter}):null;return n.isWrappable||r()||await Promise.all([import("../../../../../geometry/operators/support/apiConverter.js"),import("../../../../../geometry/operators/support/jsonConverter.js"),i()]).then(([t,e,s])=>{C={fromGeometryToGXGeometry:e.fromGeometryToGXGeometry,toGeometry:e.toGeometry,fromSpatialReference:t.fromSpatialReference}}),new U(t,e,s,n,c,d,a,o)}constructor(t,e,s,r,i,a,o,n){super(e,s,r,i,n),this._schema=t,this._featureFilter=a,this._arcadeContextInfo=o,this._tracks=new Map,this._handledChunks=new Set,this._metadata=e.metadata.weakCloneWithAdditionalFields([{name:y,alias:"trackPart",type:"esriFieldTypeSmallInteger"}]),this._trackLineMetadata=w.createFeature({geometryType:"esriGeometryPolyline",featureIdInfo:{type:"object-id",fieldName:"aggregateId"},fieldsIndex:{fields:[...this._source.metadata.fieldsIndex.fields,...this.aggregateFields,{name:y,alias:"trackPart",type:"esriFieldTypeSmallInteger"},{name:"aggregateId",alias:"aggregateId",type:"esriFieldTypeOID"}],timeZoneByFieldName:null},globalIdField:null,spatialReference:e.metadata.spatialReference,outSpatialReference:e.metadata.outSpatialReference,subtypeField:null,subtypes:null,timeInfo:e.metadata.timeInfo,timeReferenceUnknownClient:null,dateFieldsTimeZone:null,typeIdField:null,types:null})}destroy(){super.destroy(),this._clear()}get _isStream(){return this._source.isStream}get enablePixelBuffering(){return!0}get isAggregate(){return!1}requiresInvalidation(){return!0}invalidate(){super.invalidate(),this._clear()}createState(t){return new M(t)}async*applyOverrideUpdate(t){G().error("Applying override to tracks is not supported")}displayMap(t,e,s){const r=new Map(t.map(t=>[e(t),t])),i=[];for(const a of this._tracks.values()){const t=r.get(a.objectId);if(null!=t){const e=s(a.displayId,t,a.objectId);i.push(e),r.delete(a.objectId);continue}const e=a.latestObservationFeature;if(e?.objectId){const t=r.get(e.objectId);if(null!=t){const a=s(e.displayId,t,e.objectId);i.push(a),r.delete(e.objectId);continue}}for(const o of a.observations()){const t=r.get(o.objectId);if(null!=t){const e=s(o.displayId,t,o.objectId);i.push(e),r.delete(o.objectId)}}}return i}getDisplayFeatures(t){const e=new Set(t),s=[],r=[],i=this._source.chunks().map(t=>t.reader.getCursor());for(const a of this._tracks.values()){if(e.has(a.displayId)&&r.push(a.getTrackLineDisplayFeature()),null!=a.latestObservationFeature&&e.has(a.latestObservationFeature.displayId)){const{displayId:t,chunkIndex:e,featureIndex:r}=a.latestObservationRecord,o=i[e];o.setIndex(r),s.push({displayId:t,...o.readLegacyFeatureWorldSpace()})}for(const{displayId:t,chunkIndex:r,featureIndex:o}of a.observations())if(e.has(t)){const e=i[r];e.setIndex(o),s.push({displayId:t,...e.readLegacyFeatureWorldSpace()})}}return{features:s,aggregates:[],tracks:r}}getFeatureObjectIdsForAggregate(t){for(const e of this._tracks.values())if(e.objectId===t)return Array.from(e.observations(),t=>t.objectId);return[]}async*updateChunks(){0===this._handledChunks.size&&this._rebuildTracks();for(const t of this._sendStates.values())yield*this._update(t)}forEachAggregateWorldSpace(t){for(const e of this._tracks.values())t(e.getTrackLineOptimizedFeature())}_clear(){for(const t of this._source.chunks())if(this._handledChunks.has(t.chunkId)){const e=t.reader.getCursor();for(;e.next();){const t=e.getObjectId();this._attributeStore.releaseDisplayIdForObjectId(t)}}this._handledChunks.clear();for(const t of this._tracks.values())this._removeTrack(t);this._tracks.clear()}_rebuildTracks(){const t=this._source.chunks();if(!t.length)return;const e=this._metadata.timeInfo?.trackIdField;if(null==e)return;const s=new Set;for(let r=0;r<t.length;r++){const i=t[r];if(this._handledChunks.has(i.chunkId))continue;this._handledChunks.add(i.chunkId);const a=i.reader.getCursor();for(;a.next();){const t=a.getObjectId();a.setDisplayId(this._attributeStore.createDisplayIdForObjectId(t));const i=a.readAttribute(e);if(null!=i&&null!=t&&(null===this._featureFilter||this._featureFilter.check(a,this._sqlOptions))){if(!this._tracks.has(i)){const t=z.getOid(i),e=this._attributeStore.createDisplayIdForObjectId(t),s=new z(this._schema,i,t,e,this.aggregateFields,this.spatialReference,this._source.metadata,this._isStream);this._tracks.set(i,s)}this._tracks.get(i).stageObservation(r,a),s.add(i)}}}for(const r of this._tracks.values())if(s.has(r.trackId)){const e=r.commitObservations(this._attributeStore,t,this._featureFilter?.timeExtent);for(const t of e)this._attributeStore.releaseDisplayIdForObjectId(t);r.updateStatistics(t,T(1,this._arcadeContextInfo))}else this._removeTrack(r)}_removeTrack(t){this._tracks.delete(t.trackId),this._attributeStore.releaseDisplayIdForObjectId(t.objectId),null!=t.latestObservationFeature&&this._attributeStore.releaseDisplayIdForObjectId(t.latestObservationFeature.objectId)}*_update(e){if(e.done)return;e.done=!this._source.updateTracking.updating;const s=[],r=[];for(const t of this._tracks.values())if(t.length>0){if(this._schema.showLatestObservation){const r=t.getLatestObservationFeatureForTile(e);null!=r&&s.push(r)}this._schema.showTrackLine&&t.overlapsTile(e.subscription.tile)&&r.push(t.getTrackLineFeatureForTile(e))}const i=A.fromOptimizedFeatures(s,this._metadata,e.subscription.tile.transform),a=A.fromOptimizedFeatures(r,this._trackLineMetadata,e.subscription.tile.transform);let o=[];if(this._schema.showPreviousObservations){const s=this._source.chunks().map(()=>[]);for(const t of this._tracks.values())for(const{chunkIndex:e,featureIndex:r}of t.previousObservations())s[e].push(r);o=this._source.chunks().map((t,r)=>{const i=t.getTileReader(e.subscription.tile);if(null==i)return null;const a=L.from(i,s[r]);return a.setProcessorAttributes({[y]:2}),"esriGeometryPoint"!==a.geometryType&&null!=a.getInTransform()||a.setTransformForDisplay(e.subscription.tile.transform),a}).filter(t)}this.events.emit("changed");const n=e.subscription.tile.createArcadeEvaluationOptions(this._arcadeContextInfo),l=a.getCursor();for(;l.next();)this._attributeStore.setAttributeData(l.getDisplayId(),l,n,this._sqlOptions);for(const t of o){const e=t.getCursor();for(;e.next();)this._attributeStore.setAttributeData(e.getDisplayId(),e,n,this._sqlOptions)}const c=i.getCursor();for(;c.next();)this._attributeStore.setAttributeData(c.getDisplayId(),c,n,this._sqlOptions);yield new S(e.subscription,a,!1,!1,{});for(const t of o)yield new S(e.subscription,t,!1,!1,{});yield new S(e.subscription,i,!1,e.done,{})}}function q(t,e,s){if(e.length<2)return _(t,[e],!1,!1);if(s.isWrappable){let r=!1;for(let t=1;t<e.length;t++){const i=e[t][0],a=h(i,e[t-1][0],s);i!==a&&(e[t][0]=a,r=!0)}if(r){const r=p({paths:[e],spatialReference:s});if(null!=r)return _(t,r.paths,!1,!1)}return _(t,[e],!1,!1)}const r=C.fromGeometryToGXGeometry({hasM:!1,hasZ:!1,paths:[e]}),i=C.fromSpatialReference(s);if(null!=i){const e=a(r,1e6,i,o.geodesic);if(null!=e){const s=C.toGeometry(e,i);if(null!=s&&"paths"in s)return _(t,s.paths,!1,!1)}}return _(t,[e],!1,!1)}function E(t,e){const s=2,{coords:r,lengths:i}=t;if(!i.length)return void e(r[0],r[1]);let a=0;for(let o=0;o<i.length;o++){const t=i[o];let n=0,l=0;for(let i=0;i<t;i++)n+=r[s*(i+a)],l+=r[s*(i+a)+1],e(n,l);a+=t}}function N(t){const{lengths:e,coords:s}=t,r=2;if(!e.length)return[d()];const i=[];let a=0;for(let o=0;o<e.length;o++){const t=e[o],n=d();i.push(n);for(let e=0;e<t;e++){const t=s[r*(e+a)],i=s[r*(e+a)+1];u(n,[t,i])}a+=t}return i}export{U as TrackStrategy};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import has from"../../../../../core/has.js";import{destroyMaybe as e}from"../../../../../core/maybe.js";import{notDeepEqual as t}from"../../../../../core/object.js";import{ignoreAbortErrors as r,throwIfNotAbortError as s}from"../../../../../core/promiseUtils.js";import{OptimizedFeature as a}from"../../../../../layers/graphics/OptimizedFeature.js";import{QueryEngine as i}from"../../../../../layers/graphics/data/QueryEngine.js";import{FeatureStoreStatistics as n}from"../FeatureStoreStatistics.js";import{StreamMessenger as o}from"./StreamMessenger.js";import{UpdateStatus as c}from"./strategies/ALoadStrategy.js";import{FeatureDrillDownTileLoadStrategy as d}from"./strategies/FeatureDrillDownTileLoadStrategy.js";import{FeaturePagedTileLoadStrategy as h}from"./strategies/FeaturePagedTileLoadStrategy.js";import{FeatureSnapshotLoadStrategy as u}from"./strategies/FeatureSnapshotLoadStrategy.js";import{ParquetSnapshotLoadStrategy as p}from"./strategies/ParquetSnapshotLoadStrategy.js";import{ParquetTileLoadStrategy as m}from"./strategies/ParquetTileLoadStrategy.js";import{StreamLoadStrategy as y}from"./strategies/StreamLoadStrategy.js";import{FeatureSourceChunkStore as g}from"./strategies/chunks/SourceChunkStore.js";import{UpdateTracking2D as l}from"../../support/UpdateTracking2D.js";class _{constructor(e,t,r,s){this._aggregateAdapter=e,this._subscriptions=t,this._connection=r,this._cachedObjectIds=s,this._updateTracking=new l({debugName:"FeatureSource"}),this.store=new g}destroy(){this._strategy?.destroy(),this._streamMessenger?.destroy(),this._updateTracking?.destroy(),this.store.destroy()}get metadata(){return this._strategy.metadata}get streamMessenger(){return null==this._streamMessenger&&this._initStreamMessenger(),this._streamMessenger}get statistics(){return n.from(this.store)}get updateTracking(){return this._updateTracking}get usedMemory(){return this.store.usedMemory}get queryEngine(){if(!this._queryEngine){if(!this.store||!this._strategy)return null;this._queryEngine=new i({featureStore:this.store,fieldsIndex:this.metadata.fieldsIndex,geometryType:this.metadata.geometryType,featureIdInfo:this.metadata.featureIdInfo,hasM:!1,hasZ:!1,spatialReference:this.metadata.outSpatialReference,aggregateAdapter:this._aggregateAdapter,timeInfo:this.metadata.timeInfo,definitionExpression:this._strategy?.definitionExpression,availableFields:this._strategy?.availableFields})}return this._queryEngine}get isStream(){return"stream"===this._schema.type}get hasQueryDisplayFilter(){if(!this._schema)return!1;switch(this._schema.type){case"feature":return null!=this._schema.strategy.full.displayFilterInfo;case"parquet":case"stream":return!1}}chunks(){return Array.from(this.store.chunks())}prepareCacheUpdate(e,t){const r=new Set,s=new Set;for(const a of e)this._cachedObjectIds.has(a)||(this._cachedObjectIds.add(a),r.add(a));for(const a of t)this._cachedObjectIds.delete(a),s.add(a);this.hasQueryDisplayFilter&&this._strategy.prepareCacheUpdate(r,s)}async applyCacheUpdate(){this.hasQueryDisplayFilter&&await this._updateTracking.addPromise(this._strategy.applyCacheUpdate())}cleanup(){return this.store.cleanup()}onSubscribe(e){if(this._connection.onEvent({type:"subscribe",tile:e.tile.id}),!this._strategy)return;const t=this._strategy.load(e);t.then(()=>this._connection.onEvent({type:"loaded",tile:e.tile.id})).catch(t=>this._connection.onEvent({type:"error",tile:e.tile.id,error:t})),this._updateTracking.addPromise(t)}onResume(e){this._updateTracking.addPromise(r(this._strategy?.load(e)))}onUnsubscribe(e){this._connection.onEvent({type:"unsubscribe",tile:e.tile.id}),this._strategy?.unload(e)}async applyOverride(e){await(this._strategy?.applyOverride(e))}takeOverrideUpdate(){return this._strategy?.takeOverrideUpdate()}async update(r,s){const a=this._schema;if(this._schema=r,this._queryEngine=e(this._queryEngine),a&&a.type!==r.type)throw new Error("InternalError: Reconfiguring source types is not supported.");const i=new c;return!a||t(a.service,r.service)||a.strategy.type!==r.strategy.type||t(r.strategy.full,a.strategy.full)||!await this._strategy.tryUpdate(i,r.strategy.partial)?(await this._updateStrategyType(this._schema.service,r,s),await this.store.update({metadata:this.metadata,definitionExpression:this._schema.strategy.full.definitionExpression}),!0):i.requiresInvalidation}unsafeSetQueryHistoricMoment(e){"feature"===this._schema.type&&(this._schema.strategy.full.historicMoment=e,this._strategy.unsafeSetQueryHistoricMoment(new Date(e)))}_initStreamMessenger(){null==this._streamMessenger&&(this._streamMessenger=new o(this._connection))}async normalizeOverrides(e){const t={historicMoment:e.historicMoment,commands:{updateWeak:e.commands.updateWeak.map(a.fromJSON),removeWeak:e.commands.removeWeak,update:e.commands.update.map(a.fromJSON),remove:e.commands.remove,release:e.commands.release}},r=e.commands.updateByIdWeak,s=await this._queryOptimizedFeatures(r);if(s.length!==r.length){const e=new Set(s.map(e=>e.objectId));for(const s of r)e.has(s)||t.commands.removeWeak.push(s)}return t.commands.updateWeak.push(...s),t}async _queryOptimizedFeatures(e){if(0===e.length)return[];const t=[],r=(await this._strategy.queryByObjectId(e)).getCursor();for(;r.next();)t.push(r.readOptimizedFeatureWorldSpace());return t}getObjectIdsFromGlobalIds(e){const t=this.metadata.globalIdField;if(null==t)throw new Error("InternalError: Recieved an edit with globalIds, but not supported by the service");const r=this.store.mapObjectIdsFromGlobalIds(e,t).values();return Array.from(r)}async _updateStrategyType(e,t,r){const a=this._createStrategy(e,t);this._connection.onEvent({type:"updateStrategyStart",about:a.about});const i=!!this._strategy;this.store.clear(),this._strategy?.destroy(),this._strategy=a,has("esri-2d-update-debug")&&console.debug(`Version[${r}] FeatureSource.updateStrategy`,{strategy:a});const n=Array.from(this._subscriptions.values());if(!n.length)return void this._connection.onEvent({type:"updateStrategyEnd"});const o=Promise.all(n.map(e=>this._strategy.load(e).then(()=>this._connection.onEvent({type:"loaded",tile:e.tile.id})).catch(t=>this._connection.onEvent({type:"error",tile:e.tile.id,error:t}))));this._updateTracking.addPromise(o),this._strategy.prepareCacheUpdate(this._cachedObjectIds);try{i&&await o}catch(c){s(c)}this._connection.onEvent({type:"updateStrategyEnd"}),has("esri-2d-update-debug")&&console.debug(`Version[${r}] FeatureSource.updateStrategyEnd`,{strategy:a})}_createStrategy(e,t){const r={connection:this._connection,store:this.store};switch(t.type){case"feature":return this._createFeatureLoadStrategy(e,t.strategy,r);case"parquet":return this._createParquetLoadStrategy(e,t.strategy,r);case"stream":return this._createStreamLoadStrategy(e,t.strategy,r)}}_createFeatureLoadStrategy(e,t,r){switch(t.type){case"drill-down":return new d(e,t,r);case"paged-tile":return new h(e,t,r);case"snapshot":return new u(e,t,r)}}_createParquetLoadStrategy(e,t,r){switch(t.type){case"xz":return new m(e,t,r);case"snapshot":return new p(e,t,r)}}_createStreamLoadStrategy(e,t,r){const s=new y(e,t,r);return this.streamMessenger.strategy=s,s}}export{_ as FeatureSource};
|
|
5
|
+
import has from"../../../../../core/has.js";import{destroyMaybe as e}from"../../../../../core/maybe.js";import{notDeepEqual as t}from"../../../../../core/object.js";import{ignoreAbortErrors as r,throwIfNotAbortError as s}from"../../../../../core/promiseUtils.js";import{OptimizedFeature as a}from"../../../../../layers/graphics/OptimizedFeature.js";import{QueryEngine as i}from"../../../../../layers/graphics/data/QueryEngine.js";import{FeatureStoreStatistics as n}from"../FeatureStoreStatistics.js";import{StreamMessenger as o}from"./StreamMessenger.js";import{UpdateStatus as c}from"./strategies/ALoadStrategy.js";import{FeatureDrillDownTileLoadStrategy as d}from"./strategies/FeatureDrillDownTileLoadStrategy.js";import{FeaturePagedTileLoadStrategy as h}from"./strategies/FeaturePagedTileLoadStrategy.js";import{FeatureSnapshotLoadStrategy as u}from"./strategies/FeatureSnapshotLoadStrategy.js";import{ParquetSnapshotLoadStrategy as p}from"./strategies/ParquetSnapshotLoadStrategy.js";import{ParquetTileLoadStrategy as m}from"./strategies/ParquetTileLoadStrategy.js";import{StreamLoadStrategy as y}from"./strategies/StreamLoadStrategy.js";import{FeatureSourceChunkStore as g}from"./strategies/chunks/SourceChunkStore.js";import{UpdateTracking2D as l}from"../../support/UpdateTracking2D.js";class _{constructor(e,t,r,s){this._aggregateAdapter=e,this._subscriptions=t,this._connection=r,this._cachedObjectIds=s,this._updateTracking=new l({debugName:"FeatureSource"}),this.store=new g}destroy(){this._strategy?.destroy(),this._streamMessenger?.destroy(),this._updateTracking?.destroy(),this.store.destroy()}get metadata(){return this._strategy.metadata}get streamMessenger(){return null==this._streamMessenger&&this._initStreamMessenger(),this._streamMessenger}get statistics(){return n.from(this.store)}get updateTracking(){return this._updateTracking}get usedMemory(){return this.store.usedMemory}get queryEngine(){if(!this._queryEngine){if(!this.store||!this._strategy)return null;this._queryEngine=new i({featureStore:this.store,fieldsIndex:this.metadata.fieldsIndex,geometryType:this.metadata.geometryType,featureIdInfo:this.metadata.featureIdInfo,hasM:!1,hasZ:!1,spatialReference:this.metadata.outSpatialReference,aggregateAdapter:this._aggregateAdapter,timeInfo:this.metadata.timeInfo,definitionExpression:this._strategy?.definitionExpression,availableFields:this._strategy?.availableFields})}return this._queryEngine}get isStream(){return"stream"===this._schema.type}get hasQueryDisplayFilter(){if(!this._schema)return!1;switch(this._schema.type){case"feature":return null!=this._schema.strategy.full.displayFilterInfo;case"parquet":case"stream":return!1}}chunks(){return Array.from(this.store.chunks())}prepareCacheUpdate(e,t){const r=new Set,s=new Set;for(const a of e)this._cachedObjectIds.has(a)||(this._cachedObjectIds.add(a),r.add(a));for(const a of t)this._cachedObjectIds.delete(a),s.add(a);this.hasQueryDisplayFilter&&this._strategy.prepareCacheUpdate(r,s)}async applyCacheUpdate(){this.hasQueryDisplayFilter&&await this._updateTracking.addPromise(this._strategy.applyCacheUpdate())}cleanup(){return this.store.cleanup()}onSubscribe(e){if(this._connection.onEvent({type:"subscribe",tile:e.tile.id}),!this._strategy)return;const t=this._strategy.load(e);t.then(()=>this._connection.onEvent({type:"loaded",tile:e.tile.id})).catch(t=>this._connection.onEvent({type:"error",tile:e.tile.id,error:t})),this._updateTracking.addPromise(t)}onResume(e){this._updateTracking.addPromise(r(this._strategy?.load(e)))}onUnsubscribe(e){this._connection.onEvent({type:"unsubscribe",tile:e.tile.id}),this._strategy?.unload(e)}async applyOverride(e){await(this._strategy?.applyOverride(e))}takeOverrideUpdate(){return this._strategy?.takeOverrideUpdate()}async update(r,s){const a=this._schema;if(this._schema=r,this._queryEngine=e(this._queryEngine),a&&a.type!==r.type)throw new Error("InternalError: Reconfiguring source types is not supported.");const i=new c;return!a||t(a.service,r.service)||a.strategy.type!==r.strategy.type||t(r.strategy.full,a.strategy.full)||!await this._strategy.tryUpdate(i,r.strategy.partial)?(await this._updateStrategyType(this._schema.service,r,s),await this.store.update({metadata:this.metadata,definitionExpression:this._schema.strategy.full.definitionExpression}),!0):i.requiresInvalidation}unsafeSetQueryHistoricMoment(e){"feature"===this._schema.type&&(this._schema.strategy.full.historicMoment=e,this._strategy.unsafeSetQueryHistoricMoment(new Date(e)))}_initStreamMessenger(){null==this._streamMessenger&&(this._streamMessenger=new o(this._connection))}async normalizeOverrides(e){const t={historicMoment:e.historicMoment,commands:{updateWeak:e.commands.updateWeak.map(a.fromJSON),removeWeak:e.commands.removeWeak,update:e.commands.update.map(a.fromJSON),remove:e.commands.remove,release:e.commands.release}},r=e.commands.updateByIdWeak,s=await this._queryOptimizedFeatures(r);if(s.length!==r.length){const e=new Set(s.map(e=>e.objectId));for(const s of r)e.has(s)||t.commands.removeWeak.push(s)}return t.commands.updateWeak.push(...s),t}async _queryOptimizedFeatures(e){if(0===e.length)return[];const t=[],r=(await this._strategy.queryByObjectId(e,["*"])).getCursor();for(;r.next();)t.push(r.readOptimizedFeatureWorldSpace());return t}getObjectIdsFromGlobalIds(e){const t=this.metadata.globalIdField;if(null==t)throw new Error("InternalError: Recieved an edit with globalIds, but not supported by the service");const r=this.store.mapObjectIdsFromGlobalIds(e,t).values();return Array.from(r)}async _updateStrategyType(e,t,r){const a=this._createStrategy(e,t);this._connection.onEvent({type:"updateStrategyStart",about:a.about});const i=!!this._strategy;this.store.clear(),this._strategy?.destroy(),this._strategy=a,has("esri-2d-update-debug")&&console.debug(`Version[${r}] FeatureSource.updateStrategy`,{strategy:a});const n=Array.from(this._subscriptions.values());if(!n.length)return void this._connection.onEvent({type:"updateStrategyEnd"});const o=Promise.all(n.map(e=>this._strategy.load(e).then(()=>this._connection.onEvent({type:"loaded",tile:e.tile.id})).catch(t=>this._connection.onEvent({type:"error",tile:e.tile.id,error:t}))));this._updateTracking.addPromise(o),this._strategy.prepareCacheUpdate(this._cachedObjectIds);try{i&&await o}catch(c){s(c)}this._connection.onEvent({type:"updateStrategyEnd"}),has("esri-2d-update-debug")&&console.debug(`Version[${r}] FeatureSource.updateStrategyEnd`,{strategy:a})}_createStrategy(e,t){const r={connection:this._connection,store:this.store};switch(t.type){case"feature":return this._createFeatureLoadStrategy(e,t.strategy,r);case"parquet":return this._createParquetLoadStrategy(e,t.strategy,r);case"stream":return this._createStreamLoadStrategy(e,t.strategy,r)}}_createFeatureLoadStrategy(e,t,r){switch(t.type){case"drill-down":return new d(e,t,r);case"paged-tile":return new h(e,t,r);case"snapshot":return new u(e,t,r)}}_createParquetLoadStrategy(e,t,r){switch(t.type){case"xz":return new m(e,t,r);case"snapshot":return new p(e,t,r)}}_createStreamLoadStrategy(e,t,r){const s=new y(e,t,r);return this.streamMessenger.strategy=s,s}}export{_ as FeatureSource};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import e from"../../../../../../request.js";import t from"../../../../../../core/Error.js";import r from"../../../../../../core/Logger.js";import{notDeepEqual as s}from"../../../../../../core/object.js";import{QueueProcessor as i}from"../../../../../../core/QueueProcessor.js";import a from"../../../../../../rest/support/Query.js";import{FeatureSourceQueryInfo as n}from"../FeatureSourceQueryInfo.js";import{ALoadStrategy as o}from"./ALoadStrategy.js";import{fetchQueueConcurrency as u}from"./constants.js";import{createQueryAdapter as d}from"./support/queryAdapters.js";import{FeatureSetReaderJSON as c}from"../../support/FeatureSetReaderJSON.js";class l extends o{constructor(e,t,r){super(e.metadata,t,r),this._service=e,this._didApplyOverride=!1,this._queue=new i({concurrency:u,process:async e=>{const t={signal:e.options?.signal,query:e.query.customParameters,useRequestQueue:!0};return this._adapter.executeQuery(e.query.inner,t)}}),this._queryInfo=n.create(e,{...t.full,...t.partial},this.metadata),this._adapter=d(e,this.metadata,r.connection),this._lastEditDate=e.queryMetadata.lastEditDate}destroy(){super.destroy(),this._adapter.destroy()}unsafeSetQueryHistoricMoment(e){this._queryInfo.updateHistoricMoment(e)}async tryUpdate(e,t){if(s(this.availableFields,t.availableFields)){if(this._didApplyOverride||await this._queryLastEditDateChanged())return!1;await this._updateFields(t.availableFields)}return this._schema.partial=t,!0}async queryByObjectId(e){if(0===e.length)return c.empty(this.metadata);const
|
|
5
|
+
import e from"../../../../../../request.js";import t from"../../../../../../core/Error.js";import r from"../../../../../../core/Logger.js";import{notDeepEqual as s}from"../../../../../../core/object.js";import{QueueProcessor as i}from"../../../../../../core/QueueProcessor.js";import a from"../../../../../../rest/support/Query.js";import{FeatureSourceQueryInfo as n}from"../FeatureSourceQueryInfo.js";import{ALoadStrategy as o}from"./ALoadStrategy.js";import{fetchQueueConcurrency as u}from"./constants.js";import{createQueryAdapter as d}from"./support/queryAdapters.js";import{FeatureSetReaderJSON as c}from"../../support/FeatureSetReaderJSON.js";class l extends o{constructor(e,t,r){super(e.metadata,t,r),this._service=e,this._didApplyOverride=!1,this._queue=new i({concurrency:u,process:async e=>{const t={signal:e.options?.signal,query:e.query.customParameters,useRequestQueue:!0};return this._adapter.executeQuery(e.query.inner,t)}}),this._queryInfo=n.create(e,{...t.full,...t.partial},this.metadata),this._adapter=d(e,this.metadata,r.connection),this._lastEditDate=e.queryMetadata.lastEditDate}destroy(){super.destroy(),this._adapter.destroy()}unsafeSetQueryHistoricMoment(e){this._queryInfo.updateHistoricMoment(e)}async tryUpdate(e,t){if(s(this.availableFields,t.availableFields)){if(this._didApplyOverride||await this._queryLastEditDateChanged())return!1;await this._updateFields(t.availableFields)}return this._schema.partial=t,!0}async queryByObjectId(e,t){if(0===e.length)return c.empty(this.metadata);const r=this._queryInfo.createQuery({objectIds:e});return r.inner.outFields=t,this._fetch(r,null,null)}get availableFields(){return this._schema.partial.availableFields}get definitionExpression(){return this._schema.full.definitionExpression}_onOverride(){this._didApplyOverride=!0}async _updateFields(e){this._queryInfo.updateFields(e);const r=Array.from(this.store.chunks()).map(async e=>{const t=a.fromJSON(e.queryInfo.queryJSON);if(t)try{return await this._tryUpdateFields(e.reader,t,{chunkId:e.chunkId}),null}catch(r){return r}}),s=(await Promise.all(r)).filter(e=>e);if(s.length)throw new t("featurelayer-query","Encountered errors when downloading fields",{errors:s})}async _fetch(e,t,r){const s=await this._enqueue(e,t);return await this._tryUpdateFields(s,e.inner,r),s}async _queryLastEditDateChanged(){if(null==this._lastEditDate)return!1;if(!("source"in this._service))return!1;const t=this._service.source,r={...t.query,f:"json"},s=(await e(t.path,{query:r,responseType:"json"})).data.editingInfo.lastEditDate;return s!==this._lastEditDate&&(this._lastEditDate=s,!0)}async _tryUpdateFields(e,s,i){const a=this._queryInfo.createPatchFieldsQuery(s,e,i);if(!a)return;const n=await this._enqueue(a,this._options);n.getSize()===e.getSize()?e.joinAttributes(n):r.getLogger("esri.views.2d.layers.features.sources.strategies.AFetchLoadStrategy").error(new t("featurelayer-query",`Failed to join features. Expected a count of ${e.getSize()} features, but got ${n.getSize()}`,{query:a.inner.toJSON(),debugInfo:i}))}async _enqueue(e,t){return this._connection.onEvent({type:"fetchStart"}),this._queue.push({query:e,options:t}).finally(()=>{this._connection.onEvent({type:"fetchEnd",done:0===this._queue.length})})}}export{l as AFeatureLoadStrategy};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{FeatureMetadata as t}from"../../support/FeatureMetadata.js";class r{constructor(){this._requiresInvalidation=!1}get requiresInvalidation(){return this._requiresInvalidation}requireInvalidation(){this._requiresInvalidation=!0}}class e{constructor(r,e,o){this._context=o,this._controller=new AbortController,this.metadata=t.createFeature(r),this._schema=e}destroy(){this._controller.abort(),this.store.destroy()}get store(){return this._context.store}get _connection(){return this._context.connection}get _options(){return{signal:this._controller.signal}}get _signal(){return this._controller.signal}async applyOverride(t){this._onOverride(),await this.store.applyOverride(t)}takeOverrideUpdate(){return this.store.takeOverrideUpdate()}unsafeSetQueryHistoricMoment(t){throw new Error("InternalError: LoadStrategy does not support query info")}async queryByObjectId(t){throw new Error("InternalError: LoadStrategy does not support fetching")}prepareCacheUpdate(t,r){}applyCacheUpdate(){return null}}export{e as ALoadStrategy,r as UpdateStatus};
|
|
5
|
+
import{FeatureMetadata as t}from"../../support/FeatureMetadata.js";class r{constructor(){this._requiresInvalidation=!1}get requiresInvalidation(){return this._requiresInvalidation}requireInvalidation(){this._requiresInvalidation=!0}}class e{constructor(r,e,o){this._context=o,this._controller=new AbortController,this.metadata=t.createFeature(r),this._schema=e}destroy(){this._controller.abort(),this.store.destroy()}get store(){return this._context.store}get _connection(){return this._context.connection}get _options(){return{signal:this._controller.signal}}get _signal(){return this._controller.signal}async applyOverride(t){this._onOverride(),await this.store.applyOverride(t)}takeOverrideUpdate(){return this.store.takeOverrideUpdate()}unsafeSetQueryHistoricMoment(t){throw new Error("InternalError: LoadStrategy does not support query info")}async queryByObjectId(t,r){throw new Error("InternalError: LoadStrategy does not support fetching")}prepareCacheUpdate(t,r){}applyCacheUpdate(){return null}}export{e as ALoadStrategy,r as UpdateStatus};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{parseWhereClause as e}from"../../../../../../../core/sql.js";import{ASourceChunk as t}from"./ASourceChunk.js";import{FeatureSetReaderJSON as s}from"../../../support/FeatureSetReaderJSON.js";const r=1e4,i=1e3;class
|
|
5
|
+
import{parseWhereClause as e}from"../../../../../../../core/sql.js";import{ASourceChunk as t}from"./ASourceChunk.js";import{FeatureSetReaderJSON as s}from"../../../support/FeatureSetReaderJSON.js";const r=1e4,i=1e3;class a{static async create(t){const{metadata:s,definitionExpression:r}=t,i=r?await e(r,s.fieldsIndex):null;return new a(s,i,r)}constructor(e,t,s){this.metadata=e,this._clause=t,this._definitionExpression=s}get hash(){return this._definitionExpression}testFeature(e){return null==this._clause||this._clause.testFeature(e)}}class o{constructor(){this.modified=new Map,this.removed=new Set}modify(e){this.modified.set(e.objectId,e),this.removed.has(e.objectId)&&this.removed.delete(e.objectId)}remove(e){this.modified.delete(e),this.removed.add(e)}get isEmpty(){return 0===this.modified.size&&0===this.removed.size}applyWhereClause(e){const t=new o;for(const[s,r]of this.modified)e.testFeature(r)?t.modified.set(s,r):t.removed.add(r.objectId);for(const s of this.removed)t.removed.add(s);return t}}class n extends t{constructor(e){super(),this._reader=e,this.chunkId="override",this.normalizedChunkId="override"}static fromFeatures(e,t){const r=s.fromOptimizedFeatures(e,t);return new n(r)}get reader(){return this._reader}get queryInfo(){return{}}get first(){return!1}get end(){return!1}get isTiled(){return!1}getTileReader(e){if(!this._reader.getSize())return null;const t=this.queryFeaturesInBounds(e.bounds);return t.setTransformForDisplay(e.transform),t}}class d{constructor(e,t){this.inner=e,this.isWeak=t,this.lastWeak=null}get isStrong(){return!this.isWeak}}class h{constructor(e){this._parameters=e,this._overrides=new Map,this._update=new o,this._lastCleanup=0}update(e){this._parameters=e}hasOverride(e){return this._overrides.has(e)}onChunkInsert(e){if(this._overrides.size){const t=e.reader.getCursor();for(;t.next();){const e=t.getObjectId(),s=this._overrides.get(e);if(s?.lastWeak&&(s.lastWeak=null),s?.isWeak){const e=t.readOptimizedFeatureWorldSpace(),r=s.inner?.attributes??{};e.attributes={...r,...e.attributes},s.inner=e,this._update.modify(e),this.invalidate()}}}e.registerOverrides(this)}apply(e,t){const{updateWeak:s,removeWeak:r,update:i,remove:a,release:o}=e.commands;this.invalidate();for(const n of s){const e=new d(n,!0),t=this._overrides.get(n.objectId);t?.isStrong?t.lastWeak=e:(this._overrides.set(n.objectId,e),this._update.modify(n))}for(const n of i){const e=new d(n,!1),t=this._overrides.get(n.objectId);e.lastWeak=t?.isWeak?t:t?.lastWeak??null,this._overrides.set(n.objectId,e),this._update.modify(n)}for(const n of r){const e=new d(null,!0),t=this._overrides.get(n);t?.isStrong?t.lastWeak=e:(this._overrides.set(n,e),this._update.remove(n))}for(const n of a){const e=new d(null,!1),t=this._overrides.get(n);e.lastWeak=t?.isWeak?t:t?.lastWeak??null,this._overrides.set(n,e),this._update.remove(n)}if(o.length){const e=new Set;for(const t of o){const s=this._overrides.get(t);s?.lastWeak?(this._overrides.set(t,s.lastWeak),null==s.lastWeak.inner?this._update.remove(t):this._update.modify(s.lastWeak.inner)):s&&!s.isWeak&&(this._overrides.delete(t),e.add(t))}t.forEachUnsafe(t=>{const s=t.getObjectId();e.has(s)&&(this._update.modify(t.readOptimizedFeatureWorldSpace()),e.delete(s))});for(const t of e.values())this._update.remove(t)}}clearWeakOverrides(){for(const[e,t]of this._overrides.entries())t.isWeak&&this._overrides.delete(e);this.invalidate()}cleanup(e){if(this._overrides.size<r)return;const t=performance.now();if(t-this._lastCleanup<i)return;this._lastCleanup=t;const s=this._getWeakDeletions();if(!(s.size<r)){for(const t of e){const e=t.reader.withoutOverrides().getCursor();for(;e.next();){const t=e.getObjectId();s.delete(t)}}for(const e of s)this._overrides.delete(e);s.size&&this.invalidate()}}takeOverrideUpdate(){const e=this._update;return e.isEmpty?null:(this._update=new o,e.applyWhereClause(this._parameters))}asChunk(){const e=this._parameters;if(this._lastOverrideParametersHash!==e.hash&&(this._lastOverrideParametersHash=e.hash,this._chunk=null),!this._chunk){const t=[];for(const s of this._overrides.values())null!=s.inner&&e.testFeature(s.inner)&&t.push(s.inner);this._chunk=n.fromFeatures(t,e.metadata)}return this._chunk}invalidate(){this._chunk=null}putWeakObjectIdsFromGlobalIds(e,t,s){for(const[r,i]of this._overrides.entries()){if(i.isWeak&&null!=i.inner){const a=i.inner.attributes[s];a&&t.has(a)&&!e.has(a)&&e.set(a,r);continue}if(null!=i.lastWeak&&null!=i.lastWeak.inner){const a=i.lastWeak.inner.attributes[s];a&&t.has(a)&&!e.has(a)&&e.set(a,r)}}}_getWeakDeletions(){const e=new Set;for(const[t,s]of this._overrides.entries())s.isWeak&&null==s.inner&&e.add(t);return e}}export{n as OverrideChunk,a as OverrideParameters,h as OverrideState,o as OverrideUpdate};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{isSome as e}from"../../../core/arrayUtils.js";import{createFieldInfos as i}from"../../../support/popupUtils.js";import t from"../../../tables/AttributeTableTemplate.js";import l from"../../../tables/elements/AttributeTableAttachmentElement.js";import
|
|
5
|
+
import{isSome as e}from"../../../core/arrayUtils.js";import{createFieldInfos as i}from"../../../support/popupUtils.js";import t from"../../../tables/AttributeTableTemplate.js";import l from"../../../tables/elements/AttributeTableAttachmentElement.js";import n from"../../../tables/elements/AttributeTableFieldElement.js";import r from"../../../tables/elements/AttributeTableGroupElement.js";import o from"../../../tables/elements/AttributeTableRelationshipElement.js";import s from"../../../tables/support/FieldOrder.js";import a from"./AttachmentsColumnTemplate.js";import{isGroupColumn as d,isFieldColumn as m,isRelationshipColumn as p,isAttachmentsColumn as f}from"./columnUtils.js";import u from"./FieldColumnTemplate.js";import c from"./GroupColumnTemplate.js";import h from"./RelationshipColumnTemplate.js";import b from"./TableTemplate.js";import{isIFeatureTableSupportedLayer as w,isIFeatureTableSupportedLayerWithAttachments as y,isIFeatureTableSupportedLayerWithRelationships as T,hasTemplateForField as j}from"./tableUtils.js";function F(i,t){const l=[];return i?.forEach(i=>{const{description:n,label:r,type:o}=i;if("group"===o){const o=i.elements.map(e=>v(e,t)).filter(e);if(!o?.length)return;l.push(new c({description:n,columnTemplates:o,label:r}))}else{const e=v(i,t);if(!e)return;l.push(e)}}),l}function v(e,i){const{description:t,label:l,type:n}=e;if("field"===n){const n=e.fieldName??void 0,r=i.findIndex(e=>e.field&&e.field===n),o=r>-1?i.at(r)?.order:void 0;return new u({description:t,direction:o,fieldName:n,initialSortPriority:o&&r>-1?r:null,label:l})}return"attachment"===n?new a({description:t,label:l}):"relationship"===n?new h({description:t,label:l,relationshipId:e.relationshipId}):void 0}function N(i){const t=[];return i.forEach(i=>{const{hidden:l}=i;if(d(i)){if(l)return;const n=i.columns?.map(e=>E(e)).filter(e);if(!n?.length)return;t.push(new r({elements:n}))}else{const e=E(i);if(!e)return;t.push(e)}}),t}function E(e){const{fieldName:i,hidden:t}=e;if(m(e)){if(!t)return new n({fieldName:i})}else if(p(e)){if(!t)return new o({relationshipId:e.relationshipId})}else if(f(e)&&!t)return new l}async function I({layer:e,excludeAttachments:r,excludeRelationships:s,excludedFieldTypesOverride:a}){const d=[],m=[];if(!e||!w(e))return new t;await e.load();const p=i(e,{...a&&{ignoreFieldTypes:a},sortDisabled:!0});for(const{visible:i,fieldName:t}of p)i&&d.push(new n({fieldName:t}));return!d.length&&e.objectIdField&&d.push(new n({fieldName:e.objectIdField})),y(e)&&!0!==r&&d.push(new l),T(e)&&!0!==s&&e.relationships?.forEach(e=>{d.push(new o({relationshipId:e.id}))}),new t({elements:d,orderByFields:m})}async function x(e){const{excludeAttachments:t,excludeRelationships:l,layer:n,excludedFieldTypesOverride:r}=e,o=[];await n.load();return i(n,{...r&&{ignoreFieldTypes:r},sortDisabled:!0}).forEach(({fieldName:e,format:i,label:t,visible:l})=>{null!=e&&o.push(new u({fieldName:e,format:i,label:t,visible:l}))}),y(n)&&!0!==t&&o.push(new a),T(n)&&!0!==l&&n.relationships?.forEach(({id:e})=>{o.push(new h({relationshipId:e}))}),new b({columnTemplates:o})}async function A(e){const{layer:t,template:l,includeHiddenFields:n,excludedFieldTypesOverride:r}=e,o=l.orderByFields??[],s=F(l.elements,o);if(n){await t.load();i(t,{...r&&{ignoreFieldTypes:r},sortDisabled:!0}).forEach(e=>{if(!e.fieldName)return;const{fieldName:i}=e;if(!j(i,s)){const e=o.findIndex(e=>e.field&&e.field===i),t=e>-1?o.at(e)?.order:void 0,l=t&&e>-1?e:null;s.push(new u({direction:t,fieldName:i,initialSortPriority:l,visible:!1}))}}),y(t)&&!s.some(e=>"attachment"===e.type)&&s.push(new a({visible:!1})),T(t)&&t.relationships?.forEach(({id:e})=>{s.some(i=>"relationship"===i.type&&i.relationshipId===e)||s.push(new h({relationshipId:e,visible:!1}))})}return new b({columnTemplates:s})}function g(e,i,t=!0){const{allColumns:l,columns:n}=e,r=[],o=N(n.toArray());e.activeSortOrders.forEach(({fieldName:e,direction:i})=>{e&&i&&r.push(new s({field:e,order:i}))});return l.filter(e=>null!=e.direction&&(!e.hidden||t)).forEach(({fieldName:e,direction:i})=>{const t=r.find(i=>i.field===e);i&&!t&&r.push(new s({field:e,order:i}))}),i.elements=o,i.orderByFields=r,i}export{N as createAttributeTableElements,I as createAttributeTableTemplateFromLayer,F as createColumnTemplates,E as createNestedAttributeTableElement,v as createNestedColumnTemplate,A as createTableTemplateFromAttributeTableTemplate,x as createTableTemplateFromLayer,g as syncAttributeTableTemplateWithTable};
|