mirror of https://github.com/apache/lucene.git
optimize degree/radian conversion - just use constants. Silly Math.toRadians() uses division
git-svn-id: https://svn.apache.org/repos/asf/lucene/solr/trunk@889694 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
8cbde0c0ba
commit
3acf3bce1e
|
@ -32,13 +32,7 @@ import org.apache.solr.schema.SchemaField;
|
|||
import org.apache.solr.schema.TrieDateField;
|
||||
import org.apache.solr.search.function.*;
|
||||
|
||||
import org.apache.solr.search.function.distance.HaversineFunction;
|
||||
|
||||
import org.apache.solr.search.function.distance.SquaredEuclideanFunction;
|
||||
import org.apache.solr.search.function.distance.VectorDistanceFunction;
|
||||
import org.apache.solr.search.function.distance.GeohashHaversineFunction;
|
||||
import org.apache.solr.search.function.distance.GeohashFunction;
|
||||
import org.apache.solr.search.function.distance.StringDistanceFunction;
|
||||
import org.apache.solr.search.function.distance.*;
|
||||
import org.apache.solr.util.plugin.NamedListInitializedPlugin;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -287,12 +281,12 @@ public abstract class ValueSourceParser implements NamedListInitializedPlugin {
|
|||
|
||||
addParser(new DoubleParser("rad") {
|
||||
public double func(int doc, DocValues vals) {
|
||||
return Math.toRadians(vals.doubleVal(doc));
|
||||
return vals.doubleVal(doc) * DistanceUtils.DEGREES_TO_RADIANS;
|
||||
}
|
||||
});
|
||||
addParser(new DoubleParser("deg") {
|
||||
public double func(int doc, DocValues vals) {
|
||||
return Math.toDegrees(vals.doubleVal(doc));
|
||||
return vals.doubleVal(doc) * DistanceUtils.RADIANS_TO_DEGREES;
|
||||
}
|
||||
});
|
||||
addParser(new DoubleParser("sqrt") {
|
||||
|
|
|
@ -22,6 +22,9 @@ package org.apache.solr.search.function.distance;
|
|||
*
|
||||
**/
|
||||
public class DistanceUtils {
|
||||
public static final double DEGREES_TO_RADIANS = Math.PI / 180.0;
|
||||
public static final double RADIANS_TO_DEGREES = 180.0 / Math.PI;
|
||||
|
||||
/**
|
||||
* @see org.apache.solr.search.function.distance.HaversineFunction
|
||||
*
|
||||
|
@ -46,4 +49,6 @@ public class DistanceUtils {
|
|||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue