To reduce the cost of a flight, a calculation method is proposed in this paper, which takes the shortest distance as the goal and avoids the obstacle zone, and controls the turning angle as a constraint. Firstly, the Maklink diagram is used to build the obstacle zone model and establish the relationship between the obstacle zones. Then Dijkstra algorithm is used to construct the initial flight path to form a suboptimal path. Then the genetic ant colony algorithm is used to optimize the obtained suboptimal path. When there is a conflict risk between the two planned paths, the flight altitude of the aircraft on one path is adjusted, and the constraints are checked to form the optimal path. The simulation results show that the method can realize flight path optimization and verify the feasibility of the method.