@Test public void interpolationTest() { String cell1 = "31bcb57al"; String cell2 = "31bcb57ar"; String cell3 = "31bcb57bl"; assertEquals(MyGeocellUtils.interpolationCount(cell1, cell1), 1); assertEquals(MyGeocellUtils.interpolationCount(cell2, cell2), 1); assertEquals(MyGeocellUtils.interpolationCount(cell2, cell1), 2); assertEquals(MyGeocellUtils.interpolationCount(cell3, cell2), 2); assertEquals(MyGeocellUtils.interpolationCount(cell3, cell1), 3); int dist_vert = 6; int dist_hor = 5; int dist_diag = 8; for (int i = -2; i <= 2; i++) { for (int j = -2; j <= 2; j++) { String neighbour; if (Math.abs(j) == 2 || Math.abs(i) == 2) { if (Math.abs(i) == 2 && Math.abs(j) == 2) { neighbour = MyGeocellUtils.adjacent(cell1, new int[] {i / 2, j / 2}); neighbour = MyGeocellUtils.adjacent(neighbour, new int[] {i / 2, j / 2}); } else if (Math.abs(i) == 2) { neighbour = MyGeocellUtils.adjacent(cell1, new int[] {i / 2, j}); neighbour = MyGeocellUtils.adjacent(neighbour, new int[] {i / 2, 0}); } else if (Math.abs(j) == 2) { neighbour = MyGeocellUtils.adjacent(cell1, new int[] {i, j / 2}); neighbour = MyGeocellUtils.adjacent(neighbour, new int[] {0, j / 2}); } else { System.err.println("AStar: this point should not get reached ever."); neighbour = null; } } else { neighbour = MyGeocellUtils.adjacent(cell1, new int[] {i, j}); } int distance = 0; if (i == 0 && j == 0) { distance = 1; } else if (i == 0 && Math.abs(j) != 0) { distance = dist_vert * Math.abs(j); } else if (j == 0 && Math.abs(i) != 0) { distance = dist_hor * Math.abs(i); } else if (i != 0 && Math.abs(i) == Math.abs(j)) { distance = dist_diag * Math.abs(i); } else if (i != 0 && j != 0 && Math.abs(i) + Math.abs(j) == 3) { distance = dist_diag + (dist_diag / 2); } else { System.err.println("this should not happen"); distance = 99; } // System.err.println(i + "\t" + j + "\t" + distance + "\t" + // Utils.distanceBetweenGeoCells(cell1, neighbour)); assertEquals(distance, Utils.distanceBetweenGeoCells(cell1, neighbour), 1); } } }