Skip to content

Commit

Permalink
predicates working
Browse files Browse the repository at this point in the history
  • Loading branch information
mpgerlek committed Mar 14, 2012
1 parent 9b33795 commit 9275e41
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 42 deletions.
47 changes: 10 additions & 37 deletions src/filters/Predicate.cpp
Expand Up @@ -96,7 +96,7 @@ boost::uint32_t Predicate::processBuffer(PointBuffer& srcData, PointBuffer& dstD
{
if (mask[srcIndex])
{
memcpy(src, dst, numBytes);
memcpy(dst, src, numBytes);
dst += numBytes;
++count;
}
Expand All @@ -105,40 +105,9 @@ boost::uint32_t Predicate::processBuffer(PointBuffer& srcData, PointBuffer& dstD

dstData.setNumPoints(count);

//boost::uint32_t dstIndex = dstData.getNumPoints();
//boost::uint32_t numPointsAdded = 0;

//Dimension const& dimX = schema.getDimension("X");
//Dimension const& dimY = schema.getDimension("Y");
//Dimension const& dimZ = schema.getDimension("Z");
//Dimension const& dimTime = schema.getDimension("Time");

//{
// const double x = srcData.getField<double>(dimX, srcIndex);
// const double y = srcData.getField<double>(dimY, srcIndex);
// const double z = srcData.getField<double>(dimZ, srcIndex);
// const boost::uint64_t t = srcData.getField<boost::uint64_t>(dimTime, srcIndex);
// parser.setVariable("X", x);
// parser.setVariable("Y", y);
// parser.setVariable("Z", z);
// parser.setVariable("Time", t);
// bool ok = parser.evaluate();
// assert(ok);
// const bool predicate = parser.getVariable<bool>("result");

// if (predicate)
// {
// dstData.copyPointFast(dstIndex, srcIndex, srcData);
// dstData.setNumPoints(dstIndex+1);
// ++dstIndex;
// ++numPointsAdded;
// }
//}

//assert(dstIndex <= dstData.getCapacity());

//return numPointsAdded;
return 0;
delete[] mask;

return count;
}


Expand Down Expand Up @@ -190,8 +159,12 @@ boost::uint32_t Predicate::readBufferImpl(PointBuffer& dstData)
// read in a full block of points
PointBuffer srcData(dstData.getSchema(), (boost::uint32_t)dstData.getBufferByteCapacity());

// copy the valid points from the src block to the dst block
m_predicateFilter.processBuffer(srcData, dstData, *m_pythonMethod);
const boost::uint32_t numRead = getPrevIterator().read(srcData);
if (numRead > 0)
{
// copy the valid points from the src block to the dst block
m_predicateFilter.processBuffer(srcData, dstData, *m_pythonMethod);
}

return dstData.getNumPoints();
}
Expand Down
11 changes: 6 additions & 5 deletions test/unit/PredicateFilterTest.cpp
Expand Up @@ -45,7 +45,7 @@ BOOST_AUTO_TEST_SUITE(PredicateFilterTest)
using namespace pdal;

BOOST_AUTO_TEST_CASE(PredicateFilterTest_test1)
{return;
{
Bounds<double> bounds(0.0, 0.0, 0.0, 2.0, 2.0, 2.0);
pdal::drivers::faux::Reader reader(bounds, 1000, pdal::drivers::faux::Reader::Ramp);

Expand All @@ -56,7 +56,8 @@ BOOST_AUTO_TEST_CASE(PredicateFilterTest_test1)
"def yow(ins,outs):\n"
" X = ins['X']\n"
" Result = np.less(X, 1.0)\n"
" print Result\n"
" #print X\n"
" #print Result\n"
" outs['Result'] = Result\n"
" return True\n"
);
Expand Down Expand Up @@ -92,7 +93,7 @@ BOOST_AUTO_TEST_CASE(PredicateFilterTest_test1)


BOOST_AUTO_TEST_CASE(PredicateFilterTest_test2)
{return;
{
// same as above, but with 'Y >' instead of 'X <'

Bounds<double> bounds(0.0, 0.0, 0.0, 2.0, 2.0, 2.0);
Expand All @@ -103,9 +104,9 @@ BOOST_AUTO_TEST_CASE(PredicateFilterTest_test2)
"import numpy as np\n"
"import numpy as np\n"
"def yow(ins,outs):\n"
" X = ins['X']\n"
" Y = ins['Y']\n"
" Result = np.greater(Y, 1.0)\n"
" print Result\n"
" #print Result\n"
" outs['Result'] = Result\n"
" return True\n"
);
Expand Down

0 comments on commit 9275e41

Please sign in to comment.