Skip to content

Commit

Permalink
Add altitude threshold for aircraft drawing
Browse files Browse the repository at this point in the history
Explain `constants.py` in README
  • Loading branch information
sco1 committed Nov 2, 2023
1 parent f0ea7eb commit 78de52a
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,14 @@ secrets = {
"opensky_password": "YOUR_OPENSKY_PASSWORD"
}
```

### Constants
A collection of functionality-related constants is specified in `constants.py`, which can be adjusted to suit your needs:

| Variable Name | Description | Default |
|----------------------------|-----------------------------------------------|----------|
| `MAP_CENTER_LAT` | Map center latitude, decimal degrees | `42.41` |
| `MAP_CENTER_LON` | Map center longitude, deimal degrees | `-71.17` |
| `GRID_WIDTH_MI` | Map grid width, miles | `15` |
| `SKIP_GROUND` | Skip drawing aircraft on the ground | `True` |
| `GEO_ALTITUDE_THRESHOLD_M` | Skip drawing aircraft below this GPS altitude | `20` |
5 changes: 5 additions & 0 deletions constants.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# Mapping information
MAP_CENTER_LAT = 42.41
MAP_CENTER_LON = -71.17
GRID_WIDTH_MI = 15

# Aircraft plotting
SKIP_GROUND = True
GEO_ALTITUDE_THRESHOLD_M = 20
8 changes: 7 additions & 1 deletion skyportal/displaylib.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from adafruit_bitmapsaver import save_pixels
from adafruit_display_text import label

from constants import GEO_ALTITUDE_THRESHOLD_M, SKIP_GROUND
from skyportal.aircraftlib import (
AIRCRAFT_ICONS,
AircraftIcon,
Expand Down Expand Up @@ -170,7 +171,8 @@ def draw_aircraft(
aircraft: list[AircraftState],
default_icon: AircraftIcon = BASE_ICON,
custom_icons: dict[int, AircraftIcon] = AIRCRAFT_ICONS,
skip_ground: bool = True,
skip_ground: bool = SKIP_GROUND,
geo_altitude_threshold_m: float = GEO_ALTITUDE_THRESHOLD_M,
) -> None:
"""
Clear the currently plotted aircraft icons & redraw from the provided list of aircraft.
Expand All @@ -192,6 +194,10 @@ def draw_aircraft(
n_ground += 1
continue

if ap.geo_altitude_m is None or ap.geo_altitude_m < geo_altitude_threshold_m:
n_ground += 1
continue

# If we've gotten here then lat/lon can't be None
icon_x, icon_y = calculate_pixel_position(
lat=ap.lat, # type: ignore[arg-type]
Expand Down

0 comments on commit 78de52a

Please sign in to comment.