summaryrefslogtreecommitdiff
path: root/ishtar_common/management/commands/dump_towns.py
diff options
context:
space:
mode:
Diffstat (limited to 'ishtar_common/management/commands/dump_towns.py')
-rw-r--r--ishtar_common/management/commands/dump_towns.py50
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: