feat: functional automatic geolocalisation
Browse files
app/geolocalisation/js_geolocation.py
CHANGED
@@ -37,20 +37,18 @@ js_geocode = """
|
|
37 |
|
38 |
def display_location(location_json, individual):
|
39 |
geo_dict = json.loads(location_json)
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
# def display_location(location_json):
|
56 |
-
# return location_json
|
|
|
37 |
|
38 |
def display_location(location_json, individual):
|
39 |
geo_dict = json.loads(location_json)
|
40 |
+
if "latitude" in geo_dict.keys():
|
41 |
+
latitude = geo_dict["latitude"]
|
42 |
+
longitude = geo_dict["longitude"]
|
43 |
+
geolocalisation = create_geolocalisation_object(latitude, longitude, "NA")
|
44 |
+
individual = save_geolocalisation_to_json(geolocalisation, individual)
|
45 |
+
geo_text = f"Latitude: {latitude} | Longitude: {longitude}"
|
46 |
+
else:
|
47 |
+
error = geo_dict["error"]
|
48 |
+
geo_text = f"Error occured ({error}). Give your browser permission to use your geolocalisation or change browsers."
|
49 |
+
locationtext = gr.Textbox(
|
50 |
+
geo_text,
|
51 |
+
visible=True,
|
52 |
+
show_label=False,
|
53 |
+
interactive=False)
|
54 |
+
return locationtext, individual
|
|
|
|
app/mode_simple.py
CHANGED
@@ -110,8 +110,7 @@ with gr.Blocks(theme='shivi/calm_seafoam') as simple:
|
|
110 |
btn_gpslocation.click(None, [], [], js=js_geocode)
|
111 |
hidden_input.change(display_location,
|
112 |
inputs=[hidden_input, individual],
|
113 |
-
|
114 |
-
outputs=[location_data, individual])
|
115 |
|
116 |
# ---------------------------------------------------------
|
117 |
# Dead and Wounded Buttons
|
|
|
110 |
btn_gpslocation.click(None, [], [], js=js_geocode)
|
111 |
hidden_input.change(display_location,
|
112 |
inputs=[hidden_input, individual],
|
113 |
+
outputs=[locationtext, individual])
|
|
|
114 |
|
115 |
# ---------------------------------------------------------
|
116 |
# Dead and Wounded Buttons
|
app/validation_submission/utils_individual.py
CHANGED
@@ -15,6 +15,6 @@ def add_data_to_individual(key, value, individual):
|
|
15 |
return individual
|
16 |
|
17 |
def reset_individual(individual):
|
18 |
-
individual =
|
19 |
return individual
|
20 |
|
|
|
15 |
return individual
|
16 |
|
17 |
def reset_individual(individual):
|
18 |
+
individual = {}
|
19 |
return individual
|
20 |
|