function showRoutes(svg, projection, airportsData, iataCode) {
const routes = routesByAirport.get(iataCode) || [];
routes.forEach(route => {
const origin = airportsData[iataCode];
const destination = airportsData[route.destination_airport];
if (destination) {
const startPoint = projection([+origin.longitude, +origin.latitude]);
const endPoint = projection([+destination.longitude, +destination.latitude]);
const routeGroup = svg.append("g").classed("route-group", true);
routeGroup.append("line")
.attr("x1", startPoint[0])
.attr("y1", startPoint[1])
.attr("x2", endPoint[0])
.attr("y2", endPoint[1])
.attr("stroke", "gray")
.attr("stroke-width", 2)
.attr("stroke-dasharray", "5, 5");
const midX = (startPoint[0] + endPoint[0]) / 2;
const midY = (startPoint[1] + endPoint[1]) / 2;
const text = routeGroup.append("text")
.attr("x", midX)
.attr("y", midY)
.attr("dy", "0.3em")
.attr("text-anchor", "middle")
.style("font-family", "Arial")
.text(route.count);
const textSize = text.node().getBBox();
routeGroup.insert("rect", "text")
.attr("x", textSize.x - 2)
.attr("y", textSize.y - 2)
.attr("width", textSize.width + 4)
.attr("height", textSize.height + 4)
.attr("fill", "lightgray")
.attr("rx", 3);
text.raise();
}
});
}