A Patrick O'Brian Atlas

on May 17, 2020, 1:22 am

After I finished my atlas of all the Patrick O'Brian novels I thought it might be cool to see all the courses I plotted on a single world map. I am working on an Apple MacOS screensaver to animate the maps, but in the meantime, here is a rendering of all the voyages.

You can click on the image for a higher resolution view.

If you are wondering about the occasional breaks in the course lines? They are a result of sections of the story where I couldn't guess where Jack and Stephen ended up. In those cases I pick up their location again once I had a fair weather observation.

Permalink - Comments - Tags: Patrick O'Brian

Bundle.main.path forResource will return nil in a MacOS screen saver

on May 3, 2020, 5:10 am

I thought it might be worth writing a quick post on something that had me stuck building a screen saver for MacOS in Swift.

If you have a file you include in your build target (like a SQLite database of map tiles) and need to open that file you might try something like this:

let stringPath: String? = Bundle.main.path(forResource: "satellite-lowres-v1.2-z0-z5", ofType: "mbtiles")

Because I am debugging my application in a regular MacOS app (that just shows my ScreenSaverView) this code worked fine when I was debugging. As soon as I built and deployed the actual screen saver bundle everything broke.

So at that point you might spend quite a bit of time trying to debug entirely unrelated tile loading code before realising that bundle.main.path forResource was returning nil, but only in the screen saver application.

The reasons for this is that MacOS screen savers are bundles loaded by the system screen saver application, so the path you get will be something like:

/Applications/System Preferences.app/Contents/Resources

So to get this to work (in both the test app and the screen saver app) you need to get the bundle via a class in that bundle:

let stringPath: String? = Bundle(for: type(of: self)).path(forResource: "satellite-lowres-v1.2-z0-z5", ofType: "mbtiles")

I am just using the ScreenSaverView class which works fine.

This all took a little longer than it should have to find because, this being my first MacOS app, I wasn't sure where debug logging was ending up. Turns out it all appears in the Mac Console application ("Console" in Spotlight). I also struggled a bit because the Console app, or something in the MacOS logging framework was making decisions about the sensitivity of variables I was logging. So logging something like this:

os_log("Location was ---> %s", stringPath ?? "We got nil for our stringPath")

Ends up in the logs like this "Location was ---> " which isn't very helpful. To tell the logging framework that you want to see those variables you can supply it to the format string:

os_log("Location was ---> %{public}s", stringPath ?? "We got nil for our stringPath")

Permalink - Comments - Tags: Development, Swift

My Fourteen Year Project

on April 11, 2020, 4:41 am

Fourteen years ago I finished reading the twenty one novels by Patrick O'Brian set during the Napoleonic wars and on various ships commanded by the protagonist Jack Aubrey and his particular friend Stephen Maturin. I decided that interactive maps of the voyages could be a useful addition to the Internet (built with the newly available Google Maps Javascript API).

Today I finished that project:

The slow, sometimes painful, progression through these twenty one volumes has ultimately been incredibly rewarding. Hundreds of thousands of people (492,902 at last count) have visited the site and many have contacted me with support and encouragement.

This site, dated, clumsy and so embarrassingly overdue for a re-write, has been a platform on which I have been able to do a lot of other fun stuff. It is something, despite its flaws, that I am very proud of.

I think it reinforces Jason Robert's assertion that "the amount of serendipity that will occur in your life, your Luck Surface Area, is directly proportional to the degree to which you do something you're passionate about".

Permalink - Comments - Tags: Patrick O'Brian,Books

Mapping of Blue at the Mizzen Complete

on April 10, 2020, 11:57 pm

Blue at the Mizzen is finished.

I have developed symptoms of a cold and, as a result, quarantined myself inside our very small and already quarantined house. I am confident it is just a cold and not something more sinister but marvel at the tenacity of this particular rhinovirus that managed to circumvent the frequent handwashing, alcohol wipes and mask wearing to make it into my upper respiratory tract.

Thanks to this extra layer of enforced isolation I was able to finish this, the twentieth and last complete volume in Patrick O'Brian's wonderful series, in just 6 days. A new record, though perhaps one soon to be broken with my upcoming map of The, sadly truncated, Final Unfinished Voyage of Jack Aubrey.

Permalink - Comments - Tags: Patrick O'Brian,Books

Mapping of The Hundred Days Complete

on April 5, 2020, 12:56 am

The Hundred Days Map is finished. Only 11 days after The Yellow Admiral Map. Sadly this record run was entirely a result of staying at home during the current COVID-19 pandemic.

Very odd to be so close to the finish line after fourteen years of chipping away at this series.

Permalink - Comments - Tags: Patrick O'Brian,Books