Class DistanceUnits

java.lang.Object
org.apache.solr.util.DistanceUnits

public class DistanceUnits extends Object
Used with a spatial field type for all distance measurements.
See Also:
  • Field Details

  • Method Details

    • valueOf

      public static DistanceUnits valueOf(String str)
      Parses a string representation of distance units and returns its implementing class instance. Preferred way to parse a DistanceUnits would be to use AbstractSpatialFieldType.parseDistanceUnits(String), since it will default to one defined on the field type if the string is null.
      Parameters:
      str - String representation of distance units, e.g. "kilometers", "miles" etc. (null ok)
      Returns:
      an instance of the concrete DistanceUnits, null if not found.
    • getSupportedUnits

      public static Set<String> getSupportedUnits()
    • getEarthRadius

      public double getEarthRadius()
      Returns:
      Radius of the earth in this distance units
    • multiplierFromThisUnitToDegrees

      public double multiplierFromThisUnitToDegrees()
      Returns:
      multiplier needed to convert a distance in current units to degrees
    • multiplierFromDegreesToThisUnit

      public double multiplierFromDegreesToThisUnit()
      Returns:
      multiplier needed to convert a distance in degrees to current units
    • getStringIdentifier

      public String getStringIdentifier()
      Returns:
      the string identifier associated with this units instance
    • addUnits

      public static void addUnits(String strId, double earthRadius, double multiplierThisToDegrees)
      Custom distance units can be supplied using this method. It's thread-safe.
      Parameters:
      strId - string identifier for the units
      earthRadius - radius of earth in supplied units
      multiplierThisToDegrees - multiplier to convert to degrees
    • toString

      public String toString()
      Overrides:
      toString in class Object