def __setstate__(self, state): """WKB doesn't differentiate between LineString and LinearRing so we need to move the coordinate sequence into the correct geometry type""" super(LinearRing, self).__setstate__(state) cs = lgeos.GEOSGeom_getCoordSeq(self.__geom__) cs_clone = lgeos.GEOSCoordSeq_clone(cs) lgeos.GEOSGeom_destroy(self.__geom__) self.__geom__ = lgeos.GEOSGeom_createLinearRing(cs_clone)
def geos_geom_from_py(ob, create_func=None): """Helper function for geos_*_from_py functions in each geom type. If a create_func is specified the coodinate sequence is cloned and a new geometry is created with it, otherwise the geometry is cloned directly. This behaviour is useful for converting between LineString and LinearRing objects. """ if create_func is None: geom = lgeos.GEOSGeom_clone(ob._geom) else: cs = lgeos.GEOSGeom_getCoordSeq(ob._geom) cs = lgeos.GEOSCoordSeq_clone(cs) geom = create_func(cs) N = lgeos.GEOSGeom_getCoordinateDimension(geom) return geom, N