Skip to content

Commit

Permalink
Fix #2937 to support writers.las assignment of VLRs
Browse files Browse the repository at this point in the history
  • Loading branch information
hobu committed Feb 20, 2020
1 parent b40acc7 commit 57abd25
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
4 changes: 2 additions & 2 deletions doc/stages/writers.las.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ containing `user_id` and `data` items.
},
{
"type":"writers.las",
"vlrs": [{
"vlrs": {"json":[{
"description": "A description under 32 bytes",
"record_id": 42,
"user_id": "hobu",
Expand All @@ -41,7 +41,7 @@ containing `user_id` and `data` items.
"record_id": 43,
"user_id": "hobu",
"data": "dGhpcyBpcyBzb21lIG1vcmUgdGV4dA=="
}],
}]},
"filename":"outputfile.las"
}
]
Expand Down
6 changes: 5 additions & 1 deletion io/LasWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,11 @@ void LasWriter::prepared(PointTableRef table)
// Capture user-specified VLRs
void LasWriter::addUserVlrs()
{
for (const auto& v : *m_userVLRs)
NL::json* p_vlrs = m_userVLRs.get();
if (!(*p_vlrs).contains("json"))
throwError("VLR JSON object containing list of VLR entries must be at 'json' node");
NL::json vlrs = (*p_vlrs)["json"];
for (const auto& v : vlrs)
{
uint16_t recordId(1);
std::string userId("");
Expand Down
2 changes: 1 addition & 1 deletion test/unit/io/LasWriterTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1151,7 +1151,7 @@ TEST(LasWriterTest, pdal_add_vlr)
Options readerOpts;
readerOpts.add("filename", infile);

std::string vlr( " [ { \"description\": \"A description under 32 bytes\", \"record_id\": 42, \"user_id\": \"hobu\", \"data\": \"dGhpcyBpcyBzb21lIHRleHQ=\" }, { \"description\": \"A description under 32 bytes\", \"record_id\": 43, \"user_id\": \"hobu\", \"data\": \"dGhpcyBpcyBzb21lIG1vcmUgdGV4dA==\" } ]");
std::string vlr( "{\"json\": [ { \"description\": \"A description under 32 bytes\", \"record_id\": 42, \"user_id\": \"hobu\", \"data\": \"dGhpcyBpcyBzb21lIHRleHQ=\" }, { \"description\": \"A description under 32 bytes\", \"record_id\": 43, \"user_id\": \"hobu\", \"data\": \"dGhpcyBpcyBzb21lIG1vcmUgdGV4dA==\" } ]}");

Options writerOpts;
writerOpts.add("vlrs", vlr);
Expand Down

0 comments on commit 57abd25

Please sign in to comment.