Conversation
GPS coordinates can be given in Lat,Lon fields in the Markdown files. These override the EXIF GPS coordinates, if both are present.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #525 +/- ##
==========================================
- Coverage 90.72% 90.70% -0.02%
==========================================
Files 24 24
Lines 2026 2034 +8
==========================================
+ Hits 1838 1845 +7
- Misses 188 189 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
saimn
left a comment
There was a problem hiding this comment.
Seems useful, thanks. A few comments below.
src/sigal/gallery.py
Outdated
|
|
||
| @cached_property | ||
| def lat(self): | ||
| return self.markdown_metadata.get("lat", {}) |
There was a problem hiding this comment.
Can you change the properties to return media.exif.gps.lat/lon if not available in meta ? this would avoid the if/else in the template.
There was a problem hiding this comment.
But that would make it impossible to write a template that prefers the EXIF coordinates.
You might not want this, IMHO.
There was a problem hiding this comment.
people can still use directly media.exif.gps. But for media.lat I think it makes sense to avoid the manual coordinates or the exif ones.
There was a problem hiding this comment.
I hate to insist, but I feel I have to. I perceive the Python code as a considerably "deeper" layer than the templates. I expect that many users will be happy to work at the template layer but will want to avoid the Python layer. Thus, I expect that a simple, easily predictable behaviour for media.lat/lon and media.exif.gps makes it easy to write templates.
Now, if you really want to have a template without ifs, I suggest keeping meta.lat/lon as they are and adding a new set of variables that implement the fallback and a configuration option that defines preference to GPS or .md if both are present.
There was a problem hiding this comment.
And, BTW, come to think of it, one of the ifs will still be needed as it might be the case that there are no coordinates at either EXIF or .md. So we will still need an if, except without the else branch.
There was a problem hiding this comment.
I just had another idea: How about a config option that sets the order of preference between md, EXIF?
Then both ways are accessible at the template. If the option also includes a "default location" (say, 0,0 or someplace in the middle of the Pacific) then all photos are guaranteed to have a location and the template can be completely without checks. This has the advantage that photos without a location do not silently disappear but are placed at a location that the users know to mean that they have forgotten to add a location.
Co-authored-by: Simon Conseil <contact@saimon.org>
Slight code simplification, allowing get() to return None when the field is missing. The related if statement in Jinja2 accepts None as False. Co-authored-by: Simon Conseil <contact@saimon.org>
Read Lat, Lon fields in the Markdown files to localize images. These override the EXIF GPS coordinates, if both are present, allowing manually localizing the images on the map. This is useful to, for instance, localize the image based on what is depicted instead of where the camera was standing.