writing / post19 nov 2026

A map of where I shot

resync got a map of where I shot, and 62 minutes after it began, the commits add a read of the file header, because the first read found no GPS.

this post

published
2026-11-19
reading
07 min
parts
9
the exhibit: ~ / work / resync

A map for the idle viewfinder

On Sunday 1 November 2026, at 12:11 UTC, resync got a map. resync is my iPhone app for the Fujifilm X-T30 II, and the map shows where the photos on the camera's card were taken. Between 12:11 and 14:02 it got pins, a route and one broken build. The commits of that day name Claude as author or co-author. All times here are UTC.

Why a map? I wanted to see where I shot, and it just felt right.

Live view is the camera's picture on the phone, and the shoot tab shows it when the camera's Wi-Fi gives one. With no live view, the tab shows the map instead. The comment in the code says it plainly: "No live view: the map of where the photos on the card were taken." The first commit calls the idle viewfinder "a dark, muted, greyscale map".

Three marks are on it. Bone is the pale colour of the site's design system. A bone square is a pin for the photos of the card. A hollow square is a place the phone sent the camera. A line is the route of a session.

The look has a second source. With a public Mapbox token (a key) in a file that git ignores, the code draws a map style that lives in the app. Without a token, it draws Apple's map in greyscale.

Where a place comes from

The README says the camera asks for a location about every 10 seconds, and the phone answers over Bluetooth. The app reads the place back from the card later. When the card has photos but no place, the empty map says: "a photo gets one when the camera is linked as you shoot."

So a pin shows where the phone was. The code doesn't know where the lens pointed. It asks iOS for about 100 m of accuracy when only the link wants a location, and for about 10 m while a session holds the location on.

A pin is where I stood, then, not what I shot.

Two permissions

Apple's ImageCaptureCore is what lets an iPhone app talk to a camera on a cable. At 12:32 a commit message says ("the second" means the card's contents): "Camera control and the card's contents are separate permissions in ImageCaptureCore; without the second the card lists no files and the map stays empty."

Two permissions, and one of them is the whole map.

The first read found no GPS

The first commit says resync "reads each new photo's EXIF GPS through ImageCaptureCore". EXIF is the block of facts inside the file, and it has a part named GPS.

At 13:03 the app got a second way for a file that comes back with no EXIF: it reads the first bytes of the file itself, its header. Then, at 13:13, the message of commit 7f30f7a says, about the case of EXIF without GPS: "ImageCaptureCore listed {Exif} and {TIFF} but no {GPS}; a file without GPS there now gets its header read too."

That's the turn. The card had the sections, and the one with the place was missing. That annoyed me.

The header read takes the first 256 KB of a JPEG and the first 1 MB of a HEIF, and gives the bytes to the image code of iOS. A RAF is Fujifilm's raw file, and it keeps a full JPEG preview. The code reads the start of that preview from bytes 84 to 87 of the RAF header and its length from bytes 88 to 91, and takes up to 256 KB of it.

Twenty-three seconds later, another commit makes the app read the whole card again, once. The code drops the saved list of files it had read.

The case of EXIF without GPS went in at 13:13, 62 minutes after the first map commit. And the repository doesn't record a run where the header read returned GPS from my X-T30 II. The README still says photo GPS over USB is "not yet tested on this body".

One shot, one pin

The code skips a RAF that has a JPEG or HEIF of the same name beside it, so one shot gives one place. It counts a photo as read only when its read worked.

Pins that are near each other share one pin. The comment says "within about 100 m", but the code doesn't measure a distance. It rounds each place to three decimals and uses the two numbers as the key:

the key of a pintext
String(format: "%.3f,%.3f", latitude, longitude)

So the code groups by a grid. A step of 0.001 degree of latitude is about 111 m. A step of 0.001 degree of longitude is shorter away from the equator: about 79 m at 45 degrees. Two photos 5 m apart on two sides of a grid line get two pins. Two photos 100 m apart north to south, in one cell, get one.

Tap a pin and it shows the file name, the time, and "+N" for the other photos.

The route

At 13:55 a session got a route. A fix is one location reading from the phone, and the code keeps a fix only if all of this holds:

  • its accuracy is 50 m or better;
  • it is not older than the session start, it is newer than the last fix kept, and it is less than 120 seconds old;
  • it is at least as far from the last fix kept as the larger of 5 m and the smaller of the two accuracies.

The route is saved at most every 30 seconds, "so a crash loses little". A session with no good fix leaves nothing to draw. Otherwise the code draws the route as a 3 pt bone line, with a hollow square at the start.

Six minutes without a compile

That route commit removed import MapKit and import SwiftUI from PhotoMap.swift. The message of the next commit says the app did not compile. Commit 77785b4 put the imports back. Its time is 17:02 in the zone UTC+3, which is 14:02 UTC, six minutes after the route commit.

The tests, and the files

Two interface tests cover the map. They're written for the simulator, with seeded test places. One checks that three seeded photos give three pins, and one picks the route of a seeded session. No test reads a real card. No test covers the pin grid or the route filter.

The places of the photos are in photo-places.json, and the routes are in session-routes.json, both in the Application Support folder of the app. For the route, the README says the app "keeps it on the phone". The repository holds only seeded places for the tests.

What isn't settled

  • Real pins from my card. The repository doesn't record that the header read returned GPS from the card of my X-T30 II.
  • A card is skipped by file name. The code keeps the lowercase names of files it has read. It would skip a card that starts its numbering again, or a second card with the same names. No test in the repository covers this.
  • A cable and a USB mode. The README says the card lists files only when the camera is on the cable in the mode USB CARD READER. The mode for recipes shows an empty card.

It's too early to say. For now the map is still what its first commit called it: a dark, muted, greyscale viewfinder, waiting for a card with a place on it.