Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 21 additions & 6 deletions data/processors/areatree/config.areatree
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
1713:Nigerstr. 3, Student Office (Bau 713):
1724:Prinzregentenstr. 68 (Bau 724):
1740:Neherstr. 1:
2535:StudiTUM am TUM-Klinikum|StudiTUM:2535,studitum-mri
16:Am Biederstein (MRI Außenstelle):biederstein[site]
1601:Altbau 1, Vorklinik. Inst. (Bau 601):
1602:Altbau 2+3, Anatomisches Institut (Bau 602):
Expand Down Expand Up @@ -182,6 +183,8 @@
3120:Tiefbrunnen:
3121:Modellausstellung:
3122:Folienhalle:
3123:Flüssiggastank:
3124:Unterirdischer Wasserbehälter:
3201:Eichenau Lindenweg:
340:Residenz München (Nutzung):residenz[joined_building]
3401:Akademiegebäude in der Residenz:
Expand Down Expand Up @@ -229,6 +232,7 @@
4180:Verwaltungsgebäude:
4181:Maschinenhalle:
4183:Wohnung / Garage:
4186:Gärfuttersilo:
4187:Dungsilo:
4188:Fahrsilo:
4189:Strohlagerhalle:
Expand Down Expand Up @@ -273,6 +277,8 @@
4308:Humanbiologie Zoologie:
4317:Tierwissenschaften:
4318:HEZ Hans-Eisenmann-Zentrum für Agrarwissenschaften:
4330:Zentrum für Infektionsprävention|ZIP:
4331:Zentrum für Infektionsprävention Nebengebäude:
4309:Institutsgebäude Ökonomik des Gartenbaus und Landschaftsbaus:
4310:Werkstatt und Garagen Zierpflanzenbau:
4311:Institut Zierplanzenbau:
Expand Down Expand Up @@ -363,6 +369,7 @@
4510:Getreidekasten STG.WST.:
4512:Gerätehalle West:
4513:Gerätehalle Ost:
-4514:Trafostation XXVIII:
5:Garching Forschungszentrum|Garching:garching[campus]
51:Physik:physik
:Physik Hauptgebäude:physik-main
Expand Down Expand Up @@ -395,12 +402,13 @@
52:FRM II Forschungsreaktor Neutronenquelle und Heinz Maier-Leibnitz Zentrum (MLZ)|FRM II:frm-2[area]
5202:Flachbau 2+3 (Zyklotron):
5203:Bürogebäude (GRS-Altbau):
5204:Umformtechnik und Gießereiwesen (utg) (MW25):
5204:Umformtechnik und Gießereiwesen (MW25)|UTG:5204,utg
5212:RCM-Hauptbau:5212,rcm
5219:Instituts und Verwaltungsgebäude, Personalbetreuung, Immobilien, Zahlstelle:
5251:RCM-Abwassergebäude:
5252:RCM-Gasversorgung:
5257:Werkstatt u. Bürogebäude FRM II (UYW):
5301:Institute for Advanced Study (IAS):
-5251:RCM-Abwassergebäude:
-5252:RCM-Gasversorgung:
5257:Werkstatt u. Bürogebäude FRM II (UYW):5257,uyw
5301:Institute for Advanced Study (IAS):5301,ias
5302:Centrum Baustoffe und Materialprüfung (CBM):5302,cbm
5304:Mensa Garching:
5305:Modulbau NDB 2, Lichtenbergstr. 2c:
Expand Down Expand Up @@ -475,6 +483,7 @@
6101:Heizkraftwerk:
6102:Betriebsgebäude:
6103:Hochspannungsgebäude:
-6106:Trafostation Betriebsgebäude:
6107:Garagenbau:
6202:Feuerwehrwache Garching:6202,feuerwehrwache-garching
7:Garching Forschungszentrum (außerhalb):garching-extra
Expand All @@ -488,8 +497,14 @@
8104:Carl-Zeiss-Straße 8:
8111:Schleißheimerstr. 90a:
9001:TUM Science & Study Center Raitenhaslach:9001,raitenhaslach
9101:Garmisch-Partenkirchen (A, Bahnhofstr. 37):
91:Garmisch-Partenkirchen:garmisch-partenkirchen[site]
9101:Bahnhofstraße 37|A:
9110:Geigergebäude|GP:
9201:TUM FZ Friedrich N. Schwarz Berchtesgaden:
:München Flughafen|MUC:muc[site]
9344:Lärmschutzhalle 344:
9510:LabCampus 48 (AM):
9511:LabCampus 52 (AM):
93:Taufkirchen / Ottobrunn (Luftfahrt, Raumfahrt und Geodäsie)|Taufkirchen/Ottobr.:taufkirchen-ottobrunn[campus]
9377:Lise-Meitner-Straße 9:
9378:TUM Panasonic (Caroline-Herschel-Straße 100):
Expand Down
81 changes: 53 additions & 28 deletions data/processors/areatree/test_areatree.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from typing import Any

