Get distance of locations - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24) +--- Thread: Get distance of locations (/showthread.php?tid=72050) |
Get distance of locations - omid_student - 10-30-2018 Hi I have many locations(about 1000 location) I need calculate distance between this location My code is : PHP Code: function distance($lat1, $lon1, $lat2, $lon2, $unit) { I calculate distance between two location with foreach PHP Code: foreach($result as $row) { In each loop,i save previous location and get distance from their But it is wrong Does anybody can help me? RE: Get distance of locations - Pertti - 10-30-2018 Try PHP Code: if (!is_null($current)) Or is the maths part wrong? RE: Get distance of locations - omid_student - 10-30-2018 (10-30-2018, 01:54 AM)Pertti Wrote: Try"is the maths part wrong?" what do you mean? RE: Get distance of locations - omid_student - 10-30-2018 (10-30-2018, 01:54 AM)Pertti Wrote: Try Your code did not work RE: Get distance of locations - Pertti - 10-30-2018 (10-30-2018, 01:59 AM)omid_student Wrote: "is the maths part wrong?" what do you mean? I'm just trying to understand what part you have problem with from your original post. As far as I can see, from the source provided, there could be only two issues - either the calculation between two points is incorrect, or you have issues with feeding in correct points. You should try to specify what and why you think it's not working, and it'll be easier for us to help you, that's all RE: Get distance of locations - omid_student - 10-30-2018 (10-30-2018, 03:16 AM)Pertti Wrote:(10-30-2018, 01:59 AM)omid_student Wrote: "is the maths part wrong?" what do you mean? Sorry my problem was solved My locations not arranged by asc or desc Thank you RE: Get distance of locations - Pertti - 10-30-2018 (10-30-2018, 05:14 AM)omid_student Wrote: Sorry my problem was solved Excellent |