#NEWLINE# @ classmethod #NEWLINE# def get_spheroid( cls , wkt , string = True ) : #NEWLINE# #INDENT# '\n        Class method used by GeometryField on initialization to\n        retrieve the `SPHEROID[..]` parameters from the given WKT.\n        ' #NEWLINE# if gdal . HAS_GDAL : #NEWLINE# #INDENT# srs = gdal . SpatialReference ( wkt ) #NEWLINE# sphere_params = srs . ellipsoid #NEWLINE# sphere_name = srs [ 'spheroid' ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# m = cls . spheroid_regex . match ( wkt ) #NEWLINE# if m : #NEWLINE# #INDENT# sphere_params = ( float ( m . group ( 'major' ) ) , float ( m . group ( 'flattening' ) ) ) #NEWLINE# sphere_name = m . group ( 'name' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return None #NEWLINE# #UNINDENT# #UNINDENT# if ( not string ) : #NEWLINE# #INDENT# return ( wkt , sphere_params ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( len ( sphere_params ) == 3 ) : #NEWLINE# #INDENT# ( radius , flattening ) = ( sphere_params [ 0 ] , sphere_params [ 2 ] ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# ( radius , flattening ) = sphere_params #NEWLINE# #UNINDENT# return ( 'SPHEROID["%s",%s,%s]' % ( sphere_name , radius , flattening ) )