diff options
| author | Yasutake Yohei <61961825+yasutakeyohei@users.noreply.github.com> | 2026-10-25 21:29:16 +0900 |
|---|---|---|
| committer | Yasutake Yohei <61961825+yasutakeyohei@users.noreply.github.com> | 2026-10-25 21:29:16 +0900 |
| commit | fa73b6a9f36268986af68192f65978539f4d059c (patch) | |
| tree | 6a4f27d54823d35da29f68ef37b93bba37f71cf2 /scripts/update-nearby-facilities.py | |
| parent | a01062f43d36112c00d5c007ac9d488c14d8fb0d (diff) | |
parks: シェルター等の統合と編集画面の刷新
パーゴラ・東屋を「シェルター等」に統合し、編集画面に確認チェック・遊具別入力・時計・選択行ハイライトを追加した。周辺公園と周辺施設の自治体名を補完し、公園データの文字化けを修正した。
Diffstat (limited to 'scripts/update-nearby-facilities.py')
| -rw-r--r-- | scripts/update-nearby-facilities.py | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/scripts/update-nearby-facilities.py b/scripts/update-nearby-facilities.py index dcef5d6..2e25bc3 100644 --- a/scripts/update-nearby-facilities.py +++ b/scripts/update-nearby-facilities.py @@ -109,9 +109,27 @@ def address_of(tags): return city +def existing_cities(): + """前回の出力に手動で補完した city を保持する。""" + if not os.path.exists(OUT): + return {} + try: + data = json.load(open(OUT, encoding="utf-8")) + except (OSError, ValueError): + return {} + result = {} + for item in data: + key = (item.get("osm_type"), item.get("osm_id")) + city = (item.get("city") or "").strip() + if city: + result[key] = city + return result + + def main(): print("Overpass API から近隣施設を取得中...") elements = fetch_overpass() + city_by_key = existing_cities() np = load_module(os.path.join(ROOT, "scripts", "update-nearby-parks.py"), "nearby_parks") boundary_ll = np.load_boundary() @@ -160,7 +178,8 @@ def main(): "lat": lat, "lon": lon, "geocode": "OSM", - "city": (tags.get("addr:city") or "").strip(), + "city": (tags.get("addr:city") or "").strip() + or city_by_key.get((el.get("type"), el.get("id")), ""), "distance_m": int(round(distance)), "osm_type": el.get("type"), "osm_id": el.get("id"), |
