geo-coordinates-parser 1.6.6 → 1.7.1

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/README.md CHANGED
@@ -72,6 +72,9 @@ Formats used for testing can be be accessed with:
72
72
  convert.formats
73
73
  ```
74
74
 
75
+ **Please note that decimal precision needs to be reasonable. The maximum decimal places allowed in DMS, for example, is three (3). DMS coordinates with four decimal places in seconds are measuring position at a precision of less than
76
+ 10mm, which is way beyond what even the best professional GPS devices can provide.**
77
+
75
78
  **Please add coordinate formats that throw an error in the Github Issues.**
76
79
 
77
80
  **CAUTION!!!**
@@ -25,7 +25,24 @@ function converter(coordsString, decimalPlaces) {
25
25
  let lngdir = "";
26
26
  let match = [];
27
27
  let matchSuccess = false;
28
- if (regex_js_1.dd_re.test(coordsString)) {
28
+ if (regex_js_1.dm_numbers.test(coordsString)) {
29
+ match = regex_js_1.dm_numbers.exec(coordsString);
30
+ matchSuccess = checkMatch(match);
31
+ if (matchSuccess) {
32
+ ddLat = Math.abs(match[1]) + match[2] / 60;
33
+ if (Number(match[1]) < 0) {
34
+ ddLat *= -1;
35
+ }
36
+ ddLng = Math.abs(match[3]) + match[4] / 60;
37
+ if (Number(match[3]) < 0) {
38
+ ddLng *= -1;
39
+ }
40
+ }
41
+ else {
42
+ throw new Error("invalid coordinate format");
43
+ }
44
+ }
45
+ else if (regex_js_1.dd_re.test(coordsString)) {
29
46
  match = regex_js_1.dd_re.exec(coordsString);
30
47
  matchSuccess = checkMatch(match);
31
48
  if (matchSuccess) {
@@ -122,6 +139,7 @@ function converter(coordsString, decimalPlaces) {
122
139
  if (parseInt(match[10]) < 0) {
123
140
  ddLng = -1 * ddLng;
124
141
  }
142
+ //the compass directions
125
143
  if (match[1]) {
126
144
  latdir = match[1];
127
145
  lngdir = match[9];
@@ -141,24 +159,25 @@ function converter(coordsString, decimalPlaces) {
141
159
  if (matchSuccess) {
142
160
  ddLat = Math.abs(parseInt(match[2]));
143
161
  if (match[4]) {
144
- ddLat += match[4] / 60;
162
+ ddLat += match[4].replace(',', '.') / 60;
145
163
  }
146
164
  if (match[6]) {
147
- ddLat += match[6] / 3600;
165
+ ddLat += match[6].replace(',', '.') / 3600;
148
166
  }
149
167
  if (parseInt(match[2]) < 0) {
150
168
  ddLat = -1 * ddLat;
151
169
  }
152
170
  ddLng = Math.abs(parseInt(match[10]));
153
171
  if (match[12]) {
154
- ddLng += match[12] / 60;
172
+ ddLng += match[12].replace(',', '.') / 60;
155
173
  }
156
174
  if (match[14]) {
157
- ddLng += match[14] / 3600;
175
+ ddLng += match[14].replace(',', '.') / 3600;
158
176
  }
159
177
  if (parseInt(match[10]) < 0) {
160
178
  ddLng = -1 * ddLng;
161
179
  }
180
+ //the compass directions
162
181
  if (match[1]) {
163
182
  latdir = match[1];
164
183
  lngdir = match[9];
@@ -183,8 +202,8 @@ function converter(coordsString, decimalPlaces) {
183
202
  throw new Error("invalid latitude value");
184
203
  }
185
204
  //if we have one direction we must have the other
186
- if ((latdir || lngdir) && (!latdir || !lngdir)) {
187
- throw new Error("invalid coordinates format");
205
+ if ((latdir && !lngdir) || (!latdir && lngdir)) {
206
+ throw new Error("invalid coordinates value");
188
207
  }
189
208
  //the directions can't be the same
190
209
  if (latdir && latdir == lngdir) {
@@ -262,20 +281,19 @@ function converter(coordsString, decimalPlaces) {
262
281
  }
263
282
  }
264
283
  //no integer coords allowed
265
- //validation -- no integer coords
266
284
  if (/^\d+$/.test(verbatimLat) || /^\d+$/.test(verbatimLng)) {
267
285
  throw new Error('degree only coordinate/s provided');
268
286
  }
269
- //some tidying up...
287
+ // last bit of tidying up...
270
288
  if (isNaN(ddLat) && ddLat.includes(',')) {
271
289
  ddLat = ddLat.replace(',', '.');
272
290
  }
273
- //all done!!
274
- //just truncate the decimals appropriately
275
- ddLat = Number(Number(ddLat).toFixed(decimalPlaces));
276
291
  if (isNaN(ddLng) && ddLng.includes(',')) {
277
292
  ddLng = ddLng.replace(',', '.');
278
293
  }
294
+ //all done!!
295
+ //just truncate the decimals appropriately
296
+ ddLat = Number(Number(ddLat).toFixed(decimalPlaces));
279
297
  ddLng = Number(Number(ddLng).toFixed(decimalPlaces));
280
298
  return Object.freeze({
281
299
  verbatimCoordinates,
@@ -300,11 +318,11 @@ function checkMatch(match) {
300
318
  const filteredMatch = [...match];
301
319
  //we need to shift the array because it contains the whole coordinates string in the first item
302
320
  filteredMatch.shift();
303
- //check the array length is an even number else exit
321
+ //check the array length is an even number
304
322
  if (filteredMatch.length % 2 > 0) {
305
323
  return false;
306
324
  }
307
- //regex for testing corresponding values match
325
+ // regex for testing corresponding values match
308
326
  const numerictest = /^[-+]?\d+([\.,]\d+)?$/; //for testing numeric values
309
327
  const stringtest = /[eastsouthnorthwest]+/i; //for testing string values (north, south, etc)
310
328
  const halflen = filteredMatch.length / 2;
@@ -355,6 +373,7 @@ function coordsCloseEnough(coordsToTest) {
355
373
  throw new Error("coords being tested must be separated by a comma");
356
374
  }
357
375
  }
376
+ // An enum for coordinates formats
358
377
  const to = Object.freeze({
359
378
  DMS: 'DMS',
360
379
  DM: 'DM',
@@ -1,3 +1,4 @@
1
+ export const dm_numbers: RegExp;
1
2
  export const dd_re: RegExp;
2
3
  export const dms_periods: RegExp;
3
4
  export const dms_abbr: RegExp;
package/dist/cjs/regex.js CHANGED
@@ -1,7 +1,10 @@
1
1
  "use strict";
2
2
  //Coordinates pattern matching regex
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.coords_other = exports.dms_abbr = exports.dms_periods = exports.dd_re = void 0;
4
+ exports.coords_other = exports.dms_abbr = exports.dms_periods = exports.dd_re = exports.dm_numbers = void 0;
5
+ //DM as numbers only - see issue #15
6
+ const dm_numbers = /([+-]?[0-8]?[0-9])\s+([0-5]?[0-9]\.\d{3,})[\s,]{1,}([+-]?[0-1]?[0-9]?[0-9])\s+([0-5]?[0-9]\.\d{3,})/;
7
+ exports.dm_numbers = dm_numbers;
5
8
  //decimal degrees
6
9
  const 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;
7
10
  exports.dd_re = dd_re;
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ // just for counting the number of test objects in the json file
4
+ // remember if you run makeTestFormatsJSON from the debugger it puts the new json file in the root directory so you have to move it here
5
+ const data = require('./testFormats.json');
6
+ let i = 0;
@@ -0,0 +1 @@
1
+ export {};
@@ -1,10 +1,12 @@
1
1
  "use strict";
2
+ // when adding new formats, make sure to add them to testformats.js, and not to testFormats.json
3
+ // use makeTestFormatsJSON.js to make testFormats.json
2
4
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
5
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
6
  };
5
7
  Object.defineProperty(exports, "__esModule", { value: true });
6
8
  const converter_js_1 = __importDefault(require("../converter.js"));
7
- const testformats_js_1 = __importDefault(require("../testformats.js"));
9
+ const testformats_js_1 = __importDefault(require("./testformats.js"));
8
10
  const failFormats_js_1 = __importDefault(require("./failFormats.js"));
9
11
  let allPassed = true;
10
12
  //FORMATS THAT SHOULD BE CONVERTED
@@ -8,13 +8,13 @@ let test = {
8
8
  decimalCoordinates: '-24.3456, 28.92435',
9
9
  toCoordinateFormat: toCoordinateFormat_js_1.default
10
10
  };
11
- console.log(test.toCoordinateFormat('DMS'));
11
+ console.log(test.decimalCoordinates, '==', test.toCoordinateFormat('DMS'));
12
12
  test.decimalCoordinates = '-25.76887,28.26939';
13
- console.log(test.toCoordinateFormat('DMS'));
14
- console.log(test.toCoordinateFormat('DM'));
15
- console.log(test.toCoordinateFormat('DD'));
13
+ console.log(test.decimalCoordinates, '==', test.toCoordinateFormat('DMS'));
14
+ console.log(test.decimalCoordinates, '==', test.toCoordinateFormat('DM'));
15
+ console.log(test.decimalCoordinates, '==', test.toCoordinateFormat('DD'));
16
16
  test.decimalCoordinates = '-25.815928, 28.070318';
17
- console.log(test.toCoordinateFormat('DM'));
17
+ console.log(test.decimalCoordinates, '==', test.toCoordinateFormat('DM'));
18
18
  test.decimalCoordinates = '-25.000, 28.000';
19
- console.log(test.toCoordinateFormat('DMS'));
20
- console.log(test.toCoordinateFormat('DM'));
19
+ console.log(test.decimalCoordinates, '==', test.toCoordinateFormat('DMS'));
20
+ console.log(test.decimalCoordinates, '==', test.toCoordinateFormat('DM'));
@@ -0,0 +1,394 @@
1
+ [
2
+ {
3
+ "verbatimCoordinates": "40.123, -74.123",
4
+ "verbatimLatitude": "40.123",
5
+ "verbatimLongitude": "-74.123",
6
+ "decimalLatitude": 40.123,
7
+ "decimalLongitude": -74.123
8
+ },
9
+ {
10
+ "verbatimCoordinates": "40.123° N 74.123° W",
11
+ "verbatimLatitude": "40.123° N",
12
+ "verbatimLongitude": "74.123° W",
13
+ "decimalLatitude": 40.123,
14
+ "decimalLongitude": -74.123
15
+ },
16
+ {
17
+ "verbatimCoordinates": "40.123° N 74.123° W",
18
+ "verbatimLatitude": "40.123° N",
19
+ "verbatimLongitude": "74.123° W",
20
+ "decimalLatitude": 40.123,
21
+ "decimalLongitude": -74.123
22
+ },
23
+ {
24
+ "verbatimCoordinates": "40° 7´ 22.8\" N 74° 7´ 22.8\" W",
25
+ "verbatimLatitude": "40° 7´ 22.8\" N",
26
+ "verbatimLongitude": "74° 7´ 22.8\" W",
27
+ "decimalLatitude": 40.123,
28
+ "decimalLongitude": -74.123
29
+ },
30
+ {
31
+ "verbatimCoordinates": "40° 7.38’ , -74° 7.38’",
32
+ "verbatimLatitude": "40° 7.38’",
33
+ "verbatimLongitude": "-74° 7.38’",
34
+ "decimalLatitude": 40.123,
35
+ "decimalLongitude": -74.123
36
+ },
37
+ {
38
+ "verbatimCoordinates": "N40°7’22.8’’, W74°7’22.8’’",
39
+ "verbatimLatitude": "N40°7’22.8’’",
40
+ "verbatimLongitude": "W74°7’22.8’’",
41
+ "decimalLatitude": 40.123,
42
+ "decimalLongitude": -74.123
43
+ },
44
+ {
45
+ "verbatimCoordinates": "40°7’22.8\"N, 74°7’22.8\"W",
46
+ "verbatimLatitude": "40°7’22.8\"N",
47
+ "verbatimLongitude": "74°7’22.8\"W",
48
+ "decimalLatitude": 40.123,
49
+ "decimalLongitude": -74.123
50
+ },
51
+ {
52
+ "verbatimCoordinates": "40°7'22.8\"N, 74°7'22.8\"W",
53
+ "verbatimLatitude": "40°7'22.8\"N",
54
+ "verbatimLongitude": "74°7'22.8\"W",
55
+ "decimalLatitude": 40.123,
56
+ "decimalLongitude": -74.123
57
+ },
58
+ {
59
+ "verbatimCoordinates": "40 7 22.8, -74 7 22.8",
60
+ "verbatimLatitude": "40 7 22.8",
61
+ "verbatimLongitude": "-74 7 22.8",
62
+ "decimalLatitude": 40.123,
63
+ "decimalLongitude": -74.123
64
+ },
65
+ {
66
+ "verbatimCoordinates": "40.123 -74.123",
67
+ "verbatimLatitude": "40.123",
68
+ "verbatimLongitude": "-74.123",
69
+ "decimalLatitude": 40.123,
70
+ "decimalLongitude": -74.123
71
+ },
72
+ {
73
+ "verbatimCoordinates": "40.123°,-74.123°",
74
+ "verbatimLatitude": "40.123°",
75
+ "verbatimLongitude": "-74.123°",
76
+ "decimalLatitude": 40.123,
77
+ "decimalLongitude": -74.123
78
+ },
79
+ {
80
+ "verbatimCoordinates": "40.123N74.123W",
81
+ "verbatimLatitude": "40.123N",
82
+ "verbatimLongitude": "74.123W",
83
+ "decimalLatitude": 40.123,
84
+ "decimalLongitude": -74.123
85
+ },
86
+ {
87
+ "verbatimCoordinates": "4007.38N7407.38W",
88
+ "verbatimLatitude": "4007.38N",
89
+ "verbatimLongitude": "7407.38W",
90
+ "decimalLatitude": 40.123,
91
+ "decimalLongitude": -74.123
92
+ },
93
+ {
94
+ "verbatimCoordinates": "40°7’22.8\"N, 74°7’22.8\"W",
95
+ "verbatimLatitude": "40°7’22.8\"N",
96
+ "verbatimLongitude": "74°7’22.8\"W",
97
+ "decimalLatitude": 40.123,
98
+ "decimalLongitude": -74.123
99
+ },
100
+ {
101
+ "verbatimCoordinates": "400722.8N740722.8W",
102
+ "verbatimLatitude": "400722.8N",
103
+ "verbatimLongitude": "740722.8W",
104
+ "decimalLatitude": 40.123,
105
+ "decimalLongitude": -74.123
106
+ },
107
+ {
108
+ "verbatimCoordinates": "N 40 7.38 W 74 7.38",
109
+ "verbatimLatitude": "N 40 7.38",
110
+ "verbatimLongitude": "W 74 7.38",
111
+ "decimalLatitude": 40.123,
112
+ "decimalLongitude": -74.123
113
+ },
114
+ {
115
+ "verbatimCoordinates": "40:7:22.8N 74:7:22.8W",
116
+ "verbatimLatitude": "40:7:22.8N",
117
+ "verbatimLongitude": "74:7:22.8W",
118
+ "decimalLatitude": 40.123,
119
+ "decimalLongitude": -74.123
120
+ },
121
+ {
122
+ "verbatimCoordinates": "40:7:23N,74:7:23W",
123
+ "verbatimLatitude": "40:7:23N",
124
+ "verbatimLongitude": "74:7:23W",
125
+ "decimalLatitude": 40.1230555555,
126
+ "decimalLongitude": -74.1230555555
127
+ },
128
+ {
129
+ "verbatimCoordinates": "40°7’23\"N 74°7’23\"W",
130
+ "verbatimLatitude": "40°7’23\"N",
131
+ "verbatimLongitude": "74°7’23\"W",
132
+ "decimalLatitude": 40.1230555555,
133
+ "decimalLongitude": -74.12305555555555
134
+ },
135
+ {
136
+ "verbatimCoordinates": "40°7’23\"S 74°7’23\"E",
137
+ "verbatimLatitude": "40°7’23\"S",
138
+ "verbatimLongitude": "74°7’23\"E",
139
+ "decimalLatitude": -40.1230555555,
140
+ "decimalLongitude": 74.12305555555555
141
+ },
142
+ {
143
+ "verbatimCoordinates": "40°7’23\" -74°7’23\"",
144
+ "verbatimLatitude": "40°7’23\"",
145
+ "verbatimLongitude": "-74°7’23\"",
146
+ "decimalLatitude": 40.1230555555,
147
+ "decimalLongitude": -74.123055555
148
+ },
149
+ {
150
+ "verbatimCoordinates": "40d 7’ 23\" N 74d 7’ 23\" W",
151
+ "verbatimLatitude": "40d 7’ 23\" N",
152
+ "verbatimLongitude": "74d 7’ 23\" W",
153
+ "decimalLatitude": 40.1230555555,
154
+ "decimalLongitude": -74.123055555
155
+ },
156
+ {
157
+ "verbatimCoordinates": "40.123N 74.123W",
158
+ "verbatimLatitude": "40.123N",
159
+ "verbatimLongitude": "74.123W",
160
+ "decimalLatitude": 40.123,
161
+ "decimalLongitude": -74.123
162
+ },
163
+ {
164
+ "verbatimCoordinates": "40° 7.38, -74° 7.38",
165
+ "verbatimLatitude": "40° 7.38",
166
+ "verbatimLongitude": "-74° 7.38",
167
+ "decimalLatitude": 40.123,
168
+ "decimalLongitude": -74.123
169
+ },
170
+ {
171
+ "verbatimCoordinates": "40° 7.38, -74° 7.38",
172
+ "verbatimLatitude": "40° 7.38",
173
+ "verbatimLongitude": "-74° 7.38",
174
+ "decimalLatitude": 40.123,
175
+ "decimalLongitude": -74.123
176
+ },
177
+ {
178
+ "verbatimCoordinates": "40 7 22.8; -74 7 22.8",
179
+ "verbatimLatitude": "40 7 22.8",
180
+ "verbatimLongitude": "-74 7 22.8",
181
+ "decimalLatitude": 40.123,
182
+ "decimalLongitude": -74.123
183
+ },
184
+ {
185
+ "verbatimCoordinates": "50°4'17.698\"south, 14°24'2.826\"east",
186
+ "verbatimLatitude": "50°4'17.698\"south",
187
+ "verbatimLongitude": "14°24'2.826\"east",
188
+ "decimalLatitude": -50.07158277777778,
189
+ "decimalLongitude": 14.400785
190
+ },
191
+ {
192
+ "verbatimCoordinates": "50d4m17.698S 14d24m2.826E",
193
+ "verbatimLatitude": "50d4m17.698S",
194
+ "verbatimLongitude": "14d24m2.826E",
195
+ "decimalLatitude": -50.07158277777778,
196
+ "decimalLongitude": 14.400785
197
+ },
198
+ {
199
+ "verbatimCoordinates": "40:26:46N,79:56:55W",
200
+ "verbatimLatitude": "40:26:46N",
201
+ "verbatimLongitude": "79:56:55W",
202
+ "decimalLatitude": 40.44611111111111,
203
+ "decimalLongitude": -79.9486111111111
204
+ },
205
+ {
206
+ "verbatimCoordinates": "40:26:46.302N 79:56:55.903W",
207
+ "verbatimLatitude": "40:26:46.302N",
208
+ "verbatimLongitude": "79:56:55.903W",
209
+ "decimalLatitude": 40.446195,
210
+ "decimalLongitude": -79.94886194444445
211
+ },
212
+ {
213
+ "verbatimCoordinates": "40°26′47″N 79°58′36″W",
214
+ "verbatimLatitude": "40°26′47″N",
215
+ "verbatimLongitude": "79°58′36″W",
216
+ "decimalLatitude": 40.44638888888889,
217
+ "decimalLongitude": -79.97666666666667
218
+ },
219
+ {
220
+ "verbatimCoordinates": "40d 26′ 47″ N 79d 58′ 36″ W",
221
+ "verbatimLatitude": "40d 26′ 47″ N",
222
+ "verbatimLongitude": "79d 58′ 36″ W",
223
+ "decimalLatitude": 40.44638888888889,
224
+ "decimalLongitude": -79.97666666666667
225
+ },
226
+ {
227
+ "verbatimCoordinates": "40.446195N 79.948862W",
228
+ "verbatimLatitude": "40.446195N",
229
+ "verbatimLongitude": "79.948862W",
230
+ "decimalLatitude": 40.446195,
231
+ "decimalLongitude": -79.948862
232
+ },
233
+ {
234
+ "verbatimCoordinates": "40,446195° 79,948862°",
235
+ "verbatimLatitude": "40,446195°",
236
+ "verbatimLongitude": "79,948862°",
237
+ "decimalLatitude": 40.446195,
238
+ "decimalLongitude": 79.948862
239
+ },
240
+ {
241
+ "verbatimCoordinates": "40° 26.7717, -79° 56.93172",
242
+ "verbatimLatitude": "40° 26.7717",
243
+ "verbatimLongitude": "-79° 56.93172",
244
+ "decimalLatitude": 40.446195,
245
+ "decimalLongitude": -79.948862
246
+ },
247
+ {
248
+ "verbatimCoordinates": "40.446195, -79.948862",
249
+ "verbatimLatitude": "40.446195",
250
+ "verbatimLongitude": "-79.948862",
251
+ "decimalLatitude": 40.446195,
252
+ "decimalLongitude": -79.948862
253
+ },
254
+ {
255
+ "verbatimCoordinates": "40.123256; -74.123256",
256
+ "verbatimLatitude": "40.123256",
257
+ "verbatimLongitude": "-74.123256",
258
+ "decimalLatitude": 40.123256,
259
+ "decimalLongitude": -74.123256
260
+ },
261
+ {
262
+ "verbatimCoordinates": "18°24S 22°45E",
263
+ "verbatimLatitude": "18°24S",
264
+ "verbatimLongitude": "22°45E",
265
+ "decimalLatitude": -18.4,
266
+ "decimalLongitude": 22.75
267
+ },
268
+ {
269
+ "verbatimCoordinates": "10.432342S 10.6345345E",
270
+ "verbatimLatitude": "10.432342S",
271
+ "verbatimLongitude": "10.6345345E",
272
+ "decimalLatitude": -10.432342,
273
+ "decimalLongitude": 10.6345345
274
+ },
275
+ {
276
+ "verbatimCoordinates": "10.00S 10.00E",
277
+ "verbatimLatitude": "10.00S",
278
+ "verbatimLongitude": "10.00E",
279
+ "decimalLatitude": -10,
280
+ "decimalLongitude": 10
281
+ },
282
+ {
283
+ "verbatimCoordinates": "00.00S 01.00E",
284
+ "verbatimLatitude": "00.00S",
285
+ "verbatimLongitude": "01.00E",
286
+ "decimalLatitude": 0,
287
+ "decimalLongitude": 1
288
+ },
289
+ {
290
+ "verbatimCoordinates": "18.24S 22.45E",
291
+ "verbatimLatitude": "18.24S",
292
+ "verbatimLongitude": "22.45E",
293
+ "decimalLatitude": -18.4,
294
+ "decimalLongitude": 22.75
295
+ },
296
+ {
297
+ "verbatimCoordinates": "27deg 15min 45.2sec S 18deg 32min 53.7sec E",
298
+ "verbatimLatitude": "27deg 15min 45.2sec S",
299
+ "verbatimLongitude": "18deg 32min 53.7sec E",
300
+ "decimalLatitude": -27.262555555555554,
301
+ "decimalLongitude": 18.54825
302
+ },
303
+ {
304
+ "verbatimCoordinates": "-23.3245° S / 28.2344° E",
305
+ "verbatimLatitude": "-23.3245° S",
306
+ "verbatimLongitude": "28.2344° E",
307
+ "decimalLatitude": -23.3245,
308
+ "decimalLongitude": 28.2344
309
+ },
310
+ {
311
+ "verbatimCoordinates": "40° 26.7717 -79° 56.93172",
312
+ "verbatimLatitude": "40° 26.7717",
313
+ "verbatimLongitude": "-79° 56.93172",
314
+ "decimalLatitude": 40.446195,
315
+ "decimalLongitude": -79.948862
316
+ },
317
+ {
318
+ "verbatimCoordinates": "27.15.45S 18.32.53E",
319
+ "verbatimLatitude": "27.15.45S",
320
+ "verbatimLongitude": "18.32.53E",
321
+ "decimalLatitude": -27.2625,
322
+ "decimalLongitude": 18.548055
323
+ },
324
+ {
325
+ "verbatimCoordinates": "-27.15.45 18.32.53",
326
+ "verbatimLatitude": "-27.15.45",
327
+ "verbatimLongitude": "18.32.53",
328
+ "decimalLatitude": -27.2625,
329
+ "decimalLongitude": 18.548055
330
+ },
331
+ {
332
+ "verbatimCoordinates": "27.15.45.2S 18.32.53.4E",
333
+ "verbatimLatitude": "27.15.45.2S",
334
+ "verbatimLongitude": "18.32.53.4E",
335
+ "decimalLatitude": -27.262556,
336
+ "decimalLongitude": 18.548167
337
+ },
338
+ {
339
+ "verbatimCoordinates": "27.15.45,2S 18.32.53,4E",
340
+ "verbatimLatitude": "27.15.45,2S",
341
+ "verbatimLongitude": "18.32.53,4E",
342
+ "decimalLatitude": -27.262556,
343
+ "decimalLongitude": 18.548167
344
+ },
345
+ {
346
+ "verbatimCoordinates": "S23.43563 ° E22.45634 °",
347
+ "verbatimLatitude": "S23.43563 °",
348
+ "verbatimLongitude": "E22.45634 °",
349
+ "decimalLatitude": -23.43563,
350
+ "decimalLongitude": 22.45634
351
+ },
352
+ {
353
+ "verbatimCoordinates": "27,71372° S 23,07771° E",
354
+ "verbatimLatitude": "27,71372° S",
355
+ "verbatimLongitude": "23,07771° E",
356
+ "decimalLatitude": -27.71372,
357
+ "decimalLongitude": 23.07771
358
+ },
359
+ {
360
+ "verbatimCoordinates": "27.45.34 S 23.23.23 E",
361
+ "verbatimLatitude": "27.45.34 S",
362
+ "verbatimLongitude": "23.23.23 E",
363
+ "decimalLatitude": -27.759444,
364
+ "decimalLongitude": 23.38972222
365
+ },
366
+ {
367
+ "verbatimCoordinates": "S 27.45.34 E 23.23.23",
368
+ "verbatimLatitude": "S 27.45.34",
369
+ "verbatimLongitude": "E 23.23.23",
370
+ "decimalLatitude": -27.759444,
371
+ "decimalLongitude": 23.38972222
372
+ },
373
+ {
374
+ "verbatimCoordinates": "53 16.3863,4 52.8171",
375
+ "verbatimLatitude": "53 16.3863",
376
+ "verbatimLongitude": "4 52.8171",
377
+ "decimalLatitude": 53.273105,
378
+ "decimalLongitude": 4.88029
379
+ },
380
+ {
381
+ "verbatimCoordinates": "50 8.2914,-5 2.4447",
382
+ "verbatimLatitude": "50 8.2914",
383
+ "verbatimLongitude": "-5 2.4447",
384
+ "decimalLatitude": 50.13819,
385
+ "decimalLongitude": -5.040745
386
+ },
387
+ {
388
+ "verbatimCoordinates": "N 48° 30,6410', E 18° 57,4583'",
389
+ "verbatimLatitude": "N 48° 30,6410'",
390
+ "verbatimLongitude": "E 18° 57,4583'",
391
+ "decimalLatitude": 48.51068,
392
+ "decimalLongitude": 18.95764
393
+ }
394
+ ]
@@ -6,7 +6,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const converter_js_1 = __importDefault(require("../converter.js"));
7
7
  //const test = '26°44S 29°46E'
8
8
  //const test = '00.00, 01.00'
9
- const test = `26°05240'S, 27°51448'E`;
9
+ //const test = `45°5'46.8134"N, 18°30'36.7124"E`
10
+ //const test = `50 8.2914,-5 2.4447`
11
+ //const test = `8°83S 35°67E`
12
+ const test = `N 48° 30,6410', E 18° 57,4583'`;
10
13
  try {
11
14
  let converted = (0, converter_js_1.default)(test);
12
15
  console.log(converted);
@@ -236,8 +236,8 @@ const coordsRegexFormats = [
236
236
  decimalLongitude: 22.75
237
237
  }
238
238
  ];
