-
-
Notifications
You must be signed in to change notification settings - Fork 79
Added distance unit selector #491
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
Conversation
In search box the distance to a point is displayed in miles even though the unit says km. Instead of fixing that to either of the units, I added `distanceUnit` in config so admins can select which ever they prefer. I guess the most optimal would be to have it possible for users to select their preferred unit but making that happen was way beyond my skill level.
Files changed:\nM server/src/configs/custom-environment-variables.json
|
This is awesome, thank you! Going to test tonight. |
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.
Just a stylistic code change but otherwise looks and works great, thank you!
server/src/services/DbCheck.js
Outdated
| static getDistance(args, isMad) { | ||
| return raw(`ROUND(( 3959 * acos( cos( radians(${args.lat}) ) * cos( radians( ${isMad ? 'latitude' : 'lat'} ) ) * cos( radians( ${isMad ? 'longitude' : 'lon'} ) - radians(${args.lon}) ) + sin( radians(${args.lat}) ) * sin( radians( ${isMad ? 'latitude' : 'lat'} ) ) ) ),2)`).as('distance') | ||
| static getDistance(args, isMad, distanceUnit) { | ||
| return raw(`ROUND(( ${(distanceUnit == 'mi') ? '3959' : '6371'} * acos( cos( radians(${args.lat}) ) * cos( radians( ${isMad ? 'latitude' : 'lat'} ) ) * cos( radians( ${isMad ? 'longitude' : 'lon'} ) - radians(${args.lon}) ) + sin( radians(${args.lat}) ) * sin( radians( ${isMad ? 'latitude' : 'lat'} ) ) ) ),2)`).as('distance') |
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.
| return raw(`ROUND(( ${(distanceUnit == 'mi') ? '3959' : '6371'} * acos( cos( radians(${args.lat}) ) * cos( radians( ${isMad ? 'latitude' : 'lat'} ) ) * cos( radians( ${isMad ? 'longitude' : 'lon'} ) - radians(${args.lon}) ) + sin( radians(${args.lat}) ) * sin( radians( ${isMad ? 'latitude' : 'lat'} ) ) ) ),2)`).as('distance') | |
| return raw(`ROUND(( ${distanceUnit === 'mi' ? '3959' : '6371'} * acos( cos( radians(${args.lat}) ) * cos( radians( ${isMad ? 'latitude' : 'lat'} ) ) * cos( radians( ${isMad ? 'longitude' : 'lon'} ) - radians(${args.lon}) ) + sin( radians(${args.lat}) ) * sin( radians( ${isMad ? 'latitude' : 'lat'} ) ) ) ),2)`).as('distance') |
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.
Done. I also applied same changes to the changes in src/components/layout/dialogs/Search.jsx
|
What the fucking shit is this? This is why old people need to die. |
|
This option needs to die. Literally everything in the game uses (kilo)meters, notably routes which is user visible. RM also doesn't respect this option for routes. |
England has entered the chat |
In search box the distance to a point is displayed in miles even though the unit says km. Instead of fixing that to either of the units, I added
distanceUnitin config so admins can select which ever they prefer. I guess the most optimal would be to have it possible for users to select their preferred unit but making that happen was way beyond my skill level.