Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
abellgithub committed Mar 5, 2018
2 parents 03bf299 + 98cba9b commit 7b70af9
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 10 deletions.
14 changes: 9 additions & 5 deletions doc/stages/filters.ferry.rst
Expand Up @@ -7,11 +7,11 @@ The ferry filter copies data from one dimension to another, creates new
dimensions or both.

The filter is guided by a list of 'from' and 'to' dimensions in the format
<from>=<to>. Data from the 'from' dimension is copied to the 'to' dimension.
<from>=><to>. Data from the 'from' dimension is copied to the 'to' dimension.
The 'from' dimension must exist. The 'to' dimension can be pre-existing or
will be created by the ferry filter.

Alternatively, the format =<to> can be used to create a new dimension without
Alternatively, the format =><to> can be used to create a new dimension without
copying data from any source. The values of the 'to' dimension are default
initialized.

Expand Down Expand Up @@ -40,7 +40,7 @@ pre-reprojection values and the post-reprojection values.
},
{
"type":"filters.ferry",
"dimensions":"X = StatePlaneX, Y=StatePlaneY"
"dimensions":"X => StatePlaneX, Y=>StatePlaneY"
},
{
"type":"filters.reprojection",
Expand Down Expand Up @@ -71,7 +71,7 @@ so that the value can be set to '2' and written as a LAS file.
},
{
"type": "filters.ferry",
"dimensions": "=Classification"
"dimensions": "=>Classification"
},
{
"type": "filters.assign",
Expand All @@ -86,6 +86,10 @@ Options

dimensions
A list of dimensions whose values should be copied.
The format of the option is <from>=<to>, <from>=<to>,... Spaces are ignored.
The format of the option is <from>=><to>, <from>=><to>,...
Spaces are ignored.
'from' can be left empty, in which case the 'to' dimension is created and
default-initialized. 'to' dimensions will be created if necessary.

Note: the old syntax that used '=' instead of '=>' between dimension names
is still supported.
6 changes: 5 additions & 1 deletion filters/FerryFilter.cpp
Expand Up @@ -64,8 +64,12 @@ void FerryFilter::initialize()
StringList s = Utils::split(dim, '=');
if (s.size() != 2)
throwError("Invalid dimension specified '" + dim + "'. Need "
"<from dimension>=<to dimension>. See documentation for "
"<from dimension>=><to dimension>. See documentation for "
"details.");
// Allow new '=>' syntax
if (s[1][0] == '>')
s[1].erase(s[1].begin());

Utils::trim(s[0]);
Utils::trim(s[1]);
if (s[0] == s[1])
Expand Down
4 changes: 4 additions & 0 deletions io/GDALWriter.cpp
Expand Up @@ -210,6 +210,10 @@ bool GDALWriter::processOne(PointRef& point)

void GDALWriter::doneFile()
{
if (!m_grid) {
throw pdal_error("Unable to write GDAL data, grid is uninitialized. You "
"might have provided the GDALWriter zero points.");
}
std::array<double, 6> pixelToPos;

pixelToPos[0] = m_curBounds.minx;
Expand Down
3 changes: 2 additions & 1 deletion scripts/ci/script.sh
Expand Up @@ -2,11 +2,12 @@
# Builds and tests PDAL

echo "http://dl-cdn.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories
echo "@edgecommunity http://dl-cdn.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories; \
apk update
apk add \
cmake \
alpine-sdk \
eigen-dev \
eigen-dev@edgecommunity \
hexer \
hexer-dev \
nitro \
Expand Down
3 changes: 2 additions & 1 deletion scripts/docker/Dockerfile
Expand Up @@ -2,12 +2,13 @@ FROM alpine:3.7

RUN \
echo "http://dl-cdn.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories; \
echo "@edgecommunity http://dl-cdn.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories; \
apk update; \
apk add --no-cache --virtual .build-deps \
alpine-sdk \
unzip \
cmake \
eigen-dev \
eigen-dev@edgecommunity \
hexer-dev \
nitro-dev \
gdal-dev \
Expand Down
4 changes: 2 additions & 2 deletions test/unit/filters/FerryFilterTest.cpp
Expand Up @@ -65,7 +65,7 @@ TEST(FerryFilterTest, stream)
r.setOptions(ro);

Options fo;
fo.add("dimensions", "X=FooX,Y=BarY");
fo.add("dimensions", "X=FooX,Y=>BarY");

FerryFilter f;
f.setOptions(fo);
Expand Down Expand Up @@ -167,7 +167,7 @@ TEST(FerryFilterTest, test_ferry_invalid)

Options op4;

op4.add("dimensions", "X = Y, X = NewZ = NewQ");
op4.add("dimensions", "X = Y, X => NewZ = NewQ");
FerryFilter f4;
f4.setInput(reader);
f4.setOptions(op4);
Expand Down
29 changes: 29 additions & 0 deletions test/unit/io/GDALWriterTest.cpp
Expand Up @@ -35,6 +35,7 @@
#include <pdal/pdal_test_main.hpp>
#include <pdal/GDALUtils.hpp>
#include <pdal/util/FileUtils.hpp>
#include <filters/RangeFilter.hpp>
#include <io/GDALWriter.hpp>
#include <io/LasReader.hpp>
#include <io/TextReader.hpp>
Expand Down Expand Up @@ -546,3 +547,31 @@ TEST(GDALWriterTest, btint)
EXPECT_NEAR(arr[i], data[i], .001);
}

TEST(GDALWriterTest, no_points)
{
std::string outfile(Support::temppath("out.tif"));
FileUtils::deleteFile(outfile);

LasReader r;
Options ro;
ro.add("filename", Support::datapath("las/no-points.las"));
r.setOptions(ro);

RangeFilter f;
f.setInput(r);
Options fo;
fo.add("limits", "Classification[2:2]");
f.setOptions(fo);

GDALWriter w;
w.setInput(f);
Options wo;
wo.add("resolution", 2);
wo.add("filename", outfile);
w.setOptions(wo);

PointTable t;
w.prepare(t);
EXPECT_THROW(w.execute(t), pdal_error);
}

0 comments on commit 7b70af9

Please sign in to comment.