0
votes

For the application I am developing, for a given latitude and longitude in degrees, I need to find a new lat and long at a distance of 500 meters away from it (any direction i.e. north,south,east,west is fine). I have found bunch of responses on stack exchange and tried them out but honestly at this point I am really frustrated and tired. Could somebody dumb it down for me on how do I go about achieving this?

P.S. my application requires small distances that is < 500 meters

1

1 Answers

0
votes

In java script your function for generating Random lat-lon will be

function randomGeo(center_latitude,center_longitude, radius) {
    var y0 = center_latitude;
    var x0 = center_longitude;
    var rd = radius / 111300; 

    var u = Math.random();
    var v = Math.random();

    var w = rd * Math.sqrt(u);
    var t = 2 * Math.PI * v;
    var x = w * Math.cos(t);
    var y = w * Math.sin(t);

    //Adjust the x-coordinate for the shrinking of the east-west distances
    var xp = x / Math.cos(y0);

    var newlat = y + y0;
    var newlon = x + x0;
console.log(newlat+","+newlon);
}

parameter radius is in meters. Test those function like

 randomGeo(22.541161, 88.355040,50);