geonames

package
v0.0.17 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2022 License: GPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client added in v0.0.6

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

Client for GeoNames

func NewClient added in v0.0.6

func NewClient(ctx context.Context, uri string, countries ...string) (*Client, error)

NewClient Creates a new GeoNames client

func (*Client) Get added in v0.0.6

func (c *Client) Get(id LocationId) (*Location, error)

Get a location

type Coordinate

type Coordinate struct {
	Latitude  float64
	Longitude float64
}

Coordinate represents a lat long coordinate

type Location

type Location struct {
	Coordinate
	Country      country.Country `db:"country"`
	PostalCode   string          `db:"postal_code"`
	City         string          `db:"city"`
	Subdivision1 string          `db:"subdivision1"`
	Subdivision2 string          `db:"subdivision2"`
	// contains filtered or unexported fields
}

Location is an instance of a GeoNames location

func (*Location) Add

func (l *Location) Add(loc *Location)

Add to the envelope

func (*Location) Center

func (l *Location) Center() Coordinate

Center of the envelope

func (*Location) Radius

func (l *Location) Radius() float64

Radius of the envelope

type LocationId

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

LocationId is the id for the location

func City

func City(country country.Country, primary, city string) LocationId

City creates a city location id

func Country

func Country(country country.Country) LocationId

Country creates a country location id

func PostalCode

func PostalCode(country country.Country, postalCode string) LocationId

PostalCode creates an instance of the postal code location id

func Primary

func Primary(country country.Country, subdivision1 string) LocationId

Primary creates a first order subdivision location id

func Secondary

func Secondary(country country.Country, subdivision1, subdivision2 string) LocationId

Secondary creates a Secondary location id

func (LocationId) IsCity

func (id LocationId) IsCity() bool

IsCity checks if id is of city type

func (LocationId) IsCountry

func (id LocationId) IsCountry() bool

IsCountry checks if id is of country type

func (LocationId) IsPostal

func (id LocationId) IsPostal() bool

IsPostal checks if id is of postal type

func (LocationId) IsPrimary

func (id LocationId) IsPrimary() bool

IsPrimary checks if id is of Primary type

func (LocationId) IsSecondary

func (id LocationId) IsSecondary() bool

IsSecondary checks if id is of Secondary type

Jump to

Keyboard shortcuts

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