org.redisson.api.RGeo Java Examples

The following examples show how to use org.redisson.api.RGeo. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GeoExamples.java    From redisson-examples with Apache License 2.0 6 votes vote down vote up
public static void main(String[] args) {
    // connects to 127.0.0.1:6379 by default
    RedissonClient redisson = Redisson.create();

    RGeo<String> geo = redisson.getGeo("myGeo");
    GeoEntry entry = new GeoEntry(13.361389, 38.115556, "Palermo");
    geo.add(entry);
    geo.add(15.087269, 37.502669, "Catania");

    Double dist = geo.dist("Palermo", "Catania", GeoUnit.METERS);

    Map<String, GeoPosition> pos = geo.pos("Palermo", "Catania");

    List<String> cities = geo.radius(15, 37, 200, GeoUnit.KILOMETERS);
    List<String> allNearCities = geo.radius("Palermo", 10, GeoUnit.KILOMETERS);
    
    Map<String, Double> citiesWithDistance = geo.radiusWithDistance(15, 37, 200, GeoUnit.KILOMETERS);
    Map<String, Double> allNearCitiesDistance = geo.radiusWithDistance("Palermo", 10, GeoUnit.KILOMETERS);

    Map<String, GeoPosition> citiesWithPosition = geo.radiusWithPosition(15, 37, 200, GeoUnit.KILOMETERS);
    Map<String, GeoPosition> allNearCitiesPosition = geo.radiusWithPosition("Palermo", 10, GeoUnit.KILOMETERS);
    
    redisson.shutdown();
}
 
Example #2
Source File: RedissonGeoTest.java    From redisson with Apache License 2.0 6 votes vote down vote up
@Test
public void testRadiusWithDistanceOrder() {
    RGeo<String> geo = redisson.getGeo("test");
    geo.add(new GeoEntry(13.361389, 38.115556, "Palermo"), new GeoEntry(15.087269, 37.502669, "Catania"));

    Map<String, Double> descExpected = new LinkedHashMap<String, Double>();
    descExpected.put("Palermo", 190.4424);
    descExpected.put("Catania", 56.4413);
    assertThat(geo.radiusWithDistance(15, 37, 200, GeoUnit.KILOMETERS, GeoOrder.DESC).entrySet())
        .containsExactlyElementsOf(descExpected.entrySet());
    
    Map<String, Double> ascExpected = new LinkedHashMap<String, Double>();
    ascExpected.put("Catania", 56.4413);
    ascExpected.put("Palermo", 190.4424);
    assertThat(geo.radiusWithDistance(15, 37, 200, GeoUnit.KILOMETERS, GeoOrder.ASC).entrySet())
        .containsExactlyElementsOf(ascExpected.entrySet());
}
 
Example #3
Source File: RedissonGeoTest.java    From redisson with Apache License 2.0 6 votes vote down vote up
@Test
public void testRadiusMemberWithPositionOrderCount() {
    RGeo<String> geo = redisson.getGeo("test");
    geo.add(new GeoEntry(13.361389, 38.115556, "Palermo"), new GeoEntry(15.087269, 37.502669, "Catania"));

    Map<String, GeoPosition> ascExpected = new LinkedHashMap<String, GeoPosition>();
    ascExpected.put("Palermo", new GeoPosition(13.361389338970184, 38.115556395496299));
    assertThat(geo.radiusWithPosition("Palermo", 200, GeoUnit.KILOMETERS, GeoOrder.ASC, 1).entrySet()).containsExactlyElementsOf(ascExpected.entrySet());
    
    Map<String, GeoPosition> descExpected = new LinkedHashMap<String, GeoPosition>();
    descExpected.put("Catania", new GeoPosition(15.087267458438873, 37.50266842333162));
    assertThat(geo.radiusWithPosition("Palermo", 200, GeoUnit.KILOMETERS, GeoOrder.DESC, 1).entrySet()).containsExactlyElementsOf(descExpected.entrySet());
    
    RGeo<String> geo2 = redisson.getGeo("test2");
    geo2.add(new GeoEntry(13.361389, 38.115556, "Palermo"), new GeoEntry(13.361390, 38.115557, "Catania"));
    Map<String, GeoPosition> ascExpected2 = new LinkedHashMap<String, GeoPosition>();
    ascExpected2.put("Palermo", new GeoPosition(13.361389338970184, 38.115556395496299));
    ascExpected2.put("Catania", new GeoPosition(13.361389338970184, 38.115556395496299));
    assertThat(geo2.radiusWithPosition("Palermo", 200, GeoUnit.KILOMETERS, GeoOrder.DESC, 2).entrySet()).containsExactlyElementsOf(ascExpected2.entrySet());
}
 
Example #4
Source File: RedissonGeoTest.java    From redisson with Apache License 2.0 5 votes vote down vote up
@Test
public void testRadiusMemberWithPositionOrder() {
    RGeo<String> geo = redisson.getGeo("test");
    geo.add(new GeoEntry(13.361389, 38.115556, "Palermo"), new GeoEntry(15.087269, 37.502669, "Catania"));

    Map<String, GeoPosition> ascExpected = new LinkedHashMap<String, GeoPosition>();
    ascExpected.put("Palermo", new GeoPosition(13.361389338970184, 38.115556395496299));
    ascExpected.put("Catania", new GeoPosition(15.087267458438873, 37.50266842333162));
    assertThat(geo.radiusWithPosition("Palermo", 200, GeoUnit.KILOMETERS, GeoOrder.ASC).entrySet()).containsExactlyElementsOf(ascExpected.entrySet());
    
    Map<String, GeoPosition> descExpected = new LinkedHashMap<String, GeoPosition>();
    descExpected.put("Catania", new GeoPosition(15.087267458438873, 37.50266842333162));
    descExpected.put("Palermo", new GeoPosition(13.361389338970184, 38.115556395496299));
    assertThat(geo.radiusWithPosition("Palermo", 200, GeoUnit.KILOMETERS, GeoOrder.DESC).entrySet()).containsExactlyElementsOf(descExpected.entrySet());
}
 
Example #5
Source File: RedissonGeoTest.java    From redisson with Apache License 2.0 5 votes vote down vote up
@Test
public void testRadiusWithPositionOrder() {
    RGeo<String> geo = redisson.getGeo("test");
    geo.add(new GeoEntry(13.361389, 38.115556, "Palermo"), new GeoEntry(15.087269, 37.502669, "Catania"));

    Map<String, GeoPosition> descExpected = new LinkedHashMap<String, GeoPosition>();
    descExpected.put("Palermo", new GeoPosition(13.361389338970184, 38.115556395496299));
    descExpected.put("Catania", new GeoPosition(15.087267458438873, 37.50266842333162));
    assertThat(geo.radiusWithPosition(15, 37, 200, GeoUnit.KILOMETERS, GeoOrder.DESC).entrySet()).containsExactlyElementsOf(descExpected.entrySet());
    
    Map<String, GeoPosition> ascExpected = new LinkedHashMap<String, GeoPosition>();
    ascExpected.put("Catania", new GeoPosition(15.087267458438873, 37.50266842333162));
    ascExpected.put("Palermo", new GeoPosition(13.361389338970184, 38.115556395496299));
    assertThat(geo.radiusWithPosition(15, 37, 200, GeoUnit.KILOMETERS, GeoOrder.ASC).entrySet()).containsExactlyElementsOf(ascExpected.entrySet());
}
 
Example #6
Source File: RedissonGeoTest.java    From redisson with Apache License 2.0 5 votes vote down vote up
@Test
public void testRadiusWithPositionOrderCount() {
    RGeo<String> geo = redisson.getGeo("test");
    geo.add(new GeoEntry(13.361389, 38.115556, "Palermo"), new GeoEntry(15.087269, 37.502669, "Catania"));

    Map<String, GeoPosition> descExpected = new LinkedHashMap<String, GeoPosition>();
    descExpected.put("Palermo", new GeoPosition(13.361389338970184, 38.115556395496299));
    assertThat(geo.radiusWithPosition(15, 37, 200, GeoUnit.KILOMETERS, GeoOrder.DESC, 1).entrySet()).containsExactlyElementsOf(descExpected.entrySet());
    
    Map<String, GeoPosition> ascExpected = new LinkedHashMap<String, GeoPosition>();
    ascExpected.put("Catania", new GeoPosition(15.087267458438873, 37.50266842333162));
    assertThat(geo.radiusWithPosition(15, 37, 200, GeoUnit.KILOMETERS, GeoOrder.ASC, 1).entrySet()).containsExactlyElementsOf(ascExpected.entrySet());
}
 
