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

Accuracy-circle in geolocate fix #2450

Merged
merged 5 commits into from
Apr 28, 2023
Merged

Accuracy-circle in geolocate fix #2450

merged 5 commits into from
Apr 28, 2023

Conversation

Philip2809
Copy link
Contributor

@Philip2809 Philip2809 commented Apr 26, 2023

Fixes #2449

Accuracy-circle was going places, chaning size randomly, seams to be fixed with this.

Changes

Replace _updateCircleRadius in geolocate_control.ts because the calculation was wrong. Code fix heavily inspired from stackoverflow.

Before

firefox_1SSyJ6W6sa
The old "circleDiameter" calculations
image

After

firefox_smcDyhtXiE

Launch Checklist

  • Confirm your changes do not include backports from Mapbox projects (unless with compliant license) - if you are not sure about this, please ask!
  • Briefly describe the changes in this PR.
  • Link to related issues.
  • Include before/after visuals or gifs if this PR includes visual changes.
  • Add an entry to CHANGELOG.md under the ## main section.
  • Write a test

Accuracy-circle was going places, chaning size randomly, seams to be fixed with this
@HarelM
Copy link
Collaborator

HarelM commented Apr 27, 2023

THANKS!!
Can you please add a test to cover the scenario when previous code got a wrong calculation results and the new code is getting it right?
Other than that, LGTM.

@Philip2809
Copy link
Contributor Author

Sure, I am currently writing it but I am new to writing tests, how can I run the test individually? I get this error right now:

PS C:\Philip\GitHub\maplibre-gl-js> npx jest .\src\ui\control\geolocate_control.test.ts        
No tests found, exiting with code 1
Run with `--passWithNoTests` to exit with code 0
In C:\Philip\GitHub\maplibre-gl-js
  7251 files checked across 3 projects. Run with `--verbose` for more details.
Pattern: .\src\ui\control\geolocate_control.test.ts - 0 matches

@HarelM
Copy link
Collaborator

HarelM commented Apr 27, 2023

can you try flipping the backslash? i.e. ./src/ui/control/geolocate_control.test.ts?

@Philip2809
Copy link
Contributor Author

That solved it, using tab flipped the slashes for some reason. However when running it it does not seam to update, adding a console.log does not display the content?

@HarelM
Copy link
Collaborator

HarelM commented Apr 27, 2023

Not sure what you mean, console.log should work in the tests, you need to scroll up as jest throws a lot of junk to the console...

@Philip2809
Copy link
Contributor Author

I managed to figure it out, I have now added a test, it is good? The new code passed, the old one does not.

@Philip2809
Copy link
Contributor Author

I have updated the test, it fails on the old one, success on the new one. It is the smaller radius test that fails on the old code.

@HarelM HarelM changed the title [Fix-2449] fixed accuracy-circle in geolocate Accuracy-circle in geolocate fix Apr 28, 2023
@HarelM HarelM merged commit ea0cf28 into maplibre:main Apr 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

GeoLocation accuracy-bubble going places (randomly chaning size)
2 participants