function DetResult($tp) { // to google distance matrix point // 0 is $tp first // 1 is $tp second // 2 is driver end point $whichPoint; $tpNum = count($tp); if ($tpNum) { if ($tp[0]['type'] == 1) { // get in condition // DetGetinCar($passengerCurrentPoint, $driverCurrentPoint, $passengerGetinPoint) if (DetGetinCar($tp[0]['curpoint'], $GLOBALS['data']['curpoint'], $tp[0]['point'])) { // this passenger get in car // update db infomation // UPDATE `passenger` SET `passenger`.`getinStatus` = 1 WHERE (NOT `passenger`.`finished`) AND `passenger`.`aid` = 1046779538684829 $UpdatePassStatusSql = 'UPDATE `passenger` SET `passenger`.`getinStatus` = 1 WHERE (NOT `passenger`.`finished`) AND `passenger`.`aid` = ' . $tp[0]['id']; $UpdatePassStatusResult = mysql_query($UpdatePassStatusSql); $whichPoint = $tpNum > 1 ? 1 : 2; } else { $whichPoint = 0; } } else { // get out off condition // DetGetoutoffCar($passengerCurrentPoint, $driverCurrentPoint, $passengerGetoutPoint) if (DetGetoutoffCar($tp[0]['curpoint'], $GLOBALS['data']['curpoint'], $tp[0]['point'])) { // this passenger get out off car // update db infomation // UPDATE `passenger` SET `passenger`.`getoffStatus` = 1 WHERE (NOT `passenger`.`finished`) AND `passenger`.`aid` = 1046779538684829 $UpdatePassStatusSql = 'UPDATE `passenger` SET `passenger`.`getoffStatus` = 1 WHERE (NOT `passenger`.`finished`) AND `passenger`.`aid` = ' . $tp[0]['id']; $UpdatePassStatusResult = mysql_query($UpdatePassStatusSql); $whichPoint = $tpNum > 1 ? 1 : 2; } else { $whichPoint = 0; } } } else { $whichPoint = 2; } // google distance matrix api cal result // function getPathDistance($p1, $p2, $mode) // $p1 is driver curpoint in here // $p2 is destination mean $whichPoint in here // $mode could be driving (default), walking, bicycling, transit if ($whichPoint > 1) { $gdmResult = getPathDistance($GLOBALS['data']['curpoint'], end($GLOBALS['neceData']['driverPath']), "driving"); } else { $gdmResult = getPathDistance($GLOBALS['data']['curpoint'], $tp[$whichPoint]['point'], "driving"); } // $tp[0] point if get in or get out off // $whichPoint is driver page display infomation to driver by google distance matrix api $calResult = array(); if (!$whichPoint) { // client page display point // one point // passenger state 0 is the passenger not get in or get out off array_push($calResult, array("id" => $tp[0]['id'], "type" => $tp[0]['type'], "curpoint" => $tp[0]['curpoint'], "gdm" => $gdmResult)); } else { // two points // 0 is next point to show if ($whichPoint > 1) { array_push($calResult, array("id" => $GLOBALS['data']['did'], "type" => 0, "curpoint" => null, "passengerState" => null, "gdm" => $gdmResult)); } else { array_push($calResult, array("id" => $tp[1]['id'], "type" => $tp[1]['type'], "curpoint" => $tp[1]['curpoint'], "gdm" => $gdmResult)); } // $calResult[1] will be removed point on map if ($tpNum) { array_push($calResult, array("id" => $tp[0]['id'], "type" => $tp[0]['type'], "curpoint" => null, "gdm" => null)); } } return $calResult; }
for ($k = 0; $k < $compare_n; $k++) { $overlap = PathCompare(json_encode($newPassengerPath2), $driverPath[$k], true); if ($overlap != null) { //pºâ¦@¼¶ZÂ÷ $carpoolDistance = getDistance($overlap[0]); //pºâ¤W¨®ÂI»P¼«È°_ÂI¶ZÂ÷(m)»P¼«È¨«¸ô®É¶¡(s) $distRes = getPathDistance($newPassengerPath2[0], $overlap[0], 'walking'); $onDistance = $distRes[0]; $passengerTime3 = $distRes[1]; //pºâ¤U¨®ÂI»P¼«È²×ÂI¶ZÂ÷(m) $offn = count($newPassengerPath2) - 1; $distArr = array(); array_push($distArr, $newPassengerPath2[$offn], $overlap[count($overlap) - 1]); $offDistance = getDistance($distArr); //pºâ¥q¾÷¦æ¾p®É¶¡(s) $distRes = getPathDistance($driverPos[$k], $overlap[0], 'driving'); $driverTime3 = $distRes[1]; //pºâ¦w¥þ¶ZÂ÷ $safeArr = array(); array_push($safeArr, $driverPos[$i], $newPassengerPath2[0]); $safeDistance = getDistance($safeArr); //pºâ¦@¼¤ñ¨Ò $per = round($carpoolDistance / $totalDistance * 100); //¦]¬°»~®t¡A¦³¥i¯à¶W¹L100% if ($per > 100) { $per = 100; } //¿z¿ï¥q¾÷Ä@·Nµ¥«Ý®É¶¡»P¼«ÈÄ@·Nµ¥«Ý®É¶¡ if ($safeDistance <= $_SAFE || $per < $percentage || $onDistance > $distance || $driverTime3 > $passengerTime + $carpoolTime + $passengerTime2 + $carpoolTime2 + $passengerTime3 + $waiting * 60 || $passengerTime + $carpoolTime + $passengerTime2 + $carpoolTime2 + $passengerTime3 > $driverTime3 + $driverWait[$j] * 60) { $match3 = false; }