color arches based on latency

This commit is contained in:
Felix Pankratz 2025-07-22 23:51:28 +02:00
parent 901c1e2a17
commit 9bddcfaa7e

View File

@ -110,7 +110,7 @@ def traceroute(target: str):
# exclude common local network addreses
continue
hop = database.get_all(ip)
hop.latency = latency
hop.latency = float(latency)
hops.append(hop)
return hops
@ -163,7 +163,7 @@ async def main():
)
for point in points_3d:
city_marker = pv.Sphere(center=point, radius=0.02)
city_marker = pv.Sphere(center=point, radius=0.01)
plotter.add_mesh(city_marker, color="blue")
labels = [ f'{_.country_short}: {_.latency}ms' for _ in locations]
@ -174,7 +174,16 @@ async def main():
for i in range(len(points_3d[:-1])):
arch = generate_arch(points_3d[i], points_3d[i + 1], height_factor=0.2)
line = pv.lines_from_points(arch, close=False)
plotter.add_mesh(line, color="red", line_width=2)
diff = locations[i+1].latency - locations[i].latency
if diff < 20:
color="green"
elif diff < 0.5:
color = "yellow"
elif diff < 0.7:
color = "orange"
else:
color = "red"
plotter.add_mesh(line, color=color, line_width=2)
kitty.hide_cursor()
try: