github-actions[bot] commited on
Commit
7649e08
·
1 Parent(s): cd52496

Sync with https://github.com/mozilla-ai/osm-ai-helper

Browse files
Files changed (1) hide show
  1. app.py +16 -26
app.py CHANGED
@@ -1,4 +1,3 @@
1
- import os
2
  from pathlib import Path
3
  from shutil import move
4
 
@@ -11,7 +10,7 @@ from PIL import Image
11
  from streamlit_folium import st_folium
12
 
13
  from osm_ai_helper.run_inference import run_inference
14
- from osm_ai_helper.upload_osm import upload_osm
15
 
16
 
17
  @st.fragment
@@ -90,34 +89,25 @@ def handle_polygon(polygon):
90
 
91
 
92
  @st.fragment
93
- def upload_results(output_path):
94
  st.divider()
95
- st.header("Upload all polygons in `keep`")
96
 
97
  st.markdown(
98
- "The results will be uploaded using the [osm-ai-helper](https://www.openstreetmap.org/user/osm-ai-helper) profile."
 
99
  )
100
- st.markdown(
101
- "You can check the [Colab Notebook](ttps://colab.research.google.com/github/mozilla-ai/osm-ai-helper/blob/main/demo/run_inference_point.ipynb)"
102
- " and the [Authorization Guide](https://mozilla-ai.github.io/osm-ai-helper/authorization)"
103
- " to contribute with your own OpenStreetMap account."
 
 
 
 
 
 
104
  )
105
- contributor = st.text_input("(Optional) Indicate your name for attribution")
106
- if st.button("Upload all polygons in `keep`"):
107
- if contributor:
108
- comment = f"Add Swimming Pools. Contributed by {contributor}"
109
- else:
110
- comment = "Add Swimming Pools"
111
-
112
- changeset = upload_osm(
113
- results_dir=output_path / "keep",
114
- client_id=os.environ["OSM_CLIENT_ID"],
115
- client_secret=os.environ["OSM_CLIENT_SECRET"],
116
- comment=comment,
117
- )
118
- st.success(
119
- f"Changeset created: https://www.openstreetmap.org/changeset/{changeset}"
120
- )
121
 
122
 
123
  st.title("OpenStreetMap AI Helper")
@@ -171,6 +161,6 @@ if st.button("Run Inference") and lat_lon:
171
  for new in Path(output_path).glob("*.json"):
172
  handle_polygon(new)
173
 
174
- upload_results(output_path)
175
  else:
176
  st.warning("No `new` swimming pools were found. Try a different location.")
 
 
1
  from pathlib import Path
2
  from shutil import move
3
 
 
10
  from streamlit_folium import st_folium
11
 
12
  from osm_ai_helper.run_inference import run_inference
13
+ from osm_ai_helper.export_osm import convert_polygons
14
 
15
 
16
  @st.fragment
 
89
 
90
 
91
  @st.fragment
92
+ def download_results(output_path):
93
  st.divider()
94
+ st.header("Export Results")
95
 
96
  st.markdown(
97
+ "The results will be exported in [OsmChange](https://wiki.openstreetmap.org/wiki/OsmChange) format."
98
+ "\nYou can then import the file in [any of the supported editors](https://wiki.openstreetmap.org/wiki/OsmChange#Editors) format."
99
  )
100
+
101
+ changeset = convert_polygons(
102
+ results_dir=output_path / "keep",
103
+ tags={"leisure": "swimming_pool", "access": "private", "location": "outdoor"},
104
+ )
105
+ st.download_button(
106
+ label="Download all polygons in `keep`",
107
+ data=changeset,
108
+ file_name="exported_results.osc",
109
+ mime="type/xml",
110
  )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
111
 
112
 
113
  st.title("OpenStreetMap AI Helper")
 
161
  for new in Path(output_path).glob("*.json"):
162
  handle_polygon(new)
163
 
164
+ download_results(output_path)
165
  else:
166
  st.warning("No `new` swimming pools were found. Try a different location.")