Skip to content

Conversation

@Ninjasoturi
Copy link
Contributor

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.

Ninjasoturi and others added 2 commits May 12, 2022 20:02
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
@TurtIeSocks
Copy link
Collaborator

This is awesome, thank you! Going to test tonight.

Copy link
Collaborator

@TurtIeSocks TurtIeSocks left a 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!

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')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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')

Copy link
Contributor Author

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

@TurtIeSocks TurtIeSocks merged commit 61e27d4 into WatWowMap:develop May 14, 2022
@Ninjasoturi Ninjasoturi deleted the distanceunit branch May 29, 2022 11:57
@Mygod
Copy link
Collaborator

Mygod commented Oct 18, 2023

What the fucking shit is this? This is why old people need to die.

@Mygod
Copy link
Collaborator

Mygod commented Oct 18, 2023

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.

@Mygod Mygod mentioned this pull request Oct 18, 2023
@roundaboutluke
Copy link

What the fucking shit is this? This is why old people need to die.

England has entered the chat

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants