本文整理汇总了Java中redis.clients.jedis.GeoUnit类的典型用法代码示例。如果您正苦于以下问题:Java GeoUnit类的具体用法?Java GeoUnit怎么用?Java GeoUnit使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
GeoUnit类属于redis.clients.jedis包,在下文中一共展示了GeoUnit类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: georadiusByMember
import redis.clients.jedis.GeoUnit; //导入依赖的package包/类
@Test
public void georadiusByMember() {
jedis.geoadd("Sicily", 13.583333, 37.316667, "Agrigento");
jedis.geoadd("Sicily", 13.361389, 38.115556, "Palermo");
jedis.geoadd("Sicily", 15.087269, 37.502669, "Catania");
List<GeoRadiusResponse> members = jedis.georadiusByMember("Sicily", "Agrigento", 100,
GeoUnit.KM);
assertEquals(2, members.size());
members = jedis.georadiusByMember("Sicily", "Agrigento", 100, GeoUnit.KM, GeoRadiusParam
.geoRadiusParam().sortAscending());
assertEquals(2, members.size());
assertEquals("Agrigento", members.get(0).getMemberByString());
assertEquals("Palermo", members.get(1).getMemberByString());
members = jedis.georadiusByMember("Sicily", "Agrigento", 100, GeoUnit.KM, GeoRadiusParam
.geoRadiusParam().sortAscending().count(1).withCoord().withDist());
assertEquals(1, members.size());
GeoRadiusResponse member = members.get(0);
assertEquals("Agrigento", member.getMemberByString());
assertTrue(equalsWithinEpsilon(0, member.getDistance()));
assertTrue(equalsWithinEpsilon(13.583333, member.getCoordinate().getLongitude()));
assertTrue(equalsWithinEpsilon(37.316667, member.getCoordinate().getLatitude()));
}
开发者ID:qq1588518,项目名称:JRediClients,代码行数:27,代码来源:GeoCommandsTest.java
示例2: georadiusByMemberBinary
import redis.clients.jedis.GeoUnit; //导入依赖的package包/类
@Test
public void georadiusByMemberBinary() {
jedis.geoadd(bfoo, 13.583333, 37.316667, bA);
jedis.geoadd(bfoo, 13.361389, 38.115556, bB);
jedis.geoadd(bfoo, 15.087269, 37.502669, bC);
List<GeoRadiusResponse> members = jedis.georadiusByMember(bfoo, bA, 100, GeoUnit.KM);
assertEquals(2, members.size());
members = jedis.georadiusByMember(bfoo, bA, 100, GeoUnit.KM, GeoRadiusParam.geoRadiusParam()
.sortAscending());
assertEquals(2, members.size());
assertArrayEquals(bA, members.get(0).getMember());
assertArrayEquals(bB, members.get(1).getMember());
members = jedis.georadiusByMember(bfoo, bA, 100, GeoUnit.KM, GeoRadiusParam.geoRadiusParam()
.sortAscending().count(1).withCoord().withDist());
assertEquals(1, members.size());
GeoRadiusResponse member = members.get(0);
assertArrayEquals(bA, member.getMember());
assertTrue(equalsWithinEpsilon(0, member.getDistance()));
assertTrue(equalsWithinEpsilon(13.583333, member.getCoordinate().getLongitude()));
assertTrue(equalsWithinEpsilon(37.316667, member.getCoordinate().getLatitude()));
}
开发者ID:qq1588518,项目名称:JRediClients,代码行数:26,代码来源:GeoCommandsTest.java
示例3: georadius
import redis.clients.jedis.GeoUnit; //导入依赖的package包/类
@Override
public List<GeoRadiusResponse> georadius(byte[] key, double longitude, double latitude,
double radius, GeoUnit unit) {
Span span = helper.buildSpan("georadius", key);
span.setTag("longitude", longitude);
span.setTag("latitude", latitude);
span.setTag("radius", radius);
span.setTag("unit", unit.name());
try {
return super.georadius(key, longitude, latitude, radius, unit);
} catch (Exception e) {
onError(e, span);
throw e;
} finally {
span.finish();
}
}
开发者ID:opentracing-contrib,项目名称:java-redis-client,代码行数:18,代码来源:TracingJedisCluster.java
示例4: georadiusByMember
import redis.clients.jedis.GeoUnit; //导入依赖的package包/类
@Override
public List<GeoRadiusResponse> georadiusByMember(byte[] key, byte[] member, double radius,
GeoUnit unit) {
Span span = helper.buildSpan("georadiusByMember", key);
span.setTag("member", Arrays.toString(member));
span.setTag("radius", radius);
span.setTag("unit", unit.name());
try {
return super.georadiusByMember(key, member, radius, unit);
} catch (Exception e) {
onError(e, span);
throw e;
} finally {
span.finish();
}
}
开发者ID:opentracing-contrib,项目名称:java-redis-client,代码行数:17,代码来源:TracingJedisCluster.java
示例5: radious
import redis.clients.jedis.GeoUnit; //导入依赖的package包/类
public List<Postion> radious(String type, GeoCoordinate center, Long distinct, Boolean asc) {
List<Postion> postions = new ArrayList<Postion>();
Jedis jedis = redisConnection.getJedis();
try {
GeoRadiusParam geoRadiusParam = GeoRadiusParam.geoRadiusParam().withCoord().withDist();
if (asc) {
geoRadiusParam.sortAscending();
} else {
geoRadiusParam.sortDescending();
}
List<GeoRadiusResponse> responses = jedis.georadius(type,
center.getLongitude(),
center.getLatitude(),
distinct.doubleValue(),
GeoUnit.M,
geoRadiusParam);
if (responses != null) {
for (GeoRadiusResponse response : responses) {
Postion postion = new Postion(response.getMemberByString(),
type,
response.getCoordinate().getLongitude(),
response.getCoordinate().getLatitude());
postion.setDistinct(response.getDistance());
postions.add(postion);
}
}
} finally {
if (jedis != null) {
jedis.close();
}
}
return postions;
}
开发者ID:gaochao2000,项目名称:redis_util,代码行数:35,代码来源:LBSServiceRedisImpl.java
示例6: geodist
import redis.clients.jedis.GeoUnit; //导入依赖的package包/类
@Test
public void geodist() {
prepareGeoData();
Double dist = jedis.geodist("foo", "a", "b");
assertEquals(dist.intValue(), 157149);
dist = jedis.geodist("foo", "a", "b", GeoUnit.KM);
assertEquals(dist.intValue(), 157);
dist = jedis.geodist("foo", "a", "b", GeoUnit.MI);
assertEquals(dist.intValue(), 97);
dist = jedis.geodist("foo", "a", "b", GeoUnit.FT);
assertEquals(dist.intValue(), 515583);
// binary
dist = jedis.geodist(bfoo, bA, bB);
assertEquals(dist.intValue(), 157149);
dist = jedis.geodist(bfoo, bA, bB, GeoUnit.KM);
assertEquals(dist.intValue(), 157);
dist = jedis.geodist(bfoo, bA, bB, GeoUnit.MI);
assertEquals(dist.intValue(), 97);
dist = jedis.geodist(bfoo, bA, bB, GeoUnit.FT);
assertEquals(dist.intValue(), 515583);
}
开发者ID:qq1588518,项目名称:JRediClients,代码行数:30,代码来源:GeoCommandsTest.java
示例7: georadius
import redis.clients.jedis.GeoUnit; //导入依赖的package包/类
@Test
public void georadius() {
// prepare datas
Map<String, GeoCoordinate> coordinateMap = new HashMap<String, GeoCoordinate>();
coordinateMap.put("Palermo", new GeoCoordinate(13.361389, 38.115556));
coordinateMap.put("Catania", new GeoCoordinate(15.087269, 37.502669));
jedis.geoadd("Sicily", coordinateMap);
List<GeoRadiusResponse> members = jedis.georadius("Sicily", 15, 37, 200, GeoUnit.KM);
assertEquals(2, members.size());
// sort
members = jedis.georadius("Sicily", 15, 37, 200, GeoUnit.KM, GeoRadiusParam.geoRadiusParam()
.sortAscending());
assertEquals(2, members.size());
assertEquals("Catania", members.get(0).getMemberByString());
assertEquals("Palermo", members.get(1).getMemberByString());
// sort, count 1
members = jedis.georadius("Sicily", 15, 37, 200, GeoUnit.KM, GeoRadiusParam.geoRadiusParam()
.sortAscending().count(1));
assertEquals(1, members.size());
// sort, count 1, withdist, withcoord
members = jedis.georadius("Sicily", 15, 37, 200, GeoUnit.KM, GeoRadiusParam.geoRadiusParam()
.sortAscending().count(1).withCoord().withDist());
assertEquals(1, members.size());
GeoRadiusResponse response = members.get(0);
assertTrue(equalsWithinEpsilon(56.4413, response.getDistance()));
assertTrue(equalsWithinEpsilon(15.087269, response.getCoordinate().getLongitude()));
assertTrue(equalsWithinEpsilon(37.502669, response.getCoordinate().getLatitude()));
}
开发者ID:qq1588518,项目名称:JRediClients,代码行数:33,代码来源:GeoCommandsTest.java
示例8: georadiusBinary
import redis.clients.jedis.GeoUnit; //导入依赖的package包/类
@Test
public void georadiusBinary() {
// prepare datas
Map<byte[], GeoCoordinate> bcoordinateMap = new HashMap<byte[], GeoCoordinate>();
bcoordinateMap.put(bA, new GeoCoordinate(13.361389, 38.115556));
bcoordinateMap.put(bB, new GeoCoordinate(15.087269, 37.502669));
jedis.geoadd(bfoo, bcoordinateMap);
List<GeoRadiusResponse> members = jedis.georadius(bfoo, 15, 37, 200, GeoUnit.KM);
assertEquals(2, members.size());
// sort
members = jedis.georadius(bfoo, 15, 37, 200, GeoUnit.KM, GeoRadiusParam.geoRadiusParam()
.sortAscending());
assertEquals(2, members.size());
assertArrayEquals(bB, members.get(0).getMember());
assertArrayEquals(bA, members.get(1).getMember());
// sort, count 1
members = jedis.georadius(bfoo, 15, 37, 200, GeoUnit.KM, GeoRadiusParam.geoRadiusParam()
.sortAscending().count(1));
assertEquals(1, members.size());
// sort, count 1, withdist, withcoord
members = jedis.georadius(bfoo, 15, 37, 200, GeoUnit.KM, GeoRadiusParam.geoRadiusParam()
.sortAscending().count(1).withCoord().withDist());
assertEquals(1, members.size());
GeoRadiusResponse response = members.get(0);
assertTrue(equalsWithinEpsilon(56.4413, response.getDistance()));
assertTrue(equalsWithinEpsilon(15.087269, response.getCoordinate().getLongitude()));
assertTrue(equalsWithinEpsilon(37.502669, response.getCoordinate().getLatitude()));
}
开发者ID:qq1588518,项目名称:JRediClients,代码行数:33,代码来源:GeoCommandsTest.java
示例9: geodist
import redis.clients.jedis.GeoUnit; //导入依赖的package包/类
@Override
public Double geodist(byte[] key, byte[] member1, byte[] member2, GeoUnit unit) {
Span span = helper.buildSpan("geodist", key);
span.setTag("member1", Arrays.toString(member1));
span.setTag("member2", Arrays.toString(member2));
span.setTag("unit", unit.name());
try {
return super.geodist(key, member1, member2, unit);
} catch (Exception e) {
onError(e, span);
throw e;
} finally {
span.finish();
}
}
开发者ID:opentracing-contrib,项目名称:java-redis-client,代码行数:16,代码来源:TracingJedisCluster.java
示例10: GetGeoUnitByEnum
import redis.clients.jedis.GeoUnit; //导入依赖的package包/类
private GeoUnit GetGeoUnitByEnum(redisconnector.proxies.Enum_GeoUnit Unit) {
switch (Unit) {
case FT:
return GeoUnit.FT;
case MI:
return GeoUnit.MI;
case KM:
return GeoUnit.KM;
default:
return GeoUnit.M;
}
}
开发者ID:appronto,项目名称:RedisConnector,代码行数:13,代码来源:RedisConnector.java
示例11: geodist
import redis.clients.jedis.GeoUnit; //导入依赖的package包/类
@Override
public Double geodist(String arg0, String arg1, String arg2, GeoUnit arg3) {
// TODO Auto-generated method stub
return null;
}
开发者ID:tanhaichao,项目名称:leopard,代码行数:6,代码来源:RedisHashImpl.java
示例12: georadius
import redis.clients.jedis.GeoUnit; //导入依赖的package包/类
@Override
public List<GeoRadiusResponse> georadius(String arg0, double arg1, double arg2, double arg3, GeoUnit arg4) {
// TODO Auto-generated method stub
return null;
}
开发者ID:tanhaichao,项目名称:leopard,代码行数:6,代码来源:RedisHashImpl.java
示例13: georadiusByMember
import redis.clients.jedis.GeoUnit; //导入依赖的package包/类
@Override
public List<GeoRadiusResponse> georadiusByMember(String arg0, String arg1, double arg2, GeoUnit arg3) {
// TODO Auto-generated method stub
return null;
}
开发者ID:tanhaichao,项目名称:leopard,代码行数:6,代码来源:RedisHashImpl.java
注:本文中的redis.clients.jedis.GeoUnit类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论