[Liblas-devel] .net/mono bindings in c#

Mateusz Loskot mateusz at loskot.net
Thu Aug 7 10:47:04 EDT 2008


Martin Rodriguez wrote:
> Hi:
> 
> 
>> Fixed http://liblas.org/ticket/64
> 
> Thank you so much, but I find more bugs not only that:
> 
> LASHeader_GetCreationDOY ->LASHeader_SetCreationDOY
> LASHeader_GetCreationYear->LASHeader_SetCreationYear
> LASHeader_GetDataFormatId-> LASHeader_SetDataFormatId
> 
> LASHeader_SetScale ?????    Why not 3 setters like the 3 getters???
> LASHeader_SetOffset?????   Why not 3 setters like the 3 getters???
> LASHeader_SetMax?????   Why not 3 setters like the 3 getters???
> LASHeader_SetMin?????   Why not 3 setters like the 3 getters???

Martin,

Thanks for pointing these issues.

Hobu, as the C API is your baby, I'd prefer to leave this kind of 
decisions to you.

> In respect to macros:
> 
> Line ->	file ->	code
> 59	\include\liblas\capi\las_config.h 	#if defined(_MSC_VER) &&
> !defined(LAS_DISABLE_DLL)
> 87	\include\liblas\capi\las_config.h 	#ifdef _MSC_VER
> 92	\include\liblas\capi\las_config.h 	#if defined (_MSC_VER) 
> 259	\include\liblas\detail\utility.hpp 		#ifdef _MSC_VER
> 398	\include\liblas\detail\utility.hpp 		#ifdef _MSC_VER
> 99	\src\las_c_api.cpp 			#ifdef _MSC_VER
> 1508	\src\las_c_api.cpp 			#ifdef _MSC_VER
> 161	\include\liblas\cstdint.hpp	 	# elif defined(_MSC_VER)  

Is it enough solution to add tests for MINGW and CYGWIN to these #ifdef's ?

> In this last we have the most complicated solution because of the type
> definition. Here the visual C type are not the same like mingw. Here mingw
> use the sames types like GCC or cywin.

We have stolen integer types definition from Boost, file 
liblas/cstdint.hpp, they should be portable and no conflicts are expected.
However, these #ifdef's are definitely incomplete, regarding 
non-standard compilers for Windows, like CYGWIN or MINGW.

> I think the best is take a look to GLIB or Qt types (steal a little of
> code). They are really expert in multiplatform software. It´s almost the
> same like liblas types but I think a little more complete in compilers,
> architectures and operating systems.
> http://library.gnome.org/devel/glib/stable/glib-Basic-Types.html
> http://library.gnome.org/devel/glib/stable/glib-Byte-Order-Macros.html
> http://library.gnome.org/devel/gio/unstable/GDataOutputStream.html
> http://doc.trolltech.com/4.4/qdatastream.html
> 
> GIO+CAIRO+GDK+PANGO+GLIB+GTK+GTKGLEXT+GOBJECT+ATK+CLUTTER...=Qt
> 
> Behind GTK there real experts in computers:
> http://foundation.gnome.org/


Yes, I agree this is a good practice but the idea behind integer types 
in libLAS was to make them compatible with integer types defined in ANSI 
C99. That's why we use Boost-like defs.
IOW, those who use compilers that support ANSI C99 (like GCC) do not 
need libLAS definitions from cstdint.hpp, and it's #ifdef'ed out actually.
But if someone uses compiler without C99 support, like Microsoft Visual 
C++, then types defined in liblas/cstdint.hpp are used.

This solution makes it possible to use integer types having standard 
names (C99) from different sources (native compiler lib or external lib 
or liblas defs) without any  fixes and renaming required.

GLIB or Qt uses similar solution, but they have custom names of these 
types. Custom names would not allow users to use types from their own 
compiler lib, etc.

I hope I have explained it well.

>> If you are interested in including this work as part of libLAS, I can  
>> provide you with a svn login to allow you to commit it to the source  
>> repository.  It is a little late in our release process, but we can  
>> hold up the release to include this, as it doesn't directly affect the  
>> base library and I think others would find it very useful.
> 
> Yes. I think it´s the best. Thank you.


Welcome on board!

> Modules:
> - Reader
> - Writer
> - LASPoints
> - LAS Header
> - Exception class
> - Iterator class
> - c->C# API

Looks OK.

> TODO:
> - I need manage the .NET exceptions.
> - I need Implement the iterator interface.

Just FYI, iterators are optional interface to reader/writer for those 
who prefer STL-like approach.

> Here my hello world in .NET:
> 
> using System;
> using System.Text;
> using MonoLAS; 
> class Program 
> { 
>     static void Main(string[] args)
>     {
>         LASReader lasreader = new LASReader(@"F:\sample.las");
>         LASPoint laspoint;
>         LASHeader lasheader = lasreader.GetHeader();
>         LASWriter laswriter = new LASWriter(@"F:\sample_our.las", lasheader,
> LASReadWriteMode.LASModeWrite);
>         Console.WriteLine("Number of point in file= {0}",
> lasheader.PointRecordsCount);
>         while (lasreader.GetNextPoint())
>         {
>             laspoint = lasreader.GetPoint();
>             //Console.WriteLine(laspoint.X + "," + laspoint.Y + "," +
> laspoint.Z);
>             //laspoint.X=laspoint.X+23.2;
>             laswriter.WritePoint(laspoint); 
>         }
>         Console.WriteLine("END");
>         Console.Read();     } 
> } 

Cool!

After you submit your wrapper to the SVN, feel free to create Tutorial 
page (ie. http://liblas.org/wiki/CSharpTutorial) on the Wiki and add 
this snippet.

Best regards,
-- 
Mateusz Loskot, http://mateusz.loskot.net
Charter Member of OSGeo, http://osgeo.org



More information about the Liblas-devel mailing list