changeset 5:baaa27ee220d default tip

Add __iter__ to fix comparison
author Cédric Krier <ced@b2ck.com>
date Fri, 24 Feb 2012 19:49:10 +0100
parents e0fe5418a764
children
files add_iter series
diffstat 2 files changed, 66 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/add_iter	Fri Feb 24 19:49:10 2012 +0100
@@ -0,0 +1,65 @@
+# HG changeset patch
+# Parent dd5d88248c52727c5cf176a5237394b47dd8b501
+diff -r dd5d88248c52 -r 0e376a2d9a6c src/ppygis.py
+--- a/src/ppygis.py	Tue Feb 21 00:12:35 2012 +0100
++++ b/src/ppygis.py	Fri Feb 24 19:46:33 2012 +0100
+@@ -382,6 +382,9 @@
+         return 'Polygon(' + ', '.join([str(ring) for ring in self.rings]) + \
+                 self._str_srid() + ')'
+ 
++    def __iter__(self):
++        return iter(self.rings)
++
+ 
+ class GeometryCollection(Geometry):
+ 
+@@ -416,7 +419,7 @@
+     def __eq__(self, other):
+         if not isinstance(other, type(self)):
+             return False
+-        for geo1, geo2 in izip_longest(self.geometries, other.geometries):
++        for geo1, geo2 in izip_longest(self, other):
+             if geo1 != geo2:
+                 return False
+         return True
+@@ -428,6 +431,9 @@
+         return 'GeometryCollection(' + ', '.join([str(geometry) for geometry in
+                 self.geometries]) + self._str_srid() + ')'
+ 
++    def __iter__(self):
++        return iter(self.geometries)
++
+ 
+ class MultiPoint(GeometryCollection):
+ 
+@@ -471,6 +477,9 @@
+         return 'MultiPoint(' + ', '.join([str(point) for point in
+                 self.points]) + self._str_srid() + ')'
+ 
++    def __iter__(self):
++        return iter(self.points)
++
+ 
+ class MultiLineString(GeometryCollection):
+ 
+@@ -514,6 +523,9 @@
+         return 'MultiLineString(' + ', '.join([str(line) for line in
+                 self.lines]) + self._str_srid() + ')'
+ 
++    def __iter__(self):
++        return iter(self.lines)
++
+ 
+ class MultiPolygon(GeometryCollection):
+ 
+@@ -557,6 +569,10 @@
+         return 'MultiPolygon(' + ', '.join([str(polygon) for polygon in
+                 self.polygons]) + self._str_srid() + ')'
+ 
++    def __iter__(self):
++        return iter(self.polygons)
++
++
+ def register_psycopg(connection, scope=None):
+     from psycopg2.extensions import (new_type, register_type, register_adapter,
+         AsIs)
--- a/series	Wed Feb 15 12:50:55 2012 +0100
+++ b/series	Fri Feb 24 19:49:10 2012 +0100
@@ -2,3 +2,4 @@
 unittests
 add_wkt
 equality_comp
+add_iter