Skip to content

Commit

Permalink
Add uniqueKey function
Browse files Browse the repository at this point in the history
useful when the react component is displaying the search to ensure
it redraws when required
  • Loading branch information
sparlane committed Dec 20, 2024
1 parent f39802c commit e761a53
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@canterbury-air-patrol/sar-search-patterns",
"version": "0.1.1",
"version": "0.1.2",
"description": "Draw SAR Search Patterns",
"main": "dist/index.js",
"module": "dist/index.mjs",
Expand Down
16 changes: 16 additions & 0 deletions sar-search-patterns.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ class SearchPattern {
nextLeg() {
this.currentLeg++
}

uniqueKey(): string {
return `${this.searchType}-${this.sweepWidth}-${this.searchLegs}-${this.currentLeg}`
}
}

function move(from: xy, direction: number, distance: number) {
Expand Down Expand Up @@ -114,6 +118,10 @@ class SectorSearch extends SearchPattern {
lastPoint = to
}
}

uniqueKey(): string {
return `${this.searchType}-${this.sweepWidth}-${this.searchLegs}-${this.currentLeg}-${this.startingDirection}-${this.multiplier}-${this.iterations}`
}
}

class ExpandingBoxSearch extends SearchPattern {
Expand All @@ -140,6 +148,10 @@ class ExpandingBoxSearch extends SearchPattern {
from = to
}
}

uniqueKey(): string {
return `${this.searchType}-${this.sweepWidth}-${this.searchLegs}-${this.currentLeg}-${this.startingDirection}-${this.iterations}`
}
}

class CreepingLineAheadSearch extends SearchPattern {
Expand Down Expand Up @@ -188,6 +200,10 @@ class CreepingLineAheadSearch extends SearchPattern {
this.searchLegs.push(new SearchLeg(from, to, distance, direction))
}
}

uniqueKey(): string {
return `${this.searchType}-${this.sweepWidth}-${this.searchLegs}-${this.currentLeg}-${this.legLength}-${this.legs}-${this.progressDirection}`
}
}

export { SearchPattern, SearchLeg, SectorSearch, ExpandingBoxSearch, CreepingLineAheadSearch }

0 comments on commit e761a53

Please sign in to comment.