geo

package
v0.2.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 24, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient(opts *ClientOptions) *Client

func (*Client) Direct

func (c *Client) Direct(query string, opts *GeoOptions) (*GeoResponse, error)

Direct returns coordinates by location name The query should be the city name, state code (only for the US) and country code divided by comma. Please use ISO 3166 country codes.

func (*Client) Reverse

func (c *Client) Reverse(lat, lon float64, opts *GeoOptions) (*GeoResponse, error)

Reverse geocoding allows to get name of the location (city name or area name) by using geographical coordinates (lat, lon). The limit parameter in the API call allows you to cap how many location names you will see in the API response.

type ClientOptions

type ClientOptions struct {
	HttpClient *http.Client
	AppID      string // Your OpenWeather API key. May also be set as environment variable.
	Logger     *slog.Logger
}

type GeoData

type GeoData struct {
	Name    string  `json:"name"`    // Name of the found location
	Lat     float64 `json:"lat"`     // Geographical coordinates of the found location (latitude)
	Lon     float64 `json:"lon"`     // Geographical coordinates of the found location (longitude)
	Country string  `json:"country"` // Country of the found location
	State   string  `json:"state"`   // (where available) State of the found location

	// Name of the found location in different languages.
	// The list of names can be different for different locations.
	// Note: The key seem to be ISO 639 language codes
	LocalNames map[string]string `json:"local_names"`
}

type GeoOptions

type GeoOptions struct {
	Limit      int // Number of the locations in the API response.
	SaveAsJson string
}

type GeoResponse

type GeoResponse struct {
	Data []GeoData
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL