GPS Distance calculate with noises

I have points array but there is some noises like this;

enter image description here

But the real direction is;

enter image description here

When i calculate all points with haversine formula i am getting wrong distance because noises took like %20-%30 more distance. I want to extract all noises from my main data or calculate distance with minimum tolerance. Is there any algorithm about it? I found kalman filter and i used a library for it.But its drop only %2-%3 tolerance. So i need more usefull algorithm to extract those noises from my main data.

You can check the temp data from this link.

Calculate code;

const moment = require("moment");
const locations = require("./mock_data.json");

function calcKiloMeterDistance(lat1, lon1, lat2, lon2) {
  const r = 6371; // km
  const p = Math.PI / 180;
  const a =
    0.5 -
    Math.cos((lat2 - lat1) * p) / 2 +
    (Math.cos(lat1 * p) *
      Math.cos(lat2 * p) *
      (1 - Math.cos((lon2 - lon1) * p))) /
      2;

  return 2 * r * Math.asin(Math.sqrt(a));
}
const calcAllRows = () => {
  let total = 0;
  for (let i = 1; i < locations.length; i++) {
    const point1 = locations[i - 1];
    const point2 = locations[i];
    const time = point2.lastLocationUpdatedAt - point1.lastLocationUpdatedAt;
    const km = calcKiloMeterDistance(
      point1.latitude,
      point1.longitude,
      point2.latitude,
      point2.longitude
    );
    // const speed = (km / time) * 3600; //Km/sa
    // console.log(
    //   moment.unix(point2.lastLocationUpdatedAt).format("HH:mm:ss"),
    //   time,
    //   (km / time) * 3600
    // );
    total += km;
  }
  console.log(total);
};
calcAllRows();