height correction, new defalt
This commit is contained in:
1 parent
0891cf12a5
commit
b692f94122
12 files changed
+792
-205
No files matched your search
@@ -6,6 +6,18 @@ from urllib.request import Request, urlopen
|
||||
USER_AGENT = "FlightMap/0.1 (local non-commercial flight mapping)"
|
||||
|
||||
|
||||
def request_bytes(url: str, *, max_bytes: int = 32 * 1024 * 1024) -> bytes:
|
||||
request = Request(url, headers={"User-Agent": USER_AGENT})
|
||||
try:
|
||||
with urlopen(request, timeout=60) as response:
|
||||
content = response.read(max_bytes + 1)
|
||||
except (URLError, TimeoutError) as exc:
|
||||
raise RuntimeError(f"Raster download failed: {exc}") from exc
|
||||
if len(content) > max_bytes:
|
||||
raise RuntimeError("Raster download exceeds the 32 MiB limit.")
|
||||
return content
|
||||
|
||||
|
||||
def request_json(
|
||||
url: str, *, data: bytes | None = None, headers: dict[str, str] | None = None
|
||||
) -> Any:
|
||||
|
||||
Reference in new issue
Block a user