#NEWLINE# def get_geometry_type( self , table_name , geo_col ) : #NEWLINE# #INDENT# "\n        The geometry type OID used by PostGIS does not indicate the particular\n        type of field that a geometry column is (e.g., whether it's a\n        PointField or a PolygonField).  Thus, this routine queries the PostGIS\n        metadata tables to determine the geometry type,\n        " #NEWLINE# cursor = self . connection . cursor ( ) #NEWLINE# try : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# cursor . execute ( 'SELECT "coord_dimension", "srid", "type" FROM "geometry_columns" WHERE "f_table_name"=%s AND "f_geometry_column"=%s' , ( table_name , row ) ) #NEWLINE# row = cursor . fetchone ( ) #NEWLINE# if ( not row ) : #NEWLINE# #INDENT# raise GeoIntrospectionError #NEWLINE# #UNINDENT# #UNINDENT# except GeoIntrospectionError : #NEWLINE# #INDENT# cursor . execute ( 'SELECT "coord_dimension", "srid", "type" FROM "geography_columns" WHERE "f_table_name"=%s AND "f_geography_column"=%s' , ( table_name , geo_col ) ) #NEWLINE# row = cursor . fetchone ( ) #NEWLINE# #UNINDENT# if ( not row ) : #NEWLINE# #INDENT# raise Exception ( ( 'Could not find a geometry or geography column for "%s"."%s"' % ( table_name , geo_col ) ) ) #NEWLINE# #UNINDENT# field_type = OGRGeomType ( row [ 2 ] ) . django #NEWLINE# dim = row [ 0 ] #NEWLINE# srid = row [ 1 ] #NEWLINE# field_params = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# if ( srid != 4326 ) : #NEWLINE# #INDENT# field_params [ 'srid' ] = srid #NEWLINE# #UNINDENT# if ( dim != 2 ) : #NEWLINE# #INDENT# field_params [ 'dim' ] = dim #NEWLINE# #UNINDENT# #UNINDENT# finally : #NEWLINE# #INDENT# cursor . close ( ) #NEWLINE# #UNINDENT# return ( field_type , field_params )