Skip to content

Commit

Permalink
1.0.0 (#3)
Browse files Browse the repository at this point in the history
* ci: adding package-lock.json and dependency on grid-js

* chore: Port of GARSConstants.java

* chore: initial port of GridLine.java

* fix: updating to conform to typescript

* ci: porting of BandLettersRange.java

* chore: port of BandNumberRange.java

* chore: port of GARSLabeler.java

* chore: port of Grid.java

* chore: port of GridLabel.java

* chore: port of GridLabeler.java

* chore: port of GridRange.java

* chore: port of Grids.java

* chore: port of GridType.java

* chore: port of ZoomGrids.java

* chore: port of GARSProperties.java

* chore: port of GARS.java

* chore: port of GARSUtils.java

* fix: fixing compile errors

* fix: fixing compile errors in BandLettersRange.ts

* fix: fixing compile errors in BandNumberRange

* fix: correcting some compile errors for GARSLabeler and GridLabeler.  Sill broken.

* fix: fixing some compile errors in Grid. Still broken

* fix: fixing compile errors in GridLabel

* refactor: making iterators easier to use

* fix: making iterator easier to use in GridRange and fixing compile error in BandLettersRange

* fix: correcting some compile errors in Grids.  Still broken.

* fix: fixing some compile errors in GARS. Still broken.

* feat: upgradeing grid-js to 0.0.1-beta.2

* fix: correcting constructors.  still broken.

* chore: port of gars.properties

* ci: adding build support directory

* fix: correcting compile errors

* fix: correcting compile errors in Grids.ts

* feat: bump of grid-js to 0.0.0-beta.7

* fix: fixing compile errors of GridTypeUtils

* fix: fixing compile errors in GARSUtils

* fix: fixing compile errors of GARS

* refactor: formatting

* refactor: lint cleanup

* test: adding stub of a test

* refactor: renaming test

* refactor: renaming test

* config: exclding node_modules for tsconfig

* ci: looking for *.spec.* for tests

* refactor: changing how lib will be packaged

* feat: adding tsconfig recommented

* refactor: moving src to lib

* ci: removing test from dist

* test: trying to get tests working, and failing again

* ci: pointing to dist for main and types

* test: finally getting tests running, but they are still failing

* test: getting band value working

* test: getting band letters tested

* test: getting quadrants tested

* test: testing keypads

* chore: port of GARSTest.java testParse.  test is failing

* test:  commenting out gars equals checks for now

* test: port of GARSTest parse invalid

* test: port of GARSTest coordinate.  test is failing

* test: port of GARSTest 30 minute parse.  test is failing

* test: uncommenting out failing parts of the test parse

* ci: adding exports for the package

* feat: adding sprintf-js dependency.  adding bitwise opertations for converting to gars from lat/lon

* test: getting parse test working for GARS

* fix: correcting reversed iterator logic

* fix: More iterator work, test now times out

* test: increasing 30 minute test to timeout after 20 seconds

* refactor: code formatting

* ci: removing dependency on winston

* feat: bump to 0.0.0-beta.20 grid-js

* fix: appending resources/ to gars.properties filename

* feat: bump to 0.0.0-beta.22 of grid-js

* chore: adding CHANGELOG

* 0.0.1-beta.1

* feat: bump to rc.0 of grid-js

* ci: trying to fix prettier action

* ci: removing prettier action and moving it to a lint action

* test: increasing test timeout to 30s

* feat: bump to version 1.1.0 of grid-js

* doc: updating README to inclue Properties

* doc: Updating reference to remote dependencies

* doc: Adding examples to the readme, taken from Readme.spec.ts

* ci: update fix:prrettier task

* feat: bump to version 1.2.0 of grid-js

* test: removed timeout in the test class in favor of the one in the config

* test: adding test for GridLine

* linet: fixing lint errors

* test: adding BandLettersRange test

* test: adding BandNumberRange test

* refactor: rremoving Comparable

* fix: getting precision correctly

* test: adding Grid test

* test: adding GridRange test

* fix: correcting construction logic for enabled grids

* test: adding Grids test

* test: adding GridTypeUtils test

* lint: adding linter exception for prefer-for-of

* fix: adding comparable to Grid

* lint: fixing lint issues

* doc: changing java to javascript

* doc: renaming color to gars

* doc: removed @author

* 0.1.0

* 0.1.1-0

* 0.1.1-beta.0

* feat: upgrade grid-js to 2.0.1-beta.0

* 0.1.1-beta.1

* feat: bump to grid-js version 2.0.1-beta.1

* 0.1.1-beta.2

* fix: using object.keys to comply with es2015

* 0.1.1-beta.3

* ci: removing resources directory

* build: allowing for importing of json

* 0.1.1-beta.4

* ci: removing resources

* 0.1.1-beta.5

* test: adding GARSProperties test

* 0.1.1-beta.6

* fix: correcting null/undefined checks

* 0.1.1-beta.7

* fix: corrrecting null/undefined checks again

* 0.1.1-beta.8

* feat: bump to 2.0.1-beta.5 of grid-js

* 0.1.1-beta.9

* feat: bump to latest version of grid-js

* 0.1.1-beta.10

* fix: correcting getColor to call base

* fix: removing circular dependency

* fix: setting color correctly

* fix: setting width correctly

* test: adding zoom grids test and gars labeler test

* chore: removing incorrect comment

* feat: bump grid-js 2.0.0

* doc: changing engine requirement for npm to 6.x

* 1.0.0
  • Loading branch information
gillandk authored Oct 25, 2022
1 parent b438676 commit 1b42960
Show file tree
Hide file tree
Showing 40 changed files with 833 additions and 527 deletions.
4 changes: 2 additions & 2 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ Please fill out as much known and relevant information as possible.

#### Version Information:

* Color Javascript Version:
* Color Javascript Source: (e.g. Central Repository, Release, Source Code Build)
* GARS Javascript Version:
* GARS Javascript Source: (e.g. Central Repository, Release, Source Code Build)
* IDE Name & Version:
* NPM Version: (npm --version)
* Node Version: (node --version)
Expand Down
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
blank_issues_enabled: false
contact_links:
- name: Discussions
url: https://github.com/ngageoint/color-js/discussions
url: https://github.com/ngageoint/gars-js/discussions
about: Questions, Feature Requests, Feedback, Conversations
4 changes: 2 additions & 2 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
- name: Checkout Repository
uses: actions/checkout@v1

- name: Install
- name: Install Dependencies
run: npm ci

- name: Build
Expand All @@ -26,7 +26,7 @@ jobs:
- name: Coverage
run: npm run coverage

- name: Coveralls
- name: Upload Coverage
uses: coverallsapp/github-action@master
if: github.ref_name == 'master'
with:
Expand Down
3 changes: 2 additions & 1 deletion .mocharc.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ module.exports = {
ignore: ['node_modules/**'],
recursive: true,
require: ['ts-node/register'],
spec: ["test/**/*.spec.*"]
spec: ["test/**/*.spec.*"],
timeout: '30000'
};
1 change: 1 addition & 0 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
docs/
lib/
test/
resources/

*.js.map

Expand Down
74 changes: 68 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
# GARS Java
# GARS Javascript

![Build & Test](https://github.com/ngageoint/gars-js/actions/workflows/build-test.yml/badge.svg)
[![NPM](https://img.shields.io/npm/v/@ngageoint/gars-js.svg)](https://www.npmjs.com/package/@ngageoint/gars-js)
[![Coverage Status](https://coveralls.io/repos/github/ngageoint/gars-js/badge.svg)](https://coveralls.io/github/ngageoint/gars-js)
[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)

#### Global Area Reference System Lib ####

Expand All @@ -11,10 +16,67 @@ Software source code previously released under an open source license and then m

### About ###

[GARS](http://ngageoint.github.io/gars-js/) is a Java library providing Global Area Reference System functionality, a standardized geospatial reference system for areas.
[GARS](http://ngageoint.github.io/gars-js/) is a Javascript library providing Global Area Reference System functionality, a standardized geospatial reference system for areas.

### Build and Installation ###
#### Properties ####

![Build & Test](https://github.com/ngageoint/gars-js/actions/workflows/build-test.yml/badge.svg)
[![NPM](https://img.shields.io/npm/v/@ngageoint/gars-js.svg)](https://www.npmjs.com/package/@ngageoint/gars-js)
[![Coverage Status](https://coveralls.io/repos/github/ngageoint/gars-js/badge.svg)](https://coveralls.io/github/ngageoint/gars-js)
Default grid properties including zoom ranges, styles, and labelers are defined in [gars.properties](https://github.com/ngageoint/gars-js/blob/master/resources/gars.properties). The defaults can be changed in code by modifying the [Grids](https://github.com/ngageoint/gars-js/blob/master/lib/grid/Grids.ts).

#### Coordinates ####

```javascript

const gars = GARS.parse('006AG39');
const point = gars.toPoint();
const pointMeters = point.toMeters();

const latitude = 63.98862388;
const longitude = 29.06755082;
const point2 = Point.point(longitude, latitude);
const gars2 = GARS.fromPoint(point2);
const garsCoordinate = gars2.toString();
const gars30m = gars2.coordinate(GridType.THIRTY_MINUTE);
const gars15m = gars2.coordinate(GridType.FIFTEEN_MINUTE);
const gars5m = gars2.coordinate(GridType.FIVE_MINUTE);

```

#### Draw Tile Template ####

See [gars-android](https://github.com/ngageoint/gars-android) for a concrete example

```javascript

// GridTile tile = ...;

const grids = Grids.create();

const zoomGrids = grids.getGrids(tile.getZoom());
if (zoomGrids && zoomGrids.hasGrids()) {
for (const grid of zoomGrids) {
const lines = grid.getLinesFromGridTile(tile);
if (lines) {
for (const line of lines) {
const pixel1 = line.getPoint1().getPixelFromTile(tile);
const pixel2 = line.getPoint2().getPixelFromTile(tile);
// Draw line
}
}

const labels = grid.getLabelsFromGridTile(tile);
if (labels) {
for (const label of labels) {
const pixelRange = label.getBounds()!.getPixelRangeFromTile(tile);
const centerPixel = label.getCenter()!.getPixelFromTile(tile);
// Draw label
}
}
}
}

```


### Remote Dependencies ###

* [Grid Javascript](https://github.com/ngageoint/grid-js) (The MIT License (MIT)) - Grid Library
14 changes: 5 additions & 9 deletions lib/GARS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ import * as sprintf from 'sprintf-js';

/**
* Global Area Reference System Coordinate
*
* @author osbornb
*/
export class GARS {
/**
Expand Down Expand Up @@ -168,9 +166,7 @@ export class GARS {
if (typeof this !== typeof obj) return false;
const other = obj as GARS;
if (this.keypad !== other.keypad) return false;
if (!this.latitude) {
if (other.latitude) return false;
} else if (this.latitude !== other.latitude) return false;
if (this.latitude !== other.latitude) return false;
if (this.longitude !== other.longitude) return false;
if (this.quadrant !== other.quadrant) return false;
return true;
Expand Down Expand Up @@ -302,11 +298,11 @@ export class GARS {
let keypad = GARSConstants.DEFAULT_KEYPAD;

const quadrantValue = matches![3];
if (quadrantValue) {
if (quadrantValue !== null && quadrantValue !== undefined) {
quadrant = Number.parseInt(quadrantValue, 10);

const keypadValue = matches![4];
if (keypadValue) {
if (keypadValue !== null && keypadValue !== undefined) {
keypad = Number.parseInt(keypadValue, 10);
}
}
Expand All @@ -331,9 +327,9 @@ export class GARS {

let precision: GridType;

if (matches![4]) {
if (matches![4] !== null && matches![4] !== undefined) {
precision = GridType.FIVE_MINUTE;
} else if (matches![3]) {
} else if (matches![3] !== null && matches![3] !== undefined) {
precision = GridType.FIFTEEN_MINUTE;
} else {
precision = GridType.THIRTY_MINUTE;
Expand Down
2 changes: 1 addition & 1 deletion lib/GARSConstants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { GridConstants } from '@ngageoint/grid-js';
/**
* Global Area Reference System Constants
*
* @author osbornb
*
*/
export class GARSConstants {
/**
Expand Down
76 changes: 2 additions & 74 deletions lib/GARSUtils.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
import { Bounds, GridConstants, GridUtils } from '@ngageoint/grid-js';
import { GridConstants, GridUtils } from '@ngageoint/grid-js';
import { GARSConstants } from './GARSConstants';
import { BandLettersRange } from './grid/BandLettersRange';
import { BandNumberRange } from './grid/BandNumberRange';
import { GridRange } from './grid/GridRange';
import { GridType } from './grid/GridType';

/**
* Global Area Reference System utilities
*
* @author osbornb
*
*/
export class GARSUtils {
/**
Expand Down Expand Up @@ -245,75 +242,6 @@ export class GARSUtils {
return (2 - row) * 3 + column + 1;
}

/**
* Get a grid range from the bounds
*
* @param bounds
* bounds
* @return grid range
*/
public static getGridRange(bounds: Bounds): GridRange {
bounds = bounds.toDegrees();
const bandNumberRange = this.getBandNumberRangeFromBounds(bounds);
const bandLettersRange = this.getBandLettersRangeFromBounds(bounds);
return new GridRange(bandNumberRange, bandLettersRange);
}

/**
* Get a band number range between the western and eastern bounds
*
* @param bounds
* bounds
* @return band number range
*/
public static getBandNumberRangeFromBounds(bounds: Bounds): BandNumberRange {
bounds = bounds.toDegrees();
return this.getBandNumberRange(bounds.getMinLongitude(), bounds.getMaxLongitude());
}

/**
* Get a band number range between the western and eastern longitudes
*
* @param west
* western longitude in degrees
* @param east
* eastern longitude in degrees
* @return band number range
*/
public static getBandNumberRange(west: number, east: number): BandNumberRange {
const westBand = this.getLongitudeBand(west);
const eastBand = this.getLongitudeBand(east);
return new BandNumberRange(westBand, eastBand);
}

/**
* Get a band letters range between the southern and northern bounds
*
* @param bounds
* bounds
* @return band letters range
*/
public static getBandLettersRangeFromBounds(bounds: Bounds): BandLettersRange {
bounds = bounds.toDegrees();
return this.getBandLettersRange(bounds.getMinLatitude(), bounds.getMaxLatitude());
}

/**
* Get a band letters range between the southern and northern latitudes in
* degrees
*
* @param south
* southern latitude in degrees
* @param north
* northern latitude in degrees
* @return band letters range
*/
public static getBandLettersRange(south: number, north: number): BandLettersRange {
const southBand = this.getLatitudeBand(south);
const northBand = this.getLatitudeBand(north);
return new BandLettersRange(southBand, northBand);
}

/**
* Create a degree grid label
*
Expand Down
8 changes: 4 additions & 4 deletions lib/features/GridLine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ import { GridType } from '../grid/GridType';

/**
* Line between two points
*
* @author osbornb
*/
export class GridLine extends Line {
/**
Expand Down Expand Up @@ -65,7 +63,7 @@ export class GridLine extends Line {
* @return true if has grid type
*/
public hasGridType(): boolean {
return this.gridType !== null;
return this.gridType !== null && this.gridType !== undefined;
}

/**
Expand All @@ -84,7 +82,9 @@ export class GridLine extends Line {
* @return line copy
*/
public copy(): GridLine {
return new GridLine(this);
const gridLineCopy = new GridLine(this);
gridLineCopy.setGridType(this.gridType);
return gridLineCopy;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/grid/BandLettersRange.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { GARSUtils } from '../GARSUtils';
/**
* Latitude Band Letters Range
*
* @author osbornb
*
*/
export class BandLettersRange implements IterableIterator<string> {
/**
Expand Down
2 changes: 1 addition & 1 deletion lib/grid/BandNumberRange.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { GARSUtils } from '../GARSUtils';
/**
* Longitude Band Number Range
*
* @author osbornb
*
*/
export class BandNumberRange implements IterableIterator<number> {
/**
Expand Down
2 changes: 1 addition & 1 deletion lib/grid/GARSLabeler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { GridType } from './GridType';
/**
* GARS grid labeler
*
* @author osbornb
*
*/
export class GARSLabeler extends GridLabeler {
constructor(enabled: boolean, minZoom = 0, maxZoom?: number, color?: Color, textSize?: number, buffer?: number) {
Expand Down
Loading

0 comments on commit 1b42960

Please sign in to comment.