aboutsummaryrefslogtreecommitdiffstats
path: root/streamingvisitors
diff options
context:
space:
mode:
authorArne Juul <arnej@verizonmedia.com>2020-07-10 17:36:59 +0000
committerArne Juul <arnej@verizonmedia.com>2020-07-15 15:39:22 +0000
commit2ef06d7de7cd52c9c41c6275413688e4359f979f (patch)
tree311aad2ed3470a737c42f37c8f1391abd4afd523 /streamingvisitors
parent5fc7cc737144fc27ed7de2761a2f041750c949c7 (diff)
split out geo location parser into its own distinct class
Diffstat (limited to 'streamingvisitors')
-rw-r--r--streamingvisitors/src/vespa/searchvisitor/queryenvironment.cpp18
1 files changed, 5 insertions, 13 deletions
diff --git a/streamingvisitors/src/vespa/searchvisitor/queryenvironment.cpp b/streamingvisitors/src/vespa/searchvisitor/queryenvironment.cpp
index 70d304b4a87..5112ce59dfb 100644
--- a/streamingvisitors/src/vespa/searchvisitor/queryenvironment.cpp
+++ b/streamingvisitors/src/vespa/searchvisitor/queryenvironment.cpp
@@ -21,22 +21,14 @@ parseLocation(const string & location_str)
if (location_str.empty()) {
return fefLocation;
}
- string::size_type pos = location_str.find(':');
- if (pos == string::npos) {
- LOG(warning, "Location string lacks attribute vector specification. loc='%s'. Location ignored.",
- location_str.c_str());
- return fefLocation;
- }
- string attr = location_str.substr(0, pos);
- const string location = location_str.substr(pos + 1);
-
- search::common::GeoLocationSpec locationSpec;
- if (!locationSpec.parseOldFormat(location)) {
+ search::common::GeoLocationParser locationParser;
+ if (!locationParser.parseOldFormatWithField(location_str)) {
LOG(warning, "Location parse error (location: '%s'): %s. Location ignored.",
- location.c_str(), locationSpec.getParseError());
+ location_str.c_str(), locationParser.getParseError());
return fefLocation;
}
- fefLocation.setAttribute(attr);
+ auto locationSpec = locationParser.spec();
+ fefLocation.setAttribute(locationSpec.getFieldName());
fefLocation.setXPosition(locationSpec.getX());
fefLocation.setYPosition(locationSpec.getY());
fefLocation.setXAspect(locationSpec.getXAspect());