Skip to content

Instantly share code, notes, and snippets.

View mlevans's full-sized avatar

Michael Lawrence Evans mlevans

  • Office of Emerging Technology, City of Boston
  • Boston, MA
View GitHub Profile
@mlevans
mlevans / gist:2650008
Created May 10, 2012 00:21
Simple Sorting Tutorial
// Load d3
var val_arr = [];
function sortFunction(a,b) {
return a - b;
}
function loadData(){
d3.csv('data.csv',function(data){
@mlevans
mlevans / gist:2506045
Created April 27, 2012 05:08
Convert Latitude/Longitude Pair to Tile Coordinates
function latLngToCoords(zoom,lat,lon) {
var n = Math.pow(2,zoom);
var lat_rad = lat * (Math.PI / 180);
var x_coord = n * ((lon + 180) / 360);
var y_coord = .5 * n * (1 - (Math.log (Math.tan(lat_rad) + (1/Math.cos(lat_rad))) / Math.PI));
return {x: Math.floor(x_coord), y: Math.floor(y_coord)};
@mlevans
mlevans / polygonize.py
Created April 26, 2012 03:39 — forked from migurski/polygonize.py
Polygonize a bag of lines
from sys import argv
from shapely.ops import polygonize
from shapely.geometry import asShape, LineString
import json
if __name__ == '__main__':
input = argv[1]
input = json.load(open(input))
@mlevans
mlevans / index.html
Created May 25, 2011 21:21
Displaying Map Tiles from TileStream
<!Doctype html>
<html>
<head>
<title>311 Density</title>
<meta charset="utf-8" />
<link rel="stylesheet" href="https://github.com/CloudMade/Leaflet/raw/master/dist/leaflet.css" />
<!--[if lte IE 8]><link rel="stylesheet" href="https://github.com/CloudMade/Leaflet/raw/master/dist/leaflet.ie.css" /><![endif]-->
</head>
<body>