| 127 | self.scale(scaleFactor, scaleFactor) |
| 128 | |
| 129 | def initMap(self): |
| 130 | features = json.load( |
| 131 | open("Data/world.json", encoding="utf8")).get("features") |
| 132 | for feature in features: |
| 133 | geometry = feature.get("geometry") |
| 134 | if not geometry: |
| 135 | continue |
| 136 | _type = geometry.get("type") |
| 137 | coordinates = geometry.get("coordinates") |
| 138 | for coordinate in coordinates: |
| 139 | if _type == "Polygon": |
| 140 | polygon = QPolygonF( |
| 141 | [QPointF(latitude, -longitude) for latitude, longitude in coordinate]) |
| 142 | item = QGraphicsPolygonItem(polygon) |
| 143 | item.setPen(QPen(self.borderColor, 0)) |
| 144 | item.setBrush(QBrush(self.backgroundColor)) |
| 145 | item.setPos(0, 0) |
| 146 | self._scene.addItem(item) |
| 147 | elif _type == "MultiPolygon": |
| 148 | for _coordinate in coordinate: |
| 149 | polygon = QPolygonF( |
| 150 | [QPointF(latitude, -longitude) for latitude, longitude in _coordinate]) |
| 151 | item = QGraphicsPolygonItem(polygon) |
| 152 | item.setPen(QPen(self.borderColor, 0)) |
| 153 | item.setBrush(QBrush(self.backgroundColor)) |
| 154 | item.setPos(0, 0) |
| 155 | self._scene.addItem(item) |
| 156 | |
| 157 | |
| 158 | if __name__ == "__main__": |