File tree Expand file tree Collapse file tree
src/main/java/mil/nga/crs/common Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ Adheres to [Semantic Versioning](http://semver.org/).
1111* Common Geo Datums, Ellipsoids, and Prime Meridians
1212* Additional common Operation Method aliases
1313* Temporal Datum method name correction, setOriginDateTime, previously setStartDateTime
14+ * Unit conversions for backwards compatible base unit types
1415
1516## [ 1.0.0] ( https://github.com/ngageoint/coordinate-reference-systems-java/releases/tag/1.0.0 ) (06-24-2021)
1617
Original file line number Diff line number Diff line change @@ -343,7 +343,9 @@ public static Unit createDefaultUnit(UnitType type) {
343343 */
344344 public static boolean canConvert (Unit unit1 , Unit unit2 ) {
345345 return unit1 != null && unit2 != null
346- && unit1 .getType () == unit2 .getType ()
346+ && (unit1 .getType () == unit2 .getType ()
347+ || unit1 .getType () == UnitType .UNIT
348+ || unit2 .getType () == UnitType .UNIT )
347349 && unit1 .hasConversionFactor () && unit2 .hasConversionFactor ();
348350 }
349351
@@ -361,7 +363,8 @@ public static boolean canConvert(Unit unit1, Unit unit2) {
361363 */
362364 public static double convert (double value , Unit from , Unit to ) {
363365
364- if (from .getType () != to .getType ()) {
366+ if (from .getType () != to .getType () && from .getType () != UnitType .UNIT
367+ && to .getType () != UnitType .UNIT ) {
365368 throw new CRSException ("Can't convert value '" + value
366369 + "' from unit type " + from .getType ().name ()
367370 + " to unit type " + to .getType ().name ());
You can’t perform that action at this time.
0 commit comments