diff --git a/LICENSES/LicenseRef-APRS-Symbols.txt b/LICENSES/LicenseRef-APRS-Symbols.txt new file mode 100644 index 00000000..11bd5141 --- /dev/null +++ b/LICENSES/LicenseRef-APRS-Symbols.txt @@ -0,0 +1,434 @@ +APRS symbol set (https://github.com/hessu/aprs-symbols) +========================================================= + +Verbatim copy of the upstream COPYRIGHT.md, retrieved 2026-08-03 from +https://github.com/hessu/aprs-symbols. The set has no single SPDX license: +individual symbols carry different terms, summarized below. Attribution +requirement from the upstream README: "If you use this symbol set, please +provide a pointer to the source (http://github.com/hessu/aprs-symbols/)." + +--- + + +Copyright and licensing information +====================================== + +This is a collection of vectorized symbols for use on the APRS system. + +The copyright status of this collection is a bit complicated, since the +symbols come from various sources, each having different copyright owners. + +Most of the vectorized symbols are loosely based on the low-resolution +"standard" bitmap symbol set as distributed by Stephen Smith, WA8LMF. That +set is used by most APRS software around the world. The low resolution of +those symbols does not allow direct vector conversion, so I've drawn new +symbols in a similar layout. The vector versions try to mimic the original +appearance and colours, with the intention of keeping the set recognizable +and familiar to existing users. In some cases the vector versions are +probably similar enough to the originals, so that they cannot be considered +"original work" by myself. In some of these cases, the originals are +probably also mimicking someone else's design. + +The original symbols do not come with any information on their licensing. +They've been distributed with a lot of APRS software over time, but I don't +know who designed which symbol originally. Most likely all of them are +drawn by one of: + + * Roger Barker, G4IDE, "original set provided with UI-View" (SK) + * Steve Dimse, KH4G, "U.S. customary set" + * Stephen Smith, WA8LMF + +The Adobe Illustrator (.ai) file contains a copy of the original bitmaps +as a hidden layer, just for reference. + +Some symbols I obtained from other sources, such as Wikipedia. In those +cases I picked SVG versions which allow commercial reuse (source known, and +the work is placed on public domain, or with a CC license which allows +adaptation and commercial reuse). + +Some symbols are vectorized versions of product or brand logos. The +copyright of those is owned by the respective companies (Apple, Microsoft, +Kenwood), and each of those may have some opinions on how the logos are +used. Please check for yourself if you can use them or not. + +In the list below I try to summarize the licensing status for each symbol. + + +Shorthand notation for common licensing status +------------------------------------------------- + +* *VEC-OH7LZB* - Vectorized by OH7LZB, based on original APRS symbol set + * Source of original bitmap: http://wa8lmf.net/aprs/APRS_symbols.htm + * Original designer of individual symbol unknown at this time, but one of: + * Roger Barker, G4IDE + * Steve Dimse, KH4G + * Stephen Smith, WA8LMF + * Vectorized versions are designed to look similar + * Licensing: Unknown +* *OH7LZB* - Original vector design by Heikki Hannikainen, OH7LZB + * Different enough (by author's opinion) to make it a new original work, + instead of a copy of the old symbol + * License: CC BY-SA 2.0 + * https://creativecommons.org/licenses/by-sa/2.0/ + + +Primary table +---------------- + +* /! - Police station + * VEC-OH7LZB +* /# - Digipeater / Green star with D in middle + * VEC-OH7LZB +* /$ - Telephone + * VEC-OH7LZB +* /% - DX cluster + * VEC-OH7LZB +* /& - HF gateway + * VEC-OH7LZB +* /' - Small aircraft + * https://openclipart.org/detail/27182/topdown-airplane-view + * Author: Wirelizard (Brian Burger) + * With color and some other small tuning added by OH7LZB + * PD: https://openclipart.org/share +* /( - Mobile satellite station + * OH7LZB +* /) - Wheelchair, handicapped + * PD wheelchair symbol + * Vectorized from bitmap by OH7LZB +* /* - Snowmobile + * https://openclipart.org/detail/15849/snowmobile + * Author: Mystica (https://openclipart.org/user-detail/mystica) + * PD: https://openclipart.org/share +* /+ - Red Cross + * VEC-OH7LZB +* /, - Boy Scouts + * VEC-OH7LZB +* /- - House + * VEC-OH7LZB +* /. - Red X + * VEC-OH7LZB +* // - Red dot + * VEC-OH7LZB +* /0 to /9 - Numbered circles + * VEC-OH7LZB +* Fire + * http://commons.wikimedia.org/wiki/File:FireIcon.svg + * Author: Piotr Jaworski + * PD: I, the copyright holder of this work, release this work into the public domain. This applies worldwide. +* Tent + * https://openclipart.org/detail/174933/green-tent-by-stamps-174933 + * Author: stamps + * PD: https://openclipart.org/share +* Motorcycle + * http://commons.wikimedia.org/wiki/File:MUTCD_W8-15P.svg + * This file is in the public domain because it comes from the Manual on + Uniform Traffic Control Devices, sign number W8-15P, which states + specifically on page I-1 that: Any traffic control device design or + application provision contained in this Manual shall be considered to + be in the public domain. Traffic control devices contained in this + Manual shall not be protected by a patent, trademark, or copyright, + except for the Interstate Shield and any other items owned by FHWA. + * Colour version by OH7LZB +* /= - Railroad engine + * http://commons.wikimedia.org/wiki/File:Icon_train.svg + * Author: http://en.wikipedia.org/wiki/User:Richtom80 + * CC-BY-SA-2.5,2.0,1.0 +* /> - Car + * OH7LZB +* /? - File server + * https://openclipart.org/detail/163717/file-server-by-lyte + * Author: lyte + * PD: https://openclipart.org/share +* /@ - Hurricane predicted path + * VEC-OH7LZB +* /A - Aid station + * VEC-OH7LZB +* Mail (BBS) + * https://openclipart.org/detail/29268/yellow-mail-by-rg1024-29268 + * Author: rg1024 + * PD: https://openclipart.org/share +* /C - Canoe + * https://openclipart.org/detail/179047/red-canoe-by-rambo-tribble-179047 + * https://openclipart.org/detail/179041/canoe-paddle-by-rambo-tribble-179041 + * Author: Rambo Tribble + * PD: I, the copyright holder of this work, release this work into the public domain. This applies worldwide. +* /E - Eyeball + * http://commons.wikimedia.org/wiki/File:Blue_eye.svg + * PD: "This file is from the Open Clip Art Library, which released it explicitly into the public domain" + * PD: https://openclipart.org/share +* /F - Tractor + * https://openclipart.org/detail/191654/farm-tractor-by-tmjbeary-191654 + * Author: tmjbeary + * PD: https://openclipart.org/share +* /G - Grid square, 3 by 3 + * VEC-OH7LZB +* /H - Hotel + * VEC-OH7LZB +* /I - TCP/IP + * VEC-OH7LZB +* /K - School + * OH7LZB +* /L - PC user + * OH7LZB +* /M - Mac apple + * Apple +* /N - NTS + * VEC-OH7LZB +* /O - Hot air balloon + * OH7LZB +* /P - Police + * OH7LZB +* /R - RV + * OH7LZB +* /S - Space Shuttle + * https://openclipart.org/detail/814/space-shuttle-by-johnny_automatic + * PD: Published by the NASA, in "The Brain in Space" +* /T - SSTV + * https://openclipart.org/detail/48997/flat-screen-by-rg1024 + * Author: rg1024 + * Adjusted by OH7LZB + * PD: https://openclipart.org/share +* /U - Bus + * OH7LZB +* /V - ATV, amateur television + * https://openclipart.org/detail/48997/flat-screen-by-rg1024 + * Author: rg1024 + * Adjusted by OH7LZB + * PD: https://openclipart.org/share +* /W - Wx, Weather service site + * VEC-OH7LZB +* /X - Helicopter + * OH7LZB +* /Y - Sailboat + * OH7LZB +* /Z - Windows flag + * Microsoft +* /[ - Human + * VEC-OH7LZB +* /\ - DF triangle + * VEC-OH7LZB +* /] - Mailbox, post office, letter +* /^ - Large aircraft + * https://openclipart.org/detail/183204/plane-red-by-sketchartist-183204 + * Author: SketchArtist + * PD: https://openclipart.org/share +* /_ - Weather station + * VEC-OH7LZB +* /` - Satellite dish + * OH7LZB +* /a - Ambulance + * OH7LZB +* /b - Bicycle + * http://commons.wikimedia.org/wiki/File:Bicycle_evolution-numbers.svg + * Author: Wikipedia user: Al2 + * CC BY 3.0 +* /c - Incident command post + * VEC-OH7LZB +* /d - Fire station + * VEC-OH7LZB +* /e - Horse, equestrian + * https://openclipart.org/detail/142627/horse-riding-lesson-by-olku + * Author: OlKu + * PD: https://openclipart.org/share +* /f - Fire truck + * OH7LZB +* /g - Hang glider + * OH7LZB +* /h - Hospital + * VEC-OH7LZB +* /i - IOTA, islands on the air + * http://commons.wikimedia.org/wiki/File:Palm_Island_R.svg + * PI +* /j - Jeep + * OH7LZB +* /k - Truck + * OH7LZB +* /l - Laptop + * OH7LZB +* /m - Mic-E repeater + * VEC-OH7LZB +* /n - Node, black bulls-eye + * VEC-OH7LZB +* /o - Emergency operations center + * VEC-OH7LZB +* /p - Dog(e) + * OH7LZB +* /q - Grid square, 2 by 2 + * VEC-OH7LZB +* /r - Repeater tower + * OH7LZB +* /s - Ship, power boat + * OH7LZB +* /t - Truck stop + * VEC-OH7LZB +* /u - Semi-trailer truck, 18-wheeler + * OH7LZB +* /v - Van + * OH7LZB +* /w - Water station + * VEC-OH7LZB +* /x - X / Unix + * https://commons.wikimedia.org/wiki/File:X11.svg + * PD +* /y - House, yagi antenna + * VEC-OH7LZB +* /z - Shelter + * VEC-OH7LZB + + +Secondary table +------------------ + +* Emergency + * VEC-OH7LZB +* Numbered digipeater / Green star + * VEC-OH7LZB +* Bank + * VEC-OH7LZB +* Numbered gateway / Black diamond + * VEC-OH7LZB +* Crash site + * OH7LZB +* Cloudy + * OH7LZB +* MEO + * VEC-OH7LZB +* Snowflake + * http://commons.wikimedia.org/wiki/File:Snowflake_01.svg + * Author: Wikipedia user: Amada44 + * Public Domain +* Church + * VEC-OH7LZB +* Girl Scout + * VEC-OH7LZB + * Looks slightly like the common USA girl scouts logos. Should be different + enough to not infringe on "Girl Scouts of the USA" copyrights. +* Home (HF antenna) + * VEC-OH7LZB +* Unknown position + * VEC-OH7LZB +* Destination + * VEC-OH7LZB +* Numbered circle + * VEC-OH7LZB + +* Petrol Station + * OH7LZB +* Hail + * VEC-OH7LZB +* Park + * VEC-OH7LZB +* Gale Flag + * VEC-OH7LZB +* Red car from above + * OH7LZB +* Info Kiosk + * VEC-OH7LZB +* Hurricane + * OH7LZB + +* Numbered white box + * VEC-OH7LZB +* Snow blowing + * VEC-OH7LZB +* Coast Guard + * VEC-OH7LZB +* Drizzle + * VEC-OH7LZB +* Smoke / Chimney + * VEC-OH7LZB +* Freezing rain + * VEC-OH7LZB +* Snow Shwr + * VEC-OH7LZB +* Haze + * VEC-OH7LZB +* Rain Shower + * VEC-OH7LZB +* Lightning + * OH7LZB +* "Kenwood radio" + * Kenwood logo, vectorized +* "Lighthouse" + * CC BY-SA 2.0 + * http://wiki.openstreetmap.org/wiki/File:Lighthouse.svg +* Nav Buoy + * OH7LZB +* Rocket + * http://www.clker.com/clipart-gglkuglug.html + * PD according to clker.com license +* Parking + * VEC-OH7LZB + +* Earthquake, Restaurant + * VEC-OH7LZB +* Satellite + * OH7LZB +* Thunderstorm + * OH7LZB +* Sunny + * OH7LZB +* VORTAC, Numbered WXS + * VEC-OH7LZB +* Pharmacy Rx + * OH7LZB +* Wall Cloud + * OH7LZB +* Numbered plane + * https://openclipart.org/detail/183204/plane-red-by-sketchartist-183204 + * Author: SketchArtist + * PD: https://openclipart.org/share +* Numbered WX Station + * VEC-OH7LZB +* Rain + * Source: http://commons.wikimedia.org/wiki/File:Heavy-rain-shower-transparent.svg + * Author: Wikipedia user: Peepo + * Public Domain + * With modifications by OH7LZB + +* Numbered diamond + * VEC-OH7LZB +* Dust blowing + * NA +* Numbered civil defence + * VEC-OH7LZB +* DX spot + * VEC-OH7LZB +* Sleet + * NA +* Funnel Cloud + * NA +* Gale + * VEC-OH7LZB +* Store + * https://openclipart.org/detail/89299/cart-medium-by-martins.bruvelis + * Author: martins.bruvelis + * Public Domain + * Adjustments by OH7LZB +* Numbered black box + * VEC-OH7LZB +* Work zone / Excavator + * Based on http://www.clker.com/clipart-292480.html PNG version + * Vectorized and colors adjusted by OH7LZB + * PD according to clker.com documentation, uploader KURSVEIAL +* SUV + * OH7LZB +* Milepost, Numbered triangle, Circle sm + * VEC-OH7LZB +* Partly cloudy + * OH7LZB + +* Restrooms, Numbered boat + * VEC-OH7LZB +* Tornado (also used in Funnel cloud, Skywarn) + * https://openclipart.org/detail/104887/tornado-by-laabadon + * Author: Laabadon + * Public Domain +* Numbered truck + * OH7LZB +* Numbered van + * OH7LZB +* Flooding + * NA +* Sky warn, Numbered shelter, fog + * VEC-OH7LZB diff --git a/README.md b/README.md index 6dc4ad33..6597a294 100644 --- a/README.md +++ b/README.md @@ -144,4 +144,7 @@ a unified set of frontends. GPL-2.0-or-later. See [`LICENSES`](LICENSES) for the full license text and bundled third-party license files. Bundled third-party components retain their original licenses: Leaflet is BSD-2-Clause, DSEG is OFL-1.1, and opus-decoder -is MIT. +is MIT. The APRS symbol sprites come from +[hessu/aprs-symbols](https://github.com/hessu/aprs-symbols); their per-symbol +copyright status is catalogued in +[`LICENSES/LicenseRef-APRS-Symbols.txt`](LICENSES/LicenseRef-APRS-Symbols.txt). diff --git a/REUSE.toml b/REUSE.toml index e39535e3..8fd91159 100644 --- a/REUSE.toml +++ b/REUSE.toml @@ -56,3 +56,19 @@ SPDX-License-Identifier = "OFL-1.1" path = ["src/trx-client/trx-frontend/trx-frontend-http/assets/web/vendor/opus-decoder-0.7.11.min.js"] SPDX-FileCopyrightText = "2021-2025 Ethan Halsall" SPDX-License-Identifier = "MIT" + +# Vendored APRS symbol sprites (https://github.com/hessu/aprs-symbols), rev H. +# The set has no single upstream license -- individual symbols carry different +# terms, catalogued in LICENSES/LicenseRef-APRS-Symbols.txt. Upstream asks that +# users point back to https://github.com/hessu/aprs-symbols/. +[[annotations]] +path = [ + "src/trx-client/trx-frontend/trx-frontend-http/assets/web/vendor/aprs-symbols-24-0.png", + "src/trx-client/trx-frontend/trx-frontend-http/assets/web/vendor/aprs-symbols-24-1.png", + "src/trx-client/trx-frontend/trx-frontend-http/assets/web/vendor/aprs-symbols-24-2.png", + "src/trx-client/trx-frontend/trx-frontend-http/assets/web/vendor/aprs-symbols-24-0-2x.png", + "src/trx-client/trx-frontend/trx-frontend-http/assets/web/vendor/aprs-symbols-24-1-2x.png", + "src/trx-client/trx-frontend/trx-frontend-http/assets/web/vendor/aprs-symbols-24-2-2x.png", +] +SPDX-FileCopyrightText = "Heikki Hannikainen OH7LZB and the APRS symbol set authors (https://github.com/hessu/aprs-symbols)" +SPDX-License-Identifier = "LicenseRef-APRS-Symbols" diff --git a/src/trx-client/trx-frontend/trx-frontend-http/assets/web/generated/aprs.js b/src/trx-client/trx-frontend/trx-frontend-http/assets/web/generated/aprs.js index a0ccd2a7..fd3f223e 100644 --- a/src/trx-client/trx-frontend/trx-frontend-http/assets/web/generated/aprs.js +++ b/src/trx-client/trx-frontend/trx-frontend-http/assets/web/generated/aprs.js @@ -7,7 +7,7 @@ import { normalizeAprsPacket, renderAprsInfo, renderLocalAprsSymbol -} from "./chunk-M2I6DH4X.js"; +} from "./chunk-ROTCLFXS.js"; import { hostCore, hostState diff --git a/src/trx-client/trx-frontend/trx-frontend-http/assets/web/generated/chunk-M2I6DH4X.js b/src/trx-client/trx-frontend/trx-frontend-http/assets/web/generated/chunk-ROTCLFXS.js similarity index 68% rename from src/trx-client/trx-frontend/trx-frontend-http/assets/web/generated/chunk-M2I6DH4X.js rename to src/trx-client/trx-frontend/trx-frontend-http/assets/web/generated/chunk-ROTCLFXS.js index 1d386a5f..30e308a1 100644 --- a/src/trx-client/trx-frontend/trx-frontend-http/assets/web/generated/chunk-M2I6DH4X.js +++ b/src/trx-client/trx-frontend/trx-frontend-http/assets/web/generated/chunk-ROTCLFXS.js @@ -75,8 +75,51 @@ function escapeAprsCharacter(character) { if (character === '"') return """; return character; } +var APRS_SPRITE_COLUMNS = 16; +var APRS_SPRITE_CELL_PX = 24; +var APRS_SPRITE_FIRST_CODE = 33; +var APRS_SPRITE_LAST_CODE = 126; +function aprsSpriteOffset(code) { + if (code.length !== 1) return null; + const point = code.charCodeAt(0); + if (point < APRS_SPRITE_FIRST_CODE || point > APRS_SPRITE_LAST_CODE) return null; + const index = point - APRS_SPRITE_FIRST_CODE; + const column = index % APRS_SPRITE_COLUMNS; + const row = Math.floor(index / APRS_SPRITE_COLUMNS); + return `${String(-column * APRS_SPRITE_CELL_PX)}px ${String(-row * APRS_SPRITE_CELL_PX)}px`; +} +function aprsSymbolSprite(symbolTable, symbolCode) { + if (!symbolTable || !symbolCode) return null; + const symbolOffset = aprsSpriteOffset(symbolCode); + if (!symbolOffset) return null; + if (symbolTable === "/") { + return { + className: "aprs-symbol-primary", + backgroundPosition: symbolOffset, + label: `Primary APRS symbol ${symbolTable}${symbolCode}` + }; + } + if (symbolTable === "\\") { + return { + className: "aprs-symbol-alternate", + backgroundPosition: symbolOffset, + label: `Alternate APRS symbol ${symbolTable}${symbolCode}` + }; + } + const overlayOffset = aprsSpriteOffset(symbolTable); + if (!overlayOffset) return null; + return { + className: "aprs-symbol-overlaid", + backgroundPosition: `${overlayOffset}, ${symbolOffset}`, + label: `Alternate APRS symbol \\${symbolCode} with overlay ${symbolTable}` + }; +} function renderLocalAprsSymbol(packet, escapeHtml) { if (!packet.symbolTable || !packet.symbolCode) return ""; + const sprite = aprsSymbolSprite(packet.symbolTable, packet.symbolCode); + if (sprite) { + return ``; + } const symbol = escapeHtml(packet.symbolCode); const table = packet.symbolTable === "/" ? "Primary" : "Alternate"; return `${symbol}`; @@ -107,6 +150,7 @@ export { collapseAprsDuplicates, aprsHexBytes, renderAprsInfo, + aprsSymbolSprite, renderLocalAprsSymbol, normalizeAprsPacket }; diff --git a/src/trx-client/trx-frontend/trx-frontend-http/assets/web/generated/hf-aprs.js b/src/trx-client/trx-frontend/trx-frontend-http/assets/web/generated/hf-aprs.js index 6b6d80a7..dc6edd25 100644 --- a/src/trx-client/trx-frontend/trx-frontend-http/assets/web/generated/hf-aprs.js +++ b/src/trx-client/trx-frontend/trx-frontend-http/assets/web/generated/hf-aprs.js @@ -7,7 +7,7 @@ import { normalizeAprsPacket, renderAprsInfo, renderLocalAprsSymbol -} from "./chunk-M2I6DH4X.js"; +} from "./chunk-ROTCLFXS.js"; import { hostCore, hostState diff --git a/src/trx-client/trx-frontend/trx-frontend-http/assets/web/generated/map-core.js b/src/trx-client/trx-frontend/trx-frontend-http/assets/web/generated/map-core.js index 5cff0e48..a8755ecb 100644 --- a/src/trx-client/trx-frontend/trx-frontend-http/assets/web/generated/map-core.js +++ b/src/trx-client/trx-frontend/trx-frontend-http/assets/web/generated/map-core.js @@ -1,3 +1,7 @@ +import { + aprsSymbolSprite +} from "./chunk-ROTCLFXS.js"; + // src/map-core.ts function mapEl(id) { const element = document.querySelector(`#${CSS.escape(id)}`); @@ -1660,10 +1664,11 @@ var mapWindow = window; } function aprsSymbolIcon(symbolTable, symbolCode) { if (!symbolTable || !symbolCode) return null; - const table = symbolTable === "/" ? "primary" : "alternate"; + const sprite = aprsSymbolSprite(symbolTable, symbolCode); + const html = sprite ? `` : `
${escapeMapHtml(symbolCode)}
`; return L.divIcon({ className: "", - html: `
${escapeMapHtml(symbolCode)}
`, + html, iconSize: [24, 24], iconAnchor: [12, 12], popupAnchor: [0, -12] diff --git a/src/trx-client/trx-frontend/trx-frontend-http/assets/web/style.css b/src/trx-client/trx-frontend/trx-frontend-http/assets/web/style.css index 960987fa..3d38895c 100644 --- a/src/trx-client/trx-frontend/trx-frontend-http/assets/web/style.css +++ b/src/trx-client/trx-frontend/trx-frontend-http/assets/web/style.css @@ -2533,7 +2533,21 @@ body.map-fake-fullscreen-active { font-size: 0.75rem; word-break: break-all; } -.aprs-symbol { display: inline-block; width: 24px; height: 24px; background-size: 384px 192px; vertical-align: middle; margin-right: 0.3rem; } +/* APRS symbols are drawn from the vendored hessu/aprs-symbols sprite sheets: + 16x6 grids of 24px cells, indexed by `symbol code - 0x21`. The cell offset + is set inline by the APRS/map bundles; the sheet URL stays here so retina + displays can swap in the @2x variants. */ +.aprs-symbol { display: inline-block; width: 24px; height: 24px; background-repeat: no-repeat; background-size: 384px 144px; vertical-align: middle; margin-right: 0.3rem; } +.aprs-symbol-marker { margin-right: 0; } +.aprs-symbol-primary { background-image: url('/vendor/aprs-symbols-24-0.png'); } +.aprs-symbol-alternate { background-image: url('/vendor/aprs-symbols-24-1.png'); } +.aprs-symbol-overlaid { background-image: url('/vendor/aprs-symbols-24-2.png'), url('/vendor/aprs-symbols-24-1.png'); } +@media (min-resolution: 2dppx) { + .aprs-symbol-primary { background-image: url('/vendor/aprs-symbols-24-0-2x.png'); } + .aprs-symbol-alternate { background-image: url('/vendor/aprs-symbols-24-1-2x.png'); } + .aprs-symbol-overlaid { background-image: url('/vendor/aprs-symbols-24-2-2x.png'), url('/vendor/aprs-symbols-24-1-2x.png'); } +} +/* Fallback for symbol codes outside the sprite sheets: show the raw character. */ .aprs-symbol-local { border: 1px solid var(--border); border-radius: 4px; background: var(--surface-raised); color: var(--text); font: 700 0.8rem/22px ui-monospace, monospace; text-align: center; } .aprs-pos { color: var(--accent-green); text-decoration: none; margin-left: 0.3rem; font-size: 0.8rem; } .aprs-pos:hover { text-decoration: underline; } diff --git a/src/trx-client/trx-frontend/trx-frontend-http/assets/web/vendor/aprs-symbols-24-0-2x.png b/src/trx-client/trx-frontend/trx-frontend-http/assets/web/vendor/aprs-symbols-24-0-2x.png new file mode 100644 index 00000000..d6c15bbe Binary files /dev/null and b/src/trx-client/trx-frontend/trx-frontend-http/assets/web/vendor/aprs-symbols-24-0-2x.png differ diff --git a/src/trx-client/trx-frontend/trx-frontend-http/assets/web/vendor/aprs-symbols-24-0.png b/src/trx-client/trx-frontend/trx-frontend-http/assets/web/vendor/aprs-symbols-24-0.png new file mode 100644 index 00000000..8a2713f9 Binary files /dev/null and b/src/trx-client/trx-frontend/trx-frontend-http/assets/web/vendor/aprs-symbols-24-0.png differ diff --git a/src/trx-client/trx-frontend/trx-frontend-http/assets/web/vendor/aprs-symbols-24-1-2x.png b/src/trx-client/trx-frontend/trx-frontend-http/assets/web/vendor/aprs-symbols-24-1-2x.png new file mode 100644 index 00000000..f7e1a781 Binary files /dev/null and b/src/trx-client/trx-frontend/trx-frontend-http/assets/web/vendor/aprs-symbols-24-1-2x.png differ diff --git a/src/trx-client/trx-frontend/trx-frontend-http/assets/web/vendor/aprs-symbols-24-1.png b/src/trx-client/trx-frontend/trx-frontend-http/assets/web/vendor/aprs-symbols-24-1.png new file mode 100644 index 00000000..10126ef4 Binary files /dev/null and b/src/trx-client/trx-frontend/trx-frontend-http/assets/web/vendor/aprs-symbols-24-1.png differ diff --git a/src/trx-client/trx-frontend/trx-frontend-http/assets/web/vendor/aprs-symbols-24-2-2x.png b/src/trx-client/trx-frontend/trx-frontend-http/assets/web/vendor/aprs-symbols-24-2-2x.png new file mode 100644 index 00000000..ac8918ad Binary files /dev/null and b/src/trx-client/trx-frontend/trx-frontend-http/assets/web/vendor/aprs-symbols-24-2-2x.png differ diff --git a/src/trx-client/trx-frontend/trx-frontend-http/assets/web/vendor/aprs-symbols-24-2.png b/src/trx-client/trx-frontend/trx-frontend-http/assets/web/vendor/aprs-symbols-24-2.png new file mode 100644 index 00000000..c1dfa98a Binary files /dev/null and b/src/trx-client/trx-frontend/trx-frontend-http/assets/web/vendor/aprs-symbols-24-2.png differ diff --git a/src/trx-client/trx-frontend/trx-frontend-http/frontend/src/map-core.ts b/src/trx-client/trx-frontend/trx-frontend-http/frontend/src/map-core.ts index a6b896b3..d9040c84 100644 --- a/src/trx-client/trx-frontend/trx-frontend-http/frontend/src/map-core.ts +++ b/src/trx-client/trx-frontend/trx-frontend-http/frontend/src/map-core.ts @@ -3,6 +3,7 @@ // SPDX-License-Identifier: GPL-2.0-or-later import type * as Leaflet from "leaflet"; +import { aprsSymbolSprite } from "./plugins/aprs-shared"; export {}; @@ -2002,10 +2003,15 @@ const mapWindow = window as unknown as MapWindow; function aprsSymbolIcon(symbolTable: string, symbolCode: string): Leaflet.DivIcon | null { if (!symbolTable || !symbolCode) return null; - const table = symbolTable === "/" ? "primary" : "alternate"; + const sprite = aprsSymbolSprite(symbolTable, symbolCode); + const html = sprite + ? `` + : `
${escapeMapHtml(symbolCode)}
`; return L.divIcon({ className: "", - html: `
${escapeMapHtml(symbolCode)}
`, + html, iconSize: [24, 24], iconAnchor: [12, 12], popupAnchor: [0, -12] diff --git a/src/trx-client/trx-frontend/trx-frontend-http/frontend/src/plugins/aprs-shared.ts b/src/trx-client/trx-frontend/trx-frontend-http/frontend/src/plugins/aprs-shared.ts index df91abca..e9efafce 100644 --- a/src/trx-client/trx-frontend/trx-frontend-http/frontend/src/plugins/aprs-shared.ts +++ b/src/trx-client/trx-frontend/trx-frontend-http/frontend/src/plugins/aprs-shared.ts @@ -108,8 +108,80 @@ function escapeAprsCharacter(character: string): string { return character; } +// The vendored sprite sheets (assets/web/vendor/aprs-symbols-24-*.png) are +// 16x6 grids of 24px cells covering the printable codes 0x21..0x7E, so a +// symbol's cell index is simply `code - 0x21`. The sheet URLs live in CSS so +// the retina variants can be picked up by a media query; only the cell offsets +// are computed here. +const APRS_SPRITE_COLUMNS = 16; +const APRS_SPRITE_CELL_PX = 24; +const APRS_SPRITE_FIRST_CODE = 0x21; +const APRS_SPRITE_LAST_CODE = 0x7e; + +export interface AprsSymbolSprite { + /** Sheet modifier class appended to `.aprs-symbol`. */ + className: string; + /** `background-position` covering the overlay layer first, if any. */ + backgroundPosition: string; + /** Human-readable description for the tooltip. */ + label: string; +} + +function aprsSpriteOffset(code: string): string | null { + if (code.length !== 1) return null; + const point = code.charCodeAt(0); + if (point < APRS_SPRITE_FIRST_CODE || point > APRS_SPRITE_LAST_CODE) return null; + const index = point - APRS_SPRITE_FIRST_CODE; + const column = index % APRS_SPRITE_COLUMNS; + const row = Math.floor(index / APRS_SPRITE_COLUMNS); + return `${String(-column * APRS_SPRITE_CELL_PX)}px ${String(-row * APRS_SPRITE_CELL_PX)}px`; +} + +/** + * Resolve an APRS table/code pair to a sprite cell. A table identifier of `/` + * selects the primary sheet and `\` the alternate one; any other character is + * an overlay, which draws that character from the overlay sheet on top of the + * alternate symbol. Returns null when the pair is outside the sprite sheets, + * leaving callers to fall back to the raw character. + */ +export function aprsSymbolSprite( + symbolTable: string | null | undefined, + symbolCode: string | null | undefined, +): AprsSymbolSprite | null { + if (!symbolTable || !symbolCode) return null; + const symbolOffset = aprsSpriteOffset(symbolCode); + if (!symbolOffset) return null; + if (symbolTable === "/") { + return { + className: "aprs-symbol-primary", + backgroundPosition: symbolOffset, + label: `Primary APRS symbol ${symbolTable}${symbolCode}`, + }; + } + if (symbolTable === "\\") { + return { + className: "aprs-symbol-alternate", + backgroundPosition: symbolOffset, + label: `Alternate APRS symbol ${symbolTable}${symbolCode}`, + }; + } + const overlayOffset = aprsSpriteOffset(symbolTable); + if (!overlayOffset) return null; + return { + className: "aprs-symbol-overlaid", + backgroundPosition: `${overlayOffset}, ${symbolOffset}`, + label: `Alternate APRS symbol \\${symbolCode} with overlay ${symbolTable}`, + }; +} + export function renderLocalAprsSymbol(packet: AprsPacket, escapeHtml: (value: string) => string): string { if (!packet.symbolTable || !packet.symbolCode) return ""; + const sprite = aprsSymbolSprite(packet.symbolTable, packet.symbolCode); + if (sprite) { + return ``; + } const symbol = escapeHtml(packet.symbolCode); const table = packet.symbolTable === "/" ? "Primary" : "Alternate"; return `${symbol}`; diff --git a/src/trx-client/trx-frontend/trx-frontend-http/frontend/tests/aprs-symbols.test.mjs b/src/trx-client/trx-frontend/trx-frontend-http/frontend/tests/aprs-symbols.test.mjs new file mode 100644 index 00000000..541592e8 --- /dev/null +++ b/src/trx-client/trx-frontend/trx-frontend-http/frontend/tests/aprs-symbols.test.mjs @@ -0,0 +1,85 @@ +// SPDX-FileCopyrightText: 2026 Stan Grams +// +// SPDX-License-Identifier: GPL-2.0-or-later + +import assert from "node:assert/strict"; +import test from "node:test"; +import vm from "node:vm"; +import { readFile } from "node:fs/promises"; +import { bundleEntry } from "./bundle-entry.mjs"; + +const sharedUrl = new URL("../src/plugins/aprs-shared.ts", import.meta.url); +const stylePath = new URL("../../assets/web/style.css", import.meta.url); + +async function loadShared() { + const source = await bundleEntry(sharedUrl, "trxAprsShared"); + const context = vm.createContext({ Math, String, Number, Array, Date, Set, console }); + new vm.Script(source).runInContext(context); + return context.trxAprsShared; +} + +// The sheets are 16x6 grids of 24px cells covering 0x21..0x7E, so cell index +// is `code - 0x21`. Getting this wrong shifts every station to a neighbouring +// icon, which is invisible in a screenshot but wrong on every packet. +test("sprite cells are indexed from the first printable symbol code", async () => { + const { aprsSymbolSprite } = await loadShared(); + + const first = aprsSymbolSprite("/", "!"); + assert.equal(first.className, "aprs-symbol-primary"); + assert.equal(first.backgroundPosition, "0px 0px"); + assert.equal(first.label, "Primary APRS symbol /!"); + // '>' is 0x3E -> index 29 -> column 13, row 1. + assert.equal(aprsSymbolSprite("/", ">").backgroundPosition, "-312px -24px"); + // '~' is 0x7E -> index 93 -> the last cell of the last row. + assert.equal(aprsSymbolSprite("/", "~").backgroundPosition, "-312px -120px"); +}); + +test("the table identifier selects the primary, alternate, or overlay sheet", async () => { + const { aprsSymbolSprite } = await loadShared(); + + assert.equal(aprsSymbolSprite("/", "_").className, "aprs-symbol-primary"); + assert.equal(aprsSymbolSprite("\\", "_").className, "aprs-symbol-alternate"); + + // An alphanumeric table identifier is an overlay character drawn on top of + // the alternate symbol: overlay cell first, then the symbol cell. + const overlaid = aprsSymbolSprite("S", ">"); + assert.equal(overlaid.className, "aprs-symbol-overlaid"); + assert.equal(overlaid.backgroundPosition, "-48px -72px, -312px -24px"); + assert.equal(overlaid.label, "Alternate APRS symbol \\> with overlay S"); +}); + +test("codes outside the sprite sheets fall back to the raw character", async () => { + const { aprsSymbolSprite, renderLocalAprsSymbol } = await loadShared(); + const escape = (value) => value; + + assert.equal(aprsSymbolSprite("/", " "), null); + assert.equal(aprsSymbolSprite("/", ""), null); + assert.equal(aprsSymbolSprite("/", "ab"), null); + assert.equal(aprsSymbolSprite(null, ">"), null); + + assert.equal(renderLocalAprsSymbol({ symbolTable: "/", symbolCode: " " }, escape), + ' '); + assert.equal(renderLocalAprsSymbol({}, escape), ""); +}); + +test("rendered symbols carry a sprite class and an inline cell offset", async () => { + const { renderLocalAprsSymbol } = await loadShared(); + const html = renderLocalAprsSymbol({ symbolTable: "/", symbolCode: ">" }, (value) => value); + + assert.match(html, /class="aprs-symbol aprs-symbol-primary"/); + assert.match(html, /style="background-position:-312px -24px"/); + assert.match(html, /aria-label="Primary APRS symbol \/>"/); + assert.equal(html.includes("http"), false); +}); + +// The cell offsets are computed in the bundles, so the sheet URLs and the grid +// geometry have to stay in lockstep with them here. +test("the stylesheet serves every sheet locally at the sprite geometry", async () => { + const css = await readFile(stylePath, "utf8"); + + assert.match(css, /\.aprs-symbol\s*\{[^}]*background-size:\s*384px 144px/); + for (const sheet of ["24-0", "24-1", "24-2", "24-0-2x", "24-1-2x", "24-2-2x"]) { + assert.ok(css.includes(`url('/vendor/aprs-symbols-${sheet}.png')`), `missing sheet ${sheet}`); + } + assert.match(css, /\.aprs-symbol-overlaid\s*\{[^}]*aprs-symbols-24-2\.png'\), url\('\/vendor\/aprs-symbols-24-1\.png'\)/); +}); diff --git a/src/trx-client/trx-frontend/trx-frontend-http/frontend/tests/bundle-entry.mjs b/src/trx-client/trx-frontend/trx-frontend-http/frontend/tests/bundle-entry.mjs index 1b2d04ad..c322692b 100644 --- a/src/trx-client/trx-frontend/trx-frontend-http/frontend/tests/bundle-entry.mjs +++ b/src/trx-client/trx-frontend/trx-frontend-http/frontend/tests/bundle-entry.mjs @@ -4,7 +4,7 @@ import { build } from "esbuild"; -export async function bundleEntry(entryUrl) { +export async function bundleEntry(entryUrl, globalName) { const result = await build({ entryPoints: [entryUrl.pathname], bundle: true, @@ -12,6 +12,7 @@ export async function bundleEntry(entryUrl) { platform: "browser", target: "es2022", write: false, + ...(globalName ? { globalName } : {}), }); const output = result.outputFiles[0]; if (!output) throw new Error(`No bundle output for ${entryUrl.pathname}`); diff --git a/src/trx-client/trx-frontend/trx-frontend-http/src/api/assets.rs b/src/trx-client/trx-frontend/trx-frontend-http/src/api/assets.rs index 2f84d383..b68b8c7d 100644 --- a/src/trx-client/trx-frontend/trx-frontend-http/src/api/assets.rs +++ b/src/trx-client/trx-frontend/trx-frontend-http/src/api/assets.rs @@ -279,6 +279,47 @@ pub(crate) async fn leaflet_layers_2x() -> impl Responder { .body(status::LEAFLET_LAYERS_2X) } +// --------------------------------------------------------------------------- +// Vendored APRS symbol sprites +// --------------------------------------------------------------------------- + +fn embedded_png(bytes: &'static [u8]) -> HttpResponse { + HttpResponse::Ok() + .insert_header((header::CONTENT_TYPE, "image/png")) + .insert_header((header::CACHE_CONTROL, "public, max-age=604800, immutable")) + .body(bytes) +} + +#[get("/vendor/aprs-symbols-24-0.png")] +pub(crate) async fn aprs_symbols_primary() -> impl Responder { + embedded_png(status::APRS_SYMBOLS_PRIMARY) +} + +#[get("/vendor/aprs-symbols-24-0-2x.png")] +pub(crate) async fn aprs_symbols_primary_2x() -> impl Responder { + embedded_png(status::APRS_SYMBOLS_PRIMARY_2X) +} + +#[get("/vendor/aprs-symbols-24-1.png")] +pub(crate) async fn aprs_symbols_alternate() -> impl Responder { + embedded_png(status::APRS_SYMBOLS_ALTERNATE) +} + +#[get("/vendor/aprs-symbols-24-1-2x.png")] +pub(crate) async fn aprs_symbols_alternate_2x() -> impl Responder { + embedded_png(status::APRS_SYMBOLS_ALTERNATE_2X) +} + +#[get("/vendor/aprs-symbols-24-2.png")] +pub(crate) async fn aprs_symbols_overlay() -> impl Responder { + embedded_png(status::APRS_SYMBOLS_OVERLAY) +} + +#[get("/vendor/aprs-symbols-24-2-2x.png")] +pub(crate) async fn aprs_symbols_overlay_2x() -> impl Responder { + embedded_png(status::APRS_SYMBOLS_OVERLAY_2X) +} + #[cfg(test)] mod tests { use super::*; @@ -307,4 +348,41 @@ mod tests { ); assert_eq!(generated_content_type("secret.txt"), None); } + + /// Reads the width and height out of a PNG IHDR chunk. + fn png_dimensions(bytes: &[u8]) -> (u32, u32) { + assert_eq!(&bytes[..8], b"\x89PNG\r\n\x1a\n", "not a PNG"); + assert_eq!(&bytes[12..16], b"IHDR", "first chunk is not IHDR"); + let width = u32::from_be_bytes(bytes[16..20].try_into().expect("IHDR width")); + let height = u32::from_be_bytes(bytes[20..24].try_into().expect("IHDR height")); + (width, height) + } + + /// The browser computes sprite cell offsets from a 16x6 grid of 24px cells, + /// so a sheet at any other size would silently shift every APRS symbol. + #[test] + fn aprs_symbol_sheets_match_the_sprite_grid_the_frontend_assumes() { + for (name, bytes) in [ + ("aprs-symbols-24-0", status::APRS_SYMBOLS_PRIMARY), + ("aprs-symbols-24-1", status::APRS_SYMBOLS_ALTERNATE), + ("aprs-symbols-24-2", status::APRS_SYMBOLS_OVERLAY), + ] { + assert_eq!( + png_dimensions(bytes), + (384, 144), + "{name} is not a 16x6 grid" + ); + } + for (name, bytes) in [ + ("aprs-symbols-24-0-2x", status::APRS_SYMBOLS_PRIMARY_2X), + ("aprs-symbols-24-1-2x", status::APRS_SYMBOLS_ALTERNATE_2X), + ("aprs-symbols-24-2-2x", status::APRS_SYMBOLS_OVERLAY_2X), + ] { + assert_eq!( + png_dimensions(bytes), + (768, 288), + "{name} is not a 2x sheet" + ); + } + } } diff --git a/src/trx-client/trx-frontend/trx-frontend-http/src/api/mod.rs b/src/trx-client/trx-frontend/trx-frontend-http/src/api/mod.rs index e79233e1..91afbfdc 100644 --- a/src/trx-client/trx-frontend/trx-frontend-http/src/api/mod.rs +++ b/src/trx-client/trx-frontend/trx-frontend-http/src/api/mod.rs @@ -658,6 +658,13 @@ pub fn configure(cfg: &mut web::ServiceConfig) { .service(assets::leaflet_marker_shadow) .service(assets::leaflet_layers) .service(assets::leaflet_layers_2x) + // Vendored APRS symbol sprites + .service(assets::aprs_symbols_primary) + .service(assets::aprs_symbols_primary_2x) + .service(assets::aprs_symbols_alternate) + .service(assets::aprs_symbols_alternate_2x) + .service(assets::aprs_symbols_overlay) + .service(assets::aprs_symbols_overlay_2x) .service(assets::generated_asset) // Virtual channels .service(vchan::list_channels) diff --git a/src/trx-client/trx-frontend/trx-frontend-http/src/status.rs b/src/trx-client/trx-frontend/trx-frontend-http/src/status.rs index 39f34f3e..6bae90a2 100644 --- a/src/trx-client/trx-frontend/trx-frontend-http/src/status.rs +++ b/src/trx-client/trx-frontend/trx-frontend-http/src/status.rs @@ -37,6 +37,23 @@ pub const LEAFLET_MARKER_SHADOW: &[u8] = include_bytes!("../assets/web/vendor/ma pub const LEAFLET_LAYERS: &[u8] = include_bytes!("../assets/web/vendor/layers.png"); pub const LEAFLET_LAYERS_2X: &[u8] = include_bytes!("../assets/web/vendor/layers-2x.png"); +// Vendored APRS symbol sprites (https://github.com/hessu/aprs-symbols). +// Each sheet is a 16x6 grid of 24px cells indexed by `symbol code - 0x21`: +// table 0 is the primary ('/') set, table 1 the alternate ('\') set, and +// table 2 the overlay characters drawn on top of an alternate symbol. +pub const APRS_SYMBOLS_PRIMARY: &[u8] = + include_bytes!("../assets/web/vendor/aprs-symbols-24-0.png"); +pub const APRS_SYMBOLS_PRIMARY_2X: &[u8] = + include_bytes!("../assets/web/vendor/aprs-symbols-24-0-2x.png"); +pub const APRS_SYMBOLS_ALTERNATE: &[u8] = + include_bytes!("../assets/web/vendor/aprs-symbols-24-1.png"); +pub const APRS_SYMBOLS_ALTERNATE_2X: &[u8] = + include_bytes!("../assets/web/vendor/aprs-symbols-24-1-2x.png"); +pub const APRS_SYMBOLS_OVERLAY: &[u8] = + include_bytes!("../assets/web/vendor/aprs-symbols-24-2.png"); +pub const APRS_SYMBOLS_OVERLAY_2X: &[u8] = + include_bytes!("../assets/web/vendor/aprs-symbols-24-2-2x.png"); + /// Build version tag used for cache-busting asset URLs and ETag headers. /// Computed once from `PKG_VERSION` + `CLIENT_BUILD_DATE`. pub fn build_version_tag() -> &'static str {