[Liblas-commits] hg: 3 new changesets

liblas-commits at liblas.org liblas-commits at liblas.org
Mon Aug 23 10:58:16 EDT 2010


changeset fef3cda82bce in /Volumes/Data/www/liblas.org/hg
details: http://hg.liblas.orghg?cmd=changeset;node=fef3cda82bce
summary: add lasindex_test, build bigfile_test and lasindex_test by default, but do not install

changeset 86f9ef35a1fa in /Volumes/Data/www/liblas.org/hg
details: http://hg.liblas.orghg?cmd=changeset;node=86f9ef35a1fa
summary: fix up to work with latest code

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

diffstat:

 apps/CMakeLists.txt                         |   17 +-
 apps/bigtest.cpp                            |    8 +-
 apps/lasindex_test.cpp                      |  546 ++++++++++++++++++++++++++++
 include/liblas/detail/index/indexcell.hpp   |   49 +-
 include/liblas/detail/index/indexoutput.hpp |    8 +-
 include/liblas/lasindex.hpp                 |  272 +++++++++++--
 src/lasindex.cpp                            |  366 +++++++++++++-----
 7 files changed, 1075 insertions(+), 191 deletions(-)

diffs (truncated from 1886 to 300 lines):

diff -r a6eb1a6e8452 -r 057b5600534e apps/CMakeLists.txt
--- a/apps/CMakeLists.txt	Sun Aug 22 22:58:05 2010 -0500
+++ b/apps/CMakeLists.txt	Mon Aug 23 09:58:00 2010 -0500
@@ -22,16 +22,16 @@
 set(LAS2LAS2 las2las2 )
 set(LASBLOCK lasblock )
 
+set(BIGFILE_TEST bigfile_test)
+set(LASINDEX_TEST lasindex_test)
+
 # Set the build type to release if it is not explicitly set by the user and 
 # isn't in the cache yet
 if (NOT CMAKE_BUILD_TYPE )
 set(CMAKE_BUILD_TYPE "Release")
 endif()
 
-string(TOUPPER ${CMAKE_BUILD_TYPE} BUILD_TYPE_UPPER)
-if (BUILD_TYPE_UPPER EQUAL "DEBUG")
-set(BIGFILE_TEST bigfile_test)
-endif()
+
 
 # Utilities depending on 3rd-pary libraries
 if(GDAL_FOUND)
@@ -45,7 +45,7 @@
 
 set(LIBLAS_UTILITIES
     ${LASINFO} ${LASMERGE} ${LAS2LAS} ${LAS2TXT} ${TXT2LAS} 
-    ${LAS2OGR}  ${LAS2OCI} ${LAS2LAS2} ${LASBLOCK} ${BIGFILE_TEST})
+    ${LAS2OGR}  ${LAS2OCI} ${LAS2LAS2} ${LASBLOCK})
 
 # TODO: Experimental and requires testing --mloskot
 # Generate user-specific settings for Visual Studio project
@@ -132,11 +132,16 @@
     target_link_libraries(${LAS2OCI} ${APPS_CPP_DEPENDENCIES} ${Boost_LIBRARIES})
 endif()
 
-if (BIGFILE_TEST)
+if(BIGFILE_TEST)
     add_executable(${BIGFILE_TEST} bigtest.cpp)
     target_link_libraries(${BIGFILE_TEST} ${LIBLAS_C_LIB_NAME})
 endif()
 
+if (LASINDEX_TEST)
+    add_executable(${LASINDEX_TEST} lasindex_test.cpp)
+    target_link_libraries(${LASINDEX_TEST} ${APPS_CPP_DEPENDENCIES} ${Boost_LIBRARIES})    
+endif()
+
 ###############################################################################
 # Targets installation
 
diff -r a6eb1a6e8452 -r 057b5600534e apps/bigtest.cpp
--- a/apps/bigtest.cpp	Sun Aug 22 22:58:05 2010 -0500
+++ b/apps/bigtest.cpp	Mon Aug 23 09:58:00 2010 -0500
@@ -16,14 +16,14 @@
     LASError err;
     // Limitation about seeking past 4GB output size.  At 20 bytes / record, we
     // can successfully write 204 million records, but not 205.
-    const uint32_t nMillionPoints = 205;
-    const uint32_t NPOINTS = 1024*1024*nMillionPoints ;
+    const unsigned long nMillionPoints = 205;
+    const unsigned long NPOINTS = 1024*1024*nMillionPoints ;
     const char * OutputName = "Issue147.las";
 
     // Write a LAS file and after the points are in, update the header.
     header = LASHeader_Create();
     writer = LASWriter_Create(OutputName, header, LAS_MODE_WRITE);
