Created
April 21, 2019 12:10
-
-
Save jagtalon/b30cb98aa91dcaad126e139aec0a6998 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
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