Time Zone Process Flow
Overall Flow
getTimeZone flow is consists of the following steps.
Identify the City Name using from raw speech communicated by Human
Get the Latitude and Longitude of the City Name.
Get the Time Zone
Identify the City Name
Once the getTimeZone flow is triggered raw speech is passed to geography package geoPlace Function to identify the place from the raw speech.
Once the location is identified, GetCityName flow is used to get the name of the city from places list. First occurrence of the city is selected.
In case of no city identified, an exception is raised and is handled by defaulting the city to home city.
Identify Latitude and Longitude
geoLocateLatitudeLongitude flow is executed to Identify the Latitude and Longitude, City Name is passed to geopy package to identify the Latitude and Longitude of the given City.
How it works using geopy?
Once geopy package is installed.
Import Nominatim from geopy- Nominatim is a free service or tool or can be called as API with no keys that provides you with the data after providing it with name and address and vice versa.
On calling Nomination tool which accepts an argument of user_agent you can give any name as it considers it to be the name of the app to which it is providing its services. Here we are using user_agent Name as Aryan.
The geocode() function accepts the location name and returns a geodataframe that has all the details and since it’s a dataframe we can get the address, latitude and longitude by simply calling it as in snippet below.
Get Time Zone using Latitude and Longitude
Once Latitude and Longitude are Identified getTimeZoneValue flow is executed and using tzwhere package time zone is identified and returned to the user for the requested place
Time Zone is returned to the user and Control passed to NextStep.
Last updated
Was this helpful?