Skip to content

Commit da7235b

Browse files
Merge pull request #2632 from IFRCGo/feature/fix-tiling-staging-strings
Fix maptiling strings
2 parents 51d1aff + 81e9218 commit da7235b

84 files changed

Lines changed: 907 additions & 22 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,6 @@ Run ` python manage.py update-sovereign-and-disputed new_fields.csv` to update t
273273
To update GO countries and districts Mapbox tilesets, run the management command `python manage.py update-mapbox-tilesets`. This will export all country and district geometries to a GeoJSON file, and then upload them to Mapbox. The tilesets will take a while to process. The updated status can be viewed on the Mapbox Studio under tilesets. To run this management command, MAPBOX_ACCESS_TOKEN should be set in the environment. The referred files are in ./mapbox/..., so you should **not** run this command from an arbitrary point of the vm's filesystem (e.g. from the location of shapefiles), but from Django root.
274274

275275
### Options available for the command
276-
* `--production` — update production tilesets. If this flag is not set, by default the script will only update staging tiles
277276
* `--update-countries` — update tileset for countries, including labels
278277
* `--update-districts` — update tileset for districts, including labels
279278
* `--update-all` — update all countries and districts tilesets

api/management/commands/update-mapbox-tilesets.py

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ def add_arguments(self, parser):
1717
parser.add_argument("--create-and-update-admin2", help="Create and update admin2 tileset for this country ISO")
1818
parser.add_argument("--update-admin2", help="Update admin2 tileset for this country ISO")
1919
parser.add_argument("--update-all", action="store_true", help="Update tileset for countries and districts")
20-
parser.add_argument("--production", action="store_true", help="Update production tilesets. Default is staging")
2120

2221
db = settings.DATABASES["default"]
2322
DB_HOST = db["HOST"]
@@ -32,9 +31,7 @@ def handle(self, *args, **options):
3231
if os.getenv("MAPBOX_ACCESS_TOKEN") is None:
3332
raise Exception("MAPBOX_ACCESS_TOKEN must be set")
3433

35-
staging = True
36-
if options["production"]:
37-
staging = False
34+
staging = settings.GO_ENVIRONMENT != "production"
3835

3936
if options["update_countries"] or options["update_all"]:
4037
self.update_countries(staging)
@@ -131,7 +128,7 @@ def update_countries(self, staging):
131128
"upload-source",
132129
"--replace",
133130
"go-ifrc",
134-
"go-country-centroids",
131+
tileset_source_name,
135132
"/tmp/country-centroids.geojson",
136133
]
137134
)
@@ -245,13 +242,14 @@ def create_and_update_admin2(self, iso, staging=True):
245242
if status:
246243
update_status = self.update_admin2(iso, staging)
247244
if update_status:
248-
polygon_tileset_name = f"go-ifrc.go-admin2-{iso}-staging"
249-
polygon_recipe_name = f"mapbox/admin2/{iso}-staging.json"
250-
centroids_tileset_name = f"go-ifrc.go-admin2-{iso}-centroids"
251-
centroids_recipe_name = f"mapbox/admin2/{iso}-centroids.json"
252-
if not staging:
253-
polygon_tileset_name = f"go-ifrc.go-admin2-{iso}"
254-
polygon_recipe_name = f"mapbox/admin2/{iso}.json"
245+
polygon_tileset_name = f"go-ifrc.go-admin2-{iso}-staging" if staging else f"go-ifrc.go-admin2-{iso}"
246+
polygon_recipe_name = f"mapbox/admin2/{iso}-staging.json" if staging else f"mapbox/admin2/{iso}.json"
247+
centroids_tileset_name = (
248+
f"go-ifrc.go-admin2-{iso}-centroids-staging" if staging else f"go-ifrc.go-admin2-{iso}-centroids"
249+
)
250+
centroids_recipe_name = (
251+
f"mapbox/admin2/{iso}-centroids-staging.json" if staging else f"mapbox/admin2/{iso}-centroids.json"
252+
)
255253

