Skip to content

feat(arc): add great circle path mode for arcs - #73

Open
jabahm wants to merge 1 commit into
AnmolSaini16:mainfrom
jabahm:feat/great-circle-arc
Open

feat(arc): add great circle path mode for arcs#73
jabahm wants to merge 1 commit into
AnmolSaini16:mainfrom
jabahm:feat/great-circle-arc

Conversation

@jabahm

@jabahm jabahm commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds a path prop to MapArc so arcs can be rendered as true great circles (the shortest path over the globe), alongside the existing curved style.

  • New path prop on MapArc with a greatCircle mode
  • Docs: a dedicated Great Circle section on /docs/arcs with a globe example (reusing the Basic Arc routes)
  • API reference updated to document the path prop

Test plan

  • /docs/arcs renders the Great Circle example, no console errors
  • API reference lists the greatCircle path mode

Summary by CodeRabbit

  • New Features

    • Added great-circle path support for map arcs alongside the existing Bézier option.
    • Great-circle arcs handle antimeridian crossings and preserve accurate endpoints.
    • Added a documentation example showcasing arcs between London and several global cities.
  • Documentation

    • Updated the MapArc API reference with the new path option and behavior details.
    • Added guidance covering curvature, sampling, and globe projection settings.

Add a `path` prop to render arcs as true great circles, document the
greatCircle mode with a globe example, and reuse the Basic Arc routes
in that example.
@vercel

vercel Bot commented Aug 6, 2026

Copy link
Copy Markdown

@jabahm is attempting to deploy a commit to the mapcn oss program Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

MapArc now supports Bézier and great-circle paths. Great-circle generation handles antimeridian continuity, endpoint preservation, and degenerate coordinates. The documentation includes API details and a globe-based example.

Changes

MapArc great-circle paths

Layer / File(s) Summary
Path contract and coordinate generation
src/registry/map.tsx, public/r/map.json
MapArc adds the path option with Bézier as the default. Great-circle interpolation supports antimeridian unwrapping, sample normalization, endpoint pinning, and degenerate-case fallback. GeoJSON regeneration includes path changes.
Documentation and example
src/app/(main)/docs/...
The API reference and arcs page document path behavior, curvature, samples, and globe projection. A London-centered great-circle example shows labeled destination markers.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant MapArc
  participant buildArcCoordinates
  participant GeoJSON
  MapArc->>buildArcCoordinates: pass path and arc endpoints
  buildArcCoordinates->>GeoJSON: generate Bézier or great-circle coordinates
  MapArc->>GeoJSON: update geometry when path changes
Loading

Possibly related PRs

Suggested reviewers: anmolsaini16

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the addition of great-circle path support for arcs.
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.
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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 (3)
src/registry/map.tsx (1)

1712-1714: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Use a single-line guard.

Use a concise conditional for this single return statement.

As per coding guidelines, “Avoid unnecessary curly braces in conditionals; use concise syntax for simple statements.”

🤖 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 `@src/registry/map.tsx` around lines 1712 - 1714, Replace the multi-line
greatCircle conditional in the surrounding coordinate-building logic with a
single-line guard that directly returns buildGreatCircleCoordinates(from, to,
samples), preserving the existing condition and behavior.

Source: Coding guidelines

src/app/(main)/docs/_components/examples/great-circle-arc-example.tsx (2)

9-23: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Place the exported component before static content.

Move GreatCircleArcExample before the static data declarations. Keep the static data after helpers.

As per coding guidelines, “Structure files: exported component → subcomponents → helpers → static content → types.”

🤖 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 `@src/app/`(main)/docs/_components/examples/great-circle-arc-example.tsx around
lines 9 - 23, Move the exported GreatCircleArcExample component declaration
before the static hub, destinations, and arcs declarations, while keeping those
static data declarations after any helper functions in the file. Preserve the
component’s existing behavior and references.

Source: Coding guidelines


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

Use the required visual tokens and responsive rules.

Replace the hardcoded orange and white colors with semantic monochrome tokens. Use a 0.625rem radius for the label. Replace the fixed height with mobile-first height utilities. Add the required fade-up, fade-in, or scale-in animation with 100 ms marker delays.

As per coding guidelines, “Use base radius of 0.625rem with computed variants”, “Use animations: fade-up, fade-in, scale-in with staggered delays (100ms intervals)”, and “Use theme tokens defined as CSS custom properties in globals.css (oklch color space) — no hardcoded colors, always use semantic tokens.”

🤖 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 `@src/app/`(main)/docs/_components/examples/great-circle-arc-example.tsx around
lines 25 - 53, Update the great-circle example’s Map, MapArc, and MapMarker
elements to replace hardcoded orange/white colors with semantic monochrome theme
tokens, apply the 0.625rem base radius to labels, and change the fixed 420px
container height to mobile-first responsive height utilities. Add the required
fade-up, fade-in, or scale-in animation and stagger marker animations with 100ms
delays, including the hub and mapped destinations.

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 `@src/app/`(main)/docs/arcs/page.tsx:
- Around line 70-75: Correct the prose accompanying the DocsCode example for
path="greatCircle": describe it as a spherical shortest-path approximation with
poleward curvature, without claiming it models an aircraft’s actual route or
passes over Greenland. Keep the example’s technical behavior unchanged.

