Skip to content

PCD writer binary can write bad data on Windows when using binary mode #4569

@AliT1369

Description

@AliT1369

Describe the bug
I'm using PDAL C++ API. Writing a simple pipeline to read a .las file and write it back as .pcd. Using the 'ascii' mode for compression works fine, but as soon as I use 'binary' and open the output file with CloudCompare, I see the all coordinates ranges become infinite, and if I use 'compressed', the output contains the header only (and no data), although the execution doesn't throw any errors.

pdal::PipelineManager pipelineManager;

auto& lasReader = pipelineManager.addReader("readers.las");
lasReader.setOptions(pdal::Options({ "filename", filePath }));

// Add a ferry filter to create centered X and Y dimensions
auto& ferryFilter = pipelineManager.addFilter("filters.ferry");
ferryFilter.setInput(lasReader);
ferryFilter.setOptions(pdal::Options({ "dimensions", "X => originalX,Y => originalY,=>RGB" }));

// Add an assign filter to center X and Y dimensions
auto& assignFilter = pipelineManager.addFilter("filters.assign");
assignFilter.setInput(ferryFilter);
pdal::Options assignOptions;
assignOptions.add("value", "X = originalX-637300.00");
assignOptions.add("value", "Y = originalY-851400.00");
assignOptions.add("value", "RGB = (Red * 65536 + Green * 256 + Blue)");
assignFilter.setOptions(assignOptions); //, centeredY=Y-849000.00

// Add a PCD writer
auto& pcdWriter = pipelineManager.addWriter("writers.pcd");
pcdWriter.setInput(assignFilter);
pdal::Options writerOptions;
writerOptions.add("filename", "temp_output.pcd");
writerOptions.add("order", "X,Y,Z,RGB=Unsigned32");
//writerOptions.add("compression", "binary");
writerOptions.add("compression", "compressed");
writerOptions.add("keep_unspecified", "false");
pcdWriter.setOptions(writerOptions);

// Execute the pipeline
try
{
    LOG_DEBUG("Executing pipeline...");
    pipelineManager.execute();
    LOG_DEBUG("Pipeline executed successfully.");
}
catch (const pdal::pdal_error& e)
{
    std::cerr << "PDAL error: " << e.what() << std::endl;
}

Expected behavior
Getting the same cloud as ascii.

System/installation information:
PDAL built using vcpkg, PDAL Version: 2.8.1, MS Visual Studio 2022.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions