Registry / data / coordinate-parser

coordinate-parser

JSON →
library0.1.1jsnpmunverified

The `coordinate-parser` library provides a flexible algorithm for parsing strings that contain geographical coordinates in a wide variety of formats. It supports numerous representations including Decimal Degrees (DD), Degrees-Minutes-Seconds (DMS), Degrees-Decimal Minutes (DDM), and various 'exotic' formats like geographical milliseconds or compacted notations. The current stable version is 1.0.7, with the last release dating back to June 2017. As there have been no updates or maintenance activities since then, the package is effectively abandoned. A key differentiator is its robust input validation, which throws an error for any string that does not precisely conform to a recognized coordinate pattern, ensuring data integrity. It aims to simplify the extraction of latitude and longitude from complex user inputs into standardized decimal degree values.

npm install coordinate-parser
INSTALL
IMPORT
SIG · COORDINATE-PARSER
C
coordinate-parser
datajavascriptv0.1.1
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Coordinates
const Coordinates = require('coordinate-parser');
import Coordinates from 'coordinate-parser'; import { Coordinates } from 'coordinate-parser';
This package is a CommonJS module. Direct ES module `import` syntax will fail without a transpiler or CJS interop layer, as there is no `default` export for ESM and no named exports.

This quickstart demonstrates parsing various coordinate formats (DMS, DD) and using the built-in validation mechanism to check input validity.

const Coordinates = require('coordinate-parser'); try { // Parsing a standard Degrees-Minutes-Seconds (DMS) coordinate string const position1 = new Coordinates('40° 7´ 22.8" N 74° 7´ 22.8" W'); console.log(`Latitude (DMS): ${position1.getLatitude()}`); console.log(`Longitude (DMS): ${position1.getLongitude()}`); // Parsing a Decimal Degrees (DD) string const position2 = new Coordinates('40.123, -74.123'); console.log(`Latitude (DD): ${position2.getLatitude()}`); console.log(`Longitude (DD): ${position2.getLongitude()}`); // Example of using the built-in validation via try-catch const isValidPosition = function(input) { try { new Coordinates(input); return true; } catch (error) { console.error(`Validation error for "${input}": ${error.message}`); return false; } }; console.log(`Is '40.123N 74.123W' valid? ${isValidPosition('40.123N 74.123W')}`); console.log(`Is '40.123 FOOBAR! 74.123' valid? ${isValidPosition('40.123 FOOBAR! 74.123')}`); } catch (e) { console.error("An unexpected error occurred during quickstart execution:", e); }
Debug
Known issues
breakingThe `coordinate-parser` package is effectively abandoned. Its last update was in June 2017. This means there will be no further bug fixes, new features, or security patches, making it potentially vulnerable or incompatible with newer Node.js versions or evolving JavaScript ecosystems.
fix
Thoroughly audit the package's source code before use. For new projects or critical applications, consider migrating to a more actively maintained library for geographical coordinate parsing, or prepare to fork and maintain the code yourself.
affects: >=1.0.0
gotchaStrict input validation: The parser aggressively validates input strings, throwing an `Error` for any string that does not precisely conform to a recognized coordinate format. This includes malformed syntax, unknown characters, or swapped latitude/longitude components.
fix
Always wrap calls to `new Coordinates(inputString)` in a `try...catch` block to gracefully handle invalid user input or unexpected formats. Implement custom pre-validation if specific input patterns are expected.
affects: >=1.0.0
gotchaCommonJS only: The package is published exclusively as a CommonJS module. It does not natively support ES Modules (`import/export`) without a transpiler or Node.js's CJS-ESM interop layer. Direct `import` statements in pure ESM environments will likely result in runtime errors.
fix
Use `const Coordinates = require('coordinate-parser');` in Node.js environments. For browser use or pure ESM projects, ensure your build pipeline (e.g., Webpack, Rollup) is configured to handle CommonJS modules, or consider using dynamic `import('coordinate-parser').then(module => new module.Coordinates(...))`.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: Coordinates is not a constructor
Attempting to use ES module `import` syntax (e.g., `import { Coordinates } from 'coordinate-parser';` or `import Coordinates from 'coordinate-parser';`) with this CommonJS-only package.
fix
Change the import statement to `const Coordinates = require('coordinate-parser');`.
Error: Input does not resemble a valid coordinate format
The string passed to the `Coordinates` constructor does not match any of the library's recognized geographical coordinate patterns, contains invalid characters, or has an incorrect structure.
fix
Review the input string for typos or incorrect formatting. Ensure it strictly adheres to one of the supported formats. Implement a `try...catch` block around the constructor call to handle invalid inputs gracefully, as demonstrated in the quickstart.
Upgrade
Version history
0.1.1latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
9 hits · last 30 days
node
8
OpenAI (training)
1
Resources
coordinate-parser — npm install coordinate-parser · libregistry