• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

PHP getDistance函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: pdo_fetchall

        $activities = pdo_fetchall("select * from " . tablename('weilive_activity') . " where start_time < " . time() . " and end_time > " . time() . " and flag = 0 and isopen = 1 and weid = " . $weid);
        $total = pdo_fetchcolumn('SELECT COUNT(id) FROM ' . tablename('weilive_stores') . " WHERE weid = :weid AND status<>0 AND checked=1 {$condition_store} ", array(':weid' => $weid));
    }
} else {
    $styles = 2;
    if (empty($_GPC['lng'])) {
        $gps = false;
    } else {
        $gps = true;
        $lng = $_GPC['lng'];
        $lat = $_GPC['lat'];
        $stores = pdo_fetchall("SELECT * FROM " . tablename('weilive_stores') . " WHERE weid = :weid AND status<>0 AND checked=1 {$condition_store} {$order_condition} LIMIT " . ($pindex - 1) * $psize . ',' . $psize, array(':weid' => $weid));
        $distance = empty($setting) ? 5 : $setting['distance'];
        $total1 = 0;
        foreach ($stores as $key => $s) {
            $stores[$key]['dis'] = getDistance($lng, $lat, $s['lng'], $s['lat']);
            if ($stores[$key]['dis'] > $distance) {
                $total1++;
                unset($stores[$key]);
            }
        }
        if (!empty($stores)) {
            foreach ($stores as $key => $row) {
                $level[$key] = $row['level'];
                $dis[$key] = $row['dis'];
            }
            array_multisort($dis, SORT_ASC, $level, SORT_DESC, $stores);
        }
        $total = pdo_fetchcolumn('SELECT COUNT(*) FROM ' . tablename('weilive_stores') . " WHERE weid = :weid AND status<>0 AND checked=1 {$condition_store} ", array(':weid' => $weid));
        $total = $total - $total1;
        $activities = pdo_fetchall("select * from " . tablename('weilive_activity') . " where start_time < " . time() . " and end_time > " . time() . " and flag = 0 and isopen = 1 and weid = " . $weid);
开发者ID:keycoolkui,项目名称:weixinfenxiao,代码行数:31,代码来源:list.php


示例17: searchArea

 public function searchArea()
 {
     $resto_cuisine = '';
     $rating = '';
     $minimum = '';
     $pay_by = '';
     $minus_has_delivery_rates = 0;
     $cuisine_list = Yii::app()->functions->Cuisine(true);
     $country_list = Yii::app()->functions->CountryList();
     $this->data['s'] = isset($this->data['s']) ? $this->data['s'] : "";
     $search_str = explode(",", $this->data['s']);
     if (is_array($search_str) && count($search_str) >= 2) {
         $city = isset($search_str[1]) ? trim($search_str[1]) : '';
         $state = isset($search_str[2]) ? trim($search_str[2]) : '';
     } else {
         $city = trim($this->data['s']);
         $state = trim($this->data['s']);
     }
     $from_address = $this->data['s'];
     if (empty($from_address)) {
         $from_address = isset($this->data['st']) ? $this->data['st'] : '';
         if (!empty($this->data['st'])) {
             $_SESSION['kr_search_address'] = $this->data['st'];
         }
     }
     if ($res = Yii::app()->functions->searchByArea($city, $state)) {
         if (is_array($res) && count($res) >= 1) {
             $total = Yii::app()->functions->search_result_total;
             $feed_datas['sEcho'] = $this->data['sEcho'];
             $feed_datas['iTotalRecords'] = $total;
             $feed_datas['iTotalDisplayRecords'] = $total;
             /*dump($feed_datas);
               die();*/
             foreach ($res as $val) {
                 $merchant_address = $val['street'] . " " . $val['city'] . " " . $val['post_code'];
                 $miles = 0;
                 $kms = 0;
                 $ft = false;
                 $new_distance_raw = 0;
                 if ($distance = getDistance($from_address, $merchant_address, $val['country_code'], false)) {
                     $miles = $distance->rows[0]->elements[0]->distance->text;
                     //dump($miles);
                     if (preg_match("/ft/i", $miles)) {
                         $ft = true;
                         $miles_raw = $miles;
                         $new_distance_raw = str_replace("ft", '', $miles);
                         $new_distance_raw = ft2kms(trim($new_distance_raw));
                     } else {
                         $miles_raw = str_replace(array(" ", "mi"), "", $miles);
                         $kms = miles2kms(unPrettyPrice($miles_raw));
                         $new_distance_raw = $kms;
                         $kms = standardPrettyFormat($kms);
                     }
                 }
                 /*get merchant distance */
                 $mt_delivery_miles = Yii::app()->functions->getOption("merchant_delivery_miles", $val['merchant_id']);
                 $merchant_distance_type = Yii::app()->functions->getOption("merchant_distance_type", $val['merchant_id']);
                 /*dump($mt_delivery_miles);
                 		dump($miles_raw);*/
                 $resto_cuisine = '';
                 $cuisine = !empty($val['cuisine']) ? (array) json_decode($val['cuisine']) : false;
                 if ($cuisine != false) {
                     foreach ($cuisine as $valc) {
                         if (array_key_exists($valc, (array) $cuisine_list)) {
                             $resto_cuisine .= $cuisine_list[$valc] . ", ";
                         }
                     }
                     $resto_cuisine = !empty($resto_cuisine) ? substr($resto_cuisine, 0, -2) : '';
                 }
                 $resto_info = "<h5><a href=\"" . baseUrl() . "/store/menu/merchant/" . $val['restaurant_slug'] . "\">" . $val['restaurant_name'] . "</a></h5>";
                 //$resto_cuisine="<span class=\"cuisine-list\">".$resto_cuisine."</span>";
                 $resto_cuisine = wordwrap($resto_cuisine, 50, "<br />\n");
                 $resto_info .= "<p class=\"uk-text-muted\">" . $val['street'] . " " . $val['city'] . " " . $val['post_code'] . "</p>";
                 if (array_key_exists($val['country_code'], (array) $country_list)) {
                     $resto_info .= "<p class=\"uk-text-bold\">" . $country_list[$val['country_code']] . "</p>";
                 }
                 $resto_info .= "<p class=\"uk-text-bold\">" . Yii::t('default', "Cuisine") . " - " . $resto_cuisine . "</p>";
                 $delivery_est = Yii::app()->functions->getOption("merchant_delivery_estimation", $val['merchant_id']);
                 $distancesya = $miles_raw;
                 $unit_distance = $merchant_distance_type;
                 if (!empty($from_address)) {
                     if ($ft == TRUE) {
                         $resto_info .= "<p><span class=\"uk-text-bold\">" . Yii::t("default", "Distance") . ": </span> {$miles_raw} </p>";
                         if ($merchant_distance_type == "km") {
                             $distance_type = Yii::t("default", "km");
                         } else {
                             $distance_type = Yii::t("default", "miles");
                         }
                     } else {
                         if ($merchant_distance_type == "km") {
                             $distance_type = Yii::t("default", "km");
                             $resto_info .= "<p><span class=\"uk-text-bold\">" . Yii::t("default", "Distance") . ": </span> {$kms} " . Yii::t("default", "km") . "</p>";
                             $distancesya = $kms;
                         } else {
                             $resto_info .= "<p><span class=\"uk-text-bold\">" . Yii::t("default", "Distance") . ": </span> {$miles_raw} " . Yii::t("default", "miles") . "</p>";
                             $distance_type = Yii::t("default", "miles");
                         }
                     }
                 }
                 $resto_info .= "<p><span class=\"uk-text-bold\">" . Yii::t("default", "Delivery Est") . ": </span> " . $delivery_est . "</p>";
//.........这里部分代码省略.........
开发者ID:ashishvazirani,项目名称:food,代码行数:101,代码来源:AjaxAdmin.php


示例18: storeData

function storeData($data, $km, $devName, $sTime2, $eTime2)
{
    //echo $data;
    $data1 = explode("#", $data);
    $latnlong_values = "";
    //$xml = '<gps geoData="'.$latnlong_values.'" geoPointName="'.$point_names.'">';
    $km = explode("#", $km);
    $totKm += $km[0];
    $totPath .= $km[1];
    //print_r($km);
    //exit;
    $xml = '<gps>';
    $timeArr = array();
    $totalDistance = 0;
    $ct = 0;
    $j1 = 0;
    while ($j1 < count($data1)) {
        $data2 = explode("@", $data1[$j1]);
        if (count($data2) > 1) {
            $data3 = explode(",", $data2[1]);
            //print_r($data3);
            $date = $data3[8] / 1000;
            $date = $data3[8] . " " . $data3[9];
            $geodate = $data3[8] . " " . $data3[9];
            $geoTime = $data3[9];
            $pos1 = calLat($data3[2]);
            $pos2 = calLong($data3[1]);
            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;
                    }
                    $mph = $data3[3];
                    $direction = $data3[4];
                    $altitute = $data3[5];
                    $deviceIMEI = $data3[0];
                    $sessionID = $_GET["sessionID"];
                    $accuracy = $data3[6];
                    $extraInfo = $data3[6];
                    $fule_param = $data3[7];
                    $d = preg_split("/[\\s,]+/", $fule_param);
                    foreach ($d as $e) {
                        if (substr($e, 0, 3) == '[9=') {
                            $fuel = str_replace(array('[9=', ']'), '', $e);
                        }
                        if (substr($e, 0, 3) == '[1=') {
                            $engine = str_replace(array('[1=', ']'), '', $e);
                            if ($engine == '1') {
                                $engine_st = 'On';
                            } else {
                                $engine_st = 'Off';
                            }
                        }
                    }
                    $xml .= '<locations latitude="' . $pos1 . '" longitude="' . $pos2 . '" speed="' . $mph . '" direction="' . $direction . '" altitute="' . $altitute . '" curTime = "' . $curTime . '" distance="' . round($totalDistance) . '" gpsTime="' . date("h:i A", strtotime($geoTime)) . '" geodate="' . $geodate . '" deviceIMEI="' . $deviceIMEI . '" deviceName="' . $devName . '" sessionID="' . $sessionID . '"  extraInfo="' . $extraInfo . '"  route="' . $rtName . '"  other="' . $data3[7] . '"/>';
                }
            }
        }
        array_push($timeArr, $geoTime);
        if ($j1 > 0) {
            $dif = count($data1) - $j1;
            if ($dif > 10) {
                $j1 = $j1 + 10;
            } else {
                $j1 = $j1 + 1;
            }
            //echo $dif." ".$j1." ".count($data1)."<br>";
        } else {
            $j1 = $j1 + 1;
            //echo $dif." ".$j1." ".count($data1)."<br>";
        }
    }
    $xml .= '<OtherData totPt="' . $totPath . '" geoData="" geoPointName="" totalDist="' . $totKm . '" />';
    $xml .= '</gps>';
    header('Content-Type: text/xml');
    echo $xml;
}
开发者ID:shameerariff,项目名称:gpsapps,代码行数:85,代码来源:locations.php


示例19: get_member_demand

 /**
  * 用户需求详情 type=1 未报价 type=2已报价
  */
 public function get_member_demand()
 {
     //跨域解决方法: 指定域名
     header('Access-Control-Allow-Origin:http://www.caryu.net');
     header('Access-Control-Allow-Credentials:true');
     $mer_session_id = $_POST['mer_session_id'];
     $merchant_id = $this->session_handle->getsession_userid($mer_session_id);
     $id = (int) $_POST['id'];
     $bidd = M('MerchantBidding')->where(array('demand_id' => $id, 'merchant_id' => $merchant_id))->find();
     if ($bidd) {
         $type = 2;
     } else {
         $type = 1;
     }
     if (empty($id)) {
         $this->jsonUtils->echo_json_msg(4, '车主需求ID为空...');
         exit;
     }
     $arr = $this->dao->query("select a.id,a.status as demand_status ,from_unixtime(a.reach_time,'%Y-%m-%d %H:%i') as reach_time ,a.description,a.pics,a.member_id,a.longitude,a.latitude,a.cart_data,b.nick_name,b.header,a.publish,a.expire_time from " . C('DB_PREFIX') . "member_demand as a left join " . C('DB_PREFIX') . "member as b on a.member_id = b.id   where a.id={$id}");
     if ($arr) {
         $arr[0]['header'] = imgUrl($arr[0]['header']);
         $cart = json_decode($arr[0]['cart_data'], true);
         $arr[0]['cart_model'] = $cart['cart_model'];
         $model = new Model();
         $merchant = M('Merchant');
         $mer_arr = $merchant->field("longitude,latitude")->where("id={$merchant_id}")->select();
         $longitude = $arr[0]['longitude'];
         // 用户发布需求的经纬度
         $latitude = $arr[0]['latitude'];
         $demand_id = $arr[0]['id'];
         // 计算商家店铺和用户需求距离
         $arr[0]['distance'] = getDistance($latitude, $longitude, $mer_arr[0]['latitude'], $mer_arr[0]['longitude']);
         $is_expire = time() - $arr[0]['expire_time'] > 0 ? '1' : '0';
         if ($is_expire) {
             if ($arr[0]['demand_status'] == 0) {
                 $arr[0]['demand_status'] = '3';
                 //过期
             }
         }
         // 服务项目信息
         if ($arr[0]['publish'] == 0) {
             $category = "category";
         } elseif ($arr[0]['publish'] == 1) {
             $category = "car_maintain_category";
         } else {
             $this->jsonUtils->echo_json_msg(4, '订单有误');
             exit;
         }
         //
         $s_arr = $model->query("select b.name,b.id from " . C('DB_PREFIX') . "member_demand_subitems as a left join " . C('DB_PREFIX') . "{$category} as b on a.category_id=b.id  where a.demand_id={$demand_id} ");
         $perlist = array();
         if ($s_arr) {
             if ($type == 1) {
                 // 未报价
                 $arr[0]['merchant_remark'] = '';
             } elseif ($type == 2) {
                 // 已报价 bidding
                 $merchant_remark = M('MerchantBiddingRemark')->where(array('demand_id' => $id, 'merchant_id' => $merchant_id))->getField('remark');
                 $arr[0]['merchant_remark'] = !empty($merchant_remark) ? $merchant_remark : '';
                 $map['demand_id'] = $id;
                 $map['merchant_id'] = $merchant_id;
                 $alert_price = M('MerchantBidding')->where($map)->field('id as bidding_id,price,sub_id as cat_id,out_time as time')->select();
                 foreach ($alert_price as $tem) {
                     $price[$tem['cat_id']] = $tem;
                 }
             } else {
                 $this->jsonUtils->echo_json_msg(4, '参数不全.');
                 exit;
             }
             // 区分是报价为0 还是未报价,-1标识未报价
             foreach ($s_arr as $key => $row) {
                 $perlist[$key]['category_id'] = $row['id'];
                 $perlist[$key]['server_name'] = $row['name'];
                 $perlist[$key]['is_server'] = 1;
                 $perlist[$key]['price'] = !isset($price[$row['id']]['price']) ? '-1' : $price[$row['id']]['price'];
                 $perlist[$key]['bidding_id'] = !isset($price[$row['id']]['bidding_id']) ? '-1' : $price[$row['id']]['bidding_id'];
                 $perlist[$key]['time'] = !isset( 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP getDivResult函数代码示例发布时间:2022-05-15
下一篇:
PHP getDisplayDate函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap