Fixed a numerical problem with the location system
This commit is contained in:
parent
37f06b272f
commit
eaac83d9ec
1 changed files with 5 additions and 4 deletions
|
@ -95,19 +95,20 @@ document.f.location.focus();
|
||||||
$loc = mysql_fetch_assoc(mysql_query($query));
|
$loc = mysql_fetch_assoc(mysql_query($query));
|
||||||
if($maxdist <= 10)
|
if($maxdist <= 10)
|
||||||
{
|
{
|
||||||
$query = "SELECT ROUND(6378.137 * ACOS((SIN(PI() * $loc[lat] / 180) * SIN(PI() * `locations`.`lat` / 180)) + (COS(PI() * $loc[lat] / 180 ) *
|
$query = "SELECT ROUND(6378.137 * ACOS(0.9999999*((SIN(PI() * $loc[lat] / 180) * SIN(PI() * `locations`.`lat` / 180)) + (COS(PI() * $loc[lat] / 180 ) *
|
||||||
COS(PI() * `locations`.`lat` / 180) * COS(PI() * `locations`.`long` / 180 - PI() * $loc[long] / 180))), -1) AS `distance`,
|
COS(PI() * `locations`.`lat` / 180) * COS(PI() * `locations`.`long` / 180 - PI() * $loc[long] / 180)))), -1) AS `distance`,
|
||||||
`locations`.`name` AS `location`, concat(`users`.`fname`, ' ', LEFT(`users`.`lname`, 1)) AS `name`, `long`, `lat`,
|
`locations`.`name` AS `location`, concat(`users`.`fname`, ' ', LEFT(`users`.`lname`, 1)) AS `name`, `long`, `lat`,
|
||||||
`users`.`id` as `uid`, `contactinfo` FROM `locations`, `users`, `notary` WHERE `users`.`locid` = `locations`.`id` AND
|
`users`.`id` as `uid`, `contactinfo` FROM `locations`, `users`, `notary` WHERE `users`.`locid` = `locations`.`id` AND
|
||||||
`users`.`id` = `notary`.`to` AND `users`.`listme` = 1 GROUP BY `notary`.`to`
|
`users`.`id` = `notary`.`to` AND `users`.`listme` = 1 GROUP BY `notary`.`to`
|
||||||
HAVING SUM(`notary`.`points`) >= 100 AND `distance` <= '$maxdist' ORDER BY `distance`";
|
HAVING SUM(`notary`.`points`) >= 100 AND `distance` <= '$maxdist' ORDER BY `distance`";
|
||||||
} else {
|
} else {
|
||||||
$query = "SELECT ROUND(6378.137 * ACOS((SIN(PI() * $loc[lat] / 180) * SIN(PI() * `locations`.`lat` / 180)) + (COS(PI() * $loc[lat] / 180 ) *
|
$query = "SELECT ROUND(6378.137 * ACOS(0.9999999*((SIN(PI() * $loc[lat] / 180) * SIN(PI() * `locations`.`lat` / 180)) + (COS(PI() * $loc[lat] / 180 ) *
|
||||||
COS(PI() * `locations`.`lat` / 180) * COS(PI() * `locations`.`long` / 180 - PI() * $loc[long] / 180))), -1) AS `distance`,
|
COS(PI() * `locations`.`lat` / 180) * COS(PI() * `locations`.`long` / 180 - PI() * $loc[long] / 180)))), -1) AS `distance`,
|
||||||
`locations`.`name` AS `location`, concat(`users`.`fname`, ' ', LEFT(`users`.`lname`, 1)) AS `name`, `long`, `lat`,
|
`locations`.`name` AS `location`, concat(`users`.`fname`, ' ', LEFT(`users`.`lname`, 1)) AS `name`, `long`, `lat`,
|
||||||
`users`.`id` as `uid`, `contactinfo` FROM `locations`, `users`, `notary` WHERE `users`.`locid` = `locations`.`id` AND
|
`users`.`id` as `uid`, `contactinfo` FROM `locations`, `users`, `notary` WHERE `users`.`locid` = `locations`.`id` AND
|
||||||
`users`.`id` = `notary`.`to` AND `users`.`listme` = 1 GROUP BY `notary`.`to`
|
`users`.`id` = `notary`.`to` AND `users`.`listme` = 1 GROUP BY `notary`.`to`
|
||||||
HAVING SUM(`notary`.`points`) >= 100 AND `distance` <= '$maxdist' ORDER BY `distance` LIMIT 50";
|
HAVING SUM(`notary`.`points`) >= 100 AND `distance` <= '$maxdist' ORDER BY `distance` LIMIT 50";
|
||||||
|
//echo $query;
|
||||||
}
|
}
|
||||||
$res = mysql_query($query);
|
$res = mysql_query($query);
|
||||||
?><table align="center" valign="middle" border="0" cellspacing="0" cellpadding="0" class="wrapper" width="700">
|
?><table align="center" valign="middle" border="0" cellspacing="0" cellpadding="0" class="wrapper" width="700">
|
||||||
|
|
Loading…
Reference in a new issue