Skip to content

Add geographic coordinate detection feature#43

Merged
melihbirim merged 2 commits intomelihbirim:mainfrom
riazation42:main
Dec 28, 2025
Merged

Add geographic coordinate detection feature#43
melihbirim merged 2 commits intomelihbirim:mainfrom
riazation42:main

Conversation

@riazation42
Copy link
Copy Markdown
Contributor

Description

Adds support for detecting geographic coordinate pairs (latitude, longitude) in decimal degree format.

Related Issue

Fixes #161

Changes Made

  • Added COORDINATE data type constant in index.js
  • Implemented isCoordinate() validation function with lat/long range checks (-90 to 90, -180 to 180)
  • Added coordinate pattern to PATTERNS using precise regex validation
  • Updated TypeScript definitions in index.d.ts
  • Added 10 comprehensive tests covering valid/invalid coordinates, edge cases
  • Updated README.md with coordinate examples and documentation

Checklist

Required (PR will not be merged without these):

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

Code Quality:

  • Followed conventional commit format (feat:, fix:, docs:)
  • 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

123 passing (86ms)

All existing tests pass + 10 new coordinate detection tests:

  • Valid decimal degree coordinates
  • Boundary values (90, 180, -90, -180, 0, 0)
  • Various spacing formats
  • Out-of-range latitude/longitude rejection
  • Three-number string handling
  • Integration with infer() function

Examples

const predictDataTypes = require('predict-data-types');

predictDataTypes('40.7128, -74.0060');
// { '40.7128, -74.0060': 'coordinate' }

predictDataTypes.infer('51.5074, -0.1278');
// 'coordinate'

predictDataTypes.infer('91.0, 0.0');  // Out of range
// 'string'

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

- Add COORDINATE data type for detecting lat/long pairs
- Implement isCoordinate() validation function with range checks
- Add coordinate pattern to PATTERNS object using precise regex
- Update TypeScript definitions with coordinate type
- Add comprehensive test suite for coordinate detection
- Handle edge cases: invalid ranges, three numbers, spacing variations

Resolves #161
- Add coordinate to supported data types table
- Add coordinate example in infer() function
- Add DataTypes.COORDINATE constant
- Update test count from 113 to 123
@melihbirim melihbirim merged commit 818df9f into melihbirim:main Dec 28, 2025
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.

2 participants