/usr/share/pyshared/shapely/geometry/proxy.py is in python-shapely 1.2.14-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | """Proxy for coordinates stored outside Shapely geometries
"""
from shapely.geos import lgeos
from shapely import wkb
EMPTY = wkb.deserialize('010700000000000000'.decode('hex'))
class CachingGeometryProxy(object):
context = None
factory = None
__geom__ = EMPTY
_gtag = None
def __init__(self, context):
self.context = context
@property
def _is_empty(self):
return self.__geom__ in [EMPTY, None]
def empty(self):
if not self._is_empty:
lgeos.GEOSGeom_destroy(self.__geom__)
self.__geom__ = EMPTY
@property
def _geom(self):
"""Keeps the GEOS geometry in synch with the context."""
gtag = self.gtag()
if gtag != self._gtag or self._is_empty:
self.empty()
self.__geom__, n = self.factory(self.context)
self._gtag = gtag
return self.__geom__
def gtag(self):
return hash(repr(self.context))
class PolygonProxy(CachingGeometryProxy):
@property
def _geom(self):
"""Keeps the GEOS geometry in synch with the context."""
gtag = self.gtag()
if gtag != self._gtag or self._is_empty:
self.empty()
self.__geom__, n = self.factory(self.context[0], self.context[1])
self._gtag = gtag
return self.__geom__
|