-
-
Notifications
You must be signed in to change notification settings - Fork 15
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
add Text Area Description to header reader/writer #64
add Text Area Description to header reader/writer #64
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good. Please just remove nullterminate
at two locations. Use Rcpp:as
instead.
src/readheader.cpp
Outdated
if (vlr.record_id == 3) // TextArea | ||
{ | ||
CHAR* text_area_description = (CHAR*) vlr.data; | ||
lvlr.push_back(nullterminate(text_area_description, vlr.record_length_after_header)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The standard already imposes that the string are null terminated. No need to enforce it. The nullterminate
function is only a trick to make the CRAN happy with (valid) non null terminated string (but we loose 1 character). We should not use it otherwise.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done, sorry for the iterative commit...
src/writeLAS.cpp
Outdated
CharacterVector desc = vlr["description"]; | ||
std::string sdesc = as<std::string>(desc); | ||
I32 sascii_size = sascii.size(); | ||
if ((sizeof(CHAR)*sascii_size) > U16_MAX) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Be careful if you truncate the string it must be null-terminated. You must add \0
at position U16_MAX-1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have added a null terminator to text of any length as it is not done by LASlib.
Therefore, length_after_header == nchar(vlr$text_area_description)+1
always.
Thank you. Nice to see you back |
In the current PR, I propose an implementation of the VLR Text Area Description for header reader/writer.
In writeLAS.cpp, when the data of the text area is more than 65535 characters (2^16-1), it is truncated.
By the way, I also removed an excessive indentation in readher.cpp.
I PR on master branch as I noticed that devel branch was much older.