操作x-plane的apt.dat文件和与x-plane风景网关接口的工具

xplane-airports的Python项目详细描述


使用X-Plane机场数据的工具

Circleci

x plane_airport s是一个python包,用于与x-plane的机场数据(apt.dat a-apt-dat-file-format-specification/" rel="nofollow">apt.dat)文件进行交互。

这包括以下主要部件:

  1. aptdatcode>模块:用于解析和查询rawapt.dat文件(例如,X-plane安装中存储在磁盘上的文件)
    • 类本身:X-Plane的机场数据文件(可能包含35000多个机场)的解析器;对象的集合
    • 类:表示apt.dat文件中的单个机场。
  2. 网关模块:用于与x-plane风景网关交互以获取可用机场的信息,并下载贡献的各个风景包在社区里。
    • airports():查询网关上所有35000多个机场的元数据。
    • airport():查询网关以获取有关指定机场本身的信息,以及有关为其提交的所有风景包的元数据。与science_pack()不同,这并不包括实际的apt.dat或DSF数据。
    • sciented_pack():下载指定机场的推荐包或具有指定intid的风景包。包括apt.dat数据和DSF,如适用。
    • recommended_pictures_packpacks():相当于调用布景包()下载每个机场的推荐布景包(或仅下载预先选定的机场列表,由您自行决定)。
  3. < > >

    安装说明

    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
    参数:

    • apt-dat-u文件的文本strpathlib.path):apt.dat(或icao.dat)文件的内容
    • from_filestr):从中读取文件的路径

    属性ids
    包含集合中所有机场的X平面ID的生成器。请注意,这些识别码可能与机场的国际民航组织识别码对应,也可能与之不对应。
    类型:collection.iterable[str]

    属性名称
    包含集合中所有机场名称的生成器
    类型:collection.iterable[str]

    方法按ID搜索apt_id
    参数:apt_idstr)–要查询的机场的x-平面id
    返回:具有指定ID的机场,如果此集合中不存在匹配的机场,则返回none
    返回类型:union[机场,无]

    方法按名称搜索apt_name
    参数:apt_namestr)–要查询的机场的名称
    返回:与指定名称匹配的所有机场,不区分大小写(如果没有机场匹配,则为空列表) 返回类型:list[机场]

    方法按谓词搜索谓词
    参数:predicate fnairport->;bool)–我们将收集此函数返回true的所有机场 返回类型:list[机场]

    方法排序key='name'
    默认情况下,我们以从apt.dat文件读取机场数据的任何顺序存储机场数据。但是,当您调用sort时,我们将确保它是有序的(默认为name order,就像x-plane的装运版本中一样)。
    参数:str)–要排序的机场键

    方法写入磁盘路径
    编写一个包含整个机场集合的完整apt.dat文件。
    参数:path_to_write_tostr)–完整的文件路径(以.dat结尾)

    机场机场

    apt.dat文件中的一个机场。

    classx>x>x>x>x>x>x>x>x>x>x>机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场从机场机场机场机场机场机场机场起飞机场机场机场机场机场机场机场机场机场起飞机场机场机场机场机场机场机场机场机场飞行机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场飞行机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场机场/p>

    数据类成员:

    • name(str):机场的名称,如"西雅图塔科马国际机场"
    • id(str):机场的x-平面标识符,可能与国际民航组织的id对应,也可能与之不对应
    • from_filepathlib.path;默认为空):从中读取机场的apt.dat文件的路径
    • has_atc(bool;defaultfalse):如果机场标题指示机场有空中交通管制,则为true
    • 海拔高度:高于平均海平面的高度,显示在机场标题行中。
    • 文本(list[aptdatline];默认为空:apt.dat文件中与此机场相关的部分的完整文本

    静态方法从行apt-dat-u行从文件名)->;机场 参数:\

    • from_file_namestr)–从中读取此机场的apt.dat文件的名称
    • apt-dat-linecollections.iterable[aptdatline;str])–apt.dat文件的行(字符串或解析的aptdatline对象)

    静态方法from_str文件文本来自文件名)->;机场
    参数:

    • 文件文本str)–指定此机场的apt.dat文件文本部分
    • from_file_namestr)–从中读取此机场的apt.dat文件的名称

    方法头(行数=10)->;str
    返回该机场apt.dat文本的第一行

    属性具有通信频率(bool)
    如果该机场定义了与空中交通管制交互的通信无线电频率,则为真

    属性具有地面路径(bool)\
    如果机场定义了地面车辆(如行李车、燃料车等)、地面卡车停车场或出租车路线的任何目的地,则为真

    酒店有出租车路线(bool)
    如果该机场定义了空中交通管制使用其滑行道的路线规则,则为真。\

    属性有滑行道(bool)
    如果机场定义了任何滑行道几何结构,则为真

    酒店有滑行道标志(bool)
    如果机场定义了任何出租车标志,则为真

    属性有流量(bool)
    如果该机场规定了空中交通管制应在何时和何种情况下使用某些跑道的规则,则为真

    属性纬度(浮点)
    机场的纬度,X-平面计算为第一条跑道中心的纬度。\

    属性经度(浮点)
    机场的经度,X平面计算为第一条跑道中心的经度。\

    方法有u行代码行代码)->;bool
    如果机场的文本中有任何以指定行代码开头的行
    参数:行代码u或u代码联合int
    ,\ustr>集合。iterable
    int]\uu)–一个或多个"行代码"(行首的第一个标记;几乎总是int)

    方法写入磁盘路径
    编写一个完整的apt.dat文件,其中仅包含此机场。
    参数:path_to_write_tostr)–完整的文件路径(以.dat结尾)

    aptdat.aptdatline

    apt.dat文件中的一行。

    xplane_airports.aptdat.aptdat lineline_text

    方法是机场标题()->;bool
    如果这条线表示机场、海港或直升机场的起点,则为真

    方法是文件头()->;bool 如果这是apt.dat文件头的一部分,则为true

    方法是不可忽略的()->;bool
    如果该行在apt.dat文件中没有任何机场的语义值,则为true。

    方法是跑道()->;bool
    如果该线表示陆上跑道、水道或直升机停机坪,则为真

    方法跑道类型 这条线所代表的跑道类型

    属性标记->;列表[str]
    此行中的标记

    aptdat.跑道类型

    xplane_airports.aptdat.runwaytype

    用于标识不同类型跑道的行代码枚举:

    • 着陆跑道
    • 水上跑道
    • 直升机停机坪

    网关模块

    与X-Plane风景网关的API接口的工具。

    文档位于:https://gateway.x-plane.com/api rel="nofollow">https://gateway.x-plane.com/api

    gateway.gatewayapt

    xplane_airports.gateway.gateway apt aptapt:aptdat.airport,txt:optional[str],readme:str,copying:str,pack_metadata:dict,apt_metadata:optional[dict]

    当我们通过风景包()下载风景包时,我们获得的有关机场的所有数据

    数据类成员:

    • aptairport):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_packsselective_apt_ids=none)->;collections.iterable[GatewayApt]

    用于迭代网关上所有(或仅选定)机场的推荐风景包的生成器。下载所有文件并将其解压缩到内存中。

    参数:选择性的aptu idunion集合。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())
    0

    xplane_airports.gateway.sceneture_packpack_to_download)->;gatewayapt

    从网关下载单个风景包,包括其apt.dat和任何相关的DSF,并将其解压缩到内存中。

    参数:pack_to_downloadstrint)–如果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

    欢迎加入QQ群-->: 979659372 Python中文网_新手群

    推荐PyPI第三方库


热门话题
JAVA Tictoe Minimax算法不断引发异常   java弹性时间计算器字符串开关   java从表单post操作中检索值   java Selenium webdriver无法在youtube上找到元素   java如何自动填写XFA(PDF)表单?   java为什么我的秒表程序不能运行?   raspberry pi禁用java中的其他声音   java如何配置web。xml,glassfishweb。JSF的xml文件?   使用浏览器运行自动测试时出现java错误。如何运行它?   java如何阻止Swing程序在每次向JTextArea添加文本时调整组件的大小   javajavax。注射注射无效   java如何改进Solaris服务器配置   java如何在elasticsearch后端脱机时处理Hibernate搜索启动   java TCPsocket的延迟很差,除非持续流式传输