示例#1
0
        return self.size()

    def __repr__(self):
        # p = ", ".join([f"{p!r}" for p in self.get_path()])
        return f"{type(self).__name__}(<{len(self)} points>)"

    def __getitem__(self, index: int) -> positioning.GeoCoordinate:
        return positioning.GeoCoordinate(self.coordinateAt(index))

    def __setitem__(self, index: int, value: QtPositioning.QGeoCoordinate):
        self.replaceCoordinate(index, value)

    def __delitem__(self, index: int):
        self.removeCoordinate(index)

    def __add__(self, other: QtPositioning.QGeoCoordinate):
        self.addCoordinate(other)
        return self

    def get_path(self) -> list[positioning.GeoCoordinate]:
        return [positioning.GeoCoordinate(p) for p in self.path()]


if __name__ == "__main__":
    poly = GeoPolygon()
    coord = positioning.GeoCoordinate(11, 11)
    poly += coord
    poly.addCoordinate(coord)
    print(len(poly))
    print(str(poly))
示例#2
0
 def __getitem__(self, index: int) -> positioning.GeoCoordinate:
     return positioning.GeoCoordinate(self.coordinateAt(index))
示例#3
0
 def get_bottom_right(self) -> positioning.GeoCoordinate:
     return positioning.GeoCoordinate(self.bottomRight())
示例#4
0
 def get_top_left(self) -> positioning.GeoCoordinate:
     return positioning.GeoCoordinate(self.topLeft())
示例#5
0
from __future__ import annotations

from prettyqt import positioning
from prettyqt.qt import QtPositioning

QtPositioning.QGeoRectangle.__bases__ = (positioning.GeoShape, )


class GeoRectangle(QtPositioning.QGeoRectangle):
    def __repr__(self):
        return (
            f"{type(self).__name__}({self.get_top_left()!r}, {self.get_bottom_right()!r})"
        )

    def get_top_left(self) -> positioning.GeoCoordinate:
        return positioning.GeoCoordinate(self.topLeft())

    def get_bottom_right(self) -> positioning.GeoCoordinate:
        return positioning.GeoCoordinate(self.bottomRight())


if __name__ == "__main__":
    coord1 = positioning.GeoCoordinate(1, 1)
    coord2 = positioning.GeoCoordinate(11, 11)
    rect = GeoRectangle(coord1, coord2)
    print(str(rect))
    print(repr(rect))
示例#6
0
 def get_waypoints(self) -> list[positioning.GeoCoordinate]:
     return [positioning.GeoCoordinate(wp) for wp in self.waypoints()]
示例#7
0
 def get_center(self) -> positioning.GeoCoordinate:
     return positioning.GeoCoordinate(self.center())