Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion package-lock.json

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

36 changes: 29 additions & 7 deletions style/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,11 @@ describe("isolated dangers", () => {
};
const point = (properties: Record<string, unknown>) => ({ type: 1, properties }) as never;
const highlighted = (properties: Record<string, unknown>) =>
featureFilter(layer.filter).filter({ zoom: 12 }, point(properties), undefined as never);
featureFilter(layer.filter, "layers.isolated-dangers.filter").filter(
{ zoom: 12 },
point(properties),
undefined as never,
);

it("rings a shoal hazard in navigable water", () => {
expect(highlighted({ type: "wreck", depth: 1.5, surrounding_depth: 15 })).toBe(true);
Expand All @@ -168,7 +172,11 @@ describe("isolated dangers", () => {
filter: never;
};
const ringed = (properties: Record<string, unknown>) =>
featureFilter(deep.filter).filter({ zoom: 12 }, point(properties), undefined as never);
featureFilter(deep.filter, "layers.isolated-dangers.filter").filter(
{ zoom: 12 },
point(properties),
undefined as never,
);
// a 35 m hazard is "shallow" at safety 40, but the tiles stop retaining hazards past 30 —
// highlighting it would promise coverage the data does not have
expect(ringed({ type: "rock", depth: 35, surrounding_depth: 50 })).toBe(false);
Expand All @@ -193,7 +201,11 @@ describe("thinning and decoration", () => {
const layer = (id: string) =>
chartLayers({ safety: 2 }).symbols.find((l) => l.id === id) as { filter: never };
const draws = (id: string, zoom: number, properties: Record<string, unknown>) =>
featureFilter(layer(id).filter).filter({ zoom }, point(properties), undefined as never);
featureFilter(layer(id).filter, `layers.${id}.filter`).filter(
{ zoom },
point(properties),
undefined as never,
);

const buoy = { type: "buoy_lateral", family: "minor_aid", topmark_shape: "cone" };
const turbine = { type: "landmark", family: "structure" };
Expand Down Expand Up @@ -298,7 +310,11 @@ describe("restricted access", () => {
const point = (properties: Record<string, string>) => ({ type: 1, properties }) as never;

const drawn = (id: string, properties: Record<string, string>) =>
featureFilter(layer(id).filter).filter({ zoom: 16 }, point(properties), undefined as never);
featureFilter(layer(id).filter, `layers.${id}.filter`).filter(
{ zoom: 16 },
point(properties),
undefined as never,
);

const slipway = { type: "small_craft_facility", category: "slipway" };

Expand All @@ -323,7 +339,10 @@ describe("restricted access", () => {
expect(drawn("harhours", { type: "small_craft_facility", category: "fishing" })).toBe(false);

for (const key of ["icon-opacity", "text-opacity"]) {
const compiled = createExpression(layer("harhours").paint[key]);
const compiled = createExpression(
layer("harhours").paint[key],
`layers.harhours.paint.${key}`,
);
if (compiled.result !== "success") throw new Error(`${key} failed to compile`);
const opacity = (access?: string) =>
compiled.value.evaluate({ zoom: 12 }, point(access ? { access } : {}));
Expand All @@ -337,7 +356,10 @@ describe("restricted access", () => {
describe("fuel dock labels", () => {
const layout = (all.find((l) => l.id === "small-craft-facilities") as { layout: never })
.layout as Record<string, unknown>;
const compiled = createExpression(layout["text-field"]);
const compiled = createExpression(
layout["text-field"],
"layers.small-craft-facilities.layout.text-field",
);
if (compiled.result !== "success") throw new Error("text-field failed to compile");
const label = (properties: Record<string, string>) =>
compiled.value
Expand Down Expand Up @@ -380,7 +402,7 @@ it("never scales an icon above the sheet's resolution", () => {
for (const layer of all) {
const size = (layer as { layout?: Record<string, unknown> }).layout?.["icon-size"];
if (size === undefined) continue;
const compiled = createExpression(size);
const compiled = createExpression(size, `layers.${layer.id}.layout.icon-size`);
if (compiled.result !== "success") throw new Error(`${layer.id}: icon-size failed to compile`);
for (let zoom = 0; zoom <= 22; zoom += 0.25) {
for (const properties of variants) {
Expand Down
2 changes: 1 addition & 1 deletion style/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"test": "vitest run"
},
"dependencies": {
"@maplibre/maplibre-gl-style-spec": "^25.0.0",
"@maplibre/maplibre-gl-style-spec": "^26.2.1",
"@openwaters/seascape": "^0.3.0",
"@versatiles/style": "^5.12.1"
},
Expand Down