Example #1
0
function storeData($data, $km, $devName, $sTime2, $eTime2)
{
    //echo $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;
    $data1 = explode("#", $data);
    $data2 = explode("@", $data1[count($data1) - 2]);
    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];
                $devModel = getDeviceModel($data3[0]);
                $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 . '" fuel=3 extraInfo="' . $extraInfo . '"  deviceModel="' . $devModel . '" route="' . $rtName . '" other="' . $data3[7] . '"/>';
            }
        }
    }
    array_push($timeArr, $geoTime);
    //}
    $xml .= '<OtherData totPt="' . $totPath . '" geoData="" geoPointName="" totalDist="' . $totKm . '" />';
    $xml .= '</gps>';
    header('Content-Type: text/xml');
    echo $xml;
}
Example #2
0
function gpspathFunAll($clientId, $date_offline, $deviceIMEI)
{
    $date_offline = $_GET[date_offline];
    $path1 = $GLOBALS[dataPath] . "src/data/" . date('d-m-Y', strtotime($date_offline)) . "/" . $deviceIMEI . ".txt";
    if (chk_folder($path1)) {
        $file1 = @fopen($path1, "r");
        if ($file1) {
            $i = 0;
            while (!feof($file1)) {
                $data1 = fgets($file1);
            }
            $data1 = getSortedData($data1);
            $km = liveKmsAllPerDay($data1);
            //exit;
            //$data = $data1;
            $devName = getDeviceName($_GET["deviceIMEI"]);
            $devModel = getDeviceModel($_GET["deviceIMEI"]);
            storeData($data1, $km, $devName, $devModel, '', '');
            fclose($file1);
        } else {
            $data = 0;
            storeData($data);
        }
    }
}