geonames

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2021 License: GPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// NumColumns is expected number of columns in GeoNames csv
	NumColumns = 12
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Coordinate

type Coordinate struct {
	Latitude  float64
	Longitude float64
}

Coordinate represents a lat long coordinate

type DB

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

DB for geonames

func Open

func Open(ctx context.Context, uri string) (*DB, error)

Open geonames db

func (*DB) Get

func (db *DB) Get(id LocationId) (*Location, error)

Get for locations

type Location

type Location struct {
	Coordinate
	Country      string
	PostalCode   string
	City         string
	Subdivision1 string
	Subdivision2 string
	// 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 {
	Primary   string
	Secondary string
	// contains filtered or unexported fields
}

LocationId is the id for the location

func City

func City(country, Primary, city string) LocationId

City creates a city location id

func Country

func Country(country string) LocationId

Country creates a country location id

func ParseId

func ParseId(s string) (LocationId, error)

ParseId parses a location string

func PostalCode

func PostalCode(country, postalCode string) LocationId

PostalCode creates an instance of the postal code location id

func Primary

func Primary(country, subdivision1 string) LocationId

Primary creates a first order subdivision location id

func Secondary

func Secondary(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

func (LocationId) String

func (id LocationId) String() string

Jump to

Keyboard shortcuts

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