Skip to content

Commit

Permalink
added getProjString
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielJDufour committed Jul 18, 2020
1 parent 7d1ac9e commit 4af7142
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 3 deletions.
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Super Light-Weight Utility Functions for Working with Universal Transverse Merca
const isUTM = require('utm-utils/src/isUTM');

const result = isUTM(32619);
//true
// true
```

# Get Hemisphere from EPSG Code
Expand All @@ -26,5 +26,13 @@ const zone = getZone('32617');
// 17
```

# Get PROJ String from EPSG Code
```javascript
const getProjString = require('utm-utils/src/getProjString');

const projString = getProjString('32617');
// +proj=utm +zone=17 +ellps=WGS84 +datum=WGS84 +units=m +no_defs
```

# Support
Email the package author at [email protected] or post an issue at https://github.com/danieljdufour/utm-utils/issues
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "utm-utils",
"version": "0.0.1",
"version": "0.1.0",
"description": "Super Light-Weight Utility Functions for Working with Universal Transverse Mercator",
"main": "src/",
"scripts": {
Expand Down
8 changes: 8 additions & 0 deletions src/getProjString.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
const getZone = require('./getZone');
const getHemisphere = require('./getHemisphere');

module.exports = function getProjString (projection) {
const zone = getZone(projection);
const hemisphere = getHemisphere(projection);
return `+proj=utm +zone=${zone}${hemisphere === 'S' ? ' +south ' : ' '}+ellps=WGS84 +datum=WGS84 +units=m +no_defs`;
};
7 changes: 7 additions & 0 deletions test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const { expect } = require('chai');
const isUTM = require('./src/isUTM.js');
const getProjString = require('./src/getProjString');
const getHemisphere = require('./src/getHemisphere.js');
const getZone = require('./src/getZone.js');

Expand All @@ -26,3 +27,9 @@ describe("Check Zone Identification", function () {
expect(getZone(32618)).to.equal(18);
});
});

describe("Check Proj String Conversion", function () {
it("Get Proj String", function() {
expect(getProjString(32618)).to.equal('+proj=utm +zone=18 +ellps=WGS84 +datum=WGS84 +units=m +no_defs');
});
});

0 comments on commit 4af7142

Please sign in to comment.