Skip to content

Commit

Permalink
Airspaces updates (preparing next data update).
Browse files Browse the repository at this point in the history
- set bottom unit to km again with 1 decimal (from m),
- different altitude steps according to the unit:
  - 500m for meters,
  - 1000ft for feet.
  • Loading branch information
vicb committed Apr 25, 2020
1 parent 1827dfb commit a06f999
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 9 deletions.
4 changes: 2 additions & 2 deletions airspaces/togeojson.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ function pushOpenAirAirspace(airspaces, name, category, floor, ceiling, coords)
name,
category,
bottom: floor,
bottom_m: Math.floor(openAirAltMeter(floor)),
bottom_km: (openAirAltMeter(floor) / 1000).toFixed(1),
top: ceiling,
polygon: [coords],
color: null,
Expand Down Expand Up @@ -180,7 +180,7 @@ function decodeAipAirspace(asp) {
name,
category: category,
bottom: formatAipAltLimit(asp.ALTLIMIT_BOTTOM),
bottom_m: Math.floor(aipAltMeter(asp.ALTLIMIT_BOTTOM) / 1000),
bottom_km: (aipAltMeter(asp.ALTLIMIT_BOTTOM) / 1000).toFixed(1),
top: formatAipAltLimit(asp.ALTLIMIT_TOP),
polygon: [coords],
color: null,
Expand Down
28 changes: 21 additions & 7 deletions frontend/src/viewer/components/airspace-element.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { AspAt, AspMapType, AspZoomMapType } from '../logic/airspaces';
import { CSSResult, LitElement, PropertyValues, TemplateResult, css, customElement, html, property } from 'lit-element';
import { RootState, store } from '../store';
import { UNITS, formatUnit } from '../logic/units';

import { connect } from 'pwa-helpers';
import { formatUnit } from '../logic/units';

@customElement('airspace-ctrl-element')
export class AirspaceCtrlElement extends connect(store)(LitElement) {
Expand Down Expand Up @@ -81,15 +81,29 @@ export class AirspaceCtrlElement extends connect(store)(LitElement) {
}

render(): TemplateResult {
const steps: TemplateResult[] = [];
if (this.units.altitude == UNITS.feet) {
for (let ft = 1000; ft <= 17000; ft += 1000) {
const m = ft / 3.28084;
steps.push(
html`
<option value=${m / 1000}>${formatUnit(m, this.units.altitude)}</option>
`,
);
}
} else {
for (let km = 0.5; km <= 6; km += 0.5) {
steps.push(
html`
<option value=${km}>${formatUnit(km * 1000, this.units.altitude)}</option>
`,
);
}
}
return html`
<link rel="stylesheet" href="https://kit-free.fontawesome.com/releases/latest/css/free.min.css" />
<select value=${this.altitude} @change=${this.handleChange} .hidden=${!this.expanded}>
<option value="1">${formatUnit(1000, this.units.altitude)}</option>
<option value="2">${formatUnit(2000, this.units.altitude)}</option>
<option value="3">${formatUnit(3000, this.units.altitude)}</option>
<option value="4">${formatUnit(4000, this.units.altitude)}</option>
<option value="5">${formatUnit(5000, this.units.altitude)}</option>
<option value="6">${formatUnit(6000, this.units.altitude)}</option>
${steps}
</select>
<i class="fas fa-fighter-jet fa-2x" style="cursor: pointer" @click=${this.toggleExpanded}></i>
`;
Expand Down

0 comments on commit a06f999

Please sign in to comment.