Skip to content

Commit

Permalink
Resolved conversion bugs and updated tests (Turfjs#2046)
Browse files Browse the repository at this point in the history
  • Loading branch information
anotherhale authored Mar 12, 2021
1 parent 402716a commit 11d5e4f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/turf-helpers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ export let factors: { [key: string]: number } = {
millimetres: earthRadius * 1000,
nauticalmiles: earthRadius / 1852,
radians: 1,
yards: earthRadius / 1.0936,
yards: earthRadius * 1.0936,
};

/**
Expand All @@ -128,7 +128,7 @@ export let unitsFactors: { [key: string]: number } = {
millimetres: 1000,
nauticalmiles: 1 / 1852,
radians: 1 / earthRadius,
yards: 1 / 1.0936,
yards: 1.0936133,
};

/**
Expand Down
3 changes: 3 additions & 0 deletions packages/turf-helpers/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -519,10 +519,13 @@ test("round", (t) => {

test("convertLength", (t) => {
t.equal(convertLength(1000, "meters"), 1);
t.equal(convertLength(1000, "meters", "kilometers"), 1);
t.equal(convertLength(1, "kilometers", "miles"), 0.621371192237334);
t.equal(convertLength(1, "miles", "kilometers"), 1.609344);
t.equal(convertLength(1, "nauticalmiles"), 1.852);
t.equal(convertLength(1, "meters", "centimeters"), 100.00000000000001);
t.equal(convertLength(1, "meters", "yards"), 1.0936);
t.equal(convertLength(1, "yards", "meters"), 0.91441111923921);
// t.throws(() => convertLength(1, 'foo'), 'invalid units');
t.end();
});
Expand Down

0 comments on commit 11d5e4f

Please sign in to comment.