Overview
GeocodingService is a Swift actor that provides geocoding functionality for city name searches. It uses the Open-Meteo Geocoding API to find cities by name and return their geographic coordinates and metadata.
BreezeApp/Services/GeocodingService.swift:4
Actor Isolation
This service is implemented as an actor to ensure thread-safe access to its methods and properties. All async methods are actor-isolated and can be safely called from any context.Shared Instance
Methods
searchCities
Search for cities by name and return matching results with geographic coordinates.String
required
The city name or partial name to search for. Must be at least 2 characters long.
[City] - An array of City objects containing:
- City name
- Country information
- Latitude and longitude coordinates
- Additional metadata (population, timezone, etc.)
URLError.badURL- If the URL cannot be constructedURLError.badServerResponse- If the server returns a non-200 status codeDecodingError- If the response cannot be decoded
name: The search query stringcount: Maximum number of results (set to 5)language: Language for results (set to “en” for English)format: Response format (set to “json”)