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 🙏

© 2024 – Pkg Stats / Ryan Hefner

coordinate-parser

v1.0.7

Published

Geographical coordinate parser

Downloads

90,230

Readme

Coordinate Parser

Intelligent geographical coordinate parser in JavaScript

Flexible algorithm to parse strings containing various latitude/longitude formats.

Usage

Coordinates = require('coordinate-parser');

position = new Coordinates('40:7:22.8N 74:7:22.8W');

latitude = position.getLatitude(); // 40.123 ✓
longitude = position.getLongitude(); // -74.123 ✓

Supported formats

  • 40.123, -74.123
  • 40.123° N 74.123° W
  • 40° 7´ 22.8" N 74° 7´ 22.8" W
  • 40° 7.38’ , -74° 7.38’
  • N40°7’22.8, W74°7’22.8"
  • 40°7’22.8"N, 74°7’22.8"W
  • 40 7 22.8, -74 7 22.8
  • 40.123 -74.123
  • 40.123°,-74.123°
  • 144442800, -266842800
  • 40.123N74.123W
  • 4007.38N7407.38W
  • 40°7’22.8"N, 74°7’22.8"W
  • 400722.8N740722.8W
  • N 40 7.38 W 74 7.38
  • 40:7:23N,74:7:23W
  • 40:7:22.8N 74:7:22.8W
  • 40°7’23"N 74°7’23"W
  • 40°7’23" -74°7’23"
  • 40d 7’ 23" N 74d 7’ 23" W
  • 40.123N 74.123W
  • 40° 7.38, -74° 7.38

... and others that follow a similar pattern.

Handles also the following "exotic" formats:

  • 145505994.48, -268708007.88 (geographical milliseconds)
  • 4025.0999N7438.4668W (DDMM.xxxx)
  • 402505.994N743828.008W (DDMMSS.xxxx)

Coordinate validation

Input that does not resemble valid coordinates will throw an error.

The parser will detect invalid formats such as 40.123N FOOBAR 74.123W (invalid characters), 40.123W 74.123N (latitude/longitude exchanged) and 40.12 12.34 74.12 (odd numbers).

Flexibility towards non-alphanumeric characters and whitespaces is maintained.

isValidPosition = function(position) {
  var error;
  var isValid;
  try {
    isValid = true;
    new Coordinates(position);
    return isValid;
  } catch (error) {
    isValid = false;
    return isValid;
  }
};

isCoordinate = isValidPosition('40:7:22.8N 74:7:22.8W'); // true
isCoordinate = isValidPosition('40.123 FOOBAR! 74.123'); // false

Licence

This software is licensed under the Apache 2 license: http://www.apache.org/licenses/LICENSE-2.0

Copyright (C) 2016 WEPROG GmbH

Credit

Originally developed for WEPROG who kindly gave permission to open-source this code.