• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Calculate all locations distance

I have project named GPS Tracker
The one hundred device is active in my project
Each device send 24000 location to my server
In continue,i need calculate distance this locations for each device and save it
But number of records is high and if i use FOR statement for iterate array and calculate distance,the CPU maybe down
I try calculate distance between location when device send to server but locations is irregular and i cannot calculate exact distance
So i have to calculate distance after receive locations and insert into database and sort it and calculate distance

My code is :
PHP Code:
$locations $this->db->get('location')->result_array();

$last_location  =   '';
$distance       =   0;

        foreach (
$locations as $location) {

            if (
$last_location != '') {

$temp distance($last_location['latitude'],$last_location['longitude'],$location['latitude'],$location['longitude'],'m');

                if (!
$distance += $temp;


$last_location $location;


Please suggest solution for me

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.