All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.nkjmlab.gis.datum.DistanceUnitConverter Maven / Gradle / Ivy

There is a newer version: 1.0.0
Show newest version
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.");
    }
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy