Closed nstjean closed 4 years ago
I will be working on this :smile:
Awesome!!! Thank you :)
@sagarpreet-chadha just want to clarify. How does the zoom_filter array calculate and return a zoom level? Does it exist anywhere already or is it something brand new?
Yes it has already be done in LBLD (https://github.com/publiclab/leaflet-blurred-location-display)! Implementation wise would be same but the _meaning of zoomfilter would be little different.
Check more about zoom_filter
array here: https://github.com/publiclab/leaflet-blurred-location-display#zoom_filter--changing-the-zoom-levels-range-where-x-precision-marker-should-be-visible-
Briefly: Let zoom_filter = [[0,4,0] , [5,7,2] , [8,11,4] , [12,18,5]] ; Each array corresponds to [lower precision level , upper precision level , zoom level to set]. So for example: [5,7,2] means if the precision of lat/lng is >=5 (lat = 23.12345 , lng = 78.32123) and <=7 then we should set zoom = 2.
Here is how it is implemented in LBLD : https://github.com/publiclab/leaflet-blurred-location-display/blob/b46195a8b407ed55cf41801a5c4fe6f3085d61fa/src/blurredLocationDisplay.js#L23
We take zoom_filter as input when we initaiize LBLD object: https://github.com/publiclab/leaflet-blurred-location-display/blob/b46195a8b407ed55cf41801a5c4fe6f3085d61fa/examples/index.html#L103
Makes sense? Thanks!
Ahhhh! Ok, I see now! So that function returns whether or not a marker should be visible at the current zoom level. But in our new function we want to check the filters to find which zoom level to return. Yes?
@sagarpreet-chadha
I understand your explanation, however when I look at the code it doesn't seem to be doing what you describe. Say we are looking at [0,4,0]
... this should correspond to a precision level between 0 and 4 equals a zoom of 0.
if(current_zoom >= options.zoom_filter[i][0] && current_zoom <= options.zoom_filter[i][1])
...
if(precision >= options.zoom_filter[i][2]){
return true ;
}
This is checking if the zoom level is between is between 0 and 4, and then comparing the precision to 0.
Currently on LBL exammples/index.html
when I look at the map zoom levels and precision it is showing on the screen I get the following:
Precision -1 : (rounded to nearest 10s) -- Zoom level 1, 2, 3, 4, 5
Precision 0 : Zoom 6, 7, 8, 9
Precision 1 : Zoom 10, 11, 12
Precision 2 : Zoom 13, 14, 15
Precision 3 : Zoom 16, 17, 18
Yes that function is coded in context of LBLD (which marker should be visible according to zoom). For LBL we need different yet similar implementation. Makes sense? Thanks!
Then here in this file is this code, which matches what I was seeing on the screen. https://github.com/publiclab/leaflet-blurred-location/blob/1040824864a3e05a83e1e3d9ac75626d56a01ae6/src/blurredLocation.js#L204-L207
Ahhh, ok. :) I'll just use the precisionTable then, since it's already in use and is the same concept... but with converting precision to zoom we don't need a range, it's just 1 to 1.
Yes okay we can do 1:1, but we need to also allow people to add their 1:1 mapping array as input to API. Thanks!
Ahh, ok. Yes. Is the format of precisionTable above acceptable or should it be an array of arrays like this?
var precisionTable = [[-2, 2], [-1, 3], [0, 6], [1, 10], [2, 13], [3, 16]]
I think it is more easy to understand if we do it as we have done in LBLD. [x, y, z] For x <= precision <= y, zoom should be z. What do you think? Thanks!
On Wed, 18 Dec 2019, 00:39 Natalie St Jean, notifications@github.com wrote:
Ahh, ok. Yes. Is the format of precisionTable above acceptable or should it be an array of arrays like this? var precisionTable = [[-2, 2], [-1, 3], [0, 6], [1, 10], [2, 13], [3, 16]]
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/publiclab/leaflet-blurred-location/issues/222?email_source=notifications&email_token=ADSCRRK64BE4Z2EA2F5RAHLQZEPV5A5CNFSM4J3MK6E2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEHDTXFY#issuecomment-566705047, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADSCRRMLDXG27ARAY5XIVOLQZEPV5ANCNFSM4J3MK6EQ .
That's fine, but it will be the same on all of them... because precision is a single number, not a range.
var precisionTable = [[-2, -2, 2], [-1, -1, 3], [0, 0, 6], [1, 1, 10], [2, 2, 13], [3, 3, 16]]
We could do precision, then a range of zooms?
var precisionTable = [[-2, 1, 2], [-1, 3, 5], [0, 6, 9], [1, 10, 12], [2, 13, 15], [3, 16, 18]]
Or honestly for consistency's sake we could keep it in the exact same order as in LBLD.
Min zoom -> max zoom -> precision. That might be the best option.
var precisionTable = [[1, 2, -2], [3, 5, -1], [6, 9, 0], [10, 12, 1], [13, 15 , 2], [16, 18, 3]]
Hey @nstjean , sorry for not able to clear this. This function should return zoom, right? Why do you think there is 1:1 mapping between precision and zoom? Why we can not have multiple precisions mapped to 1 zoom level?
Example: if precision is in between [2,5] then this function should return lets say zoom level 8. Makes sense?
@jywarren can you chime in here? Thanks!
Because based on the code there is a range of zooms for each precision level. There is only precision levels -2 through 3. The zoom levels are 1 through 18.
This is what shows on the map itself when it's in use... Precision level -2 isn't even used.
Currently on LBL
exammples/index.html
when I look at the map zoom levels and precision it is showing on the screen I get the following: Precision -1 : (rounded to nearest 10s) -- Zoom level 1, 2, 3, 4, 5 Precision 0 : Zoom 6, 7, 8, 9 Precision 1 : Zoom 10, 11, 12 Precision 2 : Zoom 13, 14, 15 Precision 3 : Zoom 16, 17, 18
I've pushed what I have complete #224 - and it works as-is. I suggest we merge this so that I can continue working in plots2 using this function, and then later if we want to change the format of the object/array I can do another PR with the change.
From @sagarpreet-chadha in https://github.com/publiclab/plots2/issues/6946: