[Liblas-commits] hg: push Gary's latest

liblas-commits at liblas.org liblas-commits at liblas.org
Wed Oct 6 14:47:18 EDT 2010


changeset cf94fbdf37e6 in /Volumes/Data/www/liblas.org/hg
details: http://hg.liblas.orghg?cmd=changeset;node=cf94fbdf37e6
summary: push Gary's latest

diffstat:

 apps/lasindex_test.cpp      |  29 +++++++++++++++++++++++------
 include/liblas/lasindex.hpp |   6 ++++--
 src/lasindex.cpp            |  38 +++++++++++++++++++++++---------------
 3 files changed, 50 insertions(+), 23 deletions(-)

diffs (253 lines):

diff -r 2e087c088430 -r cf94fbdf37e6 apps/lasindex_test.cpp
--- a/apps/lasindex_test.cpp	Wed Oct 06 09:12:45 2010 -0500
+++ b/apps/lasindex_test.cpp	Wed Oct 06 13:47:11 2010 -0500
@@ -185,12 +185,12 @@
 	// temporary until argv[] starts to work
 	// uncomment only one of these blocks
 	/*------------------------------N1440375----------------------------------*/
-	///*------------------------build embedded index------------------------------
+	/*------------------------build embedded index------------------------------
 	const char* arggv[] = {"foo", "-t", "C:\\LibLAS\\Samples\\N1440375.tmp",
 		 "-i", "C:\\LibLAS\\Samples\\N1440375.las", "-a", SAMPLE_AUTHOR, "-c", SAMPLE_COMMENT, "-d", SAMPLE_DATE,
 		 "-o", "C:\\LibLAS\\Samples\\N1440375_idx.las"};
 	argc = 13;
-	//*/
+	*/
 	/*-----------------build index in standalone file---------------------------
 	const char* arggv[] = {"foo", "-t", "C:\\LibLAS\\Samples\\N1440375.tmp",
 		 "-i", "C:\\LibLAS\\Samples\\N1440375.las", "-a", SAMPLE_AUTHOR, "-c", SAMPLE_COMMENT, "-d", SAMPLE_DATE,
@@ -207,8 +207,8 @@
 		 "-n", "C:\\LibLAS\\Samples\\N1440375_idx.ldx", "-r"};
 	argc = 6;
 	*/
-	
-	/*const char* arggv[] = {"foo", "-t", "C:\\LibLAS\\Samples\\N1440375.tmp",
+	/*-----------------build embedded index, filter with user bounds------------
+	const char* arggv[] = {"foo", "-t", "C:\\LibLAS\\Samples\\N1440375.tmp",
 		 "-i", "C:\\LibLAS\\Samples\\N1440375.las", "-a", SAMPLE_AUTHOR, "-c", SAMPLE_COMMENT, "-d", SAMPLE_DATE,
 		 "-o", "C:\\LibLAS\\Samples\\N1440375_idx.las",
 		 "-x", "1443000.00", "1444000.00", "-y", "376000.02", "379000.00", "-z", "850.00", "950.00"};
@@ -250,6 +250,18 @@
 		 "-i", "C:\\LibLAS\\Samples\\Lincoln_idx.las", "-r"};
 	argc = 4;
 	*/
+	/*------------------------------flatDataset-------------------------------*/
+	///*------------------------------build index---------------------------------
+	const char* arggv[] = {"foo", "-t", "C:\\LibLAS\\flatDataset.tmp",
+		 "-i", "C:\\LibLAS\\Samples\\flatDataset.las", "-a", SAMPLE_AUTHOR, "-c", SAMPLE_COMMENT, "-d", SAMPLE_DATE,
+		 "-o", "C:\\LibLAS\\Samples\\flatDataset_idx.las"};
+	argc = 13;
+	//*/
+	/*------------------filter with embedded index------------------------------
+	const char* arggv[] = {"foo",
+		 "-i", "C:\\LibLAS\\Samples\\flatDataset_idx.las", "-r"};
+	argc = 4;
+	*/
 	/*------------------------------------------------------------------------*/
 	
 	for (int i = 1; i < argc; i++)
@@ -411,7 +423,7 @@
 								{
 									Bounds<double> filterBounds(oLowFilterX, oLowFilterY, oLowFilterZ,
 										oHighFilterX, oHighFilterY, oHighFilterZ);
-									if (ParamSrc.SetFilterValues(filterBounds))
+									if (ParamSrc.SetFilterValues(filterBounds, index))
 									{
 										const std::vector<uint32_t>& FilterResult = index.Filter(ParamSrc);
 										if (FilterResult.size())
@@ -507,14 +519,19 @@
 												break;
 											} // 5
 										} // switch
-										if (ParamSrc.SetFilterValues(filterBounds))
+										if (ParamSrc.SetFilterValues(filterBounds, index))
 										{
 											const std::vector<uint32_t>& FilterResult = index.Filter(ParamSrc);
 											if (FilterResult.size())
 											{
 												// do something with the list of points
+												#ifdef VISUAL_8
+												fprintf(debugger, "Points within filter area %d of %d, %s\n", FilterResult.size(), 
+													index.GetPointRecordsCount(), CovgStr);
+												#else // VISUAL_8
 												fprintf(debugger, "Points within filter area %zu of %d, %s\n", FilterResult.size(), 
 													index.GetPointRecordsCount(), CovgStr);
+												#endif // VISUAL_8
 											}
 											else
 												IndexFilterNoPoints(debugger);
diff -r 2e087c088430 -r cf94fbdf37e6 include/liblas/lasindex.hpp
--- a/include/liblas/lasindex.hpp	Wed Oct 06 09:12:45 2010 -0500
+++ b/include/liblas/lasindex.hpp	Wed Oct 06 13:47:11 2010 -0500
@@ -379,8 +379,9 @@
 		boost::uint32_t maxmem = LIBLAS_INDEX_MAXMEMDEFAULT, int debugoutputlevel = 0, FILE *debugger = 0);
 	
 	// set the bounds for use in filtering
-	bool SetFilterValues(double LowFilterX, double HighFilterX, double LowFilterY, double HighFilterY, double LowFilterZ, double HighFilterZ);
-	bool SetFilterValues(Bounds<double> const& src);
+	bool SetFilterValues(double LowFilterX, double HighFilterX, double LowFilterY, double HighFilterY, double LowFilterZ, double HighFilterZ, 
+		Index const& index);
+	bool SetFilterValues(Bounds<double> const& src, Index const& index);
 
     // Blocked copying operations, declared but not defined.
     /// Copy constructor.
@@ -427,6 +428,7 @@
 	double GetMaxFilterY(void) const	{return m_filter.max(1);};
 	double GetMinFilterZ(void) const	{return m_filter.min(2);};
 	double GetMaxFilterZ(void) const	{return m_filter.max(2);};
+	void ClampFilterBounds(Bounds<double> const& m_bounds);
 	void SetReader(Reader *reader)	{m_reader = reader;};
 	void SetIStream(std::istream *ifs)	{m_ifs = ifs;};
 	void SetOStream(std::ostream *ofs)	{m_ofs = ofs;};
diff -r 2e087c088430 -r cf94fbdf37e6 src/lasindex.cpp
--- a/src/lasindex.cpp	Wed Oct 06 09:12:45 2010 -0500
+++ b/src/lasindex.cpp	Wed Oct 06 13:47:11 2010 -0500
@@ -43,6 +43,7 @@
 #include <liblas/laswriter.hpp>
 #include <liblas/detail/index/indexoutput.hpp>
 #include <liblas/detail/index/indexcell.hpp>
