From df3c502fe4882cff79420386d858608d4b970795 Mon Sep 17 00:00:00 2001 From: Andrew Bell Date: Mon, 5 Oct 2015 10:01:19 -0500 Subject: [PATCH] Flat options for colorization. --- doc/stages/filters.colorization.rst | 46 ++--- filters/colorization/ColorizationFilter.cpp | 167 +++++++++++-------- filters/colorization/ColorizationFilter.hpp | 23 ++- include/pdal/GDALUtils.hpp | 15 -- test/unit/filters/ColorizationFilterTest.cpp | 44 +---- 5 files changed, 125 insertions(+), 170 deletions(-) diff --git a/doc/stages/filters.colorization.rst b/doc/stages/filters.colorization.rst index 64bc0be08e..35ad2adb0e 100644 --- a/doc/stages/filters.colorization.rst +++ b/doc/stages/filters.colorization.rst @@ -20,26 +20,8 @@ The bands of the raster to apply to each are selected using the "band" option, a - - - @@ -50,27 +32,19 @@ The bands of the raster to apply to each are selected using the "band" option, a - Options ------- raster The raster file to read the band from. Any format supported by `GDAL`_ may be read. -dimension - A dimension to populate with values from the raster file. There may be multiple dimension options declared. The dimension name should be supplied, and an options list indicating the raster band to read from and the scaling to apply. - - band - The raster band from which to read values for this dimension. - - scale - The scaling factor to apply to the value read from the raster. [Default: **1.0**] - -x_dim - The point dimension to use for the x dimension [Default: **X**] +dimensions + A comma separated list of dimensions to populate with values from the raster + file. The format of each dimension is ::. + Either or both of band number and scale factor may be omitted as may ':' + separators if the data is not ambiguous. If not supplied, band numbers + begin at 1 and increment from the band number of the previous dimension. + If not supplied, the scaling factor is 1.0. + [Default: "Red:1:1.0, Green:2:1.0, Blue:3:1.0"] -y_dim - The point dimension to use for the y dimension [Default: **Y**] - - .. _GDAL: http://gdal.org diff --git a/filters/colorization/ColorizationFilter.cpp b/filters/colorization/ColorizationFilter.cpp index 9bb518cc3a..57747f8776 100644 --- a/filters/colorization/ColorizationFilter.cpp +++ b/filters/colorization/ColorizationFilter.cpp @@ -65,72 +65,104 @@ Options ColorizationFilter::getDefaultOptions() { Options options; - pdal::Option red("dimension", "Red", ""); - pdal::Option b0("band",1, ""); - pdal::Option s0("scale", 1.0f, "scale factor for this dimension"); - pdal::Options redO; - redO.add(b0); - redO.add(s0); - red.setOptions(redO); - - pdal::Option green("dimension", "Green", ""); - pdal::Option b1("band",2, ""); - pdal::Option s1("scale", 1.0f, "scale factor for this dimension"); - pdal::Options greenO; - greenO.add(b1); - greenO.add(s1); - green.setOptions(greenO); - - pdal::Option blue("dimension", "Blue", ""); - pdal::Option b2("band",3, ""); - pdal::Option s2("scale", 1.0f, "scale factor for this dimension"); - pdal::Options blueO; - blueO.add(b2); - blueO.add(s2); - blue.setOptions(blueO); - - pdal::Option reproject("reproject", false, - "Reproject the input data into the same coordinate system as " - "the raster?"); - - options.add(red); - options.add(green); - options.add(blue); - options.add(reproject); + options.add("dimensions", "Red:1:1.0, Green:2:1.0, Blue:3"); return options; } +namespace +{ -void ColorizationFilter::processOptions(const Options& options) +ColorizationFilter::BandInfo parseDim(const std::string& dim, + uint32_t defaultBand) { - m_rasterFilename = options.getValueOrThrow("raster"); - std::vector