root/trunk/python/tests/File.txt

Revision 947, 2.2 kB (checked in by hobu, 7 weeks ago)

more fixups related to #83.. ensure we use GMT and fix microseconds overflow

Line 
1  >>> from liblas import file
2  >>> f = file.File('../test/data/TO_core_last_clip.las')
3 
4  >>> f.header # doctest: +ELLIPSIS
5  <liblas.header.Header object at ...>
6 
7  >>> f.header.point_records_count
8  8L
9 
10  >>> header = f.header
11  >>> p = f.read(0)
12  >>> p.x, p.y, p.z
13  (630262.30000000005, 4834500.0, 51.530000000000001)
14 
15  >>> p = f.read(6)
16  >>> p.x, p.y, p.z
17  (630320.95999999996, 4834500.0, 55.009999999999998)
18 
19  >>> points = []
20  >>> for i in f:
21  ...   points.append(i)
22  ...   print i # doctest: +ELLIPSIS
23  <liblas.point.Point object at ...>
24  <liblas.point.Point object at ...>
25  <liblas.point.Point object at ...>
26  <liblas.point.Point object at ...>
27  <liblas.point.Point object at ...>
28  <liblas.point.Point object at ...>
29  <liblas.point.Point object at ...>
30  <liblas.point.Point object at ...>
31
32  >>> len(points)
33  8
34
35  >>> for p in points:
36  ...   print p.x, p.y
37  630262.3 4834500.0
38  630282.45 4834500.0
39  630300.08 4834500.0
40  630346.83 4834500.0
41  630327.59 4834500.0
42  630323.57 4834500.0
43  630320.96 4834500.0
44  630280.89 4834500.0
45
46  >>> points = []
47  >>> for i in f:
48  ...   points.append(i)
49  ...   print i # doctest: +ELLIPSIS
50  <liblas.point.Point object at ...>
51  <liblas.point.Point object at ...>
52  <liblas.point.Point object at ...>
53  <liblas.point.Point object at ...>
54  <liblas.point.Point object at ...>
55  <liblas.point.Point object at ...>
56  <liblas.point.Point object at ...>
57  <liblas.point.Point object at ...>
58
59
60  >>> len(points)
61  8 
62
63  >>> del f
64 
65  >>> f = file.File('junk.las', mode="w", header=header)
66  >>> sum(header.offset)
67  0.0
68  >>> header.min
69  [630262.30000000005, 4834500.0, 50.899999999999999]
70
71  >>> for i in points:
72  ...    f.write(i)
73 
74  >>> pts = file.File('junk.las')
75  Traceback (most recent call last):
76  ...
77  LASException: ('File %s is already open.  Close the file or delete the reference to it', 'junk.las')
78 
79  >>> f.close()
80  >>> f.header
81
82  >>> del f
83  >>> f = file.File('junk.las', mode='w+', header=header)
84 
85  >>> for i in points:
86  ...    f.write(i)
87 
88  >>> f.close()
89 
90  >>> f = file.File('junk.las')
91  >>> cnt = 0
92  >>> for i in f:
93  ...     cnt += 1
94 
95  >>> cnt
96  16
97 
98  >>> f.close()
99  >>> import os
100  >>> os.remove('junk.las')
Note: See TracBrowser for help on using the browser.