In New York, there are so many sights and sounds that it’s easy to overlook the city’s more commonplace features. Gargoyles of New York, out now on the iOS App Store, is a documentary photo essay that showcases the city’s ubiquitous standpipes.
Day and Night
I developed Gargoyles with Guido Jiménez-Cruz. The app displays a collection of his photos, accompanied by ambient sound from the location of each photo. Gargoyles also has a hidden feature: the photos you see reflect the local time in New York.
If it’s daytime in New York, the app will show photos taken during the day. After sunset, the images will be the nighttime versions of the same standpipes.
Solving for Day and Night
To achieve the goal of automatically switching into night mode at the correct time, I needed to know the sunrise and sunset times for the current day. This information is available online, but ideally, the app would not be dependent on internet connectivity. It’s possible to calculate the values using only the time and location, so we can hard code the location and query iOS for the current time. I found a summary of the algorithm on one site, with a more complete explanation on another. Here is the implementation in Objective C:
#if DEBUG section at the end is only for testing. If built in debug mode, you can set a break point and see the sunrise and sunset times in a human-readable form.
Now all we have to do is look up the latitude and longitude of New York, and plug those numbers into the algorithm:
I hope this peek into the development of Gargoyles has been interesting. Please head over to the App Store and give the app a try.