-    for (uint32_t i = 0; i < NPOINTS; i++)
+    for (unsigned long i = 0; i < NPOINTS; i++)
     {
       double percentDone = ((double)i)/NPOINTS * 100.0;
       if (i % 1000 == 0)
@@ -50,6 +50,6 @@
    // Read the file we just wrote and check the header data.
     reader = LASReader_Create(OutputName);
     header = LASReader_GetHeader(reader);
-    uint32_t npoints = LASHeader_GetPointRecordsCount(header);
+    unsigned long npoints = LASHeader_GetPointRecordsCount(header);
     printf ("\n\nWrote %d, Read %d (testing %d Million (1024 x 1024) Points)\n", NPOINTS, npoints, nMillionPoints);
 }
diff -r a6eb1a6e8452 -r 057b5600534e apps/lasindex_test.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/apps/lasindex_test.cpp	Mon Aug 23 09:58:00 2010 -0500
@@ -0,0 +1,546 @@
+// lasindex_test.cpp : Defines the entry point for the console application.
+//
+
+#include <iosfwd>
+#include <iostream>
+#include <cstdio>
+#include <bitset>
+#include <exception>
+#include <fstream>
+#include <iostream>
+#include <map>
+#include <sstream> // std::stringstream
+#include <string>
+#include <stack>
+#include <typeinfo>
+#include <vector>
+
+#include <liblas/lasindex.hpp>
+
+using namespace liblas;
+
+#ifdef _WIN32
+#define compare_no_case(a,b,n)  _strnicmp( (a), (b), (n) )
+#else
+#define compare_no_case(a,b,n)  strncasecmp( (a), (b), (n) )
+#endif
+
+#define lasindex_test_version	"1.0"
+#define SAMPLE_AUTHOR	"Gary Huber"
+#define SAMPLE_COMMENT	"This is a test of the LAS file index system in LibLAS"
+#define SAMPLE_DATE	"7/22/10"
+void usage(FILE *debugger)
+{
+    fprintf(debugger,"----------------------------------------------------------\n");
+    fprintf(debugger,"    lasindex_test (version %s) usage:\n", lasindex_test_version);
+    fprintf(debugger,"----------------------------------------------------------\n");
+    fprintf(debugger,"\n");
+
+    fprintf(debugger,"Create index for in file, resave to out file, temporary storage file, max memory usage, sort with Z bin interval:\n");
+    fprintf(debugger,"  lasindex_test -i in.las -o out.las -t tempfile -z interval -m maxmemory\n");
+    fprintf(debugger,"\n");
+    
+    fprintf(debugger,"-i or --infile (required):\n");
+    fprintf(debugger,"  complete input file name and path\n");
+    fprintf(debugger,"\n");
+    
+    fprintf(debugger,"-o or --outfile (required unless readonly):\n");
+    fprintf(debugger,"  complete output file name and path\n");
+    fprintf(debugger,"\n");
+    
+    fprintf(debugger,"-n or --indexfile (required for reading standalone index):\n");
+    fprintf(debugger,"  complete output file name and path\n");
+    fprintf(debugger,"\n");
+    
+    fprintf(debugger,"-t or --tempfile (required):\n");
+    fprintf(debugger,"  complete temporary file name and path used during index building\n");
+    fprintf(debugger,"\n");
+    
+    fprintf(debugger,"-b or --zbinheight (optional):\n");
+    fprintf(debugger,"  elevation sorting bin height, no z sorting if omitted\n");
+    fprintf(debugger,"\n");
+    
+    fprintf(debugger,"-m or --maxmem (optional):\n");
+    fprintf(debugger,"  maximum memory to use for index building, defaults to no limit if omitted\n");
+    fprintf(debugger,"\n");
+    
+    fprintf(debugger,"-a or --author (optional):\n");
+    fprintf(debugger,"  author field for index file record header, 512 max length\n");
+    fprintf(debugger,"\n");
+    
+    fprintf(debugger,"-c or --comment (optional):\n");
+    fprintf(debugger,"  comment field for index file record header, 512 max length\n");
+    fprintf(debugger,"\n");
+    
+    fprintf(debugger,"-d or --date (optional):\n");
+    fprintf(debugger,"  date of index creation for index file record header, 512 max length\n");
+    fprintf(debugger,"\n");
+    
+    fprintf(debugger,"-r or --readonly (optional):\n");
+    fprintf(debugger,"  if set, index is to be read only, not created\n");
+    fprintf(debugger,"\n");
+    
+    fprintf(debugger,"-s or --standalone (optional):\n");
+    fprintf(debugger,"  if set, index is to be saved in separate index file, not in las file\n");
+    fprintf(debugger,"\n");
+    
+    fprintf(debugger,"-x (at least one dimension required for filter):\n");
+    fprintf(debugger,"  follow with low and high values for X filter\n");
+    fprintf(debugger,"\n");
+    
+    fprintf(debugger,"-y (at least one dimension required for filter):\n");
+    fprintf(debugger,"  follow with low and high values for Y filter\n");
+    fprintf(debugger,"\n");
+    
+    fprintf(debugger,"-z (at least one dimension required for filter):\n");
+    fprintf(debugger,"  follow with low and high values for Z filter\n");
+    fprintf(debugger,"\n");
+    
+    fprintf(debugger, "\nFor more information, see the full documentation for lasindex_test at:\n"
+                    " http://liblas.org/browser/trunk/doc/lasindex_test.txt\n");
+    fprintf(debugger,"----------------------------------------------------------\n");
+
+}
+
+std::istream* OpenInput(std::string filename) 
+{
+    std::ios::openmode const mode = std::ios::in | std::ios::binary;
+    std::istream* istrm = 0;
+    if (compare_no_case(filename.c_str(),"STDIN",5) == 0)
+    {
+        istrm = &std::cin;
+    }
+    else 
+    {
+        istrm = new std::ifstream(filename.c_str(), mode);
+    }
+    
+    if (!istrm->good())
+    {
+        delete istrm;
+        throw std::runtime_error("Reading stream was not able to be created.");
+    }
+    return istrm;
+}
+
+std::ostream* OpenOutput(std::string filename) 
+{
+    std::ios::openmode const mode = std::ios::out | std::ios::binary;
+    std::ostream* ostrm = 0;
+    if (compare_no_case(filename.c_str(),"STDOUT",5) == 0)
+    {
+        ostrm = &std::cout;
+    }
+    else 
+    {
+        ostrm = new std::ofstream(filename.c_str(), mode);
+    }
+    
+    if (!ostrm->good())
+    {
+        delete ostrm;
+        throw std::runtime_error("Writing stream was not able to be created.");
+    }
+    return ostrm;
+}
+
+void IndexInitError(FILE *debugger)
+{
+    fprintf(debugger, "Unable to initialize index.\n");
+}
+
+void IndexFilterNoPoints(FILE *debugger)
+{
+    fprintf(debugger, "No points found in search area.\n");
+}
+
+void IndexFilterInitError(FILE *debugger)
+{
+    fprintf(debugger, "Unable to initialize index filter. Invalid values.\n");
+}
+
+
+int main(int argc, char* argv[])
+{
+	char *tmpfilenme = 0;
+	char *lasinfilenme = 0;
+	char *lasoutfilenme = 0;
+	char *idxinfilenme = 0;
+	char *authorname = 0;
+	char *commentfield = 0;
+	char *datefield = 0;
+	double zbinheight = 0.0;
+	double oLowFilterX = 0.0, oHighFilterX = 0.0, oLowFilterY = 0.0, oHighFilterY = 0.0, oLowFilterZ = 0.0, oHighFilterZ = 0.0;
+	uint32_t maxmem = 0;
+	int debuglevel = 3;
+	bool readonly = 0;
+	bool forcenewindex = 0;
+	bool boundssetbyuser = 0;
+	bool writestandaloneindex = 0;
+	FILE *debugger = stderr;
+	
+	// temporary until argv[] starts to work
+	// uncomment only one of these blocks
+	/*------------------------------N1440375----------------------------------*/
+	///*------------------------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,
+		 "-o", "C:\\LibLAS\\Samples\\N1440375_idx.ldx", "-s"};
+	argc = 14;
+	*/
+	/*------------------filter with embedded index------------------------------
+	const char* arggv[] = {"foo",
+		 "-i", "C:\\LibLAS\\Samples\\N1440375_idx.las", "-r"};
+	argc = 4;
+	*/
+	/*-------------------filter from standalone file----------------------------
+	const char* arggv[] = {"foo", "-i", "C:\\LibLAS\\Samples\\N1440375.las",
+		 "-n", "C:\\LibLAS\\Samples\\N1440375_idx.ldx", "-r"};
+	argc = 6;
+	*/
+	/*---------------------Serpent Mound Model LAS Data-----------------------*/
+	/*----------------------------build index-----------------------------------
+	const char* arggv[] = {"foo", "-t", "C:\\LibLAS\\Samples\\Serpent Mound Model LAS Data.tmp",
+		 "-i", "C:\\LibLAS\\Samples\\Serpent Mound Model LAS Data.las", "-a", SAMPLE_AUTHOR, "-c", SAMPLE_COMMENT, "-d", SAMPLE_DATE,
+		 "-o", "C:\\LibLAS\\Samples\\Serpent Mound Model LAS Data_idx.las"};
+	argc = 13;
+	*/
+	/*------------------filter with embedded index------------------------------
+	const char* arggv[] = {"foo",
+		 "-i", "C:\\LibLAS\\Samples\\Serpent Mound Model LAS Data_idx.las", "-r"};


More information about the Liblas-commits mailing list