+#include <liblas/detail/writer/writer.hpp>
 
 namespace liblas
 {
@@ -303,7 +304,7 @@
 	m_filterMinYCell = m_cellsY * (ParamSrc.GetMinFilterY() - GetMinY()) / GetRangeY();
 	m_filterMaxYCell = m_cellsY * (ParamSrc.GetMaxFilterY() - GetMinY()) / GetRangeY();
 	// Z range however can be 0
-	if (GetRangeZ() > 0.0)
+	if (GetRangeZ() > 0.0 && ! detail::compare_distance(GetRangeZ(), 0.0))
 	{
 		m_filterMinZCell = m_cellsZ * (ParamSrc.GetMinFilterZ() - GetMinZ()) / GetRangeZ();
 		m_filterMaxZCell = m_cellsZ * (ParamSrc.GetMaxFilterZ() - GetMinZ()) / GetRangeZ();
@@ -731,7 +732,7 @@
 		{
 			// seek and read
 			assert(static_cast<boost::uint32_t>(PointID) < m_pointRecordsCount);
-			PtRead = (m_reader->seek(PointID) && m_reader->ReadNextPoint());
+			PtRead = (m_reader->seek(PointID) && m_reader->ReadNextPoint());
 		} // if
 		if (PtRead)
 		{
@@ -774,7 +775,7 @@
 				{
 					// seek and read
 					assert(static_cast<boost::uint32_t>(PointID) < m_pointRecordsCount);
-					PtRead = (m_reader->seek(PointID) && m_reader->ReadNextPoint());
+					PtRead = (m_reader->seek(PointID) && m_reader->ReadNextPoint());
 				} // if
 				if (PtRead)
 				{
@@ -818,7 +819,7 @@
 				{
 					// seek and read
 					assert(static_cast<boost::uint32_t>(PointID) < m_pointRecordsCount);
-					PtRead = (m_reader->seek(PointID) && m_reader->ReadNextPoint());
+					PtRead = (m_reader->seek(PointID) && m_reader->ReadNextPoint());
 				} // if
 				if (PtRead)
 				{
@@ -857,7 +858,7 @@
 	CalcRangeY(); 
 	CalcRangeZ();
 
-	if (m_cellSizeZ > 0.0)
+	if (m_cellSizeZ > 0.0 && ! detail::compare_distance(m_cellSizeZ, 0.0))
 		m_cellsZ = static_cast<boost::uint32_t>(ceil(m_rangeZ / m_cellSizeZ));
 	else
 		m_cellsZ = 1;
@@ -1008,7 +1009,7 @@
 							{
 								// get the actual point from the las file
 								assert(MapIt->first < m_pointRecordsCount);
-								if (m_reader->seek(MapIt->first) && m_reader->ReadNextPoint())
+								if (m_reader->seek(MapIt->first) && m_reader->ReadNextPoint())
 								{
 									boost::uint32_t FirstPt = 0, LastCellZ = static_cast<boost::uint32_t>(~0);
 									boost::uint32_t LastSubCell = static_cast<boost::uint32_t>(~0);
@@ -1125,7 +1126,7 @@
 	OffsetX = (CurPt.GetX() - m_bounds.min(0)) / m_rangeX;
 	if (OffsetX >= 0 && OffsetX < 1.0)
 		CurCellX = static_cast<boost::uint32_t>(OffsetX * m_cellsX);
-	else if (OffsetX == 1.0)
+	else if (detail::compare_distance(OffsetX, 1.0))
 		CurCellX = m_cellsX - 1;
 	else
 	{
@@ -1135,7 +1136,7 @@
 	OffsetY = (CurPt.GetY() - m_bounds.min(1)) / m_rangeY;
 	if (OffsetY >= 0 && OffsetY < 1.0)
 		CurCellY = static_cast<boost::uint32_t>(OffsetY * m_cellsY);
-	else if (OffsetY == 1.0)
+	else if (detail::compare_distance(OffsetY, 1.0))
 		CurCellY = m_cellsY - 1;
 	else
 	{
@@ -1153,7 +1154,7 @@
 	OffsetZ = (CurPt.GetZ() - m_bounds.min(2)) / m_rangeZ;
 	if (OffsetZ >= 0 && OffsetZ < 1.0)
 		CurCellZ = static_cast<boost::uint32_t>(OffsetZ * m_cellsZ);
-	else if (OffsetZ == 1.0)
+	else if (detail::compare_distance(OffsetZ, 1.0))
 		CurCellZ = m_cellsZ - 1;
 	else
 	{
@@ -1194,7 +1195,7 @@
 
 	return true;
 
-} // Index::IdentifyCellZ
+} // Index::IdentifySubCell
 
 bool Index::PurgePointsToTempFile(IndexCellDataBlock& CellBlock)
 {
@@ -1731,11 +1732,12 @@
 } // IndexData::SetBuildAloneValues
 
 bool IndexData::SetFilterValues(double LowFilterX, double HighFilterX, double LowFilterY, double HighFilterY, 
-	double LowFilterZ, double HighFilterZ)
+	double LowFilterZ, double HighFilterZ, Index const& index)
 {
 	try {
 		m_filter = Bounds<double>(LowFilterX, LowFilterY, LowFilterZ, HighFilterX, HighFilterY, HighFilterZ);
 		m_filter.verify();
+		m_filter.clip(index.GetBounds());
 	} // try
 	catch (std::runtime_error) {
 		return (false);
@@ -1744,11 +1746,12 @@
 	
 } // IndexData::SetFilterValues
 
-bool IndexData::SetFilterValues(Bounds<double> const& src)
+bool IndexData::SetFilterValues(Bounds<double> const& src, Index const& index)
 {
 	try {
 		m_filter = src;
 		m_filter.verify();
+		m_filter.clip(index.GetBounds());
 	} // try
 	catch (std::runtime_error) {
 		return (false);
@@ -1759,14 +1762,19 @@
 
 bool IndexData::CalcFilterEnablers(void)
 {
-	if (m_filter.min(0) == m_filter.max(0))
+	if (detail::compare_distance(m_filter.min(0), m_filter.max(0)))
 		m_noFilterX = true;
-	if (m_filter.min(1) == m_filter.max(1))
+	if (detail::compare_distance(m_filter.min(1), m_filter.max(1)))
 		m_noFilterY = true;
-	if (m_filter.min(2) == m_filter.max(2))
+	if (detail::compare_distance(m_filter.min(2), m_filter.max(2)))
 		m_noFilterZ = true;
 	return (! (m_noFilterX && m_noFilterY && m_noFilterZ));
 } // IndexData::CalcFilterEnablers
 
+void IndexData::ClampFilterBounds(Bounds<double> const& m_bounds)
+{
+	m_filter.clip(m_bounds);
+} // IndexData::ClampFilterBounds
+
 } // namespace liblas
 


More information about the Liblas-commits mailing list