[Liblas-commits] hg-main-tree: added simpler API for diffing

liblas-commits at liblas.org liblas-commits at liblas.org
Fri Aug 12 18:20:05 EDT 2011


details:   http://hg.libpc.orghg-main-tree/rev/1aa020b0888e
changeset: 1080:1aa020b0888e
user:      Michael P. Gerlek <mpg at flaxen.com>
date:      Fri Aug 12 15:18:26 2011 -0700
description:
added simpler API for diffing
Subject: hg-main-tree: account for 32 bytes of difference in the VLR header

details:   http://hg.libpc.orghg-main-tree/rev/6f79091eda96
changeset: 1081:6f79091eda96
user:      Michael P. Gerlek <mpg at flaxen.com>
date:      Fri Aug 12 15:19:20 2011 -0700
description:
account for 32 bytes of difference in the VLR header
Subject: hg-main-tree: merge

details:   http://hg.libpc.orghg-main-tree/rev/42ca3de11d81
changeset: 1082:42ca3de11d81
user:      Michael P. Gerlek <mpg at flaxen.com>
date:      Fri Aug 12 15:19:44 2011 -0700
description:
merge

diffstat:

 src/drivers/oci/Writer.cpp  |  41 ++++++++++++++++++++++-------------------
 test/unit/LasWriterTest.cpp |  10 ++++++----
 test/unit/Support.cpp       |   9 +++++++++
 test/unit/Support.hpp       |  14 ++++++--------
 4 files changed, 43 insertions(+), 31 deletions(-)

diffs (119 lines):

diff -r b0db3059a611 -r 42ca3de11d81 src/drivers/oci/Writer.cpp
--- a/src/drivers/oci/Writer.cpp	Fri Aug 12 14:44:07 2011 -0700
+++ b/src/drivers/oci/Writer.cpp	Fri Aug 12 15:19:44 2011 -0700
@@ -759,29 +759,32 @@
 
     std::ostringstream wkt_s;
 
-    if (!FileUtils::fileExists(base_table_boundary_wkt))
+    if (!base_table_boundary_column.empty())
     {
-        if (!IsValidWKT(base_table_boundary_wkt))
+        if (!FileUtils::fileExists(base_table_boundary_wkt))
         {
-            std::ostringstream oss;
-            oss << "WKT for base_table_boundary_wkt was not valid and '" << base_table_boundary_wkt
-                << "' doesn't exist as a file";
-            throw pdal::pdal_error(oss.str());
-        }        
-        wkt_s << base_table_boundary_wkt;
-    } else {
-        std::cout << "loading: " << base_table_boundary_wkt << std::endl;
-        std::string wkt = LoadSQLData(base_table_boundary_wkt);
-        if (!IsValidWKT(wkt))
-        {
-            std::ostringstream oss;
-            oss << "WKT for base_table_boundary_wkt was from file '" << base_table_boundary_wkt 
-                << "' is not valid";
-            throw pdal::pdal_error(oss.str());
+            if (!IsValidWKT(base_table_boundary_wkt))
+            {
+                std::ostringstream oss;
+                oss << "WKT for base_table_boundary_wkt was not valid and '" << base_table_boundary_wkt
+                    << "' doesn't exist as a file";
+                throw pdal::pdal_error(oss.str());
+            }
+            wkt_s << base_table_boundary_wkt;
+        } else {
+            std::cout << "loading: " << base_table_boundary_wkt << std::endl;
+            std::string wkt = LoadSQLData(base_table_boundary_wkt);
+            if (!IsValidWKT(wkt))
+            {
+                std::ostringstream oss;
+                oss << "WKT for base_table_boundary_wkt was from file '" << base_table_boundary_wkt 
+                    << "' is not valid";
+                throw pdal::pdal_error(oss.str());
+            }
+            wkt_s << wkt;
         }
-        wkt_s << wkt;
     }
