示例#1
0
 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)
示例#2
0
 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)
示例#3
0
 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)
示例#4
0
 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)
示例#5
0
 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
示例#6
0
 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)
示例#7
0
 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)
示例#8
0
 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__())
示例#9
0
 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)
示例#10
0
 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)