Spaces:
Sleeping
Sleeping
blitzkrieg0000
commited on
Commit
•
bc4c6a1
1
Parent(s):
aa563cd
iframe update
Browse files
app.py
CHANGED
@@ -1,18 +1,16 @@
|
|
1 |
import os
|
2 |
-
os.system("pip install --upgrade pip")
|
3 |
os.system("pip install folium")
|
4 |
os.system("pip install gradio")
|
5 |
os.system("pip install geemap")
|
6 |
os.system("pip install earthengine-api --upgrade")
|
7 |
|
8 |
-
|
9 |
import json
|
10 |
import folium
|
11 |
import gradio as gr
|
12 |
from folium import plugins
|
13 |
|
14 |
from lib import RequestFunction
|
15 |
-
|
16 |
|
17 |
def CreateMap():
|
18 |
fmap = folium.Map(location=[37.511905, 38.51532], zoom_start=6, world_copy_jump=True, tiles=None)
|
@@ -147,15 +145,30 @@ def CreateMap():
|
|
147 |
</script>
|
148 |
""".replace("{map}", mapObjectInHTML)))
|
149 |
|
150 |
-
return fmap
|
151 |
|
152 |
|
153 |
def CreateDatasetMap(geojson_data):
|
154 |
geojson = json.loads(geojson_data)
|
155 |
coodinates = geojson.get("features")[0].get("geometry").get("coordinates")[0]
|
156 |
data = RequestFunction(coodinates)
|
157 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
158 |
|
|
|
159 |
|
160 |
|
161 |
# Gradio uygulamasını oluşturma
|
@@ -176,7 +189,7 @@ with gr.Blocks() as app:
|
|
176 |
|
177 |
|
178 |
# Haritayı görüntüleme
|
179 |
-
map_html = gr.HTML(
|
180 |
|
181 |
# Dataset görüntüleme
|
182 |
dataset_map_html = gr.HTML(elem_id="dataset_map_container")
|
|
|
1 |
import os
|
|
|
2 |
os.system("pip install folium")
|
3 |
os.system("pip install gradio")
|
4 |
os.system("pip install geemap")
|
5 |
os.system("pip install earthengine-api --upgrade")
|
6 |
|
|
|
7 |
import json
|
8 |
import folium
|
9 |
import gradio as gr
|
10 |
from folium import plugins
|
11 |
|
12 |
from lib import RequestFunction
|
13 |
+
import html
|
14 |
|
15 |
def CreateMap():
|
16 |
fmap = folium.Map(location=[37.511905, 38.51532], zoom_start=6, world_copy_jump=True, tiles=None)
|
|
|
145 |
</script>
|
146 |
""".replace("{map}", mapObjectInHTML)))
|
147 |
|
148 |
+
return fmap
|
149 |
|
150 |
|
151 |
def CreateDatasetMap(geojson_data):
|
152 |
geojson = json.loads(geojson_data)
|
153 |
coodinates = geojson.get("features")[0].get("geometry").get("coordinates")[0]
|
154 |
data = RequestFunction(coodinates)
|
155 |
+
obj = data.to_html()
|
156 |
+
|
157 |
+
obj = html.escape(obj)
|
158 |
+
|
159 |
+
_html = f"""<iframe style="width: 100%; height: 480px" name="result" allow="midi; geolocation; microphone; camera;
|
160 |
+
display-capture; encrypted-media;" sandbox="allow-modals allow-forms
|
161 |
+
allow-scripts allow-same-origin allow-popups
|
162 |
+
allow-top-navigation-by-user-activation allow-downloads" allowfullscreen=""
|
163 |
+
allowpaymentrequest="" frameborder="0" srcdoc='{obj}'></iframe>"""
|
164 |
+
|
165 |
+
with open("dataset_map.html", "w") as f:
|
166 |
+
f.write(_html)
|
167 |
+
|
168 |
+
return _html
|
169 |
+
|
170 |
|
171 |
+
basemap = CreateMap()
|
172 |
|
173 |
|
174 |
# Gradio uygulamasını oluşturma
|
|
|
189 |
|
190 |
|
191 |
# Haritayı görüntüleme
|
192 |
+
map_html = gr.HTML(basemap._repr_html_(), elem_id="map_container")
|
193 |
|
194 |
# Dataset görüntüleme
|
195 |
dataset_map_html = gr.HTML(elem_id="dataset_map_container")
|