File size: 1,208 Bytes
cb23aba
 
8f0e835
cb23aba
 
8f0e835
cb23aba
 
 
 
 
 
 
 
 
8f0e835
 
 
 
 
cb23aba
 
 
 
 
 
 
8f0e835
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
from geopy.geocoders import Nominatim
import gradio as gr
from utils_json import add_data_to_individual
 
def get_location(address):
    # try: 
        # calling the Nominatim tool
        loc = Nominatim(user_agent="GetLoc")
        
        # entering the location name
        getLoc = loc.geocode(address)
        
        # latitude and longitude
        lat = getLoc.latitude
        lon = getLoc.longitude

        # Save values
        add_data_to_individual("latitude", lat)
        add_data_to_individual("longitude", lon)

        #display location processing
        value = "Latitude = " + str(lat) + "\n" + "Longitude = " + str(lon)
        identified_location= gr.Textbox(visible=True, interactive=False, 
                                        label="Identified GPS Location", 
                                        value=value)
        return identified_location
    
    # except:
    #     error = "Please try another less precise location."
    #     identified_location= gr.Textbox(visible=True, interactive=False, 
    #                                     label="Identified GPS Location", 
    #                                     value=error)
    #     return identified_location