当前位置: 首页>>代码示例>>PHP>>正文


PHP getDistance函数代码示例

本文整理汇总了PHP中getDistance函数的典型用法代码示例。如果您正苦于以下问题:PHP getDistance函数的具体用法?PHP getDistance怎么用?PHP getDistance使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了getDistance函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: findDistance

function findDistance($data)
{
    $timeArr = array();
    $totalDistance = 0;
    $data1 = explode("#", $data);
    for ($j1 = 0; $j1 < count($data1); $j1++) {
        $data2 = explode("\$", $data1[$j1]);
        if (count($data2) > 1) {
            $data3 = explode(",", $data2[1]);
            $vehi = $data3[0];
            $geodate = date("d-m-Y h:i A", @mktime($data3[4] + 5, $data3[5] + 30, $data3[6], $data3[2], $data3[1], $data3[3]));
            $geoTime = date("H:i:s A", @mktime($data3[4] + 5, $data3[5] + 30, $data3[6], $data3[2], $data3[1], $data3[3]));
            $pos1 = convertLat(calLat($data3[7]));
            $pos2 = convertLong(calLong($data3[8]));
            if ($pos1 > 0 && $pos2 > 0) {
                if (!in_array($geoTime, $timeArr)) {
                    if ($j1 == 0) {
                        $pits1 = $pos1;
                        $pits2 = $pos2;
                    } else {
                        $pits3 = $pos1;
                        $pits4 = $pos2;
                        $dist = getDistance($pits1, $pits2, $pits3, $pits4);
                        $totalDistance += $dist;
                        $pits1 = $pits3;
                        $pits2 = $pits4;
                    }
                }
            }
        }
        array_push($timeArr, $geoTime);
    }
    return round($totalDistance);
}
开发者ID:shameerariff,项目名称:gpsapps,代码行数:34,代码来源:showAllDevice.php

示例2: getResult

function getResult(&$rs, $x, $y, $km, $p, $id, $pageShow, $myKey, $lng = 'lng', $lat = 'lat')
{
    $km = $km * 1000;
    $data = array('data' => $rs, 'total_count' => 0, 'total_page' => 0);
    // 算出实际距离
    if ($data['data']) {
        $sortdistance = array();
        foreach ($data['data'] as $key => $val) {
            $distance = getDistance($x, $y, $val[$lng], $val[$lat]);
            if ($val[$myKey] != $id && $distance <= $km) {
                $data['data'][$key]['distance'] = $distance;
                $sortdistance[$key] = $distance;
                // 排序列
            } else {
                unset($data['data'][$key]);
            }
        }
        if ($sortdistance) {
            // 距离排序
            array_multisort($sortdistance, SORT_ASC, $data['data']);
            $data['total_count'] = count($data['data']);
            $data['total_page'] = ceil($data['total_count'] / $pageShow);
            if ($p > $data['total_page']) {
                $p = $data['total_page'];
            }
            $data['data'] = array_slice($data['data'], ($p - 1) * $pageShow, $pageShow);
        }
    }
    return $data;
}
开发者ID:sdgdsffdsfff,项目名称:51jhome_customerservice,代码行数:30,代码来源:distance.fun.php

示例3: validateAddresses

 protected function validateAddresses($origin, $destination)
 {
     $errorOrigin = '';
     $errorDestination = '';
     $distance = '';
     if (empty($origin)) {
         $errorOrigin = $this->errorMsg;
     }
     if (empty($destination)) {
         $errorDestination = $this->errorMsg;
     }
     if (!empty($origin) && !empty($destination)) {
         $arrayGoogleMapAPIResponse = getDistance($origin, $destination);
         if ($arrayGoogleMapAPIResponse['geocoded_waypoints'][0]['geocoder_status'] != 'OK') {
             $errorOrigin = $this->errorAddressMsg;
         }
         if ($arrayGoogleMapAPIResponse['geocoded_waypoints'][1]['geocoder_status'] != 'OK') {
             $errorDestination = $this->errorAddressMsg;
         }
         if (empty($errorOrigin) && empty($errorDestination) && $arrayGoogleMapAPIResponse['status'] != 'OK') {
             $errorDestination = $this->errorRouteMsg;
         }
     }
     if ($errorOrigin == '' && $errorDestination == '') {
         $distance = $arrayGoogleMapAPIResponse['routes'][0]['legs'][0]['distance']['value'];
     }
     $arrayErrorAddresses = [$errorOrigin, $errorDestination, $distance];
     return $arrayErrorAddresses;
 }
