Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem detected writing LAZ files using LazZip.Net #4

Closed
twdotson opened this issue Feb 21, 2017 · 8 comments
Closed

Problem detected writing LAZ files using LazZip.Net #4

twdotson opened this issue Feb 21, 2017 · 8 comments

Comments

@twdotson
Copy link

In file laszip_dll.cs, Line 176 ...

Array.Copy(Encoding.ASCII.GetBytes(string.Format("LASzip DLL {0}.{1} r{2} ({3})", LASzip.VERSION_MAJOR, LASzip.VERSION_MINOR, LASzip.VERSION_REVISION, LASzip.VERSION_BUILD_DATE)), header.generating_software, 32);

... generates a first chance exception of type 'System.ArgumentException' occurred in mscorlib.dll.
https://msdn.microsoft.com/en-us/library/z50k9bft(v=vs.110).aspx

It looks like the designation of 32 exceeds the string length, which is 26. It appears that adding ".PadRight(32)" after the ... BUILD_DATE) corrects the problem. There are a few other places in the code, search for "LASzip DLL {0}" that will likely have this same problem.

Also, are you aware of the 1.4 version of Martin Isenburgs LasZip is pending and that could affect the ability of this code to read LAZ files in the future.

http://rapidlasso.com/2017/02/13/prototype-for-native-las-1-4-extension-of-laszip-lidar-compressor-released/

If you are able to continue this project, I think (after discussing it with Martin) that he would like to make the Lidar community more aware of your port. Note that we can provide some simple test code for read/write if you like.

@shintadono
Copy link
Owner

Thanks for pointing out the issue. I hope I caught all the wrong calls. Please notify me again, if not.

Also, thanks for alterting me to the upcoming 1.4 support in LasZip. I wasn't aware of that. I almost thought this would never happen...

I think I really need to do some catching up to the changes made in LasZip, and I would welcome more awarness to this port. And some test code (which could also be referenced as usage example) would be great.

@twdotson
Copy link
Author

Thanks for the quick fix! I will be doing more testing and will polish the test code and post it.

Note that a quick test of this library on one file provided by Martin from ...
http://www.cs.unc.edu/~isenburg/lastools/las14/
... seemed to read properly. Perhaps there are new properties that are not available but it appears usable as it is. Hopefully we will see announcement of the library at the "LAS Room".
https://groups.google.com/d/forum/lasroom
I really believe this will be one more step toward adoption of LAZ as a common file format.

BTW, could you confirm that we will be allowed to use this managed library in our small commercial application, provided we include the contents of ...
https://github.com/shintadono/laszip.net/blob/master/README.md
... in our documentation?

@shintadono
Copy link
Owner

That is the beauty of the 'Lesser General Public License (LGPL)'. It allows you to use the software/library, even in non-free applications and commercial ones. But if you want/need to make changes to it, you are legally bound to do(publish) these changes as free software under the same or an even more free license (which would be the GPL).

I would have made the library with a MIT or similar license, but since the original (laszip in C/C++) is under LGPL, and much of the code is just a reformating or fractoring of the original code, if thought changing the license could be a bit much.

@shintadono
Copy link
Owner

Oh, and I almost forgot: I don't require the copyright and license notice to be present in a software using the library. A mention somewhere (e.g. About window) would be nice though. (I don't know about what Martin would want as a mention as originator of the base code and LAZ file format.)

@twdotson
Copy link
Author

Attached is a ZIP file containing two RTF files (VB & C#) of a candidate for a usage example. The code writes a LAZ file with two points then reads it back.

Keep in mind that the original was done in VB.NET and the C# was converted with the Telerik Converter and has not been verified. Feel free to modify them as desired.

TestLas.zip

@rapidlasso
Copy link

Hello @shintadono,

I did not know about this port until @twdotson pointed it out to me. Is the library now able to fully read the current LAS and LAZ format (up to LAS version 1.3 and likely also LAS 1.4 when only the old point types are used)? That would be something useful to share in the "LAS room" [1] or the "LAStools user forum" [2]:

http://groups.google.com/group/lasroom
http://groups.google.com/group/lastools

@twdotson
Copy link
Author

From my first post, shouldn't "LASzip DLL {0}" be changed to "LASzip NET {0}" and perhaps header.generating_software be made private? That way if there is ever an inconsistency with a file created it can be distinguished from the original library and it will be clear which DLL needs revisions?

@shintadono
Copy link
Owner

@twdotson Thanks for the examples. Exactly what was needed. And, good point with the generating software string. l'll change that to include the name of the assembly. As for the privatization of generating_software - it is public because it is public in laszip. The user is allowed to change the value (the content of the array) after the initialization with laszip_clean(). I guess the variable (the reference to the array instance) should be readonly, while the array content should be mutable. I'll check what I can do...

@rapidlasso The port was based on version 2.2 (2014-09-07), and I haven't done much since then. So I quess the library can only do, what that version could do. (Minus writing version 1 LAS files, as stated in the readme.md file). I'll try to catch up we the changes made since then, but that might take a while.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants