Use district when county is not available.

This commit is contained in:
Ray Miller 2020-12-23 08:25:57 +00:00
parent af15ee6707
commit 88336110e0

View file

@ -26,7 +26,7 @@ func main() {
b := placenames.NamedBoundary{ b := placenames.NamedBoundary{
Name: r.Name, Name: r.Name,
Type: r.LocalType, Type: r.LocalType,
County: r.CountyUnitary, County: coalesce(r.CountyUnitary, r.DistrictBorough),
Xmin: r.MbrXMin, Xmin: r.MbrXMin,
Ymin: r.MbrYMin, Ymin: r.MbrYMin,
Xmax: r.MbrXMax, Xmax: r.MbrXMax,
@ -41,3 +41,12 @@ func main() {
log.Fatal(err) log.Fatal(err)
} }
} }
func coalesce(xs ...string) string {
for _, x := range xs {
if len(x) > 0 {
return x
}
}
return ""
}