BCApis.Geocoding (bc_apis v0.1.0)
Geocoding service to convert city names to coordinates using Open-Meteo Geocoding API.
Open-Meteo provides free geocoding without requiring an API key.
Summary
Functions
Converts coordinates back to a location string for storage.
Converts a city name and country code to coordinates.
Get a list of major cities for a given country code. This is a simple static list - in a real application, you might want to use a more comprehensive database.
Functions
Converts coordinates back to a location string for storage.
Parameters
lat
: Latitude (float)lon
: Longitude (float)
Returns
- Location string in "lat,lon" format
@spec geocode_city(String.t(), String.t(), String.t()) :: {:ok, {float(), float()}} | {:error, term()}
Converts a city name and country code to coordinates.
Parameters
city
: City name (string)country_code
: ISO 3166 country code (string)api_key
: Not used (Open-Meteo is free and doesn't require API key)
Returns
{:ok, {lat, lon}}
on success{:error, reason}
on failure
Get a list of major cities for a given country code. This is a simple static list - in a real application, you might want to use a more comprehensive database.