Skip to content

Instantly share code, notes, and snippets.

@bertspaan
bertspaan / README.md
Created November 26, 2014 09:18
CitySDK LD API v0.9 - Matching API

CitySDK LD API v0.9 - Matching API

This gist contains the code of the matching API of the old version of CitySDK LD API.

api.rb was part of the Sinatra REST API, this code was triggered by a POST request, and called the code in the other files.

@bertspaan
bertspaan / bag.sql
Last active August 29, 2015 14:09
Building polygons to individual linestrings
DROP TABLE IF EXISTS bert.pandlijn;
CREATE TABLE bert.pandlijn AS
SELECT ST_MakeLine(sp,ep) AS geom, trunc(random() * 9 + 1)::int AS rand
FROM
-- extract the endpoints for every 2-point line segment for each linestring
(SELECT
ST_PointN(geom, generate_series(1, ST_NPoints(geom)-1)) as sp,
ST_PointN(geom, generate_series(2, ST_NPoints(geom) )) as ep
FROM
@bertspaan
bertspaan / GTFS-to-GEOJSON.md
Last active May 13, 2017 22:47
Ruby script to convert GTFS stops and shapes to GeoJSON.

Ruby script to convert stops.txt and shapes.txt to GeoJSON.

@bertspaan
bertspaan / sections.json
Created October 6, 2014 12:10
Building map sections for Stamen's Mapmaker Manifesto in Istanbul
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@bertspaan
bertspaan / vwo.geojson
Created September 18, 2014 10:15
VWO-scholen, met locatie. Bron: http://www.schoolcijferlijst.nl/
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@bertspaan
bertspaan / README.md
Created June 17, 2014 09:25
Bug in Grape/Hashie when POSTing GeoJSON file

I've been experiencing stack level errors in Hashie's mash.rb, when POSTing somewhat large GeoJSON files to a Grape endpoint. I'm using Grape 0.7.0.

To replicate the bug, do the following:

  1. Open two terminals, run rackup in one,
  2. and ./bug.sh in the other.

The Grape/Rack terminal will output:

[2014-06-17 11:18:37] ERROR SystemStackError: stack level too deep

@bertspaan
bertspaan / a10.geojson
Created May 28, 2014 11:21
Circle and A10!
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@bertspaan
bertspaan / README.md
Last active April 12, 2017 23:25 — forked from mbostock/.block

A treemap recursively subdivides area into rectangles; the area of any node in the tree corresponds to its value. This example uses color to encode different packages of the Flare visualization toolkit. Treemap design invented by Ben Shneiderman. Squarified algorithm by Bruls, Huizing and van Wijk. Data courtesy Jeff Heer.

@bertspaan
bertspaan / schools.rb
Created March 27, 2014 11:29
Read CitySDK schools data, export to CSV
require 'json'
schools = JSON.parse(File.open('schools.json').read, {symbolize_names: true})
schools[:results].each do |school|
data = school[:layers][:"duo.schools.secondary"][:data]
lat, lon = school[:geom][:coordinates]
csv_row = {
@bertspaan
bertspaan / artsholland.context.json
Last active August 29, 2015 13:57
JSON-LD context for CitySDK Arts Holland layer data
{
"@base": "http://rdf.citysdk.eu/ams/",
"ah": "http://purl.org/artsholland/1.0/",
"foaf": "http://xmlns.com/foaf/0.1/",
"vcard": "http://www.w3.org/2006/vcard/ns#",
"dc": "http://purl.org/dc/elements/1.1/",
"title": "dc:title",
"uri": "owl:sameAs",
"website": "foaf:homepage",
"locality": "vcard:locality",