org.apache.solr.search.function.distance
Class HaversineFunction
java.lang.Object
org.apache.lucene.queries.function.ValueSource
org.apache.solr.search.function.distance.HaversineFunction
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
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,
FunctionValues p1DV,
FunctionValues p2DV)
- Parameters:
doc
- The doc to score
- Returns:
- The haversine distance formula
getValues
public FunctionValues getValues(Map context,
AtomicReaderContext readerContext)
throws IOException
- Specified by:
getValues
in class ValueSource
- Throws:
IOException
createWeight
public void createWeight(Map context,
IndexSearcher searcher)
throws IOException
- 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()
- Specified by:
description
in class ValueSource
Copyright © 2000-2014 Apache Software Foundation. All Rights Reserved.