#NEWLINE# def geojson( self , precision = 8 , crs = False , bbox = False , **kwargs ) : #NEWLINE# #INDENT# '\n        Returns a GeoJSON representation of the geomtry field in a `geojson`\n        attribute on each element of the GeoQuerySet.\n\n        The `crs` and `bbox` keywords may be set to True if the users wants\n        the coordinate reference system and the bounding box to be included\n        in the GeoJSON representation of the geometry.\n        ' #NEWLINE# if ( ( not SpatialBackend . postgis ) or ( not SpatialBackend . geojson ) ) : #NEWLINE# #INDENT# raise NotImplementedError ( 'Only PostGIS 1.3.4+ supports GeoJSON serialization.' ) #NEWLINE# #UNINDENT# if ( not isinstance ( precision , ( int , long ) ) ) : #NEWLINE# #INDENT# raise TypeError ( 'Precision keyword must be set with an integer.' ) #NEWLINE# #UNINDENT# ( major , minor1 , minor2 ) = SpatialBackend . version #NEWLINE# if ( ( major >= 1 ) and ( minor1 >= 4 ) ) : #NEWLINE# #INDENT# options = 0 #NEWLINE# if ( crs and bbox ) : #NEWLINE# #INDENT# options = 3 #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if bbox : #NEWLINE# #INDENT# options = 1 #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if crs : #NEWLINE# #INDENT# options = 2 #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# options = 0 #NEWLINE# if ( crs and bbox ) : #NEWLINE# #INDENT# options = 3 #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if crs : #NEWLINE# #INDENT# options = 1 #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if minor1 : #NEWLINE# #INDENT# options = 2 #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# s = { #NEWLINE# #INDENT# 'desc' : 'GeoJSON' , #NEWLINE# 'procedure_args' : { #NEWLINE# #INDENT# 'precision' : precision , #NEWLINE# 'options' : options , #NEWLINE# #UNINDENT# } , #NEWLINE# 'procedure_fmt' : '%(geo_col)s,%(precision)s,%(options)s' , #NEWLINE# #UNINDENT# } #NEWLINE# return self . _spatial_attribute ( 'geojson' , s , ** kwargs )