[mgrs] 01/08: Imported Upstream version 0.0.2

Sebastiaan Couwenberg sebastic at moszumanska.debian.org
Fri Aug 7 08:07:16 UTC 2015


This is an automated email from the git hooks/post-receive script.

sebastic pushed a commit to branch master
in repository mgrs.

commit d94c4b257a2b9dd9a5924be3db6bbb0149aa43e9
Author: Bas Couwenberg <sebastic at xs4all.nl>
Date:   Fri Aug 7 09:43:39 2015 +0200

    Imported Upstream version 0.0.2
---
 mgrs.js      | 7 ++++---
 package.json | 2 +-
 test/test.js | 6 ++++++
 3 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/mgrs.js b/mgrs.js
index 95ad313..6d5b768 100644
--- a/mgrs.js
+++ b/mgrs.js
@@ -37,7 +37,7 @@ var Z = 90; // Z
  * @param {object} ll Object literal with lat and lon properties on a
  *     WGS84 ellipsoid.
  * @param {int} accuracy Accuracy in digits (5 for 1 m, 4 for 10 m, 3 for
- *      100 m, 4 for 1000 m or 5 for 10000 m). Optional, default is 5.
+ *      100 m, 2 for 1000 m or 1 for 10000 m). Optional, default is 5.
  * @return {string} the MGRS string for the given location and accuracy.
  */
 exports.forward = function(ll, accuracy) {
@@ -359,8 +359,9 @@ function getLetterDesignator(lat) {
  * @return {string} MGRS string for the given UTM location.
  */
 function encode(utm, accuracy) {
-  var seasting = "" + utm.easting,
-    snorthing = "" + utm.northing;
+  // prepend with leading zeroes
+  var seasting = "00000" + utm.easting,
+    snorthing = "00000" + utm.northing;
 
   return utm.zoneNumber + utm.zoneLetter + get100kID(utm.easting, utm.northing, utm.zoneNumber) + seasting.substr(seasting.length - 5, accuracy) + snorthing.substr(snorthing.length - 5, accuracy);
 }
diff --git a/package.json b/package.json
index 22e5a3e..74a4b43 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
 {
   "name": "mgrs",
-  "version": "0.0.1",
+  "version": "0.0.2",
   "description": "Utility for converting between WGS84 lat/lng and MGRS coordinates",
   "main": "mgrs.js",
   "scripts": {
diff --git a/test/test.js b/test/test.js
index acab8f2..0851106 100644
--- a/test/test.js
+++ b/test/test.js
@@ -28,4 +28,10 @@ describe('Second MGRS set', function() {
   it('MGRS reference with 1-digit accuracy correct.', function() {
     mgrs.forward(point,3).should.equal('25XEN041865');
   });
+  it('MGRS reference with 5-digit accuracy, northing all zeros', function(){
+    mgrs.forward([0,0],5).should.equal('31NAA6602100000');
+  });
+  it('MGRS reference with 5-digit accuracy, northing one digit', function(){
+    mgrs.forward([0,0.00001],5).should.equal('31NAA6602100001');
+  });
 })
\ No newline at end of file

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-grass/mgrs.git



More information about the Pkg-grass-devel mailing list