예제 #1
0
 @Test
 public void tempTest() {
   String center = "31bcb56fr";
   for (int i = -1; i <= 1; i++) { // 2 schleifen um alle 9 möglichen cells zu durchlaufen
     for (int j = -1; j <= 1; j++) {
       String neighbour = MyGeocellUtils.adjacent(center, new int[] {i, j});
       BoundingBox bb_center = MyGeocellUtils.computeBox(center);
       BoundingBox bb_neighbour = MyGeocellUtils.computeBox(neighbour);
       double distance = 0;
       if (Math.abs(i) == 1 && Math.abs(j) == 1) {
         distance = 3.9;
       } else if (Math.abs(i) == 0 && Math.abs(j) == 1) {
         distance = 3;
       } else if (Math.abs(i) == 1 && Math.abs(j) == 0) {
         distance = 2.5;
       } else { // selbe position
         distance = 0;
       }
       //					System.err.println("Distance: " + distance + " or " +
       // GeocellUtils.distance(bb_center.getNorthEast(), bb_neighbour.getNorthEast()));
       assertEquals(
           distance * 100,
           GeocellUtils.distance(bb_center.getNorthEast(), bb_neighbour.getNorthEast()),
           12);
     }
   }
 }
예제 #2
0
 @Test
 public void computeBoxTest() {
   String cell1 = "31bcb57al";
   String cell2 = "31bcb57ar";
   String cell3 = "31bcb57bl";
   String cell4 = "31bcb57br";
   String[] s = new String[] {cell1, cell2, cell3, cell4};
   for (String ss : s) {
     BoundingBox bb_res = MyGeocellUtils.computeBox(ss);
     System.out.print(bb_res.getNorth() + "," + bb_res.getEast() + ",");
     System.out.print(bb_res.getSouth() + "," + bb_res.getWest() + ",");
   }
   System.err.println();
 }