[Liblas-commits] hg-main-tree: only try to set the srs if we have one

liblas-commits at liblas.org liblas-commits at liblas.org
Wed Apr 27 15:32:08 EDT 2011


details:   http://hg.libpc.orghg-main-tree/rev/b6eb4612a26e
changeset: 684:b6eb4612a26e
user:      Howard Butler <hobu.inc at gmail.com>
date:      Wed Apr 27 14:31:54 2011 -0500
description:
only try to set the srs if we have one
Subject: hg-main-tree: merge

details:   http://hg.libpc.orghg-main-tree/rev/4e0890c40838
changeset: 685:4e0890c40838
user:      Howard Butler <hobu.inc at gmail.com>
date:      Wed Apr 27 14:32:02 2011 -0500
description:
merge

diffstat:

 apps/pc2pc.cpp                                     |    7 +-
 apps/pcinfo.cpp                                    |    8 +-
 include/libpc/SpatialReference.hpp                 |    3 +
 include/libpc/drivers/las/VariableLengthRecord.hpp |    9 +-
 include/libpc/filters/ScalingFilter.hpp            |   84 +++++++++
 include/libpc/filters/ScalingFilterIterator.hpp    |   62 ++++++
 src/CMakeLists.txt                                 |    4 +
 src/SpatialReference.cpp                           |    8 +
 src/Utils.cpp                                      |    5 +-
 src/drivers/las/LasHeaderWriter.cpp                |    3 +-
 src/drivers/las/LasHeaderWriter.hpp                |    5 +
 src/drivers/las/Reader.cpp                         |    2 +
 src/drivers/las/VariableLengthRecord.cpp           |    8 +-
 src/filters/ScalingFilter.cpp                      |  188 +++++++++++++++++++++
 src/filters/ScalingFilterIterator.cpp              |   72 ++++++++
 test/data/1.0_0.las                                |    0 
 test/data/1.0_0_nosrs.las                          |    0 
 test/data/1.0_1.las                                |    0 
 test/data/1.0_1_nosrs.las                          |    0 
 test/data/1.1_0.las                                |    0 
 test/data/1.1_0_nosrs.las                          |    0 
 test/data/1.1_1.las                                |    0 
 test/data/1.1_1_nosrs.las                          |    0 
 test/data/1.2_0.las                                |    0 
 test/data/1.2_0_nosrs.las                          |    0 
 test/data/1.2_1.las                                |    0 
 test/data/1.2_1_nosrs.las                          |    0 
 test/data/1.2_2.las                                |    0 
 test/data/1.2_2_nosrs.las                          |    0 
 test/data/1.2_3.las                                |    0 
 test/data/1.2_3_nosrs.las                          |    0 
 test/unit/LasWriterTest.cpp                        |    6 +-
 test/unit/LiblasWriterTest.cpp                     |   22 +-
 test/unit/SpatialReferenceTest.cpp                 |   31 +++-
 test/unit/Support.cpp                              |    4 +
 35 files changed, 498 insertions(+), 33 deletions(-)

diffs (truncated from 821 to 300 lines):

diff -r 28435427ec55 -r 4e0890c40838 apps/pc2pc.cpp
--- a/apps/pc2pc.cpp	Wed Apr 27 10:54:30 2011 -0700
+++ b/apps/pc2pc.cpp	Wed Apr 27 14:32:02 2011 -0500
@@ -187,8 +187,11 @@
         if (hasOption("a_srs"))
         {
             libpc::SpatialReference ref;
-            ref.setFromUserInput(m_srs);
-            writer.setSpatialReference(ref);            
+            if (m_srs.size() > 0)
+            {
+                ref.setFromUserInput(m_srs);
+                writer.setSpatialReference(ref);                            
+            }
         }
         if (hasOption("compress"))
         {
diff -r 28435427ec55 -r 4e0890c40838 apps/pcinfo.cpp
--- a/apps/pcinfo.cpp	Wed Apr 27 10:54:30 2011 -0700
+++ b/apps/pcinfo.cpp	Wed Apr 27 14:32:02 2011 -0500
@@ -111,12 +111,14 @@
         return 1;
     }
 
-    boost::uint64_t numPoints = reader->getNumPoints();
+    const boost::uint64_t numPoints = reader->getNumPoints();
+    const SpatialReference& srs = reader->getSpatialReference();
+
+    std::cout << numPoints << " points\n";
+    std::cout << "WKT: " << srs.getWKT() << "\n";
 
     delete reader;
 
-    std::cout << numPoints << " points\n";
-
     return 0;
 }
 
diff -r 28435427ec55 -r 4e0890c40838 include/libpc/SpatialReference.hpp
--- a/include/libpc/SpatialReference.hpp	Wed Apr 27 10:54:30 2011 -0700
+++ b/include/libpc/SpatialReference.hpp	Wed Apr 27 14:32:02 2011 -0500
@@ -54,6 +54,9 @@
     /// Default constructor.
     SpatialReference();
 
+    // calls setFromUserInput() with the given string
+    SpatialReference(const std::string& userInput);
+
     /// Destructor.
     /// If libgeotiff is enabled, deallocates libtiff and libgeotiff objects used internally.
     ~SpatialReference();
diff -r 28435427ec55 -r 4e0890c40838 include/libpc/drivers/las/VariableLengthRecord.hpp
--- a/include/libpc/drivers/las/VariableLengthRecord.hpp	Wed Apr 27 10:54:30 2011 -0700
+++ b/include/libpc/drivers/las/VariableLengthRecord.hpp	Wed Apr 27 14:32:02 2011 -0500
@@ -40,9 +40,8 @@
 #include <string>
 #include <vector>
 
