npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

check-coord

v0.2.0

Published

A powerful coordinate format validation, conversion and analysis tool. Supports validation and geometric calculations for point, line, and region coordinates.

Readme

check-coord 🌏

A powerful coordinate format validation, conversion and analysis tool. Supports validation and geometric calculations for point, line, and region coordinates.

Languages: English | 中文

📥 Install

npm install check-coord

🎮 Usage

Basic Usage

const checkCoord = require('check-coord');

// Validate single point
const result = checkCoord("116.3978146455078,39.9076393154042");
console.log(result);

Advanced Usage

const { CoordinateValidator } = require('check-coord');
const ExtendedAPI = require('check-coord/src/extended-api');

// Use validator class directly
const validator = new CoordinateValidator();
const result = validator.validate("116.3978146455078,39.9076393154042");

// Use extended API for advanced features
const api = new ExtendedAPI();
const analysis = api.analyzeCoordinates("116.3978146455078,39.9076393154042;116.39652718518064,39.93344333054544");

📍 Examples

const checkCoord = require('check-coord');

// Single coordinate point
checkCoord("116.3978146455078,39.9076393154042");

// Coordinate line (2 points)
checkCoord("116.3978146455078,39.9076393154042;116.39652718518064,39.93344333054544");

// Coordinate region (3+ points)
checkCoord("116.3978146455078,39.9076393154042;116.39652718518064,39.93344333054544;116.41712655041502,39.93370658670286");

📐 Return Values

Basic Validation Result

// Single point
{
    isTrue: true,           // Validation result
    type: 'spot',          // Coordinate type: 'spot', 'line', or 'region'
    spots: [               // Array of coordinate objects
        {
            longitude: 116.3978146455078,  // Longitude (number)
            latitude: 39.9076393154042,    // Latitude (number)
            lng: 116.3978146455078,        // Longitude (backward compatibility)
            lat: 39.9076393154042          // Latitude (backward compatibility)
        }
    ]
}

// Line (2 points)
{
    isTrue: true,
    type: 'line',
    spots: [/* 2 coordinate objects */]
}

// Region (3+ points)
{
    isTrue: true,
    type: 'region',
    spots: [/* 3+ coordinate objects */],
    regionSpot: 3          // Number of points in the region
}

// Validation error
{
    isTrue: false,
    message: "Error in coordinate point 1: Invalid longitude format: 200, should be between -180 and 180",
    errorIndex: 0,
    errorCoordinate: "200,39.9076393154042"
}

🚀 Extended Features

The extended API provides additional functionality:

  • Format Conversion: Convert between decimal degrees and DMS (degrees-minutes-seconds)
  • Distance Calculation: Calculate distance between two points using Haversine formula
  • Area Calculation: Calculate polygon area using Shoelace formula
  • Batch Validation: Validate multiple coordinate strings at once
  • Point-in-Polygon: Check if a point lies within a polygon region

🧪 Testing

npm test           # Run basic tests
npm run test:extended  # Run extended functionality tests
npm run test:all   # Run all tests

📝 Changelog

v0.2.0

  • 🎯 Refactored code architecture for better maintainability
  • 🚀 Added extended features: distance calculation, area calculation, format conversion
  • ✅ Added comprehensive test coverage
  • 🐛 Fixed longitude/latitude field duplication bug
  • 📚 Added bilingual documentation support
  • 🔄 Maintained 100% backward compatibility