Skip to content

Commit

Permalink
Merge branch 'main' into aaroads
Browse files Browse the repository at this point in the history
  • Loading branch information
1ec5 committed May 1, 2024
2 parents 2e3e746 + 5e76ca1 commit 4036ab5
Show file tree
Hide file tree
Showing 8 changed files with 139 additions and 48 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
name: Test Build (MacOS)
name: Test Build (MacOS 13)

on:
pull_request:
branches: [aaroads]

jobs:
build:
runs-on: macos-latest
runs-on: macos-13
steps:
- name: Checkout 🛎️
uses: actions/checkout@v3
Expand Down
5 changes: 5 additions & 0 deletions icons/shield40_us_nm_2.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions icons/shield40_us_nm_3.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
60 changes: 58 additions & 2 deletions scripts/stats.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as Style from "../src/js/style.js";
import config from "../src/config.js";
import { Command, Option } from "commander";
import fs from "node:fs";

const program = new Command();
program
Expand All @@ -18,9 +19,31 @@ program
.addOption(
new Option("-s, --layer-size", "size of all layers").conflicts("allJson")
)
.addOption(
new Option(
"-ss1, --spritesheet-1x-size",
"size of 1x sprite sheet"
).conflicts("allJson")
)
.addOption(
new Option(
"-ss2, --spritesheet-2x-size",
"size of 2x sprite sheet"
).conflicts("allJson")
)
.addOption(
new Option("-sh, --shield-json-size", "size of ShieldJSON").conflicts(
"allJson"
)
)
.option("-loc, --locales <locale1 locale2...>", "language codes", ["mul"])
.option("-j, --all-json", "output all stats in JSON")
.option("-pp, --pretty", "pretty-print JSON output");
.option("-pp, --pretty", "pretty-print JSON output")
.option(
"-d, --directory <dir>",
"specify location of Americana distribution",
["dist"]
);

program.parse(process.argv);

Expand All @@ -29,6 +52,7 @@ const opts = program.opts();
if (Object.keys(opts).length === 1) program.help();

const locales = opts.locales[0].split(",");
const distDir = opts.directory;

const style = Style.build(
config.OPENMAPTILES_URL,
Expand All @@ -45,8 +69,37 @@ if (opts.layerCount) {
process.exit();
}

const styleSize = JSON.stringify(layers).length;
function spriteSheetSize(distDir, single) {
let size = single ? "" : "@2x";
return (
fs.statSync(`${distDir}/sprites/sprite${size}.png`).size +
fs.statSync(`${distDir}/sprites/sprite${size}.json`).size
);
}

function distFileSize(distDir, path) {
return fs.statSync(`${distDir}/${path}`).size;
}

const spriteSheet1xSize = spriteSheetSize(distDir, true);
if (opts.spritesheet1xSize) {
console.log(spriteSheet1xSize);
process.exit();
}

const spriteSheet2xSize = spriteSheetSize(distDir, false);
if (opts.spritesheet2xSize) {
console.log(spriteSheet2xSize);
process.exit();
}

const shieldJSONSize = distFileSize(distDir, "shields.json");
if (opts.shieldJsonSize) {
console.log(shieldJSONSize);
process.exit();
}

const styleSize = JSON.stringify(layers).length;
if (opts.layerSize) {
console.log(styleSize);
process.exit();
Expand All @@ -58,6 +111,9 @@ const stats = {
layerCount,
styleSize,
layerGroup: {},
spriteSheet1xSize,
spriteSheet2xSize,
shieldJSONSize,
};

for (let i = 0; i < layerCount; i++) {
Expand Down
31 changes: 29 additions & 2 deletions scripts/stats_compare.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,40 @@ const layersRow = mdCompareRow(
);

const sizeRow = mdCompareRow(
"Size (b)",
"StyleJSON Size (b)",
stats1.styleSize,
stats2.styleSize,
difference.styleSize
);

printTable("Style size statistics", [layersRow, sizeRow]);
const shieldRow = mdCompareRow(
"ShieldJSON Size (b)",
stats1.shieldJSONSize,
stats2.shieldJSONSize,
difference.shieldJSONSize
);

const ss1xRow = mdCompareRow(
"1x Sprite Sheet Size (b)",
stats1.spriteSheet1xSize,
stats2.spriteSheet1xSize,
difference.spriteSheet1xSize
);

const ss2xRow = mdCompareRow(
"2x Sprite Sheet Size (b)",
stats1.spriteSheet2xSize,
stats2.spriteSheet2xSize,
difference.spriteSheet2xSize
);

printTable("Style size statistics", [
layersRow,
sizeRow,
ss1xRow,
ss2xRow,
shieldRow,
]);

/**
* Show comparison of the number of layers in each group before and after
Expand Down
74 changes: 36 additions & 38 deletions src/js/shield_defs.js
Original file line number Diff line number Diff line change
Expand Up @@ -775,11 +775,14 @@ export function loadShields() {
["BUS"],
Color.shields.green
);
shields["US:CA:CR"] = pentagonUpShield(
3,
15,
Color.shields.blue,
Color.shields.yellow
["CR", "Sierra"].forEach(
(county) =>
(shields[`US:CA:${county}`] = pentagonUpShield(
3,
15,
Color.shields.blue,
Color.shields.yellow
))
);
shields["US:CA:Mendocino"] = roundedRectShield(
Color.shields.green,
Expand Down Expand Up @@ -1141,8 +1144,8 @@ export function loadShields() {
"Webster",
"Winn",
].forEach(
(county) =>
(shields[`US:LA:${county}`] = pentagonUpShield(
(parish) =>
(shields[`US:LA:${parish}`] = pentagonUpShield(
3,
15,
Color.shields.blue,
Expand Down Expand Up @@ -1424,6 +1427,11 @@ export function loadShields() {

// Mississippi
shields["US:MS"] = ovalShield(Color.shields.white, Color.shields.black);
shields["US:MS:Scenic"] = banneredShield(
ovalShield(Color.shields.white, Color.shields.blue),
["SCEN"],
Color.shields.blue
);
[
"Alcorn",
"Calhoun",
Expand Down Expand Up @@ -1665,11 +1673,17 @@ export function loadShields() {
);

// New Mexico
shields["US:NM"] = pillShield(
Color.shields.white,
Color.shields.pink,
Color.shields.black
);
shields["US:NM"] = {
spriteBlank: ["shield40_us_nm_2", "shield40_us_nm_3"],
textColor: Color.shields.black,
textLayout: textConstraint("ellipse"),
padding: {
left: 5,
right: 5,
top: 5,
bottom: 5,
},
};
shields["US:NM:Frontage"] = {
spriteBlank: "shield_us_nm_frontage",
textColor: Color.shields.black,
Expand Down Expand Up @@ -2484,11 +2498,14 @@ export function loadShields() {
bottom: 5,
},
};
shields["US:UT:Wayne"] = pentagonUpShield(
3,
15,
Color.shields.blue,
Color.shields.yellow
["Wayne", "Washington"].forEach(
(county) =>
(shields[`US:UT:${county}`] = pentagonUpShield(
3,
15,
Color.shields.blue,
Color.shields.yellow
))
);

// Virginia
Expand Down Expand Up @@ -3728,23 +3745,13 @@ export function loadShields() {
};

shields["US:KY:Parkway"].refsByName = {
// FIXME: This object contains both spelled-out and abbreviated road
// names to accommodate both the abbreviated names from OpenMapTiles and
// the spelled-out names from Planetiler.
// https://github.com/onthegomap/planetiler/issues/14
"Audubon Parkway": "AU",
"Bluegrass Parkway": "BG",
"Bluegrass Pkwy": "BG",
"Cumberland Parkway": "LN",
"Cumberland Pkwy": "LN",
"Hal Rogers Parkway": "HR",
"Hal Rogers Pkwy": "HR",
"Mountain Parkway": "MP",
"Mountain Pkwy": "MP",
"Purchase Parkway": "JC",
"Purchase Pkwy": "JC",
"Western Kentucky Parkway": "WK",
"Western Kentucky Pkwy": "WK",
};

shields["US:CT:Parkway"].overrideByName = {
Expand Down Expand Up @@ -3784,15 +3791,13 @@ export function loadShields() {
};

shields["US:NY:Parkway"].refsByName = {
"Bear Mountain Parkway": "BMP",
"Bronx and Pelham Parkway": "PP",
"Bear Mountain State Parkway": "BMP",
"Bronx River Parkway": "BRP",
"Cross County Parkway": "CCP",
"Hutchinson River Parkway": "HRP",
"Korean War Veterans Parkway": "KWVP",
"Mosholu Parkway": "MP",
"Niagara Scenic Parkway": "NSP",
"Pelham Parkway": "PP",
"Saw Mill River Parkway": "SMP",
"Sprain Brook Parkway": "SBP",
"Taconic State Parkway": "TSP",
Expand All @@ -3812,14 +3817,7 @@ export function loadShields() {
"Fort Bend Westpark Tollway": "WPT",
};
shields["US:TX:Harris:HCTRA"].refsByName = {
"East Sam Houston Tollway North": "SHT",
"East Sam Houston Tollway South": "SHT",
"North Sam Houston Tollway East": "SHT",
"North Sam Houston Tollway West": "SHT",
"South Sam Houston Tollway East": "SHT",
"South Sam Houston Tollway West": "SHT",
"West Sam Houston Tollway North": "SHT",
"West Sam Houston Tollway South": "SHT",
"Sam Houston Tollway": "SHT",
"Fort Bend Toll Road": "FBTR",
"Hardy Toll Road": "HTR",
"Tomball Tollway": "TBT",
Expand Down
2 changes: 0 additions & 2 deletions src/layer/park.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ export const fill = {
"fill-color": Color.parkFill,
},
source: "openmaptiles",
minzoom: 5,
"source-layer": "park",
};

Expand All @@ -25,7 +24,6 @@ export const outline = {
"line-color": Color.parkOutline,
},
source: "openmaptiles",
minzoom: 5,
metadata: {},
"source-layer": "park",
};
Expand Down
6 changes: 4 additions & 2 deletions src/layer/poi.js
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ export const poi = {
"parking",
"police",
"school",
"college",
...getSubclasses(iconDefs.college),
"library",
"townhall",
...getSubclasses(iconDefs.post_office),
Expand All @@ -368,9 +368,11 @@ export const poi = {
[
"match",
["get", "subclass"],
[...getSubclasses(iconDefs.college)],
10,
["station", "halt"],
12,
["bus_station", "subway", ...getSubclasses(iconDefs.college)],
["bus_station", "subway"],
14,
[
"bus_stop",
Expand Down

0 comments on commit 4036ab5

Please sign in to comment.