aboutsummaryrefslogtreecommitdiffstats
path: root/client/src/main/java/ai/vespa/client/dsl/GeoLocation.java
blob: 46777a855a83f3ed63a2cd03aa9aeddde1e251a9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package ai.vespa.client.dsl;

public class GeoLocation extends QueryChain {

    private final String fieldName;
    private final Double longitude;
    private final Double latitude;
    private final String radius;

    public GeoLocation(String fieldName, Double longitude, Double latitude, String radius) {
        this.fieldName = fieldName;
        this.longitude = longitude;
        this.latitude = latitude;
        this.radius = radius;
        this.nonEmpty = true;
    }

    @Override
    boolean hasPositiveSearchField(String fieldName) {
        return this.fieldName.equals(fieldName);
    }

    @Override
    boolean hasPositiveSearchField(String fieldName, Object value) {
        return false;
    }

    @Override
    boolean hasNegativeSearchField(String fieldName) {
        return false;
    }

    @Override
    boolean hasNegativeSearchField(String fieldName, Object value) {
        return false;
    }

    @Override
    public String toString() {
        return Text.format("geoLocation(%s, %f, %f, %s)", fieldName, longitude, latitude, Q.toJson(radius));
    }
}