Repository navigation
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
fix(widgets): preserve fractional scale bar distances #1045
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
base: main
Are you sure you want to change the base?
Uh oh!
There was an error while loading. Please reload this page.
fix(widgets): preserve fractional scale bar distances #1045
Changes from all commits
aa0e509ddeefcae2b9cba064e3b53af7bf1ba8196758ea02cFile filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
There are no files selected for viewing
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.
Calling
captureToImage()and writing PNGs togetExternalFilesDir(null)was a great way to visually verify the rendering during development! For the checked-in test suite, could we remove the bitmap capture and file write (along with thejava.io.Fileandjava.util.Localeimports) so the test stays fast, self-contained, and avoids unasserted disk I/O in CI?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.
As @bubenheimer mentioned, two decimals are a bit too much for someone reading a map ("1.76 mi"). What about rounding to one decimal, which also matches what we are doing in the utils Units API? The tests would need an update (e.g.
1.01 kmbecomes1 km,1.24 mibecomes1.2 mi).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.
Since we are working toward making this codebase Kotlin Multiplatform (KMP) friendly, we'd love to avoid introducing
java.text.NumberFormat(andjava.*imports in general) into:maps-compose-widgets, which currently has zerojava.*imports.Also, when zoomed far out (e.g., continental/world zoom levels where the bar spans hundreds or thousands of kilometers/miles), formatting with 2 decimal places produces long labels like
"3456.78 km"(10 characters) that can wrap or clip inside the default65.dpwidth. For distances>= 10km/mi, rounding to a whole number keeps the label compact and readable.We can handle both cleanly in pure Kotlin using
kotlin.math.roundToIntwith zero JVM dependencies: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.
Thank you for adding unit tests for
maps-compose-widgets!Following up on the KMP comment in
ScaleBar.kt, switchingformatScaleDistanceto pure Kotlin math means we can removeimport java.util.Locale(and@Before/@AfterLocale.setDefault(...)mutation) here as well, and add a test case for larger distances (>= 10km/mi):Uh oh!
There was an error while loading. Please reload this page.