-
Notifications
You must be signed in to change notification settings - Fork 0
FEAT-3: change direction labels to use 16-point compass rose directions #7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,40 +33,24 @@ const weatherCodes = { | |
99: 'Thunderstorm', | ||
} | ||
|
||
// A 32-point compass rose | ||
// A 16-point compass rose, where each point is 22.5 degrees from the previous. | ||
const compassPoints = [ | ||
['North', 'N'], | ||
['North by East', 'NbE'], | ||
['North-Northeast', 'NNE'], | ||
['Northeast by North', 'NEbN'], | ||
['Northeast', 'NE'], | ||
['Northeast by East', 'NEbE'], | ||
['East-Northeast', 'ENE'], | ||
['East by North', 'EbN'], | ||
['East', 'E'], | ||
['East by South', 'EbS'], | ||
['East-Southeast', 'ESE'], | ||
['Southeast by East', 'SEbE'], | ||
['Southeast', 'SE'], | ||
['Southeast by South', 'SEbS'], | ||
['South-Southeast', 'SSE'], | ||
['South by East', 'SbE'], | ||
['South', 'S'], | ||
['South by West', 'SbW'], | ||
['South-Southwest', 'SSW'], | ||
['Southwest by South', 'SWbS'], | ||
['Southwest', 'SW'], | ||
['Southwest by West', 'SWbW'], | ||
['West-Southwest', 'WSW'], | ||
['West by South', 'WbS'], | ||
['West', 'W'], | ||
['West by North', 'WbN'], | ||
['West-Northwest', 'WNW'], | ||
['Northwest by West', 'NWbW'], | ||
['Northwest', 'NW'], | ||
['Northwest by North', 'NWbN'], | ||
['North-Northwest', 'NNW'], | ||
['North by West', 'NbW'] | ||
] | ||
|
||
// Example Open-Meteo API query showing how the parameters are used: | ||
|
@@ -170,7 +154,7 @@ function generateCurrentConditions(weatherData) { | |
} | ||
}) | ||
|
||
const windCompass = compassPoints[Math.round(rawConditions.wind_direction_10m / 11.25)] | ||
const windCompass = compassPoints[Math.round((rawConditions.wind_direction_10m - 11.25) / 22.5)] | ||
currentConditions['wind_compass'] = windCompass[0] | ||
currentConditions['wind_compass_short'] = windCompass[1] | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The patch reduces the compass points from a 32-point system to a 16-point system—reducing the granularity of wind direction data. Here are the potential issues:
Suggestions:
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The patch seems to reduce the points in the compass representation from a 32-point system to a 16-point system. However, this modification introduces potential issues:
Math.round(rawConditions.wind_direction_10m / 11.25)
toMath.round(rawConditions.wind_direction_10m / 22.5)
. This changes the scale so it will potentially result in index values higher than the size of the newcompassPoints
array. With the old 32-point scale, you would get index values ranging from 0 up to 31. With the new 16-point scale, the maximum would be around 16 which is out of bounds forcompassPoints
, considering indices range from 0 to 15.To fix this issue, a careful redesign of the wind direction calculation might be needed, keeping in mind that the wind direction varies from 0-360 degrees. For example, code could use something like
Math.floor(rawConditions.wind_direction_10m / 22.5) % 16
.To resolve this, it would be advised to conduct a thorough utilization analysis of the
compassPoints
array and its dependent features across the entire codebase.