Skip to content

Commit

Permalink
Fix a conditional that would fail to generate the top-most value.
Browse files Browse the repository at this point in the history
  • Loading branch information
manthey committed Jul 2, 2018
1 parent 01969bd commit 7084c70
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/isolineFeature.js
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ var isolineFeature = function (arg) {
* figuring out level further on and is based so that 0 will be the
* maximum level. */
values = [];
for (i = Math.ceil(mesh.minValue / spacing); i < Math.floor(mesh.maxValue / spacing); i += 1) {
for (i = Math.ceil(mesh.minValue / spacing); i <= Math.floor(mesh.maxValue / spacing); i += 1) {
values.push({value: i * spacing, position: i, fixedDigits: fixedDigits});
}
}
Expand Down
14 changes: 7 additions & 7 deletions tests/cases/isolineFeature.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ describe('Isoline Feature', function () {
var result = isoline._createIsolines();
expect(result.lines.length).toBe(18);
expect(result.lines[10].length).toBe(2);
expect(result.values.length).toBe(16);
expect(result.values.length).toBe(17);
expect(result.values[2].value).toBe(1);
expect(result.values[2].level).toBe(0);
expect(result.values[5].level).toBe(1);
Expand All @@ -176,7 +176,7 @@ describe('Isoline Feature', function () {
var result = isoline._createIsolines();
expect(result.lines.length).toBe(18);
expect(result.lines[10].length).toBe(4);
expect(result.values.length).toBe(16);
expect(result.values.length).toBe(17);
expect(result.values[2].value).toBe(1);
expect(result.values[2].level).toBe(0);
expect(result.values[5].level).toBe(1);
Expand Down Expand Up @@ -208,7 +208,7 @@ describe('Isoline Feature', function () {
var mesh = isoline._createIsolines().mesh;
var result;
result = isoline._getValueList(mesh);
expect(result.length).toBe(16);
expect(result.length).toBe(17);
expect(result[0].position).toBe(0);
expect(result[0].level).toBe(2);
expect(result[1].level).toBe(0);
Expand All @@ -220,17 +220,17 @@ describe('Isoline Feature', function () {
// restrictive max
isoline.isoline({min: null, max: 5});
result = isoline._getValueList(mesh);
expect(result.length).toBe(10);
expect(result.length).toBe(11);
expect(result[9].value).toBe(4.5);
// non-restrictive max
isoline.isoline({min: null, max: 20});
result = isoline._getValueList(mesh);
expect(result.length).toBe(16);
expect(result.length).toBe(17);
expect(result[15].value).toBe(7.5);
// position should be based on round numbers
isoline.isoline({min: 1, max: 5});
result = isoline._getValueList(mesh);
expect(result.length).toBe(20);
expect(result.length).toBe(21);
expect(result[0].position).toBe(5);
expect(result[19].value).toBeCloseTo(4.8);
expect(result[19].position).toBe(24);
Expand All @@ -253,7 +253,7 @@ describe('Isoline Feature', function () {
// spacing
isoline.isoline({min: null, max: null, spacing: 0.2});
result = isoline._getValueList(mesh);
expect(result.length).toBe(40);
expect(result.length).toBe(41);
expect(result[0].value).toBeCloseTo(0);
expect(result[39].value).toBeCloseTo(7.8);
// values
Expand Down
6 changes: 3 additions & 3 deletions tutorials/isoline/index.pug
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ block mainTutorial
iso.isoline('count', 10).draw();
});
+codeblock_test('isoline count', [
'map.layers()[1].features()[0]._createIsolines().values.length === 12'
'map.layers()[1].features()[0]._createIsolines().values.length === 13'
])

:markdown-it
Expand All @@ -75,7 +75,7 @@ block mainTutorial
iso.isoline('count', 8).draw();
});
+codeblock_test('isoline count', [
'map.layers()[1].features()[0]._createIsolines().values.length === 6'
'map.layers()[1].features()[0]._createIsolines().values.length === 7'
])

:markdown-it
Expand All @@ -101,7 +101,7 @@ block mainTutorial
iso.isoline('spacing', 125).draw();
});
+codeblock_test('isoline spacing', [
'map.layers()[1].features()[0]._createIsolines().values.length === 9'
'map.layers()[1].features()[0]._createIsolines().values.length === 10'
])

:markdown-it
Expand Down

0 comments on commit 7084c70

Please sign in to comment.