All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.redis.riot.operation.GeoaddCommand Maven / Gradle / Ivy

The newest version!
package com.redis.riot.operation;

import java.util.Map;
import java.util.function.ToDoubleFunction;

import com.redis.riot.function.ToGeoValue;
import com.redis.spring.batch.item.redis.writer.impl.Geoadd;

import picocli.CommandLine.Command;
import picocli.CommandLine.Option;

@Command(name = "geoadd", description = "Add members to a geo set")
public class GeoaddCommand extends AbstractMemberOperationCommand {

	@Option(names = "--lon", required = true, description = "Longitude field.", paramLabel = "")
	private String longitude;

	@Option(names = "--lat", required = true, description = "Latitude field.", paramLabel = "")
	private String latitude;

	public String getLongitude() {
		return longitude;
	}

	public void setLongitude(String field) {
		this.longitude = field;
	}

	public String getLatitude() {
		return latitude;
	}

	public void setLatitude(String field) {
		this.latitude = field;
	}

	@Override
	public Geoadd> operation() {
		return new Geoadd<>(keyFunction(), geoValueFunction());
	}

	private ToGeoValue> geoValueFunction() {
		ToDoubleFunction> lon = toDouble(longitude, 0);
		ToDoubleFunction> lat = toDouble(latitude, 0);
		return new ToGeoValue<>(memberFunction(), lon, lat);
	}

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy