def testS2CellIdIntersectsIsTrueForOverlap(self): cell1 = s2.S2CellId(0x89c259c000000000) cell2 = s2.S2CellId(0x89c2590000000000) self.assertTrue(cell1.intersects(cell2))
def testS2CellIdIntersectsIsFalseForNonOverlap(self): cell1 = s2.S2CellId(0x89c259c000000000) cell2 = s2.S2CellId(0x89e83d0000000000) self.assertFalse(cell1.intersects(cell2))
def testS2CellIdEqualsIsWrappedCorrectly(self): london = s2.S2LatLng.FromDegrees(51.5001525, -0.1262355) cell = s2.S2CellId(london) same_cell = s2.S2CellId(london) self.assertEqual(cell, same_cell)
def testS2CellIdComparsionIsWrappedCorrectly(self): london = s2.S2LatLng.FromDegrees(51.5001525, -0.1262355) cell = s2.S2CellId(london) self.assertLess(cell, cell.next()) self.assertGreater(cell.next(), cell)
def testS2PolygonInitNestedWithIncorrectTypeIsWrappedCorrectly(self): london = s2.S2LatLng.FromDegrees(51.5001525, -0.1262355) loop = s2.S2Loop(s2.S2Cell(s2.S2CellId(london))) polygon = s2.S2Polygon() with self.assertRaises(TypeError): polygon.InitNested([loop, s2.S2CellId()])
def testS2PolygonInitNestedIsWrappedCorrectly(self): london = s2.S2LatLng.FromDegrees(51.5001525, -0.1262355) small_loop = s2.S2Loop(s2.S2Cell(s2.S2CellId(london))) big_loop = s2.S2Loop(s2.S2Cell(s2.S2CellId(london).parent(1))) polygon = s2.S2Polygon() polygon.InitNested([big_loop, small_loop])
def testS2PolygonCopiesLoopInConstructorBecauseItTakesOwnership(self): london = s2.S2LatLng.FromDegrees(51.5001525, -0.1262355) loop = s2.S2Loop(s2.S2Cell(s2.S2CellId(london))) s2.S2Polygon(loop)
def testS2PolygonIsWrappedCorrectly(self): london = s2.S2LatLng.FromDegrees(51.5001525, -0.1262355) polygon = s2.S2Polygon(s2.S2Cell(s2.S2CellId(london))) self.assertEqual(polygon.num_loops(), 1) point = london.ToPoint() self.assertTrue(polygon.Contains(point))
def testS2CellUnionIsWrappedCorrectly(self): cell_union = s2.S2CellUnion() cell_union.Init([0x466d319000000000, 0x466d31b000000000]) self.assertEqual(cell_union.num_cells(), 2) trondheim = s2.S2LatLng.FromDegrees(63.431052, 10.395083) self.assertTrue(cell_union.Contains(s2.S2CellId(trondheim)))