MCPcopy Create free account
hub / github.com/PierreGode/Ragnar / handle_exit_display

Function handle_exit_display

display.py:3050–3067  ·  view source on GitHub ↗

Handle the exit signal and close the display.

(signum, frame, display_thread, exit_process=True)

Source from the content-addressed store, hash-verified

3048
3049 lats = [p[0] for p in pts]
3050 lons = [p[1] for p in pts]
3051 min_lat, max_lat = min(lats), max(lats)
3052 min_lon, max_lon = min(lons), max(lons)
3053 mid_lat = (min_lat + max_lat) / 2.0
3054 lon_scale = math.cos(math.radians(mid_lat)) or 1.0
3055 d_lat = max(max_lat - min_lat, 1e-5)
3056 d_lon = max((max_lon - min_lon) * lon_scale, 1e-5)
3057 scale = min((right - left) / d_lon, (bottom - top) / d_lat)
3058 off_x = left + ((right - left) - d_lon * scale) / 2.0
3059 off_y = top + ((bottom - top) - d_lat * scale) / 2.0
3060
3061 def to_xy(lat, lon):
3062 x = off_x + (lon - min_lon) * lon_scale * scale
3063 # invert Y so north is up
3064 y = off_y + (max_lat - lat) * scale
3065 return int(x), int(y)
3066
3067 # Network dots (background)
3068 for lat, lon in nets:
3069 x, y = to_xy(lat, lon)
3070 draw.point((x, y), fill=0)

Callers 3

handle_exitFunction · 0.90
Ragnar.pyFile · 0.90
display.pyFile · 0.85

Calls 4

infoMethod · 0.80
errorMethod · 0.80
exitMethod · 0.80
sleepMethod · 0.45

Tested by

no test coverage detected