com.blackbirdai.client.model.GeoParam Maven / Gradle / Ivy
package com.blackbirdai.client.model;
import com.blackbirdai.client.InvalidRequestException;
import com.blackbirdai.client.util.Patterns;
import com.google.common.base.Optional;
import java.util.Collections;
import java.util.List;
public class GeoParam extends Param {
private final String field;
private final Number latitude;
private final Number longitude;
private final Number distance;
public GeoParam(String field, Number latitude, Number longitude, Number distance) {
this.field = field;
this.latitude = latitude;
this.longitude = longitude;
this.distance = distance;
}
@Override
StringBuilder appendQueryStr(StringBuilder builder) throws InvalidRequestException {
if (!Patterns.FIELD_P.matcher(field).matches()) {
throw new InvalidRequestException("Invalid field-name found: " + field);
}
builder.append("&geo=field=");
builder.append(field);
builder.append("/pt=(");
builder.append(latitude);
builder.append(',');
builder.append(longitude);
builder.append(")/d=");
builder.append(distance);
return builder;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy