Skip to content

Instantly share code, notes, and snippets.


Calvin Metcalf calvinmetcalf

View GitHub Profile
View mbtiles.js
var app = require('express').createServer(),
mbtiles = require('mbtiles'),
tilelive = new (require('tilelive').Server)(mbtiles);
app.get('/:z/:x/:y.*', function(req, res) {
var options = {
x: req.param('x'),
y: req.param('y'),
z: req.param('z'),
format: req.params[0],
calvinmetcalf / esri2geo.js
Created Jul 13, 2012
script for turning esri json into geojson
View esri2geo.js
function toGeoJSON(data){
var outPut = { "type": "FeatureCollection",
"features": []};
var fl = data.features.length;
var i = 0;
var ft = data.features[i];
/* as only ESRI based products care if all the features are the same type of geometry, check for geometry type at a feature level*/
var outFT = {
"type": "Feature",
calvinmetcalf /
Created Jul 16, 2012
json demo with leaflet

Leaflet with json

the html is fairly basic boilerplate for a full screen map, but the JavaScript file includes the data as well as the code to display it, in production we'd probably want to serve that as jsonp. This can be entirely self hosted internally, except the tiles which are hosted by mapquest in this example and we'd have to render our own tiles if we wanted to host them.

calvinmetcalf /
Created Jul 20, 2012
Using ESRI JSON in Leaflet

Basic example of taking an output from our server and putting it on a map. As leaflet allows you to add geoJSON directly, we convert it from esri's JSON format to a more standard one.


large geojson dataset mapped using geojquery, in chrome, but weirdly enough, not in IE9 the overlay doesn't quite keep up with the map when it pans.

calvinmetcalf /
Created Jul 20, 2012
bbox queries for large data sets

this is like the other example but since it has a larger dataset we start zoomed in farther, and reload the data every time the viewpoint changes instead of loading all of it when the map loads.

calvinmetcalf /
Created Nov 17, 2012
battle of the frameworks

design the new avid geo site in your framework of choice, can your rails beat the (Java|Coffee)script of the node hipsters? and what about all that smack talk I hear between the Django and Flask kids? bonus points for

  • Obscurity: CoffeeScript would get more points then JavaScript, Coco would get even more, but the framework you wrote that compiles Haskell to lolcode would win.
  • Hipsterocity: this is probably going to mean your going to need to involve mustaches
  • Overengineering: why use something as passe as nosql to store comments when you can write an Octree based storage engine where nodes communicate over a distributed hash table, or how about storing post tags as edges on a [hypergraph](

points show up for 0 opacity lines

with 0 opacity lines there seems to be point features that show up at lower zooms but go away when you zoom in


So your most likely going to be iterating through an array or an object, we'll start with an array;

var array = [1,2,3,4,5]; //your array

for(var i = 0; i<array.lengh; i++){

the only issue with that is that you are checking the length of the array every time, so instead you could do

View streetType.json