#NEWLINE# def to_representation( self , instance ) : #NEWLINE# #INDENT# '\n        Serialize objects -> primitives.\n        ' #NEWLINE# feature = OrderedDict ( ) #NEWLINE# fields = list ( self . fields . values ( ) ) #NEWLINE# if self . Meta . id_field : #NEWLINE# #INDENT# field = self . fields [ self . Meta . id_field ] #NEWLINE# value = field . get_attribute ( instance ) #NEWLINE# feature [ 'id' ] = field . to_representation ( value ) #NEWLINE# fields . remove ( field ) #NEWLINE# #UNINDENT# feature [ 'type' ] = 'Feature' #NEWLINE# field = self . fields [ self . Meta . geo_field ] #NEWLINE# geo_value = field . get_attribute ( instance ) #NEWLINE# feature [ 'geometry' ] = field . to_representation ( geo_value ) #NEWLINE# fields . remove ( field ) #NEWLINE# if ( self . Meta . auto_bbox and geo_value ) : #NEWLINE# #INDENT# feature [ 'bbox' ] = geo_value . extent #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if self . Meta . bbox_geo_field : #NEWLINE# #INDENT# field = self . fields [ self . Meta . bbox_geo_field ] #NEWLINE# value = field . get_attribute ( instance ) #NEWLINE# feature [ 'bbox' ] = ( value . extent if hasattr ( value , 'extent' ) else None ) #NEWLINE# fields . remove ( field ) #NEWLINE# #UNINDENT# #UNINDENT# feature [ 'properties' ] = self . get_properties ( instance , fields ) #NEWLINE# return feature