-
Notifications
You must be signed in to change notification settings - Fork 5
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
Add ability to cache map area #82
Comments
So I think that we need to get the coordinates of the 4 extreme points of the selected area in order to get a polygon. Next, we get the x, y and z tiles of these points and cache all the tiles that are included in this polygon Example code in Python for getting tiles coords from lon and lat: import math
def deg2num(lat_deg, lon_deg, zoom):
lat_rad = math.radians(lat_deg)
n = 2.0 ** zoom
xtile = int((lon_deg + 180.0) / 360.0 * n)
ytile = int((1.0 - math.asinh(math.tan(lat_rad)) / math.pi) / 2.0 * n)
return (xtile, ytile)
print(deg2num(37.617698, 55.755864, 4))
# Output: (10, 6)
# x = 10, y = 6 |
We can use "https://api-maps.yandex.ru/services/search/v2/". In "features" json array we need "boundedBy" key. "features": [
{
"type": "Feature",
"properties": {
"id": "1",
"name": "Moscow",
"description": "Russian Federation",
"boundedBy": [
[
36.803268,
55.142226
],
[
37.967799,
56.021286
]
], Its values are diagonal points. From them we can make polygon: So, all tiles that are in this polygon refers to searched location (Moscow in this case) and we need to download them |
No description provided.
The text was updated successfully, but these errors were encountered: