Skip to content

Commit

Permalink
formatAspects: NW↷N↷E
Browse files Browse the repository at this point in the history
  • Loading branch information
simon04 committed Dec 19, 2024
1 parent 12e3e77 commit 5509716
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 2 deletions.
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@
"preview": "vite preview"
},
"devDependencies": {
"@types/lodash": "^4.17.13",
"typescript": "^5.7.2",
"vite": "^6.0.2"
},
"dependencies": {
"@eaws/outline_properties": "^7.0.5",
"lodash": "^4.17.21",
"ol": "^10.3.0",
"ol-ext": "^4.0.24",
"ol-pmtiles": "^1.0.2"
Expand Down
22 changes: 20 additions & 2 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import View from "ol/View";
import XYZ from "ol/source/XYZ";
import "ol/ol.css";
import "ol-ext/dist/ol-ext.css";
import { dropWhile, takeWhile } from "lodash";
import "./style.css";
import eawsOutlineProperties from "@eaws/outline_properties/index.json";

Expand Down Expand Up @@ -362,8 +363,25 @@ function formatBulletin(

const formatElevation = (e?: ElevationBoundaryOrBand) =>
`🏔 ${e?.lowerBound || 0}..${e?.upperBound || "∞"}`;
const formatAspects = (a?: Aspect[]) =>
Array.isArray(a) ? "🧭 " + a.join() : "";
const formatAspects = (aspects0?: Aspect[]) => {
if (!Array.isArray(aspects0) || !aspects0.length) return "";
let aspects: Aspect[] = ["N", "NE", "E", "SE", "S", "SW", "W", "NW"];
aspects = [...aspects, ...aspects];
aspects = dropWhile(aspects, (a) => aspects0.includes(a));
aspects = dropWhile(aspects, (a) => !aspects0.includes(a));
aspects = takeWhile(aspects, (a) => aspects0.includes(a));
if (aspects.length > 3) {
const main: Aspect[] = ["N", "S", "W", "E"];
aspects = [
aspects[0],
main.find((a) => aspects0.includes(a))!,
aspects[aspects.length - 1],
];
return "🧭 " + aspects.join("↷");
} else {
return "🧭 " + aspects.join(",");
}
};
result.appendChild(document.createElement("dd")).innerHTML =
region +
[bulletin.validTime?.startTime, bulletin.validTime?.endTime]
Expand Down
16 changes: 16 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,13 @@ __metadata:
languageName: node
linkType: hard

"@types/lodash@npm:^4.17.13":
version: 4.17.13
resolution: "@types/lodash@npm:4.17.13"
checksum: 10c0/c3d0b7efe7933ac0369b99f2f7bff9240d960680fdb74b41ed4bd1b3ca60cca1e31fe4046d9abbde778f941a41bc2a75eb629abf8659fa6c27b66efbbb0802a9
languageName: node
linkType: hard

"@types/rbush@npm:4.0.0":
version: 4.0.0
resolution: "@types/rbush@npm:4.0.0"
Expand Down Expand Up @@ -560,6 +567,8 @@ __metadata:
resolution: "eaws-bulletin-map@workspace:."
dependencies:
"@eaws/outline_properties": "npm:^7.0.5"
"@types/lodash": "npm:^4.17.13"
lodash: "npm:^4.17.21"
ol: "npm:^10.3.0"
ol-ext: "npm:^4.0.24"
ol-pmtiles: "npm:^1.0.2"
Expand Down Expand Up @@ -892,6 +901,13 @@ __metadata:
languageName: node
linkType: hard

"lodash@npm:^4.17.21":
version: 4.17.21
resolution: "lodash@npm:4.17.21"
checksum: 10c0/d8cbea072bb08655bb4c989da418994b073a608dffa608b09ac04b43a791b12aeae7cd7ad919aa4c925f33b48490b5cfe6c1f71d827956071dae2e7bb3a6b74c
languageName: node
linkType: hard

"lru-cache@npm:^10.0.1, lru-cache@npm:^9.1.1 || ^10.0.0":
version: 10.1.0
resolution: "lru-cache@npm:10.1.0"
Expand Down

0 comments on commit 5509716

Please sign in to comment.