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 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 country code for storage in the NeoFS location database.
func CountryCodeFromString ¶
func CountryCodeFromString(s string) (*CountryCode, error)
CountryCodeFromString parses string UN/LOCODE country code and returns CountryCode.
func CountryFromColumn ¶
func CountryFromColumn(cc *locodecolumn.CountryCode) (*CountryCode, error)
CountryFromColumn converts UN/LOCODE country code to 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 location's country code.
func (*Key) LocationCode ¶
func (k *Key) LocationCode() *LocationCode
LocationCode returns location code.
type LocationCode ¶
type LocationCode locodecolumn.LocationCode
LocationCode represents location code for storage in the NeoFS location database.
func LocationCodeFromString ¶
func LocationCodeFromString(s string) (*LocationCode, error)
LocationCodeFromString parses string UN/LOCODE location code and returns LocationCode.
func LocationFromColumn ¶
func LocationFromColumn(cc *locodecolumn.LocationCode) (*LocationCode, error)
LocationFromColumn converts UN/LOCODE country code to LocationCode.
func (*LocationCode) String ¶
func (l *LocationCode) String() string
type NamesDB ¶
type NamesDB interface { // Must resolve country code to country name. // // Must return ErrCountryNotFound if there is no // country with provided code. CountryName(*CountryCode) (string, error) // Must resolve (country code, subdivision code) to // 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 2D geographic point.
func PointFromCoordinates ¶
func PointFromCoordinates(crd *locodecolumn.Coordinates) (*Point, error)
PointFromCoordinates converts UN/LOCODE coordinates to Point.
type Record ¶
type Record struct {
// contains filtered or unexported fields
}
Record represents the entry in NeoFS location database.
func LocodeRecord ¶
LocodeRecord returns record from the NeoFS location database corresponding to string representation of UN/LOCODE.
func (*Record) CountryName ¶
CountryName returns country name.
func (*Record) LocationName ¶
LocationName returns location name.
func (*Record) SetContinent ¶
SetContinent sets location continent.
func (*Record) SetCountryName ¶
SetCountryName sets country name.
func (*Record) SetGeoPoint ¶
SetGeoPoint sets geo point of the location.
func (*Record) SetLocationName ¶
SetLocationName sets location name.
func (*Record) SetSubDivCode ¶
SetSubDivCode sets subdivision code.
func (*Record) SetSubDivName ¶
SetSubDivName sets subdivision name.
func (*Record) SubDivCode ¶
SubDivCode returns subdivision code.
func (*Record) SubDivName ¶
SubDivName returns subdivision name.