gzd-utils
Version:
Utilities for working with MGRS GZD and GeoJSON
41 lines (31 loc) • 1.5 kB
Markdown
# GZD Utils for Nodejs
[](https://travis-ci.org/github/gustavlarson/gzd-utils)
[](https://codecov.io/gh/gustavlarson/gzd-utils)
[](https://www.npmjs.com/package/gzd-utils)
[](https://bundlephobia.com/result?p=gzd-utils)
[](https://choosealicense.com/licenses/isc/)
Utilities for calculating [MGRS GZDs](https://en.wikipedia.org/wiki/Military_Grid_Reference_System) in Nodejs.
## Installation
$ npm install gzd-utils
## Usage
```typescript
import { Polygon } from 'geojson';
import { getAllGZD, getGZD } from 'gzd-utils';
// Get all GZDs
const gzdZones = getAllGZD();
gzdZones.features.forEach((zone) => {
console.log(`Zone: ${zone.properties['name']}`);
const polygon = zone.geometry as Polygon;
console.log(`Coordinates: ${polygon.coordinates}`);
};
// Get a specific GZD
let zone = getGZD('33V');
console.log(`Zone: ${zone.properties['name']}`);
let polygon = zone.geometry as Polygon;
console.log(`Coordinates: ${polygon.coordinates}`);
// Alternate way of getting a specific GZD
zone = getGZD(33, 'V');
console.log(`Zone: ${zone.properties['name']}`);
polygon = zone.geometry as Polygon;
console.log(`Coordinates: ${polygon.coordinates}`);
```