def setRadius(self, givenRadius: float): center_geometry_mbr = Envelope.from_shapely_geom(self.centerGeometry) width = center_geometry_mbr.maxx - center_geometry_mbr.minx length = center_geometry_mbr.maxy - center_geometry_mbr.miny center_geometry_internal_radius = sqrt(width**2 + length**2) / 2 self.radius = givenRadius if givenRadius > center_geometry_internal_radius else center_geometry_internal_radius self.MBR = Envelope(self.centerPoint.x - self.radius, self.centerPoint.x + self.radius, self.centerPoint.y - self.radius, self.centerPoint.y + self.radius)
def __init__(self, centerGeometry: BaseGeometry, givenRadius: float): self.MBR = None self.centerGeometry = centerGeometry self.radius = givenRadius center_geometry_mbr = Envelope.from_shapely_geom(self.centerGeometry) self.centerPoint = self.centerPoint = Point( (center_geometry_mbr.minx + center_geometry_mbr.maxx) / 2.0, (center_geometry_mbr.miny + center_geometry_mbr.maxy) / 2.0) width = center_geometry_mbr.maxx - center_geometry_mbr.minx length = center_geometry_mbr.maxy - center_geometry_mbr.miny center_geometry_internal_radius = sqrt(width**2 + length**2) / 2.0 self.radius = givenRadius if givenRadius > center_geometry_internal_radius else center_geometry_internal_radius self.MBR = Envelope(self.centerPoint.x - self.radius, self.centerPoint.x + self.radius, self.centerPoint.y - self.radius, self.centerPoint.y + self.radius) super().__init__(self.centerPoint.buffer(self.radius))