My problem involves a string that represents longitude/latitude in the format of dd°mm'ss''W (note 2 single quotes after ss).
To convert this string into its decimal representation, I am using the following code snippet:
function dmsTodegrees(val) {
var s = val.replace('°', ' ');
s = s.replace("'", ' ');
s = s.replace("''", ' ');
var tokens = s.split(' ');
var result = Number.parseFloat(tokens[0]) + Number.parseFloat(tokens[1]) / 60 + Number.parseFloat(tokens[2]) / 3600;
if (tokens[3] === 'W' || tokens[3] === 'S') result = -result;
return result;
}
However, it appears that s = s.replace("''", ' ');
is not functioning as expected, as the two single quotes (') are not being replaced. I am unsure of what mistake I might be making.
Please note that error handling has been omitted in the provided code.