Introduction
One of the Code the City 21 projects was looking at providing Scots translations of Aberdeenshire place names for displaying on an OpenStreetMap map. Part of the outcomes for that project included a list of translated places names and potentially an audio version of name to guide in pronunciation.
I’m a firm believer that Open Data shouldn’t just become “dusty data left on the digital shelf” and to “show don’t tell”. This led me to decide to show just how easy it is to do something with the data created as part of the weekend’s activities and to make use of outcomes from a previous CTC event (Aberdeenshire Settlements on Wikidata and Wikipedia) and thus take that data off the digital shelf.
My plan was to build a simple iOS app, using SwiftUI, that would allow the following:
- Listing of place names in English and their Scots translation
- View details about a place including its translation, location and photo
- Map showing all the places and indicating if a translation exists or not
I used SwiftUI as it is fun (always an important consideration) to play with and quick to get visible results. It also provides the future option to run the app as a Mac desktop app.
Playing along at home
Anyone with a Mac running at least Catalina (macOS 10.15) can install Xcode 12 and run the app on the Simulator. The source code can be found in GitHub.
Getting the source data
Knowing that work had previously been done on populating Wikidata with a list of Aberdeenshire Settlements and providing photos for them, I turned to Wikidata for sourcing the data to use in the app.
# Get list of places in Aberdeenshire, name in English and Scots, single image, lat and long
SELECT ?place (SAMPLE(?place_EN) as ?place_EN) (SAMPLE(?place_SCO) as ?place_SCO) (SAMPLE(?image) as ?image) (SAMPLE(?longitude) as ?longitude) (SAMPLE(?latitude) as ?latitude)
WHERE {
?place wdt:P31/wdt:P279* wd:Q486972 .
?place wdt:P131 wd:Q189912 .
?place p:P625 ?coordinate.
?coordinate psv:P625 ?coordinate_node .
?coordinate_node wikibase:geoLongitude ?longitude .
?coordinate_node wikibase:geoLatitude ?latitude .
OPTIONAL { ?place wdt:P18 ?image }.
OPTIONAL { ?place rdfs:label ?place_EN filter (lang(?place_EN) = "en" )}.
OPTIONAL { ?place rdfs:label ?place_SCO filter (lang(?place_SCO) = "sco" )}.
}
GROUP BY ?place
ORDER By ?place_EN
The query can be found in the CTC21 Doric Tiles GitHub repository and run via the Wikidata Query Service.
The query returned a dataset that consisted of:
- Place name in English
- Place name in Scots (if it exists)
- Single image for the place (some places have multiple images so had to be restricted to single image)
- Latitude of place
- Longitude of place
Just requesting the coordinate for each place resulted in a text string, such as Point(-2.63004 57.5583)
, which complicated the use later on. Adding the relevant code
?coordinate psv:P625 ?coordinate_node .
?coordinate_node wikibase:geoLongitude ?longitude .
?coordinate_node wikibase:geoLatitude ?latitude .
to the query to generate latitude and longitude values simplified the data reuse at the next stage.
The results returned by the query were exported as a JSON file that could be dropped straight into the Xcode project.
The App
SwiftUI allows data driven apps to be quickly pulled together. The data powering the app was a collection of Place structures populated with the contents of the JSON exported from Wikidata.
struct Place: Codable, Identifiable {
let place: String
let place_EN: String
let place_SCO: String?
let image: String?
var latitude: String
var longitude: String
// Computed Property
var id: String { return place }
var location: CLLocationCoordinate2D {
CLLocationCoordinate2D(latitude: Double(latitude)!, longitude: Double(longitude)!)
}
}
The app itself was split into three parts: Places list, Map, Settings. The Places list drills down to a Place details view.



The Settings screen just displays some about information and where the data came from. It acts partially as a placeholder for now with the room to expand as the app evolves.
Next Steps
The app created over the weekend was very much a proof of concept and so has room from many improvements. The list includes:
- Caching the location photos on the device
- Displaying additional information about the place
- Adding search to the list and map
- Adding audio pronunciation of name (the related Doric Tiles project did not achieve adding of audio during the CT21 event)
- Modified to run on Mac desktop
- Ability to requested updated list of places and translations
The final item on the above list, the ability to request an updated list of places, in theory is straight forward. All that would be required is to send the query to the Wikidata Query Service and process the results within the app. The problem is that the query takes a long time to run (nearly 45 seconds) and there may be timeout issues before the results arrive.