Пример #1
0
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))
Пример #2
0
 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)
Пример #3
0
def area(input):
    "Returns the area of the geometry (given in HEXEWKB)."
    return GEOSGeometry(input).area
Пример #4
0
def centroid(input):
    "Returns the centroid of the geometry (given in HEXEWKB)."
    return GEOSGeometry(input).centroid.wkt
Пример #5
0
def wkt_to_hex(wkt):
    "Converts WKT into HEXEWKB."
    return GEOSGeometry(wkt).hex
Пример #6
0
def hex_to_wkt(hex):
    "Converts HEXEWKB into WKT."
    return GEOSGeometry(hex).wkt
Пример #7
0
def fromstr(wkt_or_hex, **kwargs):
    "Given a string value (wkt or hex), returns a GEOSGeometry object."
    return GEOSGeometry(wkt_or_hex, **kwargs)
Пример #8
0
 def get_ext_ring(self):
     "Gets the exterior ring of the Polygon."
     return GEOSGeometry(geom_clone(get_extring(self.ptr)), srid=self.srid)
Пример #9
0
 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)