Skip to content

Commit

Permalink
airport code restored
Browse files Browse the repository at this point in the history
  • Loading branch information
Pomax committed Nov 19, 2023
1 parent f34073f commit a87b083
Show file tree
Hide file tree
Showing 8 changed files with 243 additions and 230 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
v3.1.0

- Airport code has been restored, in a radically different way internally, but with the same API as before.

The airport data is now stored in a bundled database file. If the bundled database and the in-game airport database different in the number of airports, you'll get a console warning that you'll probably want to update your version of `msfs-simconnect-api-wrapper`.

v3.0.0

- The airport code has been disabled, because it's all kinds of broken at the moment, and needs to be redone.
Expand Down Expand Up @@ -61,4 +67,3 @@ v1.4.1
---

There was no changelog prior to v1.4.1

40 changes: 10 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,17 +87,13 @@ api.connect({
Note that the event names are keys from the `SystemEvents` object, using UPPER_SNAKE_CASE, not strings.
<!--
##### Special Events
There are currently two non-simconnect events that can be listened to:
- `AIRPORTS_IN_RANGE`, registers a listener for notifications about airports coming into range of our airplane (or rather, coming into range of "the current Sim bubble", which is all world tiles currently loaded and active in the sim).
- `AIRPORTS_OUT_OF_RANGE`, registers a listener for notifications about airports dropping out of range of our airplane (with the same note as above).
--->
#### `off(evtDefinition, handler)`
Stop listening for a specific simconnect event with a specific handler. You'll typically not need to call this function directly, as you can just use the function that `on` returns. See the "System events" section above for more details on the event definition.
Expand All @@ -106,39 +102,26 @@ Stop listening for a specific simconnect event with a specific handler. You'll t
Accepts a list of simvars (with spaces or underscores) and async-returns a key/value pair object with each simvar as key (with spaces replaced by underscores).
<!--
##### special (non-simconnect) variables
There are a number of special variables that can only be retrieved using a get call with a single variable name, yielding data that is not services by SimConnect's own variables (or data that requires a considerable amount of low-level event handling).
There are a number of special variables that can only be retrieved using a get call with a single variable name, yielding data that is not serviced by SimConnect's own variables (or data that requires a considerable amount of low-level event handling).
There are currently three variables:
- `NEARBY_AIRPORTS`, which yields the list of airports that are currently in range of our airplane (or rather, in range of "the current Sim bubble", which is all world tiles currently loaded and active in the sim).
- `ALL_AIRPORTS`, which yields the list of all airports known to MSFS.
Both calls return objects of the following type:
```
FacilityAirport {
icao: four character ICAO code
latitude: number in degrees
longitude: number in degrees
altitude: number in meters
}
```
Pay special attention to the altitude, which is *not* in feet, it is in meters.
- `NEARBY_AIRPORTS`, which yields the list of airports that are currently in range of our airplane (or rather, in range of "the current Sim bubble", which is all world tiles currently loaded and active in the sim).
- `NEARBY_AIRPORTS:NM`, which yields the list of airports within a radius of `NM` nautical miles around the airplane's location.
- `AIRPORT:index`, which yields an airport's information (including runway information), with `index` being the airport's ICAO code.
This call returns objects of the following type:
The first three return arrays of Airport object, the last one returns a single Airport object
Airport objects have the following shape:
```
{
latitude: number in degrees
longitude: number in degrees
altitude: number in meters
altitude: number in feet
declination: number in degree
name: airport name as a string with at most 32 characters
name64: airport name as a string with at most 64 characters
Expand All @@ -149,15 +132,13 @@ This call returns objects of the following type:
}
```
Again, pay special attention to the altitude, which is *not* in feet, it is in meters.
Runway objects are of the following type:
Runway objects have the following shape:
```
{
latitude: number in degrees, marking the center of the runway
longitude: number in degrees, marking the center of the runway
altitude: number in meters
altitude: number in feet
heading: number in degrees
length: number in meters
width: number in meters
Expand All @@ -169,7 +150,7 @@ Runway objects are of the following type:
}
```
Approaches are of the following type:
Approaches gave the following shape:
```
{
Expand All @@ -182,7 +163,6 @@ Approaches are of the following type:
}
}
```
-->
#### `schedule(handler, interval, ...propNames)`
Expand Down
24 changes: 0 additions & 24 deletions airport-test.js

This file was deleted.

Binary file added airport.db.gz
Binary file not shown.
2 changes: 1 addition & 1 deletion examples/README.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
I'm still adding examples, hang tight =)
Once [are we flying?](https://github.com/Pomax/are-we-flying) [has been updated](https://github.com/Pomax/are-we-flying/issues/21) I'll have time to add examples here.
4 changes: 2 additions & 2 deletions msfs-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ import { SimVars } from "./simvars/index.js";
import { SystemEvents as SysEvents } from "./system-events/index.js";

// Special import for working with airport data
import { getAirportHandler } from "./special/airports.js";
import { AirportEvents, getAirportHandler } from "./special/airports.js";
import { SIMCONNECT_EXCEPTION } from "./exceptions.js";

export const SystemEvents = Object.assign({}, SysEvents);
export const SystemEvents = Object.assign({}, SysEvents, AirportEvents);
export const MSFS_NOT_CONNECTED = `Not connected to MSFS`;
const codeSafe = (string) => string.replaceAll(` `, `_`);

Expand Down
Loading

0 comments on commit a87b083

Please sign in to comment.