Example #7
Source File: RedissonGeoTest.java    From redisson with Apache License 2.0 5 votes vote down vote up
@Test
public void testRadiusMember() {
    RGeo<String> geo = redisson.getGeo("test");
    geo.add(new GeoEntry(13.361389, 38.115556, "Palermo"), new GeoEntry(15.087269, 37.502669, "Catania"));

    assertThat(geo.radius("Palermo", 200, GeoUnit.KILOMETERS)).containsExactly("Palermo", "Catania");
}
 
Example #8
Source File: RedissonGeoTest.java    From redisson with Apache License 2.0 5 votes vote down vote up
@Test
public void testRadiusMemberCount() {
    RGeo<String> geo = redisson.getGeo("test");
    geo.add(new GeoEntry(13.361389, 38.115556, "Palermo"), new GeoEntry(15.087269, 37.502669, "Catania"));

    assertThat(geo.radius("Palermo", 200, GeoUnit.KILOMETERS, 1)).containsExactly("Palermo");
}
 
Example #9
Source File: RedissonGeoTest.java    From redisson with Apache License 2.0 5 votes vote down vote up
@Test
public void testRadiusMemberOrder() {
    RGeo<String> geo = redisson.getGeo("test");
    geo.add(new GeoEntry(13.361389, 38.115556, "Palermo"), new GeoEntry(15.087269, 37.502669, "Catania"));

    assertThat(geo.radius("Palermo", 200, GeoUnit.KILOMETERS, GeoOrder.DESC)).containsExactly("Catania", "Palermo");
    assertThat(geo.radius("Palermo", 200, GeoUnit.KILOMETERS, GeoOrder.ASC)).containsExactly("Palermo", "Catania");
}
 
Example #10
Source File: RedissonGeoTest.java    From redisson with Apache License 2.0 5 votes vote down vote up
@Test
public void testRadiusMemberOrderCount() {
    RGeo<String> geo = redisson.getGeo("test");
    geo.add(new GeoEntry(13.361389, 38.115556, "Palermo"), new GeoEntry(15.087269, 37.502669, "Catania"));

    assertThat(geo.radius("Palermo", 200, GeoUnit.KILOMETERS, GeoOrder.DESC, 1)).containsExactly("Catania");
    assertThat(geo.radius("Palermo", 200, GeoUnit.KILOMETERS, GeoOrder.ASC, 1)).containsExactly("Palermo");
}
 
Example #11
Source File: RedissonGeoTest.java    From redisson with Apache License 2.0 5 votes vote down vote up
@Test
public void testRadiusMemberWithDistance() {
    RGeo<String> geo = redisson.getGeo("test");
    geo.add(new GeoEntry(13.361389, 38.115556, "Palermo"), new GeoEntry(15.087269, 37.502669, "Catania"));

    Map<String, Double> expected = new HashMap<String, Double>();
    expected.put("Palermo", 0.0);
    expected.put("Catania", 166.2742);
    assertThat(geo.radiusWithDistance("Palermo", 200, GeoUnit.KILOMETERS)).isEqualTo(expected);
}
 
Example #12
Source File: RedissonGeoTest.java    From redisson with Apache License 2.0 5 votes vote down vote up
@Test
public void testRadiusMemberWithDistanceCount() {
    RGeo<String> geo = redisson.getGeo("test");
    geo.add(new GeoEntry(13.361389, 38.115556, "Palermo"), new GeoEntry(15.087269, 37.502669, "Catania"));

    Map<String, Double> expected = new HashMap<String, Double>();
    expected.put("Palermo", 0.0);
    expected.put("Catania", 166.2742);
    assertThat(expected.entrySet().removeAll(geo.radiusWithDistance("Palermo", 200, GeoUnit.KILOMETERS, 1).entrySet())).isTrue();
    assertThat(expected).hasSize(1);
}
 
Example #13
Source File: RedissonGeoTest.java    From redisson with Apache License 2.0 5 votes vote down vote up
@Test
public void testRadiusMemberWithDistanceOrder() {
    RGeo<String> geo = redisson.getGeo("test");
    geo.add(new GeoEntry(13.361389, 38.115556, "Palermo"), new GeoEntry(15.087269, 37.502669, "Catania"));

    Map<String, Double> ascExpected = new LinkedHashMap<String, Double>();
    ascExpected.put("Palermo", 0.0);
    ascExpected.put("Catania", 166.2742);
    assertThat(geo.radiusWithDistance("Palermo", 200, GeoUnit.KILOMETERS, GeoOrder.ASC).entrySet()).containsExactlyElementsOf(ascExpected.entrySet());

    Map<String, Double> descExpected = new LinkedHashMap<String, Double>();
    descExpected.put("Catania", 166.2742);
    descExpected.put("Palermo", 0.0);
    assertThat(geo.radiusWithDistance("Palermo", 200, GeoUnit.KILOMETERS, GeoOrder.DESC).entrySet()).containsExactlyElementsOf(descExpected.entrySet());
}
 
Example #14
Source File: RedissonGeoTest.java    From redisson with Apache License 2.0 5 votes vote down vote up
@Test
public void testRadiusMemberWithDistanceOrderCount() {
    RGeo<String> geo = redisson.getGeo("test");
    geo.add(new GeoEntry(13.361389, 38.115556, "Palermo"), new GeoEntry(15.087269, 37.502669, "Catania"));

    Map<String, Double> ascExpected = new LinkedHashMap<String, Double>();
    ascExpected.put("Palermo", 0.0);
    assertThat(geo.radiusWithDistance("Palermo", 200, GeoUnit.KILOMETERS, GeoOrder.ASC, 1).entrySet()).containsExactlyElementsOf(ascExpected.entrySet());

    Map<String, Double> descExpected = new LinkedHashMap<String, Double>();
    descExpected.put("Catania", 166.2742);
    assertThat(geo.radiusWithDistance("Palermo", 200, GeoUnit.KILOMETERS, GeoOrder.DESC, 1).entrySet()).containsExactlyElementsOf(descExpected.entrySet());
}
 
Example #15
Source File: RedissonGeoTest.java    From redisson with Apache License 2.0 5 votes vote down vote up
@Test
public void testRadiusMemberWithPosition() {
    RGeo<String> geo = redisson.getGeo("test");
    geo.add(new GeoEntry(13.361389, 38.115556, "Palermo"), new GeoEntry(15.087269, 37.502669, "Catania"));

    Map<String, GeoPosition> expected = new HashMap<String, GeoPosition>();
    expected.put("Palermo", new GeoPosition(13.361389338970184, 38.115556395496299));
    expected.put("Catania", new GeoPosition(15.087267458438873, 37.50266842333162));
    assertThat(geo.radiusWithPosition("Palermo", 200, GeoUnit.KILOMETERS)).isEqualTo(expected);
}
 
Example #16
Source File: RedissonGeoTest.java    From redisson with Apache License 2.0 5 votes vote down vote up
@Test
public void testRadiusMemberWithPositionCount() {
    RGeo<String> geo = redisson.getGeo("test");
    geo.add(new GeoEntry(13.361389, 38.115556, "Palermo"), new GeoEntry(15.087269, 37.502669, "Catania"));

    Map<String, GeoPosition> expected = new HashMap<String, GeoPosition>();
    expected.put("Palermo", new GeoPosition(13.361389338970184, 38.115556395496299));
    expected.put("Catania", new GeoPosition(15.087267458438873, 37.50266842333162));
    assertThat(expected.entrySet().removeAll(geo.radiusWithPosition("Palermo", 200, GeoUnit.KILOMETERS, 1).entrySet())).isTrue();
    assertThat(expected).hasSize(1);
}
 
Example #17
Source File: RedissonGeoTest.java    From redisson with Apache License 2.0 5 votes vote down vote up
@Test
public void testRadiusWithPositionCount() {
    RGeo<String> geo = redisson.getGeo("test");
    geo.add(new GeoEntry(13.361389, 38.115556, "Palermo"), new GeoEntry(15.087269, 37.502669, "Catania"));

    Map<String, GeoPosition> expected = new HashMap<String, GeoPosition>();
    expected.put("Palermo", new GeoPosition(13.361389338970184, 38.115556395496299));
    expected.put("Catania", new GeoPosition(15.087267458438873, 37.50266842333162));
    assertThat(expected.entrySet().removeAll(geo.radiusWithPosition(15, 37, 200, GeoUnit.KILOMETERS, 1).entrySet())).isTrue();
    assertThat(expected).hasSize(1);
}
 
Example #18
Source File: RedissonGeoTest.java    From redisson with Apache License 2.0 5 votes vote down vote up
@Test
public void testRadiusStore() {
    RGeo<String> geoSource = redisson.getGeo("test");
    RGeo<String> geoDest = redisson.getGeo("test-store");
    geoSource.add(new GeoEntry(13.361389, 38.115556, "Palermo"), new GeoEntry(15.087269, 37.502669, "Catania"));

    assertThat(geoSource.radiusStoreTo(geoDest.getName(), 15, 37, 200, GeoUnit.KILOMETERS)).isEqualTo(2);
    assertThat(geoDest.readAll()).containsExactlyInAnyOrder("Palermo", "Catania");
}
 
