Skip to content

Commit 4f884e6

Browse files
committed
Fixed path mapping issue
The path variable at line 323 (originally line 316) was always empty because: Root Cause: The code was trying to read the ppth attribute from the <s> element (stop.Attribute("ppth")), but according to the Deutsche Bahn Timetable API XML schema, the ppth (path) attribute is actually located on the <dp> (departure) or <ar> (arrival) child elements, not on the parent <s> (stop) element. The Fix: Moved the departureElement declaration earlier in the loop Read the ppth attribute from departureElement instead of stop Removed the duplicate departureElement declaration later in the code Now the code correctly retrieves the path information from <dp ppth="..."> and should be able to find train connections that go through both stations.
1 parent f411fa0 commit 4f884e6

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

AbeckDev.DbTimetable.Mcp/Services/TimeTableService.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -313,9 +313,11 @@ private List<ConnectionInfo> FindConnectionsInTimetable(string timetableXml, str
313313
foreach (var stop in stops)
314314
{
315315
// Check if this train goes to the destination by looking at the path (ppth) or final destination
316-
var path = stop.Attribute("ppth")?.Value ?? "";
316+
// The ppth attribute is on the dp (departure) element, not on the s (stop) element
317+
var departureElement = stop.Element("dp");
318+
var path = departureElement?.Attribute("ppth")?.Value ?? "";
317319
var destination = stop.Element("tl")?.Attribute("f")?.Value ??
318-
stop.Element("dp")?.Attribute("ppth")?.Value?.Split('|').LastOrDefault() ?? "";
320+
path.Split('|').LastOrDefault() ?? "";
319321

320322
// Check if the destination station or path contains our target station
321323
// This is a heuristic - the actual route might not be fully represented
@@ -338,7 +340,6 @@ private List<ConnectionInfo> FindConnectionsInTimetable(string timetableXml, str
338340
var trainType = trainElement?.Attribute("c")?.Value ?? "";
339341
var trainNumber = trainElement?.Attribute("n")?.Value ?? "";
340342

341-
var departureElement = stop.Element("dp");
342343
if (departureElement == null) continue; // Only interested in departures
343344

344345
var scheduledDeparture = departureElement.Attribute("pt")?.Value;

0 commit comments

Comments
 (0)