Skip to content

Commit

Permalink
Change compression for writers.pcd
Browse files Browse the repository at this point in the history
Option writers.pcd.compression is now a string rather than a flag.
Possible options are "ascii", "binary", "compressed". Default is "ascii".
Option writers.pcd.binary is removed for redundancy.

This addresses upgrades in PDAL#1206
  • Loading branch information
Logan Byers committed Aug 24, 2016
1 parent b74cd64 commit 473d495
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 16 deletions.
20 changes: 16 additions & 4 deletions plugins/pcl/io/PcdWriter.cpp
Expand Up @@ -61,15 +61,28 @@ std::string PcdWriter::getName() const { return s_info.name; }
void PcdWriter::processOptions(const Options& ops)
{
m_filename = ops.getValueOrThrow<std::string>("filename");
m_binary = ops.getValueOrDefault("binary", false);
m_compressed = ops.getValueOrDefault("compression", false);
std::string compression = ops.getValueOrDefault("compression", "ascii");
m_xyz = ops.getValueOrDefault("xyz", false);
m_offset_x = ops.getValueOrDefault("offset_x", 0.0);
m_offset_y = ops.getValueOrDefault("offset_y", 0.0);
m_offset_z = ops.getValueOrDefault("offset_z", 0.0);
m_scale_x = ops.getValueOrDefault("scale_x", 1.0);
m_scale_y = ops.getValueOrDefault("scale_y", 1.0);
m_scale_z = ops.getValueOrDefault("scale_z", 1.0);

if (compression == "binary")
{
m_compression = 1;
}
else if (compression == "compressed")
{
m_compression = 2;
}
else // including "ascii"
{
m_compression = 0;
}

if (m_scale_x == 0.0)
{
m_scale_x = 1.0;
Expand All @@ -89,8 +102,7 @@ Options PcdWriter::getDefaultOptions()
Options options;

options.add("filename", "", "Filename to write PCD file to");
options.add("binary", false, "Write binary data?");
options.add("compression", false, "Write binary compressed data?");
options.add("compression", "ascii", "Level of PCD compression to use (ascii, binary, compressed)");
options.add("xyz", false, "Write only XYZ dimensions?");
options.add("offset_x", 0.0, "Offset to be subtracted from XYZ position");
options.add("offset_y", 0.0, "Offset to be subtracted from XYZ position");
Expand Down
17 changes: 5 additions & 12 deletions plugins/pcl/io/PcdWriter.hpp
Expand Up @@ -69,8 +69,7 @@ class PDAL_DLL PcdWriter : public Writer
inline void writeView(const PointViewPtr view); // implemented in header

std::string m_filename;
bool m_compressed;
bool m_binary;
uint8_t m_compression;
bool m_xyz;
double m_offset_x;
double m_offset_y;
Expand All @@ -93,17 +92,11 @@ void PcdWriter::writeView(const PointViewPtr view)
bounds.grow(m_offset_x, m_offset_y, m_offset_z);
pclsupport::PDALtoPCD(view, *cloud, bounds, m_scale_x, m_scale_y, m_scale_z);
pcl::PCDWriter w;
if (m_compressed)
switch (m_compression)
{
w.writeBinaryCompressed<PointT>(m_filename, *cloud);
}
else if (m_binary)
{
w.writeBinary<PointT>(m_filename, *cloud);
}
else
{
w.writeASCII<PointT>(m_filename, *cloud);
case 0 : w.writeASCII<PointT>(m_filename, *cloud); break;
case 1 : w.writeBinary<PointT>(m_filename, *cloud); break;
case 2 : w.writeBinaryCompressed<PointT>(m_filename, *cloud); break;
}
}

Expand Down

0 comments on commit 473d495

Please sign in to comment.