#NEWLINE# def test05_geography_layermapping( self ) : #NEWLINE# #INDENT# 'Testing LayerMapping support on models with geography fields.' #NEWLINE# if ( not gdal . HAS_GDAL ) : #NEWLINE# #INDENT# return #NEWLINE# #UNINDENT# from django.contrib.gis.utils import LayerMapping #NEWLINE# shp_path = os . path . realpath ( os . path . join ( os . path . dirname ( upath ( __file__ ) ) , '..' , 'data' ) ) #NEWLINE# co_shp = os . path . join ( shp_path , 'counties' , 'counties.shp' ) #NEWLINE# co_mapping = { #NEWLINE# #INDENT# 'name' : 'Name' , #NEWLINE# 'state' : 'State' , #NEWLINE# 'mpoly' : 'MULTIPOLYGON' , #NEWLINE# #UNINDENT# } #NEWLINE# names = [ 'Bexar' , 'Galveston' , 'Harris' , 'Honolulu' , 'Pueblo' ] #NEWLINE# num_polys = [ 1 , 2 , 1 , 19 , 1 ] #NEWLINE# st_names = [ 'Texas' , 'Texas' , 'Texas' , 'Hawaii' , 'Colorado' ] #NEWLINE# lm = LayerMapping ( County , co_shp , co_mapping , source_srs = 4269 , unique = 'name' ) #NEWLINE# lm . save ( silent = True , strict = True ) #NEWLINE# for ( c , name , num_poly , state ) in zip ( County . objects . order_by ( 'name' ) , names , num_polys , st_names ) : #NEWLINE# #INDENT# self . assertEqual ( 4326 , c . mpoly . srid ) #NEWLINE# self . assertEqual ( num_poly , len ( c . mpoly ) ) #NEWLINE# self . assertEqual ( name , c . name ) #NEWLINE# self . assertEqual ( state , names . state )