Tools for working with X-Plane airport data
============================================================================================================================================================
[![CircleCI](https://circleci.com/gh/X-Plane/xplane_airports/tree/main.svg?style=svg)](https://circleci.com/gh/X-Plane/xplane_airports/tree/main)
`xplane_airports` is a Python package for interacting with [X-Plane](https://www.x-plane.com)'s airport data ([`apt.dat`](https://developer.x-plane.com/article/airport-data-apt-dat-file-format-specification/)) files.
This includes the following major components:
1. [The `AptDat` module](#the-aptdat-module): Used to parse & query raw `apt.dat` files (e.g., the files stored on disk in your X-Plane installation)
- The [`AptDat`](#aptdataptdat) class itself: A parser for X-Plane's airport data files (which may contain more than 35,000 airports); a collection of [`Airport`](#aptdatairport) objects
- The [`Airport`](#aptdatairport) class: Represents an individual airport from an `apt.dat` file.
2. [The `gateway` module](#the-gateway-module): Used to interact with [the X-Plane Scenery Gateway](https://gateway.x-plane.com) to get information about what airports are available, and to download individual scenery packs contributed by the community.
- [`airports()`](#xplane_airportsgatewayairports---dict): Queries for metadata on all 35,000+ airports on the Gateway.
- [`airport()`](#xplane_airportsgatewayairportairport_id---dict): Queries the Gateway for information about the specified airport itself, as well as metadata on all scenery packs submitted for it. Unlike [`scenery_pack()`](#xplane_airportsgatewayscenery_packpack_to_download---gatewayapt), though, this does *not* include actual `apt.dat` or DSF data.
- [`scenery_pack()`](#xplane_airportsgatewayscenery_packpack_to_download---gatewayapt): Downloads either the recommended pack for the specified airport, or the scenery pack with the specified `int` ID. Includes both the `apt.dat` data and DSF, where applicable.
- [`recommended_scenery_packs()`](#xplane_airportsgatewayrecommended_scenery_packsselective_apt_idsnone---collectionsiterablegatewayapt): A generator equivalent to calling [`scenery_pack()`](#xplane_airportsgatewayscenery_packpack_to_download---gatewayapt) to download the recommended scenery pack for every airport (or only a preselected list of airports, at your discretion).
## Table of Contents
* [Installation instructions](#installation-instructions)
* [Sample code](#sample-code)
+ [Parsing the default apt.dat file in your local X-Plane installation](#parsing-the-default-aptdat-file-in-your-local-x-plane-installation)
+ [Getting metadata on airports from the Gateway](#getting-metadata-on-airports-from-the-gateway)
+ [Downloaded the recommended scenery pack for an airport from the Gateway](#downloaded-the-recommended-scenery-pack-for-an-airport-from-the-gateway)
* [The `AptDat` module](#the-aptdat-module)
+ [AptDat.AptDat](#aptdataptdat)
+ [AptDat.Airport](#aptdatairport)
+ [AptDat.AptDatLine](#aptdataptdatline)
+ [AptDat.RunwayType](#aptdatrunwaytype)
* [The `gateway` module](#the-gateway-module)
+ [gateway.GatewayApt](#gatewaygatewayapt)
+ [gateway.GatewayFeature](#gatewaygatewayfeature)
+ [API wrapping functions](#api-wrapping-functions)
- [`xplane_airports.gateway.airport`(_airport\_id_) -> dict](#xplane_airportsgatewayrecommended_scenery_packsselective_apt_idsnone---collectionsiterablegatewayapt)
- [`xplane_airports.gateway.airports`() -> dict](#xplane_airportsgatewayairports---dict)
- [`xplane_airports.gateway.recommended_scenery_packs`(_selective\_apt\_ids=None_) -> collections.Iterable\[[GatewayApt](#gatewaygatewayapt)\]](#xplane_airportsgatewayrecommended_scenery_packsselective_apt_idsnone---collectionsiterablegatewayapt)
- [`xplane_airports.gateway.scenery_pack`(_pack\_to\_download_) -> [GatewayApt](#gatewaygatewayapt)](#xplane_airportsgatewayscenery_packpack_to_download---gatewayapt)
* [Migration notes](#migration-notes)
* [Running the tests (for maintainers)](#running-the-tests-for-maintainers)
* [Publishing package updates to PyPI (for maintainers)](#publishing-package-updates-to-pypi-for-maintainers)
## Installation instructions
`xplane_airports` requires Python 3.6 or newer.
Install via pip with:
`$ pip install xplane_airports`
If you're migrating from a pre-4.0 version of the library, see the [Migration notes](#migration-notes) section below.
## Sample code
### Parsing the default apt.dat file in your local X-Plane installation
```python
from xplane_airports.AptDat import AptDat, Airport
from pathlib import Path
xplane_installation = Path(input("Path to your X-Plane installation: "))
assert xplane_installation.is_dir(), f"{xplane_installation} does not exist or is not a directory"
print("Reading 35,000+ airports from disk (this will take awhile)")
default_xplane_apt_dat = AptDat(xplane_installation / 'Resources/default scenery/default apt dat/Earth nav data/apt.dat')
print(f"{len(default_xplane_apt_dat)} airports found in your default apt.dat\n")
ksea = default_xplane_apt_dat['KSEA']
""":type ksea: Airport"""
print("KSEA's airport data on disk begins:")
print(ksea.head())
```
### Getting metadata on airports from the Gateway
```python
from xplane_airports.gateway import airports
all_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:")
for key, value in all_apts['KSEA'].items():
print('\t' + key + ':', value)
```
### Downloaded the recommended scenery pack for an airport from the Gateway
```python
from xplane_airports.gateway import scenery_pack, GatewayApt
ksea_recommended_pack = scenery_pack('KSEA')
""":type ksea_recommended_pack: GatewayApt"""
print("KSEA downloaded from the Gateway begins:")
print(ksea_recommended_pack.apt.head())
```
More sample code is available in the doctests in [the `gateway` module](#the-gateway-module) docs below.
## The `AptDat` module
Tools for reading, inspecting, and manipulating X-Plane’s airport (apt.dat) files.
### AptDat.AptDat
_class_ `AptDat.AptDat`(_path\_to\_file=None_)
A container class for [`Airport`](#aptdatairport) objects. Parses X-Plane’s gigantic `apt.dat` files, which may have data on tens of thousands of airports.
**Fields**
- `airports` (List\[Airport\])
- `xplane_version` (int): The version of the apt.dat spec used by the airports in this collection
**Static method** `from_file_text`(_apt\_dat\_file\_text_, _from\_file_) -> [`AptDat`](#aptdataptdat)\
Parameters:
- **apt\_dat\_file\_text** (_str_): The contents of an apt.dat (or ICAO.dat) file
- **from\_file** (_os.PathLike_): Path to the file from which this was read
**Property** `ids`\
A generator containing the X-Plane IDs of all airports in the collection. Note that these IDs may or may not correspond to the airports’ ICAO identifiers.\
Type: collection.Iterable\[str\]
**Property** `names`\
A generator containing the names of all airports in the collection\
Type: collection.Iterable\[str\]
**Method** `search_by_id`(_apt\_id_)\
Parameter: **apt\_id** (_str_) – The X-Plane ID of the airport you want to query\
Returns: The airport with the specified ID, or `None` if no matching airport exists in this collection.\
Return type: Optional\[[Airport](#aptdatairport)\]
**Method** `search_by_name`(_apt\_name_)\
Parameter: **apt\_name** (_str_) – The name of the airport you want to query\
Returns: All airports that match the specified name, case-insensitive (an empty list if no airports match)
Return type: list\[[Airport](#aptdatairport)\]
**Method** `search_by_predicate`(_predicate\_fn_)\
Parameter: **predicate\_fn** (_(_[_Airport_](#aptdatairport)_)_ _\-> bool_) – We will collect all airports for which this function returns `True`\
Return type: list\[[Airport](#aptdatairport)\]
**Method** `sort`(_key='name'_)\
By default, we store the ai
没有合适的资源?快使用搜索试试~ 我知道了~
用于操作 X-Plane的apt.dat文件和与 X-Plane Scenery Gateway API接口的Python工具
共21个文件
py:10个
md:3个
xml:3个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 88 浏览量
2022-07-03
01:45:19
上传
评论
收藏 131KB ZIP 举报
温馨提示
这包括以下主要组成部分: AptDat模块:用于解析和查询原始apt.dat文件(例如,X-Plane 安装中存储在磁盘上的文件 ) 类本身:X-Plane 机场数据文件的AptDat解析器(可能包含超过 35,000 个机场);Airport对象的集合 类:代表文件中的Airport单个机场apt.dat。 gateway模块:用于与 X-Plane 风景网关交互以获取有关可用机场的信息,并下载社区提供的各个风景包。 airports():查询网关上所有 35,000 多个机场的元数据。 airport():查询网关以获取有关指定机场本身的信息,以及为其提交的所有风景包的元数据。但是,与 不同scenery_pack()的是,这不包括实际apt.dat数据或 DSF 数据。 scenery_pack(): 下载指定机场的推荐包,或指定intID的风景包。包括apt.dat数据和 DSF(如适用)。 更多详情、使用方法,请下载后阅读README.md文件
资源详情
资源评论
资源推荐
收起资源包目录
xplane_airports-main.zip (21个子文件)
xplane_airports
xplane_airports
gateway.py 11KB
test_TaxiRouteNetwork.py 6KB
test_apt.dat 383KB
__init__.py 25B
test_AptDat.py 22KB
_cached_prop.py 243B
AptDat.py 28KB
sample_code.py 1KB
.github
ISSUE_TEMPLATE
bug_report.md 799B
feature_request.md 560B
benchmark.py 931B
LICENSE 1KB
.idea
runConfigurations
Test_AptDatParser.xml 964B
Sample_Code.xml 1KB
Doctest.xml 1KB
setup.py 1KB
.gitignore 1KB
.circleci
config.yml 785B
README.md 22KB
source
conf.py 5KB
index.rst 555B
共 21 条
- 1
快撑死的鱼
- 粉丝: 1w+
- 资源: 9149
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0