Skip to content

Commit

Permalink
Merge pull request #53 from bwdrop/master
Browse files Browse the repository at this point in the history
fix negative gps coordinates pack error
  • Loading branch information
hMatoba authored Oct 25, 2018
2 parents 45317c3 + 94d37e9 commit db2f80a
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions piexif.js
Original file line number Diff line number Diff line change
Expand Up @@ -2440,22 +2440,23 @@ SOFTWARE.

that.GPSHelper = {
degToDmsRational:function (degFloat) {
var minFloat = degFloat % 1 * 60;
var degAbs = Math.abs(degFloat);
var minFloat = degAbs % 1 * 60;
var secFloat = minFloat % 1 * 60;
var deg = Math.floor(degFloat);
var deg = Math.floor(degAbs);
var min = Math.floor(minFloat);
var sec = Math.round(secFloat * 100);

return [[deg, 1], [min, 1], [sec, 100]];
},

dmsRationalToDeg:function (dmsArray, ref) {
var sign = (ref === 'S' || ref === 'W') ? -1.0 : 1.0;
var deg = sign * dmsArray[0][0] / dmsArray[0][1] +
dmsArray[1][0] / dmsArray[1][1] / 60.0 +
dmsArray[2][0] / dmsArray[2][1] / 3600.0;
var sign = (ref === 'S' || ref === 'W') ? -1.0 : 1.0;
var deg = dmsArray[0][0] / dmsArray[0][1] +
dmsArray[1][0] / dmsArray[1][1] / 60.0 +
dmsArray[2][0] / dmsArray[2][1] / 3600.0;

return deg;
return deg * sign;
}
};

Expand Down

0 comments on commit db2f80a

Please sign in to comment.