I’d taken Friday off as a holiday this week, and I was also off on Monday afternoon to attend a funeral. Despite being off for a day and a half I still managed to achieve quite a lot this week. Over the weekend Thomas Clancy had alerted me to another excellent resource that has been developed by the NLS Maps people that plots the boundaries of all parishes in Scotland, which you can access here: http://maps.nls.uk/geo/boundaries/#zoom=10.671666666666667&lat=55.8481&lon=-2.5155&point=0,0. For REELS we had been hoping to incorporate parish boundaries into our Berwickshire map but didn’t know where to get the coordinates from, and there wasn’t enough time in the project for us to manually create the data. I emailed Chris Fleet at the NLS to ask where they’d got their data from, and whether we might be able to access the Berwickshire bits of it. Chris very helpfully replied to say were created by the James Hutton Institute and are hosted on the Scottish government’s Scottish Spatial Data Infrastructure Metadata Portal (see https://www.spatialdata.gov.scot/geonetwork/srv/eng/catalog.search#/metadata/c1d34a5d-28a7-4944-9892-196ca6b3be0c). The data is free to use, so long as a copyright statement is displayed, and there’s even an API through which the data can be grabbed (see here: http://sedsh127.sedsh.gov.uk/arcgis/rest/services/ScotGov/AreaManagement/MapServer/1/query). The data can even be outputted in a variety of formats, including shape files, JSON and GeoJSON. I decided to go for GeoJSON, as this seemed like a pretty good fit for the Leaflet mapping library we use.
Initially I used the latitude and longitude coordinates for one parish (Abbey St Bathans) and added this to the map. Unfortunately the polygon shape didn’t appear on the map, even though no errors were returned. This was rather confusing until I realised that whereas Leaflet tends to use latitude and then longitude as the order of the input data, GeoJSON is set to have longitude first and then latitude. This meant my polygon boundaries had been added to my map, just in a completely different part of the world! It turns out that in order to use GeoJSON data in Leaflet it’s better to use Leaflet’s in-built ‘L.geoJSON’ functions (See https://leafletjs.com/examples/geojson/). With this in place, Leaflet very straightforwardly plotted out the boundaries of my sample parish.
I had intended to write a little script that would then grab the GeoJSON data for each of the parishes in our system from the API mentioned above. However, I noticed that when passing a text string to the API it does a partial match, and can return multiple parishes. For example, our parish ‘Duns’ also brings back the data for ‘Dunscore’ and ‘Dunsyre’. I figured therefore that it would be safer if I just manually grabbed the data and inserted it directly into our ‘parishes’ database. This all worked perfectly, other than for the parish of Coldingham, which is a lot bigger than the rest, meaning the JSON data was also a lot larger. The size of the data was larger than a setting on the server was allowing me to upload to MySQL, but thankfully Chris McGlashan was able to sort that out for me.
With all of the parish data in place I styled the lines a sort of orange colour that would show up fairly well on all of our base maps. I also updated the ‘Display options’ to add in facilities to turn the boundary lines on or off. This also meant updating the citation, bookmarking and page reloading code too. I also wanted to add in the three-letter acronyms for each parish too. It turns out that adding plain text directly to a Leaflet map is not actually possible, or at least not easily. Instead the text needs to be added as a tooltip on an invisible marker, and the tooltip then has to be set as permanently visible, and then styled to remove the bubble around the text. This still left the little arrow pointing to the marker, but a bit of Googling informed me that if I set the tooltip’s ‘dicrection’ to ‘center’ the arrowheads aren’t shown. It all feels like a bit of a hack, and I hope that in future it’s a lot easier to just add text to a map in a more direct manner. However, I was glad to figure a solution out, and once I had manually grabbed the coordinates where I wanted the parish labels to appear I was all set. Here’s an example of how the map looks with parish boundaries and labels turned on:
I had some other place-name related things to do this week. On Wednesday afternoon I met with Carole, Simon and Thomas to discuss the Scottish Survey of Place-names, which I will be involved with in some capacity. We talked for a couple of hours about how the approach taken for REELS might be adapted for other surveys, and how we might connect up multiple surveys to provide Scotland-wide search and browse facilities. I can’t really say much more about it for now, but it’s good that such issues are being considered.
I spent about a day this week continuing to work on the new pages and videos for the Seeing Speech project. I fixed a formatting issue with the ‘Other Symbols’ table in the IPA Charts that was occurring in Internet Explorer, which Eleanor had noticed last week. I also uploaded the 16 new videos for /l/ and /r/ sounds that Eleanor had sent me, and created a new page for accessing these. As with the IPA Charts page I worked on last week, the videos on this page open in an overlay, which I think works pretty well. I also noticed that the videos kept on playing if you closed an overlay before the video finished, so I updated the code to ensure that the videos stop when the overlay is closed.
Other than these projects, I investigated an issue relating to Google Analytics that Craig Lamont was encountering for the Ramsay project, and I spent the rest of my time returning to the SCOSYA project. I’d met with Gary last week and he’d suggested some further updates to the staff Atlas page. It took a bit of time to get back into how the atlas works as it’s been a long time since I last worked on it, but once I’d got used to it again, and had created a new test version of the atlas for me to play with without messing up Gary’s access, I decided to try and figure out whether it would be possible to add in a ‘save map as image’ feature. I had included this before, but as the atlas uses a mixture of image types (bitmap, SVG, HTML elements) for base layers and markers the method I’d previously used wasn’t saving everything.
However, I found a plugin called ‘easyPrint’ (https://github.com/rowanwins/leaflet-easyPrint) that does seem to be able to save everything. By default it prints the map to a printer (or to PDF), but it can also be set up to ‘print’ to a PNG image. It is a bit clunky, sometimes does weird things and only works in Chrome and Firefox (and possibly Safari, I haven’t tried, but definitely not MS IE or Edge). It’s not going to be suitable for inclusion on the public atlas for these reasons, but it might be useful to the project team as a means of grabbing screenshots.
With the plugin added a new ‘download’ icon appears above the zoom controls in the bottom right. If you move your mouse over this some options appear that allow you to save an image at a variety of sizes (current, A4 portrait, A4 landscape and A3 portrait). The ‘current’ size should work without any weirdness, but the other ones have to reload the page, bringing in map tiles that are beyond what you currently see. This is where the weirdness comes in, as follows:
- The page will display a big white area instead of the map while the saving of the image takes place. This can take a few seconds.
- Occasionally the map tiles don’t load successfully and you get white areas in the image instead of the map. If this happens pan around the map a bit to load in the tiles and then try saving the image again.
- Very occasionally when the map reloads it will have completely repositioned itself, and the map image will be of this location too. Not sure why this is happening. If it does happen, reposition the map and try again and things seem to work.
Once the processing is complete the image will be saved as a PNG. If you select the ‘A3’ option the image will actually be of a much larger area than you see on your screen. I think this will prove useful to you for getting higher resolution images and also for including Shetland, two issues Gary was struggling with. Here’s a large image with Shetland in place:
That’s all for this week.