2019-12-20 11:30:58 +01:00
|
|
|
package osm
|
|
|
|
|
|
|
|
import (
|
|
|
|
"strings"
|
|
|
|
|
2020-01-07 17:36:49 +01:00
|
|
|
"github.com/photoprism/photoprism/internal/txt"
|
2019-12-20 11:30:58 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
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-31 07:16:11 +01:00
|
|
|
func (l Location) Name() (result string) {
|
|
|
|
result = l.Category()
|
2019-12-20 11:30:58 +01:00
|
|
|
|
|
|
|
if title, ok := labelTitles[result]; ok {
|
2019-12-31 07:16:11 +01:00
|
|
|
title = strings.Replace(title, "%name%", l.LocName, 1)
|
2019-12-20 11:30:58 +01:00
|
|
|
return title
|
|
|
|
}
|
|
|
|
|
2019-12-31 07:16:11 +01:00
|
|
|
if l.LocName != "" {
|
|
|
|
result = l.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]
|
|
|
|
}
|
|
|
|
|
2020-01-07 17:36:49 +01:00
|
|
|
return txt.Title(strings.TrimSpace(result))
|
2019-12-20 11:30:58 +01:00
|
|
|
}
|