-    
+
     std::string wkt_string = wkt_s.str();
     char* wkt = (char*) malloc(wkt_string.size() * sizeof(char)+1);
     strncpy(wkt, wkt_string.c_str(), wkt_string.size());
diff -r b0db3059a611 -r 42ca3de11d81 test/unit/LasWriterTest.cpp
--- a/test/unit/LasWriterTest.cpp	Fri Aug 12 14:44:07 2011 -0700
+++ b/test/unit/LasWriterTest.cpp	Fri Aug 12 15:19:44 2011 -0700
@@ -123,11 +123,13 @@
         pdal::drivers::las::LasReader reader(Support::temppath("LasWriterTest_test_simple_laz.laz"));
     }
 
-    bool filesSame = Support::compare_files(Support::temppath("LasWriterTest_test_simple_laz.laz"), 
-                                            Support::datapath("laszip/laszip-generated.laz"));
-    BOOST_CHECK(filesSame);
+    // these two files only differ by the description string in the VLR
+    const boost::uint32_t numdiffs = Support::diff_files(Support::temppath("LasWriterTest_test_simple_laz.laz"),
+                                                         Support::datapath("laszip/laszip-generated.laz"),
+                                                         249, 32);
+    BOOST_CHECK(numdiffs==0);
 
-    if (filesSame)
+    if (numdiffs==0)
     {
         FileUtils::deleteFile(Support::temppath("LasWriterTest_test_simple_laz.laz"));
     }
diff -r b0db3059a611 -r 42ca3de11d81 test/unit/Support.cpp
--- a/test/unit/Support.cpp	Fri Aug 12 14:44:07 2011 -0700
+++ b/test/unit/Support.cpp	Fri Aug 12 15:19:44 2011 -0700
@@ -217,6 +217,15 @@
 }
 
 
+boost::uint32_t Support::diff_files(const std::string& file1, const std::string& file2,
+                                    boost::uint32_t ignorable_start, boost::uint32_t ignorable_length)
+{
+    boost::uint32_t start[] = { ignorable_start };
+    boost::uint32_t len[] = { ignorable_length };
+    return diff_files(file1, file2, start, len, 1);
+}
+
+
 // do a byte-wise comparison of two (binary) files
 boost::uint32_t Support::diff_files(const std::string& file1, const std::string& file2,
                                     boost::uint32_t* ignorable_start, boost::uint32_t* ignorable_length, boost::uint32_t num_ignorables)
diff -r b0db3059a611 -r 42ca3de11d81 test/unit/Support.hpp
--- a/test/unit/Support.hpp	Fri Aug 12 14:44:07 2011 -0700
+++ b/test/unit/Support.hpp	Fri Aug 12 15:19:44 2011 -0700
@@ -80,14 +80,12 @@
     // returns number of bytes different for two binary files (or maxint if a file doesn't exist)
     static boost::uint32_t diff_files(const std::string& file1, const std::string& file2);
 
-    // same as diff_files, but allows for regions of the file be to be ignored
-    //
-    // ignorable_start/length are arrays of byte-offsets and byte-lengths,
-    // for regions in the file we wish to NOT do the comparison on.  (We are 
-    // assuming such an ignorable region exists with the same length in both 
-    // files, such as would be the case if an embedded version number in two
-    // LAS files was different.)  The number of ignorable regions is set
-    // via num_ignorables.
+    // same as diff_files, but allows for a region of the file be to be ignored
+    // (region is specified with a starting offset and a length)
+    static boost::uint32_t diff_files(const std::string& file1, const std::string& file2,
+                                      boost::uint32_t ignorable_start, boost::uint32_t ignorable_length);
+
+    // same as above diff_files with ignorable region, but for multiple regions
     static boost::uint32_t diff_files(const std::string& file1, const std::string& file2,
                                       boost::uint32_t* ignorable_start, boost::uint32_t* ignorable_length, boost::uint32_t num_ignorables);
 


More information about the Liblas-commits mailing list