import pytest
from external.models import tumonline
from processors import areatree
from processors.areatree.process import (
_areatree_lines,
Expand Down Expand Up @@ -115,44 +116,46 @@ def test_id_not_inferable() -> None:
_extract_id_and_type("123,visible_id,extra_id", None)


def test_empty_file() -> None:
"""Empty file returns empty list"""
with tempfile.NamedTemporaryFile() as file:
@pytest.fixture
def areatree_tempfile() -> Any:
"""Bind AREATREE_FILE to a writable temp file; restore the original on teardown."""
original = areatree.process.AREATREE_FILE
with tempfile.NamedTemporaryFile(mode="w+") as file:
areatree.process.AREATREE_FILE = Path(file.name)
assert not list(_areatree_lines())
yield file
areatree.process.AREATREE_FILE = original


def test_empty_file(areatree_tempfile: Any) -> None:
"""Empty file returns empty list"""
assert not list(_areatree_lines())


def test_comment_lines() -> None:
def test_comment_lines(areatree_tempfile: Any) -> None:
"""Comment lines are removed"""
with tempfile.NamedTemporaryFile(mode="w+") as file:
areatree.process.AREATREE_FILE = Path(file.name)
file.write("line1\n")
file.write("\n") # Empty line
file.write("# Comment line\n")
file.write("line2\n")
file.flush()
assert list(_areatree_lines()) == ["line1", "line2"]
areatree_tempfile.write("line1\n")
areatree_tempfile.write("\n") # Empty line
areatree_tempfile.write("# Comment line\n")
areatree_tempfile.write("line2\n")
areatree_tempfile.flush()
assert list(_areatree_lines()) == ["line1", "line2"]


def test_inline_comments() -> None:
def test_inline_comments(areatree_tempfile: Any) -> None:
"""Inline comments are removed"""
with tempfile.NamedTemporaryFile(mode="w+") as file:
areatree.process.AREATREE_FILE = Path(file.name)
file.write("line1#comment1\n")
file.write("line2#comment2 # comment 3\n")
file.flush()
assert list(_areatree_lines()) == ["line1", "line2"]
areatree_tempfile.write("line1#comment1\n")
areatree_tempfile.write("line2#comment2 # comment 3\n")
areatree_tempfile.flush()
assert list(_areatree_lines()) == ["line1", "line2"]


def test_file_preserves_indentation() -> None:
def test_file_preserves_indentation(areatree_tempfile: Any) -> None:
"""Indentation is preserved"""
with tempfile.NamedTemporaryFile(mode="w+") as file:
areatree.process.AREATREE_FILE = Path(file.name)
file.write(" line1 \n")
file.write(" line2\n")
file.write("line3")
file.flush()
assert list(_areatree_lines()) == [" line1", " line2", "line3"]
areatree_tempfile.write(" line1 \n")
areatree_tempfile.write(" line2\n")
areatree_tempfile.write("line3")
areatree_tempfile.flush()
assert list(_areatree_lines()) == [" line1", " line2", "line3"]


def test_valid_line() -> None:
Expand All @@ -170,3 +173,25 @@ def test_invalid_line_extra_parts() -> None:
"""Extra parts are not allowed"""
with pytest.raises(RuntimeError):
_split_line("1:Building A:123,456:extra_part")


def test_all_tumonline_buildings_in_areatree() -> None:
"""Every TUMonline building must have a matching entry in the areatree"""
df = areatree.process.read_areatree()

known_b_prefixes: set[str] = set()
for row in df.iter_rows(named=True):
if row.get("b_prefix") is not None:
known_b_prefixes.add(row["b_prefix"])
if row.get("b_prefix_list") is not None:
known_b_prefixes.update(row["b_prefix_list"])

missing = sorted(
(b_id, building.name)
for b_id, building in tumonline.Building.load_all().items()
if b_id not in known_b_prefixes
)

assert not missing, "TUMonline buildings missing from areatree:\n" + "\n".join(
f" {b_id}: {name}" for b_id, name in missing
)
52 changes: 52 additions & 0 deletions data/sources/01_areas-extended.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,10 @@ heilbronn:
coords:
lat: 48.1797454
lon: 11.5464106
2535:
coords:
lat: 48.136579
lon: 11.602407
2803:
coords:
lat: 48.1314
Expand Down Expand Up @@ -784,6 +788,34 @@ mi:
id: 00.05.011
- name: Bode Raum
subtext: ''
3123:
coords:
lat: 47.555956
lon: 11.291274
3124:
coords:
lat: 47.555956
lon: 11.291274
4186:
coords:
lat: 48.393568763282815
lon: 11.733481655358464
4330:
coords:
lat: 48.108354
lon: 11.529317
4331:
coords:
lat: 48.108354
lon: 11.529317
4514:
coords:
lat: 48.404824
lon: 11.694702
5212:
coords:
lat: 48.264855036851365
lon: 11.674017005901092
5622:
coords:
lat: 48.2635
Expand All @@ -802,6 +834,10 @@ mi:
coords:
lat: 48.26420983175217
lon: 11.661077742475014
6106:
coords:
lat: 48.26038874622769
lon: 11.658267595222773
galileo:
coords:
lat: 48.26541
Expand Down Expand Up @@ -940,6 +976,14 @@ taufkirchen-ottobrunn:
coords:
lat: 48.05453
lon: 11.65308
9110:
coords:
lat: 47.487317
lon: 11.061414
9344:
coords:
lat: 48.344112
lon: 11.746225
9377:
coords:
lat: 48.05453
Expand Down Expand Up @@ -982,3 +1026,11 @@ taufkirchen-ottobrunn:
lon: 11.29609
osm:
- way/1123333684
9510:
coords:
lat: 48.354030
lon: 11.754175
9511:
coords:
lat: 48.354100
lon: 11.752962
Loading