Skip to content

Commit

Permalink
truncate don't round
Browse files Browse the repository at this point in the history
  • Loading branch information
calvinmetcalf committed Feb 1, 2017
1 parent cd156d7 commit 9fb8ccb
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
4 changes: 2 additions & 2 deletions dist/mgrs.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,8 @@ function LLtoUTM(ll) {
}

return {
northing: Math.round(UTMNorthing),
easting: Math.round(UTMEasting),
northing: Math.trunc(UTMNorthing),
easting: Math.trunc(UTMEasting),
zoneNumber: ZoneNumber,
zoneLetter: getLetterDesignator(Lat)
};
Expand Down
4 changes: 2 additions & 2 deletions mgrs.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,8 @@ function LLtoUTM(ll) {
}

return {
northing: Math.round(UTMNorthing),
easting: Math.round(UTMEasting),
northing: Math.trunc(UTMNorthing),
easting: Math.trunc(UTMEasting),
zoneNumber: ZoneNumber,
zoneLetter: getLetterDesignator(Lat)
};
Expand Down
12 changes: 10 additions & 2 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ describe('First MGRS set', function() {
point[1].should.be.closeTo(48.24949, 0.000001);
});
it('MGRS reference with highest accuracy correct.', function() {
mgrs.forward(point).should.equal("33UXP0500444998");
mgrs.forward(point).should.equal("33UXP0500444997");
});
it('MGRS reference with 1-digit accuracy correct.', function() {
mgrs.forward(point,1).should.equal(mgrsStr);
Expand All @@ -34,4 +34,12 @@ describe('Second MGRS set', function() {
it('MGRS reference with 5-digit accuracy, northing one digit', function(){
mgrs.forward([0,0.00001],5).should.equal('31NAA6602100001');
});
})
})

describe ('third mgrs set', function () {
var mgrsStr = '11SPA7234911844';
var point = [-115.0820944, 36.2361322]
it('MGRS reference with highest accuracy correct.', function() {
mgrs.forward(point).should.equal(mgrsStr);
});
})

0 comments on commit 9fb8ccb

Please sign in to comment.