-
-
Notifications
You must be signed in to change notification settings - Fork 0
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
i cant get a map to generate #12
Comments
Sorry, it looks like I forgot to change it to a configuration option (I keep it off while developing since I restart so often). Can you try changing line skyportal/skyportal/displaylib.py Line 362 in 271b4e7
Either to |
It looks like even if you fix this issue you're going to run into a memory error (similar to #11) trying to download the new map tile that I wasn't noticing because I've been skipping that step. I've extracted the logic below into a little script that you can use do generate the URL to a map tile of your choice that you can use to overwrite import math
from collections import OrderedDict
secrets = {
"geoapify_key": "YOUR_GEOAPIFY_API_KEY",
"aio_username": "YOUR_AIO_USERNAME",
"aio_key": "YOUR_AIO_KEY",
}
MAP_CENTER_LAT = 42.41
MAP_CENTER_LON = -71.17
GRID_WIDTH_MI = 15
MAP_STYLE = "klokantech-basic"
GEOAPIFY_API_URL_BASE = "https://maps.geoapify.com/v1/staticmap"
AIO_URL_BASE = f"https://io.adafruit.com/api/v2/{secrets['aio_username']}/integrations/image-formatter"
def build_url(base, params):
param_str = "&".join(f"{k}={v}" for k, v in params.items())
return f"{base}?{param_str}"
def urlencode(url):
encoded_chars = []
for c in url:
if any((c.isalpha(), c.isdigit(), (c in ("-", ".")))):
encoded_chars.append(c)
else:
encoded_chars.append(f"%{ord(c):02X}")
return "".join(encoded_chars)
def build_bounding_box(
map_center_lat = MAP_CENTER_LAT, map_center_lon = MAP_CENTER_LON, grid_width_mi = GRID_WIDTH_MI,
):
earth_radius_km = 6378.1
center_lat_rad = math.radians(map_center_lat)
center_lon_rad = math.radians(map_center_lon)
grid_size_km = grid_width_mi * 1.6
# Calculate distance deltas
ang_dist = grid_size_km / earth_radius_km
d_lat = ang_dist
d_lon = math.asin(math.sin(ang_dist) / math.cos(center_lat_rad))
# Scale rectangle height from the specified width
aspect_ratio = 320 / 240
d_lon *= aspect_ratio
# Calculate latitude bounds
min_center_lat_rad = center_lat_rad - d_lat
max_center_lat_rad = center_lat_rad + d_lat
# Calculate longitude bounds
min_center_lon_rad = center_lon_rad - d_lon
max_center_lon_rad = center_lon_rad + d_lon
# Convert from radians to degrees
lat_min = math.degrees(min_center_lat_rad)
lat_max = math.degrees(max_center_lat_rad)
lon_min = math.degrees(min_center_lon_rad)
lon_max = math.degrees(max_center_lon_rad)
return lat_min, lat_max, lon_min, lon_max
def get_base_map_url(grid_bounds):
lat_min, lat_max, lon_min, lon_max = grid_bounds
map_params = OrderedDict(
[
("apiKey", secrets["geoapify_key"]),
("style", MAP_STYLE),
("format", "png"),
("center", f"lonlat:{MAP_CENTER_LON},{MAP_CENTER_LAT}"),
("area", f"rect:{lon_min},{lat_min},{lon_max},{lat_max}"),
("width", 320 * 2),
("height", 240 * 2),
]
)
map_query_url = build_url(GEOAPIFY_API_URL_BASE, map_params)
adaIO_params = OrderedDict(
[
("x-aio-key", secrets["aio_key"]),
("width", 320),
("height", 240),
("output", "BMP16"),
("url", urlencode(map_query_url)),
]
)
adaIO_query_url = build_url(AIO_URL_BASE, adaIO_params)
return adaIO_query_url
print(get_base_map_url(build_bounding_box())) |
where is this code supposed to go? |
is it just a python program to run? |
one time |
Yes. |
worked perfectly thanks! |
OpenSky is still down so I can't fully test this but I think the map tile download is back to working now & has its own configuration option. |
when i tryed this project ive gotten everything to work but generating a map i changed the cordanates in the skyportal_config.py but im stuck with the default map
The text was updated successfully, but these errors were encountered: