[Liblas-commits] hg: 2 new changesets

liblas-commits at liblas.org liblas-commits at liblas.org
Tue Oct 5 18:02:12 EDT 2010


changeset 5916faed67e6 in /Volumes/Data/www/liblas.org/hg
details: http://hg.liblas.orghg?cmd=changeset;node=5916faed67e6
summary: Replaced std::map with boost::unordered_map for DimensionMap and SizesMap. The use case is purely lookup-oriented and unordered_map promises O(1), on average better than logarithmic std::map lookup. Tests on of optimised CMAKE_BUILD_TYPE=Release on Linux 64-bit have confirmed 50% speed increase. It is 3-4 sec of absolute time versus 6-7sec measured for std::map-based version. Note, C++0x includes std::unordered_map container as part of C++ Standard Library.

changeset b1f8f5367a6b in /Volumes/Data/www/liblas.org/hg
details: http://hg.liblas.orghg?cmd=changeset;node=b1f8f5367a6b
summary: merge

diffstat:

 include/liblas/capi/liblas.h           |  19 ++-----------------
 include/liblas/detail/writer/point.hpp |   3 ---
 include/liblas/lasschema.hpp           |  10 ++++------
 python/liblas/core.py                  |  11 -----------
 python/liblas/schema.py                |  11 -----------
 python/tests/Schema.txt                |  15 +--------------
 src/detail/writer/point.cpp            |   2 --
 src/las_c_api.cpp                      |  15 ---------------
 src/lasschema.cpp                      |  31 -------------------------------
 9 files changed, 7 insertions(+), 110 deletions(-)

diffs (235 lines):

diff -r ea9e540044c0 -r b1f8f5367a6b include/liblas/capi/liblas.h
--- a/include/liblas/capi/liblas.h	Tue Oct 05 13:00:53 2010 -0500
+++ b/include/liblas/capi/liblas.h	Tue Oct 05 23:01:58 2010 +0100
@@ -1154,24 +1154,9 @@
 */
 LAS_DLL void LASString_Free(char* string);
 
-LAS_DLL LASSchemaH LASSchema_Create(  unsigned char version_major,
-                                                unsigned char version_minor,
-                                                unsigned int size,
-                                                unsigned char bHasColor,
-                                                unsigned char bHasTime);
+LAS_DLL unsigned short LASSchema_GetByteSize( LASSchemaH hFormat);
+LAS_DLL unsigned short LASSchema_GetBaseByteSize( LASSchemaH hFormat);
 
-LAS_DLL unsigned char LASSchema_GetVersionMinor( LASSchemaH hFormat);
-LAS_DLL LASError LASSchema_SetVersionMinor( LASSchemaH hFormat, unsigned char nMinor);
-LAS_DLL unsigned char LASSchema_GetMajorVersion( LASSchemaH hFormat);
-LAS_DLL LASError LASSchema_SetVersionMinor( LASSchemaH hFormat, unsigned char nMajor);
-LAS_DLL unsigned char LASSchema_HasColor( LASSchemaH hFormat);
-LAS_DLL LASError LASSchema_SetColor( LASSchemaH hFormat, unsigned char bColor);
-LAS_DLL unsigned char LASSchema_HasTime( LASSchemaH hFormat);
-LAS_DLL LASError LASSchema_SetTime( LASSchemaH hFormat, unsigned char bTime);
-LAS_DLL unsigned short LASSchema_GetByteSize( LASSchemaH hFormat);
-LAS_DLL LASError LASSchema_SetByteSize( LASSchemaH hFormat, unsigned short size);
-LAS_DLL unsigned short LASSchema_GetBaseByteSize( LASSchemaH hFormat);
-LAS_DLL LASError LASSchema_SetBaseByteSize( LASSchemaH hFormat, unsigned short size);
 
 
 LAS_DLL LASSchemaH LASHeader_GetSchema( LASHeaderH hHeader );
diff -r ea9e540044c0 -r b1f8f5367a6b include/liblas/detail/writer/point.hpp
--- a/include/liblas/detail/writer/point.hpp	Tue Oct 05 13:00:53 2010 -0500
+++ b/include/liblas/detail/writer/point.hpp	Tue Oct 05 23:01:58 2010 +0100
@@ -89,9 +89,6 @@
     
     std::vector<boost::uint8_t> m_blanks; 
 
-    bool bTime;
-    bool bColor;
-        
     void setup();
     // void fill();
 };
diff -r ea9e540044c0 -r b1f8f5367a6b include/liblas/lasschema.hpp
--- a/include/liblas/lasschema.hpp	Tue Oct 05 13:00:53 2010 -0500
+++ b/include/liblas/lasschema.hpp	Tue Oct 05 23:01:58 2010 +0100
@@ -59,18 +59,19 @@
 #include <string>
 #include <vector>
 #include <algorithm>
