From 3bcb12b3efcdeeb975594a8efebb225089690d34 Mon Sep 17 00:00:00 2001 From: David MAECHLER Date: Mon, 6 Apr 2020 02:00:21 +0200 Subject: [PATCH] add stub method for recheck on group members proximity --- back/src/Controller/position.js | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/back/src/Controller/position.js b/back/src/Controller/position.js index 605c1163..01fb5cdf 100644 --- a/back/src/Controller/position.js +++ b/back/src/Controller/position.js @@ -72,6 +72,7 @@ let createGroups = function(distances) { if(groups[i].indexOf(dist.first) === -1 && typeof alreadyInAGroup[dist.first.id] === 'undefined') { if(groups[i].length > 1) { + // if group is not empty we check current user can be added in the group according to its distance to the others already in it for(let l = 0; l < groups[i].length; l++) { let userTotest = groups[i][l]; if(computeDistance(dist.first, userTotest) <= MIN_DISTANCE) { @@ -97,6 +98,7 @@ let createGroups = function(distances) { if(groups[i].indexOf(dist.second) === -1 && typeof alreadyInAGroup[dist.second.id] === 'undefined') { if(groups[i].length > 1) { + // if group is not empty we check current user can be added in the group according to its distance to the others already in it for(let l = 0; l < groups[i].length; l++) { let userTotest = groups[i][l]; if(computeDistance(dist.second, userTotest) <= MIN_DISTANCE) { @@ -123,7 +125,22 @@ distances.sort(compareDistances); let groups = createGroups(distances); -// TODO : Créer une méthode pour checker la distance entre les membres du groupes pour savoir s'il faut les dissoudre ou non +// Compute distance between each user of a already existing group +let checkGroupDistance = function(groups) { + for(let i = 0; i < groups.length; i++) { + let group = groups[i]; + group.forEach(function(user1, key1) { + group.forEach(function(user2, key2) { + if(key1 < key2) { + let distance = computeDistance(user1, user2); + if(distance > MIN_DISTANCE) { + // TODO : message a user1 et user2 + } + } + }); + }); + } +}; console.log(users); console.log(distances);