Skip to content

Instantly share code, notes, and snippets.


Richard Fairhurst systemed

View GitHub Profile
systemed / renderd.service
Created Mar 20, 2022
systemd service for running renderd
View renderd.service
Description=Daemon that renders map tiles using mapnik
Documentation=man:renderd auditd.service
ExecStart=/usr/local/bin/renderd -f -c /usr/local/etc/renderd.conf
systemed / serialise.swift
Created Mar 5, 2022
Serialise [String:Any?] to JSON in Swift
View serialise.swift
// This can be used to serialise the results of a Eureka form to JSON
// requires AnyCodable from
let results:[String:AnyCodable] = form.values().mapValues { v in
return AnyCodable(v)
let encoder = JSONEncoder()
encoder.outputFormatting = .prettyPrinted
let json = try! encoder.encode(results)
print(String(data: json, encoding: .utf8)!)
systemed /
Created Jan 30, 2020
Installing OSM rendering stack on CentOS 7
# Install OSM rendering stack on CentOS 7
# Richard Fairhurst, January 2020
yum -y install epel-release
# Postgres/GDAL
rpm -Uvh
yum -y install postgresql94-server postgresql94-devel postgis24_94 postgis24_94-docs postgis24_94-utils gdal30 gdal30-devel
systemed / style_profiler.rb
Last active May 22, 2021
Profile Mapnik styles
View style_profiler.rb
# Mapnik style profiler
# ruby style_profiler.rb /usr/local/share/maps/style/stylesheet.xml coloured_relief,hillshade,relief,combined_relief 8.1948 46.8982 8.4502 47.0753
require '/usr/local/share/ruby/ffi-mapnik/lib/ffi-mapnik.rb'
require 'nokogiri'
require 'proj4'
require 'benchmark'
xml_fn = ARGV[0]
systemed / merge_mapnik.rb
Created Dec 15, 2019
Composite all hillshade layers into a single GeoTIFF
View merge_mapnik.rb
# Combine all hillshade layers into a single GeoTIFF
# Requires (which uses GDAL Python bindings)
require '/usr/local/share/ruby/ffi-mapnik/lib/ffi-mapnik.rb'
require 'nokogiri'
systemed /
Last active Oct 10, 2019
Vector tiles schema notes

Likely schema

place           <- place
boundary        <- boundary
route           <- route
structure       <- power, man_made, barrier, emergency, amenity=[bench, post_box, telephone…], advertising, military, playground
poi             <- shop, tourism, historic, office, amenity=[other], healthcare, craft
transport       <- highway, railway, aerialway, traffic_sign*, public_transport, amenity=bus_station
indoor &lt;- indoor*, entrance*
systemed / gist:be2d6bb242d2fa497b5d93dcafe85f0c
Last active Nov 4, 2022
Routing algorithm implementations
View gist:be2d6bb242d2fa497b5d93dcafe85f0c
(Dijkstra and plain A* are generally not included here as there are thousands of
implementations, though I've made an exception for rare Ruby and Crystal versions,
and for Thor, Mapzen's enhanced A*. )
A* Ruby
A* Crystal
A* (bidirectional with shortcuts) C++
NBA* Java
NBA* Java