Skip to content

Instantly share code, notes, and snippets.

@boo1ean
Last active August 29, 2015 14:06
Show Gist options
  • Save boo1ean/7517e7b3dc55b21bacb4 to your computer and use it in GitHub Desktop.
Save boo1ean/7517e7b3dc55b21bacb4 to your computer and use it in GitHub Desktop.
var pollutants = [];
var findPollutant = function(point) {
for (var i in pollutants) {
if (pollutants[i].latitude == point[1] && pollutants[i].longitude == point[0]) {
return i;
}
}
return -1;
}
for (var i in waterbodies) {
var wb = waterbodies[i];
var points = waterbodies[i].points;
if (points && points.length) {
for (var j in points) {
var index = findPollutant(points[j]);
if (index === -1) {
pollutants.push({
latitude: points[j][1],
longitude: points[j][0],
causes: [wb.LW_DETAILED_CAUSE_NAME],
waterbody: wb.LISTED_WATER_NAME
});
} else {
pollutants[index].causes.push(wb.LW_DETAILED_CAUSE_NAME);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment