org.nkjmlab.gis.datum.DistanceUnitConverter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of nkjmlab-utils-jpdatum Show documentation
Show all versions of nkjmlab-utils-jpdatum Show documentation
Utilities for Tokyo Datum, WGS84 and Japan Plane Rectangular
package org.nkjmlab.gis.datum;
public class DistanceUnitConverter {
public static double change(double val, DistanceUnit fromUnit, DistanceUnit toUnit) {
if (fromUnit == toUnit) {
return val;
}
switch (fromUnit) {
case M:
if (toUnit == DistanceUnit.KM) {
return val / 1000;
}
case KM:
if (toUnit == DistanceUnit.M) {
return val * 1000;
}
default:
throw new IllegalArgumentException(fromUnit + " is not suported.");
}
}
}