1""" 2/****************************************************************************** 3 * $Id$ 4 * 5 * Project: libLAS - http://liblas.org - A BSD library for LAS format data. 6 * Purpose: Python VLR implementation 7 * Author: Howard Butler, hobu.inc@gmail.com 8 * 9 ****************************************************************************** 10 * Copyright (c) 2008, Howard Butler 11 * 12 * All rights reserved. 13 * 14 * Redistribution and use in source and binary forms, with or without 15 * modification, are permitted provided that the following 16 * conditions are met: 17 * 18 * * Redistributions of source code must retain the above copyright 19 * notice, this list of conditions and the following disclaimer. 20 * * Redistributions in binary form must reproduce the above copyright 21 * notice, this list of conditions and the following disclaimer in 22 * the documentation and/or other materials provided 23 * with the distribution. 24 * * Neither the name of the Martin Isenburg or Iowa Department 25 * of Natural Resources nor the names of its contributors may be 26 * used to endorse or promote products derived from this software 27 * without specific prior written permission. 28 * 29 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 30 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 31 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 32 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 33 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 34 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 35 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 36 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 37 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 38 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 39 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 40 * OF SUCH DAMAGE. 41 ****************************************************************************/ 42 """ 43import core 44import ctypes 45 46class VLR(object): 47 def __init__(self, owned=True, handle=None): 48 if handle: 49 self.handle = handle 50 else: 51 self.handle = core.las.LASVLR_Create() 52 self.owned = owned 53 def __del__(self): 54 if self.owned: 55 if self.handle and core: 56 core.las.LASVLR_Destroy(self.handle) 57 58 def get_userid(self): 59 return core.las.LASVLR_GetUserId(self.handle) 60 def set_userid(self, value): 61 return core.las.LASVLR_SetUserId(self.handle, value) 62 userid = property(get_userid, set_userid) 63 64 def get_description(self): 65 return core.las.LASVLR_GetDescription(self.handle) 66 def set_description(self, value): 67 return core.las.LASVLR_SetDescription(self.handle, value) 68 description = property(get_description, set_description) 69 70 def get_recordlength(self): 71 return core.las.LASVLR_GetRecordLength(self.handle) 72 def set_recordlength(self, value): 73 return core.las.LASVLR_SetRecordLength(self.handle, value) 74 recordlength = property(get_recordlength, set_recordlength) 75 76 def get_recordid(self): 77 return core.las.LASVLR_GetRecordId(self.handle) 78 def set_recordid(self, value): 79 return core.las.LASVLR_SetRecordId(self.handle, value) 80 recordid = property(get_recordid, set_recordid) 81 82 def get_reserved(self): 83 return core.las.LASVLR_GetReserved(self.handle) 84 def set_reserved(self, value): 85 return core.las.LASVLR_SetReserved(self.handle, value) 86 reserved = property(get_reserved, set_reserved) 87 88 def get_data(self): 89 length = self.recordlength 90 data = (ctypes.c_ubyte * length)() 91 core.las.LASVLR_GetData(self.handle, data) 92 return data 93 94 def set_data(self, data): 95 pdata = ctypes.cast(data, ctypes.POINTER(ctypes.c_ubyte)) 96 core.las.LASVLR_SetData(self.handle, pdata, self.recordlength) 97 data = property(get_data, set_data) 98 99