[Liblas-commits] hg-main-tree: oops, put those back

liblas-commits at liblas.org liblas-commits at liblas.org
Mon Jul 11 16:51:23 EDT 2011


details:   http://hg.libpc.orghg-main-tree/rev/12b27d73370d
changeset: 849:12b27d73370d
user:      Michael P. Gerlek <mpg at flaxen.com>
date:      Mon Jul 11 13:51:18 2011 -0700
description:
oops, put those back

diffstat:

 test/unit/LasWriterTest.cpp        |  194 ++++++++++++++++++
 test/unit/SpatialReferenceTest.cpp |  389 +++++++++++++++++++++++++++++++++++++
 2 files changed, 583 insertions(+), 0 deletions(-)

diffs (truncated from 591 to 300 lines):

diff -r bf1fb7ca3762 -r 12b27d73370d test/unit/LasWriterTest.cpp
--- a/test/unit/LasWriterTest.cpp	Mon Jul 11 13:39:02 2011 -0700
+++ b/test/unit/LasWriterTest.cpp	Mon Jul 11 13:51:18 2011 -0700
@@ -0,0 +1,194 @@
+/******************************************************************************
+* Copyright (c) 2011, Michael P. Gerlek (mpg at flaxen.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 <boost/cstdint.hpp>
+#include <boost/lexical_cast.hpp>
+#include <boost/uuid/uuid_io.hpp>
+#include <boost/concept_check.hpp>
+
+#include <pdal/drivers/faux/Reader.hpp>
+#include <pdal/drivers/las/Writer.hpp>
+#include <pdal/drivers/las/Reader.hpp>
+
+#include "Support.hpp"
+
+using namespace pdal;
+
+
+BOOST_AUTO_TEST_SUITE(LasWriterTest)
+
+BOOST_AUTO_TEST_CASE(test_simple_las)
+{
+    // remove file from earlier run, if needed
+    Utils::deleteFile("temp.las");
+
+    pdal::drivers::las::LasReader reader(Support::datapath("1.2-with-color.las"));
+    
+    std::ostream* ofs = Utils::createFile("temp.las");
+
+    {
+        const boost::uint64_t numPoints = reader.getNumPoints();
+
+        // need to scope the writer, so that's it dtor can use the stream
+        pdal::drivers::las::LasWriter writer(reader, *ofs);
+        BOOST_CHECK(writer.getDescription() == "Las Writer");
+
+        writer.setCompressed(false);
+        writer.setDate(0, 0);
+        writer.setPointFormat(::pdal::drivers::las::PointFormat3);
+        writer.setSystemIdentifier("");
+        writer.setGeneratingSoftware("TerraScan");
+
+        writer.write(numPoints);
+    }
+
+    Utils::closeFile(ofs);
+
+    bool filesSame = Support::compare_files("temp.las", Support::datapath("simple.las"));
+    BOOST_CHECK(filesSame);
+
+    if (filesSame)
+    {
+        Utils::deleteFile("temp.las");
+    }
+
+    return;
+}
+
+
+BOOST_AUTO_TEST_CASE(test_simple_laz)
+{
+    // remove file from earlier run, if needed
+    Utils::deleteFile("temp.laz");
+
+    pdal::drivers::las::LasReader reader(Support::datapath("1.2-with-color.las"));
+    
+    std::ostream* ofs = Utils::createFile("temp.laz");
+
+    {
+        const boost::uint64_t numPoints = reader.getNumPoints();
+
+        // need to scope the writer, so that's it dtor can use the stream
+        pdal::drivers::las::LasWriter writer(reader, *ofs);
+
+        writer.setCompressed(true);
+        writer.setDate(0, 0);
+        writer.setPointFormat(::pdal::drivers::las::PointFormat3);
+        writer.setSystemIdentifier("");
+        writer.setGeneratingSoftware("TerraScan");
+
+        writer.write(numPoints);
+    }
+
+    Utils::closeFile(ofs);
+
+    {
+        pdal::drivers::las::LasReader reader("temp.laz");
+    }
+
+    bool filesSame = Support::compare_files("temp.laz", Support::datapath("1.2-with-color.laz"));
+    BOOST_CHECK(filesSame);
+
+    if (filesSame)
+    {
+        Utils::deleteFile("temp.laz");
+    }
+
+    return;
+}
+
+
+static void test_a_format(const std::string& refFile, boost::uint8_t majorVersion, boost::uint8_t minorVersion, int pointFormat)
+{
+    // remove file from earlier run, if needed
+    Utils::deleteFile("temp.las");
+
+    pdal::drivers::las::LasReader reader(Support::datapath("1.2_3.las"));
+    
+    std::ostream* ofs = Utils::createFile("temp.las");
+
+    {
+        const boost::uint64_t numPoints = reader.getNumPoints();
+
+        // need to scope the writer, so that's it dtor can use the stream
+        pdal::drivers::las::LasWriter writer(reader, *ofs);
+        BOOST_CHECK(writer.getDescription() == "Las Writer");
+
+        writer.setCompressed(false);
+        writer.setDate(78, 2008);
+        writer.setPointFormat((::pdal::drivers::las::PointFormat)pointFormat);
+        writer.setFormatVersion(majorVersion, minorVersion);
+        writer.setSystemIdentifier("libLAS");
+        writer.setGeneratingSoftware("libLAS 1.2");
+        
+        boost::uuids::uuid u = boost::lexical_cast<boost::uuids::uuid>("8388f1b8-aa1b-4108-bca3-6bc68e7b062e");
+        writer.setProjectId(u);
+
+        writer.write(numPoints);
+    }
+
+    Utils::closeFile(ofs);
+
+    // BUG: the following test commented out as per ticket #35
+    boost::ignore_unused_variable_warning(refFile);
+    //const bool filesSame = Support::compare_files("temp.las", Support::datapath(refFile));
+    //BOOST_CHECK(filesSame);
+    //
+    //if (filesSame)
+    {
+        Utils::deleteFile("temp.las");
+    }
+
+    return;
+}
+
+BOOST_AUTO_TEST_CASE(test_different_formats)
+{
+    test_a_format("1.0_0.las", 1, 0, 0);
+    test_a_format("1.0_1.las", 1, 0, 1);
+    
+    test_a_format("1.1_0.las", 1, 1, 0);
+    test_a_format("1.1_1.las", 1, 1, 1);
+
+    test_a_format("1.2_0.las", 1, 2, 0);
+    test_a_format("1.2_1.las", 1, 2, 1);
+    test_a_format("1.2_2.las", 1, 2, 2);
+    test_a_format("1.2_3.las", 1, 2, 3);
+
+    return;
+}
+
+
+BOOST_AUTO_TEST_SUITE_END()
diff -r bf1fb7ca3762 -r 12b27d73370d test/unit/SpatialReferenceTest.cpp
--- a/test/unit/SpatialReferenceTest.cpp	Mon Jul 11 13:39:02 2011 -0700
+++ b/test/unit/SpatialReferenceTest.cpp	Mon Jul 11 13:51:18 2011 -0700
@@ -0,0 +1,389 @@
+/******************************************************************************
+* Copyright (c) 2011, Michael P. Gerlek (mpg at flaxen.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/SpatialReference.hpp>
+#include <pdal/Utils.hpp>
+#include <pdal/drivers/las/VariableLengthRecord.hpp>
+#include <pdal/drivers/las/Writer.hpp>
+#include <pdal/drivers/las/Reader.hpp>
+
+#include "Support.hpp"
+
+BOOST_AUTO_TEST_SUITE(SpatialReferenceTest)
+
+#ifdef PDAL_SRS_ENABLED
+
+BOOST_AUTO_TEST_CASE(test_env_vars)
+{
+    
+#ifdef _MSC_VER
+    const char* gdal_data = getenv("GDAL_DATA");
+    const char* proj_lib = getenv("PROJ_LIB");
+
+    BOOST_CHECK(pdal::Utils::fileExists(gdal_data));
+    BOOST_CHECK(pdal::Utils::fileExists(proj_lib));
+#endif
+    return;
+}
+
+
+BOOST_AUTO_TEST_CASE(test_ctor)
+{
+    pdal::SpatialReference srs;
+
+    BOOST_CHECK(srs.getProj4() == "");
+    BOOST_CHECK(srs.getWKT() == "");
+
+    return;
+}
+
+
+// Test round-tripping proj.4 string
+BOOST_AUTO_TEST_CASE(test_proj4_roundtrip)
+{
+    const std::string proj4 = "+proj=utm +zone=15 +datum=WGS84 +units=m +no_defs";
+    const std::string proj4_ellps = "+proj=utm +zone=15 +ellps=WGS84 +datum=WGS84 +units=m +no_defs";
+    const std::string proj4_out = "+proj=utm +zone=15 +ellps=WGS84 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs";
+
+    {
+        pdal::SpatialReference ref;
+        ref.setProj4(proj4);
+        const std::string ret = ref.getProj4();
+        //BOOST_CHECK(ret == proj4);
+        BOOST_CHECK(ret == proj4_out);
+    }
+
+    {
+        pdal::SpatialReference ref;
+        ref.setProj4(proj4_ellps);
+        const std::string ret = ref.getProj4();
+        //BOOST_CHECK(ret == proj4);
+        BOOST_CHECK(ret == proj4_out);
+    }
+
+    {
+        pdal::SpatialReference ref;


More information about the Liblas-commits mailing list