Skip to content

feat: topo-dark style variant + fix font glyph loading#145

Merged
fank merged 2 commits into
mainfrom
feat/topo-dark-style
Feb 6, 2026
Merged

feat: topo-dark style variant + fix font glyph loading#145
fank merged 2 commits into
mainfrom
feat/topo-dark-style

Conversation

@fank
Copy link
Copy Markdown
Member

@fank fank commented Feb 6, 2026

Summary

  • Add topo-dark MapLibre style variant with dark background (#1B1B1B), muted colors (sea #1a3a5c, contours #5a4a3a/#3a5a7a, roads #888888, forest #3a5a2a), light-on-dark labels with #111111 halos, and stronger hillshade (0.5 exaggeration, 0.6 shadow)
  • Refactor topo style to use dedicated knownTopoLayerStyles map and topoLayerOrder render order instead of reusing color-relief's buildVectorFeatureLayers
  • Fix MapLibre font glyph 404s (GET /fonts/OpenSans-Regular/0-255.pbf 404) by adding transformRequest to rewrite glyph URLs to the correct images/maps/fonts/ server path — avoids fragile relative URL resolution from the style JSON location

Changes

  • internal/maptool/styles.goStyleTopoDark constant, knownTopoDarkLayerStyles map, buildTopoDarkLayers/buildTopoDarkVectorFeatureLayers, topo style refactor with knownTopoLayerStyles/topoLayerOrder/buildTopoVectorFeatureLayers
  • internal/maptool/metadata.go — generate topo-dark.json style file
  • internal/maptool/styles_test.go — add StyleTopoDark to variant test loop
  • static/scripts/ocap.js — add Topo Dark style candidate, add transformRequest for font glyph URL rewriting

Test plan

  • go build ./...
  • go test ./internal/maptool/
  • Browser test: verify topo-dark style renders with dark background and muted colors
  • Browser test: verify font glyphs load without 404 errors for all style variants
  • Browser test: verify style switcher shows Topo Dark button when style file exists

Add dark-themed topo style with muted colors (#1B1B1B background,
dark sea/contours/roads, light-on-dark labels) and stronger hillshade.
Refactor topo style to use dedicated layer styles and render order
instead of reusing color-relief's buildVectorFeatureLayers.

Fix MapLibre font glyph 404s by using transformRequest to rewrite
glyph URLs to the correct server path, avoiding fragile relative URL
resolution from the style JSON document location.
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @fank, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces a new "topo-dark" map style variant, providing users with an alternative dark-themed topographic map. Alongside this new feature, the existing topographic style's layer management has been improved for clarity and maintainability. Crucially, it also addresses a client-side issue where MapLibre font glyphs were failing to load due to incorrect URL resolution, enhancing the robustness of map rendering across all styles.

Highlights

  • New Map Style: Introduced a "topo-dark" MapLibre style variant with a dark background (#1B1B1B), muted colors for geographical features (sea, contours, roads, forest), light-on-dark labels, and stronger hillshade (0.5 exaggeration, 0.6 shadow).
  • Topo Style Refactoring: The existing "topo" style was refactored to use dedicated knownTopoLayerStyles and topoLayerOrder maps, improving organization and rendering control by moving away from reusing buildVectorFeatureLayers.
  • Font Glyph Loading Fix: Resolved 404 errors for MapLibre font glyphs by implementing a transformRequest function in ocap.js to correctly rewrite glyph URLs to the images/maps/fonts/ server path, ensuring proper font rendering across all map styles.
Changelog
  • internal/maptool/metadata.go
    • Added StyleTopoDark to the list of styles to be generated, ensuring topo-dark.json is created.
  • internal/maptool/styles.go
    • Introduced new helper functions (topoContourColorExpr, topoTextLayout, topoTextPaint, topoDarkContourColorExpr, topoDarkTextPaint, makeTopoDarkLabel) to define specific styling for both standard topo and the new topo-dark variant.
    • Defined knownTopoLayerStyles and topoLayerOrder to centralize and manage the rendering of layers for the standard topo style.
    • Defined knownTopoDarkLayerStyles with dark-themed colors and properties for the new topo-dark style.
    • Added StyleTopoDark to the StyleVariant enum.
    • Modified GenerateStyleDocument to set the appropriate background color (#1B1B1B) and call the new buildTopoDarkLayers function for the StyleTopoDark variant.
    • Refactored buildTopoLayers to use the new knownTopoLayerStyles and topoLayerOrder for building vector feature layers.
    • Implemented buildTopoDarkLayers and buildTopoDarkVectorFeatureLayers to construct the layers for the new dark style, applying its specific color palette and hillshade settings.
  • internal/maptool/styles_test.go
    • Updated the test loop for style variants to include StyleTopoDark, ensuring its generation is tested.
  • static/scripts/ocap.js
    • Added a "Topo Dark" entry to the styleCandidates array, making the new style selectable in the UI.
    • Implemented a transformRequest function within the L.maplibreGL initialization to intercept and correct font glyph URLs, resolving 404 errors by pointing them to the correct images/maps/fonts/ path.
Activity
  • No specific human activity (comments, reviews, progress updates) was provided in the context for this pull request.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a new topo-dark map style variant, refactors the existing topo style generation for better separation and maintainability, and fixes an issue with font glyph loading in MapLibre. The changes are well-structured and address the goals outlined in the description. I've provided a couple of suggestions to reduce code duplication in the new style generation logic, which would further improve the code's maintainability.

Comment thread internal/maptool/styles.go Outdated
Comment thread internal/maptool/styles.go Outdated
… styles

Extract buildOrderedVectorLayers() and layerStyleToMap() shared by both
topo variants. Replace duplicated symbol layer definitions (bush, rock,
tree, fuelstation, transmitter, stack) with makeTopoSymbol() helper.
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Feb 6, 2026

Merging this branch will increase overall coverage

Impacted Packages Coverage Δ 🤖
github.com/OCAP2/web/internal/maptool 13.87% (+0.69%) 👍

Coverage by file

Changed files (no unit tests)

Changed File Coverage Δ Total Covered Missed 🤖
github.com/OCAP2/web/internal/maptool/metadata.go 11.08% (ø) 352 39 313
github.com/OCAP2/web/internal/maptool/styles.go 33.12% (-0.87%) 921 (+253) 305 (+78) 616 (+175) 👎

Please note that the "Total", "Covered", and "Missed" counts above refer to code statements instead of lines of code. The value in brackets refers to the test coverage of that file in the old version of the code.

Changed unit test files

  • github.com/OCAP2/web/internal/maptool/styles_test.go

@fank fank merged commit 10e6f07 into main Feb 6, 2026
2 checks passed
@fank fank deleted the feat/topo-dark-style branch February 6, 2026 23:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant