From 979ae61c411e583aa053e4171d46995d955fdc72 Mon Sep 17 00:00:00 2001 From: Prajeesh Ag Date: Tue, 18 Apr 2023 14:00:32 +0300 Subject: [PATCH 1/2] If two adjacent vertices are close enough To check if two adjacent vertices are close enough both dlon and pdlat need to be close to zero. Only dlon close to zero can happen if the points happen to lie on the same longitude line. --- sphericalpolygon/excess_area.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sphericalpolygon/excess_area.py b/sphericalpolygon/excess_area.py index c890ac3..452d2ba 100644 --- a/sphericalpolygon/excess_area.py +++ b/sphericalpolygon/excess_area.py @@ -29,7 +29,7 @@ def polygon_excess(vertices): dlon = np.abs(pdlon) # If two adjacent vertices are close enough(coincident), do nothing. - if dlon < 1e-6: continue + if dlon < 1e-6 and np.abs(pdlat): continue # Calculate the area of a spherical triangle consisting of sides and north poles if dlon > np.pi: dlon = 2*np.pi - dlon @@ -69,4 +69,4 @@ def polygon_area(vertices): if area > 2*np.pi: area = 4*np.pi - area - return area \ No newline at end of file + return area From e7d1a14b9566515617d24fa374e3ff2fa407ab76 Mon Sep 17 00:00:00 2001 From: Prajeesh Ag Date: Thu, 11 Apr 2024 06:48:38 +0300 Subject: [PATCH 2/2] Update sphericalpolygon/excess_area.py Co-authored-by: Cedric Martens --- sphericalpolygon/excess_area.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sphericalpolygon/excess_area.py b/sphericalpolygon/excess_area.py index 452d2ba..6537b49 100644 --- a/sphericalpolygon/excess_area.py +++ b/sphericalpolygon/excess_area.py @@ -29,7 +29,7 @@ def polygon_excess(vertices): dlon = np.abs(pdlon) # If two adjacent vertices are close enough(coincident), do nothing. - if dlon < 1e-6 and np.abs(pdlat): continue + if dlon < 1e-6 and np.abs(pdlat) < 1e-6: continue # Calculate the area of a spherical triangle consisting of sides and north poles if dlon > np.pi: dlon = 2*np.pi - dlon