@arcgis/core
Version:
ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API
3 lines (2 loc) • 3.03 kB
JavaScript
/* COPYRIGHT Esri - https://js.arcgis.com/5.0.8/LICENSE.txt */
import{baseObjectMemory as t,estimateNumberMemory as e}from"../core/memoryEstimations.js";import{decodeGeohashXY as o}from"./geohashUtils.js";import s from"../geometry/SpatialReference.js";import{convertFromPolygon as i,quantizeOptimizedGeometry as r,convertFromPoint as h}from"../layers/graphics/featureConversionUtils.js";import{project as a}from"../layers/graphics/data/projectionSupport.js";import{AAggregateCell as n}from"../views/2d/layers/features/aggregation/AAggregateCell.js";import{AccumulatedStatistics as l}from"../views/2d/layers/features/aggregation/AccumulatedStatistics.js";const d=32;class c extends n{static create(t,e,o,s){const i=l.create(t),r=new Array(d);for(let h=0;h<r.length;h++)r[h]=null;return new c(i,e,o,s,r)}constructor(t,e,o,s,i){super(t),this.xNode=e,this.yNode=o,this.depth=s,this.children=i,this._objectIds=new Set,this._count=0,this._xWorldTotal=0,this._yWorldTotal=0,this._xGeohashTotal=0,this._yGeohashTotal=0,this.next=null}static get estimatedMemory(){let o=0;return o+=2*t,o+=e*d,o+=l.estimatedMemory,o}get id(){return`${this.xNode}.${this.yNode}`}get containedObjectIds(){return this._objectIds}get count(){return this._count}clone(){const t=new c(this._statistics.clone(),this.xNode,this.yNode,this.depth,this.children);return t._count=this._count,t._xWorldTotal=this._xWorldTotal,t._yWorldTotal=this._yWorldTotal,t._xGeohashTotal=this._xGeohashTotal,t._yGeohashTotal=this._yGeohashTotal,t.next=this.next,t._objectIds=new Set(this._objectIds),t}insert(t,e,o,s,i,r){this._count+=1,this._xWorldTotal+=e,this._yWorldTotal+=o,this._xGeohashTotal+=s,this._yGeohashTotal+=i,this._statistics.insert(t,r),this._objectIds.add(t.getObjectId())}merge(t){if(0!==t._count){this._count+=t._count,this._xWorldTotal+=t._xWorldTotal,this._yWorldTotal+=t._yWorldTotal,this._xGeohashTotal+=t._xWorldTotal,this._yGeohashTotal+=t._yWorldTotal,this._statistics.merge(t._statistics);for(const e of t._objectIds.values())this._objectIds.add(e)}}getCentroid(t){throw new Error("getCentroid not supported for GeohashNode")}getGeometry(t,e){const o=this._getLngLatBounds(),[h,n,l,d]=o,c=a({rings:[[[h,n],[h,d],[l,d],[l,n],[h,n]]]},s.WGS84,t),_=i(c);return null!=e?r(_,"esriGeometryPolygon",e,!1,!1):_}getGeometricCentroid(t,e){const o=this._getLngLatBounds(),[i,n,l,d]=o,c=a({x:(i+l)/2,y:(n+d)/2},s.WGS84,t),_=h(c);return null!=e?r(_,"esriGeometryPoint",e,!1,!1):_}getAttributes(){const t={aggregateId:this.id};for(const e of this._statistics.values())t[e.field.name]=e.value;return t.aggregateCount=this._count,t}find(t,e,o,s,i,r){if(s>=o)return this;const h=1-s%2,a=3*h+2*(1-h),n=2*h+3*(1-h),l=30-i-a,d=30-r-n,c=((t&7*h+3*(1-h)<<l)>>l)+((e&3*h+7*(1-h)<<d)>>d)*(8*h+4*(1-h)),_=this.children[c];return null==_?null:_.find(t,e,o,s+1,i+a,r+n)}_getLngLatBounds(){const t=this.depth,e=Math.ceil(t/2),s=Math.floor(t/2),i=30-(3*e+2*s),r=30-(2*e+3*s),h=this.xNode<<i,a=this.yNode<<r;return o({geohashX:h,geohashY:a},this.depth)}}export{c as GeohashCell};