diff options
Diffstat (limited to 'scripts/update-nearby-parks.py')
| -rw-r--r-- | scripts/update-nearby-parks.py | 43 |
1 files changed, 42 insertions, 1 deletions
diff --git a/scripts/update-nearby-parks.py b/scripts/update-nearby-parks.py index ef30f53..9f30e00 100644 --- a/scripts/update-nearby-parks.py +++ b/scripts/update-nearby-parks.py @@ -323,6 +323,42 @@ def existing_keys(): } +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 feature in data.get("features", []): + props = feature.get("properties") or {} + key = (props.get("osm_type"), props.get("osm_id")) + city = (props.get("city") or "").strip() + if city: + result[key] = city + return result + + +def existing_clocks(): + """前回の出力に手動で入れた時計情報を保持する。""" + if not os.path.exists(OUT): + return {} + try: + data = json.load(open(OUT, encoding="utf-8")) + except (OSError, ValueError): + return {} + result = {} + for feature in data.get("features", []): + props = feature.get("properties") or {} + key = (props.get("osm_type"), props.get("osm_id")) + clock = (props.get("時計") or "").strip() + if clock: + result[key] = clock + return result + + def exclusion_polygons(): """近隣公園から除外する大きな公園のポリゴン(経緯度)。 @@ -483,6 +519,8 @@ def main(): boundary = BoundaryIndex(boundary_xy) skip = existing_keys() + city_by_key = existing_cities() + clock_by_key = existing_clocks() exclusions = exclusion_polygons() features = [] skipped_inside = 0 @@ -555,9 +593,11 @@ def main(): "area_m2": int(round(area)), "osm_type": el.get("type"), "osm_id": el.get("id"), - "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")), ""), "note": NOTE, "name_source": name_source, + "時計": clock_by_key.get((el.get("type"), el.get("id")), ""), }, "geometry": geojson_geometry(polygons_ll), } @@ -579,6 +619,7 @@ def main(): "city": manual["city"], "note": manual["note"], "name_source": "manual", + "時計": clock_by_key.get((manual["osm_type"], manual["osm_id"]), ""), }, "geometry": { "type": "Point", |
