Class HaversineFunction
- java.lang.Object
-
- org.apache.lucene.queries.function.ValueSource
-
- org.apache.solr.search.function.distance.HaversineFunction
-
public class HaversineFunction extends org.apache.lucene.queries.function.ValueSource
Calculate the Haversine formula (distance) between any two points on a sphere Takes in four value sources: (latA, lonA); (latB, lonB).Assumes the value sources are in radians unless
See http://en.wikipedia.org/wiki/Great-circle_distance and http://en.wikipedia.org/wiki/Haversine_formula for the actual formula and also http://www.movable-type.co.uk/scripts/latlong.html
-
-
Constructor Summary
Constructors Constructor Description HaversineFunction(org.apache.lucene.queries.function.valuesource.MultiValueSource p1, org.apache.lucene.queries.function.valuesource.MultiValueSource p2, double radius)
HaversineFunction(org.apache.lucene.queries.function.valuesource.MultiValueSource p1, org.apache.lucene.queries.function.valuesource.MultiValueSource p2, double radius, boolean convertToRads)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
createWeight(Map<Object,Object> context, org.apache.lucene.search.IndexSearcher searcher)
String
description()
protected double
distance(int doc, org.apache.lucene.queries.function.FunctionValues p1DV, org.apache.lucene.queries.function.FunctionValues p2DV)
boolean
equals(Object o)
org.apache.lucene.queries.function.FunctionValues
getValues(Map<Object,Object> context, org.apache.lucene.index.LeafReaderContext readerContext)
int
hashCode()
protected String
name()
-
-
-
Constructor Detail
-
HaversineFunction
public HaversineFunction(org.apache.lucene.queries.function.valuesource.MultiValueSource p1, org.apache.lucene.queries.function.valuesource.MultiValueSource p2, double radius)
-
HaversineFunction
public HaversineFunction(org.apache.lucene.queries.function.valuesource.MultiValueSource p1, org.apache.lucene.queries.function.valuesource.MultiValueSource p2, double radius, boolean convertToRads)
-
-
Method Detail
-
name
protected String name()
-
distance
protected double distance(int doc, org.apache.lucene.queries.function.FunctionValues p1DV, org.apache.lucene.queries.function.FunctionValues p2DV) throws IOException
- Parameters:
doc
- The doc to score- Returns:
- The haversine distance formula
- Throws:
IOException
-
getValues
public org.apache.lucene.queries.function.FunctionValues getValues(Map<Object,Object> context, org.apache.lucene.index.LeafReaderContext readerContext) throws IOException
- Specified by:
getValues
in classorg.apache.lucene.queries.function.ValueSource
- Throws:
IOException
-
createWeight
public void createWeight(Map<Object,Object> context, org.apache.lucene.search.IndexSearcher searcher) throws IOException
- Overrides:
createWeight
in classorg.apache.lucene.queries.function.ValueSource
- Throws:
IOException
-
equals
public boolean equals(Object o)
- Specified by:
equals
in classorg.apache.lucene.queries.function.ValueSource
-
hashCode
public int hashCode()
- Specified by:
hashCode
in classorg.apache.lucene.queries.function.ValueSource
-
description
public String description()
- Specified by:
description
in classorg.apache.lucene.queries.function.ValueSource
-
-