0

Problem description

want to calculate the lat,long which is 50 meter far away from the start of the blockage road. Using the below line of code to calculate the lat,long but it calculate randomly in ant direction instead of proper direction.

define("RADIUSOFEARTH", 6378.0);

$latitude = 50.09469;
$longitude = 8.68162;

$new_latitude  = $latitude  + (50 / RADIUSOFEARTH) * (180 / PI); //50 in meters

$new_longitude = $longitude + (50 / RADIUSOFEARTH) * (180 / PI) / cos($latitude * PI/180); //50 in meters

echo $new_latitude .PHP_EOL;
echo $new_longitude;
  • You should copy the problem. Please do no use images. This is a reference site, so other people should be able to reach the relevant question easy. With an external image we cannot link question with answers. – Giacomo Catenazzi Sep 24 '20 at 09:09
  • You should use and add comments. It really help you. If you add the units, you see that you have a Radius of Earth in km, which it is ok. But `50` is interpreted as km and not meters. Which language? I tend never to use `/` with integers when I want to have float results (so, put a .0 to the radius of earth) – Giacomo Catenazzi Sep 24 '20 at 09:41
  • But you are mixing units. What it is the meaning 50m/6378km? You cannot get the angle using different units. – Giacomo Catenazzi Sep 24 '20 at 10:16

0 Answers0