This file is indexed.

/usr/share/pyshared/liblas/header.py is in python-liblas 1.2.1-2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
"""
/******************************************************************************
 * $Id$
 *
 * Project:  libLAS - http://liblas.org - A BSD library for LAS format data.
 * Purpose:  Python LASHeader implementation
 * Author:   Howard Butler, hobu.inc@gmail.com
 *
 ******************************************************************************
 * Copyright (c) 2008, Howard Butler
 *
 * All rights reserved.
 * 
 * Redistribution and use in source and binary forms, with or without 
 * modification, are permitted provided that the following 
 * conditions are met:
 * 
 *     * Redistributions of source code must retain the above copyright 
 *       notice, this list of conditions and the following disclaimer.
 *     * Redistributions in binary form must reproduce the above copyright 
 *       notice, this list of conditions and the following disclaimer in 
 *       the documentation and/or other materials provided 
 *       with the distribution.
 *     * Neither the name of the Martin Isenburg or Iowa Department 
 *       of Natural Resources nor the names of its contributors may be 
 *       used to endorse or promote products derived from this software 
 *       without specific prior written permission.
 * 
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 
 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 
 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 
 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 
 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 
 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 
 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 
 * OF SUCH DAMAGE.
 ****************************************************************************/
 """
import core
import datetime
import guid
import vlr
import srs

def leap_year(year):
    if (year % 400) == 0:
        return True
    elif (year % 100) == 0:
        return True
    elif (year % 4) == 0:
        return False
    return False
    
