@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())); }
@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())); }
@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(); } }
@Override public List<GeoRadiusResponse> georadius(byte[] key, double longitude, double latitude, double radius, GeoUnit unit, GeoRadiusParam param) { Span span = helper.buildSpan("georadius", key); span.setTag("longitude", longitude); span.setTag("latitude", latitude); span.setTag("radius", radius); span.setTag("unit", unit.name()); span.setTag("param", TracingHelper.toString(param.getByteParams())); try { return super.georadius(key, longitude, latitude, radius, unit, param); } catch (Exception e) { onError(e, span); throw e; } finally { span.finish(); } }
@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(); } }
@Override public List<GeoRadiusResponse> georadiusByMember(byte[] key, byte[] member, double radius, GeoUnit unit, GeoRadiusParam param) { Span span = helper.buildSpan("georadiusByMember", key); span.setTag("member", Arrays.toString(member)); span.setTag("radius", radius); span.setTag("unit", unit.name()); span.setTag("param", TracingHelper.toString(param.getByteParams())); try { return super.georadiusByMember(key, member, radius, unit, param); } catch (Exception e) { onError(e, span); throw e; } finally { span.finish(); } }
@Override public List<GeoRadiusResponse> georadius(String 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(); } }
@Override public List<GeoRadiusResponse> georadius(String key, double longitude, double latitude, double radius, GeoUnit unit, GeoRadiusParam param) { Span span = helper.buildSpan("georadius", key); span.setTag("longitude", longitude); span.setTag("latitude", latitude); span.setTag("radius", radius); span.setTag("unit", unit.name()); span.setTag("param", TracingHelper.toString(param.getByteParams())); try { return super.georadius(key, longitude, latitude, radius, unit, param); } catch (Exception e) { onError(e, span); throw e; } finally { span.finish(); } }
@Override public List<GeoRadiusResponse> georadiusByMember(String key, String member, double radius, GeoUnit unit) { Span span = helper.buildSpan("georadiusByMember", key); span.setTag("member", 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(); } }
@Override public List<GeoRadiusResponse> georadiusByMember(String key, String member, double radius, GeoUnit unit, GeoRadiusParam param) { Span span = helper.buildSpan("georadiusByMember", key); span.setTag("member", member); span.setTag("radius", radius); span.setTag("unit", unit.name()); span.setTag("param", TracingHelper.toString(param.getByteParams())); try { return super.georadiusByMember(key, member, radius, unit, param); } catch (Exception e) { onError(e, span); throw e; } finally { span.finish(); } }
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; }
@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())); }
@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())); }
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(); } } }
@Override public List<GeoRadiusResponse> georadius(String arg0, double arg1, double arg2, double arg3, GeoUnit arg4) { // TODO Auto-generated method stub return null; }
@Override public List<GeoRadiusResponse> georadius(String arg0, double arg1, double arg2, double arg3, GeoUnit arg4, GeoRadiusParam arg5) { // TODO Auto-generated method stub return null; }
@Override public List<GeoRadiusResponse> georadiusByMember(String arg0, String arg1, double arg2, GeoUnit arg3) { // TODO Auto-generated method stub return null; }
@Override public List<GeoRadiusResponse> georadiusByMember(String arg0, String arg1, double arg2, GeoUnit arg3, GeoRadiusParam arg4) { // TODO Auto-generated method stub return null; }