Skip to content

Commit

Permalink
Merge branch 'master' of github.com:PDAL/PDAL
Browse files Browse the repository at this point in the history
  • Loading branch information
hobu committed Jan 15, 2017
2 parents a7989bf + c2da3ad commit e48e092
Show file tree
Hide file tree
Showing 61 changed files with 1,498 additions and 933 deletions.
2 changes: 0 additions & 2 deletions cmake/options.cmake
Expand Up @@ -55,8 +55,6 @@ endif(DEFINED ENV{ORACLE_HOME})
option(BUILD_PLUGIN_OCI
"Choose if OCI support should be built" ${DEFINED_ORACLE_HOME})

option(BUILD_PLUGIN_P2G "Choose if Points2Grid support should be built" FALSE)

option(BUILD_PLUGIN_PCL "Choose if PCL support should be built" FALSE)
add_feature_info("PCL plugin" BUILD_PLUGIN_PCL
"provides PCL-based readers, writers, filters, and kernels")
Expand Down
43 changes: 43 additions & 0 deletions doc/stages/filters.assign.rst
@@ -0,0 +1,43 @@
.. _filters.assign:

filters.assign
===================

The assign filter allows you set the value of a dimension for all points
to a provided value.


Example 1
---------

This pipeline sets the PointSourceId of all points from 'autzen-dd.las'
to the value '26'.

.. code-block:: json
{
"pipeline":[
"autzen-dd.las",
{
"type":"filters.assign",
"dimension":"PointSourceId",
"value":26
},
{
"filename":"attributed.las",
"scale_x":0.0000001,
"scale_y":0.0000001
}
]
}
Options
-------

dimension
Name of the dimension whose value should be altered. [Required]

value
Value to apply to the dimension. [Required]

53 changes: 10 additions & 43 deletions doc/stages/filters.attribute.rst → doc/stages/filters.overlay.rst
@@ -1,16 +1,11 @@
.. _filters.attribute:
.. _filters.overlay:

filters.attribute
filters.overlay
===================

The attribute filter allows you to set the values of a
selected dimension. Two scenarios are supported:

* Set the value of a dimension of all points to single value
(use option 'value')

* Set points inside an OGR-readable Polygon or MultiPolygon
(use option 'datasource')
The overlay filter allows you to set the values of a selected dimension
based on an OGR-readable polygon or multi-polygon.

OGR SQL support
----------------
Expand Down Expand Up @@ -43,7 +38,7 @@ feature.
"pipeline":[
"autzen-dd.las",
{
"type":"filters.attribute",
"type":"filters.overlay",
"dimension":"Classification",
"datasource":"attributes.shp",
"layer":"attributes",
Expand All @@ -57,33 +52,8 @@ feature.
]
}
Example 2
---------

This pipeline sets the PointSourceId of all points from 'autzen-dd.las'
to the value '26'.

.. code-block:: json
{
"pipeline":[
"autzen-dd.las",
{
"type":"filters.attribute",
"dimension":"PointSourceId",
"value":26
},
{
"filename":"attributed.las",
"scale_x":0.0000001,
"scale_y":0.0000001
}
]
}
Example 3
Example 2
--------------------------------------------------------------------------------

