From 9cb1c0017b38b7bb205691079054a9a45d8ac3f1 Mon Sep 17 00:00:00 2001 From: Alexander Rashed Date: Sun, 12 May 2024 12:09:52 +0200 Subject: [PATCH] add support for rectanular radius --- prettymaps/fetch.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/prettymaps/fetch.py b/prettymaps/fetch.py index c116b17..057d6ad 100644 --- a/prettymaps/fetch.py +++ b/prettymaps/fetch.py @@ -60,15 +60,19 @@ def get_boundary(query, radius, circle=False, rotation=0): if circle: # Circular shape # use .buffer() to expand point into circle boundary.geometry = boundary.geometry.buffer(radius) - else: # Square shape + else: # Rectangular shape x, y = np.concatenate(boundary.geometry[0].xy) - r = radius + if type(radius) is tuple: + x_radius = radius[0] + y_radius = radius[1] + else: + x_radius = y_radius = radius boundary = GeoDataFrame( geometry=[ rotate( Polygon( - [(x - r, y - r), (x + r, y - r), - (x + r, y + r), (x - r, y + r)] + [(x - x_radius, y - y_radius), (x + x_radius, y - y_radius), + (x + x_radius, y + y_radius), (x - x_radius, y + y_radius)] ), rotation, )