def __len__(self): self._update() if self._cseq is None: return 0 else: cs_len = c_uint(0) if self._cseq: lgeos.GEOSCoordSeq_getSize(self._cseq, byref(cs_len)) return cs_len.value
def nearest_points(self, other): """Returns list of tuples like (x, y) of nearest points""" _ndim = 2 # TODO: remove hardcoding _cseq = self.impl['nearest_points'](self, other) cs_len = c_uint(0) lgeos.GEOSCoordSeq_getSize(_cseq, byref(cs_len)) llen = cs_len.value dx = c_double() dy = c_double() dz = c_double() has_z = _ndim == 3 res = [] for i in xrange(llen): lgeos.GEOSCoordSeq_getX(_cseq, i, byref(dx)) lgeos.GEOSCoordSeq_getY(_cseq, i, byref(dy)) if has_z: lgeos.GEOSCoordSeq_getZ(_cseq, i, byref(dz)) res.append((dx.value, dy.value, dz.value)) else: res.append((dx.value, dy.value)) return res
def __call__(self, this): self._validate(this) env = this.envelope if env.geom_type == 'Point': return env.bounds cs = lgeos.GEOSGeom_getCoordSeq(env.exterior._geom) cs_len = c_uint(0) lgeos.GEOSCoordSeq_getSize(cs, byref(cs_len)) minx = 1.e+20 maxx = -1e+20 miny = 1.e+20 maxy = -1e+20 temp = c_double() for i in range(cs_len.value): lgeos.GEOSCoordSeq_getX(cs, i, byref(temp)) x = temp.value if x < minx: minx = x if x > maxx: maxx = x lgeos.GEOSCoordSeq_getY(cs, i, byref(temp)) y = temp.value if y < miny: miny = y if y > maxy: maxy = y return (minx, miny, maxx, maxy)
def __len__(self): self._update() cs_len = c_uint(0) lgeos.GEOSCoordSeq_getSize(self._cseq, byref(cs_len)) return cs_len.value