Skip to content

Commit 50935c8

Browse files
committed
JS: Correct display of commonly used coords. Allow DD MM SS, DDMMS, and DD-MM-SS (no decimal) entry.
Fix for #473
1 parent 872247c commit 50935c8

File tree

1 file changed

+50
-8
lines changed
  • Firmware/RTK_Surveyor/AP-Config/src

1 file changed

+50
-8
lines changed

Firmware/RTK_Surveyor/AP-Config/src/main.js

Lines changed: 50 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,10 @@ const CoordinateTypes = {
5959
COORDINATE_INPUT_TYPE_DD_MM_SS: 6, //DD MM SS.ssssss
6060
COORDINATE_INPUT_TYPE_DD_MM_SS_DASH: 7, //DD-MM-SS.ssssss
6161
COORDINATE_INPUT_TYPE_DD_MM_SS_SYMBOL: 8, //DD°MM'SS.ssssss"
62-
COORDINATE_INPUT_TYPE_INVALID_UNKNOWN: 9,
62+
COORDINATE_INPUT_TYPE_DDMMSS_NO_DECIMAL: 9, //DDMMSS - No decimal
63+
COORDINATE_INPUT_TYPE_DD_MM_SS_NO_DECIMAL: 10, //DD MM SS - No decimal
64+
COORDINATE_INPUT_TYPE_DD_MM_SS_DASH_NO_DECIMAL: 11, //DD-MM-SS - No decimal
65+
COORDINATE_INPUT_TYPE_INVALID_UNKNOWN: 12,
6366
}
6467

6568
var convertedCoordinate = 0.0;
@@ -1315,12 +1318,12 @@ function addGeodetic() {
13151318
for (; index < recordsGeodetic.length; ++index) {
13161319
var parts = recordsGeodetic[index].split(' ');
13171320
if (ge("nicknameGeodetic").value == parts[0]) {
1318-
recordsGeodetic[index] = nicknameGeodetic.value + ' ' + fixedLat.value + ' ' + fixedLongText.value + ' ' + fixedAltitude.value + ' ' + antennaHeight.value + ' ' + antennaReferencePoint.value;
1321+
recordsGeodetic[index] = nicknameGeodetic.value + ' ' + fixedLatText.value + ' ' + fixedLongText.value + ' ' + fixedAltitude.value + ' ' + antennaHeight.value + ' ' + antennaReferencePoint.value;
13191322
break;
13201323
}
13211324
}
13221325
if (index == recordsGeodetic.length)
1323-
recordsGeodetic.push(nicknameGeodetic.value + ' ' + fixedLat.value + ' ' + fixedLongText.value + ' ' + fixedAltitude.value + ' ' + antennaHeight.value + ' ' + antennaReferencePoint.value);
1326+
recordsGeodetic.push(nicknameGeodetic.value + ' ' + fixedLatText.value + ' ' + fixedLongText.value + ' ' + fixedAltitude.value + ' ' + antennaHeight.value + ' ' + antennaReferencePoint.value);
13241327
}
13251328

13261329
updateGeodeticList();
@@ -1408,7 +1411,16 @@ function updateGeodeticList() {
14081411
$("#StationCoordinatesGeodetic option").each(function () {
14091412
var parts = $(this).text().split(' ');
14101413
var nickname = parts[0].substring(0, 15);
1411-
$(this).text(nickname + ': ' + parts[1] + ' ' + parts[2] + ' ' + parts[3]).text;
1414+
1415+
if (parts.length >= 7) {
1416+
$(this).text(nickname + ': ' + parts[1] + ' ' + parts[2] + ' ' + parts[3]
1417+
+ ' ' + parts[4] + ' ' + parts[5] + ' ' + parts[6]
1418+
+ ' ' + parts[7]).text;
1419+
}
1420+
else {
1421+
$(this).text(nickname + ': ' + parts[1] + ' ' + parts[2] + ' ' + parts[3]).text;
1422+
}
1423+
14121424
});
14131425
}
14141426

