Skip to content

Add Presidential Libraries tracking to American Mapbook - #593

Merged
rjison merged 18 commits into
tronbyt:mainfrom
rjison:americanmapbookupdates
Jul 27, 2026
Merged

Add Presidential Libraries tracking to American Mapbook#593
rjison merged 18 commits into
tronbyt:mainfrom
rjison:americanmapbookupdates

Conversation

@rjison

@rjison rjison commented Jul 27, 2026

Copy link
Copy Markdown
Collaborator

Add new tracking category - Presidential Libraries

Summary by CodeRabbit

  • New Features

    • Added presidential libraries as a new map-tracking category.
    • Expanded map data to include U.S. capitals, national parks, UNESCO World Heritage sites, and presidential libraries.
    • Improved map rendering across standard and 2× display modes.
  • Bug Fixes

    • Improved handling of maps with limited or identical coordinate bounds.
    • Fixed frame construction to preserve accurate point and count displays.
  • Data Updates

    • Added comprehensive U.S. map geometry and location data.

rjison added 15 commits July 26, 2026 22:51
…ng the final count during the ending hold frames instead of only during the animated update frames.
…t-in name and make the tracking selection logic clearer
…lication and simplify future map positioning changes.
…nd Alaska via named constants instead of bare numeric lists
…d of using a None branch, ensuring the applet always uses a valid data set.
…lt-in type name and keep tracking logic naming consistent
…s returned by get_bounds()—changing minx/maxx/miny/maxy lookups to min_x/max_x/min_y/max_y so coordinate scaling works correctly again.
…me instead of permanently, preventing multiple stacked counters and keeping items_to_plot clean
… divide by zero when all points in a group share the same x or y value; in that case, the code now places the result at the midpoint of the target range instead of crashing.
@rjison rjison self-assigned this Jul 27, 2026
@rjison
rjison requested a review from tavdog as a code owner July 27, 2026 13:37
@coderabbitai

coderabbitai Bot commented Jul 27, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The American Mapbook now loads U.S. geometry and point datasets from a separate data module, centralizes coordinate conversion, updates animation frame construction, and adds presidential-library tracking configuration.

Changes

American Mapbook

Layer / File(s) Summary
Map geometry and tracking datasets
apps/americanmapbook/americanmapbook.star, apps/americanmapbook/americanmapbook_data.star, apps/americanmapbook/manifest.yaml
U.S. geometry, capitols, national parks, heritage sites, and presidential libraries are defined in a data module and loaded by the mapbook; the manifest timestamp is updated.
Coordinate conversion and animation rendering
apps/americanmapbook/americanmapbook.star
Coordinate normalization handles degenerate bounds, inset conversion is centralized, dot sizing is updated, and per-frame overlays no longer mutate shared plotting items.
Tracking type and toggle integration
apps/americanmapbook/americanmapbook.star
Tracking selection routes to each dataset, adds presidential-library options, and generates consistent toggle configuration keys with slugify.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant main
  participant get_tracking_items
  participant get_presidential_library_options
  participant presidential_libraries
  main->>get_tracking_items: pass presidential_libraries tracking type
  get_tracking_items->>get_presidential_library_options: build library toggle fields
  get_presidential_library_options->>presidential_libraries: read library entries
  get_presidential_library_options-->>get_tracking_items: return library toggles
  get_tracking_items-->>main: return tracking items
Loading

Suggested reviewers: tavdog

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: adding Presidential Libraries tracking to American Mapbook.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (2)
apps/americanmapbook/americanmapbook.star (2)

245-286: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick win

Duplicate count-box construction is recomputed unnecessarily 100 times in the tail loop.

The count-box building logic (Lines 245-254 and 273-284) is duplicated verbatim between the per-visited-point loop and the 100-frame "stay on screen" tail loop. In the tail loop, total_visited is already final, so render.Text(...), .size(), and the padded render.Box are being recreated identically on every one of the 100 iterations for no benefit — this is pure wasted work on every render.

♻️ Proposed fix — compute once, reuse across the 100 frames
+    final_items = list(items_to_plot)
+    if config.bool("showCount"):
+        display_text = render.Text(
+            content = str(total_visited),
+            font = font,
+            color = visited_color,
+        )
+        text_w, text_h = display_text.size()
+        pad = 2 if is2x else 1
+        final_items.append(
+            add_padding_to_child_element(
+                render.Box(
+                    color = "`#000`",
+                    width = text_w,
+                    height = text_h,
+                    child = display_text,
+                ),
+                width - pad - text_w,
+                height - pad - text_h,
+            ),
+        )
+
     # Add several frames of the final product to keep on screen for longer
     for _ in range(100):
