Skip to content

Instantly share code, notes, and snippets.

View aaronlidman's full-sized avatar

Aaron Lidman aaronlidman

View GitHub Profile
@aaronlidman
aaronlidman / polyline decode
Created December 7, 2010 21:52
a googlemaps v2 encoded polyline to a list of coordinates (for use with the backward v3)
// Decode an encoded polyline into a list of lat/lng tuples.
function decodeLine (encoded) {
var len = encoded.length;
var index = 0;
var array = [];
var lat = 0;
var lng = 0;
while (index < len) {
var b;
@aaronlidman
aaronlidman / gist:1850222
Created February 17, 2012 03:07
5by5episodepage2wikipage
javascript: (function () {
(function () {
var v = "1.3.2";
if (window.jQuery === undefined || window.jQuery.fn.jquery < v) {
var done = false;
var script = document.createElement("script");
script.src = "http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js";
script.onload = script.onreadystatechange = function () {
if (!done && (!this.readyState || this.readyState == "loaded" || this.readyState == "complete")) {
done = true;
#!/usr/bin/python
"""
This script is designed to act as assistance in converting shapefiles
to OpenStreetMap data. This file is optimized and tested with MassGIS
shapefiles, converted to EPSG:4326 before being passed to the script.
You can perform this conversion with
ogr2ogr -t_srs EPSG:4326 new_file.shp old_file.shp
@aaronlidman
aaronlidman / gist:2691527
Created May 14, 2012 02:55
ogr2ogr 900913
ogr2ogr [output] [input] -skipfailures -t_srs EPSG:900913 -clipsrc -180 -85.0511 180 85.0511
(SELECT way, highway, railway,
(CASE WHEN highway IN ('motorway') THEN 'highway'
WHEN highway IN ('trunk', 'primary') THEN 'major_road'
ELSE 'minor_road' END) AS kind,
'no'::VARCHAR AS is_link,
(CASE WHEN tunnel IN ('yes', 'true') THEN 'yes'
ELSE 'no' END) AS is_tunnel,
(CASE WHEN bridge IN ('yes', 'true') THEN 'yes'
ELSE 'no' END) AS is_bridge,
(SELECT way, highway, railway, tunnel, bridge, layer,
(CASE
WHEN highway IN ('motorway', 'motorway_link') THEN 'highway'
WHEN highway IN ('trunk', 'trunk_link', 'primary', 'primary_link', 'secondary', 'secondary_link', 'tertiary', 'tertiary_link') THEN 'major_road'
WHEN highway IN ('footpath', 'track', 'footway', 'steps', 'pedestrian', 'path', 'cycleway') THEN 'path'
WHEN railway IN ('rail', 'tram', 'light_rail', 'narrow_guage', 'monorail') THEN 'rail'
ELSE 'minor_road' END) AS kind,
(CASE WHEN highway LIKE '%_link' THEN 'yes'
ELSE 'no' END) AS is_link,
@aaronlidman
aaronlidman / gist:3186651
Created July 27, 2012 07:28
quick reproj to 900913 and shapeindex
#!/bin/bash
for shp in $(find . -name \*.shp);
do
ogr2ogr "$(dirname $shp)/$(basename $shp .shp)-900913.shp" $shp -skipfailures -t_srs EPSG:900913 -clipsrc -180 -85.0511 180 85.0511
shapeindex "$(dirname $shp)/$(basename $shp .shp)-900913.shp"
done
@aaronlidman
aaronlidman / gist:3278567
Created August 6, 2012 21:25
simplegeo geojson Features to FeatureCollection from http://gis.stackexchange.com/a/16255
import sys
infile = sys.argv[1]
outfile = sys.argv[2]
## Prepare the input/output for read/write of files
fin = open(infile, 'r')
fout = open(outfile, 'w')
@aaronlidman
aaronlidman / gist:3376128
Created August 17, 2012 05:10
good enough US bounds
-124.75,24.53,-66.94,49.01
mp3splt -t 30.00 file.mp3