Skip to content

feat: Add Latitude/Longitude Coordinate Detector#44

Merged
melihbirim merged 4 commits intomainfrom
copilot/add-latitude-longitude-detector
Feb 22, 2026
Merged

feat: Add Latitude/Longitude Coordinate Detector#44
melihbirim merged 4 commits intomainfrom
copilot/add-latitude-longitude-detector

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Feb 22, 2026

Pull Request

Description

Adds geographic coordinate detection supporting decimal degree lat/lon pairs. Returns 'coordinate' for comma-separated pairs within valid ranges (lat: -90 to 90, lon: -180 to 180).

infer('40.7128, -74.0060') // → 'coordinate'
infer('0, 0')              // → 'coordinate'
infer('100, 50')           // → 'string' (lat out of range)
infer('45, 200')           // → 'string' (lon out of range)
infer('45.123')            // → 'number'  (single value)

Related Issue

Changes Made

  • Added isCoordinate() function in index.js using PATTERNS.COORDINATE regex with range validation
  • Added DataTypes.COORDINATE = 'coordinate' constant
  • Added special pre-split handling in predictDataTypes() so coordinate pairs aren't split on the comma
  • Added tests in test/index.spec.js covering valid pairs, boundary values, out-of-range lat/lon, single numbers, and three-number strings
  • Updated index.d.ts with 'coordinate' in DataType union and COORDINATE in DataTypes object
  • Updated README.md with coordinate type in supported types table, usage examples, and DataTypes.COORDINATE constant listing
  • Updated ROADMAP.md to mark Geographic Coordinates as completed (plain text, no emoji or strikethrough formatting)

Checklist

Required (PR will not be merged without these):

  • Synced with latest main branch (git rebase main)
  • All tests pass (npm test) — 123 passing
  • Linting passes (npm run lint)
  • README.md updated with:
    • Data type added to supported types list
    • Test count updated
    • Usage example added
  • TypeScript definitions added in index.d.ts
  • JSDoc documentation added for new functions

Code Quality:

  • Followed conventional commit format (feat:, fix:, style:, etc.)
  • Used single quotes (') not double quotes (")
  • No console.log statements in code
  • Functions added at the end of file (minimizes conflicts)
  • Test cases added at the end of test file
  • Pre-commit hook ran automatically (auto-fixed linting)

Test Results

  Coordinate detection
    ✔ should detect valid decimal degree coordinates
    ✔ should detect single coordinate pairs at boundaries
    ✔ should detect coordinates with various spacing
    ✔ should not detect coordinates with out-of-range latitude
    ✔ should not detect coordinates with out-of-range longitude
    ✔ should not detect single numbers as coordinates
    ✔ should not detect three numbers as coordinates
  infer - Coordinate detection
    ✔ should infer coordinate from valid pairs
    ✔ should infer coordinate from array of coordinates
    ✔ should not infer coordinate for out-of-range values

  123 passing (57ms)

Avoiding Conflicts

  • I have rebased on the latest main branch before creating this PR
  • I understand that if conflicts occur, I need to resolve them by rebasing again

Thank you for contributing! 🎉

See CONTRIBUTING.md for detailed guidelines.

Original prompt

This section details on the original issue you should resolve

<issue_title>Add Latitude/Longitude Detector</issue_title>
<issue_description>## 🎯 Goal
Add support for detecting geographic coordinates.

📝 What to do

Create a function that detects lat/long patterns like:

  • 40.7128, -74.0060 (decimal degrees)
  • 51.5074, -0.1278
  • Latitude range: -90 to 90
  • Longitude range: -180 to 180

💡 Example

// Valid coordinates
infer('40.7128, -74.0060') // Should return 'coordinates'
infer('51.5074, -0.1278') // Should return 'coordinates'
infer('0, 0') // Should return 'coordinates'

// NOT valid coordinates
infer('100, 50') // Lat out of range (-90 to 90), should return 'string'
infer('45, 200') // Lon out of range (-180 to 180), should return 'string'
infer('45.123') // Single number, should return 'number'
infer('abc, def') // Not numbers, should return 'string'

📂 Files to modify

  1. index.js - Add isCoordinates() function
  2. test/index.spec.js - Add tests
  3. index.d.ts - Add TypeScript definition

💻 Implementation hint

Check for comma-separated numbers with proper range validation. Look at isIPAddress() for range checking patterns!

Difficulty: ⭐ Easy | Time: 1-2 hours

Perfect for location-based apps! 🌍</issue_description>

<agent_instructions>follow yang and dry principals and add what is required.</agent_instructions>

Comments on the Issue (you are @copilot in this section)

@melihbirim It is your @riazation42 Please don't forget to update README.md file.

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@melihbirim melihbirim marked this pull request as ready for review February 22, 2026 23:04
@melihbirim melihbirim marked this pull request as draft February 22, 2026 23:05
Copilot AI and others added 2 commits February 22, 2026 23:06
Co-authored-by: melihbirim <398797+melihbirim@users.noreply.github.com>
Co-authored-by: melihbirim <398797+melihbirim@users.noreply.github.com>
Copilot AI changed the title [WIP] Add function to detect geographic coordinates feat: Add Latitude/Longitude Coordinate Detector Feb 22, 2026
Copilot AI requested a review from melihbirim February 22, 2026 23:08
Comment thread ROADMAP.md Outdated
Medium difficulty:

- Geographic coordinates
- ~~Geographic coordinates~~ ✅ (implemented)
Copy link
Copy Markdown
Owner

@melihbirim melihbirim Feb 22, 2026

Choose a reason for hiding this comment

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

Don't add emoji. And what is the reason of having ~~ here? @copilot

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Don't add emoji. And what is the reason of having ~~ here? @copilot

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Removed the strikethrough and emoji in b4eddca. The line now reads simply - Geographic coordinates (implemented).

Co-authored-by: melihbirim <398797+melihbirim@users.noreply.github.com>
@melihbirim melihbirim marked this pull request as ready for review February 22, 2026 23:19
@melihbirim melihbirim merged commit 0e5376d into main Feb 22, 2026
7 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.

Add Latitude/Longitude Detector

2 participants