Example #1
0
function drawCircles($image)
{
    $max = 12;
    $min = 2;
    $gap = $max - $min;
    $total = getTotalElements();
    $result = getCoords();
    foreach ($result as $row) {
        drawCircle($image, $row['x'], $row['y'], $min + $gap * ($row['total'] / $total));
    }
}
Example #2
0
function getOverAllTripReport($sdate, $vehId, $dest)
{
    $cnt = 1;
    $tmp = -1;
    $t1 = 0.0;
    $t2 = 0.0;
    $timeArr = array();
    $timediff = array();
    $strTime = '';
    $endTime = '';
    $tmpId = 0;
    $srcArr = array();
    $destArr = array();
    $stCunt = 0;
    $stChk = 0;
    $geocheck = 0;
    //print_r($dest);
    $file = $GLOBALS[dataPath] . "client_" . $_SESSION[clientID] . "/" . date("d-m-Y", strtotime($sdate)) . "/" . $vehId . ".txt";
    if (chk_folder($file)) {
        $file1 = @fopen($file, "r");
        if ($file1) {
            while (!feof($file1)) {
                $data = fgets($file1);
            }
            $data = getSortedData($data);
        }
        if (count($data) > 0) {
            $data1 = explode("#", $data);
            for ($j1 = 0; $j1 < count($data1); $j1++) {
                $data2 = explode("\$", $data1[$j1]);
                if (count($data2) > 1) {
                    $data3 = explode(",", $data2[1]);
                    //echo date("d-m-Y", strtotime($sdate))."==".date("d-m-Y",@mktime(($data3[4]+5),($data3[5]+30),$data3[6],$data3[2],$data3[1],$data3[3]));
                    $vehi = $data3[0];
                    $geodate = date("d-m-Y", @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]));
                    $vehi = $data3[0];
                    /*$getLL=drawCircle("17.98264333","79.601965","0.16");
                    		print_r($getLL);
                    		echo $resLL=getGeofenceStatus($getLL,"17.9809383333","79.6004683333");
                    		exit;*/
                    if ($pos1 > 0 && $pos2 > 0) {
                        $sel_pts = "SELECT * FROM gps_geopoints_info WHERE gpi_clientID=" . $_SESSION[clientID] . " AND gpi_id=" . $dest;
                        $rs_sel_pts = mysql_query($sel_pts);
                        if (@mysql_affected_rows() > 0) {
                            while ($fetch_sel_pts = @mysql_fetch_assoc($rs_sel_pts)) {
                                $gcdLatLng = drawCircle($fetch_sel_pts[gpi_latVal], $fetch_sel_pts[gpi_longVal], $fetch_sel_pts[gpi_miles]);
                                //print_r($fetch_sel_pts);
                                $geocheck = getGeofenceStatus($gcdLatLng, $pos1, $pos2);
                                if ($geocheck == 1) {
                                    //print_r($gcdLatLng);
                                    /*$getLL=drawCircle("17.97905965","79.59972382","0.10");
                                    		print_r($getLL);
                                    		$resLL=getGeofenceStatus($getLL,$pos1,$pos2);*/
                                    //print_r($getLL);
                                    $result_pt = $fetch_sel_pts[gpi_stopName] . "#" . $geoTime;
                                    //echo $k." ".$j1." ".$result_pt." ".$pos1."&&".$pos2."";
                                    if ($tmpId != $fetch_sel_pts[gpi_id]) {
                                        $tmpId = $fetch_sel_pts[gpi_id];
                                        //echo $fetch_sel_pts[gpi_id]." ".$dest;
                                        //echo "pos ".in_array($fetch_sel_pts[gpi_id],$dest);
                                        //if(in_array($fetch_sel_pts[gpi_id],$dest))
                                        //{
                                        if ($destArr[$tmpId] == "") {
                                            //echo "ss".count($destArr[$tmpId])." ".$tmpId." ".$result_pt."<br>";
                                            //$destArr = array_push_assoc($destArr, $tmpId, $result_pt);
                                            $destArr[$tmpId] = $result_pt;
                                            //print_r($destArr);
                                        } else {
                                            //echo $result_pt."<br>";
                                            foreach ($destArr as $key => $value) {
                                                // echo "Key: $key; Value: $value<br />\n";
                                                if ($key == $tmpId) {
                                                    //echo $key ."==". $tmpId;
                                                    $tmpVal = $value;
                                                    //unset($destArr[$key]);
                                                    $destArr[$key] = $value . ',' . $result_pt;
                                                    //print_r($destArr);
                                                    //echo "<br>";
                                                    //echo "<br>";
                                                } else {
                                                    //	$destArr[$tmpId]=$result_pt;
                                                    //$destArr = array_push_assoc($destArr, $tmpId, $result_pt);
                                                    //print_r($destArr);
                                                    //echo "<br>";
                                                }
                                            }
                                            // foreach end
                                        }
                                        // else end
                                        //}
                                        //print_r($destArr);
                                    }
                                } else {
                                    $tmpId = 0;
                                }
                            }
                        }
                        //echo "<br>";
                    }
                }
            }
            fclose($file1);
        }
    }
    $result = $destArr;
    //print_r($destArr);
    //exit;
    //echo $timediff;
    return $result;
}
Example #3
0
 $getGeofenceInfo = "SELECT * FROM tb_assigngeofence WHERE tag_diId = " . $fetDevice[di_id] . " AND tag_isActive = 1 ORDER BY tag_id ASC";
 $resGeofenceInfo = $db->query($getGeofenceInfo);
 if ($db->affected_rows > 0) {
     while ($fetGeofence = $db->fetch_array($resGeofenceInfo)) {
         $gpspts = $fetGeofence[tag_geofenceId] . "#" . $fetGeofence[tag_id] . "#" . $fetGeofence[tag_alertSrc] . "#" . $fetGeofence[tag_noofTimes] . "#" . $fetGeofence[tag_inout];
         $resSrv1 = explode("#", $gpspts);
         //print_r($resSrv1);
         //statusGeoPoint($lat,$lng,$resSrv1[0],$resSrv1[1],$resSrv1[2],$resSrv1[3],$resSrv1[4],$devDateTime,$devImei);
         $getDevice = "SELECT * FROM tb_geofence_info WHERE tgi_id = " . $fetGeofence[tag_geofenceId] . " AND tgi_isActive = 1";
         $resDevice = $db->query($getDevice);
         if ($db->affected_rows > 0) {
             $fetDevice = $db->fetch_array($resDevice);
             $lat_lng = explode(",", $fetDevice[tgi_latLong]);
             $radius = $fetDevice[tgi_radius];
             //echo $lat_lng[0]." , ".$lat_lng[1]." , ".$radius." , ".$lat." , ".$lng."<br>";
             $latlngArr = drawCircle($lat_lng[0], $lat_lng[1], $radius);
             //print_r($latlngArr);
             //exit;
             $res = getGeofenceStatus($latlngArr, $lat, $lng);
             //echo "<br>";
             //exit;
             $getAlertImeiInfo_repeat = "SELECT COUNT(*) FROM tb_geoalertinfo WHERE tgai_assignDevId = '" . $devImei . "' AND  tgai_reachdevTime2='0000-00-00 00:00:00' AND tgai_geoAssignId=" . $fetGeofence[tag_geofenceId] . " ORDER BY tgai_id DESC LIMIT 0,1";
             $already_in_alert_sent = $db->query($getAlertImeiInfo_repeat);
             if ($res) {
                 if ($already_in_alert_sent == '0') {
                     smsmAlertFunc($resSrv1[0], $resSrv1[1], $resSrv1[2], $resSrv1[3], $resSrv1[4], $devDateTime, $devImei, "in");
                 }
             } else {
                 smsmAlertFunc($resSrv1[0], $resSrv1[1], $resSrv1[2], $resSrv1[3], $resSrv1[4], $devDateTime, $devImei, "out");
             }
         }
Example #4
0
 function drawAxis($n)
 {
     global $SCALE;
     drawCircle(0.5 * $SCALE);
     drawMark(0.5 * $SCALE - 25, 15, "0.5");
     drawCircle($SCALE);
     drawMark($SCALE - 15, 15, "1");
     drawCircle(1.5 * $SCALE);
     drawMark(1.5 * $SCALE - 25, 15, "1.5");
     drawCircle(2 * $SCALE);
     drawMark(2 * $SCALE - 15, 15, "2");
     //N: should be commented
     for ($i = 1; $i < $n + 1; $i++) {
         drawSingleAxis(2 * $i * pi() / $n);
     }
 }
Example #5
0
function getUDAddress($lt, $ln)
{
    //echo $lt;
    $sel_pts = "SELECT * FROM gps_geopoints_info WHERE gpi_clientID=" . $_SESSION[clientID];
    $rs_sel_pts = mysql_query($sel_pts);
    while ($fetch_sel_pts = @mysql_fetch_assoc($rs_sel_pts)) {
        //print_r($fetch_sel_pts);
        $gcdLatLng = drawCircle($fetch_sel_pts[gpi_latVal], $fetch_sel_pts[gpi_longVal], $fetch_sel_pts[gpi_miles]);
        //print_r($gcdLatLng);
        $geocheck = getGeofenceStatus($gcdLatLng, $lt, $ln);
        if ($geocheck == 1) {
            return $fetch_sel_pts[gpi_stopName];
        }
    }
}
Example #6
0
function geoAlrtPerDay($lData, $sTime1, $eTime1)
{
    $cnt = 0;
    $data1 = explode("#", $lData);
    $timeArr = array();
    /*$latlngArr = drawCircle("15.2857824","73.958976","0.50");
    	for($i=0; $i<count($latlngArr);$i++)
    	{
    		$tarr = explode(",",$latlngArr[$i]);
    		$newArr[]= $tarr[1].",".$tarr[0];
    	}
    	print_r($latlngArr);
    	echo $res = getGeofenceStatus($latlngArr,"15.2677360","73.9664768");
    
    	exit;*/
    for ($j1 = 0; $j1 < count($data1); $j1++) {
        $data2 = explode("@", $data1[$j1]);
        if (count($data2) > 1) {
            $data3 = explode(",", $data2[1]);
            //echo '<pre>';print_r($data3); echo '</pre>';
            $geodate = $data3[8];
            $geoTime = $data3[9];
            $curTime = explode(":", $data3[9]);
            $curTime = $curTime[0] * 60 + $curTime[1] + $curTime[2];
            if ($curTime >= $sTime1 && $curTime <= $eTime1) {
                $pos1 = calLat($data3[2]);
                $pos2 = calLong($data3[1]);
                //$pos1 = "17.4145664";
                //$pos2 = "78.4665856";
                //echo $curTime." >= ".$sTime1." && ".$curTime."<=".$eTime1." ".$tmpId." ".$res." ".$pos1.",".$pos2;
                //echo "<br>";
                if ($pos1 > 0 && $pos2 > 0) {
                    if (!in_array($geoTime, $timeArr)) {
                        $getDevice = "SELECT * FROM tb_geofence_info WHERE tgi_clientId = " . $_SESSION[clientID] . " AND tgi_isActive = 1 ORDER BY tgi_id ASC";
                        $resDevice = mysql_query($getDevice);
                        if (@mysql_affected_rows() > 0) {
                            while ($fetDevice = @mysql_fetch_assoc($resDevice)) {
                                $lat_lng = explode(",", $fetDevice[tgi_latLong]);
                                $radius = $fetDevice[tgi_radius];
                                //echo $lat_lng[0]." , ".$lat_lng[1]." , ".$radius." , ".$pos1." , ".$pos2."<br>";
                                $latlngArr = drawCircle($lat_lng[0], $lat_lng[1], $radius);
                                $res = getGeofenceStatus($latlngArr, $pos1, $pos2);
                                if ($res) {
                                    if (count($geoId) == 0) {
                                        $geoId[] = $fetDevice[tgi_id];
                                        $finaTime[] = $fetDevice[tgi_id] . "#" . $geodate . " " . $geoTime . "#Entered#" . $fetDevice[tgi_name];
                                        //echo "<br><br>";
                                        $end = 0;
                                    } else {
                                        if ($geoId[count($geoId) - 1] != $fetDevice[tgi_id]) {
                                            /*echo $lat_lng[0]." , ".$lat_lng[1]." , ".$radius." , ".$pos1." , ".$pos2."<br>";
                                            		echo '<pre>';print_r($latlngArr);echo '</pre>';
                                            		for($i=0; $i<count($latlngArr);$i++)
                                            		{
                                            			$tarr = explode(",",$latlngArr[$i]);
                                            			$str .= "new GLatLng(".$tarr[1].",".$tarr[0]."),";
                                            		}
                                            		echo $str;
                                            		exit;*/
                                            $geoId[] = $fetDevice[tgi_id];
                                            $finaTime[] = $fetDevice[tgi_id] . "#" . $geodate . " " . $geoTime . "#Entered#" . $fetDevice[tgi_name];
                                            //echo "<br><br>";
                                            $end = 0;
                                        }
                                    }
                                } else {
                                    if ($geoId[count($geoId) - 1] == $fetDevice[tgi_id] && $end == 0) {
                                        $geoId[] = $fetDevice[tgi_id];
                                        $end = 1;
                                        $finaTime[] = $fetDevice[tgi_id] . "#" . $geodate . " " . $geoTime . "#Left#" . $fetDevice[tgi_name];
                                        //echo "<br><br>";
                                    }
                                }
                            }
                        }
                        array_push($timeArr, $geoTime);
                    }
                }
            }
        }
    }
    //print_r($finaTime);
    //exit;
    if (count($finaTime) > 0) {
        $finaTime = implode("@", $finaTime);
        return $finaTime;
    } else {
        return false;
    }
}