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

117
Visualizações
How to smooth elevation gain from GPS Points

I have a big problem here:

I have an array of gps datas and it's necessary to calculate some informations, I did it all except for the total elevation gain in the route. There's an array like this [825.23423, 827.39420, 828.19319, ...] that storage the elevation of each gps point passed and I need to calculate the full sum. The problem is that gps is not so accurate and sometimes gives some incorrect elevations, and it's making the sum get wrong. I tried many ways to smooth the data, here are some:

  • Set a minimum value to sum the elevation gain
  • Get "sub-arrays" and made the media of them to sum the elevation gain after.
  • Get "sub-arrays" and pop and shift the uncommon values to sum after that.
  • And the actual way I mixed all, it got better but not even close to the perfect:
const getMediaFixed = (values: number[]) => {
      values.sort((a, b) => {
        return a - b;
      });
      values.pop();
      values.shift();
      const media = values.reduce((a, b) => a + b) / values.length;
      return media;
    };

    let last: number = elevations[0];
    let elevationSum = 0;
    // let countLimit: number = 1;
    for (let i = 0; i < elevations.length - 5; i += 5) {
      let media: number;
      if (i <= elevations.length - 4) {
        media = getMediaFixed([
          elevations[i],
          elevations[i + 1],
          elevations[i + 2],
          elevations[i + 3],
          elevations[i + 4],
        ]);
      } else {
        media = elevations[i];
      }

      const temp = 0.75 * last + 0.25 * media;
      if (temp - last > 0) {
        elevationSum += temp - last;
      }
      last = temp;
    }

The point is that it's not working anyway.

Here's a site that works perfectly calculating from a GPX File (I couldn't find the contact to ask for help): https://www.trackreport.net

I appreciate any ideas to improve the code!

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

0

I made it using the exponential moving average to smooth the array with elevations and then I used 1 meter to ignore the bugs!

Thanks.

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