diff --git a/lib/polygon/__init__.py b/lib/polygon/__init__.py
new file mode 100644
index 0000000..5d020f8
--- /dev/null
+++ b/lib/polygon/__init__.py
@@ -0,0 +1,17 @@
+from poly import PolyPolygon
+
+Polygon = PolyPolygon
+
+
+if __name__ == "__main__":
+ p = Polygon([[(0,0),(30,0),(15,30)]])
+ print 'p', p.area()
+ q = Polygon([[(10,5),(30,0),(15,20)]])
+ print 'q', q.area()
+ print 'p+q', (p+q).area()
+ print 'p-q', (p-q).area()
+ print 'p&q', (p&q).area()
+ print 'p|q', (p|q).area()
+
+
+
diff --git a/lib/polygon/base.py b/lib/polygon/base.py
new file mode 100644
index 0000000..4675ee3
--- /dev/null
+++ b/lib/polygon/base.py
@@ -0,0 +1,57 @@
+"""
+ kartograph - a svg mapping library
+ Copyright (C) 2011 Gregor Aisch
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as
+ published by the Free Software Foundation, either version 3 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see .
+"""
+
+
+class AbstractPolygon(object):
+ """
+ all polygon implementation will implement this interface
+ """
+ def __init__(self, contours=None, data=None):
+ self.data = data
+
+ def __len__(self):
+ raise NotImplementedError
+
+ def __getitem__(self, key):
+ raise NotImplementedError
+
+ def addContour(self, contour):
+ raise NotImplementedError
+
+ def __and__(self, other):
+ raise NotImplementedError
+
+ def __or__(self, other):
+ raise NotImplementedError
+
+ def __add__(self, other):
+ return self.__or__(other)
+
+ def __sub__(self, other):
+ raise NotImplementedError
+
+ def area(self):
+ raise NotImplementedError
+
+ def center(self):
+ raise NotImplementedError
+
+ def isInside(self, x, y):
+ raise NotImplementedError
+
+
\ No newline at end of file
diff --git a/lib/polygon.py b/lib/polygon/poly.py
similarity index 63%
rename from lib/polygon.py
rename to lib/polygon/poly.py
index a3fe75e..dc896ec 100644
--- a/lib/polygon.py
+++ b/lib/polygon/poly.py
@@ -14,50 +14,14 @@
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see .
-"""
-
-
-class AbstractPolygon(object):
- """
- all polygon implementation will implement this interface
- """
- def __init__(self, contours=None, data=None):
- self.data = data
-
- def __len__(self):
- raise NotImplementedError
-
- def __getitem__(self, key):
- raise NotImplementedError
-
- def addContour(self, contour):
- raise NotImplementedError
-
- def __and__(self, other):
- raise NotImplementedError
-
- def __or__(self, other):
- raise NotImplementedError
-
- def __add__(self, other):
- return self.__or__(other)
-
- def __sub__(self, other):
- raise NotImplementedError
-
- def area(self):
- raise NotImplementedError
-
- def center(self):
- raise NotImplementedError
-
- def isInside(self, x, y):
- raise NotImplementedError
-
+"""
+from base import AbstractPolygon
class PolyPolygon(AbstractPolygon):
"""
+ wrapper for python polygon package
+
http://pypi.python.org/pypi/Polygon/2.0.4
http://www.j-raedler.de/projects/polygon/
"""
@@ -99,19 +63,3 @@ def center(self):
def isInside(self, x, y):
return self.poly.isInside(x,y)
-
-
-Polygon = PolyPolygon
-
-
-
-if __name__ == "__main__":
-
- p = Polygon([[(0,0),(30,0),(15,30)]])
- print 'p', p.area()
- q = Polygon([[(10,5),(30,0),(15,20)]])
- print 'q', q.area()
- print 'p+q', (p+q).area()
- print 'p-q', (p-q).area()
- print 'p&q', (p&q).area()
- print 'p|q', (p|q).area()
\ No newline at end of file