Handle the exit signal and close the display.
(signum, frame, display_thread, exit_process=True)
| 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) |
no test coverage detected