Skip to content

Instantly share code, notes, and snippets.

View dkastl's full-sized avatar

Daniel Kastl dkastl

View GitHub Profile
@dkastl
dkastl / build_pgrouting.sh
Last active July 10, 2016 14:35
Build pgRouting
#!/bin/bash
# Install dependencies Ubuntu 14.04
sudo apt-get install git cmake build-essential libcgal-dev libboost-graph-dev libboost-thread-dev python-sphinx texlive texlive-latex-extra postgresql-9.4-postgis-2.1 postgresql-server-dev-all checkinstall
# Clone the repository
git clone git@github.com:pgRouting/pgrouting.git && cd pgrouting && git checkout develop
# Compile
rm -Rf build
@dkastl
dkastl / update_virtualbox.sh
Created June 12, 2013 16:37
VirtualBox updates after kernel upgrade
#!/bin/bash
# Upgrade linux headers
sudo apt-get install linux-headers-`uname -r`
# Reconfigure dkms and load module:
sudo dpkg-reconfigure virtualbox-dkms
sudo modprobe vboxdrv
@dkastl
dkastl / git-buildpackage.sh
Last active July 7, 2016 16:57
Collection of git-buildpackage commands
#!/bin/bash
# Install Git Buildpackage
sudo apt-get install git-buildpackage cdbs debhelper
# Create tarball from tag
cd pgrouting
git archive v2.2.3 | gzip > ../tarballs/pgrouting-2.2.3-release-orig.tar.gz
# This is only for the first import and creation of a new build repository
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
#!/bin/bash
MYDATE=$(date +%d-%m-%Y)
for PORT in 5432 5433 5434
do
echo "Backups on port $PORT"
export PGPORT=$PORT
LIST=$(psql -l | awk '{ print $1 }' | grep '^[a-z]' | grep -v template | grep -v postgres)
for ITEM in $LIST
do
NAME=${ITEM}-${MYDATE}.dmp
CREATE OR REPLACE FUNCTION write_file (param_bytes bytea, param_filepath text)
RETURNS text
AS $$
import os
f = open(param_filepath, 'wb+')
os.chmod(param_filepath, 0666)
f.write(param_bytes)
return param_filepath
$$ LANGUAGE plpythonu;
@dkastl
dkastl / .inputrc
Created April 23, 2014 08:49
Incremental history searching
"\e[A": history-search-backward
"\e[B": history-search-forward
"\e[C": forward-char
"\e[D": backward-char
@dkastl
dkastl / TD1202_report.md
Last active August 29, 2015 14:25
TD1202 Report

Opening up the network data of OpenStreetMap with pgRouting

Report from "Training School 'FOSS4VGI'"

pgRouting adds routing functionality to a PostgreSQL/PostGIS database. The introductory workshop of the training school showed the participants how. It gave a practical example of how to use pgRouting with OpenStreetMap road network data. It explained the steps to prepare the data, make routing queries, assign costs and write a custom ‘plpgsql’ function to display the route in a web-mapping application.

Navigation for road networks requires complex routing algorithms that support turn restrictions

@dkastl
dkastl / unzip.sh
Created December 10, 2015 04:39
Unzip archive with Japanese file names
unzip -O shift-jis myarchive.zip
@dkastl
dkastl / split_lines.sql
Last active November 8, 2016 04:36
Split Lines at intersections
-- Sample data
CREATE TABLE pipes (id serial, geom geometry(LineString));
INSERT INTO pipes(geom) VALUES (ST_MakeLine(ST_MakePoint(1,1), ST_MakePoint(4,1)));
INSERT INTO pipes(geom) VALUES (ST_MakeLine(ST_MakePoint(1,0), ST_MakePoint(3,0)));
CREATE TABLE connections (id serial, geom geometry(LineString));
INSERT INTO connections(geom) VALUES (ST_MakeLine(ST_MakePoint(0,0), ST_MakePoint(1,1)));
INSERT INTO connections(geom) VALUES (ST_MakeLine(ST_MakePoint(0,2), ST_MakePoint(1,1)));
INSERT INTO connections(geom) VALUES (ST_MakeLine(ST_MakePoint(2,2), ST_MakePoint(2,1)));
INSERT INTO connections(geom) VALUES (ST_MakeLine(ST_MakePoint(4,0), ST_MakePoint(4,1)));