Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

geo-coordinates-parser

Package Overview
Dependencies
Maintainers
1
Versions
43
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

geo-coordinates-parser - npm Package Compare versions

Comparing version 1.5.6 to 1.5.7

81

converter.js
//function for converting coordinates from a string to decimal and verbatim
//this is just a comment

@@ -18,3 +19,3 @@ const toCoordinateFormat = require('./toCoordinateFormat.js')

coordsString = coordsString.replace(/\s\s+/g, ' ').trim(); //just to tidy up whitespaces
coordsString = coordsString.replace(/\s+/g, ' ').trim(); //just to tidy up whitespaces

@@ -111,12 +112,3 @@ var ddLat = null;

lngdir = match[14];
}
else { //we have to catch an edge case where we have no direction indicators
throw new Error("invalid DMS coordinates format")
}
//we have to catch another edge case here, same or missing direction indicators
if(!latdir || !lngdir) {
throw new Error("invalid DMS coordinates format")
}
}
}

@@ -135,5 +127,2 @@ else {

ddLat += match[4]/60;
if(!match[3]) {
match[3] = ' ';
}
}

@@ -143,5 +132,2 @@

ddLat += match[6]/3600;
if(!match[5]) {
match[5] = ' ';
}
}

@@ -157,5 +143,2 @@

ddLng += match[12]/60;
if(!match[11]) {
match[11] = ' ';
}
}

@@ -165,5 +148,2 @@

ddLng += match[14]/3600;
if(!match[13]) {
match[13] = ' ';
}
}

@@ -197,5 +177,2 @@

ddLat += match[4]/60;
if(!match[3]) {
match[3] = ' ';
}
}

@@ -205,5 +182,2 @@

ddLat += match[6]/3600;
if(!match[5]) {
match[5] = ' ';
}
}

@@ -218,5 +192,2 @@

ddLng += match[12]/60;
if(!match[11]) {
match[11] = ' ';
}
}

@@ -226,5 +197,2 @@

ddLng += match[14]/3600;
if(!match[13]) {
match[13] = ' ';
}
}

@@ -250,14 +218,26 @@

//check longitude value - it can be wrong!
if (Math.abs(ddLng) >= 180) {
throw new Error("invalid longitude value")
}
if (matchSuccess){
//just to be safe check latitude also...
if (Math.abs(ddLat) >= 90) {
throw new Error("invalid latitude value")
}
if (matchSuccess){
//more validation....
//check longitude value - it can be wrong!
if (Math.abs(ddLng) >= 180) {
throw new Error("invalid longitude value")
}
//just to be safe check latitude also...
if (Math.abs(ddLat) >= 90) {
throw new Error("invalid latitude value")
}
//if we have one direction we must have the other
if((latdir || lngdir) && (!latdir || !lngdir)) {
throw new Error("invalid coordinates format")
}
//the directions can't be the same
if(latdir && latdir == lngdir) {
throw new Error("invalid coordinates format")
}
//make sure the signs and cardinal directions match

@@ -278,3 +258,2 @@ var patt = /S|SOUTH/i;

//we need to get the verbatim coords from the string

@@ -382,3 +361,3 @@ //we can't split down the middle because if there are decimals they may have different numbers on each side

//regex for testing corresponding values match
var numerictest = /^[-+]?\d+([\.,]{1}\d+)?$/; //for testing numeric values
var numerictest = /^[-+]?\d+([\.,]\d+)?$/; //for testing numeric values
var stringtest = /[eastsouthnorthwest]+/i; //for testing string values (north, south, etc)

@@ -438,9 +417,9 @@

//degrees minutes seconds with '.' as separator - gives array with 15 values
var dms_periods = /(NORTH|SOUTH|[NS])?\s*([+-]?[0-8]?[0-9])\s*(\.)\s*([0-5]?[0-9])\s*(\.)?\s*((?:[0-5]?[0-9])(?:[\.,]{1}\d{1,3})?)?\s*(NORTH|SOUTH|[NS])?(?:\s*[,/;]\s*|\s*)(EAST|WEST|[EW])?\s*([+-]?[0-1]?[0-9]?[0-9])\s*(\.)\s*([0-5]?[0-9])\s*(\.)?\s*((?:[0-5]?[0-9])(?:[\.,]\d{1,3})?)?\s*(EAST|WEST|[EW])?/i;
var dms_periods = /(NORTH|SOUTH|[NS])?\s*([+-]?[0-8]?[0-9])\s*(\.)\s*([0-5]?[0-9])\s*(\.)\s*((?:[0-5]?[0-9])(?:[\.,]\d{1,3})?)?\s*(NORTH|SOUTH|[NS])?(?:\s*[,/;]\s*|\s*)(EAST|WEST|[EW])?\s*([+-]?[0-1]?[0-9]?[0-9])\s*(\.)\s*([0-5]?[0-9])\s*(\.)\s*((?:[0-5]?[0-9])(?:[\.,]\d{1,3})?)?\s*(EAST|WEST|[EW])?/i;
//degrees minutes seconds with words 'degrees, minutes, seconds' as separators (needed because the s of seconds messes with the S of SOUTH) - gives array of 17 values
var dms_abbr = /(NORTH|SOUTH|[NS])?[\ \t]*([+-]?[0-8]?[0-9])[\ \t]*(D(?:EG)?(?:REES)?)[\ \t]*([0-5]?[0-9])[\ \t]*(M(?:IN)?(?:UTES)?)[\ \t]*((?:[0-5]?[0-9])(?:\.\d{1,3})?)?(S(?:EC)?(?:ONDS)?)?[\ \t]*(NORTH|SOUTH|[NS])?(?:[\ \t]*[,/;][\ \t]*|[\ \t]*)(EAST|WEST|[EW])?[\ \t]*([+-]?[0-1]?[0-9]?[0-9])[\ \t]*(D(?:EG)?(?:REES)?)[\ \t]*([0-5]?[0-9])[\ \t]*(M(?:IN)?(?:UTES)?)[\ \t]*((?:[0-5]?[0-9])(?:\.\d{1,3})?)?(S(?:EC)?(?:ONDS)?)[\ \t]*(EAST|WEST|[EW])?/i;
var dms_abbr = /(NORTH|SOUTH|[NS])?\s*([+-]?[0-8]?[0-9])\s*(D(?:EG)?(?:REES)?)\s*([0-5]?[0-9])\s*(M(?:IN)?(?:UTES)?)\s*((?:[0-5]?[0-9])(?:[\.,]\d{1,3})?)?\s*(S(?:EC)?(?:ONDS)?)?\s*(NORTH|SOUTH|[NS])?(?:\s*[,/;]\s*|\s*)(EAST|WEST|[EW])?\s*([+-]?[0-1]?[0-9]?[0-9])\s*(D(?:EG)?(?:REES)?)\s*([0-5]?[0-9])\s*(M(?:IN)?(?:UTES)?)\s*((?:[0-5]?[0-9])(?:[\.,]\d{1,3})?)?\s*(S(?:EC)?(?:ONDS)?)\s*(EAST|WEST|[EW])?/i;
//everything else - gives array of 17 values
var coords_other = /(NORTH|SOUTH|[NS])?[\ \t]*([+-]?[0-8]?[0-9])[\ \t]*([•º°\.:]|D(?:EG)?(?:REES)?)?[\ \t]*,?([0-5]?[0-9](?:\.\d{1,})?)?[\ \t]*(['′´’\.:]|M(?:IN)?(?:UTES)?)?[\ \t]*,?((?:[0-5]?[0-9])(?:\.\d{1,3})?)?[\ \t]*(''|′′|’’|´´|["″”\.])?[\ \t]*(NORTH|SOUTH|[NS])?(?:\s*[,/;]\s*|\s*)(EAST|WEST|[EW])?[\ \t]*([+-]?[0-1]?[0-9]?[0-9])[\ \t]*([•º°\.:]|D(?:EG)?(?:REES)?)?[\ \t]*,?([0-5]?[0-9](?:\.\d{1,})?)?[\ \t]*(['′´’\.:]|M(?:IN)?(?:UTES)?)?[\ \t]*,?((?:[0-5]?[0-9])(?:\.\d{1,3})?)?[\ \t]*(''|′′|´´|’’|["″”\.])?[\ \t]*(EAST|WEST|[EW])?/i;
var coords_other = /(NORTH|SOUTH|[NS])?\s*([+-]?[0-8]?[0-9])\s*([•º°\.:]|D(?:EG)?(?:REES)?)?\s*,?([0-5]?[0-9](?:[\.,]\d{1,})?)?\s*(['′´’\.:]|M(?:IN)?(?:UTES)?)?\s*,?((?:[0-5]?[0-9])(?:[\.,]\d{1,3})?)?\s*(''|′′|’’|´´|["″”\.])?\s*(NORTH|SOUTH|[NS])?(?:\s*[,/;]\s*|\s*)(EAST|WEST|[EW])?\s*([+-]?[0-1]?[0-9]?[0-9])\s*([•º°\.:]|D(?:EG)?(?:REES)?)?\s*,?([0-5]?[0-9](?:[\.,]\d{1,})?)?\s*(['′´’\.:]|M(?:IN)?(?:UTES)?)?\s*,?((?:[0-5]?[0-9])(?:[\.,]\d{1,3})?)?\s*(''|′′|´´|’’|["″”\.])?\s*(EAST|WEST|[EW])?/i;

@@ -447,0 +426,0 @@ const to = Object.freeze({

{
"name": "geo-coordinates-parser",
"version": "1.5.6",
"version": "1.5.7",
"description": "A Javascript function for reading a variety of coordinate formats and converting to decimal numbers. Builds on other efforts by returning the verbatim coordinates and the decimal coordinates all in one object.",

@@ -5,0 +5,0 @@ "main": "merge.js",

@@ -107,2 +107,9 @@ //return an array of coordinate strings for testing

{
verbatimCoordinates: '40°7’23"S 74°7’23"E',
verbatimLatitude: '40°7’23"S',
verbatimLongitude: '74°7’23"E',
decimalLatitude: -40.1230555555,
decimalLongitude: 74.12305555555555
},
{
verbatimCoordinates: '40°7’23" -74°7’23"',

@@ -276,2 +283,9 @@ verbatimLatitude: '40°7’23"',

decimalLongitude: 18.548055
},
{
verbatimCoordinates: '-27.15.45 18.32.53',
verbatimLatitude: '-27.15.45',
verbatimLongitude: '18.32.53',
decimalLatitude: -27.2625,
decimalLongitude: 18.548055
},

@@ -278,0 +292,0 @@ {

@@ -136,2 +136,9 @@ [

{
"verbatimCoordinates": "40°7’23\"S 74°7’23\"E",
"verbatimLatitude": "40°7’23\"S",
"verbatimLongitude": "74°7’23\"E",
"decimalLatitude": -40.1230555555,
"decimalLongitude": 74.12305555555555
},
{
"verbatimCoordinates": "40°7’23\" -74°7’23\"",

@@ -298,2 +305,23 @@ "verbatimLatitude": "40°7’23\"",

{
"verbatimCoordinates": "-27.15.45 18.32.53",
"verbatimLatitude": "-27.15.45",
"verbatimLongitude": "18.32.53",
"decimalLatitude": -27.2625,
"decimalLongitude": 18.548055
},
{
"verbatimCoordinates": "27.15.45.2S 18.32.53.4E",
"verbatimLatitude": "27.15.45.2S",
"verbatimLongitude": "18.32.53.4E",
"decimalLatitude": -27.262556,
"decimalLongitude": 18.548167
},
{
"verbatimCoordinates": "27.15.45,2S 18.32.53,4E",
"verbatimLatitude": "27.15.45,2S",
"verbatimLongitude": "18.32.53,4E",
"decimalLatitude": -27.262556,
"decimalLongitude": 18.548167
},
{
"verbatimCoordinates": "S23.43563 ° E22.45634 °",

@@ -318,3 +346,10 @@ "verbatimLatitude": "S23.43563 °",

"decimalLongitude": 23.38972222
},
{
"verbatimCoordinates": "S 27.45.34 E 23.23.23",
"verbatimLatitude": "S 27.45.34",
"verbatimLongitude": "E 23.23.23",
"decimalLatitude": -27.759444,
"decimalLongitude": 23.38972222
}
]
const convert = require('./converter')
const test = '27.15.45,2S 18.32.53,4E'
const test = '27.45.34 S S 23.23.23'

@@ -4,0 +4,0 @@ try{

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc