Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [['distance':3.4938212,'timestamp':'2019-06-21 02:00:00'],['distance':4.4345342,'timestamp':'2019-06-21 02:00:33'],['distance':3.5482918,'timestamp':'2019-06-21 02:02:35']...]
- $gateway_single = $this->Entrada->find('all', array('conditions' => array('Entrada.id' => $gateway[Constantes::TABLA_RELACIONAL_BEACONS_GATEWAYS]['identrada_secundaria'] ) ) );
- $distances = $this->Entrada->query('select * from gateway_beacon_distances where beacon_kontakt_id like '' . $beacon_kontakt_id . '' and gateway_kontakt_id = '' . $gateway_single[0]['Entrada']['titulo'] . '' and date(`date`) = '' . $fecha . '' order by date ASC;');
- $start['running'] = 0;
- $start['time_start'] = null;
- $start['last_time'] = null;
- $times_gone_gateway = 0;
- $time_near_gateway = 0;
- $number_of_points= 0;
- foreach ($distances as $distance) {
- if ($start['running'] == 0) {
- $times_gone_gateway++;
- $start['running'] = 1;
- $start['time_start'] = $distance['gateway_beacon_distances']['date'];
- $start['last_time'] = $distance['gateway_beacon_distances']['date'];
- } else {
- $date1 = new DateTime($start['last_time']);
- $date2 = new DateTime($distance['gateway_beacon_distances']['date']);
- $diff_seconds = $date1->diff($date2);
- $time_beetween_lectures = ( ($diff_seconds->days * 24 ) * 3600 ) + ($diff_seconds->h * 3600) + ( $diff_seconds->i * 60 ) + $diff_seconds->s;
- if ($time_beetween_lectures > 15000) {
- if($number_of_points > 10){
- echo 'Distance: ' . $distance['gateway_beacon_distances']['distance_m'] . ' Time: ' . $time_beetween_lectures. '<br>';
- echo 'Start date: ' . $start['time_start'] . ' End date: ' . $start['last_time']. '<br><br><br>';
- $times_gone_gateway++;
- $date1 = new DateTime($start['time_start']);
- $date2 = new DateTime($start['last_time']);
- $time_near_gateway += ( ($diff_seconds->days * 24 ) * 3600 ) + ($diff_seconds->h * 3600) + ( $diff_seconds->i * 60 ) + $diff_seconds->s;
- }
- $start['running'] = 1;
- $start['time_start'] = $distance['gateway_beacon_distances']['date'];
- $start['last_time'] = $distance['gateway_beacon_distances']['date'];
- $number_of_points = 0;
- }
- }
- $number_of_points++;
- }
- if ($start['running'] == 0) {
- $date1 = new DateTime($start['time_start']);
- $date2 = new DateTime($start['last_time']);
- $time_near_gateway += ( ($diff_seconds->days * 24 ) * 3600 ) + ($diff_seconds->h * 3600) + ( $diff_seconds->i * 60 ) + $diff_seconds->s;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement