Tidy up code
parent
b3ac8d0835
commit
04b0b8c723
|
@ -259,13 +259,12 @@ export function findFormat (input, delim) {
|
||||||
// Test DMS/DDM/DD formats
|
// Test DMS/DDM/DD formats
|
||||||
if (testData !== undefined) {
|
if (testData !== undefined) {
|
||||||
const split = splitInput(testData);
|
const split = splitInput(testData);
|
||||||
if (split.length === 3) {
|
switch (split.length){
|
||||||
// DMS
|
case 3:
|
||||||
return "Degrees Minutes Seconds";
|
return "Degrees Minutes Seconds";
|
||||||
} else if (split.length === 2) {
|
case 2:
|
||||||
// DDM
|
|
||||||
return "Degrees Decimal Minutes";
|
return "Degrees Decimal Minutes";
|
||||||
} else if (split.length === 1) {
|
case 1:
|
||||||
return "Decimal Degrees";
|
return "Decimal Degrees";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -280,13 +279,12 @@ export function findFormat (input, delim) {
|
||||||
export function findDelim (input) {
|
export function findDelim (input) {
|
||||||
input = input.trim();
|
input = input.trim();
|
||||||
const delims = [",", ";", ":"];
|
const delims = [",", ";", ":"];
|
||||||
// Direction
|
|
||||||
const testDir = input.match(/[NnEeSsWw]/g);
|
const testDir = input.match(/[NnEeSsWw]/g);
|
||||||
if (testDir !== null && testDir.length > 0 && testDir.length < 3) {
|
if (testDir !== null && testDir.length > 0 && testDir.length < 3) {
|
||||||
// Possible direction
|
// Possibly contains a direction
|
||||||
const splitInput = input.split(/[NnEeSsWw]/);
|
const splitInput = input.split(/[NnEeSsWw]/);
|
||||||
if (splitInput.length <= 3 && splitInput.length > 0) {
|
if (splitInput.length <= 3 && splitInput.length > 0) {
|
||||||
// One of the splits should be an empty string
|
// If there's 3 splits (one should be empty), then assume we have directions
|
||||||
if (splitInput[0] === "") {
|
if (splitInput[0] === "") {
|
||||||
return "Direction Preceding";
|
return "Direction Preceding";
|
||||||
} else if (splitInput[splitInput.length - 1] === "") {
|
} else if (splitInput[splitInput.length - 1] === "") {
|
||||||
|
@ -301,6 +299,7 @@ export function findDelim (input) {
|
||||||
if (input.includes(delim)) {
|
if (input.includes(delim)) {
|
||||||
const splitInput = input.split(delim);
|
const splitInput = input.split(delim);
|
||||||
if (splitInput.length <= 3 && splitInput.length > 0) {
|
if (splitInput.length <= 3 && splitInput.length > 0) {
|
||||||
|
// Don't want to try and convert more than 2 co-ordinates
|
||||||
return delim;
|
return delim;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,7 +37,7 @@ class ConvertCoordinateFormat extends Operation {
|
||||||
"type": "option",
|
"type": "option",
|
||||||
"value": [
|
"value": [
|
||||||
"Auto",
|
"Auto",
|
||||||
"Direction Preceding", // Need better names
|
"Direction Preceding",
|
||||||
"Direction Following",
|
"Direction Following",
|
||||||
"\\n",
|
"\\n",
|
||||||
"Comma",
|
"Comma",
|
||||||
|
@ -55,7 +55,7 @@ class ConvertCoordinateFormat extends Operation {
|
||||||
"type": "option",
|
"type": "option",
|
||||||
"value": [
|
"value": [
|
||||||
"Space",
|
"Space",
|
||||||
"Direction Preceding", // Need better names
|
"Direction Preceding",
|
||||||
"Direction Following",
|
"Direction Following",
|
||||||
"\\n",
|
"\\n",
|
||||||
"Comma",
|
"Comma",
|
||||||
|
|
Loading…
Reference in New Issue