forked from TrueCloudLab/frostfs-locode-db
[#7] Add local tool for building database file
Added frostfs-locode-db CLI utility that can generate and view UN/LOCODE database files. Go package git.frostfs.info/TrueCloudLab/frostfs-node/pkg/util/locode copied to this repository to eliminate interdependency between frostfs-node and frostfs-locode-db projects. The process of building database files reduced to starting make command. Signed-off-by: George Bartolomey <george@bh4.ru>
This commit is contained in:
parent
7e523f1a28
commit
840b20538b
30 changed files with 2317 additions and 4 deletions
81
pkg/locode/db/continent.go
Normal file
81
pkg/locode/db/continent.go
Normal file
|
@ -0,0 +1,81 @@
|
|||
package locodedb
|
||||
|
||||
// Continent is an enumeration of Earth's continent.
|
||||
type Continent uint8
|
||||
|
||||
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
|
||||
)
|
||||
|
||||
// Is checks if c is the same continent as c2.
|
||||
func (c *Continent) Is(c2 Continent) bool {
|
||||
return *c == c2
|
||||
}
|
||||
|
||||
func (c Continent) String() string {
|
||||
switch c {
|
||||
case ContinentUnknown:
|
||||
fallthrough
|
||||
default:
|
||||
return "Unknown"
|
||||
case ContinentEurope:
|
||||
return "Europe"
|
||||
case ContinentAfrica:
|
||||
return "Africa"
|
||||
case ContinentNorthAmerica:
|
||||
return "North America"
|
||||
case ContinentSouthAmerica:
|
||||
return "South America"
|
||||
case ContinentAsia:
|
||||
return "Asia"
|
||||
case ContinentAntarctica:
|
||||
return "Antarctica"
|
||||
case ContinentOceania:
|
||||
return "Oceania"
|
||||
}
|
||||
}
|
||||
|
||||
// ContinentFromString returns Continent value
|
||||
// corresponding to the passed string representation.
|
||||
func ContinentFromString(str string) Continent {
|
||||
switch str {
|
||||
default:
|
||||
return ContinentUnknown
|
||||
case "Europe":
|
||||
return ContinentEurope
|
||||
case "Africa":
|
||||
return ContinentAfrica
|
||||
case "North America":
|
||||
return ContinentNorthAmerica
|
||||
case "South America":
|
||||
return ContinentSouthAmerica
|
||||
case "Asia":
|
||||
return ContinentAsia
|
||||
case "Antarctica":
|
||||
return ContinentAntarctica
|
||||
case "Oceania":
|
||||
return ContinentOceania
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue