mirror of
https://github.com/Dasemu/NavFrame.git
synced 2026-11-26 15:26:05 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
463c74efe2 | ||
|
|
989bcda281 | ||
|
|
6c33d8a6c7 |
No files matched your search
@@ -1,6 +1,7 @@
|
||||
name: Android build and checks
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
pull_request:
|
||||
permissions:
|
||||
contents: read
|
||||
@@ -17,7 +18,7 @@ jobs:
|
||||
with:
|
||||
distribution: temurin
|
||||
java-version: '17'
|
||||
- uses: android-actions/setup-android@v3
|
||||
- uses: android-actions/setup-android@v4
|
||||
- name: Install Android compile SDK
|
||||
run: sdkmanager "platforms;android-36" "build-tools;35.0.0"
|
||||
- uses: gradle/actions/setup-gradle@v4
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
name: Build worldwide offline regions
|
||||
on:
|
||||
push:
|
||||
tags: ['offline-bootstrap-andorra']
|
||||
tags: ['offline-bootstrap-andorra', 'offline-bootstrap-andorra-*', 'offline-global-2026-09-batch-*']
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
regions:
|
||||
@@ -23,9 +23,14 @@ jobs:
|
||||
- uses: actions/checkout@v4
|
||||
- id: matrix
|
||||
env:
|
||||
CAMPAIGN_TAG: ${{ github.ref_name }}
|
||||
REGION_IDS: ${{ github.event_name == 'push' && 'andorra' || inputs.regions }}
|
||||
run: |
|
||||
value=$(python3 tools/offline/global-regions.py matrix "$REGION_IDS")
|
||||
if [[ "$CAMPAIGN_TAG" == offline-global-2026-09-batch-* && "${{ github.event_name }}" == push ]]; then
|
||||
value=$(python3 tools/offline/campaign.py matrix "$CAMPAIGN_TAG")
|
||||
else
|
||||
value=$(python3 tools/offline/global-regions.py matrix "$REGION_IDS")
|
||||
fi
|
||||
echo "value=$value" >> "$GITHUB_OUTPUT"
|
||||
build:
|
||||
needs: plan
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
name: Refresh offline package catalog
|
||||
on:
|
||||
workflow_dispatch:
|
||||
permissions:
|
||||
contents: write
|
||||
jobs:
|
||||
catalog:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: write
|
||||
concurrency:
|
||||
group: offline-catalog-publication
|
||||
cancel-in-progress: false
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Rebuild index from all published regional releases
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
run: python3 tools/offline/publish-catalog.py
|
||||
+12
-4
@@ -6,7 +6,15 @@ The app installs individual `.navframe` packages containing a PMTiles map, a SQL
|
||||
|
||||
In `Dasemu/NavFrame`, open **Actions → Build worldwide offline regions → Run workflow**. Enter Geofabrik IDs such as `andorra,act,cantabria,us/california`. First run with **publish = false** to inspect artifacts; run with **publish = true** to publish packages. Each run builds at most 32 independent regions, with two concurrent builders and a 330-minute timeout per builder. No planet download or full-world local build is performed.
|
||||
|
||||
One-time bootstrap with SSH push access (no local GitHub CLI/token required): after pushing the project to the default branch, create and push the exact tag below. Only this tag triggers an automatic **Andorra** build with publication enabled; other tag or branch pushes do not trigger the offline builder. The catalog becomes available after that workflow succeeds.
|
||||
The frozen `tools/offline/campaign-global-2026-09.json` contains the global leaf-region campaign, split into 17 tag-triggered batches. It excludes parent extracts to avoid overlapping coverage and excludes packages already present when the manifest was created. Push the batch tags to queue all remaining eligible regions:
|
||||
|
||||
```sh
|
||||
for n in $(seq -w 1 17); do git push origin "offline-global-2026-09-batch-0$n"; done
|
||||
```
|
||||
|
||||
Each batch publishes successful packages independently; oversized or otherwise unsupported extracts fail as individual matrix jobs. GitHub's catalog concurrency allows one running and one pending refresh, so after all batches complete, run **Actions → Refresh offline package catalog → Run workflow** once to ensure the index includes every successful package.
|
||||
|
||||
One-time bootstrap with SSH push access (no local GitHub CLI/token required): after pushing the project to the default branch, create and push the exact tag below. Only this tag and `offline-bootstrap-andorra-*` retry tags trigger an automatic **Andorra** build with publication enabled; other tag or branch pushes do not trigger the offline builder. The catalog becomes available after that workflow succeeds. For a retry after fixing a failed run, push a new tag such as `offline-bootstrap-andorra-v2`; preserve existing tags.
|
||||
|
||||
```sh
|
||||
git tag offline-bootstrap-andorra
|
||||
@@ -29,19 +37,19 @@ curl --fail --location --output planetiler.jar https://github.com/onthegomap/pla
|
||||
python3 tools/offline/global-regions.py build --region andorra --version 20260930.1 --planetiler-jar planetiler.jar --output build/offline/andorra
|
||||
```
|
||||
|
||||
`build-region.py` also accepts existing PBF/.poly/PMTiles inputs for network-free builds. Planetiler and POI dependencies are pinned by version. Build provenance records the recipe, upstream PBF SHA-256, coverage SHA-256, Planetiler binary SHA-256 and PBF replication timestamp. Geofabrik's `latest` source URL rotates daily; the downloaded PBF is checked against its official MD5 sidecar, and its actual bytes are identified by SHA-256. A daily rotation during download fails rather than accepting a mismatch. OSM's replication timestamp identifies data freshness, while the package version identifies a publication.
|
||||
`build-region.py` also accepts existing PBF/.poly/PMTiles inputs for network-free builds. Planetiler and POI dependencies are pinned by version. Build provenance records the recipe, upstream PBF SHA-256, coverage SHA-256, Planetiler binary SHA-256 and PBF replication timestamp. Geofabrik's `latest` source URL rotates daily; the downloaded PBF is checked against its official MD5 sidecar, and its actual bytes are identified by SHA-256. If the latest link fails (including redirect loops) or its checksum mismatches during daily rotation, the builder reads the bounded official region HTML and selects its newest dated PBF with a matching-basename checksum link. It downloads and verifies that exact pair and records the actual dated extract URL in the manifest. An invalid checksum on the fallback fails the build. OSM's replication timestamp identifies data freshness, while the package version identifies a publication.
|
||||
|
||||
## Catalog and publication contract
|
||||
|
||||
Every package publishes a release `offline-gf-REGION-RUNID.ATTEMPT` with the package and `regional-catalog.json`. The workflow creates a draft, uploads assets, then publishes it; it never replaces package assets. Published region releases should be treated as immutable. Package manifests retain schema version 1 and stable IDs `gf-REGION` (slashes in upstream IDs become hyphens, e.g. `us/california` → `gf-us-california`).
|
||||
|
||||
The serialized catalog job reads **all** published region releases, merges their fragments and selects the latest publication per region. The merged index uses compact JSON and is checked against a 32 MiB / 4,096-entry Android discovery budget before publication.
|
||||
The catalog job reads **all** published region releases, merges their fragments and selects the latest publication per region. Concurrent campaign runs may coalesce pending catalog refreshes; use the manual refresh workflow after a large campaign completes. The merged index uses compact JSON and is checked against a 32 MiB / 4,096-entry Android discovery budget before publication.
|
||||
|
||||
The mutable discovery index is:
|
||||
|
||||
`https://github.com/Dasemu/NavFrame/releases/download/offline-catalog/regional-catalog.json`
|
||||
|
||||
This index release must remain mutable so its asset can be updated; do not enable repository-wide release immutability without moving the index to another host. The individual package URLs remain versioned. Historical package releases remain available. Catalog rebuilding is safe across concurrent region batches because the index job is serialized. A failed region does not prevent catalog rebuilding for successful releases.
|
||||
This index release must remain mutable so its asset can be updated; do not enable repository-wide release immutability without moving the index to another host. The individual package URLs remain versioned. Historical package releases remain available. Catalog rebuilding is serialized. A failed region does not prevent catalog rebuilding for successful releases.
|
||||
|
||||
Catalog format:
|
||||
|
||||
|
||||
@@ -0,0 +1,652 @@
|
||||
{
|
||||
"schemaVersion": 1,
|
||||
"campaign": "global-2026-09",
|
||||
"sourceSha256": "f4dd095bb0a3619ae643bcb05a0bdcbc5143660660b08a77589a7bbb6b5d6548",
|
||||
"catalogSha256": "0fa691b64842cb84ee303a70d9b550bb081e02a97d31ebda4d3168bf0bc2ad6c",
|
||||
"excludedParents": [
|
||||
"africa",
|
||||
"asia",
|
||||
"australia",
|
||||
"australia-oceania",
|
||||
"baden-wuerttemberg",
|
||||
"bayern",
|
||||
"brazil",
|
||||
"british-columbia",
|
||||
"canada",
|
||||
"central-america",
|
||||
"china",
|
||||
"czech-republic",
|
||||
"england",
|
||||
"europe",
|
||||
"france",
|
||||
"germany",
|
||||
"greater-london",
|
||||
"india",
|
||||
"indonesia",
|
||||
"italy",
|
||||
"japan",
|
||||
"netherlands",
|
||||
"nordrhein-westfalen",
|
||||
"north-america",
|
||||
"norway",
|
||||
"nunavut",
|
||||
"poland",
|
||||
"russia",
|
||||
"south-america",
|
||||
"spain",
|
||||
"united-kingdom",
|
||||
"us/california"
|
||||
],
|
||||
"excludedPublished": [
|
||||
"andorra"
|
||||
],
|
||||
"batches": [
|
||||
{
|
||||
"tag": "offline-global-2026-09-batch-001",
|
||||
"regions": [
|
||||
"act",
|
||||
"afghanistan",
|
||||
"albania",
|
||||
"alberta",
|
||||
"algeria",
|
||||
"alps",
|
||||
"alsace",
|
||||
"american-oceania",
|
||||
"andalucia",
|
||||
"angola",
|
||||
"anhui",
|
||||
"antarctica",
|
||||
"aquitaine",
|
||||
"aragon",
|
||||
"argentina",
|
||||
"armenia",
|
||||
"arnsberg-regbez",
|
||||
"ashmore-cartier",
|
||||
"asturias",
|
||||
"austria",
|
||||
"auvergne",
|
||||
"azerbaijan",
|
||||
"azores",
|
||||
"bahamas",
|
||||
"bangladesh",
|
||||
"basse-normandie",
|
||||
"bedfordshire",
|
||||
"beijing",
|
||||
"belarus",
|
||||
"belgium",
|
||||
"belize",
|
||||
"benin"
|
||||
]
|
||||
},
|
||||
{
|
||||
"tag": "offline-global-2026-09-batch-002",
|
||||
"regions": [
|
||||
"berkshire",
|
||||
"berlin",
|
||||
"bermuda",
|
||||
"bhutan",
|
||||
"bolivia",
|
||||
"bosnia-herzegovina",
|
||||
"botswana",
|
||||
"bourgogne",
|
||||
"brandenburg",
|
||||
"bremen",
|
||||
"bretagne",
|
||||
"bristol",
|
||||
"britain-and-ireland",
|
||||
"buckinghamshire",
|
||||
"bulgaria",
|
||||
"burkina-faso",
|
||||
"burundi",
|
||||
"cambodia",
|
||||
"cambridgeshire",
|
||||
"cameroon",
|
||||
"canary-islands",
|
||||
"cantabria",
|
||||
"cape-verde",
|
||||
"castilla-la-mancha",
|
||||
"castilla-y-leon",
|
||||
"cataluna",
|
||||
"central-african-republic",
|
||||
"central-fed-district",
|
||||
"central-zone",
|
||||
"centre",
|
||||
"centro",
|
||||
"centro-oeste"
|
||||
]
|
||||
},
|
||||
{
|
||||
"tag": "offline-global-2026-09-batch-003",
|
||||
"regions": [
|
||||
"ceuta",
|
||||
"chad",
|
||||
"champagne-ardenne",
|
||||
"cheshire",
|
||||
"chile",
|
||||
"chongqing",
|
||||
"christmas-island",
|
||||
"chubu",
|
||||
"chugoku",
|
||||
"cocos-islands",
|
||||
"colombia",
|
||||
"comores",
|
||||
"congo-brazzaville",
|
||||
"congo-democratic-republic",
|
||||
"cook-islands",
|
||||
"coral-sea-islands",
|
||||
"cornwall",
|
||||
"corse",
|
||||
"costa-rica",
|
||||
"crimean-fed-district",
|
||||
"croatia",
|
||||
"cuba",
|
||||
"cumbria",
|
||||
"cyprus",
|
||||
"dach",
|
||||
"denmark",
|
||||
"derbyshire",
|
||||
"detmold-regbez",
|
||||
"devon",
|
||||
"djibouti",
|
||||
"dolnoslaskie",
|
||||
"dorset"
|
||||
]
|
||||
},
|
||||
{
|
||||
"tag": "offline-global-2026-09-batch-004",
|
||||
"regions": [
|
||||
"drenthe",
|
||||
"duesseldorf-regbez",
|
||||
"durham",
|
||||
"east-sussex",
|
||||
"east-timor",
|
||||
"east-yorkshire-with-hull",
|
||||
"eastern-zone",
|
||||
"ecuador",
|
||||
"egypt",
|
||||
"el-salvador",
|
||||
"enfield",
|
||||
"equatorial-guinea",
|
||||
"eritrea",
|
||||
"essex",
|
||||
"estonia",
|
||||
"ethiopia",
|
||||
"extremadura",
|
||||
"falklands",
|
||||
"far-eastern-fed-district",
|
||||
"faroe-islands",
|
||||
"fiji",
|
||||
"finland",
|
||||
"flevoland",
|
||||
"franche-comte",
|
||||
"freiburg-regbez",
|
||||
"friesland",
|
||||
"fujian",
|
||||
"gabon",
|
||||
"galicia",
|
||||
"gansu",
|
||||
"gcc-states",
|
||||
"gelderland"
|
||||
]
|
||||
},
|
||||
{
|
||||
"tag": "offline-global-2026-09-batch-005",
|
||||
"regions": [
|
||||
"georgia",
|
||||
"ghana",
|
||||
"gloucestershire",
|
||||
"great-britain",
|
||||
"greater-manchester",
|
||||
"greece",
|
||||
"greenland",
|
||||
"groningen",
|
||||
"guadeloupe",
|
||||
"guangdong",
|
||||
"guangxi",
|
||||
"guatemala",
|
||||
"guernsey-jersey",
|
||||
"guinea",
|
||||
"guinea-bissau",
|
||||
"guizhou",
|
||||
"guyana",
|
||||
"guyane",
|
||||
"hainan",
|
||||
"haiti-and-domrep",
|
||||
"hamburg",
|
||||
"hampshire",
|
||||
"haute-normandie",
|
||||
"heard-mcdonald",
|
||||
"hebei",
|
||||
"heilongjiang",
|
||||
"henan",
|
||||
"herefordshire",
|
||||
"hertfordshire",
|
||||
"hessen",
|
||||
"hokkaido",
|
||||
"honduras"
|
||||
]
|
||||
},
|
||||
{
|
||||
"tag": "offline-global-2026-09-batch-006",
|
||||
"regions": [
|
||||
"hong-kong",
|
||||
"hubei",
|
||||
"hunan",
|
||||
"hungary",
|
||||
"iceland",
|
||||
"ile-de-clipperton",
|
||||
"ile-de-france",
|
||||
"inner-mongolia",
|
||||
"interior-admreg",
|
||||
"iran",
|
||||
"iraq",
|
||||
"ireland-and-northern-ireland",
|
||||
"island-admreg",
|
||||
"islas-baleares",
|
||||
"isle-of-man",
|
||||
"isle-of-wight",
|
||||
"isole",
|
||||
"israel-and-palestine",
|
||||
"ivory-coast",
|
||||
"jamaica",
|
||||
"java",
|
||||
"jiangsu",
|
||||
"jiangxi",
|
||||
"jihocesky",
|
||||
"jihomoravsky",
|
||||
"jilin",
|
||||
"jordan",
|
||||
"kalimantan",
|
||||
"kaliningrad",
|
||||
"kansai",
|
||||
"kanto",
|
||||
"karlovarsky"
|
||||
]
|
||||
},
|
||||
{
|
||||
"tag": "offline-global-2026-09-batch-007",
|
||||
"regions": [
|
||||
"karlsruhe-regbez",
|
||||
"kazakhstan",
|
||||
"kent",
|
||||
"kenya",
|
||||
"kiribati",
|
||||
"kitikmeot",
|
||||
"kivalliq",
|
||||
"koeln-regbez",
|
||||
"kootenay-admreg",
|
||||
"kosovo",
|
||||
"kralovehradecky",
|
||||
"kujawsko-pomorskie",
|
||||
"kyrgyzstan",
|
||||
"kyushu",
|
||||
"la-rioja",
|
||||
"lancashire",
|
||||
"languedoc-roussillon",
|
||||
"laos",
|
||||
"latvia",
|
||||
"lebanon",
|
||||
"leicestershire",
|
||||
"lesotho",
|
||||
"liaoning",
|
||||
"liberecky",
|
||||
"liberia",
|
||||
"libya",
|
||||
"liechtenstein",
|
||||
"limburg",
|
||||
"limousin",
|
||||
"lincolnshire",
|
||||
"lithuania",
|
||||
"lodzkie"
|
||||
]
|
||||
},
|
||||
{
|
||||
"tag": "offline-global-2026-09-batch-008",
|
||||
"regions": [
|
||||
"lorraine",
|
||||
"lubelskie",
|
||||
"lubuskie",
|
||||
"luxembourg",
|
||||
"macau",
|
||||
"macedonia",
|
||||
"madagascar",
|
||||
"madrid",
|
||||
"malawi",
|
||||
"malaysia-singapore-brunei",
|
||||
"maldives",
|
||||
"mali",
|
||||
"malopolskie",
|
||||
"malta",
|
||||
"maluku",
|
||||
"manitoba",
|
||||
"marshall-islands",
|
||||
"martinique",
|
||||
"mauritania",
|
||||
"mauritius",
|
||||
"mayotte",
|
||||
"mazowieckie",
|
||||
"mecklenburg-vorpommern",
|
||||
"melilla",
|
||||
"merseyside",
|
||||
"mexico",
|
||||
"micronesia",
|
||||
"midi-pyrenees",
|
||||
"mittelfranken",
|
||||
"moldova",
|
||||
"monaco",
|
||||
"mongolia"
|
||||
]
|
||||
},
|
||||
{
|
||||
"tag": "offline-global-2026-09-batch-009",
|
||||
"regions": [
|
||||
"montenegro",
|
||||
"moravskoslezky",
|
||||
"morocco",
|
||||
"mozambique",
|
||||
"muenster-regbez",
|
||||
"murcia",
|
||||
"myanmar",
|
||||
"namibia",
|
||||
"nauru",
|
||||
"navarra",
|
||||
"nepal",
|
||||
"new-brunswick",
|
||||
"new-caledonia",
|
||||
"new-south-wales",
|
||||
"new-zealand",
|
||||
"newfoundland-and-labrador",
|
||||
"nicaragua",
|
||||
"niederbayern",
|
||||
"niedersachsen",
|
||||
"niger",
|
||||
"nigeria",
|
||||
"ningxia",
|
||||
"niue",
|
||||
"noord-brabant",
|
||||
"noord-holland",
|
||||
"norcal",
|
||||
"nord-est",
|
||||
"nord-norge",
|
||||
"nord-ovest",
|
||||
"nord-pas-de-calais",
|
||||
"nordeste",
|
||||
"norfolk"
|
||||
]
|
||||
},
|
||||
{
|
||||
"tag": "offline-global-2026-09-batch-010",
|
||||
"regions": [
|
||||
"norfolk-island",
|
||||
"norte",
|
||||
"north-admreg",
|
||||
"north-caucasus-fed-district",
|
||||
"north-eastern-zone",
|
||||
"north-korea",
|
||||
"north-yorkshire",
|
||||
"northamptonshire",
|
||||
"northern-territory",
|
||||
"northern-zone",
|
||||
"northumberland",
|
||||
"northwest-territories",
|
||||
"northwestern-fed-district",
|
||||
"nottinghamshire",
|
||||
"nova-scotia",
|
||||
"nusa-tenggara",
|
||||
"oberbayern",
|
||||
"oberfranken",
|
||||
"oberpfalz",
|
||||
"okanagan-admreg",
|
||||
"olomoucky",
|
||||
"ontario",
|
||||
"opolskie",
|
||||
"ostlandet",
|
||||
"overijssel",
|
||||
"oxfordshire",
|
||||
"pais-vasco",
|
||||
"pakistan",
|
||||
"palau",
|
||||
"panama",
|
||||
"papua",
|
||||
"papua-new-guinea"
|
||||
]
|
||||
},
|
||||
{
|
||||
"tag": "offline-global-2026-09-batch-011",
|
||||
"regions": [
|
||||
"paraguay",
|
||||
"pardubicky",
|
||||
"pays-de-la-loire",
|
||||
"peru",
|
||||
"philippines",
|
||||
"picardie",
|
||||
"pitcairn-islands",
|
||||
"plzensky",
|
||||
"podkarpackie",
|
||||
"podlaskie",
|
||||
"poitou-charentes",
|
||||
"polynesie-francaise",
|
||||
"pomorskie",
|
||||
"portugal",
|
||||
"praha",
|
||||
"prince-edward-island",
|
||||
"provence-alpes-cote-d-azur",
|
||||
"qikiqtaaluk",
|
||||
"qinghai",
|
||||
"quebec",
|
||||
"queensland",
|
||||
"reunion",
|
||||
"rheinland-pfalz",
|
||||
"rhone-alpes",
|
||||
"romania",
|
||||
"rutland",
|
||||
"rwanda",
|
||||
"saarland",
|
||||
"sachsen",
|
||||
"sachsen-anhalt",
|
||||
"saint-helena-ascension-and-tristan-da-cunha",
|
||||
"samoa"
|
||||
]
|
||||
},
|
||||
{
|
||||
"tag": "offline-global-2026-09-batch-012",
|
||||
"regions": [
|
||||
"sao-tome-and-principe",
|
||||
"saskatchewan",
|
||||
"schleswig-holstein",
|
||||
"schwaben",
|
||||
"scotland",
|
||||
"sea",
|
||||
"senegal-and-gambia",
|
||||
"serbia",
|
||||
"seychelles",
|
||||
"shaanxi",
|
||||
"shandong",
|
||||
"shanghai",
|
||||
"shanxi",
|
||||
"shikoku",
|
||||
"shropshire",
|
||||
"siberian-fed-district",
|
||||
"sichuan",
|
||||
"sierra-leone",
|
||||
"slaskie",
|
||||
"slovakia",
|
||||
"slovenia",
|
||||
"socal",
|
||||
"solomon-islands",
|
||||
"somalia",
|
||||
"somerset",
|
||||
"sorlandet",
|
||||
"south-africa",
|
||||
"south-africa-and-lesotho",
|
||||
"south-australia",
|
||||
"south-fed-district",
|
||||
"south-korea",
|
||||
"south-sudan"
|
||||
]
|
||||
},
|
||||
{
|
||||
"tag": "offline-global-2026-09-batch-013",
|
||||
"regions": [
|
||||
"south-yorkshire",
|
||||
"southcoast-admreg",
|
||||
"southern-zone",
|
||||
"sri-lanka",
|
||||
"staffordshire",
|
||||
"stredocesky",
|
||||
"stuttgart-regbez",
|
||||
"sud",
|
||||
"sudan",
|
||||
"sudeste",
|
||||
"suffolk",
|
||||
"sul",
|
||||
"sulawesi",
|
||||
"sumatra",
|
||||
"suriname",
|
||||
"surrey",
|
||||
"svalbard-janmayen",
|
||||
"swaziland",
|
||||
"sweden",
|
||||
"swietokrzyskie",
|
||||
"switzerland",
|
||||
"syria",
|
||||
"taiwan",
|
||||
"tajikistan",
|
||||
"tanzania",
|
||||
"tasmania",
|
||||
"thailand",
|
||||
"thueringen",
|
||||
"tianjin",
|
||||
"tibet",
|
||||
"togo",
|
||||
"tohoku"
|
||||
]
|
||||
},
|
||||
{
|
||||
"tag": "offline-global-2026-09-batch-014",
|
||||
"regions": [
|
||||
"tokelau",
|
||||
"tonga",
|
||||
"trondelag",
|
||||
"tuebingen-regbez",
|
||||
"tunisia",
|
||||
"turkey",
|
||||
"turkmenistan",
|
||||
"tuvalu",
|
||||
"tyne-and-wear",
|
||||
"uganda",
|
||||
"ukraine",
|
||||
"unterfranken",
|
||||
"ural-fed-district",
|
||||
"uruguay",
|
||||
"us",
|
||||
"us-midwest",
|
||||
"us-northeast",
|
||||
"us-pacific",
|
||||
"us-south",
|
||||
"us-west",
|
||||
"us/alabama",
|
||||
"us/alaska",
|
||||
"us/arizona",
|
||||
"us/arkansas",
|
||||
"us/colorado",
|
||||
"us/connecticut",
|
||||
"us/delaware",
|
||||
"us/district-of-columbia",
|
||||
"us/florida",
|
||||
"us/georgia",
|
||||
"us/hawaii",
|
||||
"us/idaho"
|
||||
]
|
||||
},
|
||||
{
|
||||
"tag": "offline-global-2026-09-batch-015",
|
||||
"regions": [
|
||||
"us/illinois",
|
||||
"us/indiana",
|
||||
"us/iowa",
|
||||
"us/kansas",
|
||||
"us/kentucky",
|
||||
"us/louisiana",
|
||||
"us/maine",
|
||||
"us/maryland",
|
||||
"us/massachusetts",
|
||||
"us/michigan",
|
||||
"us/minnesota",
|
||||
"us/mississippi",
|
||||
"us/missouri",
|
||||
"us/montana",
|
||||
"us/nebraska",
|
||||
"us/nevada",
|
||||
"us/new-hampshire",
|
||||
"us/new-jersey",
|
||||
"us/new-mexico",
|
||||
"us/new-york",
|
||||
"us/north-carolina",
|
||||
"us/north-dakota",
|
||||
"us/ohio",
|
||||
"us/oklahoma",
|
||||
"us/oregon",
|
||||
"us/pennsylvania",
|
||||
"us/puerto-rico",
|
||||
"us/rhode-island",
|
||||
"us/south-carolina",
|
||||
"us/south-dakota",
|
||||
"us/tennessee",
|
||||
"us/texas"
|
||||
]
|
||||
},
|
||||
{
|
||||
"tag": "offline-global-2026-09-batch-016",
|
||||
"regions": [
|
||||
"us/us-virgin-islands",
|
||||
"us/utah",
|
||||
"us/vermont",
|
||||
"us/virginia",
|
||||
"us/washington",
|
||||
"us/west-virginia",
|
||||
"us/wisconsin",
|
||||
"us/wyoming",
|
||||
"ustecky",
|
||||
"utrecht",
|
||||
"uzbekistan",
|
||||
"valencia",
|
||||
"vanuatu",
|
||||
"venezuela",
|
||||
"vestlandet",
|
||||
"victoria",
|
||||
"vietnam",
|
||||
"volga-fed-district",
|
||||
"vysocina",
|
||||
"wales",
|
||||
"wallis-et-futuna",
|
||||
"warminsko-mazurskie",
|
||||
"warwickshire",
|
||||
"west-midlands",
|
||||
"west-sussex",
|
||||
"west-yorkshire",
|
||||
"western-australia",
|
||||
"western-zone",
|
||||
"wielkopolskie",
|
||||
"wiltshire",
|
||||
"worcestershire",
|
||||
"xinjiang"
|
||||
]
|
||||
},
|
||||
{
|
||||
"tag": "offline-global-2026-09-batch-017",
|
||||
"regions": [
|
||||
"yemen",
|
||||
"yukon",
|
||||
"yunnan",
|
||||
"zachodniopomorskie",
|
||||
"zambia",
|
||||
"zeeland",
|
||||
"zhejiang",
|
||||
"zimbabwe",
|
||||
"zlinsky",
|
||||
"zuid-holland"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Freeze global leaf batches and resolve campaign tags without network discovery."""
|
||||
import argparse
|
||||
import hashlib
|
||||
import json
|
||||
from pathlib import Path
|
||||
import re
|
||||
|
||||
PREFIX = 'offline-global-2026-09-batch-'
|
||||
DEFAULT = Path(__file__).with_name('campaign-global-2026-09.json')
|
||||
|
||||
|
||||
def create(sources, catalog, source_bytes, catalog_bytes):
|
||||
rows = sources['regions']
|
||||
ids = [row['id'] for row in rows]
|
||||
if len(ids) != len(set(ids)):
|
||||
raise ValueError('Duplicate source IDs')
|
||||
parents = {row['parent'] for row in rows if row.get('parent')}
|
||||
published = {entry.get('region') for entry in catalog['regions'] if entry.get('region')}
|
||||
published_packages = {entry['manifest']['id'] for entry in catalog['regions']}
|
||||
excluded = sorted(identifier for identifier in ids if identifier in published or 'gf-' + identifier.replace('/', '-') in published_packages)
|
||||
selected = sorted(set(ids) - parents - set(excluded))
|
||||
slugs = [identifier.replace('/', '-') for identifier in selected]
|
||||
if len(slugs) != len(set(slugs)):
|
||||
raise ValueError('Package slug collision')
|
||||
return {'schemaVersion': 1, 'campaign': 'global-2026-09',
|
||||
'sourceSha256': hashlib.sha256(source_bytes).hexdigest(),
|
||||
'catalogSha256': hashlib.sha256(catalog_bytes).hexdigest(),
|
||||
'excludedParents': sorted(set(ids) & parents), 'excludedPublished': excluded,
|
||||
'batches': [{'tag': PREFIX + f'{i // 32 + 1:03d}', 'regions': selected[i:i + 32]}
|
||||
for i in range(0, len(selected), 32)]}
|
||||
|
||||
|
||||
def select(campaign, tag):
|
||||
if campaign.get('schemaVersion') != 1 or campaign.get('campaign') != 'global-2026-09':
|
||||
raise ValueError('Unsupported campaign')
|
||||
all_ids, all_tags = [], []
|
||||
selected = None
|
||||
for batch in campaign['batches']:
|
||||
ids = batch['regions']
|
||||
if not 1 <= len(ids) <= 32 or any(not re.fullmatch(r'[a-z0-9]+(?:[-/][a-z0-9]+)*', item) for item in ids):
|
||||
raise ValueError('Invalid campaign batch')
|
||||
if not re.fullmatch(re.escape(PREFIX) + r'\d{3}', batch['tag']):
|
||||
raise ValueError('Invalid campaign tag')
|
||||
all_ids.extend(ids)
|
||||
all_tags.append(batch['tag'])
|
||||
if batch['tag'] == tag:
|
||||
selected = ids
|
||||
if len(all_ids) != len(set(all_ids)) or len(all_tags) != len(set(all_tags)):
|
||||
raise ValueError('Duplicate campaign region or tag')
|
||||
if set(all_ids) & (set(campaign['excludedParents']) | set(campaign['excludedPublished'])):
|
||||
raise ValueError('Campaign includes excluded region')
|
||||
if selected is None:
|
||||
raise ValueError('Tag is not present in frozen campaign')
|
||||
return {'region': selected}
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
sub = parser.add_subparsers(dest='command', required=True)
|
||||
build = sub.add_parser('create')
|
||||
build.add_argument('--sources', type=Path, default=Path(__file__).with_name('worldwide-sources.json'))
|
||||
build.add_argument('--catalog', type=Path, required=True)
|
||||
build.add_argument('--output', type=Path, default=DEFAULT)
|
||||
matrix = sub.add_parser('matrix')
|
||||
matrix.add_argument('tag')
|
||||
matrix.add_argument('--campaign', type=Path, default=DEFAULT)
|
||||
args = parser.parse_args()
|
||||
if args.command == 'create':
|
||||
source_bytes, catalog_bytes = args.sources.read_bytes(), args.catalog.read_bytes()
|
||||
result = create(json.loads(source_bytes), json.loads(catalog_bytes), source_bytes, catalog_bytes)
|
||||
args.output.write_text(json.dumps(result, indent=2) + '\n')
|
||||
else:
|
||||
print(json.dumps(select(json.loads(args.campaign.read_text()), args.tag)))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
@@ -2,6 +2,8 @@
|
||||
"""Discover/build bounded Geofabrik regions and merge immutable catalog fragments."""
|
||||
import argparse
|
||||
import hashlib
|
||||
from datetime import date
|
||||
from html.parser import HTMLParser
|
||||
import json
|
||||
import os
|
||||
from pathlib import Path
|
||||
@@ -10,6 +12,8 @@ import sqlite3
|
||||
import subprocess
|
||||
import sys
|
||||
from urllib.request import urlopen
|
||||
from urllib.error import HTTPError, URLError
|
||||
from urllib.parse import urljoin
|
||||
|
||||
INDEX = 'https://download.geofabrik.de/index-v1-nogeom.json'
|
||||
ROOT = Path(__file__).resolve().parents[2]
|
||||
@@ -22,10 +26,12 @@ def official_url(url):
|
||||
|
||||
|
||||
def download(url, path, maximum):
|
||||
official_url(url)
|
||||
path.parent.mkdir(parents=True, exist_ok=True)
|
||||
staging = path.with_suffix(path.suffix + '.part')
|
||||
try:
|
||||
with urlopen(url, timeout=120) as source, staging.open('wb') as target:
|
||||
official_url(source.geturl())
|
||||
if int(source.headers.get('Content-Length', 0)) > maximum:
|
||||
raise ValueError('Extract exceeds input budget; select a smaller region or larger runner')
|
||||
total = 0
|
||||
@@ -39,6 +45,78 @@ def download(url, path, maximum):
|
||||
staging.unlink(missing_ok=True)
|
||||
|
||||
|
||||
class ExtractChecksumError(ValueError):
|
||||
"""Upstream bytes and their paired checksum do not agree."""
|
||||
|
||||
|
||||
def verify_extract(pbf, checksum):
|
||||
fields = checksum.read_text().split()
|
||||
expected = fields[0] if fields else ''
|
||||
digest = hashlib.md5()
|
||||
with pbf.open('rb') as stream:
|
||||
while block := stream.read(1024 * 1024):
|
||||
digest.update(block)
|
||||
if not re.fullmatch(r'[a-fA-F0-9]{32}', expected) or digest.hexdigest() != expected.lower():
|
||||
raise ExtractChecksumError('Geofabrik PBF checksum mismatch')
|
||||
|
||||
|
||||
def dated_extract(latest, html):
|
||||
"""Choose newest valid dated PBF/checksum pair linked on this region's page."""
|
||||
official_url(latest)
|
||||
if not latest.endswith('-latest.osm.pbf'):
|
||||
raise ValueError('Expected latest extract URL')
|
||||
if len(html.encode('utf-8')) > 2 * 1024 * 1024:
|
||||
raise ValueError('Region HTML exceeds discovery budget')
|
||||
stem = latest.removesuffix('-latest.osm.pbf')
|
||||
page = stem + '.html'
|
||||
links = set()
|
||||
|
||||
class Links(HTMLParser):
|
||||
def handle_starttag(self, tag, attributes):
|
||||
if tag.lower() != 'a':
|
||||
return
|
||||
for key, value in attributes:
|
||||
if key.lower() == 'href' and value and '..' not in value:
|
||||
links.add(urljoin(page, value))
|
||||
|
||||
parser = Links()
|
||||
parser.feed(html)
|
||||
candidates = []
|
||||
pattern = re.compile(re.escape(stem) + r'-(\d{6})\.osm\.pbf')
|
||||
for link in links:
|
||||
match = pattern.fullmatch(link)
|
||||
if match is None or link + '.md5' not in links:
|
||||
continue
|
||||
stamp = match[1]
|
||||
try:
|
||||
when = date(2000 + int(stamp[:2]), int(stamp[2:4]), int(stamp[4:6]))
|
||||
except ValueError:
|
||||
continue
|
||||
candidates.append((when, official_url(link)))
|
||||
if not candidates:
|
||||
raise ValueError('Official region page has no dated PBF/checksum pair')
|
||||
return max(candidates)[1]
|
||||
|
||||
|
||||
def download_extract(latest, pbf, checksum, maximum):
|
||||
try:
|
||||
download(latest, pbf, maximum)
|
||||
download(latest + '.md5', checksum, 4096)
|
||||
verify_extract(pbf, checksum)
|
||||
return latest
|
||||
except (URLError, TimeoutError, ExtractChecksumError) as error:
|
||||
print(f'Latest extract unavailable ({error}); resolving official dated extract', file=sys.stderr)
|
||||
if isinstance(error, HTTPError):
|
||||
error.close()
|
||||
page = pbf.parent / 'region-source.html'
|
||||
download(latest.removesuffix('-latest.osm.pbf') + '.html', page, 2 * 1024 * 1024)
|
||||
source = dated_extract(latest, page.read_text(encoding='utf-8'))
|
||||
download(source, pbf, maximum)
|
||||
download(source + '.md5', checksum, 4096)
|
||||
verify_extract(pbf, checksum)
|
||||
return source
|
||||
|
||||
|
||||
def regions(index):
|
||||
properties = {f['properties']['id']: f['properties'] for f in index['features']}
|
||||
result = []
|
||||
@@ -97,16 +175,8 @@ def build(args, selected):
|
||||
work = args.output / 'work'
|
||||
work.mkdir(parents=True, exist_ok=True)
|
||||
pbf, poly = work / 'region.osm.pbf', work / 'region.poly'
|
||||
download(selected['source'], pbf, args.max_input_mib * 1024 * 1024)
|
||||
checksum = work / 'region.osm.pbf.md5'
|
||||
download(selected['source'] + '.md5', checksum, 4096)
|
||||
expected = checksum.read_text().split()[0]
|
||||
digest = hashlib.md5()
|
||||
with pbf.open('rb') as stream:
|
||||
while block := stream.read(1024 * 1024):
|
||||
digest.update(block)
|
||||
if not re.fullmatch(r'[a-fA-F0-9]{32}', expected) or digest.hexdigest() != expected.lower():
|
||||
raise ValueError('Geofabrik PBF checksum mismatch (possibly daily rotation); rerun')
|
||||
source_url = download_extract(selected['source'], pbf, checksum, args.max_input_mib * 1024 * 1024)
|
||||
download(selected['coverage'], poly, 16 * 1024 * 1024)
|
||||
slug = selected['id'].replace('/', '-')
|
||||
archive = args.output / f"gf-{slug}-{args.version}.navframe"
|
||||
@@ -114,7 +184,8 @@ def build(args, selected):
|
||||
'--id', f"gf-{slug}", '--name', selected['name'], '--version', args.version,
|
||||
'--pbf', str(pbf), '--coverage-poly', str(poly), '--coverage-url', selected['coverage'],
|
||||
'--planetiler-jar', str(args.planetiler_jar), '--java-heap', args.java_heap,
|
||||
'--source-url', selected['source'], '--output', str(archive), '--work', str(work)], check=True)
|
||||
'--python', sys.executable,
|
||||
'--source-url', source_url, '--output', str(archive), '--work', str(work)], check=True)
|
||||
if archive.stat().st_size >= args.max_package_mib * 1024 * 1024:
|
||||
raise ValueError('Package exceeds publication budget; select a smaller region')
|
||||
catalog_path = args.output / 'regional-catalog.json'
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
import importlib.util
|
||||
import json
|
||||
from pathlib import Path
|
||||
import unittest
|
||||
|
||||
spec = importlib.util.spec_from_file_location('campaign', Path(__file__).with_name('campaign.py'))
|
||||
campaign = importlib.util.module_from_spec(spec)
|
||||
spec.loader.exec_module(campaign)
|
||||
|
||||
|
||||
class CampaignTest(unittest.TestCase):
|
||||
def test_reproducible_leaf_selection_and_published_exclusion(self):
|
||||
rows = [{'id': 'parent', 'parent': None}, {'id': 'child', 'parent': 'parent'},
|
||||
{'id': 'published', 'parent': None}] + [{'id': f'r{i:03}', 'parent': None} for i in range(33)]
|
||||
catalog = {'regions': [{'manifest': {'id': 'gf-published'}}]}
|
||||
result = campaign.create({'regions': rows}, catalog, b'sources', b'catalog')
|
||||
self.assertEqual(result, campaign.create({'regions': list(reversed(rows))}, catalog, b'sources', b'catalog'))
|
||||
self.assertEqual(result['excludedParents'], ['parent'])
|
||||
self.assertEqual(result['excludedPublished'], ['published'])
|
||||
self.assertEqual([len(batch['regions']) for batch in result['batches']], [32, 2])
|
||||
self.assertEqual(campaign.select(result, campaign.PREFIX + '002')['region'], ['r031', 'r032'])
|
||||
with self.assertRaises(ValueError):
|
||||
campaign.select(result, campaign.PREFIX + '003')
|
||||
result['batches'][1]['regions'].append('child')
|
||||
with self.assertRaises(ValueError):
|
||||
campaign.select(result, campaign.PREFIX + '001')
|
||||
|
||||
def test_frozen_manifest_is_bounded_disjoint_and_matches_sources(self):
|
||||
root = Path(__file__).parent
|
||||
frozen = json.loads((root / 'campaign-global-2026-09.json').read_text())
|
||||
sources = json.loads((root / 'worldwide-sources.json').read_text())
|
||||
parents = {row['parent'] for row in sources['regions']}
|
||||
expected = {row['id'] for row in sources['regions']} - parents - set(frozen['excludedPublished'])
|
||||
actual = []
|
||||
for batch in frozen['batches']:
|
||||
actual.extend(campaign.select(frozen, batch['tag'])['region'])
|
||||
self.assertEqual(set(actual), expected)
|
||||
self.assertEqual(len(actual), len(expected))
|
||||
import hashlib
|
||||
self.assertEqual(frozen['sourceSha256'], hashlib.sha256((root / 'worldwide-sources.json').read_bytes()).hexdigest())
|
||||
@@ -1,5 +1,8 @@
|
||||
import importlib.util
|
||||
import json
|
||||
import hashlib
|
||||
from unittest.mock import patch
|
||||
from urllib.error import HTTPError
|
||||
from pathlib import Path
|
||||
import tempfile
|
||||
import unittest
|
||||
@@ -52,3 +55,57 @@ class GlobalPipelineTest(unittest.TestCase):
|
||||
second.write_text(json.dumps({'schemaVersion': 1, 'regions': [entry]}))
|
||||
with self.assertRaises(ValueError):
|
||||
global_regions.merge([first, second])
|
||||
|
||||
|
||||
class DatedExtractTest(unittest.TestCase):
|
||||
latest = 'https://download.geofabrik.de/europe/andorra-latest.osm.pbf'
|
||||
dated = 'https://download.geofabrik.de/europe/andorra-260929.osm.pbf'
|
||||
html = '<a href="andorra-260929.osm.pbf">PBF</a><a href="andorra-260929.osm.pbf.md5">MD5</a>'
|
||||
|
||||
def test_selects_newest_valid_matching_pair(self):
|
||||
html = self.html + '<a href="andorra-260928.osm.pbf">old</a><a href="andorra-260928.osm.pbf.md5">old md5</a>'
|
||||
html += '<a href="andorra-261332.osm.pbf">invalid</a><a href="andorra-261332.osm.pbf.md5">md5</a>'
|
||||
html += '<a href="andorra-261001.osm.pbf">no checksum</a>'
|
||||
html += '<a href="https://evil.example/andorra-261002.osm.pbf">evil</a><a href="https://evil.example/andorra-261002.osm.pbf.md5">evil md5</a>'
|
||||
html += '<a href="france-261002.osm.pbf">other region</a><a href="france-261002.osm.pbf.md5">other md5</a>'
|
||||
self.assertEqual(global_regions.dated_extract(self.latest, html), self.dated)
|
||||
with self.assertRaises(ValueError):
|
||||
global_regions.dated_extract(self.latest, '<a href="andorra-261001.osm.pbf">no checksum</a>')
|
||||
with self.assertRaises(ValueError):
|
||||
global_regions.dated_extract(self.latest, 'x' * (2 * 1024 * 1024 + 1))
|
||||
|
||||
def test_redirect_loop_fallback_downloads_exact_pair(self):
|
||||
requested = []
|
||||
content = b'OSM test bytes'
|
||||
def fake_download(url, path, maximum):
|
||||
requested.append(url)
|
||||
if url == self.latest:
|
||||
raise HTTPError(url, 301, 'redirect loop', {}, None)
|
||||
if url.endswith('.html'):
|
||||
path.write_text(self.html)
|
||||
elif url == self.dated:
|
||||
path.write_bytes(content)
|
||||
elif url == self.dated + '.md5':
|
||||
path.write_text(hashlib.md5(content).hexdigest() + ' andorra-260929.osm.pbf')
|
||||
else:
|
||||
self.fail('Unexpected download URL: ' + url)
|
||||
with tempfile.TemporaryDirectory() as temporary, patch.object(global_regions, 'download', side_effect=fake_download):
|
||||
root = Path(temporary)
|
||||
actual = global_regions.download_extract(self.latest, root / 'region.osm.pbf', root / 'checksum.md5', 4096)
|
||||
self.assertEqual(actual, self.dated)
|
||||
self.assertEqual(requested[-2:], [self.dated, self.dated + '.md5'])
|
||||
|
||||
def test_size_budget_error_does_not_fallback(self):
|
||||
with patch.object(global_regions, 'download', side_effect=ValueError('input budget')) as downloader:
|
||||
with self.assertRaises(ValueError):
|
||||
global_regions.download_extract(self.latest, Path('unused'), Path('unused.md5'), 1)
|
||||
self.assertEqual(downloader.call_count, 1)
|
||||
|
||||
def test_wrong_dated_checksum_fails(self):
|
||||
with tempfile.TemporaryDirectory() as temporary:
|
||||
root = Path(temporary)
|
||||
pbf, checksum = root / 'region.osm.pbf', root / 'checksum.md5'
|
||||
pbf.write_bytes(b'test')
|
||||
checksum.write_text('0' * 32)
|
||||
with self.assertRaises(global_regions.ExtractChecksumError):
|
||||
global_regions.verify_extract(pbf, checksum)
|
||||
Reference in new issue
Block a user