操作x-plane的apt.dat文件和与x-plane风景网关接口的工具
xplane-airports的Python项目详细描述
使用X-Plane机场数据的工具
x plane_airport s
是一个python包,用于与x-plane的机场数据(apt.dat a-apt-dat-file-format-specification/" rel="nofollow">apt.dat)文件进行交互。
这包括以下主要部件:
- aptdat
code>模块
:用于解析和查询rawapt.dat
文件(例如,X-plane安装中存储在磁盘上的文件)- 类本身:X-Plane的机场数据文件(可能包含35000多个机场)的解析器;对象的集合
- 类:表示apt.dat文件中的单个机场。
- 网关模块:用于与x-plane风景网关交互以获取可用机场的信息,并下载贡献的各个风景包在社区里。
airports()
:查询网关上所有35000多个机场的元数据。airport()
:查询网关以获取有关指定机场本身的信息,以及有关为其提交的所有风景包的元数据。与science_pack()
不同,这并不包括实际的apt.dat
或DSF数据。sciented_pack()
:下载指定机场的推荐包或具有指定int
id的风景包。包括apt.dat
数据和DSF,如适用。recommended_pictures_packpacks()
:相当于调用布景包()
下载每个机场的推荐布景包(或仅下载预先选定的机场列表,由您自行决定)。
< > > - apt-dat-u文件的文本(strpathlib.path):apt.dat(或icao.dat)文件的内容
- from_file(str):从中读取文件的路径
- name(str):机场的名称,如"西雅图塔科马国际机场"
- id(str):机场的x-平面标识符,可能与国际民航组织的id对应,也可能与之不对应
- from_file(pathlib.path;默认为空):从中读取机场的
apt.dat
文件的路径 - has_atc(bool;default
false
):如果机场标题指示机场有空中交通管制,则为true - 海拔高度:高于平均海平面的高度,显示在机场标题行中。
- 文本(list[aptdatline];默认为空:apt.dat文件中与此机场相关的部分的完整文本
- from_file_name(str)–从中读取此机场的apt.dat文件的名称
- apt-dat-line(collections.iterable[aptdatline;str])–apt.dat文件的行(字符串或解析的aptdatline对象)
- 文件文本(str)–指定此机场的apt.dat文件文本部分
- from_file_name(str)–从中读取此机场的apt.dat文件的名称
- 着陆跑道
- 水上跑道
- 直升机停机坪
- apt(airport):python对象,内容为apt.dat
- txt(str或
无
):dsf.txt文件的内容;没有3d的机场将不包括此项 - 自述文件(str):此风景包自述文件的内容
- 复制(str):此风景包的复制说明的内容
- pack_metadata(dict):从网关接收的json对象,其中包含有关此特定风景包的元数据
- apt_metadata(dict或
none
):从网关接收的json对象,其中包含此风景包表示的机场的元数据;如果尚未下载(尚未下载),则为none网关。网关功能
类
xplane_airports.gateway.gateway功能
枚举类,表示可用于标记网关上的风景包的功能。请注意,这些部件可能会频繁地添加/删除/更改;只有少数部件可以保证稳定。
- Hasatcflow(保证稳定)
- Hastaxiroute(保证稳定)
- hasnavaid冲突
- 始终保持水平
- haslogtxtsissue
- lInternalUse(保证稳定)
- 不包括提交(保证稳定)
- HasGroundRoutes(保证稳定)
- 地形不兼容
- 跑道号或长度修正
- 总是不起作用
- 主要机场
- 地形兼容度计
- 跑道编号修复程序
- 国际机场
- 浮动跑道
- 已认证的接地线路
- facadeinjection
- 场景机场
- 错误使用圆多边形
- 前30名
- 前50名
- 水下跑道
- 跑道不可用
- 地形缺失
- 低分辨率多晶硅
API包装函数
xplane_airports.gateway.airport
(机场id)->;dict查询风景网关以获取单个机场的元数据,以及为该机场上载的所有风景包的元数据。
API端点记录在:https://gateway.x-plane.com/api;get-a-single-airport" rel="nofollow">https://gateway.x-plane.com/api;get-a-single-airport\返回:包含机场元数据的dict
参数:机场标识(str)–网关上机场的标识(可能是或可能不是国际民航组织标识)>>>expected_keys={'icao','airportName','airportClass','latitude','longitude','elevation','acceptedSceneryCount','approvedSceneryCount','recommendedSceneryId','scenery'}>>>ksea=airport('KSEA')>>>all(keyinkseaforkeyinexpected_keys)True
包括为此机场上载的所有风景包的元数据:
>>>len(airport('KSEA')['scenery'])>=9True
>>>all_scenery_metadata=airport('KSEA')['scenery']>>>first_scenery_pack_metadata=all_scenery_metadata[0]>>>expected_keys={'sceneryId','parentId','userId','userName','dateUploaded','dateAccepted','dateApproved','dateDeclined','type','features','artistComments','moderatorComments','Status'}>>>all(keyinfirst_scenery_pack_metadataforkeyinexpected_keys)True
xplane_airports.gateway.airports
()->;dict查询它所知道的所有机场的风景网关。请注意,下载大小大于1 MB。
API端点记录在:https://gateway.x-plane.com/api;获取所有机场\返回一个包含35000多个机场的元数据的dict;键是x-plane标识符(可能与icao标识符对应,也可能与icao标识符不对应),值是各种机场元数据。
>>>airports()['KSEA']{'AirportCode':'KSEA','AirportName':'Seattle Tacoma Intl','AirportClass':None,'Latitude':47,'Longitude':-122,'Elevation':None,'Deprecated':None,'DeprecatedInFavorOf':None,'AcceptedSceneryCount':2,'ApprovedSceneryCount':2,'ExcludeSubmissions':0,'RecommendedSceneryId':45283,'Status':'Scenery Submitted','SceneryType':0,'SubmissionCount':2}
>>>len(airports())>35000True
xplane_airports.gateway.recommended_sciented_packs
(selective_apt_ids=none)->;collections.iterable[GatewayApt]用于迭代网关上所有(或仅选定)机场的推荐风景包的生成器。下载所有文件并将其解压缩到内存中。
参数:选择性的aptu id(union集合。iterable[str]\uuu,\unone]\u)-如果
none
,我们将为所有35000多个机场下载风景;如果机场id列表(由airports()返回)我们应该下载其推荐包的机场。
返回建议的风景包的生成器;每个包都包含与直接调用风景包()相同的数据
轻松申请一部分机场:
>>>packs=recommended_scenery_packs(['KSEA','KLAX','KBOS'])>>>len(list(packs))==3andall(isinstance(pack,GatewayApt)forpackinpacks)True
审核机场的特定功能:
fromxplane_airports.AptDatimportAptDat,Airportxplane_installation=input("Path to your X-Plane installation: ")print("Reading 35,000+ airports from disk")default_xplane_apt_dat=AptDat(xplane_installation+'Resources/default scenery/default apt dat/Earth nav data/apt.dat')print("%d airports found in your default apt.dat\n"%len(default_xplane_apt_dat))ksea=default_xplane_apt_dat['KSEA']""":type ksea: Airport"""print("KSEA's airport data on disk begins:")print(ksea.head())
0xplane_airports.gateway.sceneture_pack
(pack_to_download)->;gatewayapt从网关下载单个风景包,包括其apt.dat和任何相关的DSF,并将其解压缩到内存中。
参数:pack_to_download(str或int)–如果
int
,则为要下载的包的风景ID;如果str
,则为要下载其推荐包的机场。
返回下载的文件和有关风景包的元数据fromxplane_airports.AptDatimportAptDat,Airportxplane_installation=input("Path to your X-Plane installation: ")print("Reading 35,000+ airports from disk")default_xplane_apt_dat=AptDat(xplane_installation+'Resources/default scenery/default apt dat/Earth nav data/apt.dat')print("%d airports found in your default apt.dat\n"%len(default_xplane_apt_dat))ksea=default_xplane_apt_dat['KSEA']""":type ksea: Airport"""print("KSEA's airport data on disk begins:")print(ksea.head())
1推荐PyPI第三方库
安装说明
xplane_airports
需要python 3.7。
通过PIP安装,使用:
$pip安装xplane_机场
示例代码
分析本地x-plane安装中的默认apt.dat文件
fromxplane_airports.AptDatimportAptDat,Airportxplane_installation=input("Path to your X-Plane installation: ")print("Reading 35,000+ airports from disk")default_xplane_apt_dat=AptDat(xplane_installation+'Resources/default scenery/default apt dat/Earth nav data/apt.dat')print("%d airports found in your default apt.dat\n"%len(default_xplane_apt_dat))ksea=default_xplane_apt_dat['KSEA']""":type ksea: Airport"""print("KSEA's airport data on disk begins:")print(ksea.head())
从网关获取机场元数据
fromxplane_airports.gatewayimportairportsall_apts=airports()print("There are %d airports on the X-Plane Scenery Gateway"%len(all_apts))print("KSEA has the following metadata on the Gateway:")forkey,valueinall_apts['KSEA'].items():print('\t'+key+':',value)
已从网关下载机场的推荐风景包
fromxplane_airports.gatewayimportscenery_pack,GatewayAptksea_recommended_pack=scenery_pack('KSEA')""":type ksea_recommended_pack: GatewayApt"""print("KSEA downloaded from the Gateway begins:")print(ksea_recommended_pack.apt.head())
更多示例代码可在下面的文档中的网关模块中的文档中找到。
aptdat
模块
用于读取、检查和操作X-Plane机场(apt.dat)文件的工具。
aptdat.aptdat
类aptdat.aptdat
(文件路径=无)
机场
对象。分析X-Plane庞大的apt.dat文件,其中可能包含数百个机场的数据。
字段机场
(列出[机场])
静态方法来自文件文本
(apt-dat-u-file-text,来自文件)->;aptdat
参数:
属性ids
包含集合中所有机场的X平面ID的生成器。请注意,这些识别码可能与机场的国际民航组织识别码对应,也可能与之不对应。
类型:collection.iterable[str]
属性名称
包含集合中所有机场名称的生成器
类型:collection.iterable[str]
方法按ID搜索
(apt_id)
参数:apt_id(str)–要查询的机场的x-平面id
返回:具有指定ID的机场,如果此集合中不存在匹配的机场,则返回none
。
返回类型:union[机场,无]
方法按名称搜索
(apt_name)
参数:apt_name(str)–要查询的机场的名称
返回:与指定名称匹配的所有机场,不区分大小写(如果没有机场匹配,则为空列表)
返回类型:list[机场]
方法按谓词搜索
(谓词)
参数:predicate fn((airport)->;bool)–我们将收集此函数返回true的所有机场
返回类型:list[机场]
方法排序
(key='name')
默认情况下,我们以从apt.dat文件读取机场数据的任何顺序存储机场数据。但是,当您调用sort时,我们将确保它是有序的(默认为name order,就像x-plane的装运版本中一样)。
参数:键(str)–要排序的机场键
方法写入磁盘
(路径)
编写一个包含整个机场集合的完整apt.dat文件。
参数:path_to_write_to(str)–完整的文件路径(以.dat结尾)
机场机场
apt.dat文件中的一个机场。
class 数据类成员: 静态方法 静态方法 方法 属性 属性 酒店 属性 酒店 属性有流量(bool) 属性 属性 方法 方法 类 方法 方法 方法 方法 方法 属性 类 用于标识不同类型跑道的行代码枚举: 与X-Plane风景网关的API接口的工具。 文档位于:https://gateway.x-plane.com/api rel="nofollow">https://gateway.x-plane.com/api
类 当我们通过 数据类成员:x>x>x>x>x>x>x>x>x>x>x>机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场从机场机场机场机场机场机场机场起飞机场机场机场机场机场机场机场机场机场起飞机场机场机场机场机场机场机场机场机场飞行机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场飞行机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场/p>
从行
(apt-dat-u行,从文件名)->;机场
参数:\from_str
(文件文本,来自文件名)->;机场
参数:头(行数=10)
->;str
返回该机场apt.dat文本的第一行
具有通信频率
(bool)
如果该机场定义了与空中交通管制交互的通信无线电频率,则为真
具有地面路径
(bool)\
如果机场定义了地面车辆(如行李车、燃料车等)、地面卡车停车场或出租车路线的任何目的地,则为真
有出租车路线
(bool)
如果该机场定义了空中交通管制使用其滑行道的路线规则,则为真。\有滑行道
(bool)
如果机场定义了任何滑行道几何结构,则为真
有滑行道标志
(bool)
如果机场定义了任何出租车标志,则为真
如果该机场规定了空中交通管制应在何时和何种情况下使用某些跑道的规则,则为真
纬度
(浮点)
机场的纬度,X-平面计算为第一条跑道中心的纬度。\经度
(浮点)
机场的经度,X平面计算为第一条跑道中心的经度。\有u行代码
(行代码)->;bool
如果机场的文本中有任何以指定行代码开头的行
参数:行代码u或u代码(联合int写入磁盘
(路径)
编写一个完整的apt.dat文件,其中仅包含此机场。
参数:path_to_write_to(str)–完整的文件路径(以.dat结尾)aptdat.aptdatline
apt.dat
文件中的一行。xplane_airports.aptdat.aptdat line
(line_text)是机场标题
()->;bool
如果这条线表示机场、海港或直升机场的起点,则为真是文件头
()->;bool
如果这是apt.dat文件头的一部分,则为true
是不可忽略的
()->;bool
如果该行在apt.dat文件中没有任何机场的语义值,则为true。是跑道
()->;bool
如果该线表示陆上跑道、水道或直升机停机坪,则为真跑道类型
这条线所代表的跑道类型
标记
->;列表[str]
此行中的标记aptdat.跑道类型
xplane_airports.aptdat.runwaytype
网关
模块gateway.gatewayapt
xplane_airports.gateway.gateway apt apt
(apt:aptdat.airport,txt:optional[str],readme:str,copying:str,pack_metadata:dict,apt_metadata:optional[dict])风景包()下载风景包时,我们获得的有关机场的所有数据
文件