Skip to content

Commit

Permalink
add hexbin filter scaffolding http://github.com/hobu/hexer
Browse files Browse the repository at this point in the history
  • Loading branch information
hobu committed Apr 16, 2013
1 parent 9aa593b commit b118991
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 42 deletions.
14 changes: 12 additions & 2 deletions CMakeLists.txt
Expand Up @@ -470,6 +470,17 @@ if(WITH_FREEGLUT)
endif()
endif()

set (WITH_HEXER FALSE CACHE BOOL "Whether or not hexbin filter is built")

if(WITH_HEXER)
find_package(Hexer)
if(HEXER_FOUND)
include_directories(${HEXER_INCLUDE_DIR})
add_definitions(-DHAVE_HEXER=1)
set(PDAL_HAVE_HEXER 1)
endif()

endif()

# default is false for now
set(WITH_PYTHON FALSE CACHE BOOL "Choose if Python support (for PLang filters) should be built")
Expand All @@ -493,7 +504,6 @@ set (USE_PDAL_PLUGIN_OCI FALSE CACHE BOOL "Build the oci driver as a plugin rath
set (USE_PDAL_PLUGIN_MRSID FALSE CACHE BOOL "Build the MrSID driver as a plugin rather than embedding")
set (USE_PDAL_PLUGIN_CARIS FALSE CACHE BOOL "Build the Caris driver as a plugin rather than embedding")

set (WITH_PSHAPE FALSE CACHE BOOL "Whether or not to build cairo pshape rendering")


#------------------------------------------------------------------------------
Expand All @@ -511,7 +521,7 @@ if(WIN32)
set(DEFAULT_BIN_SUBDIR .)
endif()
else()
# Common locatoins for Unix and Mac OS X
# Common Locations for Unix and Mac OS X
set(DEFAULT_BIN_SUBDIR bin)
set(DEFAULT_LIB_SUBDIR lib)
set(DEFAULT_DATA_SUBDIR share/pdal)
Expand Down
4 changes: 0 additions & 4 deletions apps/CMakeLists.txt
Expand Up @@ -5,10 +5,6 @@

cmake_minimum_required(VERSION 2.8)

if (WITH_PSHAPE)
subdirs(pshape)
endif()

if(FREEGLUT_FOUND)
subdirs(pcview)
endif()
Expand Down
3 changes: 3 additions & 0 deletions hobu-config.sh
Expand Up @@ -32,6 +32,9 @@ cmake -G "$CONFIG" \
-DWITH_FLANN=ON \
-DWITH_SOCI=ON \
-DWITH_P2G=ON \
-DWITH_HEXER=ON \
-DHEXER_INCLUDE_DIR=../hexer/include \
-DHEXER_LIBRARY=../hexer/bin/Debug/libhexer.dylib \
-DGEOTIFF_INCLUDE_DIR=${GEOTIFF_HOME}/include/ \
-DGEOTIFF_LIBRARY=${GEOTIFF_HOME}/lib/libgeotiff.${SO_EXT} \
-DICONV_INCLUDE_DIR=/usr/include \
Expand Down
13 changes: 10 additions & 3 deletions apps/pshape/HexBin.hpp → include/pdal/filters/HexBin.hpp
Expand Up @@ -40,8 +40,12 @@

#include <boost/shared_ptr.hpp>

#include <Mathpair.hpp>
#include <HexGrid.hpp>
#ifdef PDAL_HAVE_HEXER

#include <hexer/Mathpair.hpp>
#include <hexer/HexGrid.hpp>

#endif

namespace pdal
{
Expand Down Expand Up @@ -104,11 +108,14 @@ class PDAL_DLL IteratorBase
Dimension const* m_dim_y;

std::vector<Pshape::Point> m_samples;

#ifdef PDAL_HAVE_HEXER
Pshape::HexGrid* m_grid;
#endif

};

} // inplacereprojection
} // hexer

namespace sequential
{
Expand Down
8 changes: 6 additions & 2 deletions src/CMakeLists.txt
Expand Up @@ -413,6 +413,7 @@ set(PDAL_FILTERS_HPP
${PDAL_FILTERS_HEADERS}/Colorization.hpp
${PDAL_FILTERS_HEADERS}/Crop.hpp
${PDAL_FILTERS_HEADERS}/Decimation.hpp
${PDAL_FILTERS_HEADERS}/HexBin.hpp
${PDAL_FILTERS_HEADERS}/Index.hpp
${PDAL_FILTERS_HEADERS}/InPlaceReprojection.hpp
${PDAL_FILTERS_HEADERS}/Mosaic.hpp
Expand All @@ -433,6 +434,7 @@ set (PDAL_FILTERS_CPP
${PDAL_FILTERS_SRC}/Colorization.cpp
${PDAL_FILTERS_SRC}/Crop.cpp
${PDAL_FILTERS_SRC}/Decimation.cpp
${PDAL_FILTERS_SRC}/HexBin.cpp
${PDAL_FILTERS_SRC}/Index.cpp
${PDAL_FILTERS_SRC}/InPlaceReprojection.cpp
${PDAL_FILTERS_SRC}/Mosaic.cpp
Expand Down Expand Up @@ -588,7 +590,8 @@ if (WIN32)
${PYTHON_LIBRARY}
${P2G_LIBRARY}
${GEOS_LIBRARY}
${FLANN_LIBRARIES})
${FLANN_LIBRARIES}
${HEXER_LIBRARY})
else()
target_link_libraries(${APPS_CPP_DEPENDENCIES}
${PDAL_LIB_NAME}
Expand All @@ -603,7 +606,8 @@ else()
${PYTHON_LIBRARY}
${P2G_LIBRARY}
${GEOS_LIBRARY}
${FLANN_LIBRARIES})
${FLANN_LIBRARIES}
${HEXER_LIBRARY})
endif()

