Documentation ¶
Index ¶
- Constants
- Variables
- func FillDatabase(table SourceTable, airports AirportDB, continents ContinentsDB, names NamesDB, ...) error
- type AirportDB
- type AirportRecord
- type Continent
- type ContinentsDB
- type CountryCode
- type DB
- type Key
- type LocationCode
- type NamesDB
- type Point
- type Record
- func (r *Record) Continent() *Continent
- func (r *Record) CountryName() string
- func (r *Record) GeoPoint() *Point
- func (r *Record) LocationName() string
- func (r *Record) SetContinent(c *Continent)
- func (r *Record) SetCountryName(name string)
- func (r *Record) SetGeoPoint(p *Point)
- func (r *Record) SetLocationName(name string)
- func (r *Record) SetSubDivCode(name string)
- func (r *Record) SetSubDivName(name string)
- func (r *Record) SubDivCode() string
- func (r *Record) SubDivName() string
- type SourceTable
Constants ¶
const ( // ContinentUnknown is an undefined Continent value. ContinentUnknown = iota // ContinentEurope corresponds to Europe. ContinentEurope // ContinentAfrica corresponds to Africa. ContinentAfrica // ContinentNorthAmerica corresponds to North America. ContinentNorthAmerica // ContinentSouthAmerica corresponds to South America. ContinentSouthAmerica // ContinentAsia corresponds to Asia. ContinentAsia // ContinentAntarctica corresponds to Antarctica. ContinentAntarctica // ContinentOceania corresponds to Oceania. ContinentOceania )
Variables ¶
var ErrAirportNotFound = errors.New("airport not found")
ErrAirportNotFound is returned by AirportRecord readers when the required airport is not found.
var ErrCountryNotFound = errors.New("country not found")
var ErrSubDivNotFound = errors.New("subdivision not found")
Functions ¶
func FillDatabase ¶
func FillDatabase(table SourceTable, airports AirportDB, continents ContinentsDB, names NamesDB, db DB) error
FillDatabase generates the NeoFS location database based on the UN/LOCODE table.
Types ¶
type AirportDB ¶
type AirportDB interface { // Must return the record by UN/LOCODE table record. // // Must return ErrAirportNotFound if there is no // related airport in the database. Get(locode.Record) (*AirportRecord, error) }
AirportDB is an interface of NeoFS airport database.
type AirportRecord ¶
type AirportRecord struct { // Name of the country where airport is located. CountryName string // Geo point where airport is located. Point *Point }
AirportRecord represents the entry in NeoFS airport database.
type Continent ¶
type Continent uint8
Continent is an enumeration of Earth's continent.
func ContinentFromString ¶
ContinentFromString returns Continent value corresponding to the passed string representation.
type ContinentsDB ¶
type ContinentsDB interface { // Must return continent of the geo point. PointContinent(*Point) (*Continent, error) }
ContinentsDB is an interface of NeoFS continent database.
type CountryCode ¶
type CountryCode locodecolumn.CountryCode
CountryCode represents a country code for the storage in the NeoFS location database.
func CountryCodeFromString ¶
func CountryCodeFromString(s string) (*CountryCode, error)
CountryCodeFromString parses a string UN/LOCODE country code and returns a CountryCode.
func CountryFromColumn ¶
func CountryFromColumn(cc *locodecolumn.CountryCode) (*CountryCode, error)
CountryFromColumn converts a UN/LOCODE country code to a CountryCode.
func (*CountryCode) String ¶
func (c *CountryCode) String() string
type DB ¶
type DB interface { // Must save the record by key in the database. Put(Key, Record) error // Must return the record by key from the database. Get(Key) (*Record, error) }
DB is an interface of NeoFS location database.
type Key ¶
type Key struct {
// contains filtered or unexported fields
}
Key represents the key in NeoFS location database.
func (*Key) CountryCode ¶
func (k *Key) CountryCode() *CountryCode
CountryCode returns the location's country code.
func (*Key) LocationCode ¶
func (k *Key) LocationCode() *LocationCode
LocationCode returns the location code.
type LocationCode ¶
type LocationCode locodecolumn.LocationCode
LocationCode represents a location code for the storage in the NeoFS location database.
func LocationCodeFromString ¶
func LocationCodeFromString(s string) (*LocationCode, error)
LocationCodeFromString parses a string UN/LOCODE location code and returns a LocationCode.
func LocationFromColumn ¶
func LocationFromColumn(cc *locodecolumn.LocationCode) (*LocationCode, error)
LocationFromColumn converts a UN/LOCODE country code to a LocationCode.
func (*LocationCode) String ¶
func (l *LocationCode) String() string
type NamesDB ¶
type NamesDB interface { // Must resolve a country code to a country name. // // Must return ErrCountryNotFound if there is no // country with the provided code. CountryName(*CountryCode) (string, error) // Must resolve (country code, subdivision code) to // a subdivision name. // // Must return ErrSubDivNotFound if either country or // subdivision is not presented in database. SubDivName(*CountryCode, string) (string, error) }
NamesDB is an interface of the NeoFS location namespace.
type Point ¶
type Point struct {
// contains filtered or unexported fields
}
Point represents a 2D geographic point.
func PointFromCoordinates ¶
func PointFromCoordinates(crd *locodecolumn.Coordinates) (*Point, error)
PointFromCoordinates converts a UN/LOCODE coordinates to a Point.
type Record ¶
type Record struct {
// contains filtered or unexported fields
}
Record represents the entry in NeoFS location database.
func LocodeRecord ¶
LocodeRecord returns the record from the NeoFS location database corresponding to the string representation of UN/LOCODE.
func (*Record) CountryName ¶
CountryName returns the country name.
func (*Record) LocationName ¶
LocationName returns the location name.
func (*Record) SetContinent ¶
SetContinent sets the location continent.
func (*Record) SetCountryName ¶
SetCountryName sets the country name.
func (*Record) SetGeoPoint ¶
SetGeoPoint sets geo point of the location.
func (*Record) SetLocationName ¶
SetLocationName sets the location name.
func (*Record) SetSubDivCode ¶
SetSubDivCode sets the subdivision code.
func (*Record) SetSubDivName ¶
SetSubDivName sets the subdivision name.
func (*Record) SubDivCode ¶
SubDivCode returns the subdivision code.
func (*Record) SubDivName ¶
SubDivName returns the subdivision name.