Skip to content

Commit c7d931f

Browse files
committed
feat: add description_code to fix output
1 parent f242a95 commit c7d931f

File tree

4 files changed

+91
-83
lines changed

4 files changed

+91
-83
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ Before building, make sure you have properly created and set an `.env` file in `
6262

6363
## Building the WASM Module Yourself
6464

65-
1. [Download](https://www.docker.com/products/docker-desktop/) Docker Desktop
65+
1. [Install](https://github.com/navigraph/cargo-msfs) cargo-msfs
6666
2. Run `npm run build:wasm` (must be on Windows)
6767
- This will take a while to download and build the first time, but subsequent runs will be quicker
6868
3. The compiled WASM module will be copied to `out` **and** `examples/aircraft/PackageSources/SimObjects/Airplanes/Navigraph_Navigation_Data_Interface_Aircraft/panel`

src/database/src/output/airway.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ pub(crate) fn map_airways(data: Vec<sql_structs::EnrouteAirways>) -> Vec<Airway>
6767
airway_row.icao_code.unwrap_or("NULL".to_string()),
6868
None,
6969
airway_row.waypoint_ref_table,
70+
airway_row.waypoint_description_code.clone(),
7071
));
7172

7273
if airway_row

src/database/src/output/fix.rs

Lines changed: 85 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -1,82 +1,85 @@
1-
use serde::Serialize;
2-
3-
use crate::math::Coordinates;
4-
5-
#[derive(Serialize, Copy, Clone)]
6-
pub enum FixType {
7-
#[serde(rename = "A")]
8-
Airport,
9-
#[serde(rename = "N")]
10-
NdbNavaid,
11-
#[serde(rename = "R")]
12-
RunwayThreshold,
13-
#[serde(rename = "G")]
14-
GlsNavaid,
15-
#[serde(rename = "I")]
16-
IlsNavaid,
17-
#[serde(rename = "V")]
18-
VhfNavaid,
19-
#[serde(rename = "W")]
20-
Waypoint,
21-
#[serde(rename = "U")]
22-
None,
23-
}
24-
25-
#[serde_with::skip_serializing_none]
26-
#[derive(Serialize, Clone)]
27-
/// Represents a fix which was used as a reference in a procedure or an airway.
28-
///
29-
/// Every `Fix` will have a full data entry as one of these structs somewhere in the database with the same `ident` and
30-
/// `icao_code`:
31-
/// - `Airport`
32-
/// - `NdbNavaid`
33-
/// - `RunwayThreshold`
34-
/// - `GlsNavaid`
35-
/// - `IlsNavaid`
36-
/// - `VhfNavaid`
37-
/// - `Waypoint`
38-
pub struct Fix {
39-
/// The type of fix
40-
pub fix_type: Option<FixType>,
41-
/// The identifier of this fix (not unique), such as `KLAX` or `BI` or `RW17L` or `G07J` or `ISYK` or `YXM` or
42-
/// `GLENN`
43-
pub ident: String,
44-
/// The icao prefix of the region that this fix is in.
45-
pub icao_code: String,
46-
/// The geographic location of this fix
47-
pub location: Coordinates,
48-
/// The identifier of the airport that this fix is associated with, if any
49-
pub airport_ident: Option<String>,
50-
}
51-
52-
impl Fix {
53-
/// Creates a `Fix` by using the latitude and longitude fields, and by parsing the linked id field from a procedure
54-
/// or airway row.
55-
pub fn from_row_data(
56-
lat: f64,
57-
long: f64,
58-
ident: String,
59-
icao_code: String,
60-
airport_ident: Option<String>,
61-
ref_table: Option<String>,
62-
) -> Self {
63-
let fix_type = ref_table.map(|ref_table| match ref_table.as_str() {
64-
"PA" => FixType::Airport,
65-
"PN" | "DB" => FixType::NdbNavaid,
66-
"PG" => FixType::RunwayThreshold,
67-
"PT" => FixType::GlsNavaid,
68-
"PI" => FixType::IlsNavaid,
69-
"D " => FixType::VhfNavaid,
70-
"EA" | "PC" => FixType::Waypoint,
71-
x => panic!("Unexpected table: '{x}'"),
72-
});
73-
74-
Self {
75-
fix_type,
76-
ident,
77-
icao_code,
78-
location: Coordinates { lat, long },
79-
airport_ident,
80-
}
81-
}
82-
}
1+
use serde::Serialize;
2+
3+
use crate::math::Coordinates;
4+
5+
#[derive(Serialize, Copy, Clone)]
6+
pub enum FixType {
7+
#[serde(rename = "A")]
8+
Airport,
9+
#[serde(rename = "N")]
10+
NdbNavaid,
11+
#[serde(rename = "R")]
12+
RunwayThreshold,
13+
#[serde(rename = "G")]
14+
GlsNavaid,
15+
#[serde(rename = "I")]
16+
IlsNavaid,
17+
#[serde(rename = "V")]
18+
VhfNavaid,
19+
#[serde(rename = "W")]
20+
Waypoint,
21+
#[serde(rename = "U")]
22+
None,
23+
}
24+
25+
#[serde_with::skip_serializing_none]
26+
#[derive(Serialize, Clone)]
27+
/// Represents a fix which was used as a reference in a procedure or an airway.
28+
///
29+
/// Every `Fix` will have a full data entry as one of these structs somewhere in the database with the same `ident` and
30+
/// `icao_code`:
31+
/// - `Airport`
32+
/// - `NdbNavaid`
33+
/// - `RunwayThreshold`
34+
/// - `GlsNavaid`
35+
/// - `IlsNavaid`
36+
/// - `VhfNavaid`
37+
/// - `Waypoint`
38+
pub struct Fix {
39+
/// The type of fix
40+
pub fix_type: Option<FixType>,
41+
pub fix_code: Option<String>,
42+
/// The identifier of this fix (not unique), such as `KLAX` or `BI` or `RW17L` or `G07J` or `ISYK` or `YXM` or
43+
/// `GLENN`
44+
pub ident: String,
45+
/// The icao prefix of the region that this fix is in.
46+
pub icao_code: String,
47+
/// The geographic location of this fix
48+
pub location: Coordinates,
49+
/// The identifier of the airport that this fix is associated with, if any
50+
pub airport_ident: Option<String>,
51+
}
52+
53+
impl Fix {
54+
/// Creates a `Fix` by using the latitude and longitude fields, and by parsing the linked id field from a procedure
55+
/// or airway row.
56+
pub fn from_row_data(
57+
lat: f64,
58+
long: f64,
59+
ident: String,
60+
icao_code: String,
61+
airport_ident: Option<String>,
62+
ref_table: Option<String>,
63+
fix_code: Option<String>,
64+
) -> Self {
65+
let fix_type = ref_table.map(|ref_table| match ref_table.as_str() {
66+
"PA" => FixType::Airport,
67+
"PN" | "DB" => FixType::NdbNavaid,
68+
"PG" => FixType::RunwayThreshold,
69+
"PT" => FixType::GlsNavaid,
70+
"PI" => FixType::IlsNavaid,
71+
"D " => FixType::VhfNavaid,
72+
"EA" | "PC" => FixType::Waypoint,
73+
x => panic!("Unexpected table: '{x}'"),
74+
});
75+
76+
Self {
77+
fix_type,
78+
ident,
79+
icao_code,
80+
location: Coordinates { lat, long },
81+
airport_ident,
82+
fix_code,
83+
}
84+
}
85+
}

src/database/src/output/procedure_leg.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ impl From<sql_structs::Procedures> for ProcedureLeg {
106106
ProcedureLeg {
107107
overfly: leg
108108
.waypoint_description_code
109+
.clone()
109110
.map_or(false, |x| x.chars().nth(1) == Some('Y')),
110111
altitude: leg.altitude1.map(|altitude1| AltitudeContstraint {
111112
altitude1,
@@ -131,6 +132,7 @@ impl From<sql_structs::Procedures> for ProcedureLeg {
131132
leg.waypoint_icao_code.unwrap(),
132133
Some(leg.airport_identifier.clone()),
133134
leg.waypoint_ref_table,
135+
leg.waypoint_description_code.clone(),
134136
))
135137
} else {
136138
None
@@ -143,6 +145,7 @@ impl From<sql_structs::Procedures> for ProcedureLeg {
143145
leg.recommended_navaid_icao_code.unwrap(),
144146
Some(leg.airport_identifier.clone()),
145147
leg.recommended_navaid_ref_table,
148+
leg.waypoint_description_code.clone(),
146149
))
147150
} else {
148151
None
@@ -169,6 +172,7 @@ impl From<sql_structs::Procedures> for ProcedureLeg {
169172
leg.center_waypoint_icao_code.unwrap(),
170173
Some(leg.airport_identifier),
171174
leg.center_waypoint_ref_table,
175+
leg.waypoint_description_code,
172176
))
173177
} else {
174178
None

0 commit comments

Comments
 (0)