Skip to content

Commit

Permalink
Laylines being shown when vessel is upwind (#149).
Browse files Browse the repository at this point in the history
  • Loading branch information
panaaj committed Jun 14, 2024
1 parent 7e2956e commit 13fa163
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/app/modules/map/ol/lib/navigation/layer-layline.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { Extent, Coordinate } from '../models';
import { fromLonLatArray, mapifyCoords } from '../util';
import { AsyncSubject } from 'rxjs';
import { Convert } from 'src/app/lib/convert';
import { Angle } from 'src/app/lib/geoutils';

// ** Freeboard Layline component **
@Component({
Expand All @@ -43,6 +44,7 @@ export class LaylineComponent implements OnInit, OnDestroy, OnChanges {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
@Input() laylineStyles: { [key: string]: any };
@Input() heading: number;
@Input() bearing: number;
@Input() awa: number;
@Input() opacity: number;
@Input() visible: boolean;
Expand Down Expand Up @@ -117,17 +119,24 @@ export class LaylineComponent implements OnInit, OnDestroy, OnChanges {
}

parseValues() {
const fa: Feature[] = [];
let idx = 0;
// is upwind
if (
typeof this.bearing !== 'number' ||
typeof this.heading !== 'number' ||
Math.abs(Convert.radiansToDegrees(this.awa)) >= 90
typeof this.awa !== '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 = [];
return;
}

if (this.lines) {
if (this.lines.port && Array.isArray(this.lines.port)) {
this.lines.port.forEach((l: Coordinate[]) => {
Expand Down

0 comments on commit 13fa163

Please sign in to comment.