This example sets the Intensity attribute to ``CLS`` values read from the
Expand All @@ -97,7 +67,7 @@ This example sets the Intensity attribute to ``CLS`` values read from the
"pipeline":[
"autzen-dd.las",
{
"type":"filters.attribute",
"type":"filters.overlay",
"dimension":"Intensity",
"datasource":"attributes.shp",
"query":"SELECT CLS FROM attributes where cls!=6",
Expand All @@ -113,21 +83,18 @@ Options
-------

dimension
Name of the dimension whose value should be altered. [Default: none]

value
Value to apply to the dimension. [Default: none]
Name of the dimension whose value should be altered. [Required]

datasource
OGR-readable datasource for Polygon or MultiPolygon data. [Default: none]
OGR-readable datasource for Polygon or MultiPolygon data. [Required]

column
The OGR datasource column from which to read the attribute.
[Default: first column]

query
OGR SQL query to execute on the datasource to fetch geometry and attributes.
[Default: none]
The entire layer is fetched if no query is provided. [Default: none]

layer
The data source's layer to use. [Defalt: first layer]
Expand Down
28 changes: 22 additions & 6 deletions doc/stages/readers.faux.rst
Expand Up @@ -3,9 +3,29 @@
readers.faux
============

The "**faux reader**" is used for testing pipelines. It does not read from a
The faux reader is used for testing pipelines. It does not read from a
file or database, but generates synthetic data to feed into the pipeline.

The faux reader requires a mode argume to define the method in which points
should be generated. Valid modes are as follows:

constant
The values provided as the minimums to the bounds argument are
used for the X, Y and Z value, respectively, for every point.
random
Random values are chosen within the provided bounds.
ramp
Value increase uniformly from the minimum values to the maximum values.
uniform
Random values of each dimension are uniformly distributed in the
provided ranges.
normal
Random values of each dimension are normally distributed in the
provided ranges.
grid
Creates points with integer-valued coordinates in the range provided
(excluding the upper bound).

Example
-------

Expand Down Expand Up @@ -46,9 +66,5 @@ stdev_x|y|z
only) [Default: 1]

mode
How to generate synthetic points. One of "constant" (repeat single value),
"random" (random values within bounds), "ramp" (steadily increasing values
within the bounds), "uniform" (uniformly distributed within bounds), or
"normal" (normal distribution with given mean and standard deviation).
[Required]
"constant", "random", "ramp", "uniform", "normal" or "grid" [Required]

16 changes: 8 additions & 8 deletions doc/tutorial/clipping-with-shapefile.rst
Expand Up @@ -41,10 +41,10 @@ Stage Operations
-------------------------------------------------------------------------------

This operation depends on two :ref:`stages <stage_index>` PDAL provides.
The first is the :ref:`filters.attribute` stage, which allows you to assign
point values based on polygons read from `OGR`_. The second is the :ref:`filters.range`,
which allows you to keep or reject points from the set that match given
criteria.
The first is the :ref:`filters.overlay` stage, which allows you to assign
point values based on polygons read from `OGR`_. The second is the
:ref:`filters.range`, which allows you to keep or reject points from the
set that match given criteria.

.. seealso::

Expand Down Expand Up @@ -118,7 +118,7 @@ as they are read, filtered, and written.
"pipeline":[
"autzen.laz",
{
"type":"filters.attribute",
"type":"filters.overlay",
"dimension":"Classification",
"datasource":"attributes.vrt",
"layer":"OGRGeoJSON",
Expand All @@ -134,7 +134,7 @@ as they are read, filtered, and written.
* :ref:`readers.las`: Define a reader that can read `ASPRS LAS`_ or `LASzip`_
data.
* :ref:`filters.attribute`: Using the VRT we defined in `Data Preparation`_,
* :ref:`filters.overlay`: Using the VRT we defined in `Data Preparation`_,
read attribute polygons out of the data source and assign the values from the
``CLS`` column to the ``Classification`` field.
* :ref:`filters.range`: Given that we have set the ``Classification`` values
Expand All @@ -146,7 +146,7 @@ as they are read, filtered, and written.
.. note::

You don't have to use only ``Classification`` to set the attributes
with :ref:`filters.attribute`. Any valid dimension name could work, but
with :ref:`filters.overlay`. Any valid dimension name could work, but
most LiDAR softwares will display categorical coloring for the
``Classification`` field, and we can leverage that behavior in this
scenario.
Expand All @@ -173,7 +173,7 @@ Conclusion
-------------------------------------------------------------------------------

PDAL allows the composition of point cloud operations. This tutorial demonstrated
how to use the :ref:`filters.attribute` and :ref:`filters.range` stages to clip
how to use the :ref:`filters.overlay` and :ref:`filters.range` stages to clip
points with shapefiles.

.. _`CloudCompare`: http://www.danielgm.net/cc/
Expand Down
9 changes: 5 additions & 4 deletions doc/workshop/exercises/analysis/clipping/clipping.rst
Expand Up @@ -85,11 +85,12 @@ Pipeline breakdown

``autzen.laz`` is the `LASzip`_ file we will clip.

2. :ref:`filters.attribute`
2. :ref:`filters.overlay`
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The :ref:`filters.attribute` filter allows you to assign values for coincident
polygons. Using the VRT we defined in `Data preparation`_, :ref:`filters.attribute` will
The :ref:`filters.overlay` filter allows you to assign values for coincident
polygons. Using the VRT we defined in `Data preparation`_,
:ref:`filters.overlay` will
assign the values from the ``CLS`` column to the ``Classification`` field.


Expand Down Expand Up @@ -132,7 +133,7 @@ website.
Notes
--------------------------------------------------------------------------------

1. :ref:`filters.attribute` does point-in-polygon checks against every point
1. :ref:`filters.overlay` does point-in-polygon checks against every point
that is read.

2. Points that are *on* the boundary are included.
Expand Down
4 changes: 2 additions & 2 deletions doc/workshop/slides/source/clipping.rst
Expand Up @@ -59,7 +59,7 @@ Pipeline
================================================================================

1. :ref:`readers.las`
2. :ref:`filters.attribute`
2. :ref:`filters.overlay`
3. :ref:`filters.range`
4. :ref:`writers.las`

Expand All @@ -79,7 +79,7 @@ Range Filter
Pipeline Strategy
================================================================================

1. Assign with `filters.attribute`
1. Assign with `filters.overlay`
2. Filter with `filters.range`


Expand Down
2 changes: 1 addition & 1 deletion doc/workshop/slides/source/pdal_intro.rst
Expand Up @@ -117,7 +117,7 @@ Writers (database)
Filters
================================================================================

* :ref:`Attribute assignment<filters.attribute>`
* :ref:`Geographic attribute assignment<filters.overlay>`
* :ref:`Polygon clipping <filters.crop>`
* :ref:`Splitting by volume <filters.chipper>`
* :ref:`Splitting by geometry <filters.divider>`
Expand Down
87 changes: 87 additions & 0 deletions filters/AssignFilter.cpp
@@ -0,0 +1,87 @@
/******************************************************************************
* Copyright (c) 2017, Hobu Inc., info@hobu.co
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following
* conditions are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided
* with the distribution.
* * Neither the name of Hobu, Inc. or Flaxen Geo Consulting nor the
* names of its contributors may be used to endorse or promote
* products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
* OF SUCH DAMAGE.
****************************************************************************/

#include "AssignFilter.hpp"

#include <pdal/pdal_macros.hpp>
#include <pdal/StageFactory.hpp>
#include <pdal/util/ProgramArgs.hpp>

namespace pdal
{

static PluginInfo const s_info = PluginInfo(
"filters.assign",
"Assign values for a dimension using a specified value.",
"http://pdal.io/stages/filters.assign.html" );

CREATE_STATIC_PLUGIN(1, 0, AssignFilter, Filter, s_info)

void AssignFilter::addArgs(ProgramArgs& args)
{
args.add("dimension", "Dimension on which to filter", m_dimName).
setPositional();
args.add("value", "Value to set on matching points", m_value).
setPositional();
}


void AssignFilter::prepared(PointTableRef table)
{
m_dim = table.layout()->findDim(m_dimName);
if (m_dim == Dimension::Id::Unknown)
throw pdal_error(getName() + ": Dimension '" + m_dimName +
"' not found.");
}


bool AssignFilter::processOne(PointRef& point)
{
point.setField(m_dim, m_value);
return true;
}


void AssignFilter::filter(PointView& view)
{
PointRef point(view, 0);
for (PointId id = 0; id < view.size(); ++id)
{
point.setPointId(id);
processOne(point);
}
}

} // namespace pdal

0 comments on commit e48e092

Please sign in to comment.