Metadata: Improve time zone estimates #914
This commit is contained in:
parent
019a649c61
commit
6ee2613e90
2 changed files with 16 additions and 10 deletions
|
@ -870,6 +870,20 @@ func (m *Photo) SetTakenAt(taken, local time.Time, zone, source string) {
|
|||
m.UpdateDateFields()
|
||||
}
|
||||
|
||||
// SetTimeZone updates the time zone.
|
||||
func (m *Photo) SetTimeZone(zone, source string) {
|
||||
if zone == "" {
|
||||
return
|
||||
}
|
||||
|
||||
if SrcPriority[source] < SrcPriority[m.TakenSrc] && m.TimeZone != "" {
|
||||
return
|
||||
}
|
||||
|
||||
m.TimeZone = zone
|
||||
m.TakenAt = m.GetTakenAt()
|
||||
}
|
||||
|
||||
// UpdateDateFields updates internal date fields.
|
||||
func (m *Photo) UpdateDateFields() {
|
||||
if m.TakenAt.IsZero() || m.TakenAt.Year() < 1000 {
|
||||
|
|
|
@ -77,21 +77,13 @@ func (m *Photo) EstimatePlace() {
|
|||
m.PlaceID = recentPhoto.PlaceID
|
||||
m.PhotoCountry = recentPhoto.PhotoCountry
|
||||
m.PlaceSrc = SrcEstimate
|
||||
|
||||
if m.TakenSrc != SrcManual {
|
||||
m.TimeZone = recentPhoto.TimeZone
|
||||
m.TakenAt = m.GetTakenAt()
|
||||
}
|
||||
m.SetTimeZone(recentPhoto.TimeZone, recentPhoto.TakenSrc)
|
||||
|
||||
log.Debugf("photo: approximate position of %s is %s (id %s)", m, txt.Quote(m.CountryName()), recentPhoto.PlaceID)
|
||||
} else if recentPhoto.HasCountry() {
|
||||
m.PhotoCountry = recentPhoto.PhotoCountry
|
||||
m.PlaceSrc = SrcEstimate
|
||||
|
||||
if m.TakenSrc != SrcManual {
|
||||
m.TimeZone = recentPhoto.TimeZone
|
||||
m.TakenAt = m.GetTakenAt()
|
||||
}
|
||||
m.SetTimeZone(recentPhoto.TimeZone, recentPhoto.TakenSrc)
|
||||
|
||||
log.Debugf("photo: probable country for %s is %s", m, txt.Quote(m.CountryName()))
|
||||
} else {
|
||||
|
|
Loading…
Reference in a new issue