Example #19
Source File: RedissonGeoTest.java    From redisson with Apache License 2.0 5 votes vote down vote up
@Test
public void testRadiusStoreSorted() {
    RGeo<String> geoSource = redisson.getGeo("test");
    RGeo<String> geoDest = redisson.getGeo("test-store");
    geoSource.add(new GeoEntry(13.361389, 38.115556, "Palermo"), new GeoEntry(15.087269, 37.502669, "Catania"));

    assertThat(geoSource.radiusStoreSortedTo(geoDest.getName(), 15, 37, 200, GeoUnit.KILOMETERS)).isEqualTo(2);
    assertThat(geoDest.readAll()).containsExactly("Catania", "Palermo");
}
 
Example #20
Source File: RedissonGeoTest.java    From redisson with Apache License 2.0 5 votes vote down vote up
@Test
public void testRadiusStoreCount() {
    RGeo<String> geoSource = redisson.getGeo("test");
    RGeo<String> geoDest = redisson.getGeo("test-store");
    geoSource.add(new GeoEntry(13.361389, 38.115556, "Palermo"), new GeoEntry(15.087269, 37.502669, "Catania"));

    assertThat(geoSource.radiusStoreTo(geoDest.getName(), 15, 37, 200, GeoUnit.KILOMETERS, 1)).isEqualTo(1);
    assertThat(geoDest.readAll()).containsExactly("Catania");
}
 
Example #21
Source File: RedissonGeoTest.java    From redisson with Apache License 2.0 5 votes vote down vote up
@Test
public void testRadiusStoreSortedCount() {
    RGeo<String> geoSource = redisson.getGeo("test");
    RGeo<String> geoDest = redisson.getGeo("test-store");
    geoSource.add(new GeoEntry(13.361389, 38.115556, "Palermo"), new GeoEntry(15.087269, 37.502669, "Catania"));

    assertThat(geoSource.radiusStoreSortedTo(geoDest.getName(), 15, 37, 200, GeoUnit.KILOMETERS, 1)).isEqualTo(1);
    assertThat(geoDest.readAll()).containsExactly("Catania");
}
 
Example #22
Source File: RedissonGeoTest.java    From redisson with Apache License 2.0 5 votes vote down vote up
@Test
public void testRadiusStoreOrderCount() {
    RGeo<String> geoSource = redisson.getGeo("test");
    RGeo<String> geoDest = redisson.getGeo("test-store");
    geoSource.add(new GeoEntry(13.361389, 38.115556, "Palermo"), new GeoEntry(15.087269, 37.502669, "Catania"));

    assertThat(geoSource.radiusStoreTo(geoDest.getName(), 15, 37, 200, GeoUnit.KILOMETERS, GeoOrder.DESC, 1)).isEqualTo(1);
    assertThat(geoDest.readAll()).containsExactly("Palermo");

    assertThat(geoSource.radiusStoreTo(geoDest.getName(), 15, 37, 200, GeoUnit.KILOMETERS, GeoOrder.ASC, 1)).isEqualTo(1);
    assertThat(geoDest.readAll()).containsExactly("Catania");
}
 
Example #23
Source File: RedissonGeoTest.java    From redisson with Apache License 2.0 5 votes vote down vote up
@Test
public void testRadiusStoreSortedOrderCount() {
    RGeo<String> geoSource = redisson.getGeo("test");
    RGeo<String> geoDest = redisson.getGeo("test-store");
    geoSource.add(new GeoEntry(13.361389, 38.115556, "Palermo"), new GeoEntry(15.087269, 37.502669, "Catania"));

    assertThat(geoSource.radiusStoreSortedTo(geoDest.getName(), 15, 37, 200, GeoUnit.KILOMETERS, GeoOrder.DESC, 1)).isEqualTo(1);
    assertThat(geoDest.readAll()).containsExactly("Palermo");

    assertThat(geoSource.radiusStoreSortedTo(geoDest.getName(), 15, 37, 200, GeoUnit.KILOMETERS, GeoOrder.ASC, 1)).isEqualTo(1);
    assertThat(geoDest.readAll()).containsExactly("Catania");
}
 
