Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

128
Visualizações
How to get Latitude and Longitude after going a distance at certain bearing from another point?

Let's say I have the latitude and longitude coordinate [30, -87]. From that point, I would like to be able to find where my location would be after traveling let's say 10km at 45 degrees of bearing.

My first attempt at trying to solve this didn't go so well as you can see below. This obviously doesn't account for the units which is really the hardest part to comprehend for me at least.

var bearing = 45;
var distance = 10;

var position = {
 "latitude": 30,
 "longitude": -87
};

var newLat = Math.cos(bearing) * distance + position.latitude;
var newLon = Math.sin(bearing) * distance + position.longitude;

I'm assuming the radius of the earth will come into play at one point but I really didn't know where to start so any help would be greatly appreciated.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

I have used python code here: Get lat/long given current point, distance and bearing, and converted in into JS code to get the answer.

Here is the code:

const bearing = 45;
const bearing_rad = (bearing*Math.PI)/180;
const distance = 10;

const EARTH_RADIUS = 6378.1;

const initial_position = {
 "latitude": 30,
 "longitude": -87
};

const init_lat = (initial_position.latitude*Math.PI)/180;
const init_lon = (initial_position.longitude*Math.PI)/180;

const final_lat = (180/Math.PI)*(Math.asin( Math.sin(init_lat)*Math.cos(distance/EARTH_RADIUS) + Math.cos(init_lat)*Math.sin(distance/EARTH_RADIUS)*Math.cos(bearing_rad)));

const final_lon = (180/Math.PI)*(init_lon + Math.atan2(Math.sin(bearing_rad)*Math.sin(distance/EARTH_RADIUS)*Math.cos(init_lat), Math.cos(distance/EARTH_RADIUS)-Math.sin(init_lat)*Math.sin(final_lat)));

console.log(final_lat, final_lon); // 30.06350049619102 -86.96303358059173
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda