Skip to content
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

Show walking distance in meters, not miles #716

Closed
amenk opened this issue Dec 3, 2022 · 11 comments
Closed

Show walking distance in meters, not miles #716

amenk opened this issue Dec 3, 2022 · 11 comments
Assignees

Comments

@amenk
Copy link

amenk commented Dec 3, 2022

I could not find a configuration option to display the walking distances in meters / kilometers instead of miles.

Is that possible already?

@miles-grant-ibigroup
Copy link
Collaborator

I believe setting the react-intl settings for distance should cause the formatting to change. @binh-dam-ibigroup may have more information

@binh-dam-ibigroup
Copy link
Collaborator

I believe setting the react-intl settings for distance should cause the formatting to change. @binh-dam-ibigroup may have more information

react-intl can determine how to display a number and unit for a given locale, however OTP-RR is still yet to compute metric quantities.

@amenk
Copy link
Author

amenk commented Dec 5, 2022

So this would be a feature request then? Or is is already configurable in OTP-RR?

@binh-dam-ibigroup
Copy link
Collaborator

So this would be a feature request then? Or is is already configurable in OTP-RR?

That would be a feature request.

@binh-dam-ibigroup
Copy link
Collaborator

@amenk So that you know, this is not an immediate priority for IBI, however we welcome pull requests.

@amenk
Copy link
Author

amenk commented Dec 11, 2022

I found out that the basic rendering logic is already there.

So it might be enough to set the second parameter here to true / a configurable value.

humanizeDistanceString(leg.distance, false, intl)

We also have to think about whether we let the end-user chose the unit or it's a system default configuration for the config.yml (or both)

PS: I am still wondering if there is a better workflow to contribute to OTP-UI than this one.

@miles-grant-ibigroup
Copy link
Collaborator

miles-grant-ibigroup commented Dec 16, 2022

Sorry for the delay on getting back to you -- well spotted on the metric support! I personally think it should somehow be set via the react-intl language. Let me know if you have any ideas there, or feel free to open a PR as a proposal and we can discuss further that way!

As for the workflow, I'm impressed you got yarn link working... For the most part my workflow is just a lot of copying files around :(

@amenk
Copy link
Author

amenk commented Dec 18, 2022

Setting that value to true works in the otp-ui storybook very well :-)

Unfortunately my yarn link approach does not seem to work that well in the moment, as I am getting

Error
Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:
1. You might have mismatching versions of React and the renderer (such as React DOM)
2. You might be breaking the Rules of Hooks
3. You might have more than one copy of React in the same app
See https://reactjs.org/link/invalid-hook-call for tips about how to debug and fix this problem.
Call Stack
 resolveDispatcher
  otp-ui/node_modules/react/cjs/react.development.js:1476:13
 useDebugValue
  otp-ui/node_modules/react/cjs/react.development.js:1540:22
 eval
  otp-ui/node_modules/styled-components/dist/styled-components.browser.esm.js:28:18500
 O
  otp-ui/node_modules/styled-components/dist/styled-components.browser.esm.js:28:19607
 renderWithHooks
  node_modules/react-dom/cjs/react-dom.development.js:14803:18
 updateForwardRef
  node_modules/react-dom/cjs/react-dom.development.js:16816:20
 beginWork
  node_modules/react-dom/cjs/react-dom.development.js:18645:16
 HTMLUnknownElement.callCallback
  node_modules/react-dom/cjs/react-dom.development.js:188:14
 Object.invokeGuardedCallbackDev
  node_modules/react-dom/cjs/react-dom.development.js:237:16
 invokeGuardedCallback
  node_modules/react-dom/cjs/react-dom.development.js:292:31
× Close

When trying this in the otp-react-redux application..

@miles-grant-ibigroup
Copy link
Collaborator

Yep this is a known issue! This is what I was wondering if you'd been able to solve. We don't use yarn link for this reason. Instead, either copying files into node_modules yourself or setting the package.json version to be a path to the local otp-ui package is sadly the way to go...

@amenk
Copy link
Author

amenk commented Feb 3, 2023

@miles-grant-ibigroup let's continue this discussion in #773

@amenk
Copy link
Author

amenk commented Feb 4, 2023

This is actually a duplicate of

#158
opentripplanner/otp-ui#116

So I am closing this one here.

@amenk amenk closed this as completed Feb 4, 2023
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

No branches or pull requests

3 participants