1
/******************************************************************************
4
* Project: libLAS - http://liblas.org - A BSD library for LAS format data.
6
* Author: Martin Vales, martin_gnu@mundo-r.com
8
******************************************************************************
9
* Copyright (c) 2008, Martin Vales
11
* All rights reserved.
13
* Redistribution and use in source and binary forms, with or without
14
* modification, are permitted provided that the following
17
* * Redistributions of source code must retain the above copyright
18
* notice, this list of conditions and the following disclaimer.
19
* * Redistributions in binary form must reproduce the above copyright
20
* notice, this list of conditions and the following disclaimer in
21
* the documentation and/or other materials provided
22
* with the distribution.
23
* * Neither the name of the Martin Isenburg or Iowa Department
24
* of Natural Resources nor the names of its contributors may be
25
* used to endorse or promote products derived from this software
26
* without specific prior written permission.
28
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
29
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
30
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
31
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
32
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
33
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
34
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
35
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
36
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
37
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
38
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
40
****************************************************************************/
43
using System.Collections.Generic;
45
using LASError = System.Int32;
46
using LASWriterH = System.IntPtr;
47
using LASReaderH = System.IntPtr;
48
using LASPointH = System.IntPtr;
49
using LASGuidH = System.IntPtr;
50
using LASVLRH = System.IntPtr;
51
using LASHeaderH = System.IntPtr;
56
/// LASVariableLengthRecord class
58
public class LASVariableLengthRecord : IDisposable
60
private LASVLRH hvlrh;
63
/// The object user should call this method when they finished with the object.
67
CAPI.LASVLR_Destroy(hvlrh);
68
// Clean up unmanaged resources here.
69
// Dispose other contained disposable objects.
73
/// Default constructor.
75
public LASVariableLengthRecord()
77
hvlrh = CAPI.LASVLR_Create();
81
/// Creates a new variable length record uing the LASVLRH opaque pointer
83
/// <param name="hVlrh">LASVLRH opaque pointer</param>
84
public LASVariableLengthRecord(LASVLRH hVlrh)
89
//public override string ToString()
91
// return CAPI.LASGuid_AsString(hguid);
95
/// Get the LASVLRH opaque pointer.
97
/// <returns>LASVLRH opaque pointer </returns>
98
public LASVLRH GetPointer()
104
/// the User Id for the variable length record.
106
/// <remarks> It will be clipped to fit within 16 characters</remarks>
111
return CAPI.LASVLR_GetUserId(hvlrh);
116
LASError error = CAPI.LASVLR_SetUserId(hvlrh, value);
117
if ((Int32)error != 0)
119
LASException e = new LASException("Exception in Set VLR UserId.");
126
/// the description for the variable length record.
128
/// <remarks> It will be clipped to fit within 32 characters</remarks>
129
public string Description
133
return CAPI.LASVLR_GetDescription(hvlrh);
138
LASError error = CAPI.LASVLR_SetDescription(hvlrh, value);
139
if ((Int32)error != 0)
141
LASException e = new LASException("Exception in Set VLR Description.");
148
/// the record length of the data stored in the variable length record.
150
public UInt16 RecordLength
154
return CAPI.LASVLR_GetRecordLength(hvlrh);
159
LASError error = CAPI.LASVLR_SetRecordLength(hvlrh, value);
160
if ((Int32)error != 0)
162
LASException e = new LASException("Exception in Set VLR RecordLength.");
169
/// the record id for the variable length record.
171
public UInt16 RecordId
175
return CAPI.LASVLR_GetRecordId(hvlrh);
180
LASError error = CAPI.LASVLR_SetRecordId(hvlrh, value);
181
if ((Int32)error != 0)
183
LASException e = new LASException("Exception in Set VLR RecordId.");
190
/// the reserved value of the variable length record.
192
/// <remarks>This should be 0 and should always be 0.</remarks>
193
public UInt16 Reserved
197
return CAPI.LASVLR_GetReserved(hvlrh);
202
LASError error = CAPI.LASVLR_SetReserved(hvlrh, value);
203
if ((Int32)error != 0)
205
LASException e = new LASException("Exception in Set VLR Reserved.");
212
/// Gets the data stream for the variable length record as an array of bytes
214
/// <param name="data">a empty array of bytes where place the array</param>
215
public void GetData(out byte[] data)
217
LASError error = CAPI.LASVLR_GetData(hvlrh, out data);
218
if ((Int32)error != 0)
220
LASException e = new LASException("Exception in VLR GetData.");
226
/// Sets the data stream for the variable length record as an array of bytes
228
/// <param name="data">array of bytes</param>
229
public void SetData(ref byte[] data)
231
UInt16 lenght = (UInt16)data.Length;
232
LASError error = CAPI.LASVLR_SetData(hvlrh, ref data, lenght);
233
if ((Int32)error != 0)
235
LASException e = new LASException("Exception in VLR SetData.");