diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2025-05-27 16:30:21 +0200 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2025-05-27 16:30:21 +0200 |
commit | c2d836b31da08412b12e67fc440b95a110a7aa55 (patch) | |
tree | 0b9f5444493a4e6fcbe8b0eaa173dccf680bc120 /ishtar_common/management/commands/dump_towns.py | |
parent | 131973f319d9ec11ac1509d7921e0d6c39d10305 (diff) | |
download | Ishtar-c2d836b31da08412b12e67fc440b95a110a7aa55.tar.bz2 Ishtar-c2d836b31da08412b12e67fc440b95a110a7aa55.zip |
🐛 admin town: fix geojson import/export - ♻️ management command: dump/load towns refactoring
Diffstat (limited to 'ishtar_common/management/commands/dump_towns.py')
-rw-r--r-- | ishtar_common/management/commands/dump_towns.py | 50 |
1 files changed, 3 insertions, 47 deletions
diff --git a/ishtar_common/management/commands/dump_towns.py b/ishtar_common/management/commands/dump_towns.py index 31465aa13..aa5270aef 100644 --- a/ishtar_common/management/commands/dump_towns.py +++ b/ishtar_common/management/commands/dump_towns.py @@ -44,7 +44,8 @@ class Command(BaseCommand): def handle(self, *args, **options): quiet = options['quiet'] query = options["query"] - q = Town.objects.filter(main_geodata__isnull=False, main_geodata__multi_polygon__isnull=False) + q = Town.objects.filter(main_geodata__isnull=False, + main_geodata__multi_polygon__isnull=False) if query: try: query = json.loads(query) @@ -61,52 +62,7 @@ class Command(BaseCommand): get_progress("processing town", idx, nb_lines, started) ) sys.stdout.flush() - geo = town.main_geodata - town_dct = { - "model": "ishtar_common.town", - "fields": { - "name": town.name, - "surface": town.surface, - "numero_insee": town.numero_insee, - "notice": town.notice, - "year": town.year, - "cached_label": town.cached_label, - "main_geodata": [ - "ishtar_common", - "town", - town.numero_insee - ], - "geodata": [ - ["ishtar_common", "town", town.numero_insee] - ], - "children": [ - t.numero_insee - for t in town.children.filter(numero_insee__isnull=False).all() - ] - } - } - geo_dct = { - "model": "ishtar_common.geovectordata", - "fields": { - "name": geo.name, - "source_content_type": [ - "ishtar_common", - "town" - ], - "source": town.numero_insee, - "data_type": [ - "town-limit" - ], - "provider": geo.provider.txt_idx, - "comment": geo.comment, - "cached_x": geo.cached_x, - "cached_y": geo.cached_y, - "spatial_reference_system": None, - "multi_polygon": geo.multi_polygon.wkt - } - } - result.append(geo_dct) - result.append(town_dct) + result += town.geodata_export today = datetime.date.today() result_file = f"ishtar-towns-{today.strftime('%Y-%m-%d')}.json" with open(result_file, "w") as r: |