@@ -1735,7 +1747,7 @@ function identifyInputType(userEntry) {
17351747
// DD MM SS.ssssss
17361748
// DD-MM-SS.ssssss
17371749

1738-
if (decimalCount != 1) return (CoordinateTypes.COORDINATE_INPUT_TYPE_INVALID_UNKNOWN); //Just no. 40.09033470 is valid.
1750+
if (decimalCount > 1) return (CoordinateTypes.COORDINATE_INPUT_TYPE_INVALID_UNKNOWN); //Just no. 40.09033470 is valid.
17391751
if (spaceCount > 2) return (CoordinateTypes.COORDINATE_INPUT_TYPE_INVALID_UNKNOWN); //Only 0, 1, or 2 allowed. 40 05 25.2049 is valid.
17401752
if (dashCount > 3) return (CoordinateTypes.COORDINATE_INPUT_TYPE_INVALID_UNKNOWN); //Only 0, 1, 2, or 3 allowed. -105-11-05.1629 is valid.
17411753
if (lengthOfLeadingNumber > 7) return (CoordinateTypes.COORDINATE_INPUT_TYPE_INVALID_UNKNOWN); //Only 7 or fewer. -1051105.188992 (DDDMMSS or DDMMSS) is valid
@@ -1755,6 +1767,11 @@ function identifyInputType(userEntry) {
17551767
var decimal = Math.trunc(intPortion / 10000); //Get DDD
17561768
intPortion -= (decimal * 10000);
17571769
var minutes = Math.trunc(intPortion / 100); //Get MM
1770+
1771+
//Find '.'
1772+
if (userEntry.indexOf('.') == -1)
1773+
coordinateInputType = CoordinateTypes.COORDINATE_INPUT_TYPE_DDMMSS_NO_DECIMAL;
1774+
17581775
var seconds = userEntry; //Get DDDMMSS.ssssss
17591776
seconds -= (decimal * 10000); //Remove DDD
17601777
seconds -= (minutes * 100); //Remove MM
@@ -1791,6 +1808,11 @@ function identifyInputType(userEntry) {
17911808
var data = userEntry.split('-');
17921809
var decimal = Number(data[0]); //Get DD
17931810
var minutes = Number(data[1]); //Get MM
1811+
1812+
//Find '.'
1813+
if (userEntry.indexOf('.') == -1)
1814+
coordinateInputType = CoordinateTypes.COORDINATE_INPUT_TYPE_DD_MM_SS_DASH_NO_DECIMAL;
1815+
17941816
var seconds = Number(data[2]); //Get SS.ssssss
17951817
convertedCoordinate = decimal + (minutes / 60.0) + (seconds / 3600.0);
17961818
if (negativeSign) convertedCoordinate *= -1;
@@ -1818,6 +1840,11 @@ function identifyInputType(userEntry) {
18181840
var data = userEntry.split(' ');
18191841
var decimal = Number(data[0]); //Get DD
18201842
var minutes = Number(data[1]); //Get MM
1843+
1844+
//Find '.'
1845+
if (userEntry.indexOf('.') == -1)
1846+
coordinateInputType = CoordinateTypes.COORDINATE_INPUT_TYPE_DD_MM_SS_NO_DECIMAL;
1847+
18211848
var seconds = Number(data[2]); //Get SS.ssssss
18221849
convertedCoordinate = decimal + (minutes / 60.0) + (seconds / 3600.0);
18231850
if (negativeSign) convertedCoordinate *= -1;
@@ -1862,6 +1889,9 @@ function convertInput(coordinate, coordinateInputType) {
18621889
|| coordinateInputType == CoordinateTypes.COORDINATE_INPUT_TYPE_DDMMSS
18631890
|| coordinateInputType == CoordinateTypes.COORDINATE_INPUT_TYPE_DD_MM_SS_DASH
18641891
|| coordinateInputType == CoordinateTypes.COORDINATE_INPUT_TYPE_DD_MM_SS_SYMBOL
1892+
|| coordinateInputType == CoordinateTypes.COORDINATE_INPUT_TYPE_DDMMSS_NO_DECIMAL
1893+
|| coordinateInputType == CoordinateTypes.COORDINATE_INPUT_TYPE_DD_MM_SS_NO_DECIMAL
1894+
|| coordinateInputType == CoordinateTypes.COORDINATE_INPUT_TYPE_DD_MM_SS_DASH_NO_DECIMAL
18651895
) {
18661896
var longitudeDegrees = Math.trunc(coordinate);
18671897
coordinate -= longitudeDegrees;
@@ -1881,8 +1911,14 @@ function convertInput(coordinate, coordinateInputType) {
18811911
coordinateString = longitudeDegrees + "-" + longitudeMinutes + "-" + coordinate;
18821912
else if (coordinateInputType == CoordinateTypes.COORDINATE_INPUT_TYPE_DD_MM_SS_SYMBOL)
18831913
coordinateString = longitudeDegrees + "°" + longitudeMinutes + "'" + coordinate + "\"";
1884-
else
1914+
else if (coordinateInputType == CoordinateTypes.COORDINATE_INPUT_TYPE_DD_MM_SS)
18851915
coordinateString = longitudeDegrees + " " + longitudeMinutes + " " + coordinate;
1916+
else if (coordinateInputType == CoordinateTypes.COORDINATE_INPUT_TYPE_DDMMSS_NO_DECIMAL)
1917+
coordinateString = longitudeDegrees + "" + longitudeMinutes + "" + Math.round(coordinate);
1918+
else if (coordinateInputType == CoordinateTypes.COORDINATE_INPUT_TYPE_DD_MM_SS_NO_DECIMAL)
1919+
coordinateString = longitudeDegrees + " " + longitudeMinutes + " " + Math.round(coordinate);
1920+
else if (coordinateInputType == CoordinateTypes.COORDINATE_INPUT_TYPE_DD_MM_SS_DASH_NO_DECIMAL)
1921+
coordinateString = longitudeDegrees + "-" + longitudeMinutes + "-" + Math.round(coordinate);
18861922
}
18871923

18881924
return (coordinateString);
@@ -1919,8 +1955,14 @@ function printableInputType(coordinateInputType) {
19191955
case (CoordinateTypes.COORDINATE_INPUT_TYPE_DD_MM_SS):
19201956
return ("DD MM SS.ssssss");
19211957
break;
1922-
case (CoordinateTypes.COORDINATE_INPUT_TYPE_DD_MM_SS_DASH):
1923-
return ("DD-MM-SS.ssssss");
1958+
case (CoordinateTypes.COORDINATE_INPUT_TYPE_DDMMSS_NO_DECIMAL):
1959+
return ("DDMMSS");
1960+
break;
1961+
case (CoordinateTypes.COORDINATE_INPUT_TYPE_DD_MM_SS_NO_DECIMAL):
1962+
return ("DD MM SS");
1963+
break;
1964+
case (CoordinateTypes.COORDINATE_INPUT_TYPE_DD_MM_SS_DASH_NO_DECIMAL):
1965+
return ("DD-MM-SS");
19241966
break;
19251967
}
19261968
return ("Unknown");

0 commit comments

Comments
 (0)