Exemplo n.º 1
0
  public void testQueryInGeobox() {
    String cursorString = null;

    CursorPage<DEmployee, Long> page =
        employeeDao.queryInGeobox(
            20f, 110f, Geobox.BITS_18_154m, 60, null, false, null, false, cursorString);
    assertEquals(60, page.getItems().size());
    final DLocation centre = new DLocation(20f, 110f);
    for (DEmployee actual : page.getItems()) {
      double distance = Geobox.distance(centre, employeeDao.getGeoLocation(actual));
      System.out.println("   distance=" + distance);
      assertTrue("distance", distance < 308);
    }

    page =
        employeeDao.queryInGeobox(
            20f, 110f, Geobox.BITS_18_154m, 60, null, false, null, false, page.getCursorKey());
    assertEquals(23, page.getItems().size());
    for (DEmployee actual : page.getItems()) {
      double distance = Geobox.distance(centre, employeeDao.getGeoLocation(actual));
      System.out.println("   distance=" + distance);
      assertTrue("distance", distance < 308);
    }
  }
Exemplo n.º 2
0
  protected void populate() {
    LOG.info("--- populate() " + getName() + " ---");

    Map<Long, DEmployee> employees = new HashMap<Long, DEmployee>();
    for (int i = 1; i < 132; i++) {
      DEmployee employee = new DEmployee();
      employee.setId(Long.valueOf(i));
      employee.setFingerprint(String.format("%dfingerprint%d", i, i));
      employee.setOfficeLocation(
          0 == i % 9
              ? null
              : new DLocation(
                  20.0f + 0.00029f * ((i % 20) - 10), 110.0f + 0.00028f * ((i % 13) - 6)));
      employeeDao.persist(employee);
      employees.put(Long.valueOf(i), employee);
    }
  }