root/trunk/python/tests/VLR.txt

Revision 888, 1.4 kB (checked in by hobu, 2 months ago)

VLR data setting for C/Python APIs #78

Line 
1  >>> from liblas import vlr
2  >>> v = vlr.VLR()
3  >>> v.reserved
4  0
5  >>> v.recordid
6  0
7  >>> v.recordid = 2
8  >>> v.recordid
9  2
10  >>> v.userid
11  ''
12  >>> v.userid = 'liblas.org'
13  >>> v.userid
14  'liblas.org'
15 
16  >>> v.description
17  ''
18  >>> v.description = 'libLAS'
19  >>> v.description
20  'libLAS'
21 
22  >>> v.recordlength = 256
23  >>> v.recordlength
24  256
25 
26  >>> import ctypes
27  >>> data = (ctypes.c_ubyte * 256)()
28  >>> data[10]
29  0
30 
31  >>> for i in range(256):
32  ...     data[i] = 2+i
33 
34  >>> data[10]
35  12
36  >>> v.data = data
37 
38# Ensure we can round trip the data
39  >>> [data[i] for i in range(10)]
40  [2, 3, 4, 5, 6, 7, 8, 9, 10, 11]
41  >>> [v.data[i] for i in range(10)]
42  [2, 3, 4, 5, 6, 7, 8, 9, 10, 11]
43
44# Ensure poking one array doesn't affect the other
45  >>> data[1] = 32
46  >>> v.data = data
47  >>> data[1] = 3
48  >>> v.data[1]
49  32
50  >>> data[1]
51  3
52 
53  >>> [v.data[i] for i in range(10)]
54  [2, 32, 4, 5, 6, 7, 8, 9, 10, 11]
55 
56   
57  >>> from liblas import file
58  >>> f = file.File('../test/data/srs.las')
59  >>> h = f.header
60  >>> h.records_count
61  3L
62  >>> h.proj4
63  '+proj=utm +zone=17 +ellps=WGS84 +units=m '
64  >>> v = h.GetVLR(0)
65  >>> v.recordid
66  34735
67  >>> v.userid
68  'LASF_Projection'
69 
70  >>> data = v.data
71  >>> len(data)
72  72
73  >>> data[6]
74  8
75
76  # Ensure the offset is updated when a VLR is deleted
77  >>> h.data_offset
78  759L
79  >>> h.DeleteVLR(0)
80  >>> h.data_offset
81  633L
82 
83 
Note: See TracBrowser for help on using the browser.