Package org.apache.solr.util
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:
AbstractSpatialFieldType
-
-
Field Summary
Fields Modifier and Type Field Description static DistanceUnits
DEGREES
static String
DEGREES_PARAM
static DistanceUnits
KILOMETERS
static String
KILOMETERS_PARAM
static DistanceUnits
MILES
static String
MILES_PARAM
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static void
addUnits(String strId, double earthRadius, double multiplierThisToDegrees)
Custom distance units can be supplied using this method.double
getEarthRadius()
String
getStringIdentifier()
static Set<String>
getSupportedUnits()
double
multiplierFromDegreesToThisUnit()
double
multiplierFromThisUnitToDegrees()
String
toString()
static DistanceUnits
valueOf(String str)
Parses a string representation of distance units and returns its implementing class instance.
-
-
-
Field Detail
-
KILOMETERS_PARAM
public static final String KILOMETERS_PARAM
- See Also:
- Constant Field Values
-
MILES_PARAM
public static final String MILES_PARAM
- See Also:
- Constant Field Values
-
DEGREES_PARAM
public static final String DEGREES_PARAM
- See Also:
- Constant Field Values
-
KILOMETERS
public static final DistanceUnits KILOMETERS
-
MILES
public static final DistanceUnits MILES
-
DEGREES
public static final DistanceUnits DEGREES
-
-
Method Detail
-
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 useAbstractSpatialFieldType.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.
-
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 unitsearthRadius
- radius of earth in supplied unitsmultiplierThisToDegrees
- multiplier to convert to degrees
-
-