diff --git a/src/app/modules/map/components/popover/popover.component.ts b/src/app/modules/map/components/popover/popover.component.ts index 15174029..3ba977fe 100644 --- a/src/app/modules/map/components/popover/popover.component.ts +++ b/src/app/modules/map/components/popover/popover.component.ts @@ -9,8 +9,9 @@ import { ChangeDetectionStrategy } from '@angular/core'; import { AppInfo } from 'src/app/app.info'; -import { SKAtoN, SKAircraft } from 'src/app/modules'; +import { SKAircraft, SKMeteo } from 'src/app/modules'; import { SKNotification } from 'src/app/types'; +import { Convert } from 'src/app/lib/convert'; /*********** Popover *************** title: string - title text, @@ -234,6 +235,27 @@ aton: SKAtoN - aton data {{ timeLastUpdate }} {{ timeAgo }} + @if(isMeteo && aton.temperature !== undefined) { +
+
Temperature:
+
+ {{ this.app.formatValueForDisplay(aton.temperature, 'K') }} +
+
+ } @if(isMeteo && aton.tws !== undefined && aton.twd !== undefined) { +
+
Wind:
+
+ + +
+
+ }
 
@@ -253,7 +275,7 @@ aton: SKAtoN - aton data }) export class AtoNPopoverComponent { @Input() title: string; - @Input() aton: SKAtoN; + @Input() aton: SKMeteo; @Input() canClose: boolean; @Output() info: EventEmitter = new EventEmitter(); @Output() closed: EventEmitter = new EventEmitter(); @@ -261,12 +283,16 @@ export class AtoNPopoverComponent { _title: string; timeLastUpdate: string; timeAgo: string; // last update in minutes ago + protected convert = Convert; + isMeteo: boolean; constructor(public app: AppInfo) {} ngOnInit() { if (!this.aton) { this.handleClose(); + } else { + this.isMeteo = this.aton.id.includes('meteo'); } } diff --git a/src/app/modules/skresources/resource-classes.ts b/src/app/modules/skresources/resource-classes.ts index 2d906c85..8fe767d2 100644 --- a/src/app/modules/skresources/resource-classes.ts +++ b/src/app/modules/skresources/resource-classes.ts @@ -251,6 +251,9 @@ export class SKAircraft extends AISBase { // ** Meteo / weather class ** export class SKMeteo extends SKAtoN { callsign: string; + twd: number; + tws: number; + temperature: number; constructor() { super(); } diff --git a/src/app/modules/skresources/resource-dialogs.ts b/src/app/modules/skresources/resource-dialogs.ts index badf8a9f..70ad019d 100644 --- a/src/app/modules/skresources/resource-dialogs.ts +++ b/src/app/modules/skresources/resource-dialogs.ts @@ -22,6 +22,7 @@ import { SKRoute } from './resource-classes'; import { SKResourceSet } from './sets/resource-set'; +import { GeoUtils } from 'src/app/lib/geoutils'; /********* ResourceDialog ********** data: { @@ -793,33 +794,55 @@ export class AircraftPropertiesModal {
-
Lat:
+
Name:
+ + @if(pointMeta[i].description) {
-
Lon:
+
Desc:
- @if(i < pointNames.length) { + } + +
+
+ square_foot +
+
+ +   + +
+
+
@if(data.type === 'route') { @@ -863,11 +886,12 @@ export class AircraftPropertiesModal { ] }) export class ActiveResourcePropertiesModal implements OnInit { - public points: Array = []; - public pointNames: Array = []; - public selIndex = -1; - public clearButtonText = 'Clear'; - public showClearButton = false; + protected points: Array = []; + protected pointMeta: Array<{ name: string; description: string }> = []; + protected legs: { bearing: string; distance: string }[] = []; + protected selIndex = -1; + protected clearButtonText = 'Clear'; + protected showClearButton = false; constructor( public app: AppInfo, @@ -891,6 +915,7 @@ export class ActiveResourcePropertiesModal implements OnInit { this.points = [].concat( this.data.resource[1].feature.geometry.coordinates ); + this.legs = this.getLegs(); this.data.title = this.data.resource[1].name ? `${this.data.resource[1].name} Points` @@ -900,35 +925,61 @@ export class ActiveResourcePropertiesModal implements OnInit { this.selIndex = this.app.data.navData.pointIndex; this.showClearButton = true; } - if ( - this.data.resource[1].feature.properties.coordinatesMeta && - Array.isArray( - this.data.resource[1].feature.properties.coordinatesMeta - ) - ) { - this.pointNames = this.getPointNames( - this.data.resource[1].feature.properties.coordinatesMeta - ); - } + this.pointMeta = this.getPointMeta(); } } } - // eslint-disable-next-line @typescript-eslint/no-explicit-any - getPointNames(pointsMeta: any[]): string[] { - return pointsMeta.map((pt) => { - if (pt.href) { - const id = pt.href.split('/').slice(-1); - const wpt = this.app.data.waypoints.filter((i) => { - return i[0] === id[0] ? true : false; - }); - return wpt.length !== 0 ? `* ${wpt[0][1].name}` : '!wpt reference!'; - } else { - return pt.name ?? ''; - } + getLegs() { + const pos = this.app.data.vessels.self.position; + return GeoUtils.routeLegs(this.points, pos).map((l) => { + return { + bearing: this.app.formatValueForDisplay(l.bearing, 'deg'), + distance: this.app.formatValueForDisplay(l.distance, 'm') + }; }); } + getPointMeta() { + if ( + this.data.resource[1].feature.properties.coordinatesMeta && + Array.isArray(this.data.resource[1].feature.properties.coordinatesMeta) + ) { + const pointsMeta = + this.data.resource[1].feature.properties.coordinatesMeta; + let idx = 0; + return pointsMeta.map((pt) => { + idx++; + if (pt.href) { + const id = pt.href.split('/').slice(-1); + const wpt = this.data.skres.fromCache('waypoints', id[0]); + return wpt + ? { + name: `* ${wpt[1].name}`, + description: `* ${wpt[1].description}` + } + : { + name: '!wpt reference!', + description: '' + }; + } else { + return { + name: pt.name ?? `RtePt-${('000' + String(idx)).slice(-3)}`, + description: pt.description ?? `` + }; + } + }); + } else { + let idx = 0; + return this.points.map(() => { + return { + name: `RtePt-${('000' + String(++idx)).slice(-3)}`, + description: '' + }; + }); + } + } + selectPoint(idx: number) { if (this.points.length < 2 || this.selIndex < 0) { return; @@ -943,19 +994,16 @@ export class ActiveResourcePropertiesModal implements OnInit { if (this.data.type === 'route') { const selPosition = this.points[this.selIndex]; moveItemInArray(this.points, e.previousIndex, e.currentIndex); - if ( - this.data.type === 'route' && - this.data.resource[1].feature.properties.coordinatesMeta - ) { + this.legs = this.getLegs(); + if (this.data.resource[1].feature.properties.coordinatesMeta) { moveItemInArray( this.data.resource[1].feature.properties.coordinatesMeta, e.previousIndex, e.currentIndex ); - this.pointNames = this.getPointNames( - this.data.resource[1].feature.properties.coordinatesMeta - ); } + this.pointMeta = this.getPointMeta(); + this.updateFlag(selPosition); this.data.skres.updateRouteCoords( this.data.resource[0],