added test display in speed_map_display.py
This commit is contained in:
parent
ca393c6678
commit
369db54b5a
@ -1,7 +1,9 @@
|
|||||||
import pygame
|
import pygame
|
||||||
|
|
||||||
|
from gps_loader import GPSLoader
|
||||||
from map_display import MapDisplay
|
from map_display import MapDisplay
|
||||||
from path import Path
|
from path import Path
|
||||||
|
from units import Unit
|
||||||
from vec import Vec2
|
from vec import Vec2
|
||||||
|
|
||||||
|
|
||||||
@ -52,3 +54,30 @@ class SpeedMapDisplay(MapDisplay):
|
|||||||
b = int(b_span * f + self.min_speed_col[2])
|
b = int(b_span * f + self.min_speed_col[2])
|
||||||
|
|
||||||
return r, g, b
|
return r, g, b
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
name = "data_28-03"
|
||||||
|
cities = [
|
||||||
|
(Vec2(7.359119, 46.227302), "Sion", "above"),
|
||||||
|
(Vec2(7.079001, 46.105981), "Martigny", "below"),
|
||||||
|
(Vec2(7.001849, 46.216559), "Saint-Maurice", "right")
|
||||||
|
]
|
||||||
|
|
||||||
|
data = GPSLoader.load_data(f"{name}.csv")
|
||||||
|
speeds = list(map(lambda s: s.convert(Unit.KM_H).value, data["speeds"]))
|
||||||
|
path = Path(data["points"], speeds)
|
||||||
|
|
||||||
|
pygame.init()
|
||||||
|
|
||||||
|
win = pygame.display.set_mode([600, 600])
|
||||||
|
display = SpeedMapDisplay(
|
||||||
|
win,
|
||||||
|
6.971094, 7.430611,
|
||||||
|
46.076312, 46.253036,
|
||||||
|
cities,
|
||||||
|
(255, 0, 0), (0, 255, 0), 155)
|
||||||
|
|
||||||
|
display.draw_path(path)
|
||||||
|
pygame.display.flip()
|
||||||
|
input()
|
||||||
|
Loading…
Reference in New Issue
Block a user