Class GeoLocator
- Namespace
- SimpleWeather
- Assembly
- SimpleWeather.dll
Provides helper methods for interacting with the OpenWeather geocoding APIs.
public class GeoLocator
- Inheritance
-
GeoLocator
- Inherited Members
Constructors
GeoLocator(string?)
Provides helper methods for interacting with the OpenWeather geocoding APIs.
public GeoLocator(string? apiKey = null)
Parameters
apiKeystringOptional API key used when issuing HTTP requests.
Methods
GetCitiesByNameAsync(string, string?, string?, CancellationToken)
Retrieves up to five matching cities based on name, state, and country filters.
public Task<List<string>> GetCitiesByNameAsync(string cityName, string? stateCode = null, string? countryCode = null, CancellationToken cancellationToken = default)
Parameters
cityNamestringThe city name to look up.
stateCodestringOptional ISO state code used for disambiguation.
countryCodestringOptional ISO country code used for disambiguation.
cancellationTokenCancellationTokenToken used to cancel the HTTP request.
Returns
GetCityNameByCoordinatesAsync(LatLong, CancellationToken)
Looks up the city name for the supplied coordinate pair.
public Task<string?> GetCityNameByCoordinatesAsync(LatLong latLong, CancellationToken cancellationToken = default)
Parameters
latLongLatLongThe latitude and longitude to reverse geocode.
cancellationTokenCancellationTokenToken used to cancel the HTTP request.
Returns
GetCityNameByCoordinatesAsync(double, double, CancellationToken)
Looks up the city name for the supplied latitude/longitude pair.
public Task<string?> GetCityNameByCoordinatesAsync(double lat, double lon, CancellationToken cancellationToken = default)
Parameters
latdoubleThe latitude to reverse geocode.
londoubleThe longitude to reverse geocode.
cancellationTokenCancellationTokenToken used to cancel the HTTP request.
Returns
GetCoordinatesByCityNameAsync(string, string?, string?, CancellationToken)
Retrieves the first set of coordinates that matches the supplied city filters.
public Task<LatLong?> GetCoordinatesByCityNameAsync(string cityName, string? stateCode = null, string? countryCode = null, CancellationToken cancellationToken = default)
Parameters
cityNamestringThe city name to look up.
stateCodestringOptional ISO state code used for disambiguation.
countryCodestringOptional ISO country code used for disambiguation.
cancellationTokenCancellationTokenToken used to cancel the HTTP request.
Returns
GetCoordinatesByPostCodeAsync(string, string, CancellationToken)
Retrieves coordinates by postal or ZIP code.
public Task<LatLong?> GetCoordinatesByPostCodeAsync(string postCode, string countryCode, CancellationToken cancellationToken = default)
Parameters
postCodestringThe postal or ZIP code.
countryCodestringThe ISO country code the postal code belongs to.
cancellationTokenCancellationTokenToken used to cancel the HTTP request.