Skip to content

Commit 3fd6dd1

Browse files
committed
Prime Meridians offset from greenwich in degrees
1 parent 414f895 commit 3fd6dd1

3 files changed

Lines changed: 46 additions & 3 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ Adheres to [Semantic Versioning](http://semver.org/).
1111
* Additional included names in Ellipsoids
1212
* Ellipsoids saved reciprocal flattening value
1313
* Prime Meridians name capitalizations
14+
* Prime Meridians offset from greenwich in degrees
1415

1516
## [1.1.0](https://github.com/ngageoint/coordinate-reference-systems-java/releases/tag/1.1.0) (10-14-2021)
1617

src/main/java/mil/nga/crs/common/Units.java

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -402,4 +402,35 @@ public static double convert(double value, Unit from, Unit to) {
402402
return value * (from.getConversionFactor() / to.getConversionFactor());
403403
}
404404

405+
/**
406+
* Determine if values can be converted between the two units
407+
*
408+
* @param unit1
409+
* first unit
410+
* @param unit2
411+
* second unit
412+
* @return true if can convert
413+
* @since 1.1.1
414+
*/
415+
public static boolean canConvert(Units unit1, Units unit2) {
416+
return canConvert(unit1.createUnit(), unit2.createUnit());
417+
}
418+
419+
/**
420+
* Convert the value from a unit to a same typed unit, both with conversion
421+
* factors
422+
*
423+
* @param value
424+
* value to convert
425+
* @param from
426+
* unit to convert from
427+
* @param to
428+
* unit to convert to
429+
* @return converted value
430+
* @since 1.1.1
431+
*/
432+
public static double convert(double value, Units from, Units to) {
433+
return convert(value, from.createUnit(), to.createUnit());
434+
}
435+
405436
}

src/main/java/mil/nga/crs/geo/PrimeMeridians.java

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
import java.util.HashMap;
44
import java.util.Map;
55

6+
import mil.nga.crs.common.Units;
7+
68
/**
79
* Common Prime Meridians
810
*
@@ -92,7 +94,7 @@ public enum PrimeMeridians {
9294
private final String name;
9395

9496
/**
95-
* Offset from greenwich
97+
* Offset from greenwich in radians
9698
*/
9799
private final double offsetFromGreenwich;
98100

@@ -133,14 +135,23 @@ public String getName() {
133135
}
134136

135137
/**
136-
* Get the offset from greenwich
138+
* Get the offset from greenwich in radians
137139
*
138-
* @return offset longitude
140+
* @return offset longitude in radians
139141
*/
140142
public double getOffsetFromGreenwich() {
141143
return offsetFromGreenwich;
142144
}
143145

146+
/**
147+
* Get the offset from greenwich in degrees
148+
*
149+
* @return offset longitude in degrees
150+
*/
151+
public double getOffsetFromGreenwichDegrees() {
152+
return Units.convert(offsetFromGreenwich, Units.RADIAN, Units.DEGREE);
153+
}
154+
144155
/**
145156
* Get the prime meridians type from the name
146157
*

0 commit comments

Comments
 (0)