Metadata: Improve time zone estimates #914

This commit is contained in:
Michael Mayer 2021-01-19 13:47:41 +01:00
parent 019a649c61
commit 6ee2613e90
2 changed files with 16 additions and 10 deletions

View file

@ -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 {

View file

@ -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 {