Documentation
¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Geocoder ¶
type Geocoder struct { Domain string UserAgent string Scheme string Timeout time.Duration Proxies map[string]string API string ReverseAPI string }
Geocoder represents a Nominatim geocoder with configuration options.
func NewGeocoder ¶
NewGeocoder initializes a new Geocoder instance with the specified user agent.
func (*Geocoder) Geocode ¶
Geocode performs a geocoding request to the Nominatim API with the specified query parameters. It returns either a single Location or a slice of Locations based on the exactlyOne parameter.
Example ¶
geocoder, err := NewGeocoder("zip_code_locator") if err != nil { fmt.Println("Error creating geocoder:", err) return } // Example querying by postal code query := map[string]string{ "postalcode": "90210", "country": "US", } result, err := geocoder.Geocode(query, true) if err != nil { fmt.Println("Error geocoding:", err) return } location, ok := result.(*Location) if !ok { fmt.Println("Error: expected *Location type") return } fmt.Printf("Location found: %s\n", location.DisplayName) fmt.Printf("Coordinates: %s, %s\n", location.Lat, location.Lon)
func (*Geocoder) Reverse ¶
Reverse performs a reverse geocoding request to the Nominatim API with the specified latitude and longitude.
Example ¶
geocoder, err := NewGeocoder("reverse_geocoder") if err != nil { fmt.Println("Error creating geocoder:", err) return } // Example reverse geocoding (Beverly Hills coordinates) lat, lon := 34.0736, -118.4004 location, err := geocoder.Reverse(lat, lon, true) if err != nil { fmt.Println("Error reverse geocoding:", err) return } fmt.Printf("Address: %s\n", location.DisplayName)
Click to show internal directories.
Click to hide internal directories.