Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://github.com/PDAL/PDAL into point-context
Conflicts: include/pdal/filters/PCLBlock.hpp include/pdal/filters/Scaling.hpp
- Loading branch information
Showing
9 changed files
with
278 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
156 changes: 156 additions & 0 deletions
156
test/unit/drivers/pgpointcloud/PgpointcloudWriterTest.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,156 @@ | ||
/****************************************************************************** | ||
* Copyright (c) 2014, Pete Gadomski (pete.gadomski@gmail.com) | ||
* | ||
* 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 <boost/test/unit_test.hpp> | ||
|
||
#include <pdal/drivers/las/Reader.hpp> | ||
#include <pdal/drivers/pgpointcloud/Writer.hpp> | ||
|
||
#include "Support.hpp" | ||
#include "drivers/pgpointcloud/Support.hpp" | ||
|
||
|
||
pdal::Options getWriterOptions() | ||
{ | ||
pdal::Options options; | ||
|
||
options.add(pdal::Option("connection", pdal::drivers::pgpointcloud::testDbTempConn)); | ||
options.add(pdal::Option("table", "pdal_test_table")); | ||
options.add(pdal::Option("srid", "4326")); | ||
options.add(pdal::Option("capacity", "10000")); | ||
|
||
return options; | ||
} | ||
|
||
struct PgpointcloudWriterTestFixture | ||
{ | ||
PgpointcloudWriterTestFixture() | ||
: m_masterConnection( | ||
pdal::drivers::pgpointcloud::pg_connect( | ||
pdal::drivers::pgpointcloud::testDbConn)) | ||
, m_testConnection(NULL) | ||
{ | ||
// Silence those pesky notices | ||
executeOnMasterDb("SET client_min_messages TO WARNING"); | ||
|
||
dropTestDb(); | ||
|
||
std::stringstream createDbSql; | ||
createDbSql << "CREATE DATABASE " << | ||
pdal::drivers::pgpointcloud::testDbTempname << " TEMPLATE template0"; | ||
executeOnMasterDb(createDbSql.str()); | ||
m_testConnection = pdal::drivers::pgpointcloud::pg_connect( | ||
pdal::drivers::pgpointcloud::testDbTempConn); | ||
|
||
executeOnTestDb("CREATE EXTENSION pointcloud"); | ||
} | ||
|
||
void executeOnTestDb(const std::string& sql) | ||
{ | ||
pdal::drivers::pgpointcloud::pg_execute(m_testConnection, sql); | ||
} | ||
|
||
~PgpointcloudWriterTestFixture() | ||
{ | ||
if (m_testConnection) | ||
{ | ||
PQfinish(m_testConnection); | ||
} | ||
dropTestDb(); | ||
if (m_masterConnection) | ||
{ | ||
PQfinish(m_masterConnection); | ||
} | ||
} | ||
|
||
private: | ||
|
||
void executeOnMasterDb(const std::string& sql) | ||
{ | ||
pdal::drivers::pgpointcloud::pg_execute(m_masterConnection, sql); | ||
} | ||
|
||
void execute(PGconn* connection, const std::string& sql) | ||
{ | ||
if (connection) | ||
{ | ||
pdal::drivers::pgpointcloud::pg_execute(connection, sql); | ||
} | ||
else | ||
{ | ||
throw std::runtime_error("Not connected to database for testing"); | ||
} | ||
} | ||
|
||
void dropTestDb() | ||
{ | ||
std::stringstream dropDbSql; | ||
dropDbSql << "DROP DATABASE IF EXISTS " << pdal::drivers::pgpointcloud::testDbTempname; | ||
executeOnMasterDb(dropDbSql.str()); | ||
} | ||
|
||
PGconn* m_masterConnection; | ||
PGconn* m_testConnection; | ||
|
||
}; | ||
|
||
BOOST_FIXTURE_TEST_SUITE(PgpointcloudWriterTest, PgpointcloudWriterTestFixture) | ||
|
||
|
||
BOOST_AUTO_TEST_CASE(testWrite) | ||
{ | ||
pdal::drivers::las::Reader reader(Support::datapath("1.2-with-color.las")); | ||
pdal::drivers::pgpointcloud::Writer writer(reader, getWriterOptions()); | ||
|
||
writer.initialize(); | ||
|
||
boost::uint64_t numPointsWritten = writer.write(0); | ||
BOOST_CHECK_EQUAL(numPointsWritten, 1065); | ||
} | ||
|
||
|
||
BOOST_AUTO_TEST_CASE(testNoPointcloudExtension) | ||
{ | ||
executeOnTestDb("DROP EXTENSION pointcloud"); | ||
|
||
pdal::drivers::las::Reader reader(Support::datapath("1.2-with-color.las")); | ||
pdal::drivers::pgpointcloud::Writer writer(reader, getWriterOptions()); | ||
|
||
writer.initialize(); | ||
|
||
BOOST_CHECK_THROW(writer.write(0), pdal::pdal_error); | ||
} | ||
|
||
|
||
BOOST_AUTO_TEST_SUITE_END() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/****************************************************************************** | ||
* Copyright (c) 2014, Peter J. Gadomski (pete.gadomski@gmail.com) | ||
* | ||
* 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. | ||
****************************************************************************/ | ||
|
||
#ifndef UNITTEST_DRIVERS_PGPOINTCLOUD_SUPPORT_INCLUDED | ||
#define UNITTEST_DRIVERS_PGPOINTCLOUD_SUPPORT_INCLUDED | ||
|
||
|
||
namespace pdal | ||
{ | ||
namespace drivers | ||
{ | ||
namespace pgpointcloud | ||
{ | ||
|
||
|
||
static const std::string testDbHost("@PGPOINTCLOUD_TEST_DB_HOST@"); | ||
static const std::string testDbPort("@PGPOINTCLOUD_TEST_DB_PORT@"); | ||
static const std::string testDbName("@PGPOINTCLOUD_TEST_DB_NAME@"); | ||
static const std::string testDbTempname("@PGPOINTCLOUD_TEST_DB_TEMPNAME@"); | ||
|
||
static const std::string testDbConn(std::string("dbname='@PGPOINTCLOUD_TEST_DB_NAME@' ") + | ||
"host='@PGPOINTCLOUD_TEST_DB_HOST@' port='@PGPOINTCLOUD_TEST_DB_PORT@'"); | ||
static const std::string testDbTempConn(std::string("dbname='@PGPOINTCLOUD_TEST_DB_TEMPNAME@'") + | ||
"host='@PGPOINTCLOUD_TEST_DB_HOST@' port='@PGPOINTCLOUD_TEST_DB_PORT@'"); | ||
|
||
|
||
} | ||
} | ||
} // namespace pdal::drivers::pgpointcloud | ||
|
||
|
||
#endif // UNITTEST_DRIVERS_PGPOINTCLOUD_SUPPORT_INCLUDED |