Spaces:
Runtime error
Runtime error
Commit
•
86239b3
0
Parent(s):
Duplicate from nt3awnou/Nt3awnou-rescue-map
Browse filesCo-authored-by: Nouamane Tazi <nouamanetazi@users.noreply.huggingface.co>
- .gitattributes +35 -0
- .gitignore +23 -0
- .streamlit/config.toml +28 -0
- README.md +12 -0
- app.py +298 -0
- requirements.txt +2 -0
- src/map_utils.py +102 -0
- src/text_content.py +88 -0
- src/utils.py +142 -0
.gitattributes
ADDED
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
*.7z filter=lfs diff=lfs merge=lfs -text
|
2 |
+
*.arrow filter=lfs diff=lfs merge=lfs -text
|
3 |
+
*.bin filter=lfs diff=lfs merge=lfs -text
|
4 |
+
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
5 |
+
*.ckpt filter=lfs diff=lfs merge=lfs -text
|
6 |
+
*.ftz filter=lfs diff=lfs merge=lfs -text
|
7 |
+
*.gz filter=lfs diff=lfs merge=lfs -text
|
8 |
+
*.h5 filter=lfs diff=lfs merge=lfs -text
|
9 |
+
*.joblib filter=lfs diff=lfs merge=lfs -text
|
10 |
+
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
11 |
+
*.mlmodel filter=lfs diff=lfs merge=lfs -text
|
12 |
+
*.model filter=lfs diff=lfs merge=lfs -text
|
13 |
+
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
14 |
+
*.npy filter=lfs diff=lfs merge=lfs -text
|
15 |
+
*.npz filter=lfs diff=lfs merge=lfs -text
|
16 |
+
*.onnx filter=lfs diff=lfs merge=lfs -text
|
17 |
+
*.ot filter=lfs diff=lfs merge=lfs -text
|
18 |
+
*.parquet filter=lfs diff=lfs merge=lfs -text
|
19 |
+
*.pb filter=lfs diff=lfs merge=lfs -text
|
20 |
+
*.pickle filter=lfs diff=lfs merge=lfs -text
|
21 |
+
*.pkl filter=lfs diff=lfs merge=lfs -text
|
22 |
+
*.pt filter=lfs diff=lfs merge=lfs -text
|
23 |
+
*.pth filter=lfs diff=lfs merge=lfs -text
|
24 |
+
*.rar filter=lfs diff=lfs merge=lfs -text
|
25 |
+
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
26 |
+
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
27 |
+
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
28 |
+
*.tar filter=lfs diff=lfs merge=lfs -text
|
29 |
+
*.tflite filter=lfs diff=lfs merge=lfs -text
|
30 |
+
*.tgz filter=lfs diff=lfs merge=lfs -text
|
31 |
+
*.wasm filter=lfs diff=lfs merge=lfs -text
|
32 |
+
*.xz filter=lfs diff=lfs merge=lfs -text
|
33 |
+
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
+
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
+
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
.gitignore
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Byte-compiled / optimized / DLL files
|
2 |
+
__pycache__/
|
3 |
+
|
4 |
+
# C extensions
|
5 |
+
*.so
|
6 |
+
|
7 |
+
# Distribution / packaging
|
8 |
+
bin/
|
9 |
+
build/
|
10 |
+
develop-eggs/
|
11 |
+
dist/
|
12 |
+
eggs/
|
13 |
+
lib/
|
14 |
+
lib64/
|
15 |
+
parts/
|
16 |
+
sdist/
|
17 |
+
var/
|
18 |
+
*.egg-info/
|
19 |
+
.installed.cfg
|
20 |
+
*.egg
|
21 |
+
|
22 |
+
# vscode
|
23 |
+
.vscode
|
.streamlit/config.toml
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
[browser]
|
2 |
+
|
3 |
+
# Internet address where users should point their browsers in order to
|
4 |
+
# connect to the app. Can be IP address or DNS name and path.
|
5 |
+
|
6 |
+
# This is used to:
|
7 |
+
# - Set the correct URL for CORS and XSRF protection purposes.
|
8 |
+
# - Show the URL on the terminal
|
9 |
+
# - Open the browser
|
10 |
+
|
11 |
+
# Default: "localhost"
|
12 |
+
serverAddress = "localhost"
|
13 |
+
|
14 |
+
# Whether to send usage statistics to Streamlit.
|
15 |
+
|
16 |
+
# Default: true
|
17 |
+
gatherUsageStats = false
|
18 |
+
|
19 |
+
# Port where users should point their browsers in order to connect to the
|
20 |
+
# app.
|
21 |
+
|
22 |
+
# This is used to:
|
23 |
+
# - Set the correct URL for CORS and XSRF protection purposes.
|
24 |
+
# - Show the URL on the terminal
|
25 |
+
# - Open the browser
|
26 |
+
|
27 |
+
# Default: whatever value is set in server.port.
|
28 |
+
serverPort = 8502
|
README.md
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
title: Nt3awnu Map
|
3 |
+
emoji: ❤️
|
4 |
+
colorFrom: white
|
5 |
+
colorTo: white
|
6 |
+
sdk: streamlit
|
7 |
+
sdk_version: 1.26.0
|
8 |
+
app_file: app.py
|
9 |
+
duplicated_from: nt3awnou/Nt3awnou-rescue-map
|
10 |
+
---
|
11 |
+
|
12 |
+
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
app.py
ADDED
@@ -0,0 +1,298 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
import time
|
3 |
+
from datetime import datetime
|
4 |
+
|
5 |
+
import folium
|
6 |
+
import pandas as pd
|
7 |
+
import streamlit as st
|
8 |
+
from huggingface_hub import HfApi
|
9 |
+
from streamlit_folium import st_folium
|
10 |
+
from src.utils import add_latlng_col
|
11 |
+
|
12 |
+
from src.text_content import (
|
13 |
+
COLOR_MAPPING,
|
14 |
+
CREDITS_TEXT,
|
15 |
+
HEADERS_MAPPING,
|
16 |
+
ICON_MAPPING,
|
17 |
+
INTRO_TEXT_AR,
|
18 |
+
INTRO_TEXT_EN,
|
19 |
+
INTRO_TEXT_FR,
|
20 |
+
LOGO,
|
21 |
+
REVIEW_TEXT,
|
22 |
+
SLOGAN,
|
23 |
+
)
|
24 |
+
from src.utils import init_map, parse_gg_sheet
|
25 |
+
|
26 |
+
TOKEN = os.environ.get("HF_TOKEN", None)
|
27 |
+
REQUESTS_URL = "https://docs.google.com/spreadsheets/d/1gYoBBiBo1L18IVakHkf3t1fOGvHWb23loadyFZUeHJs/edit#gid=966953708"
|
28 |
+
INTERVENTIONS_URL = (
|
29 |
+
"https://docs.google.com/spreadsheets/d/1eXOTqunOWWP8FRdENPs4cU9ulISm4XZWYJJNR1-SrwY/edit#gid=2089222765"
|
30 |
+
)
|
31 |
+
api = HfApi(TOKEN)
|
32 |
+
|
33 |
+
|
34 |
+
# Initialize Streamlit Config
|
35 |
+
st.set_page_config(layout="wide", initial_sidebar_state="collapsed", page_icon="🤝", page_title="Nt3awnou نتعاونو")
|
36 |
+
|
37 |
+
# Initialize States
|
38 |
+
if "sleep_time" not in st.session_state:
|
39 |
+
st.session_state.sleep_time = 2
|
40 |
+
if "auto_refresh" not in st.session_state:
|
41 |
+
st.session_state.auto_refresh = False
|
42 |
+
|
43 |
+
auto_refresh = st.sidebar.checkbox("Auto Refresh?", st.session_state.auto_refresh)
|
44 |
+
if auto_refresh:
|
45 |
+
number = st.sidebar.number_input("Refresh rate in seconds", value=st.session_state.sleep_time)
|
46 |
+
st.session_state.sleep_time = number
|
47 |
+
|
48 |
+
|
49 |
+
# Streamlit functions
|
50 |
+
def display_interventions(interventions_df, m):
|
51 |
+
"""Display NGO interventions on the map"""
|
52 |
+
for index, row in interventions_df.iterrows():
|
53 |
+
status = (
|
54 |
+
"Done ✅"
|
55 |
+
if row[interventions_df.columns[5]] != "Intervention prévue dans le futur / Planned future intervention"
|
56 |
+
else "Planned ⌛"
|
57 |
+
)
|
58 |
+
color_mk = (
|
59 |
+
"green"
|
60 |
+
if row[interventions_df.columns[5]] != "Intervention prévue dans le futur / Planned future intervention"
|
61 |
+
else "pink"
|
62 |
+
)
|
63 |
+
intervention_type = row[interventions_df.columns[6]].split("/")[0].strip()
|
64 |
+
org = row[interventions_df.columns[1]]
|
65 |
+
city = row[interventions_df.columns[9]]
|
66 |
+
date = row[interventions_df.columns[4]]
|
67 |
+
intervention_info = f"<b>Status:</b> {status}<br><b>Org:</b> {org}<br><b>Intervention:</b> {intervention_type}<br><b>📅 Date:</b> {date}"
|
68 |
+
if row["latlng"] is None:
|
69 |
+
continue
|
70 |
+
folium.Marker(
|
71 |
+
location=row["latlng"],
|
72 |
+
tooltip=city,
|
73 |
+
popup=folium.Popup(intervention_info, max_width=300),
|
74 |
+
icon=folium.Icon(color=color_mk),
|
75 |
+
).add_to(m)
|
76 |
+
|
77 |
+
|
78 |
+
def show_requests(filtered_df, m):
|
79 |
+
"""Display victim requests on the map"""
|
80 |
+
for index, row in filtered_df.iterrows():
|
81 |
+
request_type = row["ما هي احتياجاتك؟ (أضفها إذا لم يتم ذكرها)"]
|
82 |
+
long_lat = row[
|
83 |
+
"هل يمكنك تقديم الإحداثيات الدقيقة للموقع؟ (ادا كنت لا توجد بعين المكان) متلاً \n31.01837503440344, -6.781405948842175"
|
84 |
+
]
|
85 |
+
maps_url = f"https://maps.google.com/?q={long_lat}"
|
86 |
+
display_text = f'<b>Request Type:</b> {request_type}<br><b>Id:</b> {row["id"]}<br><a href="{maps_url}" target="_blank" rel="noopener noreferrer"><b>Google Maps</b></a>'
|
87 |
+
icon_name = ICON_MAPPING.get(request_type, "info-sign")
|
88 |
+
if row["latlng"] is None:
|
89 |
+
continue
|
90 |
+
|
91 |
+
folium.Marker(
|
92 |
+
location=row["latlng"],
|
93 |
+
tooltip=row[" لأي جماعة / قيادة / دوار تنتمون ؟"]
|
94 |
+
if not pd.isna(row[" لأي جماعة / قيادة / دوار تنتمون ؟"])
|
95 |
+
else None,
|
96 |
+
popup=folium.Popup(display_text, max_width=300),
|
97 |
+
icon=folium.Icon(color=COLOR_MAPPING.get(request_type, "blue"), icon=icon_name),
|
98 |
+
).add_to(m)
|
99 |
+
|
100 |
+
|
101 |
+
def display_google_sheet_tables(data_url):
|
102 |
+
"""Display the google sheet tables for requests and interventions"""
|
103 |
+
st.markdown(
|
104 |
+
f"""<iframe src="{data_url}" width="100%" height="600px"></iframe>""",
|
105 |
+
unsafe_allow_html=True,
|
106 |
+
)
|
107 |
+
|
108 |
+
|
109 |
+
def display_dataframe(df, drop_cols, data_url, search_id=True, status=False):
|
110 |
+
"""Display the dataframe in a table"""
|
111 |
+
col_1, col_2 = st.columns([1, 1])
|
112 |
+
|
113 |
+
with col_1:
|
114 |
+
query = st.text_input(
|
115 |
+
"🔍 Search for information / بحث عن المعلومات",
|
116 |
+
key=f"search_requests_{int(search_id)}",
|
117 |
+
)
|
118 |
+
with col_2:
|
119 |
+
if search_id:
|
120 |
+
id_number = st.number_input(
|
121 |
+
"🔍 Search for an id / بحث عن رقم",
|
122 |
+
min_value=0,
|
123 |
+
max_value=len(filtered_df),
|
124 |
+
value=0,
|
125 |
+
step=1,
|
126 |
+
)
|
127 |
+
if status:
|
128 |
+
selected_status = st.selectbox(
|
129 |
+
"🗓️ Status / حالة",
|
130 |
+
["all / الكل", "Done / تم", "Planned / مخطط لها"],
|
131 |
+
key="status",
|
132 |
+
)
|
133 |
+
|
134 |
+
if query:
|
135 |
+
# Filtering the dataframe based on the query
|
136 |
+
mask = df.apply(lambda row: row.astype(str).str.contains(query).any(), axis=1)
|
137 |
+
display_df = df[mask]
|
138 |
+
else:
|
139 |
+
display_df = df
|
140 |
+
|
141 |
+
display_df = display_df.drop(drop_cols, axis=1)
|
142 |
+
|
143 |
+
if search_id and id_number:
|
144 |
+
display_df = display_df[display_df["id"] == id_number]
|
145 |
+
|
146 |
+
if status:
|
147 |
+
target = "Pouvez-vous nous préciser si vous êtes déjà intervenus ou si vous prévoyez de le faire | Tell us if you already made the intervention, or if you're planning to do it"
|
148 |
+
if selected_status == "Done / تم":
|
149 |
+
display_df = display_df[display_df[target] == "Intervention déjà passée / Past intevention"]
|
150 |
+
|
151 |
+
elif selected_status == "Planned / مخطط لها":
|
152 |
+
display_df = display_df[display_df[target] != "Intervention déjà passée / Past intevention"]
|
153 |
+
|
154 |
+
st.dataframe(display_df, height=500)
|
155 |
+
st.markdown(
|
156 |
+
f"To view the full Google Sheet for advanced filtering go to: {data_url} **لعرض الورقة كاملة، اذهب إلى**"
|
157 |
+
)
|
158 |
+
# if we want to check hidden contact information
|
159 |
+
st.markdown(
|
160 |
+
f"We are hiding contact information to protect the privacy of the victims. If you are an NGO and want to contact the victims, please contact us at nt3awnoumorocco@gmail.com",
|
161 |
+
)
|
162 |
+
# arabic needs rtl
|
163 |
+
st.markdown(
|
164 |
+
f"""
|
165 |
+
<div style="text-align: left;">
|
166 |
+
<a href="mailto:nt3awnoumorocco@gmail.com">nt3awnoumorocco@gmail.com</a> نحن نخفي معلومات الاتصال لحماية خصوصية الضحايا. إذا كنت جمعية وتريد الاتصال بالضحايا، يرجى الاتصال بنا على
|
167 |
+
</div>
|
168 |
+
""",
|
169 |
+
unsafe_allow_html=True,
|
170 |
+
)
|
171 |
+
|
172 |
+
|
173 |
+
def id_review_submission():
|
174 |
+
"""Id review submission form"""
|
175 |
+
st.subheader("🔍 Review of requests")
|
176 |
+
st.markdown(REVIEW_TEXT)
|
177 |
+
|
178 |
+
id_to_review = st.number_input("Enter id / أدخل الرقم", min_value=0, max_value=len(df), value=0, step=1)
|
179 |
+
reason_for_review = st.text_area("Explain why / أدخل سبب المراجعة")
|
180 |
+
if st.button("Submit / أرسل"):
|
181 |
+
if reason_for_review == "":
|
182 |
+
st.error("Please enter a reason / الرجاء إدخال سبب")
|
183 |
+
else:
|
184 |
+
filename = f"review_id_{id_to_review}_{datetime.now().strftime('%Y-%m-%d_%H-%M-%S')}.txt"
|
185 |
+
with open(filename, "w") as f:
|
186 |
+
f.write(f"id: {id_to_review}, explanation: {reason_for_review}\n")
|
187 |
+
api.upload_file(
|
188 |
+
path_or_fileobj=filename,
|
189 |
+
path_in_repo=filename,
|
190 |
+
repo_id="nt3awnou/review_requests",
|
191 |
+
repo_type="dataset",
|
192 |
+
)
|
193 |
+
st.success("Submitted at https://huggingface.co/datasets/nt3awnou/review_requests/ تم الإرسال")
|
194 |
+
|
195 |
+
|
196 |
+
# Logo and Title
|
197 |
+
st.markdown(LOGO, unsafe_allow_html=True)
|
198 |
+
# st.title("Nt3awnou نتعاونو")
|
199 |
+
st.markdown(SLOGAN, unsafe_allow_html=True)
|
200 |
+
|
201 |
+
# Load data and initialize map with plugins
|
202 |
+
df = parse_gg_sheet(REQUESTS_URL)
|
203 |
+
df = add_latlng_col(df, process_column=15)
|
204 |
+
interventions_df = parse_gg_sheet(INTERVENTIONS_URL)
|
205 |
+
interventions_df = add_latlng_col(interventions_df, process_column=12)
|
206 |
+
m = init_map()
|
207 |
+
|
208 |
+
# Selection of requests
|
209 |
+
options = [
|
210 |
+
"إغاثة",
|
211 |
+
"مساعدة طبية",
|
212 |
+
"مأوى",
|
213 |
+
"طعام وماء",
|
214 |
+
"مخاطر (تسرب الغاز، تلف في الخدمات العامة...)",
|
215 |
+
]
|
216 |
+
selected_options = []
|
217 |
+
|
218 |
+
# with tab_en:
|
219 |
+
# st.markdown("👉 **Choose request type**")
|
220 |
+
# with tab_ar:
|
221 |
+
# st.markdown("👉 **اختر نوع الطلب**")
|
222 |
+
# with tab_fr:
|
223 |
+
# st.markdown("👉 **Choisissez le type de demande**")
|
224 |
+
|
225 |
+
st.markdown("👉 **Choose request type | Choissisez le type de demande | اختر نوع الطلب**")
|
226 |
+
col1, col2, col3, col4, col5 = st.columns([2, 3, 2, 3, 4])
|
227 |
+
cols = [col1, col2, col3, col4, col5]
|
228 |
+
|
229 |
+
for i, option in enumerate(options):
|
230 |
+
checked = cols[i].checkbox(HEADERS_MAPPING[option], value=True)
|
231 |
+
if checked:
|
232 |
+
selected_options.append(option)
|
233 |
+
|
234 |
+
df["id"] = df.index
|
235 |
+
filtered_df = df[df["ما هي احتياجاتك؟ (أضفها إذا لم يتم ذكرها)"].isin(selected_options)]
|
236 |
+
selected_headers = [HEADERS_MAPPING[request] for request in selected_options]
|
237 |
+
|
238 |
+
# Selection of interventions
|
239 |
+
show_interventions = st.checkbox(
|
240 |
+
"Display Interventions | عرض عمليات المساعدة | Afficher les interventions",
|
241 |
+
value=True,
|
242 |
+
)
|
243 |
+
|
244 |
+
if show_interventions:
|
245 |
+
# print(interventions_df.columns)
|
246 |
+
display_interventions(interventions_df, m)
|
247 |
+
|
248 |
+
# Show requests
|
249 |
+
show_requests(filtered_df, m)
|
250 |
+
|
251 |
+
st_data = st_folium(m, use_container_width=True)
|
252 |
+
tab_ar, tab_en, tab_fr = st.tabs(["العربية", "English", "Français"])
|
253 |
+
|
254 |
+
|
255 |
+
with tab_en:
|
256 |
+
st.markdown(INTRO_TEXT_EN, unsafe_allow_html=True)
|
257 |
+
with tab_ar:
|
258 |
+
st.markdown(INTRO_TEXT_AR, unsafe_allow_html=True)
|
259 |
+
with tab_fr:
|
260 |
+
st.markdown(INTRO_TEXT_FR, unsafe_allow_html=True)
|
261 |
+
|
262 |
+
# Requests table
|
263 |
+
st.divider()
|
264 |
+
st.subheader("📝 **Table of requests / جدول الطلبات**")
|
265 |
+
drop_cols = [
|
266 |
+
"(عند الامكان) رقم هاتف شخص موجود في عين المكان",
|
267 |
+
"الرجاء الضغط على الرابط التالي لمعرفة موقعك إذا كان متاحا",
|
268 |
+
"GeoStamp",
|
269 |
+
"GeoCode",
|
270 |
+
"GeoAddress",
|
271 |
+
"Status",
|
272 |
+
]
|
273 |
+
display_dataframe(filtered_df, drop_cols, REQUESTS_URL, search_id=True)
|
274 |
+
|
275 |
+
# Interventions table
|
276 |
+
st.divider()
|
277 |
+
st.subheader("📝 **Table of interventions / جدول التدخلات**")
|
278 |
+
display_dataframe(
|
279 |
+
interventions_df,
|
280 |
+
[], # We show NGOs contact information
|
281 |
+
INTERVENTIONS_URL,
|
282 |
+
search_id=False,
|
283 |
+
status=True,
|
284 |
+
)
|
285 |
+
|
286 |
+
# Submit an id for review
|
287 |
+
st.divider()
|
288 |
+
id_review_submission()
|
289 |
+
|
290 |
+
|
291 |
+
# Credits
|
292 |
+
st.markdown(
|
293 |
+
CREDITS_TEXT,
|
294 |
+
unsafe_allow_html=True,
|
295 |
+
)
|
296 |
+
if auto_refresh:
|
297 |
+
time.sleep(number)
|
298 |
+
st.experimental_rerun()
|
requirements.txt
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
folium
|
2 |
+
streamlit_folium
|
src/map_utils.py
ADDED
@@ -0,0 +1,102 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from branca.element import Template, MacroElement
|
2 |
+
|
3 |
+
|
4 |
+
template = """
|
5 |
+
{% macro html(this, kwargs) %}
|
6 |
+
|
7 |
+
<!doctype html>
|
8 |
+
<html lang="en">
|
9 |
+
<head>
|
10 |
+
<meta charset="utf-8">
|
11 |
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
12 |
+
<title>jQuery UI Draggable - Default functionality</title>
|
13 |
+
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
|
14 |
+
|
15 |
+
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
|
16 |
+
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
|
17 |
+
|
18 |
+
<script>
|
19 |
+
$( function() {
|
20 |
+
$( "#maplegend" ).draggable({
|
21 |
+
start: function (event, ui) {
|
22 |
+
$(this).css({
|
23 |
+
right: "auto",
|
24 |
+
top: "auto",
|
25 |
+
bottom: "auto"
|
26 |
+
});
|
27 |
+
}
|
28 |
+
});
|
29 |
+
});
|
30 |
+
|
31 |
+
</script>
|
32 |
+
</head>
|
33 |
+
<body>
|
34 |
+
|
35 |
+
|
36 |
+
<div id='maplegend' class='maplegend'
|
37 |
+
style='position: absolute; z-index:9999; border:2px solid grey; background-color:rgba(255, 255, 255, 0.8);
|
38 |
+
border-radius:6px; padding: 10px; font-size:14px; right: 20px; bottom: 20px;'>
|
39 |
+
|
40 |
+
<div class='legend-title'>Legend / مفتاح الخريطة</div>
|
41 |
+
<div class='legend-scale'>
|
42 |
+
<ul class='legend-labels'>
|
43 |
+
<li><span style='background:#CE3C28;opacity:0.7;'></span>Rescue / إغاثة</li>
|
44 |
+
<li><span style='background:#ED922E;opacity:0.7;'></span>Medical Assistance / مساعدة طبية</li>
|
45 |
+
<li><span style='background:#FFCA92;opacity:0.7;'></span>Shelter / مأوى</li>
|
46 |
+
<li><span style='background:#37A8DA;opacity:0.7;'></span>Food & Water / طعام وماء</li>
|
47 |
+
<li><span style='background:#575757;opacity:0.7;'></span>Danger / مخاطر (تسرب الغاز، تلف في الخدمات العامة...)</li>
|
48 |
+
<li><span style='background:#6EAA25;opacity:0.7;'></span>Done / تم</li>
|
49 |
+
<li><span style='background:#FF91E8;opacity:0.7;'></span>Planned / مخطط لها</li>
|
50 |
+
</ul>
|
51 |
+
</div>
|
52 |
+
</div>
|
53 |
+
|
54 |
+
</body>
|
55 |
+
</html>
|
56 |
+
|
57 |
+
<style type='text/css'>
|
58 |
+
.maplegend .legend-title {
|
59 |
+
text-align: left;
|
60 |
+
margin-bottom: 5px;
|
61 |
+
font-weight: bold;
|
62 |
+
font-size: 90%;
|
63 |
+
color: #333;
|
64 |
+
}
|
65 |
+
.maplegend .legend-scale ul {
|
66 |
+
margin: 0;
|
67 |
+
margin-bottom: 5px;
|
68 |
+
padding: 0;
|
69 |
+
float: left;
|
70 |
+
list-style: none;
|
71 |
+
}
|
72 |
+
.maplegend .legend-scale ul li {
|
73 |
+
font-size: 80%;
|
74 |
+
list-style: none;
|
75 |
+
margin-left: 0;
|
76 |
+
line-height: 18px;
|
77 |
+
margin-bottom: 2px;
|
78 |
+
color: #111;
|
79 |
+
}
|
80 |
+
.maplegend ul.legend-labels li span {
|
81 |
+
display: block;
|
82 |
+
float: left;
|
83 |
+
height: 16px;
|
84 |
+
width: 30px;
|
85 |
+
margin-right: 5px;
|
86 |
+
margin-left: 0;
|
87 |
+
border: 1px solid #999;
|
88 |
+
}
|
89 |
+
.maplegend .legend-source {
|
90 |
+
font-size: 80%;
|
91 |
+
color: #777;
|
92 |
+
clear: both;
|
93 |
+
}
|
94 |
+
.maplegend a {
|
95 |
+
color: #777;
|
96 |
+
}
|
97 |
+
</style>
|
98 |
+
{% endmacro %}"""
|
99 |
+
legend_macro = MacroElement()
|
100 |
+
legend_macro._template = Template(template)
|
101 |
+
|
102 |
+
__all__ = ["legend_macro"]
|
src/text_content.py
ADDED
@@ -0,0 +1,88 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
INTRO_TEXT_EN = """
|
2 |
+
<div style="text-align: left;">
|
3 |
+
Nt3awnou نتعاونو is a collaborative platform dedicated to aiding individuals impacted by the recent earthquake in Morocco. Our core mission is to streamline and coordinate timely assistance for everyone affected. How do we achieve this? We assist those in need by allowing them to communicate their location and the specific aid they require, either by completing a form or sending a voice message via WhatsApp to a designated number. Once we receive and process this information, it can be viewed in our dashboard, which allows NGOs to organize and precisely target their interventions, ensuring swift assistance reaches those in need. Any organization that has taken initiative in a particular area can notify us by completing a dedicated form. This data is also incorporated into the dashboard so that other NGOs can help affected areas that still haven't received help.
|
4 |
+
Warning : There are still rocks falling down the mountains, making the roads to the affected areas very dangerous. We advise volunteers to donate directly to specialized NGOs.<br>
|
5 |
+
<br>
|
6 |
+
<b>✉️ You can contact us via email at </b><a href="mailto:nt3awnoumorocco@gmail.com">nt3awnoumorocco@gmail.com</a> <br>
|
7 |
+
<b>📝 Help us report more people in need by filling this form </b><a href="https://forms.gle/nZNCUVog9ka2Vdqu6">https://forms.gle/nZNCUVog9ka2Vdqu6</a> <br>
|
8 |
+
<b>📝 NGOs can report their interventions by filling this form </b><a href="https://forms.gle/PsNSuHHjTTgwQMmVA">https://forms.gle/PsNSuHHjTTgwQMmVA</a>
|
9 |
+
</div>
|
10 |
+
<br>
|
11 |
+
"""
|
12 |
+
|
13 |
+
INTRO_TEXT_AR = """
|
14 |
+
<div style="text-align: right;">
|
15 |
+
|
16 |
+
نتعاونو هي منصة تعاونية لمساعدة الأفراد المتضررين من الزلزال الأخير في المغرب. مهمتنا هي تسهيل تقديم المساعدة في الوقت المناسب و بفاعلية و تنظيم لجميع المتضررين. كيفاش؟ كنعاونو الناس لي محتاجين للمساعدة إعلمونا بمكانهم و نوع المساعدة لي محتاجين ليها سواء عن طريق ملأ الاستمارة أو عن طريق إرسال تسجيل صوتي عبر واتساب إلى رقم مخصص. بعد معالجة هاد المعلومات، كنجمعوهم فخريطة كتمكن الجمعيات من تنظيم و استهداف تدخلاتهم بدقة باش توصل المساعدة للناس لي محتاجين في وقت أسرع. و كل جمعية قامت باللازم في منطقة معينة تقدر تعلمنا عن طريق ملأ استمارة مخصصة لهاد الأمر. هاد المعلومات كذلك كتضاف للخريطة باش باقي الجمعيات يتاجهو لمناطق أخرى مازال ماوصلاتهم مساعدة.
|
17 |
+
تحذير : نظرا لخطورة الطرقان بسبب الحجر اللي كيطيح من الجبال، ننصح المتطوعين اللي بغاو يساعدو المناطق المتضررة يتبرعو عن طريق الجمعيات المختصة.
|
18 |
+
<br>
|
19 |
+
nt3awnoumorocco@gmail.com <b>المتطوعين ليبغاو يعاونوا يقدرو يتصلوا معنا عبر البريد ✉️ </b><br>
|
20 |
+
https://forms.gle/nZNCUVog9ka2Vdqu6 <b>: ساعدونا نبلغو الناس ليمحتاجين فهاد الاستمارة 📝 </b><br>
|
21 |
+
https://forms.gle/PsNSuHHjTTgwQMmVA <b>: الجمعيات لي عندهم تدخلات يقدرو يبلغونا عبر هاد الاستمار ة📝</b>
|
22 |
+
</div>
|
23 |
+
<br>
|
24 |
+
"""
|
25 |
+
|
26 |
+
INTRO_TEXT_FR = """
|
27 |
+
<div style="text-align: left;">
|
28 |
+
Nt3awnou نتعاونو est une plateforme collaborative dédiée à l'aide aux personnes touchées par le récent tremblement de terre au Maroc. Notre mission principale est de rationaliser et de coordonner une assistance rapide pour toutes les personnes touchées. Comment y parvenons-nous ? Nous aidons les personnes dans le besoin en leur permettant de communiquer leur localisation et l'aide spécifique dont elles ont besoin, soit en remplissant un formulaire, soit en envoyant un message vocal via WhatsApp à un numéro désigné. Une fois reçues et traitées, ces informations peuvent être consultées dans notre tableau de bord, qui permet aux associations d'organiser et de cibler précisément leurs interventions, afin que l'aide parvienne rapidement à ceux qui en ont besoin. Toute organisation ayant pris une initiative dans une zone particulière peut nous en informer en remplissant un formulaire prévu à cet effet. Ces données sont également intégrées au tableau de bord afin que d'autres associations puissent aider les zones touchées qui n'ont pas encore reçu d'aide.
|
29 |
+
Avertissement : Il y a encore des chutes de pierres dans les montagnes, ce qui rend les routes vers les zones touchées très dangereuses. Nous conseillons aux volontaires de faire des dons directement aux associations spécialisées.
|
30 |
+
<br>
|
31 |
+
<b>✉️ Vous pouvez nous contacter par courrier électronique à l'adresse suivante : </b>nt3awnoumorocco@gmail.com <br>
|
32 |
+
<b>📝 Aidez-nous à signaler plus de personnes dans le besoin en remplissant ce formulaire : </b>https://forms.gle/nZNCUVog9ka2Vdqu6 <br>
|
33 |
+
<b>📝 Les associations peuvent signaler leurs interventions en remplissant ce formulaire :</b>https://forms.gle/PsNSuHHjTTgwQMmVA
|
34 |
+
</div>
|
35 |
+
<br>
|
36 |
+
"""
|
37 |
+
|
38 |
+
SLOGAN = """
|
39 |
+
<div style="text-align: center;">
|
40 |
+
<h4>وَمَنْ أَحْيَاهَا فَكَأَنَّمَا أَحْيَا النَّاسَ جَمِيعاً</h4>
|
41 |
+
</div>
|
42 |
+
"""
|
43 |
+
|
44 |
+
HEADERS_MAPPING = {
|
45 |
+
"إغاثة" : "Rescue | إغاثة | Secours",
|
46 |
+
"مساعدة طبية": "Medical Assistance | مساعدة طبية | Assistance médicale",
|
47 |
+
"مأوى": "Shelter | مأوى | Abri",
|
48 |
+
"طعام وماء": "Food & Water | طعام وماء | Nourriture et eau",
|
49 |
+
"مخاطر (تسرب الغاز، تلف في الخدمات العامة...)": "Danger | مخاطر (تسرب الغاز، تلف في الخدمات العامة...) | Danger",
|
50 |
+
}
|
51 |
+
|
52 |
+
COLOR_MAPPING = {
|
53 |
+
"إغاثة": "red",
|
54 |
+
"مساعدة طبية": "orange",
|
55 |
+
"مأوى": "beige",
|
56 |
+
"طعام وماء": "blue",
|
57 |
+
"مخاطر (تسرب الغاز، تلف في الخدمات العامة...)": "gray",
|
58 |
+
}
|
59 |
+
|
60 |
+
ICON_MAPPING = {
|
61 |
+
"إغاثة": "bell", # life ring icon for rescue
|
62 |
+
"مساعدة طبية": "heart", # medical kit for medical assistance
|
63 |
+
"مأوى": "home", # home icon for shelter
|
64 |
+
"طعام وماء": "cutlery", # cutlery (fork and knife) for food & water
|
65 |
+
"مخاطر (تسرب الغاز، تلف في الخدمات العامة...)": "Warning" # warning triangle for dangers
|
66 |
+
}
|
67 |
+
|
68 |
+
CREDITS_TEXT = """
|
69 |
+
<hr>
|
70 |
+
<div style="text-align: center;">
|
71 |
+
<p>By <b>Moroccans</b> for <b>Moroccans</b> 🤝</p>
|
72 |
+
<p>Bot powered by <a href="https://www.annarabic.com/">Annarabic</a></p>
|
73 |
+
<p>Collaboration made possible thanks to <a href="https://summerschool.morocco.ai/">AI Summer School</a></p>
|
74 |
+
"""
|
75 |
+
|
76 |
+
LOGO = """
|
77 |
+
<style>
|
78 |
+
.block-container {
|
79 |
+
padding-top: 1rem;
|
80 |
+
padding-bottom: 0rem;
|
81 |
+
}
|
82 |
+
</style>
|
83 |
+
<div style="text-align: center;">
|
84 |
+
<img src="https://storage.googleapis.com/storage-annarabic/Nt3awnou(1).png" width="200" height="200">
|
85 |
+
</div>
|
86 |
+
"""
|
87 |
+
|
88 |
+
REVIEW_TEXT = """**If a request should be reviewed or dropped submit its id here/ إذا كان يجب مراجعة أو حذف طلب، أدخل رقمه هنا:**"""
|
src/utils.py
ADDED
@@ -0,0 +1,142 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import folium
|
2 |
+
import pandas as pd
|
3 |
+
from folium import plugins
|
4 |
+
from src.map_utils import legend_macro
|
5 |
+
|
6 |
+
|
7 |
+
EPICENTER_LOCATION = [31.12210171476489, -8.42945837915193]
|
8 |
+
BORDER_COLOR = "black"
|
9 |
+
|
10 |
+
def parse_gg_sheet(url):
|
11 |
+
url = url.replace("edit#gid=", "export?format=csv&gid=")
|
12 |
+
df = pd.read_csv(url, on_bad_lines="warn")
|
13 |
+
return df
|
14 |
+
|
15 |
+
# Session for Requests
|
16 |
+
# session = requests.Session()
|
17 |
+
# @st.cache_data(persist=True)
|
18 |
+
# def parse_latlng_from_link(url):
|
19 |
+
# try:
|
20 |
+
# # extract latitude and longitude from gmaps link
|
21 |
+
# if "@" not in url:
|
22 |
+
# resp = session.head(url, allow_redirects=True)
|
23 |
+
# url = resp.url
|
24 |
+
# latlng = url.split("@")[1].split(",")[0:2]
|
25 |
+
# return [float(latlng[0]), float(latlng[1])]
|
26 |
+
# except Exception as e:
|
27 |
+
# return None
|
28 |
+
|
29 |
+
def add_latlng_col(df, process_column):
|
30 |
+
"""Add a latlng column to the dataframe"""
|
31 |
+
df = df.assign(latlng=df.iloc[:, process_column].apply(parse_latlng))
|
32 |
+
return df
|
33 |
+
|
34 |
+
# parse latlng (column 4) to [lat, lng]
|
35 |
+
import re
|
36 |
+
def parse_latlng(latlng):
|
37 |
+
if pd.isna(latlng):
|
38 |
+
return None
|
39 |
+
# lat, lng = latlng.split(",")
|
40 |
+
# return [float(lat), float(lng)]
|
41 |
+
|
42 |
+
try:
|
43 |
+
# check if it matches (30.9529832, -7.1010705) or (30.9529832,-7.1010705)
|
44 |
+
if re.match(r"\(\d+\.\d+,\s?-\d+\.\d+\)", latlng):
|
45 |
+
lat, lng = latlng[1:-1].split(",")
|
46 |
+
return [float(lat), float(lng)]
|
47 |
+
# check of it matches 30.9529832, -7.1010705 or 30.9529832,-7.1010705
|
48 |
+
elif re.match(r"\d+\.\d+,\s?-\d+\.\d+", latlng):
|
49 |
+
lat, lng = latlng.split(",")
|
50 |
+
return [float(lat), float(lng)]
|
51 |
+
# check if it matches 30,9529832, -7,1010705 or 30,9529832,-7,1010705, match1=30,9529832 and match2=-7,1010705
|
52 |
+
elif re.match(r"\d+,\d+,\s?-\d+,\d+", latlng):
|
53 |
+
d1, d2, d3, d4 = latlng.split(",")
|
54 |
+
return [float(".".join([d1, d2])), float(".".join([d3, d4]))]
|
55 |
+
except Exception as e:
|
56 |
+
print(f"Error parsing latlng: {latlng} Reason: {e}")
|
57 |
+
return None
|
58 |
+
print(f"Error parsing latlng: {latlng}")
|
59 |
+
return None
|
60 |
+
|
61 |
+
def add_epicentre_to_map(map_obj):
|
62 |
+
icon_epicentre = folium.plugins.BeautifyIcon(
|
63 |
+
icon='spinner',
|
64 |
+
spin=True,
|
65 |
+
border_color='#b3334f',
|
66 |
+
background_color='#b3334f',
|
67 |
+
text_color='white'
|
68 |
+
)
|
69 |
+
folium.Marker(location=EPICENTER_LOCATION,
|
70 |
+
popup="Epicenter مركز الزلزال",
|
71 |
+
icon=icon_epicentre).add_to(map_obj)
|
72 |
+
|
73 |
+
|
74 |
+
def add_danger_distances_to_map(map_obj):
|
75 |
+
Danger_Distances_group = folium.FeatureGroup(name='Danger distances - earthquake magnitude 7 | مسافات الخطر - قوة الزلازل 7').add_to(map_obj)
|
76 |
+
|
77 |
+
zones = [
|
78 |
+
{"radius": 100000, "fill_opacity": 0.1, "weight": 1, "fill_color": "yellow", "tooltip": "50 to 100 km - Moderate risk area | منطقة خطر معتدلة"},
|
79 |
+
{"radius": 50000, "fill_opacity": 0.1, "weight": 1, "fill_color": "orange", "tooltip": "30 to 50 km - High risk zone | منطقة عالية المخاطر"},
|
80 |
+
{"radius": 30000, "fill_opacity": 0.2, "weight": 1, "fill_color": "#FF0000", "tooltip": "10 to 30 km - Very high risk zone | منطقة شديدة الخطورة"},
|
81 |
+
{"radius": 10000, "fill_opacity": 0.2, "weight": 0.2, "fill_color": "#8B0000", "tooltip": "0 to 10km - direct impact zone | منطقة التأثير المباشر"}
|
82 |
+
]
|
83 |
+
|
84 |
+
for zone in zones:
|
85 |
+
folium.Circle(
|
86 |
+
location=EPICENTER_LOCATION,
|
87 |
+
radius=zone["radius"],
|
88 |
+
color=BORDER_COLOR,
|
89 |
+
weight=zone["weight"],
|
90 |
+
fill_opacity=zone["fill_opacity"],
|
91 |
+
opacity=zone["fill_opacity"], # Assuming border opacity should match fill_opacity
|
92 |
+
fill_color=zone["fill_color"],
|
93 |
+
tooltip=zone["tooltip"],
|
94 |
+
).add_to(Danger_Distances_group)
|
95 |
+
|
96 |
+
|
97 |
+
def init_map():
|
98 |
+
m = folium.Map(
|
99 |
+
location=[31.228674, -7.992047],
|
100 |
+
zoom_start=8.5,
|
101 |
+
min_zoom=8.5,
|
102 |
+
max_lat=35.628674,
|
103 |
+
min_lat=29.628674,
|
104 |
+
max_lon=-4.992047,
|
105 |
+
min_lon=-10.992047,
|
106 |
+
max_bounds=True,
|
107 |
+
)
|
108 |
+
# Add a search bar to the map
|
109 |
+
plugins.Geocoder(
|
110 |
+
collapsed=False,
|
111 |
+
position="topright",
|
112 |
+
placeholder="Search | البحث",
|
113 |
+
).add_to(m)
|
114 |
+
|
115 |
+
# Add Fullscreen button to the map
|
116 |
+
plugins.Fullscreen(
|
117 |
+
position="topright",
|
118 |
+
title="Expand me | تكبير الخريطة",
|
119 |
+
title_cancel="Exit me | تصغير الخريطة",
|
120 |
+
force_separate_button=True,
|
121 |
+
).add_to(m)
|
122 |
+
|
123 |
+
# Satellite View from Mapbox
|
124 |
+
tileurl = "https://api.mapbox.com/styles/v1/phd2020/clmer2mra01d001pbgjkictpt/tiles/256/{z}/{x}/{y}@2x?access_token=pk.eyJ1IjoicGhkMjAyMCIsImEiOiJja29lZzFwZmUwNHkzMm5wMjZnYjVvcGltIn0.tE0ritrelQOyLdKUH6hgOw"
|
125 |
+
folium.TileLayer(
|
126 |
+
tiles=tileurl,
|
127 |
+
attr="Satellite View",
|
128 |
+
name="Satellite View | عرض القمر الصناعي",
|
129 |
+
overlay=False,
|
130 |
+
control=True,
|
131 |
+
).add_to(m)
|
132 |
+
|
133 |
+
# Add danger zones
|
134 |
+
add_epicentre_to_map(m)
|
135 |
+
add_danger_distances_to_map(m)
|
136 |
+
|
137 |
+
# Add a LayerControl to the map to toggle between layers (Satellite View and Default One)
|
138 |
+
folium.LayerControl().add_to(m)
|
139 |
+
|
140 |
+
# Macro to add legend
|
141 |
+
m.get_root().add_child(legend_macro)
|
142 |
+
return m
|