2019-12-20 11:30:58 +01:00
|
|
|
package osm
|
|
|
|
|
|
|
|
import (
|
|
|
|
"strings"
|
|
|
|
|
|
|
|
"github.com/photoprism/photoprism/internal/util"
|
|
|
|
)
|
|
|
|
|
|
|
|
var labelTitles = map[string]string{
|
2019-12-21 17:24:29 +01:00
|
|
|
"airport": "Airport",
|
2019-12-20 20:23:16 +01:00
|
|
|
"visitor center": "Visitor Center",
|
2019-12-20 11:30:58 +01:00
|
|
|
}
|
|
|
|
|
2019-12-27 05:18:52 +01:00
|
|
|
func (o Location) Name() (result string) {
|
2019-12-20 23:05:44 +01:00
|
|
|
result = o.Category()
|
2019-12-20 11:30:58 +01:00
|
|
|
|
|
|
|
if title, ok := labelTitles[result]; ok {
|
2019-12-27 05:18:52 +01:00
|
|
|
title = strings.Replace(title, "%name%", o.LocName, 1)
|
2019-12-20 11:30:58 +01:00
|
|
|
return title
|
|
|
|
}
|
|
|
|
|
2019-12-27 05:18:52 +01:00
|
|
|
if o.LocName != "" {
|
|
|
|
result = o.LocName
|
2019-12-20 11:30:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
result = strings.Replace(result, "_", " ", -1)
|
|
|
|
|
|
|
|
if i := strings.Index(result, " - "); i > 1 {
|
|
|
|
result = result[:i]
|
|
|
|
}
|
|
|
|
|
|
|
|
if i := strings.Index(result, ","); i > 1 {
|
|
|
|
result = result[:i]
|
|
|
|
}
|
|
|
|
|
|
|
|
return util.Title(strings.TrimSpace(result))
|
|
|
|
}
|