In `@src/registry/map.tsx`:
- Around line 1667-1673: Normalize samples through a shared finite,
maximum-bounded segment-count helper before generating coordinates, and reuse
that count in both path-generation modes so Infinity and NaN cannot produce
non-terminating or one-coordinate results. Apply the source change around the
visible segment calculation and regenerate the embedded registry source at
src/registry/map.tsx lines 1667-1673 and public/r/map.json line 17 with the same
normalizer.

---

Nitpick comments:
In `@src/app/`(main)/docs/_components/examples/great-circle-arc-example.tsx:
- Around line 9-23: Move the exported GreatCircleArcExample component
declaration before the static hub, destinations, and arcs declarations, while
keeping those static data declarations after any helper functions in the file.
Preserve the component’s existing behavior and references.
- Around line 25-53: Update the great-circle example’s Map, MapArc, and
MapMarker elements to replace hardcoded orange/white colors with semantic
monochrome theme tokens, apply the 0.625rem base radius to labels, and change
the fixed 420px container height to mobile-first responsive height utilities.
Add the required fade-up, fade-in, or scale-in animation and stagger marker
animations with 100ms delays, including the hub and mapped destinations.

In `@src/registry/map.tsx`:
- Around line 1712-1714: Replace the multi-line greatCircle conditional in the
surrounding coordinate-building logic with a single-line guard that directly
returns buildGreatCircleCoordinates(from, to, samples), preserving the existing
condition and behavior.
🪄 Autofix

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: e03c5f95-dd14-475b-9fbb-ba97bb8394eb

📥 Commits

Reviewing files that changed from the base of the PR and between 874e2c9 and 7d1665c.

📒 Files selected for processing (5)
  • public/r/map.json
  • src/app/(main)/docs/_components/examples/great-circle-arc-example.tsx
  • src/app/(main)/docs/api-reference/page.tsx
  • src/app/(main)/docs/arcs/page.tsx
  • src/registry/map.tsx

Comment on lines +70 to +75
<DocsCode>path=&quot;greatCircle&quot;</DocsCode> to render the true
shortest path over the sphere (the orthodrome) instead. This is the
route an aircraft actually flies, so long-haul connections bend
toward the poles — the same London hub as above, but a London → New
York flight now arcs up over Greenland instead of straight across the
Atlantic. In this mode{" "}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Correct the aircraft-route description.

path="greatCircle" renders a spherical shortest-path approximation. It does not model the route an aircraft actually flies. The London-to-New York great circle does not pass over Greenland. Describe the path as poleward curvature, or use a route that demonstrates the stated geography.

🤖 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 `@src/app/`(main)/docs/arcs/page.tsx around lines 70 - 75, Correct the prose
accompanying the DocsCode example for path="greatCircle": describe it as a
spherical shortest-path approximation with poleward curvature, without claiming
it models an aircraft’s actual route or passes over Greenland. Keep the
example’s technical behavior unchanged.

Comment thread src/registry/map.tsx
Comment on lines +1667 to +1673
const segments = Math.max(2, Math.floor(samples));

// Degenerate cases: coincident points (d ~ 0) or near-antipodal points
// (sin(d) ~ 0, great circle not unique). Slerp is undefined here, so fall
// back to the unwrapped straight segment. Guarantees no NaN.
if (d < 1e-9 || sinD < 1e-9) {
return [from, [lng2, lat2]];

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

Normalize samples before generating coordinates.

Infinity makes segments infinite, so the coordinate loop never terminates. NaN skips the loop and returns a one-coordinate LineString. Normalize to a finite, bounded segment count and reuse it for both path modes.

  • src/registry/map.tsx#L1667-L1673: add a shared finite and maximum-bounded segment normalizer, then use it in both coordinate generators.
  • public/r/map.json#L17-L17: regenerate the embedded registry source with the same normalizer.
Proposed fix
+const MAX_ARC_SAMPLES = 512;
+
+function getArcSegments(samples: number) {
+  const finiteSamples = Number.isFinite(samples)
+    ? samples
+    : DEFAULT_ARC_SAMPLES;
+  return Math.min(MAX_ARC_SAMPLES, Math.max(2, Math.floor(finiteSamples)));
+}
+
-  const segments = Math.max(2, Math.floor(samples));
+  const segments = getArcSegments(samples);
📍 Affects 2 files
  • src/registry/map.tsx#L1667-L1673 (this comment)
  • public/r/map.json#L17-L17
🤖 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 `@src/registry/map.tsx` around lines 1667 - 1673, Normalize samples through a
shared finite, maximum-bounded segment-count helper before generating
coordinates, and reuse that count in both path-generation modes so Infinity and
NaN cannot produce non-terminating or one-coordinate results. Apply the source
change around the visible segment calculation and regenerate the embedded
registry source at src/registry/map.tsx lines 1667-1673 and public/r/map.json
line 17 with the same normalizer.

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