用于航空的Python寻路器

2024-04-24 05:34:46 发布

您现在位置:Python中文网/ 问答频道 /正文

我做了一个应用程序,除了所有其他的事情,试图找到一个有效的路线之间的两个机场。 我在sqlite3数据库中有所有需要的数据,我在PyQt5中嵌入的带有实时信号的底图中查询和绘制这些数据。 我的问题是我找不到算法,使所有可能的变化(与取消资格的一些,因为所有的可能性是巨大的)和存储它们输出最终有效的路线。 我认为Dijkstra的算法无法实现,因为任何时候一条路线都可能到达死胡同。你知道吗

我的主要问题是算法及其实现,而不是数据,所以不要犹豫,写任何可能的算法所需的任何数据。你知道吗

算法提示如下:

  1. 我有一个出发点。你知道吗
  2. 我发现所有的路线,包括这个出发点(取消资格的oposite标题)(每条路线有不同的航路点)。你知道吗
  3. 为每条路线找到下一个航路点。你知道吗
  4. 现在这个航路点可以连接到其他路线,以此类推。你知道吗
  5. 然后通过各种变型或到达死胡同对路线进行测试和研究。你知道吗
  6. 继续,直到到达最后一个(目标航路点)。你知道吗
  7. 输出以某种方式存储的路由

到目前为止,我对堆栈问题的看法是:

##finding base direction##
base_radians = math.atan2(self.dest_coord[0]-self.dep_coord[0], self.dest_coord[1]-self.dep_coord[1])
base_degrees = math.degrees(base_radians)
print(base_degrees)
if base_degrees < 0 :
    base_heading = 'W'
else:
    base_heading = 'E'
### finding all routes connected to first waypoint###
self.cursor.execute("select DISTINCT ats_ident,seq_num from dafif_ats where wpt1_ident = ? AND ats_icao = ? AND direction = ? ORDER BY ats_ident,seq_num ASC",('ATV','LGGG',base_heading))
sub_ats_idents = self.cursor.fetchall()
#### for each route find next waypoints###       
for i in sub_ats_idents:
    self.cursor.execute("select wpt1_ident,wpt2_ident from dafif_ats where ats_ident = ? and ats_icao = ?  and direction = ? and seq_num >= ? ORDER BY seq_num ASC",(i[0],'LGGG',base_heading,i[1]))
    each_wpt_combo = self.cursor.fetchall()
    #### for each next waypoint find possible routes###   
    for x in each_wpt_combo:
        self.cursor.execute("select DISTINCT ats_ident,seq_num from dafif_ats where wpt1_ident = ? AND ats_icao = ? AND direction = ? ORDER BY ats_ident,seq_num ASC",(x[0],'LGGG',base_heading))
        each_ats = self.cursor.fetchall()
        print(each_ats)
        #### for each subroute plot waypoints###   
        for z in each_ats:
            self.cursor.execute("select wpt1_dlon,wpt1_dlat,wpt2_dlon,wpt2_dlat from dafif_ats where wpt1_ident = ? AND ats_icao = ? AND direction = ? ORDER BY ats_ident,seq_num ASC",(x[0],'LGGG',base_heading))
            plot_var = self.cursor.fetchall()
            self.route_sender.emit(plot_var)
            time.sleep(0.1)

enter image description here

任何材料或例子阅读将是超级。 提前打电话。你知道吗


Tags: andself算法forbase路线cursornum