コード例 #1
0
  @Test
  public void settingUpNearWithMetricRecalculatesDistance() {

    NearQuery query = NearQuery.near(2.5, 2.5, Metrics.KILOMETERS).maxDistance(150);

    assertThat(query.getMaxDistance(), is(ONE_FIFTY_KILOMETERS));
    assertThat(query.getMetric(), is((Metric) Metrics.KILOMETERS));
    assertThat(query.isSpherical(), is(true));
  }
コード例 #2
0
  @Test
  public void configuresResultMetricCorrectly() {

    NearQuery query = NearQuery.near(2.5, 2.1);
    assertThat(query.getMetric(), is((Metric) Metrics.NEUTRAL));

    query = query.maxDistance(ONE_FIFTY_KILOMETERS);
    assertThat(query.getMetric(), is((Metric) Metrics.KILOMETERS));
    assertThat(query.getMaxDistance(), is(ONE_FIFTY_KILOMETERS));
    assertThat(query.isSpherical(), is(true));

    query = query.in(Metrics.MILES);
    assertThat(query.getMetric(), is((Metric) Metrics.MILES));
    assertThat(query.getMaxDistance(), is(ONE_FIFTY_KILOMETERS));
    assertThat(query.isSpherical(), is(true));

    query = query.maxDistance(new Distance(200, Metrics.KILOMETERS));
    assertThat(query.getMetric(), is((Metric) Metrics.MILES));
  }