diff --git a/view_data_across_atp_datasets.py b/view_data_across_atp_datasets.py index 329b364..ccc558b 100644 --- a/view_data_across_atp_datasets.py +++ b/view_data_across_atp_datasets.py @@ -1,7 +1,57 @@ import rich import osm_bot_abstraction_layer.util_download_file import os +import json + config = __import__("0_config") +obtain_atp_data = __import__("2_obtain_atp_data") + +def download(): + for entry in obtain_atp_data.get_atp_history()[::-1]: + run_id = entry['run_id'] + print(run_id) + obtain_atp_data.download_specific_atp_run(run_id) + + + +def relevant_one(feature): + if feature['properties']['ref'] == "Z2220": + return True + if feature["id"] == "y0P1sd7RSJB-6RBe-vTNFRUDZEg=": + return True + if "addr:street_address" in feature['properties']: + if "kalinowe" in feature['properties']["addr:street_address"].lower(): + if feature['properties'].get('addr:city') != "Rokietnica": + return True + return False + +def view(): + # for zabka see + # https://github.com/alltheplaces/alltheplaces/issues/5888 https://github.com/alltheplaces/alltheplaces/pull/5586 + for entry in obtain_atp_data.get_atp_history()[::-1]: + run_id = entry['run_id'] + print() + print(run_id) + folder = obtain_atp_data.atp_unpacked_folder(run_id) + source_atp_filepath = folder + "zabka_pl.geojson" + with open(source_atp_filepath) as file: + try: + data = json.load(file) + rich.print("spider:collection_time", data['dataset_attributes'].get("spider:collection_time")) + for feature in data['features']: + if relevant_one(feature): + #rich.print(feature['properties']['addr:city']) + rich.print(feature['properties']['opening_hours']) + #rich.print(feature) + print() + except json.decoder.JSONDecodeError as e: + print(e) + +# {"type": "Feature", "id": "y0P1sd7RSJB-6RBe-vTNFRUDZEg=", "properties": {"ref": "Z2220", "@source_uri": "https://www.zabka.pl/app/uploads/locator-store-data.json", "@spider": "zabka_pl", "name:pl": "\u017babka", "name:uk": "\u0416\u0430\u0431\u043a\u0430", "shop": "convenience", "addr:street_address": "ul. Miko\u0142ajczyka/os. Kalinowe 12c", "addr:city": "Krak\u00f3w", "addr:country": "PL", "name": "\u017babka", "website": "https://www.zabka.pl/znajdz-sklep/ID02220-krakow-ul-mikolajczyka-os-kalinowe-12c/", "opening_hours": "Mo-Sa 06:00-23:00", "brand": "\u017babka", "brand:wikidata": "Q2589061", "nsi_id": "zabka-f55ead"}, "geometry": {"type": "Point", "coordinates": [20.014811, 50.092896]}}, + +download() +view() + # https://data.alltheplaces.xyz/runs/history.json # https://alltheplaces-data.openaddresses.io/runs/2025-01-11-13-32-30/output/zabka_pl.geojson