#NEWLINE# def asShape( context ) : #NEWLINE# #INDENT# 'Adapts the context to a geometry interface. The coordinates remain\n    stored in the context.\n    ' #NEWLINE# if hasattr ( context , '__geo_interface__' ) : #NEWLINE# #INDENT# ob = context . __geo_interface__ #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# ob = context #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# geom_type = ob . get ( 'type' ) . lower ( ) #NEWLINE# #UNINDENT# except AttributeError : #NEWLINE# #INDENT# raise ValueError ( 'Context does not provide geo interface' ) #NEWLINE# #UNINDENT# if ( geom_type == 'point' ) : #NEWLINE# #INDENT# return asPoint ( ob [ 'coordinates' ] ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( geom_type == 'linestring' ) : #NEWLINE# #INDENT# return asLineString ( ob [ 'coordinates' ] ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( geom_type == 'polygon' ) : #NEWLINE# #INDENT# return asPolygon ( ob [ 'coordinates' ] [ 0 ] , ob [ 'coordinates' ] [ 1 : ] ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( geom_type == 'multipoint' ) : #NEWLINE# #INDENT# return asMultiPoint ( ob [ 'coordinates' ] ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( geom_type == 'multilinestring' ) : #NEWLINE# #INDENT# return asMultiLineString ( ob [ 'coordinates' ] ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( geom_type == 'multipolygon' ) : #NEWLINE# #INDENT# return MultiPolygonAdapter ( ob [ 'coordinates' ] , context_type = 'geojson' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# raise ValueError ( ( 'Unknown geometry type: %s' % geom_type ) )