Documentation
¶
Overview ¶
Package locodedb implements a UN LOCODE database.
It contains all the data internally and provides simple Get API to retrieve records based on short LOCODE strings. The DB is stored compressed before the first use (~1MB) and is unpacked automatically on the first access (which takes ~100-200ms). Unpacked it needs ~4MB of RAM.
Index ¶
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 )
const CountryCodeLen = 2
CountryCodeLen is the length of the country code.
const LocationCodeLen = 3
LocationCodeLen is the length of the location code.
Variables ¶
var ErrInvalidString = errors.New("invalid string format in UN/Locode")
ErrInvalidString is returned when the string is not a valid location code.
var ErrNotFound = errors.New("record not found")
ErrNotFound is returned when the record is not found in the location database.
Functions ¶
This section is empty.
Types ¶
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 Record ¶
type Record struct { Country string Location string SubDivName string SubDivCode string Point Point Cont Continent }
Record represents a record in the location database (resulting CSV files). It contains all the information about the location. It is used to fill the database. Country, Location are full names, codes are in Key.