diff --git a/filters/HexBinFilter.cpp b/filters/HexBinFilter.cpp index c0e2fdfec8..4684deda52 100644 --- a/filters/HexBinFilter.cpp +++ b/filters/HexBinFilter.cpp @@ -108,7 +108,6 @@ void HexBin::done(PointTableRef table) m_metadata.add("boundary", "MULTIPOLYGON EMPTY", "Empty polygon -- unable to compute boundary"); return; - } diff --git a/filters/HexBinFilter.hpp b/filters/HexBinFilter.hpp index d2f5f62b9a..8c295dd8e4 100644 --- a/filters/HexBinFilter.hpp +++ b/filters/HexBinFilter.hpp @@ -42,8 +42,6 @@ #include "private/hexer/HexGrid.hpp" #include "private/hexer/Processor.hpp" -//namespace hexer = pdalhexer; - namespace pdal { diff --git a/filters/private/hexer/HexGrid.hpp b/filters/private/hexer/HexGrid.hpp index 435be77562..1cb73e11b8 100644 --- a/filters/private/hexer/HexGrid.hpp +++ b/filters/private/hexer/HexGrid.hpp @@ -42,7 +42,6 @@ #include "Mathpair.hpp" #include "Path.hpp" #include "Segment.hpp" -#include "export.hpp" namespace hexer { @@ -51,7 +50,7 @@ class HexIter; static const double SQRT_3 = 1.732050808; -class HEXER_DLL HexGrid +class HexGrid { friend class HexIter; public: diff --git a/filters/private/hexer/HexInfo.hpp b/filters/private/hexer/HexInfo.hpp index e4540acda1..ee560d77af 100644 --- a/filters/private/hexer/HexInfo.hpp +++ b/filters/private/hexer/HexInfo.hpp @@ -36,7 +36,7 @@ namespace hexer { -class HEXER_DLL HexInfo +class HexInfo { public: Point m_center; diff --git a/filters/private/hexer/HexIter.hpp b/filters/private/hexer/HexIter.hpp index 4a87827eeb..7db8469256 100644 --- a/filters/private/hexer/HexIter.hpp +++ b/filters/private/hexer/HexIter.hpp @@ -33,14 +33,13 @@ ****************************************************************************/ #pragma once -#include "export.hpp" #include "HexGrid.hpp" #include "HexInfo.hpp" namespace hexer { -class HEXER_DLL HexIter +class HexIter { public: HexIter(HexGrid::HexMap::iterator iter, HexGrid *grid) : diff --git a/filters/private/hexer/Hexagon.hpp b/filters/private/hexer/Hexagon.hpp index 29787e4860..48bcfe0f8c 100644 --- a/filters/private/hexer/Hexagon.hpp +++ b/filters/private/hexer/Hexagon.hpp @@ -35,13 +35,12 @@ #include -#include "export.hpp" #include "Mathpair.hpp" namespace hexer { -class HEXER_DLL Hexagon +class Hexagon { public: Hexagon(int x, int y) : m_x(x), m_y(y), m_count(0), m_dense(false), diff --git a/filters/private/hexer/Mathpair.hpp b/filters/private/hexer/Mathpair.hpp index d60ec0f168..c551caa5bb 100644 --- a/filters/private/hexer/Mathpair.hpp +++ b/filters/private/hexer/Mathpair.hpp @@ -34,13 +34,11 @@ #pragma once -#include "export.hpp" - namespace hexer { template -struct HEXER_DLL Mathpair +struct Mathpair { public: Mathpair() : m_x(T(0)), m_y(T(0)) diff --git a/filters/private/hexer/Path.hpp b/filters/private/hexer/Path.hpp index 3ac98b43ec..9d3a448fa9 100644 --- a/filters/private/hexer/Path.hpp +++ b/filters/private/hexer/Path.hpp @@ -38,7 +38,6 @@ #include "Mathpair.hpp" #include "Segment.hpp" -#include "export.hpp" namespace hexer { @@ -51,7 +50,7 @@ enum Orientation class HexGrid; -class HEXER_DLL Path +class Path { public: Path(HexGrid *m_grid, Orientation orient) : diff --git a/filters/private/hexer/Processor.cpp b/filters/private/hexer/Processor.cpp index 643a575cb3..ca46f96ea3 100644 --- a/filters/private/hexer/Processor.cpp +++ b/filters/private/hexer/Processor.cpp @@ -40,10 +40,6 @@ #include "HexGrid.hpp" -#ifdef HEXER_HAVE_GDAL -#include "gdal.h" -#endif - #include "Mathpair.hpp" namespace hexer @@ -95,20 +91,4 @@ void processHexes(HexGrid *grid, HexReader reader) grid->findParentPaths(); } -std::string GetFullVersion( void ) -{ - std::ostringstream os; - - os << "hexer " - << HEXER_VERSION_MAJOR << "." - << HEXER_VERSION_MINOR << "." - << HEXER_VERSION_PATCH; - -#ifdef HEXER_HAVE_GDAL - os << " with GDAL " << GDALVersionInfo("RELEASE_NAME"); -#endif - - return os.str(); -} - } //namespace hexer diff --git a/filters/private/hexer/Processor.hpp b/filters/private/hexer/Processor.hpp index 24338a8c13..5ca3b98d44 100644 --- a/filters/private/hexer/Processor.hpp +++ b/filters/private/hexer/Processor.hpp @@ -39,19 +39,15 @@ #include #include "Path.hpp" -#include "export.hpp" namespace hexer { typedef std::function PointReader; typedef std::function HexReader; - HEXER_DLL void process(HexGrid *grid, PointReader); - HEXER_DLL void processHexes(HexGrid *grid, HexReader); - - HEXER_DLL double computeHexSize(const std::vector& samples, + void process(HexGrid *grid, PointReader); + void processHexes(HexGrid *grid, HexReader); + double computeHexSize(const std::vector& samples, int density); - - HEXER_DLL std::string GetFullVersion( void ); } // namespace hexer diff --git a/filters/private/hexer/Segment.hpp b/filters/private/hexer/Segment.hpp index e7f681d960..489fe5b81b 100644 --- a/filters/private/hexer/Segment.hpp +++ b/filters/private/hexer/Segment.hpp @@ -38,7 +38,6 @@ #include #include "Mathpair.hpp" -#include "export.hpp" namespace hexer { @@ -46,7 +45,7 @@ namespace hexer class Hexagon; class HexGrid; -class HEXER_DLL Segment +class Segment { public: Segment() : m_hex(NULL), m_side(0) diff --git a/filters/private/hexer/Utils.hpp b/filters/private/hexer/Utils.hpp deleted file mode 100644 index aecb17938f..0000000000 --- a/filters/private/hexer/Utils.hpp +++ /dev/null @@ -1,66 +0,0 @@ -/****************************************************************************** - * Copyright (c) 2014, Hobu Inc. (howard@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 the Howard Butler or Hobu, Inc. - * 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. - ****************************************************************************/ -#pragma once - -#include -#include - -namespace hexer -{ - -// compares two values to within a given tolerance -// the value |tolerance| is compared to |actual - expected| -template -static bool compare_approx(const T& actual, const T& expected, - const T& tolerance) -{ - const double diff = std::abs((double)actual - (double)expected); - const double delta = std::abs((double)tolerance); - - if (diff > delta) - { - return false; - } - return true; -} - -template -static bool compare_distance(const T& actual, const T& expected) -{ - const T epsilon = std::numeric_limits::epsilon(); - return compare_approx(actual, expected, epsilon); -} - -} // namespace hexer - diff --git a/filters/private/hexer/export.hpp b/filters/private/hexer/export.hpp deleted file mode 100644 index 00893ae841..0000000000 --- a/filters/private/hexer/export.hpp +++ /dev/null @@ -1,63 +0,0 @@ -/****************************************************************************** - * Copyright (c) 2014, Hobu Inc. (howard@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 the Howard Butler or Hobu, Inc. - * 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. - ****************************************************************************/ - - -#ifndef INCLUDED_HEXER_EXPORT_HPP -#define INCLUDED_HEXER_EXPORT_HPP - -#include - -#ifndef HEXER_DLL -#if defined(HEXER_COMPILER_MSVC) && !defined(HEXER_DISABLE_DLL) -#if defined(HEXER_DLL_EXPORT) -# define HEXER_DLL __declspec(dllexport) -#elif defined(HEXER_DLL_IMPORT) -# define HEXER_DLL __declspec(dllimport) -#else -# define HEXER_DLL -#endif -#else -# if defined(USE_GCC_VISIBILITY_FLAG) -# define HEXER_DLL __attribute__ ((visibility("default"))) -# else -# define HEXER_DLL -# endif -#endif -#endif - -#ifdef HEXER_COMPILER_MSVC -#pragma warning(disable:4251)// [templated class] needs to have dll-interface... -#endif - -#endif diff --git a/filters/private/hexer/gitsha.cpp b/filters/private/hexer/gitsha.cpp deleted file mode 100644 index 201f0e5127..0000000000 --- a/filters/private/hexer/gitsha.cpp +++ /dev/null @@ -1,3 +0,0 @@ -#include -#define GIT_SHA1 "df2fcbb3f8b98b5ea7977ae2821dcc9acf71b25e" -const char g_GIT_SHA1HEXER[] = GIT_SHA1; diff --git a/filters/private/hexer/gitsha.h b/filters/private/hexer/gitsha.h deleted file mode 100644 index 5b7a681928..0000000000 --- a/filters/private/hexer/gitsha.h +++ /dev/null @@ -1 +0,0 @@ -extern const char g_GIT_SHA1HEXER[]; diff --git a/filters/private/hexer/hexer.hpp b/filters/private/hexer/hexer.hpp deleted file mode 100644 index 981b0ada8d..0000000000 --- a/filters/private/hexer/hexer.hpp +++ /dev/null @@ -1,42 +0,0 @@ -/****************************************************************************** - * Copyright (c) 2014, Hobu Inc. (howard@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 the Howard Butler or Hobu, Inc. - * 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. - ****************************************************************************/ - -#ifndef INCLUDED_HEXER_HPP -#define INCLUDED_HEXER_HPP - -#include "hexer_defines.h" -#include "exception.hpp" -#include "gitsha.h" - -#endif diff --git a/filters/private/hexer/hexer_defines.h b/filters/private/hexer/hexer_defines.h deleted file mode 100644 index e89261210d..0000000000 --- a/filters/private/hexer/hexer_defines.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * pdal_defines.h.in is used by cmake to generate hexer_defines.h - * - * Do not edit hexer_defines.h! - * - * Note this is a C-style header. Do not use C++ syntax. - */ -#ifndef HEXER_DEFINES_H -#define HEXER_DEFINES_H - -/* - * version settings - */ -#define HEXER_VERSION_MAJOR 1 -#define HEXER_VERSION_MINOR 4 -#define HEXER_VERSION_PATCH 0 - -#define HEXER_VERSION_STRING "1.4.0" - - -/* - * availability of 3rd-party libraries - */ -#define HEXER_HAVE_CAIRO -#define HEXER_HAVE_GDAL - -/* - * availability of execinfo and backtrace - */ -#define HEXER_HAVE_EXECINFO_H - -/* - * Debug or Release build? - */ -#define HEXER_BUILD_TYPE "Release" - -/* - * platform compiler - */ -/* #undef HEXER_COMPILER_MSVC */ - -#endif diff --git a/kernels/DensityKernel.cpp b/kernels/DensityKernel.cpp index e40f72f5ae..fd0a3ebd94 100644 --- a/kernels/DensityKernel.cpp +++ b/kernels/DensityKernel.cpp @@ -34,7 +34,7 @@ #include "DensityKernel.hpp" #include "../filters/HexBinFilter.hpp" -#include "OGR.hpp" +#include "private/density/OGR.hpp" #include #include @@ -78,8 +78,7 @@ void DensityKernel::outputDensity(pdal::SpatialReference const& reference) hexer::HexGrid* grid = hexbin->grid(); - hexdensity::writer::OGR writer(m_outputFile, reference.getWKT(), - m_driverName, m_layerName); + OGR writer(m_outputFile, reference.getWKT(), m_driverName, m_layerName); writer.writeDensity(grid); // writer.writeBoundary(grid); } diff --git a/kernels/OGR.cpp b/kernels/private/density/OGR.cpp similarity index 95% rename from kernels/OGR.cpp rename to kernels/private/density/OGR.cpp index 7124e0c617..e65ef47fef 100644 --- a/kernels/OGR.cpp +++ b/kernels/private/density/OGR.cpp @@ -41,21 +41,80 @@ #include #include -#include "../filters/private/hexer/HexGrid.hpp" -#include "../filters/private/hexer/HexIter.hpp" +#include +#include using namespace std; namespace pdal { -namespace hexdensity +namespace { -namespace writer +void collectPath(hexer::Path* path, OGRGeometryH polygon) { + OGRGeometryH ring = OGR_G_CreateGeometry(wkbLinearRing); + + vector pts = path->points(); + + vector::const_iterator i; + for (i = pts.begin(); i != pts.end(); ++i) + { + OGR_G_AddPoint_2D(ring, i->m_x, i->m_y); + } + + if( OGR_G_AddGeometryDirectly(polygon, ring) != OGRERR_NONE ) + { + std::ostringstream oss; + oss << "Unable to add geometry with error '" << + CPLGetLastErrorMsg() << "'"; + throw pdal::pdal_error(oss.str()); + } + + vector paths = path->subPaths(); + for (vector::size_type pi = 0; pi != paths.size(); ++pi) + { + hexer::Path* p = paths[pi]; + collectPath(p, polygon); + } +} + +OGRGeometryH collectHexagon(hexer::HexInfo const& info, + hexer::HexGrid const* grid) +{ + OGRGeometryH ring = OGR_G_CreateGeometry(wkbLinearRing); + + hexer::Point pos = info.m_center; + pos += grid->origin(); -OGR::OGR(std::string const& filename, std::string srs, std::string driver, std::string layerName) + + OGR_G_AddPoint_2D(ring, pos.m_x, pos.m_y); + for (int i = 1; i <= 5; ++i) + { + hexer::Point p = pos + grid->offset(i); + OGR_G_AddPoint_2D(ring, p.m_x, p.m_y); + } + OGR_G_AddPoint_2D(ring, pos.m_x, pos.m_y); + + OGRGeometryH polygon = OGR_G_CreateGeometry(wkbPolygon); + if( OGR_G_AddGeometryDirectly(polygon, ring ) != OGRERR_NONE ) + { + std::ostringstream oss; + oss << "Unable to add ring to polygon in collectHexagon '" + << CPLGetLastErrorMsg() << "'"; + throw pdal::pdal_error(oss.str()); + } + + return polygon; + +} + +} // unnamed namespace + + +OGR::OGR(std::string const& filename, std::string srs, std::string driver, + std::string layerName) : m_filename(filename) , m_driver(driver) , m_srs(srs) @@ -66,6 +125,13 @@ OGR::OGR(std::string const& filename, std::string srs, std::string driver, std:: createLayer(); } + +OGR::~OGR() +{ + OGR_DS_Destroy(m_ds); +} + + void OGR::createLayer() { @@ -162,64 +228,6 @@ void OGR::writeBoundary(hexer::HexGrid *grid) } } -void OGR::collectPath(hexer::Path* path, OGRGeometryH polygon) -{ - OGRGeometryH ring = OGR_G_CreateGeometry(wkbLinearRing); - - vector pts = path->points(); - - vector::const_iterator i; - for (i = pts.begin(); i != pts.end(); ++i) - { - OGR_G_AddPoint_2D(ring, i->m_x, i->m_y); - } - - if( OGR_G_AddGeometryDirectly(polygon, ring) != OGRERR_NONE ) - { - std::ostringstream oss; - oss << "Unable to add geometry with error '" << - CPLGetLastErrorMsg() << "'"; - throw pdal::pdal_error(oss.str()); - } - - vector paths = path->subPaths(); - for (vector::size_type pi = 0; pi != paths.size(); ++pi) - { - hexer::Path* p = paths[pi]; - collectPath(p, polygon); - } -} - -OGRGeometryH OGR::collectHexagon(hexer::HexInfo const& info, hexer::HexGrid const* grid) -{ - OGRGeometryH ring = OGR_G_CreateGeometry(wkbLinearRing); - - hexer::Point pos = info.m_center; - pos += grid->origin(); - - - OGR_G_AddPoint_2D(ring, pos.m_x, pos.m_y); - for (int i = 1; i <= 5; ++i) - { - hexer::Point p = pos + grid->offset(i); - OGR_G_AddPoint_2D(ring, p.m_x, p.m_y); - } - OGR_G_AddPoint_2D(ring, pos.m_x, pos.m_y); - - OGRGeometryH polygon = OGR_G_CreateGeometry(wkbPolygon); - if( OGR_G_AddGeometryDirectly(polygon, ring ) != OGRERR_NONE ) - { - std::ostringstream oss; - oss << "Unable to add ring to polygon in collectHexagon '" - << CPLGetLastErrorMsg() << "'"; - throw pdal::pdal_error(oss.str()); - } - - return polygon; - -} - - void OGR::writeDensity(hexer::HexGrid *grid) { int counter(0); @@ -251,13 +259,5 @@ void OGR::writeDensity(hexer::HexGrid *grid) } } - -OGR::~OGR() -{ - OGR_DS_Destroy(m_ds); -} - -} // namespace writer -} // namespace hexer } // namespace pdal diff --git a/kernels/OGR.hpp b/kernels/private/density/OGR.hpp similarity index 77% rename from kernels/OGR.hpp rename to kernels/private/density/OGR.hpp index 37566c1366..12f76977f9 100644 --- a/kernels/OGR.hpp +++ b/kernels/private/density/OGR.hpp @@ -33,30 +33,25 @@ ****************************************************************************/ #pragma once -#include "../filters/private/hexer/hexer.hpp" -#include "../filters/private/hexer/Processor.hpp" -#include "../filters/private/hexer/hexer_defines.h" -#include "../filters/private/hexer/Mathpair.hpp" -#include "../filters/private/hexer/HexInfo.hpp" -#include "../filters/private/hexer/export.hpp" +#include #include "ogr_api.h" #include "gdal.h" -namespace pdal -{ -namespace hexdensity -{ -namespace writer +namespace hexer { + class HexGrid; +} +namespace pdal +{ class OGR { - public: - OGR(std::string const& filename, std::string srs, std::string driver = "ESRI Shapefile", std::string layerName =""); + OGR(std::string const& filename, std::string srs, + std::string driver = "ESRI Shapefile", std::string layerName =""); ~OGR(); void writeBoundary(hexer::HexGrid *grid); @@ -72,13 +67,7 @@ class OGR std::string m_layerName; void createLayer(); - void collectPath(hexer::Path* path, OGRGeometryH polygon); - OGRGeometryH collectHexagon(hexer::HexInfo const& info, hexer::HexGrid const* grid); - }; -} // writer - -} // namespace +} // namespace pdal -} //pdal