开发者ID:seboccis,项目名称:infinity,代码行数:29,代码来源:FormController.php

示例4: matchTrip

function matchTrip($tripId)
{
    if (!isLoggedIn()) {
        $response = array("status" => 1, "error" => "Invalid session");
        echo json_encode($response);
        return;
    }
    include "config.php";
    $myTripQuery = "SELECT * FROM " . $db_mysql_table_name . " WHERE id='" . $tripId . "'";
    $tripQuerySuccess = mysqli_query($link, $myTripQuery);
    if ($tripQuerySuccess) {
        if (mysqli_num_rows($tripQuerySuccess) == 1) {
            $matchTrip = mysqli_fetch_assoc($tripQuerySuccess);
        } else {
            $response = array("status" => 1, "error" => "Duplicate id in DB ");
            echo json_encode($response);
        }
    } else {
        $response = array("status" => 1, "error" => "Unable to run query in DB");
        echo json_encode($response);
    }
    $query = "SELECT * FROM " . $db_mysql_table_name . " WHERE state=0" . " AND id!='" . $tripId . "'" . " AND date='" . getTripDate($matchTrip) . "'";
    // Ensures rides are on the same day.
    $success = mysqli_query($link, $query);
    $rows = array();
    if ($success) {
        while ($row = mysqli_fetch_assoc($success)) {
            if (timeCoincides($row, $matchTrip)) {
                // Ensures that they start at around the same time.
                if (getDistance(getDestAddr($row), getDestAddr($matchTrip)) <= 3000) {
                    if (getDistance(getSourceAddr($row), getSourceAddr($matchTrip)) <= 3000) {
                        $rows[] = $row;
                    }
                }
            }
        }
        $response = array("status" => 0, "data" => $rows);
        $response = json_encode($response);
        foreach ($rows as $match) {
            send_email(getUserId($match), $response);
        }
        if (!empty($playerlist)) {
            // Do not send email if no match found
            send_email(getMailId(), $response);
        } else {
            // Send email of no match if needed.
        }
        echo json_encode($response);
    } else {
        $response = array("status" => 1, "error" => "Unable to run query in DB");
        echo json_encode($response);
    }
}
开发者ID:mrinaldhar,项目名称:CabShare,代码行数:53,代码来源:matchTrip.php

示例5: kmsPerDay

function kmsPerDay($path)
{
    $timeArr = array();
    $cnt = 1;
    $totalDistance = 0;
    $file1 = @fopen($path, "r");
    if ($file1) {
        $i = 0;
        while (!feof($file1)) {
            $data = fgets($file1);
            //$i++;
        }
        $data = getSortedData($data);
        $data1 = explode("#", $data);
        for ($j1 = 0; $j1 < count($data1); $j1++) {
            $data2 = explode("\$", $data1[$j1]);
            if (count($data2) > 1) {
                $data3 = explode(",", $data2[1]);
                $vehi = $data3[0];
                $geodate = date("d-m-Y h:i A", @mktime($data3[4] + 5, $data3[5] + 30, $data3[6], $data3[2], $data3[1], $data3[3]));
                $geoTime = date("H:i:s A", @mktime($data3[4] + 5, $data3[5] + 30, $data3[6], $data3[2], $data3[1], $data3[3]));
                $pos1 = convertLat(calLat($data3[7]));
                $pos2 = convertLong(calLong($data3[8]));
                if ($pos1 > 0 && $pos2 > 0) {
                    if (!in_array($geoTime, $timeArr)) {
                        if ($j1 == 0) {
                            $pits1 = $pos1;
                            $pits2 = $pos2;
                        } else {
                            $pits3 = $pos1;
                            $pits4 = $pos2;
                            $dist = getDistance($pits1, $pits2, $pits3, $pits4);
                            $totalDistance += $dist;
                            $pits1 = $pits3;
                            $pits2 = $pits4;
                        }
                    }
                }
            }
            array_push($timeArr, $geoTime);
        }
        //echo $data3[11];
        $res = simpleGeocode($pos1, $pos2);
        //print_r($res);
        $res = str_replace('"', "", $res);
        //echo $res."<br>";
        //echo round($totalDistance,2);
        $finalData = round($totalDistance) . "#" . $geodate . "#" . $res;
        fclose($file1);
        return $finalData;
    }
}
开发者ID:shameerariff,项目名称:gpsapps,代码行数:52,代码来源:monthlyReport.php

