Skip to content

Instantly share code, notes, and snippets.

View systemed's full-sized avatar

Richard Fairhurst systemed

View GitHub Profile
@systemed
systemed / gist:be2d6bb242d2fa497b5d93dcafe85f0c
Last active April 10, 2024 03:49
Routing algorithm implementations
(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
@systemed
systemed / renderd.service
Created March 20, 2022 22:21
systemd service for running renderd
[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 March 5, 2022 18:15
Serialise [String:Any?] to JSON in 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 / style_profiler.rb
Last active May 22, 2021 17:55
Profile Mapnik styles
# 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 / osm_centos7.sh
Created January 30, 2020 18:50
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 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 / merge_mapnik.rb
Created December 15, 2019 11:55
Composite all hillshade layers into a single GeoTIFF
# 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 October 10, 2019 15:21
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*