33 * hierarchically given an array of length scales (zoom levels).
44 */
55
6- var $ = require ( 'jquery' ) ;
7-
86/**
97 * This class manages a group of nearby points that are clustered as a
108 * single object for display purposes. The class constructor is private
@@ -106,10 +104,10 @@ ClusterTree.prototype.each = function (func) {
106104 * @returns {geo.geoPosition } The 2-d coordinates of the center.
107105 */
108106ClusterTree . prototype . coords = function ( ) {
109- var i , center = { x : 0 , y : 0 } ;
110107 if ( this . _coord ) {
111108 return this . _coord ;
112109 }
110+ var i , center = { x : 0 , y : 0 } ;
113111 // first add up the points at the node
114112 for ( i = 0 ; i < this . _points . length ; i += 1 ) {
115113 center . x += this . _points [ i ] . x ;
@@ -122,10 +120,11 @@ ClusterTree.prototype.coords = function () {
122120 center . y += this . _clusters [ i ] . coords ( ) . y * this . _clusters [ i ] . count ( ) ;
123121 }
124122
125- return {
123+ this . _coord = {
126124 x : center . x / this . count ( ) ,
127125 y : center . y / this . count ( )
128126 } ;
127+ return this . _coord ;
129128} ;
130129
131130/**
@@ -202,9 +201,6 @@ C.prototype.addPoint = function (point) {
202201 }
203202 }
204203
205- if ( ! parent ) {
206- $ . noop ( ) ;
207- }
208204 // create a new cluster with these two points
209205 newCluster = new ClusterTree ( this , zoom , [ closest , point ] ) ;
210206 this . _clusters [ zoom ] . addObject ( newCluster , newCluster . coords ( ) ) ;
0 commit comments