geonames

package
v0.0.0-...-5f57c41 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2024 License: GPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AF = 6255146
	AS = 6255147
	EU = 6255148
	NA = 6255149
	OC = 6255151
	SA = 6255150
	AN = 6255152
)

Variables

View Source
var (
	ErrGeoNameNotReady = fmt.Errorf("geoname csv dump is %w", utils.ErrNotReady)
	ErrGeoNameDisabled = fmt.Errorf("geoname csv dump is %w", utils.ErrDisabled)
)

Functions

func GeoNameContinents

func GeoNameContinents() []*entity.GeoNameContinent

Types

type Continent

type Continent int

type CustomGeonamesEntity

type CustomGeonamesEntity struct {
	GeoNameID int    `json:"geoNameID"`
	Name      string `json:"name"`
}

type CustomGeonamesRecord

type CustomGeonamesRecord struct {
	City        CustomGeonamesEntity `json:"city"`
	Subdivision CustomGeonamesEntity `json:"subdivision"`
	Country     CustomGeonamesEntity `json:"country"`
	Continent   CustomGeonamesEntity `json:"continent"`
}

func NewCustomGeonamesRecord

func NewCustomGeonamesRecord(geoName string, geoNameID int) CustomGeonamesRecord

func (CustomGeonamesRecord) CityEntity

func (rec CustomGeonamesRecord) CityEntity() *entity.GeoName

func (CustomGeonamesRecord) ContinentEntity

func (rec CustomGeonamesRecord) ContinentEntity() *entity.GeoNameContinent

func (CustomGeonamesRecord) CountryEntity

func (rec CustomGeonamesRecord) CountryEntity() *entity.GeoNameCountry

func (CustomGeonamesRecord) SubdivisionEntity

func (rec CustomGeonamesRecord) SubdivisionEntity() *entity.GeoNameAdminSubdivision

type CustomStorage

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

func NewCustomStorage

func NewCustomStorage(records []CustomGeonamesRecord) *CustomStorage

func NewCustomStorageFromFile

func NewCustomStorageFromFile(path string) (*CustomStorage, error)

func (*CustomStorage) Cities

func (s *CustomStorage) Cities(_ context.Context, filter entity.GeoNameFilter) ([]*entity.GeoName, error)

func (*CustomStorage) Continents

func (s *CustomStorage) Continents(_ context.Context) []*entity.GeoNameContinent

func (*CustomStorage) Countries

func (*CustomStorage) Subdivisions

type GeoNameStorage

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

func NewStorage

func NewStorage(dir string) *GeoNameStorage

func (*GeoNameStorage) Cities

func (r *GeoNameStorage) Cities(ctx context.Context, filter entity.GeoNameFilter) ([]*entity.GeoName, error)

func (*GeoNameStorage) Continents

func (r *GeoNameStorage) Continents(ctx context.Context) []*entity.GeoNameContinent

func (*GeoNameStorage) Countries

func (r *GeoNameStorage) Countries(ctx context.Context, filter entity.GeoNameFilter) ([]*entity.GeoNameCountry, error)

func (*GeoNameStorage) Subdivisions

func (*GeoNameStorage) WaitReady

func (r *GeoNameStorage) WaitReady()

type MultiStorage

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

func NewMultiStorage

func NewMultiStorage(storages ...Storage) *MultiStorage

func (*MultiStorage) Add

func (s *MultiStorage) Add(storages ...Storage) *MultiStorage

func (*MultiStorage) Cities

func (s *MultiStorage) Cities(ctx context.Context, filter entity.GeoNameFilter) ([]*entity.GeoName, error)

func (*MultiStorage) Continents

func (s *MultiStorage) Continents(ctx context.Context) []*entity.GeoNameContinent

func (*MultiStorage) Countries

func (s *MultiStorage) Countries(ctx context.Context, filter entity.GeoNameFilter) ([]*entity.GeoNameCountry, error)

func (*MultiStorage) Subdivisions

type Storage

type Storage interface {
	Continents(ctx context.Context) []*entity.GeoNameContinent
	Countries(ctx context.Context, filter entity.GeoNameFilter) ([]*entity.GeoNameCountry, error)
	Subdivisions(ctx context.Context, filter entity.GeoNameFilter) ([]*entity.GeoNameAdminSubdivision, error)
	Cities(ctx context.Context, filter entity.GeoNameFilter) ([]*entity.GeoName, error)
}

func NewCustomStoragesFromDir

func NewCustomStoragesFromDir(dir, customStoragesPrefix string) []Storage

Jump to

Keyboard shortcuts

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