lucene-solr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From yo...@apache.org
Subject svn commit: r889694 - in /lucene/solr/trunk/src/java/org/apache/solr/search: ValueSourceParser.java function/distance/DistanceUtils.java
Date Fri, 11 Dec 2009 16:53:32 GMT
Author: yonik
Date: Fri Dec 11 16:53:31 2009
New Revision: 889694

URL: http://svn.apache.org/viewvc?rev=889694&view=rev
Log:
optimize degree/radian conversion - just use constants. Silly Math.toRadians() uses division

Modified:
    lucene/solr/trunk/src/java/org/apache/solr/search/ValueSourceParser.java
    lucene/solr/trunk/src/java/org/apache/solr/search/function/distance/DistanceUtils.java

Modified: lucene/solr/trunk/src/java/org/apache/solr/search/ValueSourceParser.java
URL: http://svn.apache.org/viewvc/lucene/solr/trunk/src/java/org/apache/solr/search/ValueSourceParser.java?rev=889694&r1=889693&r2=889694&view=diff
==============================================================================
--- lucene/solr/trunk/src/java/org/apache/solr/search/ValueSourceParser.java (original)
+++ lucene/solr/trunk/src/java/org/apache/solr/search/ValueSourceParser.java Fri Dec 11 16:53:31
2009
@@ -32,13 +32,7 @@
 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 @@
 
     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") {

Modified: lucene/solr/trunk/src/java/org/apache/solr/search/function/distance/DistanceUtils.java
URL: http://svn.apache.org/viewvc/lucene/solr/trunk/src/java/org/apache/solr/search/function/distance/DistanceUtils.java?rev=889694&r1=889693&r2=889694&view=diff
==============================================================================
--- lucene/solr/trunk/src/java/org/apache/solr/search/function/distance/DistanceUtils.java
(original)
+++ lucene/solr/trunk/src/java/org/apache/solr/search/function/distance/DistanceUtils.java
Fri Dec 11 16:53:31 2009
@@ -22,6 +22,9 @@
  *
  **/
 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 @@
     }
     return result;
   }
+
+
 }



Mime
View raw message