def test_interpolation(self): cell = geocell.compute(geotypes.Point(37, -122), 14) sw_adjacent = geocell.adjacent(cell, (-1, -1)) sw_adjacent2 = geocell.adjacent(sw_adjacent, (-1, -1)) # interpolate between a cell and south-west adjacent, should return # 4 total cells self.assertEquals(4, len(geocell.interpolate(cell, sw_adjacent))) self.assertEquals(4, geocell.interpolation_count(cell, sw_adjacent)) # interpolate between a cell and the cell SW-adjacent twice over, # should return 9 total cells self.assertEquals(9, len(geocell.interpolate(cell, sw_adjacent2))) self.assertEquals(9, geocell.interpolation_count(cell, sw_adjacent2))
def test_adjacent(self): cell = geocell.compute(geotypes.Point(37, -122), 14) box = geocell.compute_box(cell) # adjacency tests using bounding boxes self.assertEquals(box.north, geocell.compute_box(geocell.adjacent(cell, (0, 1))).south) self.assertEquals(box.south, geocell.compute_box(geocell.adjacent(cell, (0, -1))).north) self.assertEquals(box.east, geocell.compute_box(geocell.adjacent(cell, (1, 0))).west) self.assertEquals(box.west, geocell.compute_box(geocell.adjacent(cell, (-1, 0))).east) self.assertEquals(8, len(geocell.all_adjacents(cell))) # also test collinearity self.assertTrue( geocell.collinear(cell, geocell.adjacent(cell, (0, 1)), True)) self.assertFalse( geocell.collinear(cell, geocell.adjacent(cell, (0, 1)), False)) self.assertTrue( geocell.collinear(cell, geocell.adjacent(cell, (1, 0)), False)) self.assertFalse( geocell.collinear(cell, geocell.adjacent(cell, (1, 0)), True))