Skip to content

Navigation Menu

Sign in
Sign up

Make the download cache insensitive to region-name spelling - #7

Open
FBumann wants to merge 1 commit into
open-energy-transition:main from
FBumann:fix-cache-key-case
Open

Make the download cache insensitive to region-name spelling #7
FBumann wants to merge 1 commit into
open-energy-transition:main from
FBumann:fix-cache-key-case

Conversation

@FBumann

@FBumann FBumann commented Aug 15, 2026
edited
Loading

Copy link
Copy Markdown

Small, but helpfull change, making the caching case insensitive

The bug

The --country value is embedded verbatim in every cache key, so the spelling of the region name decides whether a cached download is found:

$ python create_grid_poster.py --country Germany # downloads 12 tiles, ~40 min
$ python create_grid_poster.py --country germany # downloads all 12 again
Using cached boundary for germany
Downloading OSM power features: power=['line'] across 12 tiles

Confirmed against a populated cache:

spelling tiles cached combined result cached
'Germany' 12/12 yes
'germany' 0/12 no

The boundary line is misleading — that geocode happened to be cached under the lower-case spelling from an earlier attempt — but the tiles are the expensive part, so the run re-queries Overpass in full. On a rate-limited public endpoint that is the difference between an instant render and a long throttled download. Stray surrounding whitespace splits the cache the same way.

The fix

Fold case and surrounding whitespace when building cache keys, via a single _cache_name() helper applied at the six sites where the region name feeds cache_key(). Nothing else changes — the name is still displayed and geocoded exactly as typed.

Verification

  • "Germany", "germany", "GERMANY", " Germany " → 1 distinct cache key (was 4).
  • Names differing by more than case stay distinct: Germany/France/North America/United States of America → 4 distinct keys.

Compatibility note

This changes existing key values. A cache written with a capitalized name is re-downloaded once; keys for names already typed in lower case are unchanged, since the normalized form equals the old raw form. Worth a mention in release notes if that matters for the gallery build.

The --country value is embedded verbatim in every cache key, so "Germany"
and "germany" hash differently and the second spelling re-downloads all of
the region's Overpass tiles despite the data already sitting in cache/.
The same applies to stray surrounding whitespace.
Fold case and whitespace when building cache keys so the spellings share a
single cached download. Region names that differ in more than case still
get distinct keys.
Note this changes existing key values: a cache written with a capitalized
name is re-downloaded once. Keys for names already typed in lower case are
unchanged.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
FBumann marked this pull request as ready for review August 15, 2026 21:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

1 participant

AltStyle によって変換されたページ (->オリジナル) /