@arcgis/core
Version:
ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API
6 lines (5 loc) • 3.05 kB
JavaScript
/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
*/
import{decodeGeohashXY as t}from"./geohashUtils.js";import e from"../geometry/SpatialReference.js";import{convertFromPolygon as o,quantizeOptimizedGeometry as s,convertFromPoint as r}from"../layers/graphics/featureConversionUtils.js";import i from"../layers/graphics/OptimizedGeometry.js";import{project as h}from"../layers/graphics/data/projectionSupport.js";import{AAggregateCell as a}from"../views/2d/layers/features/aggregation/AAggregateCell.js";import{AccumulatedStatistics as n}from"../views/2d/layers/features/aggregation/AccumulatedStatistics.js";class l extends a{static create(t,e,o,s){const r=n.create(t),i=new Array(32);for(let h=0;h<i.length;h++)i[h]=null;return new l(r,e,o,s,i)}constructor(t,e,o,s,r){super(t),this.xNode=e,this.yNode=o,this.depth=s,this.children=r,this._objectIds=new Set,this._count=0,this._xWorldTotal=0,this._yWorldTotal=0,this._xGeohashTotal=0,this._yGeohashTotal=0,this.next=null}get id(){return`${this.xNode}.${this.yNode}`}get containedObjectIds(){return this._objectIds}get count(){return this._count}clone(){const t=new l(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,r,i){this._count+=1,this._xWorldTotal+=e,this._yWorldTotal+=o,this._xGeohashTotal+=s,this._yGeohashTotal+=r,this._statistics.insert(t,i),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,r){const a=this._getLngLatBounds(),[n,l,d,c]=a,_=h({rings:[[[n,l],[n,c],[d,c],[d,l],[n,l]]]},e.WGS84,t),u=o(new i,_,!1,!1);if(null!=r){return s(new i,u,!1,!1,"esriGeometryPolygon",r,!1,!1)}return u}getGeometricCentroid(t,o){const a=this._getLngLatBounds(),[n,l,d,c]=a,_=h({x:(n+d)/2,y:(l+c)/2},e.WGS84,t),u=r(new i,_);if(null!=o){return s(new i,u,!1,!1,"esriGeometryPoint",o,!1,!1)}return u}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,r,i){if(s>=o)return this;const h=1-s%2,a=3*h+2*(1-h),n=2*h+3*(1-h),l=30-r-a,d=30-i-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,r+a,i+n)}_getLngLatBounds(){const e=this.depth,o=Math.ceil(e/2),s=Math.floor(e/2),r=30-(3*o+2*s),i=30-(2*o+3*s),h=this.xNode<<r,a=this.yNode<<i;return t({geohashX:h,geohashY:a},this.depth)}}export{l as GeohashCell};