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.
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 |
Ruby script to convert stops.txt
and shapes.txt
to GeoJSON.
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:
rackup
in one,./bug.sh
in the other.The Grape/Rack terminal will output:
[2014-06-17 11:18:37] ERROR SystemStackError: stack level too deep
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.
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 = { |
{ | |
"@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", |