示例6: lists

 public function lists()
 {
     $must = array();
     $this->check_param($must);
     $this->check_sign();
     extract($this->params);
     do {
         if (!isset($page_size)) {
             $page_size = 10;
         }
         //设置默认的 city_id 为 1
         if (!isset($city_id)) {
             $city_id = 1;
         }
         $this->Table_model->init(T_DISTRICT);
         $where_map = array('city' => $city_id);
         //是否只返回已经开发的商圈
         if (isset($is_developed)) {
             $where_map['is_developed'] = $is_developed;
         }
         $limit_arr = array($page_size, $this->page_now);
         $order_map = array('is_developed' => 'desc');
         $res = $this->Table_model->records($where_map, array(), $limit_arr, $order_map);
         if ($res['err_num'] == 0) {
             $results =& $res['results'];
             $results['pager'] = paging($results['records_num'], $this->page_now, $page_size);
             foreach ($results['records'] as &$value) {
                 $value['photo'] = json_decode($value['photo']);
                 //@todo 因为城市暂时只有一个北京,先临时处理下
                 $value['city_name'] = "北京";
                 //如果传参数 longtitude , 和 latitude ,则多返回一个 用户距 商圈距离字段
                 if (isset($Latitude) && isset($Longitude)) {
                     if (!$Latitude) {
                         $value['distance'] = "无法获取您的位置信息";
                     }
                     if (!$Longitude) {
                         $value['distance'] = "无法获取您的位置信息";
                     } else {
                         $value['distance'] = getDistance($value['Latitude'], $value['Longitude'], $Latitude, $Longitude);
                     }
                 } else {
                     $value['distance'] = "无法获取您的位置信息";
                 }
             }
             unset($results['records_num']);
             $this->op($res);
         } else {
             $this->st(array(), "获取商圈列表失败!", API_UNKNOW_ERR);
         }
     } while (0);
     $this->op();
 }
开发者ID:codekissyoung,项目名称:kanjiebao,代码行数:52,代码来源:District.php

示例7: bestServer

function bestServer($location, $server)
{
    foreach ($server as $k => $s) {
        foreach ($location as $i => $loc) {
            $sum = $sum + getDistance($loc['latitutde'], $loc['longitude'], $s['latitude'], $s['longitude']);
            if ($sum <= $min || !$min) {
                $min = $sum;
                $id = $s['id'];
            }
        }
    }
    return $id;
}
开发者ID:marat1803,项目名称:tf2matchmaking,代码行数:13,代码来源:server.php

示例8: getStations

function getStations($lat, $lng, $rad)
{
    global $db;
    $ret = array();
    $q = mysqli_query($db, "SELECT * FROM `it_stations`");
    while (($station = mysqli_fetch_assoc($q)) != null) {
        $station["distance"] = ceil(getDistance((double) $station["lat"], (double) $station["lng"], (double) $lat, (double) $lng) * 1000);
        if ($station["distance"] < $rad * 1000) {
            $station["prices"] = getPrices($station["id"]);
            $ret[] = $station;
        }
    }
    return $ret;
}
开发者ID:xXSparkeyy,项目名称:harbour-spritradar,代码行数:14,代码来源:index.php

示例9: getDistance

function getDistance($evalCallback, $from, $previousDistance = 0, $previousLocations = [])
{
    global $routes;
    $previousLocations[] = $from;
    $distances = [];
    foreach ($routes[$from] as $to => $length) {
        if (\in_array($to, $previousLocations)) {
            continue;
        }
        // Here (at least on shortest path) we could stop if previous + length > previous-best
        $distances[$to] = \getDistance($evalCallback, $to, $previousDistance + $length, $previousLocations);
    }
    return empty($distances) ? $previousDistance : \call_user_func($evalCallback, $distances);
}
开发者ID:boast,项目名称:adventofcode,代码行数:14,代码来源:day_09.php