-        final_items = list(items_to_plot)
-
-        if config.get("showCount") == "true":
-            display_text = render.Text(
-                content = str(total_visited),
-                font = font,
-                color = visited_color,
-            )
-            text_w, text_h = display_text.size()
-            pad = 2 if is2x else 1
-
-            final_items.append(
-                add_padding_to_child_element(
-                    render.Box(
-                        color = "`#000`",
-                        width = text_w,
-                        height = text_h,
-                        child = display_text,
-                    ),
-                    width - pad - text_w,
-                    height - pad - text_h,
-                ),
-            )
-
         animation_frames.append(render.Stack(children = final_items))
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@apps/americanmapbook/americanmapbook.star` around lines 245 - 286, Extract
the final count-box construction used in the tail loop into a value computed
once before the 100-iteration loop, then append that reused element to each
frame when showCount is enabled. Update the tail-loop logic around render.Text,
size(), and add_padding_to_child_element so these operations are not repeated,
while preserving the existing frame contents and behavior.

196-196: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Use config.bool() instead of config.get(...) == "true" for Toggle fields.

All three sites read a schema.Toggle value via config.get(key) == "true". Per pixlet's own docs, Toggle values should be read with config.bool(), which returns an actual boolean instead of relying on string-literal comparison.

♻️ Proposed fix
-                if config.get("%s_%s_%s" % (preface, slugify(location["state"]), slugify(location[config_item.lower()]))) == "true":
+                if config.bool("%s_%s_%s" % (preface, slugify(location["state"]), slugify(location[config_item.lower()]))):
-                if config.get("showCount") == "true":
+                if config.bool("showCount"):

(apply the same replacement at both Line 237 and Line 264)

As per coding guidelines, "Retrieve boolean options from schema.Toggle with config.bool("key") rather than config.get("key")."

Also applies to: 237-237, 264-264

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@apps/americanmapbook/americanmapbook.star` at line 196, Replace the
Toggle-value checks in the conditions at the shown locations with config.bool()
using the same constructed key, removing the string comparison to "true". Apply
this consistently to all three occurrences, including the corresponding checks
near the other two locations, while preserving the existing control flow.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@apps/americanmapbook/americanmapbook.star`:
- Around line 122-129: Update the dot_size initialization near the canvas
dimension setup to scale with is2x, using the established 2x rendering
convention so it is 2 on high-density canvases and 1 otherwise. Remove the stale
inline comment and keep the resulting dot_size value shared by both outline
padding and visible dot rendering.
- Around line 172-196: Update get_location_options, get_national_park_options,
and get_world_heritage_options to build Toggle IDs with the shared slugify()
helper instead of plain space replacement, matching the lookup key constructed
in the tracking flow. Preserve get_presidential_library_options’ existing
slugify behavior so punctuation-containing entries resolve to the same
configuration keys.

---

Nitpick comments:
In `@apps/americanmapbook/americanmapbook.star`:
- Around line 245-286: Extract the final count-box construction used in the tail
loop into a value computed once before the 100-iteration loop, then append that
reused element to each frame when showCount is enabled. Update the tail-loop
logic around render.Text, size(), and add_padding_to_child_element so these
operations are not repeated, while preserving the existing frame contents and
behavior.
- Line 196: Replace the Toggle-value checks in the conditions at the shown
locations with config.bool() using the same constructed key, removing the string
comparison to "true". Apply this consistently to all three occurrences,
including the corresponding checks near the other two locations, while
preserving the existing control flow.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: db4d5906-4536-485e-b87a-48e1aeb0fb1b

📥 Commits

Reviewing files that changed from the base of the PR and between ca683aa and fc449e6.

📒 Files selected for processing (3)
  • apps/americanmapbook/americanmapbook.star
  • apps/americanmapbook/americanmapbook_data.star
  • apps/americanmapbook/manifest.yaml

Comment thread apps/americanmapbook/americanmapbook.star
Comment thread apps/americanmapbook/americanmapbook.star
@rjison rjison changed the title American Mapbook Updates Add Presidential Libraries tracking to American Mapbook Jul 27, 2026
@rjison
rjison merged commit cbd8acc into tronbyt:main Jul 27, 2026
1 check passed
@rjison
rjison deleted the americanmapbookupdates branch July 27, 2026 14:03
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