summaryrefslogtreecommitdiff
path: root/lib/polygon.py
diff options
context:
space:
mode:
authormdroe <mdroe@stsci.edu>2012-07-11 13:27:46 -0400
committermdroe <mdroe@stsci.edu>2012-07-11 13:27:46 -0400
commite0886647eb9f8073c214878498c4d422b0aa31ab (patch)
tree771fb653cda89df452c994350b7b3ebcdf721771 /lib/polygon.py
parent896f9128ccb2c2ff66ee3ca7f43c89c7db187ad6 (diff)
downloadstsci.sphere-e0886647eb9f8073c214878498c4d422b0aa31ab.tar.gz
Intersection with an empty polygon should return an empty polygon.
git-svn-id: http://svn.stsci.edu/svn/ssb/stsci_python/stsci_python/branches/sphere@17821 fe389314-cf27-0410-b35b-8c050e845b92 Former-commit-id: 1db96e6bd2b7525c07e2a73832c142f74730a635
Diffstat (limited to 'lib/polygon.py')
-rw-r--r--lib/polygon.py11
1 files changed, 7 insertions, 4 deletions
diff --git a/lib/polygon.py b/lib/polygon.py
index fd67042..0957279 100644
--- a/lib/polygon.py
+++ b/lib/polygon.py
@@ -367,7 +367,7 @@ class SphericalPolygon(object):
`True` or `False`.
"""
self_n = len(self.points)
-
+
if self_n != len(other.points):
return False
@@ -376,10 +376,10 @@ class SphericalPolygon(object):
self_a = self.area()
is_same_limit = thres * self_a
-
+
if np.abs(self_a - other.area()) > is_same_limit:
return False
-
+
if do_sort:
self_pts = self._sorted_points(preserve_order=False, unique=True)
other_pts = other._sorted_points(preserve_order=False, unique=True)
@@ -388,7 +388,7 @@ class SphericalPolygon(object):
other_pts = other.points
is_eq = True
-
+
for self_p, other_p in zip(self_pts, other_pts):
x_sum = 0.0
@@ -696,6 +696,9 @@ class SphericalPolygon(object):
# return self.__class__([], [0, 0, 0])
from . import graph
+ if len(self._points) < 3 or len(other._points) < 3:
+ return self.__class__([], [0, 0, 0])
+
g = graph.Graph([self, other])
polygon = g.intersection()