1
/******************************************************************************
4
* Project: libLAS - http://liblas.org - A BSD library for LAS format data.
5
* Purpose: Test cases of LASWriter class, .NET/Mono bindings
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 NUnit.Framework;
51
public class LASWriterTest
54
protected void SetUp()
59
public void CopyConstructor()
61
LASHeader header = new LASHeader();
62
//string sig = "LASF and garbage";
64
// header.FileSignature = sig;
65
// Assert.AreEqual(header.FileSignature.Length,4);
67
Assert.AreEqual(1, 1);
68
//h1.SetFileSignature(sig);
69
//ensure_not(h1.GetFileSignature() == sig);
70
//ensure_equals(h1.GetFileSignature().size(), 4);
71
//ensure_equals(h1.GetFileSignature(), LASHeader::FileSignature);
74
//ensure_not(h2.GetFileSignature() == sig);
75
//ensure_equals(h2.GetFileSignature().size(), 4);
76
//ensure_equals(h2.GetFileSignature(), LASHeader::FileSignature);
80
public void FileSignature()
82
LASHeader header = new LASHeader();
83
// string sig = "LASF and garbage";
85
Assert.AreEqual(header.FileSignature.Length, 4);
86
Assert.AreEqual(header.FileSignature, "LASF");
88
// I can not set FileSignature from c# API because i am a bad guy.
89
//header.FileSignature = "LASF";
93
public void FileSourceId()
95
LASHeader h1 = new LASHeader();
99
UInt16 overflowed = 0;
101
h1.FileSourceId = id1;
102
Assert.AreEqual(h1.FileSourceId, id1);
103
h1.FileSourceId = id2;
104
Assert.AreEqual(h1.FileSourceId, id2);
107
// Likely compiler warning: truncation from int to liblas::uint16_t
108
h1.FileSourceId = (ushort)(id2 + 1);
109
Assert.AreEqual(h1.FileSourceId, overflowed);
113
public void Reserved()
115
LASHeader h = new LASHeader();
117
Assert.AreEqual(h.Reserved, 0);
121
public void ProjectId()
123
LASHeader h = new LASHeader();
125
//string strid="030B4A82-1B7C-11CF-9D53-00AA003C9CB6";
126
// Assert.AreEqual(h.Reserved, 0);
127
// liblas::guid id(strid.c_str());
129
// std::string strid("030B4A82-1B7C-11CF-9D53-00AA003C9CB6");
130
//liblas::guid id(strid.c_str());
132
//liblas::LASHeader h;
133
//h.SetProjectId(id);
134
//ensure_not(h.GetProjectId().is_null());
135
//ensure_equals(h.GetProjectId(), id);
139
public void MinorMajorVersion()
141
LASHeader h = new LASHeader();
144
Assert.AreEqual(h.VersionMinor, 0);
145
Assert.AreEqual(h.VersionMajor, 1);
149
Assert.AreEqual(h.VersionMinor, 1);
150
Assert.AreEqual(h.VersionMajor, 1);
155
//don�t get the next line...
156
Assert.AreEqual(2, 5);
158
catch (LASException e)
160
Assert.AreEqual(e.Message, "Exception in Set Header VersionMajor.");
166
//don�t get the next line...
167
Assert.AreEqual(2, 5);
169
catch (LASException e)
171
Assert.AreEqual(e.Message, "Exception in Set Header VersionMinor.");
176
public void SoftwareId()
178
LASHeader h = new LASHeader();
180
string softid1 = "Short Soft Id"; // 13 bytes
181
int len1 = softid1.Length;
182
string softid2 = "Long Software Identifier - XX YY"; // 32 bytes
183
int len2 = softid2.Length;
185
h.SoftwareId = softid1;
186
Assert.AreEqual(h.SoftwareId, softid1);
187
Assert.AreEqual(h.SoftwareId.Length, len1);
188
// Assert.AreEqual(h.GetSoftwareId(true).size(), 32);
190
h.SoftwareId = softid2;
191
Assert.AreEqual(h.SoftwareId, softid2);
192
Assert.AreEqual(h.SoftwareId.Length, len2);
193
// Assert.AreEqual(h.GetSoftwareId(true).size(), 32);
197
public void PointRecordsByReturnCount()
199
LASHeader h = new LASHeader();
200
// Assert.AreEqual(h.GetPointRecordsByReturnCount(5),5);
202
h.SetPointRecordsByReturnCount(0, 100);
203
//ensure_equals(h.GetPointRecordsByReturnCount().size(), 5);
204
Assert.AreEqual(h.GetPointRecordsByReturnCount(0), 100);
206
h.SetPointRecordsByReturnCount(1, 101);
207
//ensure_equals(h.GetPointRecordsByReturnCount().size(), 5);
208
Assert.AreEqual(h.GetPointRecordsByReturnCount(1), 101);
210
h.SetPointRecordsByReturnCount(2, 102);
211
//ensure_equals(h.GetPointRecordsByReturnCount().size(), 5);
212
Assert.AreEqual(h.GetPointRecordsByReturnCount(2), 102);
214
h.SetPointRecordsByReturnCount(3, 103);
215
//ensure_equals(h.GetPointRecordsByReturnCount().size(), 5);
216
Assert.AreEqual(h.GetPointRecordsByReturnCount(3), 103);
218
h.SetPointRecordsByReturnCount(4, 104);
219
//ensure_equals(h.GetPointRecordsByReturnCount().size(), 5);
220
Assert.AreEqual(h.GetPointRecordsByReturnCount(4), 104);
225
h.SetPointRecordsByReturnCount(5, 500);
226
//don�t get the next line...
227
Assert.AreEqual(2, 5);
229
catch (LASException e)
231
Assert.AreEqual(e.Message, "Exception in Set Header SetPointRecordsByReturnCount.");