239
+ // additional formats we've encountered
239
240
  const otherFormats = [
240
- // additional formats we've encountered
241
241
  {
242
242
  verbatimCoordinates: '10.432342S 10.6345345E',
243
243
  verbatimLatitude: '10.432342S',
@@ -342,6 +342,27 @@ const otherFormats = [
342
342
  verbatimLongitude: 'E 23.23.23',
343
343
  decimalLatitude: -27.759444,
344
344
  decimalLongitude: 23.38972222
345
+ },
346
+ {
347
+ verbatimCoordinates: '53 16.3863,4 52.8171',
348
+ verbatimLatitude: '53 16.3863',
349
+ verbatimLongitude: '4 52.8171',
350
+ decimalLatitude: 53.273105,
351
+ decimalLongitude: 4.88029
352
+ },
353
+ {
354
+ verbatimCoordinates: '50 8.2914,-5 2.4447',
355
+ verbatimLatitude: '50 8.2914',
356
+ verbatimLongitude: '-5 2.4447',
357
+ decimalLatitude: 50.13819,
358
+ decimalLongitude: -5.040745
359
+ },
360
+ {
361
+ verbatimCoordinates: `N 48° 30,6410', E 18° 57,4583'`,
362
+ verbatimLatitude: `N 48° 30,6410'`,
363
+ verbatimLongitude: `E 18° 57,4583'`,
364
+ decimalLatitude: 48.51068,
365
+ decimalLongitude: 18.95764
345
366
  }
346
367
  ];
347
368
  function getAllTestFormats() {
@@ -1,6 +1,7 @@
1
1
  export default toCoordinateFormat;
2
2
  /**
3
- * Converts decimalCoordinates to other formats commonly used
3
+ * Converts decimalCoordinates to commonly used string formats
4
+ * Note that this will add degree and direction symbols to decimal coordinates
4
5
  * @param {string} format Either DMS or DM
5
6
  * @returns {string}
6
7
  */