示例10: testUserLocation

 public function testUserLocation()
 {
     $this->load->model('Venue_model');
     $this->load->model('User_model');
     $this->load->helper("location");
     $me = $this->User_model->load(1);
     $me = $me[0];
     $peppers = $this->Venue_model->load(1);
     $peppers = $peppers[0];
     $capital = $this->Venue_model->load(7);
     $capital = $capital[0];
     $distanceToPeps = getDistance($me->lastLocationLat, $me->lastLocationLong, $peppers->latitude, $peppers->longitude);
     $distanceToCap = getDistance($me->lastLocationLat, $me->lastLocationLong, $capital->latitude, $capital->longitude);
     //echo "To Peps: " . $distanceToPeps . ", To Capital: " . $distanceToCap;
     self::printJson($capital);
 }
开发者ID:boyernotseaboyer,项目名称:Cheapskate,代码行数:16,代码来源:CheapskateAPI.php

示例11: showdetail

 public function showdetail()
 {
     global $G, $lang;
     $tid = intval($_GET['tid']);
     $task = $this->t('task')->where(array('tid' => $tid))->selectOne();
     if ($task) {
         $task['pic'] = image($task['pic']);
         $task['distance'] = getDistance($this->longitude, $this->latitude, $task['longitude'], $task['latitude']);
         if ($_GET['datatype'] == 'json') {
             $task['content'] = stripHtml($task['content']);
             $this->showAppData($task);
         } else {
             include template('task_detail', 'app');
         }
     }
 }
开发者ID:xy113,项目名称:XiangBaLaoServer,代码行数:16,代码来源:class.TaskController.php

示例12: liveKmsPerDay

function liveKmsPerDay($lData, $sTime1, $eTime1)
{
    $timeArr = array();
    //$ptArr = array();
    $cnt = 0;
    $totalDistance = 0;
    $data1 = explode("#", $lData);
    for ($j1 = 0; $j1 < count($data1); $j1++) {
        $data2 = explode("@", $data1[$j1]);
        if (count($data2) > 1) {
            $data3 = explode(",", $data2[1]);
            $geodate = $data3[8];
            $geoTime = $data3[9];
            $curTime = explode(":", $data3[9]);
            $curTime = $curTime[0] * 60 + $curTime[1];
            //echo "<br>";
            if ($curTime >= $sTime1 && $curTime <= $eTime1) {
                $pos1 = calLat($data3[2]);
                $pos2 = calLong($data3[1]);
                if ($pos1 > 0 && $pos2 > 0) {
                    if (!in_array($geoTime, $timeArr)) {
                        if ($cnt == 0) {
                            $pits1 = $pos1;
                            $pits2 = $pos2;
                        } else {
                            $pits3 = $pos1;
                            $pits4 = $pos2;
                            //echo $sTime1." >= ".$curTime." <= ".$eTime1." ".$totalDistance."<br>";
                            $dist = getDistance($pits1, $pits2, $pits3, $pits4);
                            $totalDistance += $dist;
                            $pits1 = $pits3;
                            $pits2 = $pits4;
                        }
                    }
                }
                $cnt++;
            }
        }
        array_push($timeArr, $geoTime);
    }
    //$res=simpleGeocode($pos1,$pos2);
    //$res=str_replace('"',"",$res);
    $finalData = round($totalDistance);
    return $finalData;
}
开发者ID:shameerariff,项目名称:gpsapps,代码行数:45,代码来源:distance.php

示例13: showdetail

 /**
  * 显示商品详细信息
  */
 public function showdetail()
 {
     global $G, $lang;
     $id = intval($_GET['id']);
     $this->t('goods')->where(array('id' => $id))->update('viewnum=viewnum+1');
     $goods = $this->t('goods')->where(array('id' => $id))->selectOne();
     $goods['dateline'] = @date('Y-m-d H:i', $goods['dateline']);
     $goods['modified'] = @date('Y-m-d H:i', $goods['modified']);
     $goods['pic'] = image($goods['pic']);
     $goods['distance'] = getDistance($this->longitude, $this->latitude, $goods['longitude'], $goods['latitude']);
     if ($_GET['datatype'] == 'json') {
         $this->showAppData($goods);
     } else {
         $json = json_encode($goods);
         $description = $this->t('goods_description')->where(array('goods_id' => $id))->selectOne();
         $shop = $this->t('shop')->where(array('shopid' => $goods['shopid']))->selectOne();
         $shop['pic'] = image($shop['pic']);
         include template('goods_detail', 'app');
     }
 }
开发者ID:xy113,项目名称:XiangBaLaoServer,代码行数:23,代码来源:class.GoodsController.php

示例14: getSaving

