Skip to content

feat(geocode): parse typed coordinates in the search box - #177

Open
yellowhat wants to merge 5 commits into
GeiserX:mainfrom
yellowhat:feat/geocode-typed-coordinates
Open

yellowhat wants to merge 5 commits into
GeiserX:mainfrom
yellowhat:feat/geocode-typed-coordinates

Conversation

@yellowhat

@yellowhat yellowhat commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

Typing or pasting coordinates into the origin or destination box now resolves to that exact point, without calling Photon. Before this change, Photon got the coordinates as a text query and returned fuzzy, often wrong, matches.

Supported formats (latitude first)

Format Example
Decimal degrees 40.741895, -73.989308 · 40.4168 -3.7038
With degree sign / hemisphere 40.7419°N 73.9893°W · N 40.7419 W 73.9893
DMS 40°44'30.8"N 73°59'21.5"W (also ′ ″ and space-separated)
DDM 40° 44.514' N, 73° 59.359' W
Hemisphere-swapped order 73.9893 W 40.7419 N
European decimal commas 40,7419; -73,9893 · 40,7419 -73,9893

Inputs that are ambiguous or invalid are rejected and go to Photon as before:

  • lone whole numbers: 28, 3, 40,74
  • out of range: lat > 90, lon > 180
  • minutes or seconds ≥ 60
  • a minus sign with a hemisphere letter: -40.7 S
  • two latitudes or two longitudes
  • more than two components

Summary by CodeRabbit

  • New Features
    • Search boxes now recognize typed latitude/longitude coordinates, including decimal, directional, and degree-minute-second formats. Valid coordinates return a location directly without a Photon lookup; unsupported or ambiguous entries continue to use the standard search.
  • Documentation
    • Updated search and API guidance to explain coordinate entry, behavior when Photon is unavailable, and the responses returned for coordinate queries.

Parse coordinates typed into the search box (latitude first) into
[lon, lat]. Supports decimal degrees, DMS (40°44'30.8"N 73°59'21.5"W),
DDM (40° 44.514' N), and N/S/E/W hemisphere letters before or after the
number, in either order (73 W 40 N).

Inputs that are ambiguous or out of range are rejected and left for
Photon: lone whole numbers ("28, 3"), lat > 90, lon > 180, minutes or
seconds >= 60, a minus sign combined with a hemisphere letter, and two
latitudes or two longitudes.

Not wired into geocode() yet.
When the input has no dot and doesn't parse as-is, retry with commas
between digits read as decimal points, so "40,7419; -73,9893",
"40,7419, -73,9893" and "40,7419 -73,9893" all resolve.

Inputs with a dot never use the comma retry. Short pairs like "40,74"
and "40,5 3" are still rejected, so ordinary queries like "28,3" keep
going to Photon.
If the query parses as coordinates, geocode() returns a single result
at that point, using the trimmed query as its name, and doesn't call
Photon. Pasting "40.741895, -73.989308" into the origin or destination
box now resolves to that exact spot instead of a fuzzy text match.

This also works when PHOTON_URL is not set.
@coderabbitai

coderabbitai Bot commented Oct 3, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

⚙️ Run configuration
  • Configuration used: Repository: GeiserX/Pumperly/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 4a321e1f-6469-46a8-b432-cd1425f28ce2
📥 Commits

Reviewing files that changed from the base of the PR and between 5d8c38e and 862f386.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: GeiserX/Pumperly/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 81ec2008-f610-4d8b-bb2c-76bfd1e8c9db
📥 Commits

Reviewing files that changed from the base of the PR and between 1b34cd5 and 5d8c38e.

📒 Files selected for processing (5)
  • docs/configuration/geocoding-photon.md
  • docs/reference/api.md
  • docs/using/routes.md
  • src/lib/photon.test.ts
  • src/lib/photon.ts

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

Coordinate queries are parsed locally and return one geocoding result without a Photon request. Other queries continue through the Photon lookup path. Documentation describes supported coordinate formats and API behavior.

Changes

Coordinate Input Geocoding

Layer / File(s) Summary
Coordinate parsing
src/lib/photon.ts, src/lib/photon.test.ts, docs/using/routes.md
parseCoordinates accepts decimal, DMS, and DDM coordinates, validates their components and ranges, and returns longitude-latitude pairs. Tests cover supported formats and rejected inputs. The route documentation describes accepted formats and fallback behavior.
Local coordinate geocoding
src/lib/photon.ts, src/lib/photon.test.ts, docs/reference/api.md, docs/configuration/geocoding-photon.md, docs/using/routes.md
geocode returns a result with the trimmed query as its name when coordinate parsing succeeds. Tests verify the result and that it does not call fetch. The documentation describes the API result and search behavior when Photon is unavailable.

Priority: ➖ Normal

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

Change: Feature

Merge Risk: ⚪ Minimal · up to 5d8c3

Typed coordinates in the search boxes now resolve locally without Photon, and other queries behave as before. No merge-blocking issue was identified.

Security Architecture Review

Security architecture risk: ⚪ Minimal · up to 5d8c3

Recognized coordinates use the existing result format and route-selection paths without adding privileges or bypassing request validation. No material security risk was found in the changed flow.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The inspected exposure remains the public geocode response and existing route-selection consumers. The new branch does not introduce tenant identity, credential use, asset access, or persistent writes.

Trust Boundaries and Controls

  • observed — User input still passes API parameter validation before geocode executes. Successful coordinate parsing bypasses the external provider, not the API validation boundary; rejected coordinate syntax follows the existing provider lookup.

Resilience and Maintainability Implications

  • inferred — Tokenizer state does not create a cross-request transition in the inspected implementation: each invocation resets the shared regular-expression index and completes synchronously before geocode reaches any asynchronous provider work.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 42.86% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 7 functions across 2 files. (3 skipped: 3… Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 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 main change: parsing typed coordinates in the search box.
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.
Full details: Docstring Coverage

Explanation

Docstring coverage is 42.86% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 7 functions across 2 files. (3 skipped: 3 unsupported.)

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

Add a "Typing coordinates" section to the route guide that lists the
accepted formats. Fix three places that said search finds nothing
without Photon: typed coordinates now work without it. The
/api/geocode reference now covers the single result it returns for a
coordinate query.

This branch has not been deployed

No deployments
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