Example #24
Source File: RedissonGeoTest.java    From redisson with Apache License 2.0 5 votes vote down vote up
@Test
public void testRadiusStoreEmpty() {
    RGeo<String> geoSource = redisson.getGeo("test");
    RGeo<String> geoDest = redisson.getGeo("test-store");

    assertThat(geoSource.radiusStoreTo(geoDest.getName(), 15, 37, 200, GeoUnit.KILOMETERS)).isEqualTo(0);
    assertThat(geoDest.readAll()).isEmpty();
}
 
Example #25
Source File: RedissonGeoTest.java    From redisson with Apache License 2.0 5 votes vote down vote up
@Test
public void testRadiusStoreMember() {
    RGeo<String> geoSource = redisson.getGeo("test");
    RGeo<String> geoDest = redisson.getGeo("test-store");
    geoSource.add(new GeoEntry(13.361389, 38.115556, "Palermo"), new GeoEntry(15.087269, 37.502669, "Catania"));

    assertThat(geoSource.radiusStoreTo(geoDest.getName(), "Palermo", 200, GeoUnit.KILOMETERS)).isEqualTo(2);
    assertThat(geoDest.readAll()).containsExactlyInAnyOrder("Palermo", "Catania");
}
 
Example #26
Source File: RedissonGeoTest.java    From redisson with Apache License 2.0 5 votes vote down vote up
@Test
public void testRadiusStoreMemberCount() {
    RGeo<String> geoSource = redisson.getGeo("test");
    RGeo<String> geoDest = redisson.getGeo("test-store");
    geoSource.add(new GeoEntry(13.361389, 38.115556, "Palermo"), new GeoEntry(15.087269, 37.502669, "Catania"));

    assertThat(geoSource.radiusStoreTo(geoDest.getName(), "Palermo", 200, GeoUnit.KILOMETERS, 1)).isEqualTo(1);
    assertThat(geoDest.readAll()).containsExactly("Palermo");
}
 
Example #27
Source File: RedissonGeoTest.java    From redisson with Apache License 2.0 5 votes vote down vote up
@Test
public void testRadiusStoreMemberOrderCount() {
    RGeo<String> geoSource = redisson.getGeo("test");
    RGeo<String> geoDest = redisson.getGeo("test-store");
    geoSource.add(new GeoEntry(13.361389, 38.115556, "Palermo"), new GeoEntry(15.087269, 37.502669, "Catania"));

    assertThat(geoSource.radiusStoreTo(geoDest.getName(), "Palermo", 200, GeoUnit.KILOMETERS, GeoOrder.DESC, 1)).isEqualTo(1);
    assertThat(geoDest.readAll()).containsExactly("Catania");

    assertThat(geoSource.radiusStoreTo(geoDest.getName(), "Palermo", 200, GeoUnit.KILOMETERS, GeoOrder.ASC, 1)).isEqualTo(1);
    assertThat(geoDest.readAll()).containsExactly("Palermo");
}
 
Example #28
Source File: RedissonGeoTest.java    From redisson with Apache License 2.0 5 votes vote down vote up
@Test
public void testRadiusStoreMemberEmpty() {
    RGeo<String> geoSource = redisson.getGeo("test");
    RGeo<String> geoDest = redisson.getGeo("test-store");

    assertThat(geoSource.radiusStoreTo(geoDest.getName(), "Palermo", 200, GeoUnit.KILOMETERS)).isEqualTo(0);
    assertThat(geoDest.readAll()).isEmpty();
}
 
Example #29
Source File: RedissonGeoTest.java    From redisson with Apache License 2.0 5 votes vote down vote up
@Test
public void testRadiusWithPosition() {
    RGeo<String> geo = redisson.getGeo("test");
    geo.add(new GeoEntry(13.361389, 38.115556, "Palermo"), new GeoEntry(15.087269, 37.502669, "Catania"));

    Map<String, GeoPosition> expected = new HashMap<String, GeoPosition>();
    expected.put("Palermo", new GeoPosition(13.361389338970184, 38.115556395496299));
    expected.put("Catania", new GeoPosition(15.087267458438873, 37.50266842333162));
    assertThat(geo.radiusWithPosition(15, 37, 200, GeoUnit.KILOMETERS)).isEqualTo(expected);
}
 
Example #30
Source File: RedissonGeoTest.java    From redisson with Apache License 2.0 5 votes vote down vote up
@Test
public void testPos1() {
    RGeo<String> geo = redisson.getGeo("test");
    geo.add(0.123,0.893,"hi");
    Map<String, GeoPosition> res = geo.pos("hi");
    assertThat(res.get("hi").getLatitude()).isNotNull();
    assertThat(res.get("hi").getLongitude()).isNotNull();
}