Skip to content

Commit

Permalink
Full implement single
Browse files Browse the repository at this point in the history
  • Loading branch information
FL550 committed Oct 2, 2024
1 parent 6bfb54d commit 956be63
Showing 1 changed file with 47 additions and 7 deletions.
54 changes: 47 additions & 7 deletions simple_dwd_weatherforecast/dwdmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ class germany_boundaries:
class MarkerShape(Enum):
CIRCLE = "circle"
SQUARE = "square"
TRIANGLE = "triangle"
CROSS = "cross"


Expand All @@ -50,6 +49,7 @@ def __init__(
shape: MarkerShape,
size: int,
colorRGB: tuple[int, int, int],
width: int = 0
):
if (
latitude is None
Expand All @@ -64,6 +64,7 @@ def __init__(
self.shape = shape
self.size = size
self.colorRGB = colorRGB
self.width = width


class ImageBoundaries:
Expand All @@ -79,7 +80,6 @@ def __init__(self, minX: float, maxX: float, minY: float, maxY: float) -> None:
self.maxY = maxY


# TODO mapmarker
def get_from_location(
longitude,
latitude,
Expand All @@ -88,6 +88,7 @@ def get_from_location(
background_type: WeatherBackgroundMapType = WeatherBackgroundMapType.BUNDESLAENDER,
image_width=520,
image_height=580,
markers: list[Marker] = [],
):
if radius_km <= 0:
raise ValueError("Radius must be greater than 0")
Expand All @@ -105,6 +106,7 @@ def get_from_location(
background_type,
image_width,
image_height,
markers
)


Expand Down Expand Up @@ -284,10 +286,48 @@ def draw_marker(
if marker.shape == MarkerShape.CIRCLE:
draw.circle(location_relative_to_image, marker.size, fill=marker.colorRGB)
elif marker.shape == MarkerShape.CROSS:
# TODO
pass
size = round(marker.size / 2, 0)
draw.line(
[
(
location_relative_to_image[0] - size,
location_relative_to_image[1],
),
(
location_relative_to_image[0] + size,
location_relative_to_image[1],
),
],
marker.colorRGB,
marker.width
)
draw.line(
[
(
location_relative_to_image[0],
location_relative_to_image[1] - size,
),
(
location_relative_to_image[0],
location_relative_to_image[1] + size,
),
],
marker.colorRGB,
marker.width
)
elif marker.shape == MarkerShape.SQUARE:
pass
elif marker.shape == MarkerShape.TRIANGLE:
pass
size = round(marker.size / 2, 0)
draw.rectangle(
[
(
location_relative_to_image[0] - size,
location_relative_to_image[1] - size,
),
(
location_relative_to_image[0] + size,
location_relative_to_image[1] + size,
),
],
marker.colorRGB,
)
return image

0 comments on commit 956be63

Please sign in to comment.