fix: address code review findings
This commit is contained in:
@@ -239,6 +239,30 @@ func RouteSearch(hc *HandlerContext, w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
}
|
||||
|
||||
// Detect closed stations by checking if they have real edges in the graph
|
||||
for _, cityID := range []string{req.FromCityID, req.ToCityID} {
|
||||
// Get stations for this city
|
||||
stations := getStationsForCity(cityID)
|
||||
for _, station := range stations {
|
||||
if len(station) > 0 {
|
||||
stationID := station[0]
|
||||
// Check if this station has real edges
|
||||
hasRealEdges := false
|
||||
for _, edge := range hc.Router.Edges() {
|
||||
if edge.From.ID == stationID || edge.To.ID == stationID {
|
||||
if edge.Kind == routing.EdgeKindReal {
|
||||
hasRealEdges = true
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
if !hasRealEdges {
|
||||
closedStationsMap[stationID] = true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Run Pareto-optimal route search using the graph
|
||||
results := hc.Router.FindRoutesPareto(req.FromCityID, req.ToCityID, opts, closedStationsMap, neighborsMap)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user