From 4c07c0feb2eff31f1bf5f49e1eb700fc78742743 Mon Sep 17 00:00:00 2001 From: moanos Date: Thu, 22 May 2025 22:01:58 +0200 Subject: [PATCH] feat: Add location as object when uploading shelters --- scripts/upload_animal_shelters.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/scripts/upload_animal_shelters.py b/scripts/upload_animal_shelters.py index 26414a3..c928a9e 100644 --- a/scripts/upload_animal_shelters.py +++ b/scripts/upload_animal_shelters.py @@ -82,8 +82,22 @@ def main(): if "name" not in tierheim["properties"].keys() or "addr:city" not in tierheim["properties"].keys(): continue + locationdata = { + "place_id": tierheim["id"], + "latitude": tierheim["geometry"]["coordinates"][0][0][0], + "longitude": tierheim["geometry"]["coordinates"][0][0][1], + "name": tierheim["properties"]["name"], + "city": tierheim["properties"]["addr:city"], + "housenumber": get_or_none(tierheim, "addr:housenumber"), + "postcode": get_or_none(tierheim, "addr:postcode"), + "street": get_or_none(tierheim, "addr:street"), + "countrycode": get_or_none(tierheim, "addr:country"), + } + + locationresult = requests.post(f"{instance}/api/locations/", json=locationdata, headers=h) + data = {"name": tierheim["properties"]["name"], - "location_string": f"{get_or_none(tierheim, "addr:street")} {get_or_none(tierheim, "addr:housenumber")}, {get_or_none(tierheim, "addr:postcode")} {tierheim["properties"]["addr:city"]}", + "location": json.loads(locationresult.content)["id"], "phone_number": choose(("contact:phone", "phone"), tierheim["properties"], replace=True), "fediverse_profile": get_or_none(tierheim, "contact:mastodon"), "facebook": https(add(get_or_none(tierheim, "contact:facebook"), "facebook")),