From 88336110e07fd195d892c00b099f90b1cf91d2ea Mon Sep 17 00:00:00 2001 From: Ray Miller Date: Wed, 23 Dec 2020 08:25:57 +0000 Subject: [PATCH] Use district when county is not available. --- cmd/save-gob/main.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/cmd/save-gob/main.go b/cmd/save-gob/main.go index 63fe08b..73aac6c 100644 --- a/cmd/save-gob/main.go +++ b/cmd/save-gob/main.go @@ -26,7 +26,7 @@ func main() { b := placenames.NamedBoundary{ Name: r.Name, Type: r.LocalType, - County: r.CountyUnitary, + County: coalesce(r.CountyUnitary, r.DistrictBorough), Xmin: r.MbrXMin, Ymin: r.MbrYMin, Xmax: r.MbrXMax, @@ -41,3 +41,12 @@ func main() { log.Fatal(err) } } + +func coalesce(xs ...string) string { + for _, x := range xs { + if len(x) > 0 { + return x + } + } + return "" +}