Skip to content

Commit

Permalink
Performance data controls layline display (#149)
Browse files Browse the repository at this point in the history
  • Loading branch information
panaaj committed Jun 22, 2024
1 parent b052ba9 commit 72e9870
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 14 deletions.
4 changes: 2 additions & 2 deletions src/app/modules/map/fb-map.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -479,9 +479,9 @@
<fb-layline
[lines]="vesselLines.laylines"
[laylineStyles]="featureStyles.layline"
[heading]="app.data.vessels.self.heading"
[bearing]="app.data.navData.bearing.value"
[awa]="app.data.vessels.self.wind.awa"
[twd]="app.data.vessels.self.wind.twd"
[tackAngle]="app.data.vessels.self.performance.beatAngle"
[mapZoom]="fbMap.zoomLevel"
[zIndex]="212"
>
Expand Down
25 changes: 14 additions & 11 deletions src/app/modules/map/ol/lib/navigation/layer-layline.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ export class LaylineComponent implements OnInit, OnDestroy, OnChanges {
@Input() mapZoom = 10;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
@Input() laylineStyles: { [key: string]: any };
@Input() heading: number;
@Input() bearing: number;
@Input() awa: number;
@Input() bearing: number; // degrees
@Input() twd: number; // radians
@Input() tackAngle = Math.PI / 4; // radians (45 deg)
@Input() opacity: number;
@Input() visible: boolean;
@Input() extent: Extent;
Expand Down Expand Up @@ -88,9 +88,9 @@ export class LaylineComponent implements OnInit, OnDestroy, OnChanges {
for (const key in changes) {
if (
key === 'lines' ||
key === 'heading' ||
key === 'bearing' ||
key === 'awa'
key === 'twd' ||
key === 'tackAngle'
) {
this.parseValues();
if (this.source) {
Expand Down Expand Up @@ -121,19 +121,22 @@ export class LaylineComponent implements OnInit, OnDestroy, OnChanges {
parseValues() {
if (
typeof this.bearing !== 'number' ||
typeof this.heading !== 'number' ||
typeof this.awa !== 'number'
typeof this.twd !== 'number' ||
typeof this.tackAngle !== 'number'
) {
this.features = [];
return;
}

const fa: Feature[] = [];
let idx = 0;
// is destination upwind
const awd = Angle.add(this.heading, Convert.radiansToDegrees(this.awa));
if (Math.abs(Angle.difference(this.bearing, awd)) >= 90) {
this.features = [];

const tad = Convert.radiansToDegrees(this.tackAngle);
const wd = Convert.radiansToDegrees(this.twd);
const destUpwind = Math.abs(Angle.difference(this.bearing, wd)) < tad;

if (!destUpwind) {
this.features = fa;
return;
}

Expand Down
4 changes: 4 additions & 0 deletions src/app/modules/skresources/resource-classes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ export class SKVessel {
sog: number;
name: string;
mmsi: string;
type: { id: number; name: string } = { id: -1, name: '' };
callsign: string;
state: string;
wind = {
Expand Down Expand Up @@ -207,6 +208,9 @@ export class SKVessel {
nextPoint: {},
previousPoint: {}
};
performance = {
beatAngle: null
};
properties = {};
}

Expand Down
3 changes: 2 additions & 1 deletion src/app/modules/skstream/skstream.facade.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,8 @@ export class SKStreamFacade {
{ path: 'environment.wind.*', period: 1000, policy: 'fixed' },
{ path: 'environment.mode', period: 1000, policy: 'fixed' },
{ path: 'resources.*', period: 1000, policy: 'fixed' },
{ path: 'steering.autopilot.*', period: 1000, policy: 'fixed' }
{ path: 'steering.autopilot.*', period: 1000, policy: 'fixed' },
{ path: 'performance.*', period: 1000, policy: 'fixed' }
]
}
});
Expand Down
4 changes: 4 additions & 0 deletions src/app/modules/skstream/skstream.worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -766,8 +766,12 @@ function processVessel(d: SKVessel, v, isSelf = false) {
if (typeof v.value.buddy !== 'undefined') {
d.buddy = v.value.buddy;
}
} else if (v.path === 'performance.beatAngle') {
d.performance.beatAngle = v.value;
} else if (v.path === 'communication.callsignVhf') {
d.callsign = v.value;
} else if (v.path === 'design.aisShipType') {
d.type = v.value;
} else if (v.path === 'navigation.position' && v.value) {
// position is not null
if (
Expand Down

0 comments on commit 72e9870

Please sign in to comment.