Changeset 1082

Show
Ignore:
Timestamp:
04/26/08 14:51:02
Author:
seang
Message:

a == b (Python equality) is no longer the same thing as a.equals(b) (topological equality), new safer predicate shortcuts for objects that are identical in the Python sense (#163)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • Shapely/trunk/CHANGES.txt

    r1080 r1082  
    11All tickets are children of http://trac.gispython.org/projects/PCL/ticket/ 
     2 
     31.0.4 (2008-04-26) 
     4------------------ 
     5- Disentangle Python and topological equality (#163). 
     6- Implement safe predicate shortcuts for objects identical in the Python sense 
     7  (#163). 
    28 
    391.0.3 (2008-04-09) 
  • Shapely/trunk/shapely/geometry/base.py

    r1066 r1082  
    249249        return self.to_wkt() 
    250250 
    251     def __eq__(self, other): 
    252         return self.equals(other) 
    253      
    254     def __ne__(self, other): 
    255         return not self.equals(other) 
    256  
    257251    # To support pickling 
    258252 
     
    420414 
    421415    # TODO: Relate Pattern? 
    422     disjoint = BinaryPredicate(lgeos.GEOSDisjoint
    423     touches = BinaryPredicate(lgeos.GEOSTouches
    424     intersects = BinaryPredicate(lgeos.GEOSIntersects
    425     crosses = BinaryPredicate(lgeos.GEOSCrosses
    426     within = BinaryPredicate(lgeos.GEOSWithin
    427     contains = BinaryPredicate(lgeos.GEOSContains
    428     overlaps = BinaryPredicate(lgeos.GEOSOverlaps
    429     equals = BinaryPredicate(lgeos.GEOSEquals
     416    disjoint = BinaryPredicate(lgeos.GEOSDisjoint, False
     417    touches = BinaryPredicate(lgeos.GEOSTouches, False
     418    intersects = BinaryPredicate(lgeos.GEOSIntersects, True
     419    crosses = BinaryPredicate(lgeos.GEOSCrosses, False
     420    within = BinaryPredicate(lgeos.GEOSWithin, True
     421    contains = BinaryPredicate(lgeos.GEOSContains, True
     422    overlaps = BinaryPredicate(lgeos.GEOSOverlaps, False
     423    equals = BinaryPredicate(lgeos.GEOSEquals, True
    430424 
    431425    # Unary predicates 
  • Shapely/trunk/shapely/geometry/point.py

    r1043 r1082  
    206206 
    207207    context = None 
    208     __geom = None 
     208    __geom__ = None 
    209209    _owned = False 
    210210 
     
    227227    def _geom(self): 
    228228        """Keeps the GEOS geometry in synch with the context.""" 
    229         if self.__geom is not None: 
    230             lgeos.GEOSGeom_destroy(self.__geom
    231         self.__geom, n = geos_point_from_py(self.context) 
    232         return self.__geom 
     229        if self.__geom__ is not None: 
     230            lgeos.GEOSGeom_destroy(self.__geom__
     231        self.__geom__, n = geos_point_from_py(self.context) 
     232        return self.__geom__ 
    233233 
    234234    # TODO: reimplement x, y, z properties without calling invoking _geom 
  • Shapely/trunk/shapely/predicates.py

    r1005 r1082  
    1515    context = None 
    1616 
    17     def __init__(self, fn): 
     17    def __init__(self, fn, self_predicate_value): 
    1818        self.fn = fn 
     19        self.self_predicate_value = self_predicate_value 
    1920        def errcheck(result, func, argtuple): 
    2021            if result == 2: 
     
    3031        if self.context._geom is None or other._geom is None: 
    3132            raise ValueError, "Null geometry supports no operations" 
     33        elif self.context == other: 
     34            return self.self_predicate_value 
    3235        return bool(self.fn(self.context._geom, other._geom)) 
    3336 
  • Shapely/trunk/tests/Predicates.txt

    r1005 r1082  
    2929  False 
    3030 
    31   >>> point == Point(0.0, 0.0) 
    32   True 
    33  
    34   >>> point == Point(-1.0, -1.0) 
    35   False 
    36  
    37   >>> point != Point(-1.0, -1.0) 
     31  >>> point.equals(Point(0.0, 0.0)) 
    3832  True 
    3933