[Liblas-commits] r987 - in trunk: include/liblas
include/liblas/detail src test/unit
liblas-commits at liblas.org
liblas-commits at liblas.org
Tue Feb 3 09:59:22 EST 2009
Author: mloskot
Date: Tue Feb 3 09:59:22 2009
New Revision: 987
URL: http://liblas.org/changeset/987
Log:
Fixed #87 - implemented support for reading/writing "Point Source ID" - attribute of point record defined in LAS 1.0.
The new LASPoint accessors operating on Point Source ID play dual role, for LAS 1.0 they get/set User Bit Field but for LAS 1.1 - Point Source ID.
Modified:
trunk/include/liblas/detail/utility.hpp
trunk/include/liblas/laspoint.hpp
trunk/src/laspoint.cpp
trunk/src/lasreader.cpp
trunk/src/laswriter.cpp
trunk/test/unit/common.cpp
Modified: trunk/include/liblas/detail/utility.hpp
==============================================================================
--- trunk/include/liblas/detail/utility.hpp (original)
+++ trunk/include/liblas/detail/utility.hpp Tue Feb 3 09:59:22 2009
@@ -189,8 +189,8 @@
uint8_t flags; // TODO: Replace with portable std::bitset<8>
uint8_t classification;
int8_t scan_angle_rank;
- uint8_t user_data;
- uint16_t point_source_id;
+ uint8_t user_data; // 1.0: File Marker / 1.1: User Data
+ uint16_t point_source_id; // 1.0: User Bit field / 1.1: Point Source ID
};
template <typename T>
Modified: trunk/include/liblas/laspoint.hpp
==============================================================================
--- trunk/include/liblas/laspoint.hpp (original)
+++ trunk/include/liblas/laspoint.hpp Tue Feb 3 09:59:22 2009
@@ -54,8 +54,6 @@
/// Definition of point data record.
///
-/// \todo TODO: Think about last 1-byte field in record Point Source ID (LAS 1.1)
-///
class LASPoint
{
public:
@@ -134,8 +132,17 @@
int8_t GetScanAngleRank() const;
void SetScanAngleRank(int8_t const& rank);
+ /// Fetch value of File Marker (LAS 1.0) or User Data (LAS 1.1).
uint8_t GetUserData() const;
+
+ /// Set value of File Marker (LAS 1.0) or User Data (LAS 1.1).
void SetUserData(uint8_t const& data);
+
+ /// Fetch value of User Bit Field (LAS 1.0) or Point Source ID (LAS 1.1).
+ uint16_t GetPointSourceID() const;
+
+ /// Set value of User Bit Field (LAS 1.0) or Point Source ID (LAS 1.1).
+ void SetPointSourceID(uint16_t const& id);
double GetTime() const;
void SetTime(double const& time);
@@ -158,6 +165,7 @@
uint8_t m_class;
int8_t m_angleRank;
uint8_t m_userData;
+ uint16_t m_pointSourceId;
double m_gpsTime;
void throw_out_of_range() const
@@ -279,6 +287,16 @@
return m_userData;
}
+inline uint16_t LASPoint::GetPointSourceID() const
+{
+ return m_pointSourceId;
+}
+
+inline void LASPoint::SetPointSourceID(uint16_t const& id)
+{
+ m_pointSourceId = id;
+}
+
inline double LASPoint::GetTime() const
{
return m_gpsTime;
Modified: trunk/src/laspoint.cpp
==============================================================================
--- trunk/src/laspoint.cpp (original)
+++ trunk/src/laspoint.cpp Tue Feb 3 09:59:22 2009
@@ -50,17 +50,25 @@
namespace liblas {
LASPoint::LASPoint() :
- m_intensity(0), m_flags(0), m_class(0),
- m_angleRank(0), m_userData(0), m_gpsTime(0)
+ m_intensity(0),
+ m_flags(0),
+ m_class(0),
+ m_angleRank(0),
+ m_userData(0),
+ m_pointSourceId(0),
+ m_gpsTime(0)
{
std::memset(m_coords, 0, sizeof(m_coords));
}
LASPoint::LASPoint(LASPoint const& other) :
m_intensity(other.m_intensity),
- m_flags(other.m_flags), m_class(other.m_class),
- m_angleRank(other.m_angleRank), m_userData(other.m_userData),
- m_gpsTime(other.m_gpsTime)
+ m_flags(other.m_flags),
+ m_class(other.m_class),
+ m_angleRank(other.m_angleRank),
+ m_userData(other.m_userData),
+ m_pointSourceId(other.m_pointSourceId),
+ m_gpsTime(other.m_gpsTime)
{
std::memcpy(m_coords, other.m_coords, sizeof(m_coords));
}
@@ -77,6 +85,7 @@
m_class = rhs.m_class;
m_angleRank = rhs.m_angleRank;
m_userData = rhs.m_userData;
+ m_pointSourceId = rhs.m_pointSourceId;
m_gpsTime = rhs.m_gpsTime;
}
return *this;
Modified: trunk/src/lasreader.cpp
==============================================================================
--- trunk/src/lasreader.cpp (original)
+++ trunk/src/lasreader.cpp Tue Feb 3 09:59:22 2009
@@ -173,9 +173,7 @@
m_point.SetClassification(m_record.classification);
m_point.SetScanAngleRank(m_record.scan_angle_rank);
m_point.SetUserData(m_record.user_data);
-
- // TODO: Should we handle m_record.point_source_id ?
-
+ m_point.SetPointSourceID(m_record.point_source_id);
m_point.SetTime(time);
}
Modified: trunk/src/laswriter.cpp
==============================================================================
--- trunk/src/laswriter.cpp (original)
+++ trunk/src/laswriter.cpp Tue Feb 3 09:59:22 2009
@@ -89,10 +89,10 @@
m_record.flags = point.GetScanFlags();
m_record.classification = point.GetClassification();
m_record.scan_angle_rank = point.GetScanAngleRank();
+ // For LAS 1.0 - File Marker; for LAS 1.1 - User Data.
m_record.user_data = point.GetUserData();
- // TODO: How to handle this in portable way, for LAS 1.0 and 1.1
- m_record.point_source_id = 0;
-
+ // For LAS 1.0 - User Bit Field; for LAS 1.1 - Point Source ID.
+ m_record.point_source_id = point.GetPointSourceID();
if (m_header.GetDataFormatId() == LASHeader::ePointFormat0)
m_pimpl->WritePointRecord(m_record);
Modified: trunk/test/unit/common.cpp
==============================================================================
--- trunk/test/unit/common.cpp (original)
+++ trunk/test/unit/common.cpp Tue Feb 3 09:59:22 2009
@@ -103,8 +103,10 @@
p.GetClassification(), 0);
ensure_equals("wrong defualt scan angle rank",
p.GetScanAngleRank(), 0);
- ensure_equals("wrong defualt user data value",
+ ensure_equals("wrong defualt file marker/user data value",
p.GetUserData(), 0);
+ ensure_equals("wrong defualt user bit field/point source id value",
+ p.GetPointSourceID(), 0);
ensure_equals("wrong defualt time",
p.GetTime(), double(0));
@@ -156,6 +158,7 @@
ensure_equals(p.GetClassification(), liblas::uint8_t(1));
ensure_equals(p.GetScanAngleRank(), 0);
ensure_equals(p.GetUserData(), 3);
+ ensure_equals(p.GetPointSourceID(), 0);
ensure_equals(p.GetScanFlags(), 9);
ensure_distance(p.GetTime(), double(413665.23360000004), 0.0001);
}
@@ -169,6 +172,7 @@
ensure_equals(p.GetClassification(), 1);
ensure_equals(p.GetScanAngleRank(), 0);
ensure_equals(p.GetUserData(), 3);
+ ensure_equals(p.GetPointSourceID(), 0);
ensure_equals(p.GetScanFlags(), 9);
ensure_distance(p.GetTime(), double(413665.52880000003), 0.0001);
}
@@ -182,6 +186,7 @@
ensure_equals(p.GetClassification(), 1);
ensure_equals(p.GetScanAngleRank(), 0);
ensure_equals(p.GetUserData(), 4);
+ ensure_equals(p.GetPointSourceID(), 0);
ensure_equals(p.GetScanFlags(), 18);
ensure_distance(p.GetTime(), double(414093.84360000002), 0.0001);
}
More information about the Liblas-commits
mailing list