Skip to content

Instantly share code, notes, and snippets.

@Gaiiden
Created April 14, 2016 08:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Gaiiden/d5303fc64442601b73cb415944821393 to your computer and use it in GitHub Desktop.
Save Gaiiden/d5303fc64442601b73cb415944821393 to your computer and use it in GitHub Desktop.
renders ascent profiles (or any path really)
clearscreen.
set pathData to readjson("path.json").
set colorList to list(green, red, cyan, purple, yellow, blue).
set colorListIndex to -1.
set lastPhase to "".
clearvecdraws().
from { local index is 0. } until index = pathData["geo"]:length-1 step { set index to index + 1. } do {
if pathData["phase"][index] <> lastPhase {
set lastPhase to pathData["phase"][index].
set colorListIndex to colorListIndex + 1.
if colorListIndex = colorList:length set colorListIndex to 0.
}
vecdraw(latlng(pathData["geo"][index]:lat, pathData["geo"][index]:lng):altitudeposition(pathData["alt"][index]),
pathData["vec"][index] + (latlng(pathData["geo"][index+1]:lat, pathData["geo"][index+1]:lng):altitudeposition(pathData["alt"][index+1]) - latlng(pathData["geo"][index]:lat, pathData["geo"][index]:lng):altitudeposition(pathData["alt"][index])),
colorList[colorListIndex],
"",
1.0,
true,
100).
}.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment