Changeset 901

Show
Ignore:
Timestamp:
10/06/08 03:41:13 (3 months ago)
Author:
MartinVales
Message:
 
Location:
trunk/csharp/dotnetLibLAS
Files:
8 modified

Legend:

Unmodified
Added
Removed
  • trunk/csharp/dotnetLibLAS/AssemblyInfo.cs

    r870 r901  
    3232// You can specify all the values or you can default the Revision and Build Numbers  
    3333// 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  
    6565    }; 
    6666 
    67  
     67    /// <summary> 
     68    /// LASException class 
     69    /// </summary> 
    6870    public class LASException : 
    6971        System.ApplicationException 
    7072 
    7173    { 
     74        /// <summary> 
     75        /// Default constructor 
     76        /// </summary> 
     77        /// <param name="message">string to show</param> 
    7278        public LASException(string message) 
    7379            : 
     
    7682 
    7783        } 
    78  
     84        /// <summary> 
     85        /// TODO 
     86        /// </summary> 
     87        /// <param name="value">TODO</param> 
     88        /// <returns>the string </returns> 
    7989        public static string GetString(Int32 value) 
    8090         
  • trunk/csharp/dotnetLibLAS/LASHeader.cs

    r870 r901  
    11/****************************************************************************** 
    2  
    32 *  
    4  
    53 * 
    6  
    74 * Project:  libLAS - http://liblas.org - A BSD library for LAS format data. 
    8  
    95 * Purpose:   
    10  
    116 * Author:   Martin Vales, martin_gnu@mundo-r.com 
    12  
    137 * 
    14  
    158 ****************************************************************************** 
    16  
    179 * Copyright (c) 2008, Martin Vales 
    18  
    1910 * 
    20  
    2111 * All rights reserved. 
    22  
    2312 *  
    24  
    2513 * Redistribution and use in source and binary forms, with or without  
    26  
    2714 * modification, are permitted provided that the following  
    28  
    2915 * conditions are met: 
    30  
    3116 *  
    32  
    3317 *     * Redistributions of source code must retain the above copyright  
    34  
    3518 *       notice, this list of conditions and the following disclaimer. 
    36  
    3719 *     * Redistributions in binary form must reproduce the above copyright  
    38  
    3920 *       notice, this list of conditions and the following disclaimer in  
    40  
    4121 *       the documentation and/or other materials provided  
    42  
    4322 *       with the distribution. 
    44  
    4523 *     * Neither the name of the Martin Isenburg or Iowa Department  
    46  
    4724 *       of Natural Resources nor the names of its contributors may be  
    48  
    4925 *       used to endorse or promote products derived from this software  
    50  
    5126 *       without specific prior written permission. 
    52  
    5327 *  
    54  
    5528 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS  
    56  
    5729 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT  
    58  
    5930 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS  
    60  
    6131 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE  
    62  
    6332 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,  
    64  
    6533 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,  
    66  
    6734 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS  
    68  
    6935 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED  
    70  
    7136 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,  
    72  
    7337 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT  
    74  
    7538 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY  
    76  
    7739 * OF SUCH DAMAGE. 
    78  
    7940 ****************************************************************************/ 
    8041 
    81  
    82  
    8342using System; 
    84  
    8543using System.Collections.Generic; 
    86  
    8744using System.Text; 
    88  
    8945using LASError = System.Int32; 
    90  
    9146using LASWriterH = System.IntPtr; 
    92  
    9347using LASReaderH = System.IntPtr; 
    94  
    9548using LASPointH = System.IntPtr; 
    96  
    9749using LASGuidH = System.IntPtr; 
    98  
    9950using LASVLRH = System.IntPtr; 
    100  
    10151using LASHeaderH = System.IntPtr; 
    102  
    103  
    10452 
    10553namespace LibLAS 
    10654{ 
    107  
     55    /// <summary> 
     56    /// LASHeader class 
     57    /// </summary> 
    10858    public class LASHeader : IDisposable 
    10959    { 
    11060 
    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> 
    11764        public void Dispose() 
    11865        { 
    11966 
    120  
    121  
    12267            CAPI.LASHeader_Destroy(hHeader); 
    123  
    12468            // Clean up unmanaged resources here. 
    125  
    12669            // Dispose other contained disposable objects. 
    127  
    128         } 
    129  
    130  
    131  
    132  
     70        } 
    13371 
    13472 
     
    13674        enum FormatVersion 
    13775        { 
    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  
    14784        }; 
    14885 
    149  
    150  
    15186        /// Versions of point record format. 
    152  
    15387        enum PointFormat 
    15488        { 
    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   
    16093        }; 
    16194 
    162  
    163  
    16495        /// Number of bytes of point record storage in particular format. 
    165  
    16696        enum PointSize 
    16797        { 
    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   
    173102        }; 
    174103 
    175104 
    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; 
    197113 
    198114 
    199115        private LASHeaderH hHeader; 
    200116 
    201  
    202  
     117        /// <summary> 
     118        /// gets the opaque pointer to the LASHeaderH instance. 
     119        /// </summary> 
     120        /// <returns>opaque pointer to the LASHeaderH instance.</returns> 
    203121        public LASHeaderH GetPointer() 
    204122        { 
    205  
    206123            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> 
    229140        public LASHeader() 
    230141        { 
    231  
    232142            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> 
    238150        public LASHeader Copy() 
    239151        { 
    240  
    241152            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> 
    247159        public void Destroy() 
    248160        { 
    249  
    250161            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> 
    292191        public string FileSignature 
    293192        { 
    294  
    295             get 
    296             { 
    297  
     193            get 
     194            { 
    298195                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> 
    316204        public UInt16 FileSourceId 
    317205        { 
    318  
    319             get 
    320             { 
    321  
     206            get 
     207            { 
    322208                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> 
    342228        public Int16 Reserved 
    343229        { 
    344  
    345             get 
    346             { 
    347  
     230            get 
     231            { 
    348232                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> 
    370242        public String ProjectId 
    371243        { 
    372  
    373             get 
    374             { 
    375  
     244            get 
     245            { 
    376246                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> 
    400256        public byte VersionMajor 
    401257        { 
    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            { 
    410260                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            { 
    424264 
    425265                LASError error = CAPI.LASHeader_SetVersionMajor(hHeader, value); 
    426  
    427266                if ((Int32)error != 0) 
    428267                { 
    429268                    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> 
    446280        public byte VersionMinor 
    447281        { 
    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            { 
    455284 
    456285                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            { 
    468289 
    469290                LASError error = CAPI.LASHeader_SetVersionMinor(hHeader, value); 
    470  
    471291                if ((Int32)error != 0) 
    472292                { 
    473293                    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> 
    484303        public String SystemId 
    485304        { 
    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