-
-
Notifications
You must be signed in to change notification settings - Fork 79
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
Create a struct for ZoomLevel
#95
Comments
I'll try to pick up this issue. Can any one assign it to me? |
Sure! If you have any questions feel free to contact me on matrix |
should this be an enum with either z8 or f32 values? This way we can work with it transparently, while still enjoying the u8 perf optimizations... Although this could be a case of premature optimization, and instead it should just be two values -- |
I think both "zoomes" are conceptionally quite different and their documentation will also differ. While zoom is a property of the "viewport", the zoom level is a property of a tile (like you said). |
Should this be a type alias instead of creating a new struct? If it's just need for improving code reading. |
I think a new struct makes sense, so we can actually define functions on a ZoomLevel and make sure people understand what this u8 means. |
We probably should add a struct for
ZoomLevel
.Originally posted by @maxammann in #87 (comment)
🤔 Expected Behavior
Zoom
is a f64 which represents the current zoom on the map. It needs to be a floating number because we want to be able to zoom smoothly on the map.ZoomLevel
is a u8 which represents the level of a tile within the map's quad tree.ZoomLevel
0 would be one tile that contains the entire map,ZoomLevel
1 would be a part of the map if it was split in 4, etc.We can derive the current
ZoomLevel
from theZoom
using the constantZOOM_BOUNDS
defined in thecoords.rs
file.😯 Current Behavior
Currently
ZoomLevel
is always stored as a u8 directly.💁 Possible Solution
We should create a custom type or a struct to store the zoom level.
🔦 Context
It would make the code easier to read.
💻 Examples
The function below could be changed from:
to:
The text was updated successfully, but these errors were encountered: