geo-coordinates-parser 1.5.5 → 1.5.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/converter.js CHANGED
@@ -78,7 +78,7 @@ function converter(coordsString, decimalPlaces) {
78
78
  }
79
79
 
80
80
  if (match[6]){
81
- ddLat += match[6]/3600;
81
+ ddLat += match[6].replace(',', '.')/3600;
82
82
  }
83
83
 
84
84
  if (parseInt(match[2]) < 0) {
@@ -92,7 +92,7 @@ function converter(coordsString, decimalPlaces) {
92
92
  }
93
93
 
94
94
  if (match[13]) {
95
- ddLng += match[13]/3600;
95
+ ddLng += match[13].replace(',', '.')/3600;
96
96
  }
97
97
 
98
98
  if (parseInt(match[9]) < 0) {
@@ -119,7 +119,7 @@ function converter(coordsString, decimalPlaces) {
119
119
 
120
120
  }
121
121
  else {
122
- throw new Error("invalid DMS coordinates format")
122
+ throw new Error("invalid DMS coordinates format")
123
123
  }
124
124
  }
125
125
  else if (dms_abbr.test(coordsString)) {
@@ -422,7 +422,7 @@ function coordsCloseEnough(coordsToTest) {
422
422
  var dd_re = /(NORTH|SOUTH|[NS])?[\s]*([+-]?[0-8]?[0-9](?:[\.,]\d{3,}))[\s]*([•º°]?)[\s]*(NORTH|SOUTH|[NS])?[\s]*[,/;]?[\s]*(EAST|WEST|[EW])?[\s]*([+-]?[0-1]?[0-9]?[0-9](?:[\.,]\d{3,}))[\s]*([•º°]?)[\s]*(EAST|WEST|[EW])?/i;
423
423
 
424
424
  //degrees minutes seconds with '.' as separator - gives array with 15 values
425
- 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;
425
+ 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;
426
426
 
427
427
  //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
428
428
  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;
package/failFormats.js CHANGED
@@ -11,6 +11,7 @@ const failingFormats = [
11
11
  'S 27.45.34 S 23.23.23', //invalid direction on right side
12
12
  'S 90°4\'17.698" S 23°4\'17.698"',
13
13
  '27.45.34 S S 23.23.23', //invalid direction on right side
14
+ '27.45.34 23.23.23 E' //no dir on one side
14
15
  ]
15
16
 
16
17
  module.exports = failingFormats
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "geo-coordinates-parser",
3
- "version": "1.5.5",
3
+ "version": "1.5.6",
4
4
  "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
5
  "main": "merge.js",
6
6
  "scripts": {
package/testIndividual.js CHANGED
@@ -1,5 +1,5 @@
1
1
  const convert = require('./converter')
2
- const test = 'S 27.45.34 S 23.23.23'
2
+ const test = '27.15.45,2S 18.32.53,4E'
3
3
 
4
4
  try{
5
5
  let converted = convert(test)
package/testformats.js CHANGED
@@ -273,6 +273,20 @@ var otherFormats = [
273
273
  decimalLatitude: -27.2625,
274
274
  decimalLongitude: 18.548055
275
275
  },
276
+ {
277
+ verbatimCoordinates: '27.15.45.2S 18.32.53.4E',
278
+ verbatimLatitude: '27.15.45.2S',
279
+ verbatimLongitude: '18.32.53.4E',
280
+ decimalLatitude: -27.262556,
281
+ decimalLongitude: 18.548167
282
+ },
283
+ {
284
+ verbatimCoordinates: '27.15.45,2S 18.32.53,4E',
285
+ verbatimLatitude: '27.15.45,2S',
286
+ verbatimLongitude: '18.32.53,4E',
287
+ decimalLatitude: -27.262556,
288
+ decimalLongitude: 18.548167
289
+ },
276
290
  {
277
291
  verbatimCoordinates: 'S23.43563 ° E22.45634 °', //decimals with spaces before the symbol!!
278
292
  verbatimLatitude: 'S23.43563 °',