summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--searchlib/src/tests/features/prod_features.cpp4
-rw-r--r--searchlib/src/vespa/searchlib/features/closenessfeature.cpp1
-rw-r--r--searchlib/src/vespa/searchlib/features/distancefeature.cpp12
-rw-r--r--searchlib/src/vespa/searchlib/features/distancefeature.h3
4 files changed, 17 insertions, 3 deletions
diff --git a/searchlib/src/tests/features/prod_features.cpp b/searchlib/src/tests/features/prod_features.cpp
index 25b5ba20d26..a82f711c621 100644
--- a/searchlib/src/tests/features/prod_features.cpp
+++ b/searchlib/src/tests/features/prod_features.cpp
@@ -830,8 +830,8 @@ Test::testDistance()
StringList params, in, out;
FT_SETUP_FAIL(pt, params);
- FT_SETUP_OK(pt, params.add("pos"), in, out.add("out"));
-
+ FT_SETUP_OK(pt, params.add("pos"), in,
+ out.add("out").add("index").add("latitude").add("longitude"));
FT_DUMP_EMPTY(_factory, "distance");
}
diff --git a/searchlib/src/vespa/searchlib/features/closenessfeature.cpp b/searchlib/src/vespa/searchlib/features/closenessfeature.cpp
index ca5b5a48ecb..341076f30dd 100644
--- a/searchlib/src/vespa/searchlib/features/closenessfeature.cpp
+++ b/searchlib/src/vespa/searchlib/features/closenessfeature.cpp
@@ -190,7 +190,6 @@ ClosenessBlueprint::setup(const IIndexEnvironment & env,
}
describeOutput("out", "The closeness of the document (linear)");
describeOutput("logscale", "The closeness of the document (logarithmic shape)");
-
return true;
}
diff --git a/searchlib/src/vespa/searchlib/features/distancefeature.cpp b/searchlib/src/vespa/searchlib/features/distancefeature.cpp
index 6582bcae92a..78a94c4abe0 100644
--- a/searchlib/src/vespa/searchlib/features/distancefeature.cpp
+++ b/searchlib/src/vespa/searchlib/features/distancefeature.cpp
@@ -82,6 +82,9 @@ ConvertRawscoreToDistance::execute(uint32_t docId)
feature_t
DistanceExecutor::calculateDistance(uint32_t docId)
{
+ _best_index = -1.0;
+ _best_x = 0.0;
+ _best_y = 0.0;
if ((! _locations.empty()) && (_pos != nullptr)) {
LOG(debug, "calculate 2D Z-distance from %zu locations", _locations.size());
return calculate2DZDistance(docId);
@@ -105,6 +108,9 @@ DistanceExecutor::calculate2DZDistance(uint32_t docId)
vespalib::geo::ZCurve::decode(_intBuf[i], &docx, &docy);
uint64_t sqdist = loc->location.sq_distance_to({docx, docy});
if (sqdist < sqabsdist) {
+ _best_index = i;
+ _best_x = docx;
+ _best_y = docy;
sqabsdist = sqdist;
}
}
@@ -128,6 +134,9 @@ void
DistanceExecutor::execute(uint32_t docId)
{
outputs().set_number(0, calculateDistance(docId));
+ outputs().set_number(1, _best_index);
+ outputs().set_number(2, _best_y * 0.000001); // latitude
+ outputs().set_number(3, _best_x * 0.000001); // longitude
}
const feature_t DistanceExecutor::DEFAULT_DISTANCE(6400000000.0);
@@ -164,6 +173,9 @@ DistanceBlueprint::setup_geopos(const IIndexEnvironment & env,
_arg_string = attr;
_use_geo_pos = true;
describeOutput("out", "The euclidean distance from the query position.");
+ describeOutput("index", "Index in array of closest point");
+ describeOutput("latitude", "Latitude of closest point");
+ describeOutput("longitude", "Longitude of closest point");
env.hintAttributeAccess(_arg_string);
return true;
}
diff --git a/searchlib/src/vespa/searchlib/features/distancefeature.h b/searchlib/src/vespa/searchlib/features/distancefeature.h
index ece139c6546..7ad19af8a3b 100644
--- a/searchlib/src/vespa/searchlib/features/distancefeature.h
+++ b/searchlib/src/vespa/searchlib/features/distancefeature.h
@@ -18,6 +18,9 @@ private:
GeoLocationSpecPtrs _locations;
const attribute::IAttributeVector * _pos;
attribute::IntegerContent _intBuf;
+ feature_t _best_index;
+ feature_t _best_x;
+ feature_t _best_y;
feature_t calculateDistance(uint32_t docId);
feature_t calculate2DZDistance(uint32_t docId);