Skip to content

Instantly share code, notes, and snippets.

@jagtalon
Created April 21, 2019 12:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jagtalon/b30cb98aa91dcaad126e139aec0a6998 to your computer and use it in GitHub Desktop.
Save jagtalon/b30cb98aa91dcaad126e139aec0a6998 to your computer and use it in GitHub Desktop.
{
let phillyNeighborhoods = {};
let workingPhillyBike = phillyBike;
phillyGeo.features.forEach(function(geo) {
phillyNeighborhoods[geo.properties.listname] = {
count: 0,
cartodb_id: geo.properties.cartodb_id
};
let reducedPhillyBike = workingPhillyBike;
workingPhillyBike = [];
reducedPhillyBike.forEach(function(bike) {
if(d3Geo.geoContains(geo, [bike.end_lon, bike.end_lat])) {
phillyNeighborhoods[geo.properties.listname].count += 1;
} else {
workingPhillyBike.push(bike);
}
});
});
let neighborhoods = Object.keys(phillyNeighborhoods).map(function(n) {
return {"Neighborhood": n,
"Count": phillyNeighborhoods[n].count,
cartodb_id: phillyNeighborhoods[n].cartodb_id};
});
return neighborhoods;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment