forked from TrueCloudLab/frostfs-node
[#316] locode/boltdb: Replace all references to the City with Location
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
0a87fec6c6
commit
9a425924cf
4 changed files with 27 additions and 27 deletions
|
@ -164,7 +164,7 @@ var (
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Printf("Country: %s\n", record.CountryName())
|
fmt.Printf("Country: %s\n", record.CountryName())
|
||||||
fmt.Printf("City: %s\n", record.CityName())
|
fmt.Printf("Location: %s\n", record.LocationName())
|
||||||
fmt.Printf("Continent: %s\n", record.Continent())
|
fmt.Printf("Continent: %s\n", record.Continent())
|
||||||
if subDivCode := record.SubDivCode(); subDivCode != "" {
|
if subDivCode := record.SubDivCode(); subDivCode != "" {
|
||||||
fmt.Printf("Subdivision: [%s] %s\n", subDivCode, record.SubDivName())
|
fmt.Printf("Subdivision: [%s] %s\n", subDivCode, record.SubDivName())
|
||||||
|
|
|
@ -30,7 +30,7 @@ type locodeBoltEntryWrapper struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *locodeBoltEntryWrapper) LocationName() string {
|
func (l *locodeBoltEntryWrapper) LocationName() string {
|
||||||
return l.Record.CityName()
|
return l.Record.LocationName()
|
||||||
}
|
}
|
||||||
|
|
||||||
type locodeBoltDBWrapper locodebolt.DB
|
type locodeBoltDBWrapper locodebolt.DB
|
||||||
|
|
|
@ -48,26 +48,26 @@ func locationBucketKey(lc *locodedb.LocationCode) ([]byte, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
type recordJSON struct {
|
type recordJSON struct {
|
||||||
CountryName string
|
CountryName string
|
||||||
CityName string
|
LocationName string
|
||||||
SubDivName string
|
SubDivName string
|
||||||
SubDivCode string
|
SubDivCode string
|
||||||
Latitude float64
|
Latitude float64
|
||||||
Longitude float64
|
Longitude float64
|
||||||
Continent string
|
Continent string
|
||||||
}
|
}
|
||||||
|
|
||||||
func recordValue(r locodedb.Record) ([]byte, error) {
|
func recordValue(r locodedb.Record) ([]byte, error) {
|
||||||
p := r.GeoPoint()
|
p := r.GeoPoint()
|
||||||
|
|
||||||
rj := &recordJSON{
|
rj := &recordJSON{
|
||||||
CountryName: r.CountryName(),
|
CountryName: r.CountryName(),
|
||||||
CityName: r.CityName(),
|
LocationName: r.LocationName(),
|
||||||
SubDivName: r.SubDivName(),
|
SubDivName: r.SubDivName(),
|
||||||
SubDivCode: r.SubDivCode(),
|
SubDivCode: r.SubDivCode(),
|
||||||
Latitude: p.Latitude(),
|
Latitude: p.Latitude(),
|
||||||
Longitude: p.Longitude(),
|
Longitude: p.Longitude(),
|
||||||
Continent: r.Continent().String(),
|
Continent: r.Continent().String(),
|
||||||
}
|
}
|
||||||
|
|
||||||
return json.Marshal(rj)
|
return json.Marshal(rj)
|
||||||
|
@ -82,7 +82,7 @@ func recordFromValue(data []byte) (*locodedb.Record, error) {
|
||||||
|
|
||||||
r := new(locodedb.Record)
|
r := new(locodedb.Record)
|
||||||
r.SetCountryName(rj.CountryName)
|
r.SetCountryName(rj.CountryName)
|
||||||
r.SetCityName(rj.CityName)
|
r.SetLocationName(rj.LocationName)
|
||||||
r.SetSubDivName(rj.SubDivName)
|
r.SetSubDivName(rj.SubDivName)
|
||||||
r.SetSubDivCode(rj.SubDivCode)
|
r.SetSubDivCode(rj.SubDivCode)
|
||||||
r.SetGeoPoint(locodedb.NewPoint(rj.Latitude, rj.Longitude))
|
r.SetGeoPoint(locodedb.NewPoint(rj.Latitude, rj.Longitude))
|
||||||
|
|
|
@ -45,7 +45,7 @@ func (k *Key) LocationCode() *LocationCode {
|
||||||
type Record struct {
|
type Record struct {
|
||||||
countryName string
|
countryName string
|
||||||
|
|
||||||
cityName string
|
locationName string
|
||||||
|
|
||||||
subDivName string
|
subDivName string
|
||||||
|
|
||||||
|
@ -71,9 +71,9 @@ func NewRecord(r locode.Record) (*Record, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
return &Record{
|
return &Record{
|
||||||
cityName: r.NameWoDiacritics,
|
locationName: r.NameWoDiacritics,
|
||||||
subDivCode: r.SubDiv,
|
subDivCode: r.SubDiv,
|
||||||
p: point,
|
p: point,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -87,14 +87,14 @@ func (r *Record) SetCountryName(name string) {
|
||||||
r.countryName = name
|
r.countryName = name
|
||||||
}
|
}
|
||||||
|
|
||||||
// CityName returns city name.
|
// LocationName returns location name.
|
||||||
func (r *Record) CityName() string {
|
func (r *Record) LocationName() string {
|
||||||
return r.cityName
|
return r.locationName
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetCityName sets city name.
|
// SetLocationName sets location name.
|
||||||
func (r *Record) SetCityName(name string) {
|
func (r *Record) SetLocationName(name string) {
|
||||||
r.cityName = name
|
r.locationName = name
|
||||||
}
|
}
|
||||||
|
|
||||||
// SubDivCode returns subdivision code.
|
// SubDivCode returns subdivision code.
|
||||||
|
|
Loading…
Reference in a new issue