The GARS Library was developed at the National Geospatial-Intelligence Agency (NGA) in collaboration with BIT Systems. The government has "unlimited rights" and is releasing this software to increase the impact of government investments by providing developers with the opportunity to take things in new directions. The software use, modification, and distribution rights are stipulated within the MIT license.
If you'd like to contribute to this project, please make a pull request. We'll review the pull request and discuss the changes. All pull request contributions to this project will be released under the MIT license.
Software source code previously released under an open source license and then modified by NGA staff is considered a "joint work" (see 17 USC § 101); it is partially copyrighted, partially public domain, and as a whole is protected by the copyrights of the non-government authors and must be released according to the terms of the original open source license.
GARS is a Java library providing Global Area Reference System functionality, a standardized geospatial reference system for areas.
View the latest Javadoc
GARS gars = GARS.parse("006AG39");
Point point = gars.toPoint();
Point pointMeters = point.toMeters();
double latitude = 63.98862388;
double longitude = 29.06755082;
Point point2 = Point.point(longitude, latitude);
GARS gars2 = GARS.from(point2);
String garsCoordinate = gars2.toString();
String gars30m = gars2.coordinate(GridType.THIRTY_MINUTE);
String gars15m = gars2.coordinate(GridType.FIFTEEN_MINUTE);
String gars5m = gars2.coordinate(GridType.FIVE_MINUTE);
See gars-android for a concrete example
// GridTile tile = ...;
Grids grids = Grids.create();
ZoomGrids zoomGrids = grids.getGrids(tile.getZoom());
if (zoomGrids.hasGrids()) {
for (Grid grid : zoomGrids) {
List<GridLine> lines = grid.getLines(tile);
if (lines != null) {
for (GridLine line : lines) {
Pixel pixel1 = line.getPoint1().getPixel(tile);
Pixel pixel2 = line.getPoint2().getPixel(tile);
// Draw line
}
}
List<GridLabel> labels = grid.getLabels(tile);
if (labels != null) {
for (GridLabel label : labels) {
PixelRange pixelRange = label.getBounds()
.getPixelRange(tile);
Pixel centerPixel = label.getCenter().getPixel(tile);
// Draw label
}
}
}
}
Default grid properties including zoom ranges, styles, and labelers are defined in gars.properties. The defaults can be changed in code by modifying the Grids.
Pull from the Maven Central Repository (JAR, POM, Source, Javadoc)
<dependency>
<groupId>mil.nga</groupId>
<artifactId>gars</artifactId>
<version>1.1.3</version>
</dependency>
Build this repository using Eclipse and/or Maven:
mvn clean install
- Grid Java (The MIT License (MIT)) - Grid Library