Skip to content

Instantly share code, notes, and snippets.

Avatar

Richard Fairhurst systemed

View GitHub Profile
@systemed
systemed / renderd.service
Created Mar 20, 2022
systemd service for running renderd
View renderd.service
[Unit]
Description=Daemon that renders map tiles using mapnik
Documentation=man:renderd
After=network.target auditd.service
[Service]
RuntimeDirectory=renderd
RuntimeDirectoryMode=0755
ExecStart=/usr/local/bin/renderd -f -c /usr/local/etc/renderd.conf
@systemed
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 https://github.com/Flight-School/AnyCodable
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
systemed / osm_centos7.sh
Created Jan 30, 2020
Installing OSM rendering stack on CentOS 7
View osm_centos7.sh
# Install OSM rendering stack on CentOS 7
# Richard Fairhurst, January 2020
yum -y install epel-release
# Postgres/GDAL
rpm -Uvh https://yum.postgresql.org/9.4/redhat/rhel-7-x86_64/pgdg-centos94-9.4-3.noarch.rpm
yum -y install postgresql94-server postgresql94-devel postgis24_94 postgis24_94-docs postgis24_94-utils gdal30 gdal30-devel
# GCC
@systemed
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
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 gdalcopyproj.py (which uses GDAL Python bindings)
require '/usr/local/share/ruby/ffi-mapnik/lib/ffi-mapnik.rb'
require 'nokogiri'
Mapnik.register_datasources("/usr/local/lib/mapnik/input")
Mapnik.register_fonts("/usr/local/share/maps/style/fonts")
@systemed
systemed / vector_tile_schema.md
Last active Oct 10, 2019
Vector tiles schema notes
View vector_tile_schema.md

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
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 https://github.com/georgian-se/shortest-path
A* Crystal https://github.com/petoem/a-star.cr
A* (bidirectional with shortcuts) C++ https://github.com/valhalla/valhalla
NBA* JS https://github.com/anvaka/ngraph.path
NBA* Java https://github.com/coderodde/GraphSearchPal
NBA* Java https://github.com/coderodde/FunkyPathfinding