Skip to content

Instantly share code, notes, and snippets.

@LouisaKB
Created November 8, 2016 11:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save LouisaKB/16a59d599297a1c9abef0d12a572f68a to your computer and use it in GitHub Desktop.
Save LouisaKB/16a59d599297a1c9abef0d12a572f68a to your computer and use it in GitHub Desktop.
function filterByResponse(poi, responseText) {
var responseJson = JSON.parse(responseText);
// As a response we get dictionary with reachable points.
// In request we have set it up as id: coords, so keys of the dictionary are indices of the reachable points.
var reachablePointsKeys = Object.keys(responseJson.sources.source1.points);
var unreachablePoiKeys = Object.keys(poi).filter(function(elem) {
return reachablePointsKeys.indexOf(elem) == -1;
});
var reachablePoints = reachablePointsKeys.map(function(i){
return poi[i];
});
var unreachablePoints = unreachablePoiKeys.map(function (i) {
return poi[i];
});
return {reachable: reachablePoints, unreachable: unreachablePoints };
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment