Browse files

add examples for filtering to keep last returns or specified return v…

…alues
  • Loading branch information...
1 parent 2508504 commit 428c60fc32227e523c1e0623fb2b12265bd43a24 @hobu hobu committed Apr 19, 2012
View
30 test/data/plang/predicate-keep-last-return.xml
@@ -0,0 +1,30 @@
+<?xml version="1.0"?>
+<Pipeline version="1.0">
+ <Writer type="drivers.las.writer">
+ <Option name="filename">
+ out2.las
+ </Option>
+ <Filter type="filters.predicate">
+ <Option name="module">anything</Option>
+ <Option name="function">filter</Option>
+ <Option name="source">
+import numpy as np
+
+def filter(ins,outs):
+ ret = ins['ReturnNumber']
+ ret_no = ins['NumberOfReturns']
+
+ # Use the first test for our base array.
+ rets = np.equal(ret, ret_no)
+
+ outs['Mask'] = rets
+ return True
+ </Option>
+ <Reader type="drivers.las.reader">
+ <Option name="filename">
+ ../autzen.las
+ </Option>
+ </Reader>
+ </Filter>
+ </Writer>
+</Pipeline>
View
37 test/data/plang/predicate-keep-specified-returns.xml
@@ -0,0 +1,37 @@
+<?xml version="1.0"?>
+<Pipeline version="1.0">
+ <Writer type="drivers.las.writer">
+ <Option name="filename">
+ out2.las
+ </Option>
+ <Filter type="filters.predicate">
+ <Option name="module">anything</Option>
+ <Option name="function">filter</Option>
+ <Option name="source">
+import numpy as np
+
+def filter(ins,outs):
+ ret = ins['ReturnNumber']
+
+ keep_ret = [0, 1,2]
+
+ # Use the first test for our base array.
+ keep = np.equal(ret, keep_ret[0])
+
+ # For 1:n, test each predicate and join back
+ # to our existing predicate array
+ for k in range(1, len(keep_ret)):
+ t = np.equal(ret, keep_ret[k])
+ keep = keep + t
+
+ outs['Mask'] = keep
+ return True
+ </Option>
+ <Reader type="drivers.las.reader">
+ <Option name="filename">
+ ../autzen.las
+ </Option>
+ </Reader>
+ </Filter>
+ </Writer>
+</Pipeline>

0 comments on commit 428c60f

Please sign in to comment.