message(STATUS "Using boost lib: ${Boost_LIBRARIES}")
Expand Down
41 changes: 10 additions & 31 deletions apps/pshape/HexBin.cpp → src/filters/HexBin.cpp
Expand Up @@ -32,7 +32,7 @@
* OF SUCH DAMAGE.
****************************************************************************/

#include <HexBin.hpp>
#include <pdal/filters/HexBin.hpp>

#include <boost/concept_check.hpp> // ignore_unused_variable_warning

Expand Down Expand Up @@ -72,33 +72,6 @@ void HexBin::initialize()
Options HexBin::getDefaultOptions()
{
Options options;
// Option in_srs("in_srs", std::string(""),"Input SRS to use to override -- fetched from previous stage if not present");
// Option out_srs("out_srs", std::string(""), "Output SRS to reproject to");
// Option x("x_dim", std::string("X"), "Dimension name to use for 'X' data");
// Option y("y_dim", std::string("Y"), "Dimension name to use for 'Y' data");
// Option z("z_dim", std::string("Z"), "Dimension name to use for 'Z' data");
// Option x_scale("scale_x", 1.0f, "Scale for output X data in the case when 'X' dimension data are to be scaled. Defaults to '1.0'. If not set, the Dimensions's scale will be used");
// Option y_scale("scale_y", 1.0f, "Scale for output Y data in the case when 'Y' dimension data are to be scaled. Defaults to '1.0'. If not set, the Dimensions's scale will be used");
// Option z_scale("scale_z", 1.0f, "Scale for output Z data in the case when 'Z' dimension data are to be scaled. Defaults to '1.0'. If not set, the Dimensions's scale will be used");
// Option x_offset("offset_x", 0.0f, "Offset for output X data in the case when 'X' dimension data are to be scaled. Defaults to '0.0'. If not set, the Dimensions's scale will be used");
// Option y_offset("offset_y", 0.0f, "Offset for output Y data in the case when 'Y' dimension data are to be scaled. Defaults to '0.0'. If not set, the Dimensions's scale will be used");
// Option z_offset("offset_z", 0.0f, "Offset for output Z data in the case when 'Z' dimension data are to be scaled. Defaults to '0.0'. If not set, the Dimensions's scale will be used");
// Option ignore_old_dimensions("ignore_old_dimensions", true, "Mark old, unprojected dimensions as ignored");
// Option do_offset_z("do_offset_z", false, "Should we re-offset Z data");
// options.add(in_srs);
// options.add(out_srs);
// options.add(x);
// options.add(y);
// options.add(z);
// options.add(x_scale);
// options.add(y_scale);
// options.add(z_scale);
// options.add(x_offset);
// options.add(y_offset);
// options.add(z_offset);
// options.add(ignore_old_dimensions);
// options.add(do_offset_z);

return options;
}

Expand Down Expand Up @@ -155,7 +128,10 @@ boost::uint32_t HexBin::readBufferImpl(PointBuffer& buffer)
int32_t yi = buffer.getField<int32_t>(*m_dim_y, i);
double x = m_dim_x->applyScaling<int32_t>(xi);
double y = m_dim_y->applyScaling<int32_t>(yi);
#ifdef PDAL_HAVE_HEXER

m_samples.push_back(Pshape::Point(x,y));
#endif
}

return numPoints;
Expand All @@ -167,16 +143,19 @@ void HexBin::readBufferEndImpl(PointBuffer&)
// double hexsize = Pshape::computeHexSize(samples);
double hexsize =5 ;
int dense_limit = 10;

#ifdef PDAL_HAVE_HEXER

m_grid = new Pshape::HexGrid(hexsize, dense_limit);
for (std::vector<Pshape::Point>::size_type i = 0; i < m_samples.size(); ++i)
{
m_grid->addPoint(m_samples[i]);
}

// m_grid->drawHexagons();
// grid.dumpInfo();

m_grid->findShapes();

#endif

}


Expand Down

0 comments on commit b118991

Please sign in to comment.