Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
com.aliyun.tair.tairgis.TairGisCluster Maven / Gradle / Ivy
Go to download
Aliyun Tair Redis client for Java
Copyright (C) Alibaba Cloud Computing
All rights reserved.
版权所有 (C)阿里云计算有限公司
http://www.aliyun.com
package com.aliyun.tair.tairgis;
import com.aliyun.tair.ModuleCommand;
import com.aliyun.tair.tairgis.factory.GisBuilderFactory;
import com.aliyun.tair.tairgis.params.GisParams;
import com.aliyun.tair.tairgis.params.GisSearchResponse;
import redis.clients.jedis.BuilderFactory;
import redis.clients.jedis.GeoUnit;
import redis.clients.jedis.JedisCluster;
import redis.clients.jedis.Protocol;
import redis.clients.jedis.util.SafeEncoder;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class TairGisCluster {
private JedisCluster jc;
public TairGisCluster(JedisCluster jc) {
this.jc = jc;
}
public Long gisadd(final String key, final String polygonName, final String polygonWktText) {
Object obj = jc.sendCommand(key, ModuleCommand.GISADD, key, polygonName, polygonWktText);
return BuilderFactory.LONG.build(obj);
}
public Long gisadd(final byte[] key, final byte[] polygonName, final byte[] polygonWktText) {
Object obj = jc.sendCommand(key, ModuleCommand.GISADD, key, polygonName, polygonWktText);
return BuilderFactory.LONG.build(obj);
}
public String gisget(final String key, final String polygonName) {
Object obj = jc.sendCommand(key, ModuleCommand.GISGET, key, polygonName);
return BuilderFactory.STRING.build(obj);
}
public byte[] gisget(final byte[] key, final byte[] polygonName) {
Object obj = jc.sendCommand(key, ModuleCommand.GISGET, key, polygonName);
return BuilderFactory.BYTE_ARRAY.build(obj);
}
public Map gissearch(final String key, final String pointWktText) {
Object obj = jc.sendCommand(key, ModuleCommand.GISSEARCH, key, pointWktText);
List result = (List) obj;
if (null == result || 0 == result.size()) {
return new HashMap();
} else {
List rawResults = (List) result.get(1);
return (Map) BuilderFactory.STRING_MAP.build(rawResults);
}
}
public Map gissearch(final byte[] key, final byte[] pointWktText) {
Object obj = jc.sendCommand(key, ModuleCommand.GISSEARCH, key, pointWktText);
List result = (List) obj;
if (null == result || 0 == result.size()) {
return new HashMap();
} else {
List rawResults = (List) result.get(1);
return (Map) BuilderFactory.BYTE_ARRAY_MAP.build(rawResults);
}
}
public List gissearch(final String key, final double longitude, final double latitude,
final double radius, final GeoUnit unit, final GisParams gisParams) {
Object obj = jc.sendCommand(SafeEncoder.encode(key), ModuleCommand.GISSEARCH,
gisParams.getByteParams(SafeEncoder.encode(key), SafeEncoder.encode(GisParams.RADIUS),
Protocol.toByteArray(longitude), Protocol.toByteArray(latitude),
Protocol.toByteArray(radius), unit.raw));
return GisBuilderFactory.GISSEARCH_WITH_PARAMS_RESULT.build(obj);
}
public List gissearch(final byte[] key, final double longitude, final double latitude,
final double radius, final GeoUnit unit, final GisParams gisParams) {
Object obj = jc.sendCommand(key, ModuleCommand.GISSEARCH,
gisParams.getByteParams(key, SafeEncoder.encode(GisParams.RADIUS),
Protocol.toByteArray(longitude), Protocol.toByteArray(latitude),
Protocol.toByteArray(radius), unit.raw));
return GisBuilderFactory.GISSEARCH_WITH_PARAMS_RESULT.build(obj);
}
public List gissearchByMember(final String key, String member, final double radius,
final GeoUnit unit, final GisParams gisParams) {
Object obj = jc.sendCommand(SafeEncoder.encode(key), ModuleCommand.GISSEARCH,
gisParams.getByteParams(SafeEncoder.encode(key), SafeEncoder.encode(GisParams.MEMBER),
SafeEncoder.encode(member), Protocol.toByteArray(radius), unit.raw));
return GisBuilderFactory.GISSEARCH_WITH_PARAMS_RESULT.build(obj);
}
public List gissearchByMember(final byte[] key, byte[] member, final double radius,
final GeoUnit unit, final GisParams gisParams) {
Object obj = jc.sendCommand(key, ModuleCommand.GISSEARCH,
gisParams.getByteParams(key, SafeEncoder.encode(GisParams.MEMBER), member,
Protocol.toByteArray(radius), unit.raw));
return GisBuilderFactory.GISSEARCH_WITH_PARAMS_RESULT.build(obj);
}
public Map giscontains(final String key, final String pointWktText) {
Object obj = jc.sendCommand(key, ModuleCommand.GISCONTAINS, key, pointWktText);
List result = (List) obj;
if (null == result || 0 == result.size()) {
return new HashMap();
} else {
List rawResults = (List) result.get(1);
return (Map) BuilderFactory.STRING_MAP.build(rawResults);
}
}
public List giscontains(final String key, final String pointWktText, final GisParams gisParams) {
Object obj = jc.sendCommand(SafeEncoder.encode(key), ModuleCommand.GISCONTAINS,
gisParams.getByteParams(SafeEncoder.encode(key), SafeEncoder.encode(pointWktText)));
List result = (List) obj;
if (null == result || 0 == result.size()) {
return new ArrayList();
} else {
List rawResults = (List) result.get(1);
return BuilderFactory.STRING_LIST.build(rawResults);
}
}
public Map giscontains(final byte[] key, final byte[] pointWktText) {
Object obj = jc.sendCommand(key, ModuleCommand.GISCONTAINS, key, pointWktText);
List result = (List) obj;
if (null == result || 0 == result.size()) {
return new HashMap();
} else {
List rawResults = (List) result.get(1);
return (Map) BuilderFactory.BYTE_ARRAY_MAP.build(rawResults);
}
}
public List giscontains(final byte[] key, final byte[] pointWktText, final GisParams gisParams) {
Object obj = jc.sendCommand(key, ModuleCommand.GISCONTAINS, gisParams.getByteParams(key, pointWktText));
List result = (List) obj;
if (null == result || 0 == result.size()) {
return new ArrayList();
} else {
List rawResults = (List) result.get(1);
return BuilderFactory.BYTE_ARRAY_LIST.build(rawResults);
}
}
public Map giswithin(final String key, final String pointWktText) {
Object obj = jc.sendCommand(key, ModuleCommand.GISWITHIN, key, pointWktText);
List result = (List) obj;
if (null == result || 0 == result.size()) {
return new HashMap();
} else {
List rawResults = (List) result.get(1);
return (Map) BuilderFactory.STRING_MAP.build(rawResults);
}
}
public List giswithin(final String key, final String pointWktText, final GisParams gisParams) {
Object obj = jc.sendCommand(SafeEncoder.encode(key), ModuleCommand.GISWITHIN,
gisParams.getByteParams(SafeEncoder.encode(key), SafeEncoder.encode(pointWktText)));
List result = (List) obj;
if (null == result || 0 == result.size()) {
return new ArrayList();
} else {
List rawResults = (List) result.get(1);
return BuilderFactory.STRING_LIST.build(rawResults);
}
}
public Map giswithin(final byte[] key, final byte[] pointWktText) {
Object obj = jc.sendCommand(key, ModuleCommand.GISWITHIN, key, pointWktText);
List result = (List) obj;
if (null == result || 0 == result.size()) {
return new HashMap();
} else {
List rawResults = (List) result.get(1);
return (Map) BuilderFactory.BYTE_ARRAY_MAP.build(rawResults);
}
}
public List giswithin(final byte[] key, final byte[] pointWktText, final GisParams gisParams) {
Object obj = jc.sendCommand(key, ModuleCommand.GISWITHIN, gisParams.getByteParams(key, pointWktText));
List result = (List) obj;
if (null == result || 0 == result.size()) {
return new ArrayList();
} else {
List rawResults = (List) result.get(1);
return BuilderFactory.BYTE_ARRAY_LIST.build(rawResults);
}
}
public Map gisintersects(final String key, final String pointWktText) {
Object obj = jc.sendCommand(key, ModuleCommand.GISINTERSECTS, key, pointWktText);
List result = (List) obj;
if (null == result || 0 == result.size()) {
return new HashMap();
} else {
List rawResults = (List) result.get(1);
return (Map) BuilderFactory.STRING_MAP.build(rawResults);
}
}
public Map gisintersects(final byte[] key, final byte[] pointWktText) {
Object obj = jc.sendCommand(key, ModuleCommand.GISINTERSECTS, key, pointWktText);
List result = (List) obj;
if (null == result || 0 == result.size()) {
return new HashMap();
} else {
List rawResults = (List) result.get(1);
return (Map) BuilderFactory.BYTE_ARRAY_MAP.build(rawResults);
}
}
public String gisdel(final String key, final String polygonName) {
Object obj = jc.sendCommand(key, ModuleCommand.GISDEL, key, polygonName);
return BuilderFactory.STRING.build(obj);
}
public byte[] gisdel(final byte[] key, final byte[] polygonName) {
Object obj = jc.sendCommand(key, ModuleCommand.GISDEL, key, polygonName);
return BuilderFactory.BYTE_ARRAY.build(obj);
}
public Map gisgetall(final String key) {
Object obj = jc.sendCommand(key, ModuleCommand.GISGETALL, key);
return BuilderFactory.STRING_MAP.build(obj);
}
public List gisgetall(final String key, final GisParams gisParams) {
Object obj = jc.sendCommand(SafeEncoder.encode(key), ModuleCommand.GISGETALL,
gisParams.getByteParams(SafeEncoder.encode(key)));
return BuilderFactory.STRING_LIST.build(obj);
}
public Map gisgetall(final byte[] key) {
Object obj = jc.sendCommand(key, ModuleCommand.GISGETALL, key);
return BuilderFactory.BYTE_ARRAY_MAP.build(obj);
}
public List gisgetall(final byte[] key, final GisParams gisParams) {
Object obj =jc.sendCommand(key, ModuleCommand.GISGETALL, gisParams.getByteParams(key));
return BuilderFactory.BYTE_ARRAY_LIST.build(obj);
}
}