Skip to content

Commit

Permalink
Update buildingpart.js
Browse files Browse the repository at this point in the history
  • Loading branch information
Beakerboy authored Jul 17, 2024
1 parent 0cd8244 commit 4666624
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/buildingpart.js
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,11 @@ class BuildingPart {
*/
static cardinalToDegree(cardinal) {
const cardinalUpperCase = `${cardinal}`.toUpperCase();
let degreesTimesTwo = 'N NNE NE ENE E ESE SE SSE S SSW SW WSW W WNW NW NNW'.split(' ').indexOf(cardinalUpperCase) * 45;
const index = 'N NNE NE ENE E ESE SE SSE S SSW SW WSW W WNW NW NNW'.split(' ').indexOf(cardinalUpperCase);
if (index === -1) {
return undefined;
}
const degreesTimesTwo = index * 45;
// integer floor
return degreesTimesTwo % 2 === 0 ? degreesTimesTwo / 2 : (degreesTimesTwo - 1) / 2;
}
Expand Down

0 comments on commit 4666624

Please sign in to comment.