From 6ae25bb6cfc14a9b4f71db4c4ea7552194c2528e Mon Sep 17 00:00:00 2001 From: mdroe Date: Fri, 6 Jun 2014 01:23:22 +0000 Subject: Fix union with empty polygon. git-svn-id: http://svn.stsci.edu/svn/ssb/stsci_python/stsci.sphere/trunk@32433 fe389314-cf27-0410-b35b-8c050e845b92 Former-commit-id: ad718756b906e7254f8a899a8683e641e8396c17 --- stsci/sphere/polygon.py | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'stsci/sphere/polygon.py') diff --git a/stsci/sphere/polygon.py b/stsci/sphere/polygon.py index 2d67ff2..0406402 100644 --- a/stsci/sphere/polygon.py +++ b/stsci/sphere/polygon.py @@ -104,6 +104,9 @@ class SphericalPolygon(object): return '%s(%r, %r)' % (self.__class__.__name__, self.points, self.inside) + def copy(self): + return self.__class__(self._points.copy(), self._inside.copy()) + @property def points(self): """ @@ -604,6 +607,11 @@ class SphericalPolygon(object): module. """ from . import graph + if len(self._points) < 3: + return other.copy() + elif len(other._points) < 3: + return self.copy() + g = graph.Graph([self, other]) polygon = g.union() -- cgit