Changeset 901
- Timestamp:
- 10/06/08 03:41:13 (3 months ago)
- Location:
- trunk/csharp/dotnetLibLAS
- Files:
-
- 8 modified
-
AssemblyInfo.cs (modified) (1 diff)
-
LASException.cs (modified) (2 diffs)
-
LASHeader.cs (modified) (3 diffs)
-
LASPoint.cs (modified) (16 diffs)
-
LASReader.cs (modified) (6 diffs)
-
LASWriter.cs (modified) (4 diffs)
-
LibLASCAPI.cs (modified) (8 diffs)
-
dotnetLibLAS.csproj (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/csharp/dotnetLibLAS/AssemblyInfo.cs
r870 r901 32 32 // You can specify all the values or you can default the Revision and Build Numbers 33 33 // by using the '*' as shown below: 34 [assembly: AssemblyVersion("0. 2.0.0")]35 [assembly: AssemblyFileVersion("0. 2.0.0")]34 [assembly: AssemblyVersion("0.3.0.0")] 35 [assembly: AssemblyFileVersion("0.3.0.0")] -
trunk/csharp/dotnetLibLAS/LASException.cs
r870 r901 65 65 }; 66 66 67 67 /// <summary> 68 /// LASException class 69 /// </summary> 68 70 public class LASException : 69 71 System.ApplicationException 70 72 71 73 { 74 /// <summary> 75 /// Default constructor 76 /// </summary> 77 /// <param name="message">string to show</param> 72 78 public LASException(string message) 73 79 : … … 76 82 77 83 } 78 84 /// <summary> 85 /// TODO 86 /// </summary> 87 /// <param name="value">TODO</param> 88 /// <returns>the string </returns> 79 89 public static string GetString(Int32 value) 80 90 -
trunk/csharp/dotnetLibLAS/LASHeader.cs
r870 r901 1 1 /****************************************************************************** 2 3 2 * 4 5 3 * 6 7 4 * Project: libLAS - http://liblas.org - A BSD library for LAS format data. 8 9 5 * Purpose: 10 11 6 * Author: Martin Vales, martin_gnu@mundo-r.com 12 13 7 * 14 15 8 ****************************************************************************** 16 17 9 * Copyright (c) 2008, Martin Vales 18 19 10 * 20 21 11 * All rights reserved. 22 23 12 * 24 25 13 * Redistribution and use in source and binary forms, with or without 26 27 14 * modification, are permitted provided that the following 28 29 15 * conditions are met: 30 31 16 * 32 33 17 * * Redistributions of source code must retain the above copyright 34 35 18 * notice, this list of conditions and the following disclaimer. 36 37 19 * * Redistributions in binary form must reproduce the above copyright 38 39 20 * notice, this list of conditions and the following disclaimer in 40 41 21 * the documentation and/or other materials provided 42 43 22 * with the distribution. 44 45 23 * * Neither the name of the Martin Isenburg or Iowa Department 46 47 24 * of Natural Resources nor the names of its contributors may be 48 49 25 * used to endorse or promote products derived from this software 50 51 26 * without specific prior written permission. 52 53 27 * 54 55 28 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 56 57 29 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 58 59 30 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 60 61 31 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 62 63 32 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 64 65 33 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 66 67 34 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 68 69 35 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 70 71 36 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 72 73 37 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 74 75 38 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 76 77 39 * OF SUCH DAMAGE. 78 79 40 ****************************************************************************/ 80 41 81 82 83 42 using System; 84 85 43 using System.Collections.Generic; 86 87 44 using System.Text; 88 89 45 using LASError = System.Int32; 90 91 46 using LASWriterH = System.IntPtr; 92 93 47 using LASReaderH = System.IntPtr; 94 95 48 using LASPointH = System.IntPtr; 96 97 49 using LASGuidH = System.IntPtr; 98 99 50 using LASVLRH = System.IntPtr; 100 101 51 using LASHeaderH = System.IntPtr; 102 103 104 52 105 53 namespace LibLAS 106 54 { 107 55 /// <summary> 56 /// LASHeader class 57 /// </summary> 108 58 public class LASHeader : IDisposable 109 59 { 110 60 111 112 113 // The object user should call this method 114 115 // when they finished with the object. 116 61 /// <summary> 62 /// The object user should call this method when they finished with the object. In .NET is magaged by the GC. 63 /// </summary> 117 64 public void Dispose() 118 65 { 119 66 120 121 122 67 CAPI.LASHeader_Destroy(hHeader); 123 124 68 // Clean up unmanaged resources here. 125 126 69 // Dispose other contained disposable objects. 127 128 } 129 130 131 132 70 } 133 71 134 72 … … 136 74 enum FormatVersion 137 75 { 138 139 eVersionMajorMin = 1, ///< Minimum of major component 140 141 eVersionMajorMax = 1, ///< Maximum of major component 142 143 eVersionMinorMin = 0, ///< Minimum of minor component 144 145 eVersionMinorMax = 1 ///< Maximum of minor component 146 76 /// Minimum of major component 77 eVersionMajorMin = 1, 78 ///Maximum of major component 79 eVersionMajorMax = 1, 80 /// Minimum of minor component 81 eVersionMinorMin = 0, 82 /// Maximum of minor component 83 eVersionMinorMax = 1 147 84 }; 148 85 149 150 151 86 /// Versions of point record format. 152 153 87 enum PointFormat 154 88 { 155 156 ePointFormat0 = 0, ///< Point Data Format \e 0 157 158 ePointFormat1 = 1 ///< Point Data Format \e 1 159 89 ///Point Data Format \e 0 90 ePointFormat0 = 0, 91 /// Point Data Format \e 1 92 ePointFormat1 = 1 160 93 }; 161 94 162 163 164 95 /// Number of bytes of point record storage in particular format. 165 166 96 enum PointSize 167 97 { 168 169 ePointSize0 = 20, ///< Size of point record in data format \e 0 170 171 ePointSize1 = 28 ///< Size of point record in data format \e 1 172 98 ///Size of point record in data format \e 0 99 ePointSize0 = 20, 100 /// Size of point record in data format \e 1 101 ePointSize1 = 28 173 102 }; 174 103 175 104 176 177 178 179 // Official signature of ASPRS LAS file format, always \b "LASF". 180 181 public static readonly string FileSignature_; 182 183 184 185 // Default system identifier used by libLAS, always \b "libLAS". 186 187 public static readonly string SystemIdentifier; 188 189 190 191 //Default software identifier used by libLAS, always \b "libLAS X.Y". 192 193 public static readonly string SoftwareIdentifier; 194 195 196 105 //// Official signature of ASPRS LAS file format, always \b "LASF". 106 //public static readonly string FileSignature_; 107 108 //// Default system identifier used by libLAS, always \b "libLAS". 109 //public static readonly string SystemIdentifier; 110 111 ////Default software identifier used by libLAS, always \b "libLAS X.Y". 112 //public static readonly string SoftwareIdentifier; 197 113 198 114 199 115 private LASHeaderH hHeader; 200 116 201 202 117 /// <summary> 118 /// gets the opaque pointer to the LASHeaderH instance. 119 /// </summary> 120 /// <returns>opaque pointer to the LASHeaderH instance.</returns> 203 121 public LASHeaderH GetPointer() 204 122 { 205 206 123 return hHeader; 207 208 } 209 210 211 212 //Default constructor. 213 214 //The default constructed header is configured according to the ASPRS 215 216 //LAS 1.1 Specification, point data format set to 0. 217 218 //Other fields filled with 0. 219 220 public LASHeader(LASHeaderH hHeader_) 221 { 222 223 hHeader = hHeader_; 224 225 } 226 227 228 124 } 125 126 127 /// <summary> 128 /// LASHeader constructor using the LASHeaderH opaque pointer. 129 /// </summary> 130 /// <param name="hLASHeader"></param> 131 public LASHeader(LASHeaderH hLASHeader) 132 { 133 hHeader = hLASHeader; 134 } 135 136 /// <summary> 137 /// Default constructor. 138 /// </summary> 139 /// <remarks>The default constructed header is configured according to the ASPRS LAS 1.1 Specification, point data format set to 0. Other fields filled with 0.</remarks> 229 140 public LASHeader() 230 141 { 231 232 142 hHeader = CAPI.LASHeader_Create(); 233 234 } 235 236 237 143 } 144 145 146 /// <summary> 147 /// Copy the LASHeader in a new instance 148 /// </summary> 149 /// <returns>new LASHeader instance.</returns> 238 150 public LASHeader Copy() 239 151 { 240 241 152 return new LASHeader(CAPI.LASHeader_Copy(hHeader)); 242 243 } 244 245 246 153 } 154 155 /// <summary> 156 /// Destroy the unmanaged resources to the instance. 157 /// </summary> 158 /// <remarks>The user could call this method when they finished with the object.</remarks> 247 159 public void Destroy() 248 160 { 249 250 161 CAPI.LASHeader_Destroy(hHeader); 251 252 } 253 254 255 256 // /// Assignment operator. 257 258 // LASHeader& operator=(LASHeader const& rhs); 259 260 261 262 // /// Comparison operator. 263 264 // bool operator==(const LASHeader& other) const; 265 266 267 268 269 270 271 272 273 274 //Set ASPRS LAS file signature. 275 276 //The only value allowed as file signature is \b "LASF", 277 278 //defined as FileSignature constant. 279 280 //\exception std::invalid_argument - if invalid signature given. 281 282 //\param v - string contains file signature, at least 4-bytes long 283 284 //with "LASF" as first four bytes. 285 286 287 288 //Get ASPRS LAS file signature. 289 290 //\return 4-characters long string - \b "LASF". 291 162 } 163 164 /// <summary> 165 /// Comparison overload to the LASHeader 166 /// </summary> 167 /// <param name="lasHeader1">LASHeader instance to be compared</param> 168 /// <param name="lasHeader2">LASHeader instance to be compared</param> 169 /// <returns>true if lasHeader1==lasHeader2</returns> 170 public static bool operator ==(LASHeader lasHeader1, LASHeader lasHeader2) 171 { 172 return lasHeader1.Equals(lasHeader2); 173 } 174 175 /// <summary> 176 /// Comparison overload to the LASHeader 177 /// </summary> 178 /// <param name="lasHeader1">LASHeader instance to be compared</param> 179 /// <param name="lasHeader2">LASHeader instance to be compared</param> 180 /// <returns></returns> 181 public static bool operator !=(LASHeader lasHeader1, LASHeader lasHeader2) 182 { 183 return !(lasHeader1 == lasHeader2); 184 } 185 186 187 /// <summary> 188 /// Get ASPRS LAS file signature. 189 /// </summary> 190 /// <remarks>The only value allowed as file signature is "LASF",</remarks> 292 191 public string FileSignature 293 192 { 294 295 get 296 { 297 193 get 194 { 298 195 return CAPI.LASHeader_GetFileSignature(hHeader); 299 300 } 301 302 } 303 304 305 306 //Get file source identifier. 307 308 //\exception No throw 309 310 // /// Set file source identifier. 311 312 // /// \param v - should be set to a value between 1 and 65535. 313 314 // /// \exception No throw 315 196 } 197 } 198 199 200 /// <summary> 201 /// file source identifier. 202 /// </summary> 203 /// <remarks> should be set to a value between 1 and 65535.</remarks> 316 204 public UInt16 FileSourceId 317 205 { 318 319 get 320 { 321 206 get 207 { 322 208 return CAPI.LASHeader_GetFileSourceId(hHeader); 323 324 }325 326 327 328 }329 330 331 332 333 334 335 336 // /// Get value field reserved by the ASPRS LAS Specification.337 338 // /// \note This field is always filled with 0.339 340 341 209 } 210 set 211 { 212 213 LASError error = CAPI.LASHeader_SetFileSourceId(hHeader, value); 214 if ((Int32)error != 0) 215 { 216 LASException e = new LASException("Exception in Set Header SetFileSourceId."); 217 throw e; 218 } 219 220 } 221 222 } 223 224 /// <summary> 225 /// Get value field reserved by the ASPRS LAS Specification. 226 /// </summary> 227 /// <remarks>This field is always filled with 0.</remarks> 342 228 public Int16 Reserved 343 229 { 344 345 get 346 { 347 230 get 231 { 348 232 return CAPI.LASHeader_GetReserved(hHeader); 349 350 } 351 352 //set 353 354 //{ 355 356 357 358 //} 359 360 } 361 362 363 364 365 366 //Get project identifier. 367 368 //\return Global Unique Identifier as an instance of liblas::guid class. 369 233 } 234 235 } 236 237 238 /// <summary> 239 /// Get project identifier. 240 /// </summary> 241 /// <remarks>return Global Unique Identifier.</remarks> 370 242 public String ProjectId 371 243 { 372 373 get 374 { 375 244 get 245 { 376 246 return CAPI.LASHeader_GetProjectId(hHeader); 377 378 } 379 380 //set 381 382 //{ 383 384 // // void SetProjectId(guid const& v); 385 386 // //status = value; 387 388 //} 389 390 } 391 392 393 394 395 396 397 398 399 247 } 248 } 249 250 251 252 /// <summary> 253 /// major component of version of LAS format. 254 /// </summary> 255 /// <remarks>Always 1 as the only valid value. value between eVersionMajorMin and eVersionMajorMax (always 1).</remarks> 400 256 public byte VersionMajor 401 257 { 402 403 get 404 { 405 406 //Get major component of version of LAS format. 407 408 //\return Always 1 is returned as the only valid value. 409 258 get 259 { 410 260 return CAPI.LASHeader_GetVersionMajor(hHeader); 411 412 } 413 414 set 415 { 416 417 418 419 //Set major component of version of LAS format. 420 421 //\exception std::out_of_range - invalid value given. 422 423 //\param v - value between eVersionMajorMin and eVersionMajorMax. 261 } 262 set 263 { 424 264 425 265 LASError error = CAPI.LASHeader_SetVersionMajor(hHeader, value); 426 427 266 if ((Int32)error != 0) 428 267 { 429 268 LASException e = new LASException("Exception in Set Header VersionMajor."); 430 431 throw e; 432 } 433 434 435 436 } 437 438 } 439 440 441 442 443 444 445 269 throw e; 270 } 271 272 } 273 } 274 275 276 /// <summary> 277 /// minor component of version of LAS format. 278 /// </summary> 279 /// <remarks>Valid values are 1 or 0. value between eVersionMinorMin and eVersionMinorMax.</remarks> 446 280 public byte VersionMinor 447 281 { 448 449 get 450 { 451 452 //Get minor component of version of LAS format. 453 454 //\return Valid values are 1 or 0. 282 get 283 { 455 284 456 285 return CAPI.LASHeader_GetVersionMinor(hHeader); 457 458 } 459 460 set 461 { 462 463 //Set minor component of version of LAS format. 464 465 //\exception std::out_of_range - invalid value given. 466 467 //\param v - value between eVersionMinorMin and eVersionMinorMax. 286 } 287 set 288 { 468 289 469 290 LASError error = CAPI.LASHeader_SetVersionMinor(hHeader, value); 470 471 291 if ((Int32)error != 0) 472 292 { 473 293 LASException e = new LASException("Exception in Set Header VersionMinor."); 474 475 throw e; 476 } 477 478 } 479 480 } 481 482 483 294 throw e; 295 } 296 } 297 } 298 299 /// <summary> 300 /// system identifier 301 /// </summary> 302 /// <remarks>Default value is "libLAS" specified as the SystemIdentifier constant. string is padded right with spaces and its length is 32 bytes.</remarks> 484 303 public String SystemId 485 304 { 486 487 get 488 { 489 490 //Get system identifier. 491 492 //Default value is \b "libLAS" specified as the SystemIdentifier constant. 493 494 //\param pad - if true the returned string is padded right with spaces and
