height correction, new defalt
This commit is contained in:
1 parent
0891cf12a5
commit
b692f94122
12 files changed
+792
-205
No files matched your search
+42
-31
@@ -105,8 +105,8 @@ def local_map(tmp_path: Path) -> Path:
|
||||
|
||||
|
||||
def test_default_and_reversed_bounds() -> None:
|
||||
assert DEFAULT_BOUNDS.values == (4.784498, 52.232025, 4.863525, 52.253985)
|
||||
assert Bounds.corners(4.863525, 52.253985, 4.784498, 52.232025) == DEFAULT_BOUNDS
|
||||
assert DEFAULT_BOUNDS.values == (4.784, 52.232, 4.864, 52.258)
|
||||
assert Bounds.corners(4.864, 52.258, 4.784, 52.232) == DEFAULT_BOUNDS
|
||||
assert DEFAULT_BOUNDS.contains(4.83, 52.24)
|
||||
expanded = DEFAULT_BOUNDS.expand(2000)
|
||||
assert expanded.west < DEFAULT_BOUNDS.west and expanded.north > DEFAULT_BOUNDS.north
|
||||
@@ -174,29 +174,22 @@ def test_database_readonly(recorded: tuple[Path, Session]) -> None:
|
||||
connection.execute("DELETE FROM observations")
|
||||
|
||||
|
||||
def test_terrain_and_datum_conversion(tmp_path: Path) -> None:
|
||||
def test_local_terrain_summary(tmp_path: Path) -> None:
|
||||
terrain = raster(tmp_path / "terrain.tif", -2)
|
||||
geoid = raster(tmp_path / "geoid.tif", 43)
|
||||
with Elevation(terrain, "orthometric", geoid, True) as elevation:
|
||||
with Elevation(terrain, "orthometric") as elevation:
|
||||
assert elevation.mean_ground(DEFAULT_BOUNDS, 4) == -2
|
||||
assert elevation.aircraft_altitude(observation()) == 1000
|
||||
with Elevation(terrain, "orthometric", geoid, False) as elevation:
|
||||
assert elevation.aircraft_altitude(observation()) is None
|
||||
with Elevation(terrain, "orthometric", None, True) as elevation:
|
||||
assert elevation.aircraft_altitude(observation()) is None
|
||||
with Elevation(terrain, "wgs84-ellipsoid", None, True) as elevation:
|
||||
assert elevation.aircraft_altitude(observation()) == 1043
|
||||
assert elevation.aircraft_altitude(observation(geo_altitude=None)) is None
|
||||
|
||||
|
||||
def test_terrain_missing_data(tmp_path: Path) -> None:
|
||||
def test_terrain_missing_data(tmp_path: Path, caplog: pytest.LogCaptureFixture) -> None:
|
||||
terrain = raster(tmp_path / "terrain.tif", -9999)
|
||||
with Elevation(terrain, "wgs84-ellipsoid") as elevation:
|
||||
assert elevation.mean_ground(DEFAULT_BOUNDS, 4) is None
|
||||
small = Bounds(4.80, 52.24, 4.81, 52.25)
|
||||
raster(terrain, 0, bounds=small)
|
||||
with Elevation(terrain, "wgs84-ellipsoid") as elevation:
|
||||
assert elevation.mean_ground(DEFAULT_BOUNDS, 4) is None
|
||||
assert elevation.mean_ground(DEFAULT_BOUNDS, 16) == 0
|
||||
assert 0 < elevation.land_coverage < 1
|
||||
assert "averaging valid land only" in caplog.text
|
||||
|
||||
|
||||
def test_equal_area_ground_average(tmp_path: Path) -> None:
|
||||
@@ -209,18 +202,17 @@ def test_equal_area_ground_average(tmp_path: Path) -> None:
|
||||
assert elevation.mean_ground(DEFAULT_BOUNDS, 10) == pytest.approx(5)
|
||||
|
||||
|
||||
def test_height_is_time_weighted_and_excludes_extensions() -> None:
|
||||
def test_reported_altitude_is_time_weighted_and_excludes_extensions() -> None:
|
||||
bounds = Bounds(0, 0, 2, 1)
|
||||
observations = [
|
||||
observation(longitude=-1, latitude=0.5, timestamp=T0, geo_altitude=0),
|
||||
observation(longitude=1, latitude=0.5, timestamp=T0 + 20, geo_altitude=200),
|
||||
observation(longitude=3, latitude=0.5, timestamp=T0 + 60, geo_altitude=600),
|
||||
observation(longitude=-1, latitude=0.5, timestamp=T0, baro_altitude=0),
|
||||
observation(longitude=1, latitude=0.5, timestamp=T0 + 20, baro_altitude=200),
|
||||
observation(longitude=3, latitude=0.5, timestamp=T0 + 60, baro_altitude=600),
|
||||
]
|
||||
with Elevation(None, "wgs84-ellipsoid", None, True) as elevation:
|
||||
tracks = make_tracks(observations, Projection(bounds), elevation, 10, 120)
|
||||
tracks = make_tracks(observations, Projection(bounds), 120)
|
||||
# Inside: 10s at mean altitude 150 + 20s at mean altitude 300.
|
||||
assert len(tracks) == 1
|
||||
assert tracks[0].average_height == pytest.approx(240)
|
||||
assert tracks[0].average_altitude == pytest.approx(250)
|
||||
assert tracks[0].start == pytest.approx(T0 + 10)
|
||||
assert tracks[0].end == pytest.approx(T0 + 40)
|
||||
|
||||
@@ -229,13 +221,31 @@ def test_stationary_positions_and_missing_altitude() -> None:
|
||||
items = [
|
||||
observation(),
|
||||
observation(timestamp=T0 + 25),
|
||||
observation(timestamp=T0 + 40, longitude=4.82, baro_altitude=None),
|
||||
]
|
||||
tracks = make_tracks(items, Projection(DEFAULT_BOUNDS), 120)
|
||||
assert len(tracks) == 1 and tracks[0].average_altitude is None
|
||||
assert make_tracks(items[:2], Projection(DEFAULT_BOUNDS), 120) == []
|
||||
|
||||
|
||||
def test_reported_altitude_does_not_require_geometric_altitude() -> None:
|
||||
items = [
|
||||
observation(geo_altitude=None),
|
||||
observation(timestamp=T0 + 40, longitude=4.82, geo_altitude=None),
|
||||
]
|
||||
with Elevation(None, "wgs84-ellipsoid", None, True) as elevation:
|
||||
tracks = make_tracks(items, Projection(DEFAULT_BOUNDS), elevation, -2, 120)
|
||||
assert len(tracks) == 1 and tracks[0].average_height is None
|
||||
with Elevation(None) as elevation:
|
||||
assert make_tracks(items[:2], Projection(DEFAULT_BOUNDS), elevation, None, 120) == []
|
||||
tracks = make_tracks(items, Projection(DEFAULT_BOUNDS), 120)
|
||||
assert len(tracks) == 1
|
||||
assert tracks[0].average_altitude == 900
|
||||
|
||||
|
||||
@pytest.mark.parametrize("altitude", [0, -50, 1234])
|
||||
def test_zero_negative_and_positive_reported_altitudes_are_preserved(altitude: float) -> None:
|
||||
items = [
|
||||
observation(baro_altitude=altitude, geo_altitude=9999),
|
||||
observation(timestamp=T0 + 40, longitude=4.82, baro_altitude=altitude, geo_altitude=9999),
|
||||
]
|
||||
tracks = make_tracks(items, Projection(DEFAULT_BOUNDS), 120)
|
||||
assert tracks[0].average_altitude == pytest.approx(altitude)
|
||||
|
||||
|
||||
def test_track_splitting_and_ground_filter() -> None:
|
||||
@@ -275,7 +285,6 @@ def test_end_to_end_offline_repeatable(
|
||||
local_map=local_map,
|
||||
terrain=terrain,
|
||||
terrain_reference="wgs84-ellipsoid",
|
||||
confirm_geometric_ellipsoid=True,
|
||||
)
|
||||
== 1
|
||||
)
|
||||
@@ -296,12 +305,13 @@ def test_end_to_end_offline_repeatable(
|
||||
assert flight_paths and all("C " in element.attrib["d"] for element in flight_paths)
|
||||
flight = root.find(f".//{{{SVG_NS}}}g[@id='flight-1']")
|
||||
assert flight is not None and flight.attrib["data-callsign"] == "KLM123"
|
||||
assert flight.attrib["data-average-height-metres"] != "unavailable"
|
||||
assert flight.attrib["data-average-barometric-altitude-metres"] == "900.000"
|
||||
assert flight.attrib["data-altitude-source"] == "barometric"
|
||||
for element in root.iter(f"{{{SVG_NS}}}path"):
|
||||
assert "clip-path" not in element.attrib
|
||||
for x, y in re.findall(r"(-?\d+\.\d+),(-?\d+\.\d+)", element.attrib["d"]):
|
||||
assert 0 <= float(x) <= 297 and 0 <= float(y) <= 210
|
||||
assert "HEIGHT" not in output.read_text() # Lettering is geometry, not SVG text.
|
||||
assert "BARO ALT" not in output.read_text() # Lettering is geometry, not SVG text.
|
||||
with pytest.raises(ValueError, match="already exists"):
|
||||
render(path, session.id, output, local_map=local_map)
|
||||
|
||||
@@ -448,7 +458,7 @@ def test_opensky_parsing_and_auth(monkeypatch: pytest.MonkeyPatch) -> None:
|
||||
client = OpenSky()
|
||||
items = client.observations(DEFAULT_BOUNDS)
|
||||
assert items[0].callsign == "KLM123" and items[0].geo_altitude == 1043
|
||||
assert "lamin=52.232025" in fetch.call_args.args[0]
|
||||
assert f"lamin={DEFAULT_BOUNDS.south}" in fetch.call_args.args[0]
|
||||
state[5] = None
|
||||
assert client.observations(DEFAULT_BOUNDS) == []
|
||||
fetch.return_value = {"states": None}
|
||||
@@ -521,6 +531,7 @@ def test_cli_validation_and_plot(
|
||||
session.id,
|
||||
"--map-data",
|
||||
str(local_map),
|
||||
"--no-terrain",
|
||||
"--output",
|
||||
str(tmp_path / "cli.svg"),
|
||||
]
|
||||
|
||||
Reference in new issue
Block a user