256254
create_status = subprocess.run(
257255
[
@@ -285,10 +283,8 @@ def create_and_update_admin2(self, iso, staging=True):
285283
def update_admin2(self, iso, staging=True):
286284
# update tileset source
287285
# update tileset and publish
288-
polygon_tileset_source__name = f"go-admin2-{iso}-src-staging"
289-
centroids_tileset_source_name = f"go-admin2-{iso}-centroids-src"
290-
if not staging:
291-
polygon_tileset_source__name = f"go-admin2-{iso}-src"
286+
polygon_tileset_source__name = f"go-admin2-{iso}-src-staging" if staging else f"go-admin2-{iso}-src"
287+
centroids_tileset_source_name = f"go-admin2-{iso}-centroids-src-staging" if staging else f"go-admin2-{iso}-centroids-src"
292288

293289
print("Tileset source", polygon_tileset_source__name)
294290
print("Tileset source centroids", centroids_tileset_source_name)
@@ -319,10 +315,10 @@ def publish_admin2(self, iso, staging=True, create=False):
319315
update_status = True
320316

321317
if update_status:
322-
polygon_tileset_name = f"go-ifrc.go-admin2-{iso}-staging"
323-
centroids_tileset_name = f"go-ifrc.go-admin2-{iso}-centroids"
324-
if not staging:
325-
polygon_tileset_name = f"go-ifrc.go-admin2-{iso}"
318+
polygon_tileset_name = f"go-ifrc.go-admin2-{iso}-staging" if staging else f"go-ifrc.go-admin2-{iso}"
319+
centroids_tileset_name = (
320+
f"go-ifrc.go-admin2-{iso}-centroids-staging" if staging else f"go-ifrc.go-admin2-{iso}-centroids"
321+
)
326322

327323
publish_status = subprocess.run(["tilesets", "publish", polygon_tileset_name])
328324
publish_status = subprocess.run(["tilesets", "publish", centroids_tileset_name])

assets

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"version": 1,
3+
"layers": {
4+
"go-admin2-AFG-centroids-staging": {
5+
"source": "mapbox://tileset-source/go-ifrc/go-admin2-AFG-centroids-src-staging",
6+
"minzoom": 5,
7+
"maxzoom": 10
8+
}
9+
}
10+
}
11+
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"version": 1,
3+
"layers": {
4+
"go-admin2-ARG-centroids-staging": {
5+
"source": "mapbox://tileset-source/go-ifrc/go-admin2-ARG-centroids-src-staging",
6+
"minzoom": 5,
7+
"maxzoom": 10
8+
}
9+
}
10+
}
11+
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"version": 1,
3+
"layers": {
4+
"go-admin2-BDI-centroids-staging": {
5+
"source": "mapbox://tileset-source/go-ifrc/go-admin2-BDI-centroids-src-staging",
6+
"minzoom": 5,
7+
"maxzoom": 10
8+
}
9+
}
10+
}
11+
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"version": 1,
3+
"layers": {
4+
"go-admin2-BEN-centroids-staging": {
5+
"source": "mapbox://tileset-source/go-ifrc/go-admin2-BEN-centroids-src-staging",
6+
"minzoom": 5,
7+
"maxzoom": 10
8+
}
9+
}
10+
}
11+
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"version": 1,
3+
"layers": {
4+
"go-admin2-BFA-centroids-staging": {
5+
"source": "mapbox://tileset-source/go-ifrc/go-admin2-BFA-centroids-src-staging",
6+
"minzoom": 5,
7+
"maxzoom": 10
8+
}
9+
}
10+
}
11+
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"version": 1,
3+
"layers": {
4+
"go-admin2-BGD-centroids-staging": {
5+
"source": "mapbox://tileset-source/go-ifrc/go-admin2-BGD-centroids-src-staging",
6+
"minzoom": 5,
7+
"maxzoom": 10
8+
}
9+
}
10+
}
11+
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"version": 1,
3+
"layers": {
4+
"go-admin2-BGR-centroids-staging": {
5+
"source": "mapbox://tileset-source/go-ifrc/go-admin2-BGR-centroids-src-staging",
6+
"minzoom": 5,
7+
"maxzoom": 10
8+
}
9+
}
10+
}
11+

0 commit comments

Comments
 (0)