#NEWLINE# def write_features( fobj , collection , sequence = False , geojson_type = 'feature' , use_rs = False , **dump_kwds ) : #NEWLINE# #INDENT# 'Read an iterator of (feat, bbox) pairs and write to file using\n    the selected modes.' #NEWLINE# if sequence : #NEWLINE# #INDENT# for feat in collection ( ) : #NEWLINE# #INDENT# ( xs , ys ) = zip ( * coords ( feat ) ) #NEWLINE# bbox = ( min ( xs ) , min ( ys ) , max ( xs ) , max ( ys ) ) #NEWLINE# if use_rs : #NEWLINE# #INDENT# fobj . write ( '\x1e' ) #NEWLINE# #UNINDENT# if ( geojson_type == 'feature' ) : #NEWLINE# #INDENT# fobj . write ( json . dumps ( feat , ** dump_kwds ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( geojson_type == 'bbox' ) : #NEWLINE# #INDENT# fobj . write ( json . dumps ( bbox , ** dump_kwds ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# fobj . write ( json . dumps ( { #NEWLINE# #INDENT# 'type' : 'FeatureCollection' , #NEWLINE# 'bbox' : bbox , #NEWLINE# 'features' : [ feat ] , #NEWLINE# #UNINDENT# } , ** dump_kwds ) ) #NEWLINE# #UNINDENT# #UNINDENT# fobj . write ( '\n' ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# features = list ( collection ( ) ) #NEWLINE# if ( geojson_type == 'bbox' ) : #NEWLINE# #INDENT# fobj . write ( json . dumps ( collection . bbox , ** dump_kwds ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( geojson_type == 'feature' ) : #NEWLINE# #INDENT# fobj . write ( json . dumps ( features [ 0 ] , ** dump_kwds ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# fobj . write ( json . dumps ( { #NEWLINE# #INDENT# 'bbox' : collection . bbox , #NEWLINE# 'type' : 'FeatureCollection' , #NEWLINE# 'features' : features , #NEWLINE# #UNINDENT# } , ** dump_kwds ) ) #NEWLINE# #UNINDENT# #UNINDENT# fobj . write ( '\n' )