org.apache.solr.search.function.distance
Class HaversineFunction
java.lang.Object
org.apache.solr.search.function.ValueSource
org.apache.solr.search.function.distance.HaversineFunction
- All Implemented Interfaces:
- Serializable
public class HaversineFunction
- extends 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
- See Also:
- Serialized Form
Method Summary |
void |
createWeight(Map context,
org.apache.lucene.search.Searcher searcher)
Implementations should propagate createWeight to sub-ValueSources which can optionally store
weight info in the context. |
String |
description()
description of field, used in explain() |
protected double |
distance(int doc,
DocValues p1DV,
DocValues p2DV)
|
boolean |
equals(Object o)
|
DocValues |
getValues(Map context,
org.apache.lucene.index.IndexReader reader)
Gets the values for this reader and the context that was previously
passed to createWeight() |
int |
hashCode()
|
protected String |
name()
|
HaversineFunction
public HaversineFunction(MultiValueSource p1,
MultiValueSource p2,
double radius)
HaversineFunction
public HaversineFunction(MultiValueSource p1,
MultiValueSource p2,
double radius,
boolean convertToRads)
name
protected String name()
distance
protected double distance(int doc,
DocValues p1DV,
DocValues p2DV)
- Parameters:
doc
- The doc to scorep1DV
- p2DV
-
- Returns:
- The haversine distance formula
getValues
public DocValues getValues(Map context,
org.apache.lucene.index.IndexReader reader)
throws IOException
- Description copied from class:
ValueSource
- Gets the values for this reader and the context that was previously
passed to createWeight()
- Overrides:
getValues
in class ValueSource
- Throws:
IOException
createWeight
public void createWeight(Map context,
org.apache.lucene.search.Searcher searcher)
throws IOException
- Description copied from class:
ValueSource
- Implementations should propagate createWeight to sub-ValueSources which can optionally store
weight info in the context. The context object will be passed to getValues()
where this info can be retrieved.
- Overrides:
createWeight
in class ValueSource
- Throws:
IOException
equals
public boolean equals(Object o)
- Specified by:
equals
in class ValueSource
hashCode
public int hashCode()
- Specified by:
hashCode
in class ValueSource
description
public String description()
- Description copied from class:
ValueSource
- description of field, used in explain()
- Specified by:
description
in class ValueSource
Copyright © 2000-2011 Apache Software Foundation. All Rights Reserved.