node.js
server-side event-driven javascript
mongoDB
"noSQL" document-based database
leaflet.js
front-end library for mapping
d3.js
data-driven visualization toolbox
MongoClient.connect(url, function(err, db) { var incidents = db.collection('incidents'); ...
var dates = _.range(0,days_ago+1).map(function(i){ return moment().subtract(i,'days').format("YYYY-MM-DD"); }); async.eachLimit(dates,5,function(date,cb){ var url = "http://warhammer.mcc.virginia.edu/calls.php?fdate="+date; request(url, function(err, resp, body){ $ = cheerio.load(body); ...
incidents.update({ incident_id:incident.incident_id, unit:incident.unit_id },incident,{upsert:true},row_cb);
var geocoder = require('node-geocoder')('google','https',{apiKey:secrets.google_apikey}); var geocoderBottleneck = new bottleneck(0,200); async.eachLimit(incidents,5,function(incident,cb){ // keep under the rate limit... geocoder.geocode( incident.address+" Charlottesville, VA", function(err, location){ incidentsCollection.update( {_id:incident._id}, {"$set":{location:location} }, geocoderBottleneck.submit(cb,null,null)); } ); });https://github.com/nchaulet/node-geocoder
leaflet.js
open-source JS library for interactive maps
d3.json("data/rids.json", function(oa){ var d3Overlay = L.d3SvgOverlay( function(selection,projection){ selection.selectAll('#mapID circle').data(oa) .enter().append("circle") .attr("opacity",0.7) .attr("r", function(d){ var endScale = Math.pow(2, 11-m.getZoom()); return 1.0*Math.sqrt(d.incidents)*endScale; }) .attr("fill", function(d){ return svColorScale(d.averageResponseTime); }) .attr("cx",function(d){ var point = projection.latLngToLayerPoint([d.location.latitude, d.location.longitude]); return point.x; }); }, {zoomAnimate:true}); d3Overlay.addTo(m); });http://meekohi.com/rids
var svColorScale = d3.scale.linear().domain([0, 30]).range(["#66FF66","#FF6666"]); g.selectAll("scatter-dots") .data(calltimesByTime) .enter().append("svg:circle") .attr("cx", function (d,i) { return x(d[0]); } ) .attr("cy", function (d) { return y(d[2]); } ) .attr("r", 1) .attr("fill", function(d){ return svColorScale(d[2]); }) .attr("opacity",0.6);