feat: Add bus transport type to routing with Pareto ranking support
This commit is contained in:
@@ -141,13 +141,19 @@ func BuildGraphFromStations(stations []StationInfo) *Graph {
|
||||
|
||||
// Add synthetic edge: station <-> city hub
|
||||
cityNode := cityNodes[si.CityCode]
|
||||
tp := TransportTypeTrain
|
||||
if si.CityCode == "c_airport" {
|
||||
tp = TransportTypePlane
|
||||
} else if si.CityCode == "c_bus" {
|
||||
tp = TransportTypeBus
|
||||
}
|
||||
graph.AddEdge(&Edge{
|
||||
From: station,
|
||||
To: cityNode,
|
||||
Kind: EdgeKindSynthetic,
|
||||
Duration: 300, // 5 min synthetic transfer
|
||||
Transport: "train",
|
||||
TransportType: TransportTypeTrain,
|
||||
Transport: string(tp),
|
||||
TransportType: tp,
|
||||
IsTransfer: true,
|
||||
})
|
||||
|
||||
@@ -157,8 +163,8 @@ func BuildGraphFromStations(stations []StationInfo) *Graph {
|
||||
To: station,
|
||||
Kind: EdgeKindSynthetic,
|
||||
Duration: 300, // 5 min synthetic transfer
|
||||
Transport: "train",
|
||||
TransportType: TransportTypeTrain,
|
||||
Transport: string(tp),
|
||||
TransportType: tp,
|
||||
IsTransfer: true,
|
||||
})
|
||||
}
|
||||
@@ -172,13 +178,21 @@ func addSyntheticEdgesForNode(graph *Graph, node *Node) {
|
||||
// Connect this node to city hubs in the same city via synthetic edges
|
||||
for _, n := range graph.Nodes() {
|
||||
if n.Type == NodeTypeCity && n.CityCode == node.CityCode {
|
||||
// Determine transport type based on city code
|
||||
tp := TransportTypeTrain
|
||||
if node.CityCode == "c_airport" {
|
||||
tp = TransportTypePlane
|
||||
} else if node.CityCode == "c_bus" {
|
||||
tp = TransportTypeBus
|
||||
}
|
||||
// Add synthetic edge from node to city hub
|
||||
graph.AddEdge(&Edge{
|
||||
From: node,
|
||||
To: n,
|
||||
Kind: EdgeKindSynthetic,
|
||||
Duration: 300, // 5 min synthetic transfer
|
||||
Transport: "train",
|
||||
Transport: string(tp),
|
||||
TransportType: tp,
|
||||
IsTransfer: true,
|
||||
})
|
||||
|
||||
@@ -188,7 +202,8 @@ func addSyntheticEdgesForNode(graph *Graph, node *Node) {
|
||||
To: node,
|
||||
Kind: EdgeKindSynthetic,
|
||||
Duration: 300, // 5 min synthetic transfer
|
||||
Transport: "train",
|
||||
Transport: string(tp),
|
||||
TransportType: tp,
|
||||
IsTransfer: true,
|
||||
})
|
||||
}
|
||||
@@ -532,9 +547,10 @@ func (g *Graph) FindRoute(originID, destID string, opts SearchOptions, yclient .
|
||||
From: fromNode,
|
||||
To: toNode,
|
||||
Duration: seg.Duration,
|
||||
Transport: "train",
|
||||
Transport: string(TransportTypeTrain),
|
||||
IsTransfer: seg.HasTransfers,
|
||||
Kind: EdgeKindReal,
|
||||
TransportType: TransportTypeTrain,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user