Changeset 1088

Show
Ignore:
Timestamp:
04/27/08 22:04:50
Author:
seang
Message:

Hash-based cache of geos geometries prevents corruption while keeping adapter in synch with context (#163)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • Shapely/trunk/shapely/geometry/point.py

    r1082 r1088  
    1111from shapely.geometry.base import BaseGeometry, CoordinateSequence 
    1212from shapely.geometry.base import exceptNull 
     13from shapely.geometry.proxy import CachingGeometryProxy 
    1314 
    1415 
     
    200201 
    201202 
    202 class PointAdapter(Point): 
     203class PointAdapter(CachingGeometryProxy, Point): 
    203204 
    204205    """Adapts a Python coordinate pair or a numpy array to the point interface. 
    205206    """ 
    206207 
    207     context = None 
    208     __geom__ = None 
    209208    _owned = False 
    210209 
    211210    def __init__(self, context): 
    212211        self.context = context 
     212        self.factory = geos_point_from_py 
    213213 
    214214    @property 
     
    224224            return len(self.context) 
    225225 
    226     @property 
    227     def _geom(self): 
    228         """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__ 
     226#    @property 
     227#    def _geom(self): 
     228#        """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__ 
    233233 
    234234    # TODO: reimplement x, y, z properties without calling invoking _geom 
  • Shapely/trunk/shapely/predicates.py

    r1082 r1088  
    3131        if self.context._geom is None or other._geom is None: 
    3232            raise ValueError, "Null geometry supports no operations" 
    33         elif self.context == other: 
    34             return self.self_predicate_value 
     33        #elif self.context == other: 
     34        #    return self.self_predicate_value 
    3535        return bool(self.fn(self.context._geom, other._geom)) 
    3636