#NEWLINE# def _set_datum( self , rec_offs , dim , val ) : #NEWLINE# #INDENT# 'Set a non dimension field as with _set_raw_datum, but supply a formatted value' #NEWLINE# if ( dim . num == 1 ) : #NEWLINE# #INDENT# lb = ( rec_offs + dim . offs ) #NEWLINE# ub = ( lb + dim . length ) #NEWLINE# try : #NEWLINE# #INDENT# self . data_provider . _mmap [ lb : ub ] = struct . pack ( dim . fmt , val ) #NEWLINE# #UNINDENT# except : #NEWLINE# #INDENT# self . data_provider . _mmap [ lb : ub ] = struct . pack ( dim . fmt , int ( val ) ) #NEWLINE# #UNINDENT# return #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# dimlen = len ( val ) #NEWLINE# #UNINDENT# except Exception : #NEWLINE# #INDENT# dimlen = 1 #NEWLINE# #UNINDENT# if ( dim . num != dimlen ) : #NEWLINE# #INDENT# raise laspy . util . LaspyException ( ( ( ( ( ( 'Fields must be replaced with data of the same length. ' + str ( dim . name ) ) + ' should be length ' ) + str ( dim . num ) ) + ', received ' ) + str ( dimlen ) ) ) #NEWLINE# #UNINDENT# def f( x ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# outbyte = struct . pack ( dim . fmt , val [ x ] ) #NEWLINE# #UNINDENT# except : #NEWLINE# #INDENT# outbyte = struct . pack ( dim . fmt , int ( val [ x ] ) ) #NEWLINE# #UNINDENT# self . data_provider . _mmap [ ( ( ( x * dim . length ) + rec_offs ) + dim . offs ) : ( ( ( ( x + 1 ) * dim . length ) + rec_offs ) + dim . offs ) ] = outbyte #NEWLINE# #UNINDENT# map ( f , xrange ( dim . num ) ) #NEWLINE# return