Skip to content

Instantly share code, notes, and snippets.

@330k
Created June 15, 2023 02:00
Show Gist options
  • Save 330k/e2f20b3b068f6d745e2c650fbc4034eb to your computer and use it in GitHub Desktop.
Save 330k/e2f20b3b068f6d745e2c650fbc4034eb to your computer and use it in GitHub Desktop.
Routes.activeMap.activeRoute.flattenBridgesAndTunnels =
function() {
var e, t, n = !1, r = Routes.activeMap.activeRoute.trackPoints(), o = r.length;
r.some((function(e) {
return !(Number.isFinite(e.distance) && Number.isFinite(e.ele))
}
)) || r.forEach((function(i, a) {
if (!i.flattened)
if (i.roadEnv && !n)
for (n = !0,
e = a; r[a].distance - r[e].distance < 20 && e > 0; )
e -= 1;
else if (n && (0 === i.roadEnv || void 0 === i.roadEnv)) {
for (n = !1,
t = a; r[t].distance - r[a].distance < 20 && t < o; )
t += 1;
var s = r[e]
, l = r[t]
, c = s.distance
, u = (l.ele - s.ele) / (l.distance - s.distance);
r.slice(e, t).forEach((function(e) {
e.ele = (e.distance - c) * u + s.ele,
e.flattened = !0
}
))
}
}
))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment