File: VLR.txt

package info (click to toggle)
liblas 1.8.0-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 7,888 kB
  • ctags: 4,614
  • sloc: cpp: 31,630; xml: 4,195; python: 2,928; ansic: 2,439; cs: 2,411; sh: 143; makefile: 37
file content (119 lines) | stat: -rwxr-xr-x 2,270 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
  >>> from liblas import vlr
  >>> v = vlr.VLR()
  >>> v.reserved
  43707
  >>> v.recordid
  0
  >>> v.recordid = 2
  >>> v.recordid
  2
  >>> str(v.userid.decode())
  ''
  >>> v.userid = b'liblas.org'
  >>> str(v.userid.decode())
  'liblas.org'

  >>> str(v.description.decode())
  ''
  >>> v.description = b'libLAS'
  >>> str(v.description.decode())
  'libLAS'

  >>> v.recordlength = 256
  >>> v.recordlength
  256

  >>> import ctypes
  >>> data = (ctypes.c_ubyte * 256)()
  >>> data[10]
  0

  >>> for i in range(256):
  ...     data[i] = 2+i

  >>> data[10]
  12
  >>> v.data = data

# Ensure we can round trip the data
  >>> [data[i] for i in range(10)]
  [2, 3, 4, 5, 6, 7, 8, 9, 10, 11]
  >>> [v.data[i] for i in range(10)]
  [2, 3, 4, 5, 6, 7, 8, 9, 10, 11]

# Ensure poking one array doesn't affect the other
  >>> data[1] = 32
  >>> v.data = data
  >>> data[1] = 3
  >>> v.data[1]
  32
  >>> data[1]
  3

  >>> [v.data[i] for i in range(10)]
  [2, 32, 4, 5, 6, 7, 8, 9, 10, 11]

  >>> import liblas

#  >>> liblas.HAVE_GDAL
#  >>> liblas.HAVE_LIBGEOTIFF

  >>> from liblas import file
  >>> f = file.File('../test/data/srs.las')
  >>> h = f.header
  >>> int(h.records_count)
  3

  >>> def test_srs():
  ...     s = h.srs
  ...     if not liblas.HAVE_LIBGEOTIFF:
  ...         return True
  ...     if not liblas.HAVE_GDAL:
  ...         return s.proj4 == '+proj=utm +zone=17 +ellps=WGS84 +units=m '
  ...     if liblas.HAVE_GDAL:
  ...         return s.proj4 == '+proj=utm +zone=17 +datum=WGS84 +units=m +no_defs '
  ...     return False

  >>> test_srs()
  True


  >>> v = h.GetVLR(0)
  >>> v.recordid
  34735
  >>> str(v.userid.decode())
  'LASF_Projection'

  >>> data = v.data
  >>> len(data)
  72
  >>> data[6]
  8

  # Deleting a VLR shouldn't change the offset
  >>> int(h.data_offset)
  759
  >>> h.DeleteVLR(0)
  >>> int(h.data_offset)
  759

  >>> del f

  >>> f = file.File('../test/data/srs.las')
  >>> h = f.header
  >>> int(f.header.data_offset)
  759
  >>> f2 = file.File('junk_srs.las',mode='w',header=h)
  >>> for p in f:
  ...     f2.write(p)

  >>> f2.close()
  >>> del f2

  >>> f3 = file.File('junk_srs.las')
  >>> int(f3.header.records_count)
  3
  >>> int(f3.header.data_offset)
  759
  >>> import os
  >>> os.remove('junk_srs.las')