Skip to content

Fix OSM API gzip response handling#173

Merged
enzet merged 3 commits intoenzet:mainfrom
gitmur444:fix-osm-download-gzip-handling
Nov 15, 2025
Merged

Fix OSM API gzip response handling#173
enzet merged 3 commits intoenzet:mainfrom
gitmur444:fix-osm-download-gzip-handling

Conversation

@gitmur444
Copy link
Contributor

Problem Description

The map-machine currently fails with "Cannot download data" error when trying to download data from the OpenStreetMap API in some environments (particularly Docker containers). This happens because the OSM API returns gzip-compressed responses, but the code in osm_getter.py expects the response to start with an XML opening bracket <.

Root Cause

When the OSM API returns compressed (gzip) data, the binary content starts with gzip magic bytes \x1f\x8b instead of XML's <. This causes map-machine to reject the response as invalid and raise a "Cannot download data" error.

Evidence and Logs

With original code, when downloading a larger area:

INFO Getting https://api.openstreetmap.org/api/0.6/map...
CRITICAL Cannot download data.

With the fixed code, we get a proper error for large areas:

INFO Getting https://api.openstreetmap.org/api/0.6/map...
CRITICAL Cannot download data: too many nodes (limit is 50000). Try to request smaller area.

And for appropriately sized areas, it works correctly:

INFO Getting https://api.openstreetmap.org/api/0.6/map...
INFO Constructing ways...
INFO Constructing nodes...
INFO Drawing ways...
INFO Drawing main icons...
INFO Drawing extra icons...
INFO Drawing texts...
INFO Writing output SVG to output/paris_small_area_fixed.svg...

@enzet enzet merged commit d2f522f into enzet:main Nov 15, 2025
2 checks passed
@enzet
Copy link
Owner

enzet commented Nov 15, 2025

@gitmur444 Sorry that it took me so long to merge it. And thank you for one of the most well-documented PRs I've ever seen.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants