Permalink
Browse files

getRangeNum() method integrated from caseypt

  • Loading branch information...
1 parent 60ae8ce commit 7e0e25b980f1e9915f071453c14a18b1224e9c75 @simogeo committed May 28, 2012
Showing with 14 additions and 0 deletions.
  1. +14 −0 lib/geostats.js
View
@@ -450,6 +450,20 @@ var geostats = function(a) {
return this.ranges;
};
+
+ /*
+ * Returns the number/index of this.ranges that value falls into
+ */
+ this.getRangeNum = function(value) {
+ var bounds, i;
+
+ for (i = 0; i < this.ranges.length; i++) {
+ bounds = this.ranges[i].split(/ - /);
+ if (value <= parseFloat(bounds[1])) {
+ return i;
+ }
+ }
+ }
/**
* Return an html legend

0 comments on commit 7e0e25b

Please sign in to comment.