def fromfile(file_name): """ Given a string file name, returns a GEOSGeometry. The file may contain WKB, WKT, or HEX. """ fh = open(file_name, 'rb') buf = fh.read() fh.close() if wkt_regex.match(buf) or hex_regex.match(buf): return GEOSGeometry(buf) else: return GEOSGeometry(buffer(buf))
def get_interior_ring(self, ring_i): """ Gets the interior ring at the specified index, 0 is for the first interior ring, not the exterior ring. """ self._checkindex(ring_i + 1) return GEOSGeometry(geom_clone(get_intring(self.ptr, ring_i)), srid=self.srid)
def area(input): "Returns the area of the geometry (given in HEXEWKB)." return GEOSGeometry(input).area
def centroid(input): "Returns the centroid of the geometry (given in HEXEWKB)." return GEOSGeometry(input).centroid.wkt
def wkt_to_hex(wkt): "Converts WKT into HEXEWKB." return GEOSGeometry(wkt).hex
def hex_to_wkt(hex): "Converts HEXEWKB into WKT." return GEOSGeometry(hex).wkt
def fromstr(wkt_or_hex, **kwargs): "Given a string value (wkt or hex), returns a GEOSGeometry object." return GEOSGeometry(wkt_or_hex, **kwargs)
def get_ext_ring(self): "Gets the exterior ring of the Polygon." return GEOSGeometry(geom_clone(get_extring(self.ptr)), srid=self.srid)
def __getitem__(self, index): "Returns the Geometry from this Collection at the given index (0-based)." # Checking the index and returning the corresponding GEOS geometry. self._checkindex(index) return GEOSGeometry(geom_clone(get_geomn(self.ptr, index)), srid=self.srid)