-namespace libpc {
-    class SpatialReference;
-}
+#include <libpc/SpatialReference.hpp>
+
 
 namespace libpc { namespace drivers { namespace las {
     
@@ -85,7 +84,7 @@
     static const int s_headerLength = 54;
 
     static void setSRSFromVLRs(const std::vector<VariableLengthRecord>& vlrs, SpatialReference& srs);
-    static void setVLRsFromSRS(const SpatialReference& srs, std::vector<VariableLengthRecord>& vlrs);
+    static void setVLRsFromSRS(const SpatialReference& srs, std::vector<VariableLengthRecord>& vlrs, SpatialReference::WKTModeFlag modeFlag);
 
     static std::string bytes2string(const boost::uint8_t* bytes, boost::uint32_t len);
 
@@ -121,7 +120,7 @@
     boost::uint32_t count() const;
 
     void constructSRS(SpatialReference&) const;
-    void addVLRsFromSRS(const SpatialReference& srs);
+    void addVLRsFromSRS(const SpatialReference& srs, SpatialReference::WKTModeFlag modeFlag);
 
 private:
    std::vector<VariableLengthRecord> m_list;
diff -r 28435427ec55 -r 4e0890c40838 include/libpc/filters/ScalingFilter.hpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/include/libpc/filters/ScalingFilter.hpp	Wed Apr 27 14:32:02 2011 -0500
@@ -0,0 +1,84 @@
+/******************************************************************************
+* 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.
+****************************************************************************/
+
+#ifndef INCLUDED_FILTERS_SCALINGFILTER_HPP
+#define INCLUDED_FILTERS_SCALINGFILTER_HPP
+
+#include <libpc/libpc.hpp>
+
+#include <boost/shared_ptr.hpp>
+
+#include <libpc/Filter.hpp>
+
+namespace libpc
+{
+    class PointBuffer;
+}
+
+namespace libpc { namespace filters {
+
+class ScalingFilterSequentialIterator;
+
+class LIBPC_DLL ScalingFilter : public Filter
+{
+public:
+    ScalingFilter(const Stage& prevStage);
+
+    const std::string& getDescription() const;
+    const std::string& getName() const;
+
+    bool supportsIterator (StageIteratorType t) const
+    {   
+        if (t == StageIterator_Sequential ) return true;
+
+        return false;
+    }
+
+    libpc::SequentialIterator* createSequentialIterator() const;
+    libpc::RandomIterator* createRandomIterator() const { return NULL; }
+
+    void processBuffer(PointBuffer& data) const;
+
+private:
+    void checkImpedance();
+    void initialize();
+
+    ScalingFilter& operator=(const ScalingFilter&); // not implemented
+    ScalingFilter(const ScalingFilter&); // not implemented
+};
+
+
+} } // namespaces
+
+#endif
diff -r 28435427ec55 -r 4e0890c40838 include/libpc/filters/ScalingFilterIterator.hpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/include/libpc/filters/ScalingFilterIterator.hpp	Wed Apr 27 14:32:02 2011 -0500
@@ -0,0 +1,62 @@
+/******************************************************************************
+* 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.
+****************************************************************************/
+
+#ifndef INCLUDED_FILTERS_SCALINGFILTERITERATOR_HPP
+#define INCLUDED_FILTERS_SCALINGFILTERITERATOR_HPP
+
+#include <libpc/libpc.hpp>
+
+#include <libpc/filters/ScalingFilter.hpp>
+#include <libpc/FilterIterator.hpp>
+
+namespace libpc { namespace filters {
+
+
+class ScalingFilterSequentialIterator : public libpc::FilterSequentialIterator
+{
+public:
+    ScalingFilterSequentialIterator(const ScalingFilter& filter);
+
+private:
+    boost::uint64_t skipImpl(boost::uint64_t);
+    boost::uint32_t readImpl(PointBuffer&);
+    bool atEndImpl() const;
+
+    const ScalingFilter& m_scalingFilter;
+};
+
+
+} } // namespaces
+
+#endif
diff -r 28435427ec55 -r 4e0890c40838 src/CMakeLists.txt
--- a/src/CMakeLists.txt	Wed Apr 27 10:54:30 2011 -0700
+++ b/src/CMakeLists.txt	Wed Apr 27 14:32:02 2011 -0500
@@ -246,6 +246,8 @@
   ${LIBPC_HEADERS_DIR}/filters/MosaicFilterIterator.hpp
   ${LIBPC_HEADERS_DIR}/filters/ReprojectionFilter.hpp
   ${LIBPC_HEADERS_DIR}/filters/ReprojectionFilterIterator.hpp
+  ${LIBPC_HEADERS_DIR}/filters/ScalingFilter.hpp
+  ${LIBPC_HEADERS_DIR}/filters/ScalingFilterIterator.hpp
 )
 
 set (LIBPC_FILTERS_CPP 
@@ -263,6 +265,8 @@
   ./filters/MosaicFilterIterator.cpp
   ./filters/ReprojectionFilter.cpp
   ./filters/ReprojectionFilterIterator.cpp
+  ./filters/ScalingFilter.cpp
+  ./filters/ScalingFilterIterator.cpp
 )
 
 FOREACH(file ${LIBPC_FILTERS_HPP})
diff -r 28435427ec55 -r 4e0890c40838 src/SpatialReference.cpp
--- a/src/SpatialReference.cpp	Wed Apr 27 10:54:30 2011 -0700
+++ b/src/SpatialReference.cpp	Wed Apr 27 14:32:02 2011 -0500
@@ -52,6 +52,14 @@
 }
 
 
+SpatialReference::SpatialReference(const std::string& s)
+    : m_wkt("")
+{
+    this->setFromUserInput(s);
+    return;
+}
+
+
 SpatialReference::SpatialReference(SpatialReference const& rhs) 
     : m_wkt(rhs.m_wkt)
 {
diff -r 28435427ec55 -r 4e0890c40838 src/Utils.cpp
--- a/src/Utils.cpp	Wed Apr 27 10:54:30 2011 -0700
+++ b/src/Utils.cpp	Wed Apr 27 14:32:02 2011 -0500
@@ -143,7 +143,10 @@
 
 bool Utils::deleteFile(const std::string& file)
 {
-  return boost::filesystem::remove(file);
+    if (!fileExists(file))
+        return false;
+        
+    return boost::filesystem::remove(file);
 }
 
 
diff -r 28435427ec55 -r 4e0890c40838 src/drivers/las/LasHeaderWriter.cpp
--- a/src/drivers/las/LasHeaderWriter.cpp	Wed Apr 27 10:54:30 2011 -0700
+++ b/src/drivers/las/LasHeaderWriter.cpp	Wed Apr 27 14:32:02 2011 -0500
@@ -55,6 +55,7 @@
 LasHeaderWriter::LasHeaderWriter(LasHeader& header, std::ostream& ostream)
     : m_header(header)
     , m_ostream(ostream)
+    , m_wktModeFlag(SpatialReference::eCompoundOK)


More information about the Liblas-commits mailing list