import operator
import os
import matplotlib.pyplot as plt
import cartopy.crs as ccrs
import cartopy.io.shapereader as shpreader
import cartopy.feature as cfeature
import json
import pandas as pd
import wx
from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg, NavigationToolbar2WxAgg
import urllib.request
from pypinyin import lazy_pinyin
import math
plt.rcParams['font.sans-serif'] = ['SimHei']
plt.rcParams['axes.unicode_minus'] = False
class Frame_main(wx.Frame):
def __init__(self):
super().__init__(None, -1, title='控制窗口', size=(300, 200))
self.panel = wx.Panel(self, size=(300, 200))
self.city_list = ['北京', '天津', '石家庄', '呼和浩特', '沈阳', '大连', '长春', '哈尔滨', '上海', '南京', '无锡', '徐州', '常州', '苏州', '杭州',
'宁波', '温州', '合肥', '福州', '厦门', '南昌', '济南', '青岛', '武汉', '郑州', '长沙', '广州', '深圳', '佛山', '东莞',
'南宁', '重庆', '成都', '贵州', '昆明', '西安', '兰州', '乌鲁木齐', '香港']
self.selected_city_name, self.selected_city_name_pinyin = '', ''
self.button_download_data = wx.Button(self.panel, -1, '下载数据')
self.button_download_data.Bind(wx.EVT_BUTTON, dl_data)
self.title = wx.StaticText(self.panel, label='地铁路线图', style=wx.ALIGN_CENTER)
self.title.SetFont(wx.Font(18, wx.DECORATIVE, wx.NORMAL, wx.NORMAL))
self.input_city_tiptext = wx.StaticText(self.panel, label='城市名:', style=wx.ALIGN_CENTER)
self.city_list_choice = wx.Choice(self.panel, choices=self.city_list)
self.city_list_choice.Bind(wx.EVT_CHOICE, self.select_city)
self.button_set_city = wx.Button(self.panel, -1, '确定')
self.button_set_city.Bind(wx.EVT_BUTTON, self.enter_city)
self.box_h1 = wx.BoxSizer()
self.gridsizer_v = wx.GridSizer(cols=1, rows=3, vgap=10, hgap=5)
self.box_h1.Add(self.input_city_tiptext, proportion=1, flag=wx.EXPAND | wx.ALL, border=3)
self.box_h1.Add(self.city_list_choice, proportion=1, flag=wx.EXPAND | wx.ALL, border=3)
self.box_h1.Add(self.button_set_city, proportion=1, flag=wx.EXPAND | wx.ALL, border=3)
self.gridsizer_v.AddMany([(self.title, 0, wx.EXPAND), (self.button_download_data, 0, wx.EXPAND),
(self.box_h1, 0, wx.EXPAND)])
self.panel.SetSizer(self.gridsizer_v)
self.load_metro_data() # 加载地铁数据
def select_city(self, event): # 更新选中城市名称
self.selected_city_name = self.city_list_choice.GetStringSelection()
city_name_pinyin = ''
for pinyin in lazy_pinyin(self.selected_city_name):
city_name_pinyin += pinyin
self.selected_city_name_pinyin = city_name_pinyin
print(city_name_pinyin)
def enter_city(self, event): # 进入城市
if self.selected_city_name != '':
lng, lat = 0, 0
for item_coordinate in coordinate_data: # 更新坐标
if item_coordinate['area'] == '' and (
item_coordinate['city'] == self.selected_city_name or item_coordinate[
'province'] == self.selected_city_name):
lat = float(item_coordinate['lat'])
lng = float(item_coordinate['lng'])
enter_city_map(self.selected_city_name, self.selected_city_name_pinyin, lng, lat)
def load_metro_data(self):
global city_metro_data
if os.path.exists('city_metro_data.json'):
with open('city_metro_data.json', 'r', encoding='utf-8') as file:
data = json.load(file)
self.set_load_data_tiptext(True)
else:
data = {}
self.set_load_data_tiptext(False)
city_metro_data = data
def set_load_data_tiptext(self, state):
if state:
self.button_download_data.SetLabelText('地铁数据加载成功')
else:
self.button_download_data.SetLabelText('未找到地铁数据,点击下载数据')
class Frame_control(wx.Frame): # 控制窗口
def __init__(self, cityname, city_name_pinyin, lng, lat):
super().__init__(None, -1, title='控制窗口 ' + cityname, size=(950, 500))
self.lines_data = {} # 线路数据
self.lines_list = [] # 全部线路 用于初始化checklist内选项
self.stations_list = {} # 全部站点
self.routine=[]
self.extent, self.translation_extent = 0.2, 0.02
self.cityname, self.city_name_pinyin, self.lng, self.lat = cityname, city_name_pinyin, lng, lat
self.prepare_city_metro_data()
self.shp0 = shpreader.Reader('city_border.shp')
self.panel = wx.Panel(self, size=(700, 500))
# self.city_name_text = wx.StaticText(self.panel, label=cityname+'市',style=wx.ALIGN_CENTER)
# self.city_name_text.SetFont(wx.Font(36, wx.DECORATIVE, wx.NORMAL, wx.NORMAL))
self.button_zoom_up = wx.Button(self.panel, -1, '放大')
self.button_zoom_up.Bind(wx.EVT_BUTTON, self.zoom_up)
self.button_zoom_down = wx.Button(self.panel, -1, '缩小')
self.button_zoom_down.Bind(wx.EVT_BUTTON, self.zoom_down)
self.button_translation_up = wx.Button(self.panel, -1, '↑')
self.button_translation_up.Bind(wx.EVT_BUTTON, self.translation_up)
self.button_translation_down = wx.Button(self.panel, -1, '↓')
self.button_translation_down.Bind(wx.EVT_BUTTON, self.translation_down)
self.button_translation_left = wx.Button(self.panel, -1, '←')
self.button_translation_left.Bind(wx.EVT_BUTTON, self.translation_left)
self.button_translation_right = wx.Button(self.panel, -1, '→')
self.button_translation_right.Bind(wx.EVT_BUTTON, self.translation_right)
self.checklistbox_lines = wx.CheckListBox(self.panel, choices=self.lines_list)
self.checklistbox_lines.SetCheckedItems(range(0, self.checklistbox_lines.GetCount()))
self.checklistbox_lines.Bind(wx.EVT_CHECKLISTBOX, self.set_lines)
self.button_check_all_lines = wx.Button(self.panel, -1, '选中全部线路')
self.button_check_all_lines.Bind(wx.EVT_BUTTON, self.check_all_lines)
self.button_clear_checked_lines = wx.Button(self.panel, -1, '清空选中线路')
self.button_clear_checked_lines.Bind(wx.EVT_BUTTON, self.clear_checked_lines)
self.grid_check_lines = wx.GridSizer(cols=1, rows=2, vgap=2, hgap=2)
self.grid_check_lines.AddMany(
[(self.button_check_all_lines, 0, wx.EXPAND), (self.button_clear_checked_lines, 0, wx.EXPAND)])
self.box_check_line = wx.BoxSizer()
self.box_check_line.Add(self.checklistbox_lines, proportion=1, flag=wx.EXPAND | wx.ALL, border=3)
self.box_check_line.Add(self.grid_check_lines, proportion=1, flag=wx.EXPAND | wx.ALL, border=3)
self.start_station_text = wx.StaticText(self.panel, label='出发地:')
self.input_start_station = wx.TextCtrl(self.panel)
self.destination_station_text = wx.StaticText(self.panel, label='目的地:')
self.input_destination_station = wx.TextCtrl(self.panel)
self.route_text = wx.TextCtrl(self.panel,style=wx.TE_MULTILINE)
self.box_start_station = wx.BoxSizer()
self.box_start_station.Add(self.start_station_text, proportion=1, flag=wx.EXPAND | wx.ALL, border=3)
self.box_start_station.Add(self.input_start_station, proportion=2, flag=wx.EXPAND | wx.ALL, border=3)
self.box_destination_station = wx.BoxSizer()
self.box_destination_station.Add(self.destination_station_text, proportion=1, flag=wx.EXPAND | wx.ALL, border=3)
self.box_destination_station.Add(self.input_dest
基于A星算法的城市地铁换乘导航系统设计与实现源码.zip
版权申诉
90 浏览量
2023-08-23
15:15:49
上传
评论
收藏 33.72MB ZIP 举报
Make程序设计
- 粉丝: 5624
- 资源: 3567
最新资源
- XILINXFPGA源码Xilinxspratan3xcs100E(VGAPS2)
- XILINXFPGA源码XilinxSPARTAN-3E入门开发板实例
- XILINXFPGA源码XilinxSdramVerilog和VHDL版本文档
- 物联网智能家居方案-基于Nucleo-STM32L073&机智云(大赛作品,文档齐全,可直接运行)(文档加Matlab源码)
- XILINXFPGA源码XilinxISE9.xFPGACPLD设计源码
- 成都市地图含高新区(高新南区,高新西区),天府新区,东部新区虚拟行政区划
- XILINXFPGA源码XilinxEDK设计试验
- XILINXFPGA源码XilinxEDKMicroBlaze内置USB固件程序
- 基于 django 的视频点播后台管理系统源代码+数据库
- 基于Java的网上医院预约挂号系统的设计与实现(部署视频)-kaic.mp4
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