Spaces:
Running
on
Zero
Running
on
Zero
Suchinthana
commited on
Commit
·
0162762
1
Parent(s):
92e64c7
removing generate_static_map duplicate
Browse files
app.py
CHANGED
@@ -193,34 +193,6 @@ def get_bounds(geojson):
|
|
193 |
lngs = [coord[0] for coord in coordinates]
|
194 |
return [[min(lats), min(lngs)], [max(lats), max(lngs)]]
|
195 |
|
196 |
-
@spaces.GPU
|
197 |
-
def generate_static_map(geojson_data, bounds=None):
|
198 |
-
# Create a static map object with specified dimensions
|
199 |
-
m = StaticMap(600, 600)
|
200 |
-
|
201 |
-
if bounds:
|
202 |
-
center_lat = (bounds[0][0] + bounds[1][0]) / 2
|
203 |
-
center_lng = (bounds[0][1] + bounds[1][1]) / 2
|
204 |
-
zoom = 10 # Adjust zoom level as needed
|
205 |
-
m.set_center(center_lat, center_lng, zoom)
|
206 |
-
|
207 |
-
# Process each feature in the GeoJSON
|
208 |
-
for feature in geojson_data["features"]:
|
209 |
-
geom_type = feature["geometry"]["type"]
|
210 |
-
coords = feature["geometry"]["coordinates"]
|
211 |
-
|
212 |
-
if geom_type == "Point":
|
213 |
-
m.add_marker(CircleMarker((coords[0], coords[1]), 'blue', 10))
|
214 |
-
elif geom_type in ["MultiPoint", "LineString"]:
|
215 |
-
for coord in coords:
|
216 |
-
m.add_marker(CircleMarker((coord[0], coord[1]), 'blue', 10))
|
217 |
-
elif geom_type in ["Polygon", "MultiPolygon"]:
|
218 |
-
for polygon in coords:
|
219 |
-
m.add_polygon(Polygon([(c[0], c[1]) for c in polygon], 'blue', 3))
|
220 |
-
|
221 |
-
return m.render(zoom=10)
|
222 |
-
|
223 |
-
|
224 |
# Gradio UI
|
225 |
@spaces.GPU
|
226 |
def handle_query(query):
|
|
|
193 |
lngs = [coord[0] for coord in coordinates]
|
194 |
return [[min(lats), min(lngs)], [max(lats), max(lngs)]]
|
195 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
196 |
# Gradio UI
|
197 |
@spaces.GPU
|
198 |
def handle_query(query):
|