SymbolProcessor.eaa92b93.js 7.5 KB

1
  1. import{m as C,_ as F,a0 as K,bX as $,e6 as T,l as _,aL as E,b4 as I,t as M,a as v,b2 as L,k as A}from"./index.6c049565.js";import{n as P}from"./ExpandedCIM.64535143.js";import{p as O}from"./visualVariablesUtils.4b17aac7.js";import{S as U}from"./Utils.e8554a0e.js";import{x as z,l as k,b as B,E as j,t as H}from"./Matcher.d9c9cebd.js";import{p as J}from"./BaseProcessor.693ac1c5.js";import"./BidiEngine.d8bba3fc.js";import"./enums.0295eb81.js";import"./MaterialKey.bbaab8f1.js";import"./Rect.95b0fd2e.js";import"./quantizationUtils.4f3ed95a.js";import"./GeometryUtils.4f19e772.js";import"./floatRGBA.c5518572.js";import"./visualVariablesUtils.88ca310b.js";import"./enums.2d9e6f64.js";import"./Texture.8e8dfb11.js";import"./VertexElementDescriptor.1fdca6da.js";import"./tileUtils.a1e62810.js";import"./TileClipper.7297efa2.js";import"./Geometry.d049a63c.js";import"./GeometryUtils.51c4032a.js";import"./earcut.afc1d357.js";import"./devEnvironmentUtils.d8d0484c.js";class N{constructor(e){this._remoteClient=e,this._resourceMap=new Map,this._inFlightResourceMap=new Map,this.geometryEngine=null}destroy(){}async fetchResource(e,r){const s=this._resourceMap,i=s.get(e);if(i)return i;let a=this._inFlightResourceMap.get(e);if(a)return a;try{a=this._remoteClient.invoke("tileRenderer.fetchResource",{url:e},{...r}),this._inFlightResourceMap.set(e,a),a.then(o=>(this._inFlightResourceMap.delete(e),s.set(e,o),o))}catch(o){return C(o)?null:{width:0,height:0}}return a}getResource(e){var r;return(r=this._resourceMap.get(e))!=null?r:null}}function x(t,e){return(!t.minScale||t.minScale>=e)&&(!t.maxScale||t.maxScale<=e)}function D(t){const e=t.message,r={message:{data:{},tileKey:e.tileKey,tileKeyOrigin:e.tileKeyOrigin,version:e.version},transferList:new Array};for(const s in e.data){const i=e.data[s];if(r.message.data[s]=null,v(i)){const a=i.stride,o=i.indices.slice(0),l=i.vertices.slice(0),c=i.records.slice(0),d={stride:a,indices:o,vertices:l,records:c,metrics:I(i.metrics,h=>h.slice(0))};r.transferList.push(o,l,c),r.message.data[s]=d}}return r}let S=class extends J{constructor(){super(...arguments),this.type="symbol",this._matchers={feature:null,aggregate:null},this._bufferData=new Map,this._bufferIds=new Map}initialize(){this.handles.add([this.tileStore.on("update",this.onTileUpdate.bind(this))]),this._resourceManagerProxy=new N(this.remoteClient)}destroy(){this._resourceManagerProxy.destroy()}get supportsTileUpdates(){return!0}forEachBufferId(t){this._bufferIds.forEach(e=>{e.forEach(t)})}async update(t,e){const r=e.schema.processors[0];if(r.type!=="symbol")return;const s=$(this._schema,r);(T(s,"mesh")||T(s,"target"))&&(t.mesh=!0,t.why.mesh.push("Symbology changed"),this._schema=r,this._factory=this._createFactory(r),this._factory.update(r,this.tileStore.tileScheme.tileInfo))}onTileMessage(t,e,r,s){return _(s),this._onTileData(t,e,r,s)}onTileClear(t){const e={clear:!0};return this._bufferData.delete(t.key.id),this._bufferIds.delete(t.key.id),this.remoteClient.invoke("tileRenderer.onTileData",{tileKey:t.id,data:e})}onTileError(t,e,r){const s=r.signal,i={tileKey:t.id,error:e};return this.remoteClient.invoke("tileRenderer.onTileError",i,{signal:s})}onTileUpdate(t){for(const e of t.removed)this._bufferData.has(e.key.id)&&this._bufferData.delete(e.key.id),this._bufferIds.has(e.key.id)&&this._bufferIds.delete(e.key.id);for(const e of t.added)this._bufferData.forEach(r=>{for(const s of r)s.message.tileKey===e.id&&this._updateTileMesh("append",e,D(s),[],!1,!1,null)})}_addBufferData(t,e){this._bufferData.has(t)||this._bufferData.set(t,[]),this._bufferData.get(t).push(D(e))}_createFactory(t){const{geometryType:e,objectIdField:r,fields:s}=this.service,i=(d,h)=>this.remoteClient.invoke("tileRenderer.getMaterialItems",d,h),a={geometryType:e,fields:s,spatialReference:E.fromJSON(this.spatialReference)},o=new z(i,this.tileStore.tileScheme.tileInfo),{matcher:l,aggregateMatcher:c}=t.mesh;return this._store=o,this._matchers.feature=k(l,o,a,this._resourceManagerProxy),this._matchers.aggregate=I(c,d=>k(d,o,a,this._resourceManagerProxy)),new B(e,r,o)}async _onTileData(t,e,r,s){_(s);const{type:i,addOrUpdate:a,remove:o,clear:l,end:c}=e,d=!!this._schema.mesh.sortKey;if(!a){const u={type:i,addOrUpdate:null,remove:o,clear:l,end:c,sort:d};return this.remoteClient.invoke("tileRenderer.onTileData",{tileKey:t.id,data:u},s)}const h=this._processFeatures(t,a,r,s,e.status.version);try{const u=await h;if(M(u)){const n={type:i,addOrUpdate:null,remove:o,clear:l,end:c,sort:d};return this.remoteClient.invoke("tileRenderer.onTileData",{tileKey:t.id,data:n},s)}const m=[];for(const n of u){let f=!1;const g=n.message.bufferIds,p=t.key.id,b=n.message.tileKey;if(p!==b&&v(g)){if(!this.tileStore.get(b)){this._addBufferData(p,n),m.push(n);continue}let y=this._bufferIds.get(b);y||(y=new Set,this._bufferIds.set(b,y));const R=Array.from(g);for(const w of R){if(y.has(w)){f=!0;break}y.add(w)}}f||(this._addBufferData(p,n),m.push(n))}await Promise.all(m.map(n=>{const f=t.key.id===n.message.tileKey,g=f?e.remove:[],p=f&&e.end;return this._updateTileMesh(i,t,n,g,p,e.clear,s.signal)}))}catch(u){this._handleError(t,u,s)}}async _updateTileMesh(t,e,r,s,i,a,o){const l=t,c=r.message.tileKey,d=!!this._schema.mesh.sortKey;c!==e.key.id&&(i=!1);const h=I(r,f=>f.message),u=I(r,f=>f.transferList)||[],m={type:l,addOrUpdate:h,remove:s,clear:a,end:i,sort:d},n={transferList:A(u)||[],signal:o};return _(n),this.remoteClient.invoke("tileRenderer.onTileData",{tileKey:c,data:m},n)}async _processFeatures(t,e,r,s,i){if(M(e)||!e.hasFeatures)return null;const a={transform:t.transform,hasZ:!1,hasM:!1},o=this._factory,l={viewingMode:"",scale:t.scale},c=await this._matchers.feature,d=await this._matchers.aggregate;_(s);const h=this._getLabelInfos(t,e);return await o.analyze(e.getCursor(),this._resourceManagerProxy,c,d,a,l),_(s),this._writeFeatureSet(t,e,a,h,o,r,i)}_writeFeatureSet(t,e,r,s,i,a,o){const l=e.getSize(),c=this._schema.mesh.matcher.symbologyType,d=new j(t.key.id,{features:l,records:l,metrics:0},c,a,c!==U.HEATMAP,o),h={viewingMode:"",scale:t.scale},u=e.getCursor();for(;u.next();)try{const n=u.getDisplayId(),f=v(s)?s.get(n):null;i.writeCursor(d,u,r,h,t.level,f,this._resourceManagerProxy)}catch{}const m=t.tileInfoView.tileInfo.isWrappable;return d.serialize(m)}_handleError(t,e,r){if(!C(e)){const s={tileKey:t.id,error:e.message};return this.remoteClient.invoke("tileRenderer.onTileError",s,{signal:r.signal})}}_getLabelingSchemaForScale(t){const e=this._schema.mesh.labels;if(M(e))return null;if(e.type==="subtype"){const s={type:"subtype",classes:{}};let i=!1;for(const a in e.classes){const o=e.classes[a].filter(l=>x(l,t.scale));i=i||!!o.length,s.classes[a]=o}return i?s:null}const r=e.classes.filter(s=>x(s,t.scale));return r.length?{type:"simple",classes:r}:null}_getLabels(t,e){var r;if(e.type==="subtype"){const s=this.service.subtypeField,i=L(s,"Expected to find subtype Field"),a=t.readAttribute(i);return a==null?[]:(r=e.classes[a])!=null?r:[]}return e.classes}_getLabelInfos(t,e){const r=this._getLabelingSchemaForScale(t);if(M(r))return null;const s=new Map,i=e.getCursor();for(;i.next();){const a=i.getDisplayId(),o=[],l=O(a),c=l&&i.readAttribute("cluster_count")!==1?"aggregate":"feature",d=this._getLabels(i,r);for(const h of d){if(h.target!==c)continue;const u=i.getStorage(),m=l&&c==="feature"?u.getComputedStringAtIndex(i.readAttribute("referenceId"),h.fieldIndex):u.getComputedStringAtIndex(a,h.fieldIndex);if(!m)continue;const n=P(m.toString()),f=n[0],g=n[1];this._store.getMosaicItem(h.symbol,H(f)).then(p=>{o[h.index]={glyphs:p.glyphMosaicItems,rtl:g,index:h.index}})}s.set(a,o)}return s}};S=F([K("esri.views.2d.layers.features.processors.SymbolProcessor")],S);const pe=S;export{pe as default};