publiclab / leaflet-blurred-location

A Leaflet-based interface for selecting a "blurred" or low-resolution location, to preserve privacy
https://publiclab.github.io/leaflet-blurred-location/examples/
GNU General Public License v3.0
35 stars 32 forks source link

Create getZoomFromCoordinates(lat, lon) #224

Closed nstjean closed 4 years ago

nstjean commented 4 years ago

Fixes #222

Function takes in a lat and lon and calculates the appropriate zoom level based on the precision of the lat and lon. Returns zoom.

For edge case of lat and lon having a different precision level I checked both lat and lon and took the highest one. I used helper functions getPrecisionFromCoordinates and getPrecisionFromNum

I also added precisionTable to the API options so an override object can be passed in. The default object currently is: var default_precision_table = {'-2': 2, '-1': 3, '0': 6, '1': 10, '2': 13, '3': 16}; This can later be changed if we decide we want a different format!

jywarren commented 4 years ago

Ok awesome, let's increment the version number in package.json here so we can republish on NPM when it merges!

nstjean commented 4 years ago

I think something messed up when I rebased and did a merge. I'll find whatever is causing the test failures

nstjean commented 4 years ago

Apparently jasmine tests do not like let in functions! Finally figured that out and fixed it.

I also changed the version to 1.4.1 instead of 1.3.2 based on your instructions in https://github.com/publiclab/plots2/issues/6887 :)

nstjean commented 4 years ago

Since I was already looking at the testing and this hasn't been merged yet I added tests for my new functions. :)

jywarren commented 4 years ago

Oh sorry usually the final digit goes to 0 again so 1.4.0, I misspoke when explaining it! No big deal here though. Thanks!

jywarren commented 4 years ago

I'll publish later today, or maybe @sagarpreet-chadha can, I forget if he has access?

jywarren commented 4 years ago

Thanks!

nstjean commented 4 years ago

Ok thanks! I'll remember the numbering system next time. :)

jywarren commented 4 years ago

no prob, it was my mistake! OK - published it! You can try bumping the version manually downstream now, OR dependabot can be triggered to recommend it and open a PR.

jywarren commented 4 years ago

https://www.npmjs.com/package/leaflet-blurred-location

jywarren commented 4 years ago

I just gave dependabot a bump so we'll see!