Skip to content

Commit

Permalink
Very large serie cause Stack Overflow / fix issue #33
Browse files Browse the repository at this point in the history
  • Loading branch information
simon committed Feb 10, 2017
1 parent 46bdc17 commit 9a0b715
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 19 deletions.
18 changes: 16 additions & 2 deletions lib/geostats.js
Original file line number Diff line number Diff line change
Expand Up @@ -271,15 +271,29 @@ var geostats = function(a) {
if (this._nodata())
return;

this.stat_min = Math.min.apply(null, this.serie);
this.stat_min = this.serie[0];

for (i = 0; i < this.pop(); i++) {
if (this.serie[i] < min) {
this.stat_min = this.serie[i];
}
}

return this.stat_min;
};

/** return max value */
this.max = function() {

this.stat_max = Math.max.apply(null, this.serie);
if (this._nodata())
return;

this.stat_max = this.serie[0];
for (i = 0; i < this.pop(); i++) {
if (this.serie[i] > max) {
this.stat_max = this.serie[i];
}
}

return this.stat_max;
};
Expand Down
Loading

0 comments on commit 9a0b715

Please sign in to comment.