function getSaving($source, $destination)
{
    $data = getDistance($source, $destination);
    $fare = calculateFare($data["distance"]);
    $duration = minToHours(calculateDuration($data["distance"]));
    $start_date = "06/03/2015";
    $end_date = "09/03/2015";
    $geoCordinates = get_lat_long($destination);
    $hotelPrice = getStayzillahotel($geoCordinates[0], $geoCordinates[1], $start_date, $end_date);
    $Price = $hotelPrice->hotels[0]->rawPrice;
    $stayzillaSource = $hotelPrice->hotels[0]->address;
    $data_User = array("distance" => $data["distance"], "duration" => $duration, "cabFare" => $fare);
    $stayzillaData = getDistance($stayzillaSource, $destination);
    $stayZillaDistance = number_format((double) $hotelPrice->hotels[0]->distanceFromLatLong / 1000, 2, '.', '');
    $stayzillafare = calculateFare($stayZillaDistance);
    $stayzillaDuration = minToHours(calculateDuration($stayZillaDistance));
    $data_stayzilla = array("distance" => $stayZillaDistance . " km", "duration" => $stayzillaDuration, "cabFare" => $stayzillafare, "hotelFare" => $Price, "hotelData" => $hotelPrice->hotels[0]);
    $responceData = array();
    $responceData["user"] = $data_User;
    $responceData["stayzilla"] = $data_stayzilla;
    return json_encode($responceData);
}
开发者ID:VishnuSubramanian,项目名称:stayzilla-hackathon-web,代码行数:22,代码来源:caluclate_saving.php

示例15: addTableData

function addTableData()
{
    $abfrage = "SELECT * FROM Hotel";
    $ergebnis = mysql_query($abfrage);
    if (mysql_num_rows($ergebnis) == 0) {
        echo "keine Daten vorhanden";
    }
    while ($row = mysql_fetch_row($ergebnis)) {
        //Land besorgen
        $ab = "SELECT * FROM Countries WHERE iso2='" . $row[6] . "'";
        $land = mysql_fetch_object(mysql_query($ab));
        //Zimmerbuchungen besorgen
        $ab1 = "SELECT * FROM Zimmerbuchung WHERE hotelid='" . $row[0] . "' AND von<'" . date("Y-m-d H:i:s") . "' AND bis>'" . date("Y-m-d H:i:s") . "'";
        $zimmer = mysql_num_rows(mysql_query($ab1));
        $zimmer = !$zimmer ? "0" : $zimmer;
        $hotelname = getHotelNameByID($row[0]);
        //Tabellenzeile einfügen
        echo "<tr>";
        echo '<td><div class="box">
		<p class"hover">' . $row[0] . '</p>
		<div class="mask"><img class="minipic" src="../images/hotels/' . getHotelBild($hotelname) . '" width="250" height="270" border="0" alt=' . $hotelname . '></div>
		</td>';
        // echo "<td>" . $row[0] . "</td>";
        echo '<td class="name">' . $row[1] . '<input type="button" class="showZimmer" value="Zimmer" onclick=\'window.location.href = "#' . $row[0] . '"\'/></td>';
        echo "<td style='width:125px;'><p hidden>" . $row[2] . "</p>" . addSterne($row[2]) . "</td>";
        echo '<td><span class="pie">' . $zimmer . '/' . $row[3] . '</span><br>' . $zimmer . '/' . $row[3] . '</td>';
        echo "<td>" . $row[4] . "<br>" . $row[5] . "<br>" . $land->country . "<img src='../images/flags/" . strtolower($row[6]) . ".png'></td>";
        $flughafen = getDistance($row[4] . " " . $row[5], "airport " . $row[8]);
        echo "<td>" . getOrtAndFlag($row[8]) . "<br>" . $flughafen . " km</td>";
        echo "<td><a href='" . $row[7] . "'>Link</a></td>";
        echo "<td><a href='../phpdata/hotelAendern.php?";
        echo addEditList($row[0], "Hotel");
        echo "#openModal'><img src='../images/edit.png'  class='bin'></td>";
        echo "<td><a href='../phpdata/hotelLoeschen.php?id=" . $row[0] . "'><img src='../images/loeschen.png'  class='bin'></td>";
        echo "</tr>";
    }
}
开发者ID:class142,项目名称:proj,代码行数:37,代码来源:hotels.php


注:本文中的getDistance函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。