class Header(object):
    def __init__(self, owned=True, handle=None):
        if handle:
            self.handle = handle
        else:
            self.handle = core.las.LASHeader_Create()
        self.owned = owned
    def __del__(self):
        if self.owned:
            if self.handle and core:
                core.las.LASHeader_Destroy(self.handle)
    
    def get_filesignature(self):
        """Returns the file signature for the file.  It should always be LASF"""
        return core.las.LASHeader_GetFileSignature(self.handle)
    file_signature = property(get_filesignature)
    
    def get_filesourceid(self):
        return core.las.LASHeader_GetFileSourceId(self.handle)
    filesource_id = property(get_filesourceid)

    def get_projectid(self):
        """Returns the ProjectID/GUID for the file.  libLAS does not currently support setting this value from Python"""
        return core.las.LASHeader_GetProjectId(self.handle)
    project_id = property(get_projectid)
    
    def get_guid(self):
        """Returns the GUID for the file as a liblas.guid.GUID"""
        return guid.GUID(handle=core.las.LASHeader_GetGUID(self.handle))
    def set_guid(self, value):
        """Sets the GUID for the file.  It must be a liblas.guid.GUID"""
        return core.las.LASHeader_SetGUID(self.handle, value.handle)
    guid = property(get_guid, set_guid)
    
    def get_majorversion(self):
        """Returns the major version for the file.  Expect this value to always be 1"""
        return core.las.LASHeader_GetVersionMajor(self.handle)
    def set_majorversion(self, value):
        """Sets the major version for the file.  Only the value 1 is accepted at this time"""
        return core.las.LASHeader_SetVersionMajor(self.handle, value)
    major_version = property(get_majorversion, set_majorversion)

    def get_minorversion(self):
        """Returns the minor version of the file.  Expect this value to always be 0, 1, or 2"""
        return core.las.LASHeader_GetVersionMinor(self.handle)
    def set_minorversion(self, value):
        """Sets the minor version of the file.  The value should be 0 for 1.0 LAS files and 1 for 1.1 LAS files"""
        return core.las.LASHeader_SetVersionMinor(self.handle, value)
    minor_version = property(get_minorversion, set_minorversion)

    def get_systemid(self):
        """Returns the system identifier specified in the file"""
        return core.las.LASHeader_GetSystemId(self.handle)
    def set_systemid(self, value):
        """Sets the system identifier.  The value is truncated to 31 characters"""
        return core.las.LASHeader_SetSystemId(self.handle, value[0:31])
    system_id = property(get_systemid, set_systemid)

    def get_softwareid(self):
        """Returns the software identifier specified in the file"""
        return core.las.LASHeader_GetSoftwareId(self.handle)
    def set_softwareid(self, value):
        """Sets the software identifier. 
        
        The value is truncated to 31 characters.

        Parameters
        ----------
        value : a string that will automatically be truncated to 31 characters
        
        Example
        -------
        >>> h.software_id
        'libLAS 1.0'
        >>> h.software_id = 'hobu'
        >>> h.software_id
        'hobu'
        >>> h.software_id = 'hobu'*9
        >>> h.software_id
        'hobuhobuhobuhobuhobuhobuhobuhob'        
        """
        return core.las.LASHeader_SetSoftwareId(self.handle, value[0:31])
    software_id = property(get_softwareid, set_softwareid)

    def get_date(self):
        """Return the header's date as a datetime.datetime.  If no date is set in the 
        header, None is returned.
        
        Note that dates in LAS headers are not transitive because the header
        only stores the year and the day number.
        """
        day = core.las.LASHeader_GetCreationDOY(self.handle)
        year = core.las.LASHeader_GetCreationYear(self.handle)
        if year == 0 and day == 0:
            return None
        if not leap_year(year):
            return datetime.datetime(year,1,1)+datetime.timedelta(day)
        else:
            return datetime.datetime(year,1,1)+datetime.timedelta(day-1)
    def set_date(self, value=datetime.datetime.now()):
        """Set the header's date from a datetime.datetime instance.

        Parameters
        ----------
        value : datetime.datetime instance or none to use the current time

        Example
        -------
        >>> t = datetime.datetime(2008,3,19)
        >>> h.date = t
        >>> h.date
        datetime.datetime(2008, 3, 19, 0, 0)
        """
        delta = value - datetime.datetime(value.year,1,1)
        if not leap_year(value.year):
            core.las.LASHeader_SetCreationDOY(self.handle, delta.days)
        else:
            core.las.LASHeader_SetCreationDOY(self.handle, delta.days + 1)
        core.las.LASHeader_SetCreationYear(self.handle, value.year)
    date = property(get_date, set_date)
    
    def get_headersize(self):
        """Return the size of the header block of the LAS file in bytes.  
        
        Should not be needed in Python land
        """
        return core.las.LASHeader_GetHeaderSize(self.handle)
    header_size = property(get_headersize)
    
    def get_dataoffset(self):
        """Returns the location in bytes of where the data block of the LAS file starts"""
        return core.las.LASHeader_GetDataOffset(self.handle)
    def set_dataoffset(self, value):
        """Sets the data offset
        
        Any space between this value and the end of the VLRs will be written with 0's
        """
        return core.las.LASHeader_SetDataOffset(self.handle, value)
    data_offset = property(get_dataoffset, set_dataoffset)
    
    def get_recordscount(self):
        """Returns the number of user-defined header records in the header.  
        User-defined records are not really supported at this time in libLAS"""
        return core.las.LASHeader_GetRecordsCount(self.handle)
    records_count = property(get_recordscount)
    
    def get_dataformatid(self):
        """Gets the point format value
        
        A value of 1 means the format is 1.1 compatible and includes a time 
        value on the points.  A value of 0 means the format is 1.0 compatible.
        """
        return core.las.LASHeader_GetDataFormatId(self.handle)
    def set_dataformatid(self, value):
        """Sets the point format value
        
        It can be 3, 2, 1, or 0.
        """
        if value not in [3, 2,1,0]:
            raise core.LASException("Format ID must be 3, 2, 1, or 0")
        return core.las.LASHeader_SetDataFormatId(self.handle, value)
    dataformat_id = property(get_dataformatid, set_dataformatid)
    
    def get_datarecordlength(self):
        return core.las.LASHeader_GetDataRecordLength(self.handle)
    data_record_length = property(get_datarecordlength)
    
    def get_pointrecordscount(self):
        """Returns the expected number of point records in the file.  
        
        Note that this value can be grossly out of sync with the 
        actual number of points in the file.  Do not depend on it for 
        anything significant (like picking iteration locations in the file :)
        """
        return core.las.LASHeader_GetPointRecordsCount(self.handle)
    def set_pointrecordscount(self, value):
        """Sets the number of point records expected in the file"""
        return core.las.LASHeader_SetPointRecordsCount(self.handle, value)
    point_records_count = property(get_pointrecordscount, set_pointrecordscount)
    
    def get_pointrecordsbyreturncount(self):
        """Gets the histogram of point records by return number for returns 0...8

        Example
        -------

        >>> h.point_return_count
        [0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L]
        
        """
        output = []
        for i in range(8):
            output.append(core.las.LASHeader_GetPointRecordsByReturnCount(self.handle, i))
        return output
    def set_pointrecordsbyreturncount(self, value):
        """Sets the histogram of point records by return number from a list of returns 0..8

        Example
        -------

        >>> h.point_return_count = [1341235L, 3412341222L, 0L, 0L, 4321L, 0L, 0L, 0L]
        >>> h.point_return_count 
        [1341235L, 3412341222L, 0L, 0L, 4321L, 0L, 0L, 0L]

        """
        for i in value[0:7]:
            core.las.LASHeader_SetPointRecordsByReturnCount(self.handle, value.index(i), i)
    point_return_count = property(get_pointrecordsbyreturncount, set_pointrecordsbyreturncount)
    
    def get_scale(self):
        """Gets the scale factors in [x, y, z] for the point data.  
        
        libLAS uses this header value when reading/writing raw point data to the file.  
        If you change it in the middle of writing data, expect the unexpected.
        
        Example
        -------
        
        >>> h.scale
        [0.01, 0.01, 0.01]
        """
        x = core.las.LASHeader_GetScaleX(self.handle)
        y = core.las.LASHeader_GetScaleY(self.handle)
        z = core.las.LASHeader_GetScaleZ(self.handle)
        return [x,y,z]
    def set_scale(self, value):
        """Sets the scale factors in [x, y, z] for the point data.

        Example
        -------
        
        >>> h.scale = [0.5, 0.5, 0.001]
        >>> h.scale
        [0.5, 0.5, 0.001]
        """
        return core.las.LASHeader_SetScale(self.handle, value[0], value[1], value[2])
    scale = property(get_scale, set_scale)

    def get_offset(self):
        """Gets the offset factors in [x, y, z] for the point data.  
        
        libLAS uses this header value when reading/writing raw point data to the file.  
        If you change it in the middle of writing data, expect the unexpected.
        
        Example
        -------
        
        >>> h.offset
        [0.0, 0.0, 0.0]
        """
        x = core.las.LASHeader_GetOffsetX(self.handle)
        y = core.las.LASHeader_GetOffsetY(self.handle)
        z = core.las.LASHeader_GetOffsetZ(self.handle)
        return [x,y,z]
    def set_offset(self, value):
        """Sets the offset factors in [x, y, z] for the point data.

        Example
        -------
        
        >>> h.offset = [32, 32, 256]
        >>> h.offset
        [32.0, 32.0, 256.0]
        """
        return core.las.LASHeader_SetOffset(self.handle, value[0], value[1], value[2])
    offset = property(get_offset, set_offset)

    def get_min(self):
        """Gets the minimum values of [x, y, z] for the data.

        Example
        -------
        
        >>> h.min
        [0.0, 0.0, 0.0]
        """
        x = core.las.LASHeader_GetMinX(self.handle)
        y = core.las.LASHeader_GetMinY(self.handle)
        z = core.las.LASHeader_GetMinZ(self.handle)
        return [x,y,z]
    def set_min(self, value):
        """Sets the minimum values of [x, y, z] for the data.

        Example
        -------
        
        >>> h.min = [33452344.2333, 523442.344, -90.993]
        >>> h.min
        [33452344.2333, 523442.34399999998, -90.992999999999995]
        """
        return core.las.LASHeader_SetMin(self.handle, value[0], value[1], value[2])
    min = property(get_min, set_min)

    def get_max(self):
        x = core.las.LASHeader_GetMaxX(self.handle)
        y = core.las.LASHeader_GetMaxY(self.handle)
        z = core.las.LASHeader_GetMaxZ(self.handle)
        return [x,y,z]
    def set_max(self, value):
        """Sets the maximum values of [x, y, z] for the data.

        Example
        -------
        
        >>> h.max = [33452344.2333, 523442.344, -90.993]
        >>> h.max
        [33452344.2333, 523442.34399999998, -90.992999999999995]
        """
        return core.las.LASHeader_SetMax(self.handle, value[0], value[1], value[2])
    max = property(get_max, set_max)


    def GetVLR(self, value):
        return vlr.VLR(handle=core.las.LASHeader_GetVLR(self.handle, value))

    def DeleteVLR(self, value):
        core.las.LASHeader_DeleteVLR(self.handle, value)

    def get_srs(self):
        return srs.SRS(handle=core.las.LASHeader_GetSRS(self.handle))
    def set_srs(self, value):
        return core.las.LASHeader_SetSRS(self.handle, value.handle)
    srs = property(get_srs, set_srs)