Skip to content

Commit

Permalink
fixing bug on counter for unique value - closing issue #50
Browse files Browse the repository at this point in the history
  • Loading branch information
simon committed Oct 17, 2019
1 parent a79d3ea commit 07fdc71
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 27 deletions.
17 changes: 13 additions & 4 deletions lib/geostats.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,14 @@ var geostats = function(a) {
this.counter = new Array();

// we init counter with 0 value
for(i = 0; i < this.bounds.length -1; i++) {
this.counter[i]= 0;
if(this.is_uniqueValues == true) {
for(i = 0; i < this.bounds.length; i++) {
this.counter[i]= 0;
}
} else {
for(i = 0; i < this.bounds.length -1; i++) {
this.counter[i]= 0;
}
}

for(j=0; j < tmp.length; j++) {
Expand All @@ -184,7 +190,7 @@ var geostats = function(a) {
var cclass = this.getClass(tmp[j]);
this.counter[cclass]++;

}
}

};

Expand Down Expand Up @@ -1127,8 +1133,11 @@ var geostats = function(a) {


if(this.is_uniqueValues == true) {
if(value == this.bounds[i])

if(value == this.bounds[i]) {
// console.log(value + ' - ' + this.bounds[i] + ' returned value : ' + i);
return i;
}
} else {
// parseFloat() is necessary
if(parseFloat(value) <= this.bounds[i + 1]) {
Expand Down
Loading

0 comments on commit 07fdc71

Please sign in to comment.