<s> """<STR_LIT>""" <EOL> from ctypes import c_void_p <EOL> from shapely . geos import lgeos <EOL> from shapely . geometry . base import BaseGeometry <EOL> from shapely . geometry . base import BaseMultipartGeometry <EOL> from shapely . geometry . base import HeterogeneousGeometrySequence <EOL> from shapely . geometry . base import geos_geom_from_py <EOL> class GeometryCollection ( BaseMultipartGeometry ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , geoms = None ) : <EOL> """<STR_LIT>""" <EOL> BaseMultipartGeometry . __init__ ( self ) <EOL> if not geoms : <EOL> pass <EOL> else : <EOL> self . _geom , self . _ndim = geos_geometrycollection_from_py ( geoms ) <EOL> @ property <EOL> def __geo_interface__ ( self ) : <EOL> geometries = [ ] <EOL> for geom in self . geoms : <EOL> geometries . append ( geom . __geo_interface__ ) <EOL> return dict ( type = '<STR_LIT>' , geometries = geometries ) <EOL> @ property <EOL> def geoms ( self ) : <EOL> if self . is_empty : <EOL> return [ ] <EOL> return HeterogeneousGeometrySequence ( self ) <EOL> def geos_geometrycollection_from_py ( ob ) : <EOL> """<STR_LIT>""" <EOL> L = len ( ob ) <EOL> N = <NUM_LIT:2> <EOL> subs = ( c_void_p * L ) ( ) <EOL> for l in range ( L ) : <EOL> assert ( isinstance ( ob [ l ] , BaseGeometry ) ) <EOL> if ob [ l ] . has_z : <EOL> N = <NUM_LIT:3> <EOL> geom , n = geos_geom_from_py ( ob [ l ] ) <EOL> subs [ l ] = geom <EOL> return ( lgeos . GEOSGeom_createCollection ( <NUM_LIT:7> , subs , L ) , N ) <EOL> def _test ( ) : <EOL> import doctest <EOL> doctest . testmod ( ) <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> _test ( ) </s>
