diff --git a/internal/form/search_photos.go b/internal/form/search_photos.go index ef72c2355..3e1d7bc6d 100644 --- a/internal/form/search_photos.go +++ b/internal/form/search_photos.go @@ -48,7 +48,7 @@ type SearchPhotos struct { Olc string `form:"olc" example:"olc:8FWCHX7W+" notes:"OLC Position (Open Location Code)"` Lat float64 `form:"lat" example:"lat:41.894043" notes:"GPS Position (Latitude)"` Lng float64 `form:"lng" example:"lng:-87.62448" notes:"GPS Position (Longitude)"` - Alt string `form:"alt" example:"alt:300-500" notes:"GPS Altitude Range"` + Alt string `form:"alt" example:"alt:300-500" notes:"GPS Altitude (m)"` Dist float64 `form:"dist" example:"dist:50" notes:"Distance to Position (km)"` Latlng string `form:"latlng" notes:"GPS Bounding Box (Lat N, Lng E, Lat S, Lng W)"` Fmin float32 `form:"fmin" notes:"F-number (min)"` @@ -79,9 +79,9 @@ type SearchPhotos struct { Review bool `form:"review" notes:"Finds pictures in review"` // Find photos in review Camera string `form:"camera" example:"camera:canon" notes:"Camera Make/Model Name"` // Camera UID or name Lens string `form:"lens" example:"lens:ef24" notes:"Lens Make/Model Name"` // Lens UID or name - Iso string `form:"iso" example:"iso:200-400" notes:"ISO Range"` - F string `form:"f" example:"f:2.8-4.5" notes:"F-Number Range"` - Mm string `form:"mm" example:"mm:28-35" notes:"Focal Length Range"` + Iso string `form:"iso" example:"iso:200-400" notes:"ISO Number (light sensitivity)"` + Mm string `form:"mm" example:"mm:28-35" notes:"Focal Length (35mm equivalent)"` + F string `form:"f" example:"f:2.8-4.5" notes:"Aperture (f-number)"` Before time.Time `form:"before" time_format:"2006-01-02" notes:"Finds pictures taken before this date"` // Finds images taken before date After time.Time `form:"after" time_format:"2006-01-02" notes:"Finds pictures taken after this date"` // Finds images taken after date Count int `form:"count" binding:"required" serialize:"-"` // Result FILE limit diff --git a/internal/form/search_photos_geo.go b/internal/form/search_photos_geo.go index 07b09a6b5..7c8039a5a 100644 --- a/internal/form/search_photos_geo.go +++ b/internal/form/search_photos_geo.go @@ -46,8 +46,8 @@ type SearchPhotosGeo struct { Olc string `form:"olc" example:"olc:8FWCHX7W+" notes:"OLC Position (Open Location Code)"` Lat float64 `form:"lat" example:"lat:41.894043" notes:"GPS Position (Latitude)"` Lng float64 `form:"lng" example:"lng:-87.62448" notes:"GPS Position (Longitude)"` + Alt string `form:"alt" example:"alt:300-500" notes:"GPS Altitude (m)"` Dist float64 `form:"dist" example:"dist:50" notes:"Distance to Position (km)"` - Alt string `form:"alt" example:"alt:300-500" notes:"GPS Altitude Range"` Latlng string `form:"latlng" notes:"GPS Bounding Box (Lat N, Lng E, Lat S, Lng W)"` Person string `form:"person"` // Alias for Subject Subjects string `form:"subjects"` // Text @@ -68,9 +68,9 @@ type SearchPhotosGeo struct { Color string `form:"color"` Camera int `form:"camera"` Lens int `form:"lens"` - Iso string `form:"iso" example:"iso:200-400" notes:"ISO Range"` - F string `form:"f" example:"f:2.8-4.5" notes:"F-Number Range"` - Mm string `form:"mm" example:"mm:28-35" notes:"Focal Length Range"` + Iso string `form:"iso" example:"iso:200-400" notes:"ISO Number (light sensitivity)"` + Mm string `form:"mm" example:"mm:28-35" notes:"Focal Length (35mm equivalent)"` + F string `form:"f" example:"f:2.8-4.5" notes:"Aperture (f-number)"` Count int `form:"count" serialize:"-"` Offset int `form:"offset" serialize:"-"` } diff --git a/internal/search/photos.go b/internal/search/photos.go index e3c2ca232..12bb772dc 100644 --- a/internal/search/photos.go +++ b/internal/search/photos.go @@ -494,21 +494,21 @@ func searchPhotos(f form.SearchPhotos, sess *entity.Session, resultCols string) s = s.Where("lenses.lens_name LIKE ? OR lenses.lens_model LIKE ? OR lenses.lens_slug LIKE ?", v, v, v) } - // Filter by ISO Range. + // Filter by ISO Number (light sensitivity) range. if rangeStart, rangeEnd, rangeErr := txt.IntRange(f.Iso, 0, 10000000); rangeErr == nil { s = s.Where("photos.photo_iso >= ? AND photos.photo_iso <= ?", rangeStart, rangeEnd) } - // Filter by F-Number Range. - if rangeStart, rangeEnd, rangeErr := txt.FloatRange(f.F, 0, 10000000); rangeErr == nil { - s = s.Where("photos.photo_f_number >= ? AND photos.photo_f_number <= ?", rangeStart-0.01, rangeEnd+0.01) - } - - // Filter by Focal Length Range. + // Filter by Focal Length (35mm equivalent) range. if rangeStart, rangeEnd, rangeErr := txt.IntRange(f.Mm, 0, 10000000); rangeErr == nil { s = s.Where("photos.photo_focal_length >= ? AND photos.photo_focal_length <= ?", rangeStart, rangeEnd) } + // Filter by Aperture (f-number) range. + if rangeStart, rangeEnd, rangeErr := txt.FloatRange(f.F, 0, 10000000); rangeErr == nil { + s = s.Where("photos.photo_f_number >= ? AND photos.photo_f_number <= ?", rangeStart-0.01, rangeEnd+0.01) + } + // Filter by year. if f.Year != "" { s = s.Where(AnyInt("photos.photo_year", f.Year, txt.Or, entity.UnknownYear, txt.YearMax)) @@ -690,19 +690,19 @@ func searchPhotos(f form.SearchPhotos, sess *entity.Session, resultCols string) s = s.Where("photos.photo_lng BETWEEN ? AND ?", lngW, lngE) } - // Filter by GPS Latitude (from +90 to -90 degrees). + // Filter by GPS Latitude range (from +90 to -90 degrees). if latN, latS, latErr := clean.GPSLatRange(f.Lat, f.Dist); latErr == nil { s = s.Where("photos.photo_lat BETWEEN ? AND ?", latS, latN) } - // Filter by GPS Longitude (from -180 to +180 degrees). + // Filter by GPS Longitude range (from -180 to +180 degrees) if lngE, lngW, lngErr := clean.GPSLngRange(f.Lng, f.Dist); lngErr == nil { s = s.Where("photos.photo_lng BETWEEN ? AND ?", lngW, lngE) } - // Filter by GPS Altitude - if rangeStart, rangeEnd, rangeErr := txt.IntRange(f.Alt, 0, 1000000); rangeErr == nil { - s = s.Where("photos.photo_altitude >= ? AND photos.photo_altitude <= ?", rangeStart, rangeEnd) + // Filter by GPS Altitude (m) range. + if rangeStart, rangeEnd, rangeErr := txt.IntRange(f.Alt, -6378000, 1000000000); rangeErr == nil { + s = s.Where("photos.photo_altitude BETWEEN ? AND ?", rangeStart, rangeEnd) } // Find photos taken before date. diff --git a/internal/search/photos_geo.go b/internal/search/photos_geo.go index 5232cb645..8d03abfd4 100644 --- a/internal/search/photos_geo.go +++ b/internal/search/photos_geo.go @@ -407,21 +407,21 @@ func UserPhotosGeo(f form.SearchPhotosGeo, sess *entity.Session) (results GeoRes s = s.Where("photos.lens_id = ?", f.Lens) } - // Filter by ISO Range. + // Filter by ISO Number (light sensitivity) range. if rangeStart, rangeEnd, rangeErr := txt.IntRange(f.Iso, 0, 10000000); rangeErr == nil { s = s.Where("photos.photo_iso >= ? AND photos.photo_iso <= ?", rangeStart, rangeEnd) } - // Filter by F-Number Range. - if rangeStart, rangeEnd, rangeErr := txt.FloatRange(f.F, 0, 10000000); rangeErr == nil { - s = s.Where("photos.photo_f_number >= ? AND photos.photo_f_number <= ?", rangeStart-0.01, rangeEnd+0.01) - } - - // Filter by Focal Length Range. + // Filter by Focal Length (35mm equivalent) range. if rangeStart, rangeEnd, rangeErr := txt.IntRange(f.Mm, 0, 10000000); rangeErr == nil { s = s.Where("photos.photo_focal_length >= ? AND photos.photo_focal_length <= ?", rangeStart, rangeEnd) } + // Filter by Aperture (f-number) range. + if rangeStart, rangeEnd, rangeErr := txt.FloatRange(f.F, 0, 10000000); rangeErr == nil { + s = s.Where("photos.photo_f_number >= ? AND photos.photo_f_number <= ?", rangeStart-0.01, rangeEnd+0.01) + } + // Filter by year. if f.Year != "" { s = s.Where(AnyInt("photos.photo_year", f.Year, txt.Or, entity.UnknownYear, txt.YearMax)) @@ -588,21 +588,21 @@ func UserPhotosGeo(f form.SearchPhotosGeo, sess *entity.Session) (results GeoRes s = s.Where("photos.photo_lng BETWEEN ? AND ?", lngW, lngE) } - // Filter by GPS Latitude (from +90 to -90 degrees). + // Filter by GPS Latitude range (from +90 to -90 degrees). if latN, latS, latErr := clean.GPSLatRange(f.Lat, f.Dist); latErr == nil { s = s.Where("photos.photo_lat BETWEEN ? AND ?", latS, latN) } - // Filter by GPS Altitude - if rangeStart, rangeEnd, rangeErr := txt.IntRange(f.Alt, 0, 1000000); rangeErr == nil { - s = s.Where("photos.photo_altitude >= ? AND photos.photo_altitude <= ?", rangeStart, rangeEnd) - } - - // Filter by GPS Longitude (from -180 to +180 degrees). + // Filter by GPS Longitude range (from -180 to +180 degrees). if lngE, lngW, lngErr := clean.GPSLngRange(f.Lng, f.Dist); lngErr == nil { s = s.Where("photos.photo_lng BETWEEN ? AND ?", lngW, lngE) } + // Filter by GPS Altitude (m) range. + if rangeStart, rangeEnd, rangeErr := txt.IntRange(f.Alt, -6378000, 1000000000); rangeErr == nil { + s = s.Where("photos.photo_altitude BETWEEN ? AND ?", rangeStart, rangeEnd) + } + // Find photos taken before date. if !f.Before.IsZero() { s = s.Where("photos.taken_at <= ?", f.Before.Format("2006-01-02"))