Skip to content

Store and manage trail elevation profiles in Payload - #128

Merged
kwiens merged 11 commits into
mainfrom
codex/cms-elevation-profiles
Sep 20, 2026
Merged

kwiens merged 11 commits into
mainfrom
codex/cms-elevation-profiles

Conversation

@kwiens

@kwiens kwiens commented Sep 20, 2026

Copy link
Copy Markdown
Owner

🤖

Summary

  • make Payload the primary home for the 406 checked-in Bend and Chattanooga elevation profiles by importing them during both city seeds
  • add a Payload Measurements view with a rendered elevation chart, formatted distance/climb/descent/range, and a context-aware elevation action
  • recalculate from the last saved CMS geometry without refetching OSM; for style-owned trails without CMS geometry, repopulate from the trusted city-scoped bundled profile instead
  • preserve draft state, normal access checks, and record locks along both update paths
  • show descent alongside distance and climb in the public mountain-bike trail list
  • validate complete profile payloads at static-file, seed, API, and public-read boundaries
  • align GraphQL with Payload 3.90.1's supported peer range

Code and documentation

Examples

An existing trail's Measurements tab now presents rider-facing values such as:

Distance 3.42 mi · Climb 620 ft · Descent 598 ft · Elevation range 1,040–1,486 ft

The sidebar uses the same stored summaries:

3.42 mi · ↑ 620 ft · ↓ 598 ft

A trail with CMS geometry shows Recalculate elevation and samples Terrain-RGB. A style-owned trail such as Godsey Ridge Expert Spur shows an enabled Repopulate elevation action instead. Its bundled profile changes the stale 0.00 mi summary to 0.03 mi and stores all eight chart samples in Payload.

Recalculation is a narrow authenticated request:

POST /api/trails/42/recalculate-elevation

{
  "message": "Elevation profile recalculated.",
  "measurements": {
    "distance": 3.42,
    "elevationGain": 620,
    "elevationLoss": 598,
    "elevationMin": 1040,
    "elevationMax": 1486
  },
  "profile": { "trail": "Example Trail", "profile": ["..."] }
}

The Godsey fallback path returns the same response shape with:

{
  "message": "Bundled elevation profile repopulated.",
  "measurements": {
    "distance": 0.03,
    "elevationGain": 16,
    "elevationLoss": 12,
    "elevationMin": 940,
    "elevationMax": 952
  }
}

The action is disabled while the form is saving or has unsaved edits. Terrain and bundled-profile failures leave existing measurements untouched.

Production rollout

The read-only production audit before this change found:

City Published trails Stored profiles Stored geometries
Chattanooga 224 218 218
Bend 182 0 182

After deployment, run:

pnpm db:seed:chattanooga
pnpm db:seed:bend

No database migration is required. The six style-owned Godsey Ridge trails receive their checked-in profiles during the seed; an editor can also repopulate any one of them directly from its Measurements tab.

Verification

  • pnpm check
  • pnpm test:run — 64 files, 670 tests passed
  • pnpm build — all 13 routes built successfully
  • git diff --check
  • local integration: /admin returned 200; anonymous elevation update returned the expected 401

The unrelated local change in src/utils/map.test.ts is intentionally excluded from this PR.

@vercel

vercel Bot commented Sep 20, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
bikemap Ready Ready Preview Sep 20, 2026 2:24pm UTC

Request Review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 20, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-20T00:08:36.648242Z 6eb5119 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6eb51197ff

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/payload/components/ElevationProfileAdmin.tsx Outdated
…rofiles

# Conflicts:
#	scripts/seed/chattanooga.ts
#	src/data/cities/chattanooga/trails-data.test.ts
@kwiens
kwiens merged commit 97aec5a into main Sep 20, 2026
5 checks passed
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