Skip to content

Commit

Permalink
Merge pull request #201 from n8rzz/bugfix/ATC-191
Browse files Browse the repository at this point in the history
bugfix/ATC-191
  • Loading branch information
n8rzz authored Dec 18, 2016
2 parents 31092c7 + c22d404 commit ec51eec
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@




### Bugfixes
- Moves `_comment` blocks in airport json file to be within object the are describing [#145](https://github.com/n8rzz/atc/issues/145)
- Streamlines flight number generation and adds new method to add new callsigns to the existing list [#151](https://github.com/n8rzz/atc/issues/151)
Expand Down Expand Up @@ -74,3 +75,5 @@
- Aircraft strips show arrival airport in uppercase [#108](https://github.com/n8rzz/atc/issues/108)
- Updates `FixCollection.findFixByName()` to accept upper, mixed, or lower case fix name [#109](https://github.com/n8rzz/atc/issues/109)
- Switching to a previously loaded airport does not clear previous airport fixes [#115](https://github.com/n8rzz/atc/issues/115)
- Fixes `parseElevation()` so that it does not return NaN when it is given the string `'Infinity'` [#191] (https://github.com/n8rzz/atc/issues/191)
- Originally reported under [#756](https://github.com/zlsa/atc/issues/756)
5 changes: 4 additions & 1 deletion src/assets/scripts/utilities/unitConverters.js
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,9 @@ export const parseElevation = (elevation) => {

// if its a number, we're done here.
// This will catch whole numbers, floats, Infinity and -Infinity.
if (_isNumber(elevation)) {
// This checks if strings are given will skip the regex and exit early
// Also stops the function from returning NaN
if (_isNumber(elevation) || elevation === 'Infinity' || elevation === '-Infinity') {
return parseFloat(elevation);
}

Expand All @@ -320,3 +322,4 @@ export const parseElevation = (elevation) => {

return parseFloat(parsedElevation);
};

2 changes: 2 additions & 0 deletions test/utilities/unitConverters.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,4 +129,6 @@ ava('.parseElevation() should parse a string elevation into an elevation in feet
t.true(parseElevation('-23m') === -75.45931758530183);
t.true(parseElevation(Infinity) === Infinity);
t.true(parseElevation(-Infinity) === -Infinity);
t.true(parseElevation('Infinity') === Infinity);
t.true(parseElevation('-Infinity') === -Infinity);
});

0 comments on commit ec51eec

Please sign in to comment.