Skip to content
Browse files

Clarify logic in asc/desc multi-val selection.

  • Loading branch information...
1 parent f494df2 commit 5c54ef140c8470e7fbeaee975b134944fcb23ba6 @dsmiley committed Apr 18, 2012
Showing with 13 additions and 16 deletions.
  1. +13 −16 src/main/java/solr2155/solr/search/function/distance/HaversineMultiConstFunction.java
View
29 src/main/java/solr2155/solr/search/function/distance/HaversineMultiConstFunction.java
@@ -69,23 +69,20 @@ public long longVal(int doc) {
}
public double doubleVal(int doc) {
- List<Point2D> geoList = ghDocVals.point2Ds(doc);
- if (geoList == null) {
- if (asc == false) {
- return 0.0;
- } else {
- return DistanceUtils.EARTH_MEAN_RADIUS_KM;
- }
+ double distance;
+ if (asc == false) {
+ distance = 0.0;
+ } else {
+ distance = DistanceUtils.EARTH_MEAN_RADIUS_KM * Math.PI;//v1.0.5
}
- double distance = 0.0; // this will be overlaid
- boolean firstLap = true;
- for (Point2D point : geoList) {
- double distanceNew = distance(point);
- if ((firstLap) ||
- (asc == true && distanceNew < distance) ||
- (asc == false && distanceNew > distance)) {
- distance = distanceNew;
- firstLap = false;
+ List<Point2D> geoList = ghDocVals.point2Ds(doc);
+ if (geoList != null) {
+ for (Point2D point : geoList) {
+ double distanceNew = distance(point);
+ if ((asc == true && distanceNew < distance) ||
+ (asc == false && distanceNew > distance)) {
+ distance = distanceNew;
+ }
}
}
return distance;

0 comments on commit 5c54ef1

Please sign in to comment.
Something went wrong with that request. Please try again.