Created
November 8, 2016 11:43
-
-
Save LouisaKB/16a59d599297a1c9abef0d12a572f68a 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
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