Permalink
Browse files

distance algo fix

  • Loading branch information...
1 parent e986c9b commit ab1f1c46eaea4bc22cd90d317afeeb8a640c5553 @RussellDias RussellDias committed Nov 26, 2011
Showing with 9 additions and 6 deletions.
  1. +3 −0 main.php
  2. +6 −6 receive-location.php
View
@@ -1,4 +1,7 @@
<?php
+error_reporting(-1);
+ini_set('display_errors', 'on');
+
$headers = array();
$toilets = array();
$row = 0;
View
@@ -3,7 +3,7 @@
$postdata = file_get_contents("php://input");
$user = json_decode($postdata, true);
-
+$user['location'] = array(-27.4675018,153.0246554);
//$user['location'][0] = lat
//$user['location'][1] = long
@@ -21,16 +21,16 @@
}, $toilets);
-$toilets = array_filter($toilets, function($member) {
- $max_distance = ($user['urgency'] + 500) * 2;
+$max_distance = (10 * $user['urgency']) + 1000;
+
+$toilets = array_filter($toilets, function($member) use ($max_distance) {
+ //$max_distance = ($user['urgency'] + 500) * 2;
return $member['distance'] < $max_distance;
});
usort($toilets, function($a, $b) {
return $a['distance'] - $b['distance'];
});
-
-
header('content-type: application/json');
-echo json_encode(array_slice($toilets, 0, 10));
+echo json_encode(array_slice($toilets, 0, 30));

0 comments on commit ab1f1c4

Please sign in to comment.