当前位置: 首页>>代码示例>>Java>>正文


Java GeoRadiusResponse类代码示例

本文整理汇总了Java中redis.clients.jedis.GeoRadiusResponse的典型用法代码示例。如果您正苦于以下问题:Java GeoRadiusResponse类的具体用法?Java GeoRadiusResponse怎么用?Java GeoRadiusResponse使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


GeoRadiusResponse类属于redis.clients.jedis包,在下文中一共展示了GeoRadiusResponse类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: georadiusByMember

import redis.clients.jedis.GeoRadiusResponse; //导入依赖的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.GeoRadiusResponse; //导入依赖的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.GeoRadiusResponse; //导入依赖的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.GeoRadiusResponse; //导入依赖的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.GeoRadiusResponse; //导入依赖的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: georadius

import redis.clients.jedis.GeoRadiusResponse; //导入依赖的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

示例7: georadiusBinary

import redis.clients.jedis.GeoRadiusResponse; //导入依赖的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

示例8: georadius

import redis.clients.jedis.GeoRadiusResponse; //导入依赖的package包/类
public java.util.List<IMendixObject> georadius(IContext context, String Key, double Latitude, double Longitude,
		double Radius, redisconnector.proxies.Enum_GeoUnit Unit, int Max) {
	try {
		redis = pool.getResource();
		setDatabase();
		_logNode.debug("georadius " + Key + "," + Longitude + "," + "," + Latitude + "," + Radius + "," + Unit);
		List<GeoRadiusResponse> results;
		GeoRadiusParam param = GeoRadiusParam.geoRadiusParam().sortAscending().withCoord().withDist();

		if (Max > 0) {
			param.count(Max);
		}

		results = redis.georadius(Key, Longitude, Latitude, Radius, GetGeoUnitByEnum(Unit), param);

		ArrayList<IMendixObject> resultList = new ArrayList<IMendixObject>();

		for (GeoRadiusResponse object : results) {
			GeoPosition row = new GeoPosition(context);
			row.setName(object.getMemberByString());
			row.setLatitude(new BigDecimal(object.getCoordinate().getLatitude(), MathContext.DECIMAL64));
			row.setLongitude(new BigDecimal(object.getCoordinate().getLongitude(), MathContext.DECIMAL64));
			row.setDistance(new BigDecimal(object.getDistance(), MathContext.DECIMAL64));
			resultList.add(row.getMendixObject());
		}

		return resultList;
	} catch (JedisConnectionException e) {
		if (redis != null) {
			redis.close();
		}
		throw e;
	} finally {
		if (redis != null) {
			redis.close();
		}
	}
}
 
开发者ID:appronto,项目名称:RedisConnector,代码行数:39,代码来源:RedisConnector.java

示例9: georadius

import redis.clients.jedis.GeoRadiusResponse; //导入依赖的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

示例10: georadiusByMember

import redis.clients.jedis.GeoRadiusResponse; //导入依赖的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.GeoRadiusResponse类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。