From 2989c5c8cb3b0603b084abb9c5b2a872506f191f Mon Sep 17 00:00:00 2001 From: David Manthey Date: Thu, 21 Jun 2018 14:22:19 -0400 Subject: [PATCH] Fix a conditional that would fail to generate the top-most value. --- src/isolineFeature.js | 2 +- tests/cases/isolineFeature.js | 14 +++++++------- tutorials/isoline/index.pug | 6 +++--- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/isolineFeature.js b/src/isolineFeature.js index a0a4b8ef29..08eb9bf63c 100644 --- a/src/isolineFeature.js +++ b/src/isolineFeature.js @@ -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}); } } diff --git a/tests/cases/isolineFeature.js b/tests/cases/isolineFeature.js index 9daa122d6d..9d606a6dc8 100644 --- a/tests/cases/isolineFeature.js +++ b/tests/cases/isolineFeature.js @@ -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); @@ -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); @@ -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); @@ -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); @@ -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 diff --git a/tutorials/isoline/index.pug b/tutorials/isoline/index.pug index 225f101f11..1b0090b4b6 100644 --- a/tutorials/isoline/index.pug +++ b/tutorials/isoline/index.pug @@ -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 @@ -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 @@ -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