-#include <map>
+#include <boost/unordered_map.hpp>
 
 namespace liblas {  
 
 class Dimension;
+
 typedef boost::shared_ptr<Dimension> DimensionPtr;
-typedef std::map<std::string, DimensionPtr> DimensionMap;
+typedef boost::unordered_map<std::string, DimensionPtr> DimensionMap;
 
 typedef std::vector<DimensionPtr> DimensionArray;
 
 typedef boost::array<std::size_t, 4> SizesArray;
-typedef std::map<std::string, SizesArray > SizesMap;
+typedef boost::unordered_map<std::string, SizesArray> SizesMap;
 
 class Schema
 {
@@ -97,9 +98,6 @@
     PointFormatName GetDataFormatId() const { return m_data_format_id; }
     void SetDataFormatId(PointFormatName const& value);
     
-    bool HasColor() const;
-    bool HasTime() const; 
-    
     void AddDimension(DimensionPtr dim);
     DimensionPtr GetDimension(std::string const& name) const;
     // DimensionPtr GetDimension(std::size_t index) const;
diff -r ea9e540044c0 -r b1f8f5367a6b python/liblas/core.py
--- a/python/liblas/core.py	Tue Oct 05 13:00:53 2010 -0500
+++ b/python/liblas/core.py	Tue Oct 05 23:01:58 2010 +0100
@@ -747,17 +747,6 @@
 las.LASSchema_GetByteSize.errcheck = check_value
 
 
-
-las.LASSchema_HasColor.restype = ctypes.c_uint8
-las.LASSchema_HasColor.argtypes = [ctypes.c_void_p]
-las.LASSchema_HasColor.errcheck = check_value
-
-
-las.LASSchema_HasTime.restype = ctypes.c_uint8
-las.LASSchema_HasTime.argtypes = [ctypes.c_void_p]
-las.LASSchema_HasTime.errcheck = check_value
-
-
 las.LASSchema_Destroy.argtypes = [ctypes.c_void_p]
 las.LASSchema_Destroy.errcheck = check_void_done
 las.LASSchema_Destroy.restype = None
diff -r ea9e540044c0 -r b1f8f5367a6b python/liblas/schema.py
--- a/python/liblas/schema.py	Tue Oct 05 13:00:53 2010 -0500
+++ b/python/liblas/schema.py	Tue Oct 05 23:01:58 2010 +0100
@@ -102,14 +102,3 @@
     size = property(get_size, set_size, None, doc)
 
 
-    def get_color(self):
-        return bool(core.las.LASSchema_HasColor(self.handle))
-
-    doc = """Does this format have color information"""
-    color = property(get_color, None, None, doc)
-
-    def get_time(self):
-        return bool(core.las.LASSchema_HasTime(self.handle))
-
-    doc = """Does this format have time information"""
-    time = property(get_time, None, None, doc)
diff -r ea9e540044c0 -r b1f8f5367a6b python/tests/Schema.txt
--- a/python/tests/Schema.txt	Tue Oct 05 13:00:53 2010 -0500
+++ b/python/tests/Schema.txt	Tue Oct 05 23:01:58 2010 +0100
@@ -8,11 +8,6 @@
   >>> f = schema.Schema()
   >>> f.size
   20
-  >>> f.color
-  False
-  >>> f.time
-  False
-
   
 
   >>> h = f2.header
@@ -23,12 +18,7 @@
   
   >>> f.size
   28
-  
-  >>> f.color
-  False
-  
-  >>> f.time
-  True
+
   
   >>> h = header.Header()
   >>> f = h.schema
@@ -37,9 +27,6 @@
   >>> f.size
   34
 
-  >>> f.time
-  True 
-    
 
 
   >>> h.schema = f
diff -r ea9e540044c0 -r b1f8f5367a6b src/detail/writer/point.cpp
--- a/src/detail/writer/point.cpp	Tue Oct 05 13:00:53 2010 -0500
+++ b/src/detail/writer/point.cpp	Tue Oct 05 23:01:58 2010 +0100
@@ -60,8 +60,6 @@
     , m_ofs(ofs)
     , m_header(header)
     , m_format(header->GetSchema())
-    , bTime(header->GetSchema().HasTime())
-    , bColor(header->GetSchema().HasColor())
 {
     setup();
 }
diff -r ea9e540044c0 -r b1f8f5367a6b src/las_c_api.cpp
--- a/src/las_c_api.cpp	Tue Oct 05 13:00:53 2010 -0500
+++ b/src/las_c_api.cpp	Tue Oct 05 23:01:58 2010 +0100
@@ -2010,21 +2010,6 @@
     return (LASSchemaH) schema;
 }
 
-LAS_DLL boost::uint8_t LASSchema_HasColor( LASSchemaH hFormat)
-{
-    VALIDATE_LAS_POINTER1(hFormat, "LASSchema_HasColor", 0);
-    
-    return static_cast<int>(((liblas::Schema*) hFormat)->HasColor());    
-}
-
-
-LAS_DLL boost::uint8_t LASSchema_HasTime( LASSchemaH hFormat)
-{
-    VALIDATE_LAS_POINTER1(hFormat, "LASSchema_HasTime", 0);
-    
-    return static_cast<int>(((liblas::Schema*) hFormat)->HasTime());    
-}
-
 
 LAS_DLL boost::uint16_t LASSchema_GetByteSize( LASSchemaH hFormat)
 {
diff -r ea9e540044c0 -r b1f8f5367a6b src/lasschema.cpp
--- a/src/lasschema.cpp	Tue Oct 05 13:00:53 2010 -0500
+++ b/src/lasschema.cpp	Tue Oct 05 23:01:58 2010 +0100
@@ -792,37 +792,6 @@
 }
 
 
-bool Schema::HasColor() const
-{
-    DimensionPtr c;
-    try {
-        c = GetDimension("Red");
-        c = GetDimension("Green");
-        c = GetDimension("Blue");
-    } catch (std::runtime_error const& e) {
-        boost::ignore_unused_variable_warning(e);
-        return false;
-    }
-    
-    return true;
-    
-}
-
-bool Schema::HasTime() const
-{
-    DimensionPtr c;
-    try {
-        c = GetDimension("Time");
-    } catch (std::runtime_error const& e) {
-        boost::ignore_unused_variable_warning(e);
-        return false;
-    }
-    
-    return true;
-    
-}
-
-
 
 VariableRecord Schema::GetVLR() const
 {


More information about the Liblas-commits mailing list