def testQTileEquals(self): tile1 = QTile(Tile(1, 1, 15)) tile2 = QTile(Tile(1, 1, 15)) tile3 = QTile(Tile(1, 2, 15)) tile4 = QTile(Tile(1, 1, 12)) self.assertEqual(tile1, tile2) self.assertNotEqual(tile1, tile3) self.assertNotEqual(tile1, tile4)
def testTilesEquals(self): tile1 = Tile(1, 1, 15) tile2 = Tile(1, 1, 15) tile3 = Tile(1, 2, 15) tile4 = Tile(1, 1, 12) self.assertEqual(tile1, tile2) self.assertNotEqual(tile1, tile3) self.assertNotEqual(tile1, tile4)
def draw(self, painter: "QPainter"): for x in range(self.map_rect.left(), self.map_rect.right()): for y in range(self.map_rect.top(), self.map_rect.bottom()): tile = QTile(Tile(x, y, self.zoom), (x - self.map_rect.left()) * TILE_SIZE, (y - self.map_rect.top()) * TILE_SIZE) self.draw_tile(painter, tile)
def testRemoveOutsideTiles(self): widget = MapWidget() for row in range(2): for column in range(2): qtile = QTile(Tile(0.0000, 0.0000, 15)) qtile.map_x = column * 256 qtile.map_y = row * 256 widget.drawn_tiles.append(qtile)
def download(self): self.drawn.clear() for x in range(self.map_rect.left(), self.map_rect.right()): for y in range(self.map_rect.top(), self.map_rect.bottom()): tile = Tile(x, y, self.zoom) if not self.osm.exist_tile((tile.x, tile.y)): self.osm.download_tile(tile) return
def testTileInSet(self): tile1 = QTile(Tile(1, 1, 15)) tile2 = QTile(Tile(3, 3, 15)) seq = {QTile(Tile(1, 1, 15)), QTile(Tile(1, 2, 15)), QTile(Tile(2, 1, 15)), QTile(Tile(2, 2, 15))} self.assertTrue(tile1 in seq) self.assertFalse(tile2 in seq)
def testQTilesInSequences(self): tile1 = QTile(Tile(1, 1, 15)) tile2 = QTile(Tile(3, 3, 15)) seq = [QTile(Tile(1, 1, 15)), QTile(Tile(1, 2, 15)), QTile(Tile(2, 1, 15)), QTile(Tile(2, 2, 15))] self.assertTrue(tile1 in seq) self.assertFalse(tile2 in seq)
def testTileHashEquals(self): tile1 = Tile(1, 1, 15) tile2 = Tile(1, 1, 15) tile3 = Tile(1, 2, 15) tile4 = Tile(1, 1, 12) self.assertEqual(tile1.__hash__(), tile2.__hash__()) self.assertNotEqual(tile1.__hash__(), tile3.__hash__()) self.assertNotEqual(tile1.__hash__(), tile4.__hash__())
def testTilesInSequences(self): tile1 = Tile(1, 1, 15) tile2 = Tile(3, 3, 15) seq = [Tile(1, 1, 15), Tile(1, 2, 15), Tile(2, 1, 15), Tile(2, 2, 15)] self.assertTrue(tile1 in seq) self.assertFalse(tile2 in seq)
def __init__(self, tile: "Tile", map_x=0, map_y=0): Tile.__init__(self, tile.x, tile.y, tile.zoom) QItem.__init__(self, map_x, map_y)