Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

165
Vistas
How can I get truly random even distribution of GPS coordinates in JavaScript?

My first attempt produces points often near polar regions:

gps = {
    lat: (Math.random() * (90 - -90) + -90) * Math.PI / 180,
    lon: (Math.random() * (180 - -180) + -180) * Math.PI / 180,
    alt: 0
};

(yes I'm converting to radians) I quickly realized that it's an uneven distribution. According to this site https://dosull.github.io/posts/2021-10-20-random-even-points-on-the-globe/ I'll need to use some sort of "acos" (is that arccos?) function, but I don't even know what language that is. whuber's comment at https://gis.stackexchange.com/questions/236321/generating-random-lat-long-coordinates mentions cosine but I'm not sure exactly what the formula would be.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

lat: Math.acos(Math.random() * 2 - 1) - Math.PI / 2,
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda