Skip to content

Commit

Permalink
trawl: ignore hidden links
Browse files Browse the repository at this point in the history
can be used to trawl only a part of a draw
  • Loading branch information
le-jeu committed Apr 13, 2024
1 parent e536ceb commit f85eccf
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/code/dialogs/trawl.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import VLatLon from "geodesy/latlon-ellipsoidal-vincenty";
import { WasabeeMarker, WasabeeBlocker } from "../model";
import { displayInfo } from "../error";
import statics from "../static";
import { isFiltered } from "../filter";

const TrawlerDialog = WDialog.extend({
statics: {
Expand Down Expand Up @@ -290,6 +291,9 @@ const TrawlDialog = WDialog.extend({

const points = new Array();
for (const l of operation.links) {
// Ignore filtered out links
if (!isFiltered(l)) continue;

const lls = l.getLatLngs(operation);
const start = new VLatLon(lls[0].lat, lls[0].lng);
const end = new VLatLon(lls[1].lat, lls[1].lng);
Expand Down
8 changes: 7 additions & 1 deletion src/code/filter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export type Filter =

let currentFilter: Filter = null;

function computeFilter(task: Task, filter: Filter) {
function computeFilter(task: Task, filter: Filter): boolean {
if (filter.op === "and") {
return filter.list.every((f) => computeFilter(task, f));
} else if (filter.op === "or") {
Expand Down Expand Up @@ -90,6 +90,12 @@ function validateFilter(filter: Filter) {
}
}

/**
* Check if a task is filtered by the current filter
*
* @param task
* @returns `true` if the task must appears, `false` if the task is filtered and may be ignored
*/
export function isFiltered(task: Task) {
if (!currentFilter) return true;
return computeFilter(task, currentFilter);
Expand Down

0 comments on commit f85eccf

Please sign in to comment.