#NEWLINE# def _center_pts( pts ) : #NEWLINE# #INDENT# 'Fancy label position generator, using erosion to get label coordinate' #NEWLINE# min = pts . min ( 0 ) #NEWLINE# pts -= min #NEWLINE# max = pts . max ( 0 ) #NEWLINE# pts /= max #NEWLINE# if ( len ( pts ) > 20 ) : #NEWLINE# #INDENT# pts = pts [ : : ( len ( pts ) / 20 ) ] #NEWLINE# #UNINDENT# poly = Polygon ( [ tuple ( p ) for p in pts ] ) #NEWLINE# for i in np . linspace ( 0 , 1 , 100 ) : #NEWLINE# #INDENT# if poly . buffer ( ( - i ) ) . is_empty : #NEWLINE# #INDENT# return ( ( list ( poly . buffer ( ( - last_i ) ) . centroid . coords ) [ 0 ] * max ) + min ) #NEWLINE# #UNINDENT# last_i = i #NEWLINE# #UNINDENT# print ( 'unable to find zero centroid...' ) #NEWLINE# return ( ( list ( poly . buffer ( ( - 100 ) ) . centroid . coords ) [ 0 ] * pts ) + min )