Skip to content

Commit

Permalink
Merge pull request #1096 from ZeLonewolf/clay-shields-mx-mx-widen
Browse files Browse the repository at this point in the history
Replace shield icons for Mexican federal highways
  • Loading branch information
claysmalley authored Jun 22, 2024
2 parents df2a52b + 827e963 commit 5311561
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 16 deletions.
4 changes: 0 additions & 4 deletions icons/shield_mx_mx.svg

This file was deleted.

4 changes: 4 additions & 0 deletions icons/shield_mx_mx_2.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions icons/shield_mx_mx_3.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions icons/shield_mx_mx_4.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion shieldlib/src/shield.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { TextPlacement } from "./shield_text";
import { StyleImage } from "maplibre-gl";

const narrowCharacters = /[1IJijl .-]/g;
const maxRefLength = 7;

function compoundShieldSize(
r: ShieldRenderingContext,
Expand All @@ -30,7 +31,7 @@ function compoundShieldSize(
}

export function isValidRef(ref: string): boolean {
return ref !== null && ref.length !== 0 && ref.length <= 6;
return ref !== null && ref.length !== 0 && ref.length <= maxRefLength;
}

/**
Expand Down
11 changes: 6 additions & 5 deletions src/js/shield_defs.js
Original file line number Diff line number Diff line change
Expand Up @@ -538,12 +538,13 @@ export function loadShields() {

// Carreteras Federales
shields["MX:MX"] = {
spriteBlank: "shield_mx_mx",
spriteBlank: ["shield_mx_mx_2", "shield_mx_mx_3", "shield_mx_mx_4"],
textLayout: textConstraint("ellipse"),
padding: {
left: 2,
right: 2,
top: 3,
bottom: 2,
left: 1,
right: 1,
top: 5,
bottom: 4,
},
};
[
Expand Down
2 changes: 1 addition & 1 deletion src/shieldtest.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
<thead>
<tr>
<th>Network</th>
<th colspan="14">Graphic</th>
<th colspan="16">Graphic</th>
<th>Performance</th>
</tr>
</thead>
Expand Down
3 changes: 3 additions & 0 deletions src/shieldtest.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ let networks = [
"CA:PE",
"US:FL:Toll",
"CA:BC",
"MX:MX",
"IN:NH",
"PK:motorway",
"US:US",
Expand Down Expand Up @@ -260,6 +261,8 @@ let refs = [
"A 562",
"1138-2",
"A26/A7",
"GUA 10D",
"SS18var",
];

export function getShieldCanvas(network, ref, name) {
Expand Down
10 changes: 5 additions & 5 deletions test/spec/shield.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ const handler = shieldRenderer.getStyleImageMissingHandler();

handler({ id: "shield\nBAB\n5\n\n" });
handler({ id: "shield\nUS:RI\n\n\n" });
handler({ id: "shield\nUS:RI\nABC123\n\n" });
handler({ id: "shield\nUS:RI\nEquator\n\n" });
handler({ id: "shield\nUS:RI\nABC1234\n\n" });
handler({ id: "shield\nUS:RI\nLatitude\n\n" });
handler({ id: "shield\nrwn\n\n\n" });
handler({ id: "foo" });

Expand All @@ -51,9 +51,9 @@ describe("shield", function () {
expect(isBlankSprite("shield\nUS:RI\n\n\n")).to.be.true;
});
it("rejects a long ref", function () {
expect(mockRepo.hasSprite("shield\nUS:RI\nABC123\n\n")).to.be.true;
expect(isBlankSprite("shield\nUS:RI\nABC123\n\n")).to.be.false;
expect(isBlankSprite("shield\nUS:RI\nEquator\n\n")).to.be.true;
expect(mockRepo.hasSprite("shield\nUS:RI\nABC1234\n\n")).to.be.true;
expect(isBlankSprite("shield\nUS:RI\nABC1234\n\n")).to.be.false;
expect(isBlankSprite("shield\nUS:RI\nLatitude\n\n")).to.be.true;
});
});
});

0 comments on commit 5311561

Please sign in to comment.