  >>> from liblas import file
  >>> f = file.File('../test/data/TO_core_last_clip.las')
  
  >>> f.header # doctest: +ELLIPSIS
  <liblas.header.Header object at ...>
  
  >>> f.header.point_records_count
  8L
  
  >>> header = f.header
  >>> p = f.read(0)
  >>> p.x, p.y, p.z
  (630262.30000000005, 4834500.0, 51.530000000000001)
  
  >>> p = f.read(6)
  >>> p.x, p.y, p.z
  (630320.95999999996, 4834500.0, 55.009999999999998)
  
  >>> f2 = file.File('../test/data/TO_core_last_clip.las')
  >>> p2 = f2.read(6)
  >>> p.x, p.y, p.z
  (630320.95999999996, 4834500.0, 55.009999999999998)
  >>> f2.close()
  >>> del f2
  
  >>> points = []
  >>> for i in f:
  ...   points.append(i)
  ...   print i # doctest: +ELLIPSIS
  <liblas.point.Point object at ...>
  <liblas.point.Point object at ...>
  <liblas.point.Point object at ...>
  <liblas.point.Point object at ...>
  <liblas.point.Point object at ...>
  <liblas.point.Point object at ...>
  <liblas.point.Point object at ...>
  <liblas.point.Point object at ...>

  >>> len(points)
  8

  >>> for p in points:
  ...   print p.x, p.y
  630262.3 4834500.0
  630282.45 4834500.0
  630300.08 4834500.0
  630346.83 4834500.0
  630327.59 4834500.0
  630323.57 4834500.0
  630320.96 4834500.0
  630280.89 4834500.0

  >>> points = []
  >>> for i in f:
  ...   points.append(i)
  ...   print i # doctest: +ELLIPSIS
  <liblas.point.Point object at ...>
  <liblas.point.Point object at ...>
  <liblas.point.Point object at ...>
  <liblas.point.Point object at ...>
  <liblas.point.Point object at ...>
  <liblas.point.Point object at ...>
  <liblas.point.Point object at ...>
  <liblas.point.Point object at ...>


  >>> len(points)
  8  

  >>> del f
  
  >>> f = file.File('junk.las', mode="w", header=header)
  >>> sum(header.offset)
  0.0
  >>> header.min
  [630262.30000000005, 4834500.0, 50.899999999999999]

  >>> for i in points:
  ...    f.write(i)
  
  >>> pts = file.File('junk.las')
  Traceback (most recent call last):
  ...
  LASException: File junk.las is already open for write.  Close the file or delete the reference to it
  
  >>> f.close()
  >>> f.header

  >>> del f
  >>> f = file.File('junk.las', mode='w+', header=header)
  
  >>> for i in points:
  ...    f.write(i)
  
  >>> f.close()
  
  >>> f = file.File('junk.las')
  >>> cnt = 0
  >>> for i in f:
  ...     cnt += 1
  
  >>> cnt
  16

  >>> buffered_header = f.header
  >>> del f 

  >>> buffered_header.data_offset = 1024
  >>> f3 = file.File('junk2.las',mode='w',header=buffered_header)

  >>> f3.header.data_offset
  1024L

  >>> for i in points:
  ...    f3.write(i)
    
  >>> f3.close()

  >>> del f3
 
The header's offset will change +=2 because of the 1.0
requirement to write pad bytes at the end of the header
  
  >>> f = file.File('junk2.las')
  >>> f.header.data_offset
  1026L
  
  >>> points = []
  >>> for i in f:
  ...   points.append(i)
  ...   print i # doctest: +ELLIPSIS
  <liblas.point.Point object at ...>
  <liblas.point.Point object at ...>
  <liblas.point.Point object at ...>
  <liblas.point.Point object at ...>
  <liblas.point.Point object at ...>
  <liblas.point.Point object at ...>
  <liblas.point.Point object at ...>
  <liblas.point.Point object at ...>

  >>> for g in points:
  ...   print int(g.x), int(g.y)
  630262 4834500
  630282 4834500
  630300 4834500
  630346 4834500
  630327 4834500
  630323 4834500
  630320 4834500
  630280 4834500

Now try writing a 1.2 version of the junk2.las file above to ensure that
the data_offset *doesn't* change at all

  >>> buffered_header.data_offset = 1024
  >>> buffered_header.minor_version = 2
  >>> f3 = file.File('junk3.las',mode='w',header=buffered_header)

  >>> f3.header.data_offset
  1024L

  >>> for i in points:
  ...    f3.write(i)
    
  >>> f3.close()

  >>> del f3

  >>> f = file.File('junk3.las')
  >>> f.header.data_offset
  1024L
  
  >>> points = []
  >>> for i in f:
  ...   points.append(i)
  ...   print i # doctest: +ELLIPSIS
  <liblas.point.Point object at ...>
  <liblas.point.Point object at ...>
  <liblas.point.Point object at ...>
  <liblas.point.Point object at ...>
  <liblas.point.Point object at ...>
  <liblas.point.Point object at ...>
  <liblas.point.Point object at ...>
  <liblas.point.Point object at ...>

  >>> for g in points:
  ...   print int(g.x), int(g.y)
  630262 4834500
  630282 4834500
  630300 4834500
  630346 4834500
  630327 4834500
  630323 4834500
  630320 4834500
  630280 4834500
    
  >>> import os
  >>> os.remove('junk.las')
  >>> os.remove('junk2.las')
  >>> os.remove('junk3.las')

  >>> f = file.File('junk.las', mode="w", header=header)
  >>> import liblas.core
  >>> liblas.core.las.LASWriter_Destroy(f.handle)
  >>> print 'destroyed once'
  destroyed once
  >>> f.handle = None
  >>> liblas.core.las.LASWriter_Destroy(f.handle)
  Traceback (most recent call last):
  ...
  LASException: LASError in "LASWriter_Destroy": Pointer 'hWriter' is NULL in 'LASWriter_Destroy'.

  >>> import os
  >>> os.remove('junk.las')
  

