geo-coordinates-parser 1.7.0 → 1.7.2
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 +2 -0
- package/dist/cjs/converter.js +24 -12
- package/dist/cjs/tests/temp.cjs +6 -0
- package/dist/cjs/tests/temp.d.cts +1 -0
- package/dist/cjs/tests/test.js +2 -0
- package/dist/cjs/tests/testFormatConverter.js +7 -7
- package/dist/cjs/tests/testFormats.json +394 -0
- package/dist/cjs/tests/testformats.js +1 -1
- package/dist/cjs/toCoordinateFormat.d.ts +2 -1
- package/dist/cjs/toCoordinateFormat.js +39 -27
- package/dist/mjs/converter.js +24 -12
- package/dist/mjs/tests/temp.cjs +5 -0
- package/dist/mjs/tests/temp.d.cts +1 -0
- package/dist/mjs/tests/test.js +2 -0
- package/dist/mjs/tests/testFormatConverter.js +7 -7
- package/dist/mjs/tests/testFormats.json +394 -0
- package/dist/mjs/tests/testformats.js +1 -1
- package/dist/mjs/toCoordinateFormat.d.ts +2 -1
- package/dist/mjs/toCoordinateFormat.js +39 -27
- package/package.json +1 -1
package/README.md
CHANGED
@@ -46,6 +46,8 @@ converted.decimalLatitude; // 40.446195 ✓
|
|
46
46
|
converted.decimalLongitude; // -79.948862 ✓
|
47
47
|
converted.verbatimLatitude; // '40° 26.7717' ✓
|
48
48
|
converted.verbatimLongitude; // '-79° 56.93172' ✓
|
49
|
+
converted.decimalCoordinates; // for convenience
|
50
|
+
convert.originalFormat; // 'DM' to indicate degrees and minutes
|
49
51
|
```
|
50
52
|
The returned object includes properties verbatimCoordinates, verbatimLatitude, verbatimLongitude, decimalLatitude, decimalLatitude, and decimalCoordinates.
|
51
53
|
|
package/dist/cjs/converter.js
CHANGED
@@ -23,6 +23,7 @@ function converter(coordsString, decimalPlaces) {
|
|
23
23
|
let ddLng = null;
|
24
24
|
let latdir = "";
|
25
25
|
let lngdir = "";
|
26
|
+
let originalFormat = null;
|
26
27
|
let match = [];
|
27
28
|
let matchSuccess = false;
|
28
29
|
if (regex_js_1.dm_numbers.test(coordsString)) {
|
@@ -37,6 +38,7 @@ function converter(coordsString, decimalPlaces) {
|
|
37
38
|
if (Number(match[3]) < 0) {
|
38
39
|
ddLng *= -1;
|
39
40
|
}
|
41
|
+
originalFormat = "DM";
|
40
42
|
}
|
41
43
|
else {
|
42
44
|
throw new Error("invalid coordinate format");
|
@@ -55,6 +57,7 @@ function converter(coordsString, decimalPlaces) {
|
|
55
57
|
if (ddLng.includes(',')) {
|
56
58
|
ddLng = ddLng.replace(',', '.');
|
57
59
|
}
|
60
|
+
originalFormat = "DD";
|
58
61
|
//validation, we don't want things like 23.00000
|
59
62
|
//some more validation: no zero coords or degrees only
|
60
63
|
if (Number(Math.round(ddLat)) == Number(ddLat)) {
|
@@ -84,9 +87,11 @@ function converter(coordsString, decimalPlaces) {
|
|
84
87
|
ddLat = Math.abs(parseInt(match[2]));
|
85
88
|
if (match[4]) {
|
86
89
|
ddLat += match[4] / 60;
|
90
|
+
originalFormat = "DM";
|
87
91
|
}
|
88
92
|
if (match[6]) {
|
89
93
|
ddLat += match[6].replace(',', '.') / 3600;
|
94
|
+
originalFormat = "DMS";
|
90
95
|
}
|
91
96
|
if (parseInt(match[2]) < 0) {
|
92
97
|
ddLat = -1 * ddLat;
|
@@ -122,9 +127,11 @@ function converter(coordsString, decimalPlaces) {
|
|
122
127
|
ddLat = Math.abs(parseInt(match[2]));
|
123
128
|
if (match[4]) {
|
124
129
|
ddLat += match[4] / 60;
|
130
|
+
originalFormat = "DM";
|
125
131
|
}
|
126
132
|
if (match[6]) {
|
127
133
|
ddLat += match[6] / 3600;
|
134
|
+
originalFormat = "DMS";
|
128
135
|
}
|
129
136
|
if (parseInt(match[2]) < 0) {
|
130
137
|
ddLat = -1 * ddLat;
|
@@ -139,6 +146,7 @@ function converter(coordsString, decimalPlaces) {
|
|
139
146
|
if (parseInt(match[10]) < 0) {
|
140
147
|
ddLng = -1 * ddLng;
|
141
148
|
}
|
149
|
+
//the compass directions
|
142
150
|
if (match[1]) {
|
143
151
|
latdir = match[1];
|
144
152
|
lngdir = match[9];
|
@@ -159,9 +167,11 @@ function converter(coordsString, decimalPlaces) {
|
|
159
167
|
ddLat = Math.abs(parseInt(match[2]));
|
160
168
|
if (match[4]) {
|
161
169
|
ddLat += match[4].replace(',', '.') / 60;
|
170
|
+
originalFormat = "DM";
|
162
171
|
}
|
163
172
|
if (match[6]) {
|
164
173
|
ddLat += match[6].replace(',', '.') / 3600;
|
174
|
+
originalFormat = "DMS";
|
165
175
|
}
|
166
176
|
if (parseInt(match[2]) < 0) {
|
167
177
|
ddLat = -1 * ddLat;
|
@@ -176,6 +186,7 @@ function converter(coordsString, decimalPlaces) {
|
|
176
186
|
if (parseInt(match[10]) < 0) {
|
177
187
|
ddLng = -1 * ddLng;
|
178
188
|
}
|
189
|
+
//the compass directions
|
179
190
|
if (match[1]) {
|
180
191
|
latdir = match[1];
|
181
192
|
lngdir = match[9];
|
@@ -200,13 +211,20 @@ function converter(coordsString, decimalPlaces) {
|
|
200
211
|
throw new Error("invalid latitude value");
|
201
212
|
}
|
202
213
|
//if we have one direction we must have the other
|
203
|
-
if ((latdir
|
204
|
-
throw new Error("invalid coordinates
|
214
|
+
if ((latdir && !lngdir) || (!latdir && lngdir)) {
|
215
|
+
throw new Error("invalid coordinates value");
|
205
216
|
}
|
206
217
|
//the directions can't be the same
|
207
218
|
if (latdir && latdir == lngdir) {
|
208
219
|
throw new Error("invalid coordinates format");
|
209
220
|
}
|
221
|
+
// a bit of tidying up...
|
222
|
+
if (ddLat.toString().includes(',')) {
|
223
|
+
ddLat = ddLat.replace(',', '.');
|
224
|
+
}
|
225
|
+
if (ddLng.toString().includes(',')) {
|
226
|
+
ddLng = ddLng.replace(',', '.');
|
227
|
+
}
|
210
228
|
//make sure the signs and cardinal directions match
|
211
229
|
let patt = /S|SOUTH/i;
|
212
230
|
if (patt.test(latdir)) {
|
@@ -279,20 +297,12 @@ function converter(coordsString, decimalPlaces) {
|
|
279
297
|
}
|
280
298
|
}
|
281
299
|
//no integer coords allowed
|
282
|
-
//validation -- no integer coords
|
283
300
|
if (/^\d+$/.test(verbatimLat) || /^\d+$/.test(verbatimLng)) {
|
284
301
|
throw new Error('degree only coordinate/s provided');
|
285
302
|
}
|
286
|
-
//some tidying up...
|
287
|
-
if (isNaN(ddLat) && ddLat.includes(',')) {
|
288
|
-
ddLat = ddLat.replace(',', '.');
|
289
|
-
}
|
290
303
|
//all done!!
|
291
304
|
//just truncate the decimals appropriately
|
292
305
|
ddLat = Number(Number(ddLat).toFixed(decimalPlaces));
|
293
|
-
if (isNaN(ddLng) && ddLng.includes(',')) {
|
294
|
-
ddLng = ddLng.replace(',', '.');
|
295
|
-
}
|
296
306
|
ddLng = Number(Number(ddLng).toFixed(decimalPlaces));
|
297
307
|
return Object.freeze({
|
298
308
|
verbatimCoordinates,
|
@@ -301,6 +311,7 @@ function converter(coordsString, decimalPlaces) {
|
|
301
311
|
decimalLatitude: ddLat,
|
302
312
|
decimalLongitude: ddLng,
|
303
313
|
decimalCoordinates: `${ddLat},${ddLng}`,
|
314
|
+
originalFormat,
|
304
315
|
closeEnough: coordsCloseEnough,
|
305
316
|
toCoordinateFormat: toCoordinateFormat_js_1.default
|
306
317
|
});
|
@@ -317,11 +328,11 @@ function checkMatch(match) {
|
|
317
328
|
const filteredMatch = [...match];
|
318
329
|
//we need to shift the array because it contains the whole coordinates string in the first item
|
319
330
|
filteredMatch.shift();
|
320
|
-
//check the array length is an even number
|
331
|
+
//check the array length is an even number
|
321
332
|
if (filteredMatch.length % 2 > 0) {
|
322
333
|
return false;
|
323
334
|
}
|
324
|
-
//regex for testing corresponding values match
|
335
|
+
// regex for testing corresponding values match
|
325
336
|
const numerictest = /^[-+]?\d+([\.,]\d+)?$/; //for testing numeric values
|
326
337
|
const stringtest = /[eastsouthnorthwest]+/i; //for testing string values (north, south, etc)
|
327
338
|
const halflen = filteredMatch.length / 2;
|
@@ -372,6 +383,7 @@ function coordsCloseEnough(coordsToTest) {
|
|
372
383
|
throw new Error("coords being tested must be separated by a comma");
|
373
384
|
}
|
374
385
|
}
|
386
|
+
// An enum for coordinates formats
|
375
387
|
const to = Object.freeze({
|
376
388
|
DMS: 'DMS',
|
377
389
|
DM: 'DM',
|
@@ -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 {};
|
package/dist/cjs/tests/test.js
CHANGED
@@ -1,4 +1,6 @@
|
|
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
|
};
|
@@ -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
|
+
]
|
@@ -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',
|
@@ -1,6 +1,7 @@
|
|
1
1
|
export default toCoordinateFormat;
|
2
2
|
/**
|
3
|
-
* Converts decimalCoordinates to
|
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
|
*/
|