[Liblas-devel] Trying out liblas

John Hayes jahayes at gmail.com
Mon Sep 22 13:01:07 EDT 2008


Howard,

Thanks for the reply.  Here is a patch that has the caller passing in
the output stream.  I also included the files I change because I don't
know how hard it is to apply hg diff output.

-john

On Fri, Sep 19, 2008 at 8:25 PM, Howard Butler <hobu.inc at gmail.com> wrote:
>
> On Sep 19, 2008, at 6:07 PM, John Hayes wrote:
>
>> Hello,
>>
>> I just downloaded liblas 1.0.0b2 and am having some problems.
>>
>> My end goal is get the scale factors for a bunch of LAS files.  I want
>> run the following shell code:
>>
>> $ for i in *.las; do lasinfo $i | grep "Scale Factor X Y Z" ; done
>>
>> The first problem is lasinfo always says the scale factors are zero.
>> It looks like the scale factors for these LAS files are around 1e-7.
>> The following patch fixes the printf formatter.
>
> John,
>
> I have fixed this with your patch:
>
> http://liblas.org/ticket/75
>
> Additionally, you might also try doing this task in Python if it fits:
>
>>>> import liblas
>>>> f = liblas.file.File('/Users/hobu/svn/liblas/trunk/test/data/srs.las')
>>>> h = f.header
>>>> h.scale
> [0.01, 0.01, 0.01]
>
>
>
>>
>> The next problem is lasinfo prints its output to stderr so the pipe
>> does not work.  This seems wrong to me.
>>
>> Is it safe to change the fprintf(stderr, ... )s to fprintf(stdout,
>> ...)s or should I make the caller pass in the output file stream?
>>
>
> The correct approach would be for the print_ methods in lascommon.c to take
> in a stream and print to that.  For example, it makes a lot of sense for
> lasinfo to print to stdout when writing summary info, but the same code is
> use to write summary info when you are doing operations like las2las (which
> should be putting stuff to stderr because the user may be writing the .las
> file to stdout or something).
>
> If you register on liblas.org and file a bug, I will try to clean it up for
> the final release (or you can cook up a patch and I'll apply it).
>
> Thanks for trying libLAS, we hope you'll like it.
>
> Howard
>
-------------- next part --------------
diff -r 9660e01d86bf apps/las2las.c
--- a/apps/las2las.c	Fri Sep 19 15:17:56 2008 -0700
+++ b/apps/las2las.c	Mon Sep 22 09:53:37 2008 -0700
@@ -20,10 +20,10 @@
 #include "liblas.h"
 
 LASPointSummary* SummarizePoints(LASReaderH reader);
-void print_point_summary(LASPointSummary* summary, LASHeaderH header);
-void print_point(LASPointH point);
-void print_header(LASHeaderH header, const char* file_name, int bSkipVLR);
-void repair_header(LASHeaderH header, LASPointSummary* summary) ;
+void print_point_summary(FILE *file, LASPointSummary* summary, LASHeaderH header);
+void print_point(FILE *file, LASPointH point);
+void print_header(FILE *file, LASHeaderH header, const char* file_name, int bSkipVLR);
+void repair_header(FILE *file, LASHeaderH header, LASPointSummary* summary) ;
 
 #define LAS_FORMAT_10 0
 #define LAS_FORMAT_11 1
@@ -756,9 +756,9 @@
     } 
     summary = SummarizePoints(reader);
     if (verbose) {
-        print_point_summary(summary, header);
+        print_point_summary(stderr, summary, header);
     }
-    repair_header(header, summary) ;
+    repair_header(stderr, header, summary) ;
 
     if (summary) {
         LASPoint_Destroy(summary->pmin);
diff -r 9660e01d86bf apps/las2txt.c
--- a/apps/las2txt.c	Fri Sep 19 15:17:56 2008 -0700
+++ b/apps/las2txt.c	Mon Sep 22 09:53:37 2008 -0700
@@ -18,7 +18,7 @@
 
 #include "liblas.h"
 
-void print_header(LASHeaderH header, const char* file_name);
+void print_header(FILE *file, LASHeaderH header, const char* file_name);
 
 void usage()
 {
@@ -341,7 +341,7 @@
 
     if (verbose)
     {
-        print_header(header, file_name_in);
+        print_header(stderr, header, file_name_in);
     }
 
     if (header_comment_sign)
diff -r 9660e01d86bf apps/lascommon.c
--- a/apps/lascommon.c	Fri Sep 19 15:17:56 2008 -0700
+++ b/apps/lascommon.c	Mon Sep 22 09:53:38 2008 -0700
@@ -163,47 +163,47 @@
     return summary; 
 }
 
-void print_point(LASPointH point) {
+void print_point(FILE *file, LASPointH point) {
 
-    fprintf(stderr, "---------------------------------------------------------\n");
+    fprintf(file, "---------------------------------------------------------\n");
     
-    fprintf(stderr, "  X: \t\t%.6f\n", 
-                    LASPoint_GetX(point)
-                    );
-    fprintf(stderr, "  Y: \t\t%.6f\n", 
-                    LASPoint_GetY(point)
-                    );
-    fprintf(stderr, "  Z: \t\t%.6f\n", 
-                    LASPoint_GetZ(point)
-                    );
-    fprintf(stderr, "  Time:\t\t\t%.6f\n", 
-                    LASPoint_GetTime(point)
-                    );
-    fprintf(stderr, "  Return Number:\t%d\n", 
-                    LASPoint_GetReturnNumber(point)
-                    );
-    fprintf(stderr, "  Return Count:\t\t%d\n", 
-                    LASPoint_GetNumberOfReturns(point)
-                    );
-    fprintf(stderr, "  Flightline Edge:\t%d\n", 
-                    LASPoint_GetFlightLineEdge(point)
-                    );
-    fprintf(stderr, "  Intensity:\t\t%d\n",
-                    LASPoint_GetIntensity(point)
-                    );
-    fprintf(stderr, "  Scan Direction Flag:\t%d\n",
-                    LASPoint_GetScanDirection(point)
-                    );
-    fprintf(stderr, "  Scan Angle Rank:\t%d\n",
-                    LASPoint_GetScanAngleRank(point)
-                    );
+    fprintf(file, "  X: \t\t%.6f\n", 
+                  LASPoint_GetX(point)
+                  );
+    fprintf(file, "  Y: \t\t%.6f\n", 
+                  LASPoint_GetY(point)
+                  );
+    fprintf(file, "  Z: \t\t%.6f\n", 
+                  LASPoint_GetZ(point)
+                  );
+    fprintf(file, "  Time:\t\t\t%.6f\n", 
+                  LASPoint_GetTime(point)
+                  );
+    fprintf(file, "  Return Number:\t%d\n", 
+                  LASPoint_GetReturnNumber(point)
+                  );
+    fprintf(file, "  Return Count:\t\t%d\n", 
+                  LASPoint_GetNumberOfReturns(point)
+                  );
+    fprintf(file, "  Flightline Edge:\t%d\n", 
+                  LASPoint_GetFlightLineEdge(point)
+                  );
+    fprintf(file, "  Intensity:\t\t%d\n",
+                  LASPoint_GetIntensity(point)
+                  );
+    fprintf(file, "  Scan Direction Flag:\t%d\n",
+                  LASPoint_GetScanDirection(point)
+                  );
+    fprintf(file, "  Scan Angle Rank:\t%d\n",
+                  LASPoint_GetScanAngleRank(point)
+                  );
                     
-    fprintf(stderr, "  Classification:\t%d\n",
-                    LASPoint_GetClassification(point)
-                    );
+    fprintf(file, "  Classification:\t%d\n",
+                  LASPoint_GetClassification(point)
+                  );
 
 }
-void print_point_summary(LASPointSummary* summary, LASHeaderH header) {
+void print_point_summary(FILE *file, LASPointSummary* summary, LASHeaderH header) {
 
     long rgpsum = 0;
     long pbretsum = 0;
@@ -212,126 +212,126 @@
 
     if (!summary) {LASError_Print("Point Summary does not exist!"); exit(1);}
 
-    fprintf(stderr, "\n---------------------------------------------------------\n");
-    fprintf(stderr, "  Point Inspection Summary\n");
-    fprintf(stderr, "---------------------------------------------------------\n");
+    fprintf(file, "\n---------------------------------------------------------\n");
+    fprintf(file, "  Point Inspection Summary\n");
+    fprintf(file, "---------------------------------------------------------\n");
     
-    fprintf(stderr, "  Header Point Count: %d\n",
-                    LASHeader_GetPointRecordsCount(header));
+    fprintf(file, "  Header Point Count: %d\n",
+                  LASHeader_GetPointRecordsCount(header));
                     
-    fprintf(stderr, "  Actual Point Count: %d\n", 
-                    summary->number_of_point_records);
+    fprintf(file, "  Actual Point Count: %d\n", 
+                  summary->number_of_point_records);
 
-    fprintf(stderr, "\n  Minimum and Maximum Attributes (min,max)\n");
-    fprintf(stderr, "---------------------------------------------------------\n");
+    fprintf(file, "\n  Minimum and Maximum Attributes (min,max)\n");
+    fprintf(file, "---------------------------------------------------------\n");
     
-    fprintf(stderr, "  Min X,Y,Z: \t\t%.6f,%.6f,%.6f\n", 
-                    LASPoint_GetX(summary->pmin),
-                    LASPoint_GetY(summary->pmin),
-                    LASPoint_GetZ(summary->pmin)
+    fprintf(file, "  Min X,Y,Z: \t\t%.6f,%.6f,%.6f\n", 
+                  LASPoint_GetX(summary->pmin),
+                  LASPoint_GetY(summary->pmin),
+                  LASPoint_GetZ(summary->pmin)
                     );
-    fprintf(stderr, "  Max X,Y,Z: \t\t%.6f,%.6f,%.6f\n", 
-                    LASPoint_GetX(summary->pmax),
-                    LASPoint_GetY(summary->pmax),
-                    LASPoint_GetZ(summary->pmax)
-                    );
-    fprintf(stderr, "  Bounding Box:\t\t%.2f,%.2f,%.2f,%.2f\n",
-                    LASPoint_GetX(summary->pmin),
-                    LASPoint_GetY(summary->pmin),
-                    LASPoint_GetX(summary->pmax),
-                    LASPoint_GetY(summary->pmax)
-                    );
-    fprintf(stderr, "  Time:\t\t\t%.6f,%.6f\n", 
-                    LASPoint_GetTime(summary->pmin),
-                    LASPoint_GetTime(summary->pmax)
-                    );
-    fprintf(stderr, "  Return Number:\t%d,%d\n", 
-                    LASPoint_GetReturnNumber(summary->pmin),
-                    LASPoint_GetReturnNumber(summary->pmax)
-                    );
-    fprintf(stderr, "  Return Count:\t\t%d,%d\n", 
-                    LASPoint_GetNumberOfReturns(summary->pmin),
-                    LASPoint_GetNumberOfReturns(summary->pmax)
-                    );
-    fprintf(stderr, "  Flightline Edge:\t%d,%d\n", 
-                    LASPoint_GetFlightLineEdge(summary->pmin),
-                    LASPoint_GetFlightLineEdge(summary->pmax)
-                    );
-    fprintf(stderr, "  Intensity:\t\t%d,%d\n",
-                    LASPoint_GetIntensity(summary->pmin),
-                    LASPoint_GetIntensity(summary->pmax)
-                    );
-    fprintf(stderr, "  Scan Direction Flag:\t%d,%d\n",
-                    LASPoint_GetScanDirection(summary->pmin),
-                    LASPoint_GetScanDirection(summary->pmax)
-                    );
-    fprintf(stderr, "  Scan Angle Rank:\t%d,%d\n",
-                    LASPoint_GetScanAngleRank(summary->pmin),
-                    LASPoint_GetScanAngleRank(summary->pmax)
-                    );
-    fprintf(stderr, "  Classification:\t%d,%d\n",
-                    LASPoint_GetClassification(summary->pmin),
-                    LASPoint_GetClassification(summary->pmax)
-                    );
+    fprintf(file, "  Max X,Y,Z: \t\t%.6f,%.6f,%.6f\n", 
+                  LASPoint_GetX(summary->pmax),
+                  LASPoint_GetY(summary->pmax),
+                  LASPoint_GetZ(summary->pmax)
+                  );
+    fprintf(file, "  Bounding Box:\t\t%.2f,%.2f,%.2f,%.2f\n",
+                  LASPoint_GetX(summary->pmin),
+                  LASPoint_GetY(summary->pmin),
+                  LASPoint_GetX(summary->pmax),
+                  LASPoint_GetY(summary->pmax)
+                  );
+    fprintf(file, "  Time:\t\t\t%.6f,%.6f\n", 
+                  LASPoint_GetTime(summary->pmin),
+                  LASPoint_GetTime(summary->pmax)
+                  );
+    fprintf(file, "  Return Number:\t%d,%d\n", 
+                  LASPoint_GetReturnNumber(summary->pmin),
+                  LASPoint_GetReturnNumber(summary->pmax)
+                  );
+    fprintf(file, "  Return Count:\t\t%d,%d\n", 
+                  LASPoint_GetNumberOfReturns(summary->pmin),
+                  LASPoint_GetNumberOfReturns(summary->pmax)
+                  );
+    fprintf(file, "  Flightline Edge:\t%d,%d\n", 
+                  LASPoint_GetFlightLineEdge(summary->pmin),
+                  LASPoint_GetFlightLineEdge(summary->pmax)
+                  );
+    fprintf(file, "  Intensity:\t\t%d,%d\n",
+                  LASPoint_GetIntensity(summary->pmin),
+                  LASPoint_GetIntensity(summary->pmax)
+                  );
+    fprintf(file, "  Scan Direction Flag:\t%d,%d\n",
+                  LASPoint_GetScanDirection(summary->pmin),
+                  LASPoint_GetScanDirection(summary->pmax)
+                  );
+    fprintf(file, "  Scan Angle Rank:\t%d,%d\n",
+                  LASPoint_GetScanAngleRank(summary->pmin),
+                  LASPoint_GetScanAngleRank(summary->pmax)
+                  );
+    fprintf(file, "  Classification:\t%d,%d\n",
+                  LASPoint_GetClassification(summary->pmin),
+                  LASPoint_GetClassification(summary->pmax)
+                  );
 
-    fprintf(stderr, "\n  Number of Points by Return\n");
-    fprintf(stderr, "---------------------------------------------------------\n");
+    fprintf(file, "\n  Number of Points by Return\n");
+    fprintf(file, "---------------------------------------------------------\n");
 
     for (i = 0; i < 5; i++) {
         pbretsum = pbretsum + summary->number_of_points_by_return[i];
-        fprintf(stderr, "\t(%d) %d", i,summary->number_of_points_by_return[i]);
+        fprintf(file, "\t(%d) %d", i,summary->number_of_points_by_return[i]);
     }
-    fprintf(stderr, "\n Total Points: %ld\n", pbretsum); 
+    fprintf(file, "\n Total Points: %ld\n", pbretsum); 
                     
-    fprintf(stderr, "\n  Number of Returns by Pulse\n");
-    fprintf(stderr, "---------------------------------------------------------\n");
+    fprintf(file, "\n  Number of Returns by Pulse\n");
+    fprintf(file, "---------------------------------------------------------\n");
     
     for (i = 1; i < 8; i++) {
         rgpsum = rgpsum + summary->number_of_returns_of_given_pulse[i];
-        fprintf(stderr, "\t(%d) %d", i,summary->number_of_returns_of_given_pulse[i]);
+        fprintf(file, "\t(%d) %d", i,summary->number_of_returns_of_given_pulse[i]);
     }
-    fprintf(stderr, "\n Total Pulses: %ld\n", rgpsum); 
+    fprintf(file, "\n Total Pulses: %ld\n", rgpsum); 
 
 
     for (i = 0; i < 5; i++) {
         if (LASHeader_GetPointRecordsByReturnCount(header, i) != summary->number_of_points_by_return[i]) 
         {
-            fprintf(stderr, " \n Actual number of points by return \n is different from header (actual, header):\n"); 
+            fprintf(file, " \n Actual number of points by return \n is different from header (actual, header):\n"); 
             for (i = 0; i < 5; i++) {
-                fprintf(stderr, "\t(%d,%d)", 
+                fprintf(file, "\t(%d,%d)", 
                         summary->number_of_points_by_return[i],
                         LASHeader_GetPointRecordsByReturnCount(header, i)
                         );
             } 
-            fprintf(stderr, "\n");
+            fprintf(file, "\n");
         }
     }
 
-    fprintf(stderr, "\n  Point Classifications\n");
-    fprintf(stderr, "---------------------------------------------------------\n");
+    fprintf(file, "\n  Point Classifications\n");
+    fprintf(file, "---------------------------------------------------------\n");
 
     for (i = 0; i < 32; i++) {
         if (summary->classification[i]) {
-            fprintf(stderr, "\t%8d %s (%d)\n", 
-                            summary->classification[i], 
-                            LASPointClassification[i], 
-                            i);
+            fprintf(file, "\t%8d %s (%d)\n", 
+                          summary->classification[i], 
+                          LASPointClassification[i], 
+                          i);
         }
     }
 
     if (summary->classification_synthetic || summary->classification_keypoint ||  summary->classification_withheld) {
-        fprintf(stderr, "\n  Point Classification Histogram\n");
-        fprintf(stderr, "---------------------------------------------------------\n");
+        fprintf(file, "\n  Point Classification Histogram\n");
+        fprintf(file, "---------------------------------------------------------\n");
 
-        if (summary->classification_synthetic) fprintf(stderr, " +-> flagged as synthetic: %d\n", summary->classification_synthetic);
-        if (summary->classification_keypoint) fprintf(stderr,  " +-> flagged as keypoints: %d\n", summary->classification_keypoint);
-        if (summary->classification_withheld) fprintf(stderr,  " +-> flagged as withheld:  %d\n", summary->classification_withheld);
-    }         
+        if (summary->classification_synthetic) fprintf(file, " +-> flagged as synthetic: %d\n", summary->classification_synthetic);
+        if (summary->classification_keypoint) fprintf(file,  " +-> flagged as keypoints: %d\n", summary->classification_keypoint);
+        if (summary->classification_withheld) fprintf(file,  " +-> flagged as withheld:  %d\n", summary->classification_withheld);
+    }
 }
 
 
 
-void print_header(LASHeaderH header, const char* file_name, int bSkipVLR) {
+void print_header(FILE *file, LASHeaderH header, const char* file_name, int bSkipVLR) {
 
     char *pszSignature = NULL;
     char *pszProjectId = NULL;
@@ -357,93 +357,93 @@
     
     nVLR = LASHeader_GetRecordsCount(header);
     
-    fprintf(stderr, "\n---------------------------------------------------------\n");
-    fprintf(stderr, "  Header Summary\n");
-    fprintf(stderr, "---------------------------------------------------------\n");
+    fprintf(file, "\n---------------------------------------------------------\n");
+    fprintf(file, "  Header Summary\n");
+    fprintf(file, "---------------------------------------------------------\n");
 
 
-    fprintf(stderr, "  File Name: %s\n", file_name);
+    fprintf(file, "  File Name: %s\n", file_name);
     
     if (strcmp(pszSignature,"LASF") !=0) {
         LASError_Print("File signature is not 'LASF'... aborting");
         exit(1);
     }
-    fprintf(stderr, "  Version:                    %d.%d\n", 
-                    LASHeader_GetVersionMajor(header), 
-                    LASHeader_GetVersionMinor(header));
+    fprintf(file, "  Version:                    %d.%d\n", 
+                  LASHeader_GetVersionMajor(header), 
+                  LASHeader_GetVersionMinor(header));
 
-    fprintf(stderr, "  Source ID:                  %d\n", 
-                    LASHeader_GetFileSourceId(header) ) ;
+    fprintf(file, "  Source ID:                  %d\n", 
+                  LASHeader_GetFileSourceId(header) ) ;
 
-    fprintf(stderr, "  Reserved:                   %d\n", 
-                    LASHeader_GetReserved(header) );
+    fprintf(file, "  Reserved:                   %d\n", 
+                  LASHeader_GetReserved(header) );
 
-    fprintf(stderr, "  Project ID/GUID:           '%s'\n", 
-                    pszProjectId);
+    fprintf(file, "  Project ID/GUID:           '%s'\n", 
+                  pszProjectId);
 
-    fprintf(stderr, "  System Identifier:         '%s'\n", 
-                    pszSystemId);
+    fprintf(file, "  System Identifier:         '%s'\n", 
+                  pszSystemId);
 
-    fprintf(stderr, "  Generating Software:       '%s'\n", 
-                    pszSoftwareId);
+    fprintf(file, "  Generating Software:       '%s'\n", 
+                  pszSoftwareId);
 
-    fprintf(stderr, "  File Creation Day/Year:    %d/%d\n", 
-                    LASHeader_GetCreationDOY(header), 
-                    LASHeader_GetCreationYear(header));
+    fprintf(file, "  File Creation Day/Year:    %d/%d\n", 
+                  LASHeader_GetCreationDOY(header), 
+                  LASHeader_GetCreationYear(header));
 
-    fprintf(stderr, "  Header Size                %d\n", 
-                    LASHeader_GetHeaderSize(header));
+    fprintf(file, "  Header Size                %d\n", 
+                  LASHeader_GetHeaderSize(header));
 
-    fprintf(stderr, "  Offset to Point Data       %d\n", 
-                    LASHeader_GetDataOffset(header));
+    fprintf(file, "  Offset to Point Data       %d\n", 
+                  LASHeader_GetDataOffset(header));
 
-    fprintf(stderr, "  Number Var. Length Records %d\n", 
-                    LASHeader_GetRecordsCount(header));
+    fprintf(file, "  Number Var. Length Records %d\n", 
+                  LASHeader_GetRecordsCount(header));
 
-    fprintf(stderr, "  Point Data Format          %d\n", 
-                    LASHeader_GetDataFormatId(header));
+    fprintf(file, "  Point Data Format          %d\n", 
+                  LASHeader_GetDataFormatId(header));
 
-    fprintf(stderr, "  Point Data Record Length   %d\n", 
-                    LASHeader_GetDataRecordLength(header));
+    fprintf(file, "  Point Data Record Length   %d\n", 
+                  LASHeader_GetDataRecordLength(header));
 
-    fprintf(stderr, "  Number of Point Records    %d\n", 
-                    LASHeader_GetPointRecordsCount(header));
+    fprintf(file, "  Number of Point Records    %d\n", 
+                  LASHeader_GetPointRecordsCount(header));
 
-    fprintf(stderr, "  Number of Points by Return %d %d %d %d %d\n", 
-                    LASHeader_GetPointRecordsByReturnCount(header, 0), 
-                    LASHeader_GetPointRecordsByReturnCount(header, 1), 
-                    LASHeader_GetPointRecordsByReturnCount(header, 2), 
-                    LASHeader_GetPointRecordsByReturnCount(header, 3), 
-                    LASHeader_GetPointRecordsByReturnCount(header, 4));
+    fprintf(file, "  Number of Points by Return %d %d %d %d %d\n", 
+                  LASHeader_GetPointRecordsByReturnCount(header, 0), 
+                  LASHeader_GetPointRecordsByReturnCount(header, 1), 
+                  LASHeader_GetPointRecordsByReturnCount(header, 2), 
+                  LASHeader_GetPointRecordsByReturnCount(header, 3), 
+                  LASHeader_GetPointRecordsByReturnCount(header, 4));
 
-    fprintf(stderr, "  Scale Factor X Y Z         %.6f %.6f %.6f\n", 
-                    LASHeader_GetScaleX(header), 
-                    LASHeader_GetScaleY(header),
-                    LASHeader_GetScaleZ(header));
+    fprintf(file, "  Scale Factor X Y Z         %.6g %.6g %.6g\n", 
+                  LASHeader_GetScaleX(header), 
+                  LASHeader_GetScaleY(header),
+                  LASHeader_GetScaleZ(header));
 
-    fprintf(stderr, "  Offset X Y Z               %.6f %.6f %.6f\n", 
-                    LASHeader_GetOffsetX(header), 
-                    LASHeader_GetOffsetY(header), 
-                    LASHeader_GetOffsetZ(header));
+    fprintf(file, "  Offset X Y Z               %.6f %.6f %.6f\n", 
+                  LASHeader_GetOffsetX(header), 
+                  LASHeader_GetOffsetY(header), 
+                  LASHeader_GetOffsetZ(header));
 
-    fprintf(stderr, "  Min X Y Z                  %.6f %.6f %.6f\n",
-                    LASHeader_GetMinX(header), 
-                    LASHeader_GetMinY(header), 
-                    LASHeader_GetMinZ(header));
+    fprintf(file, "  Min X Y Z                  %.6f %.6f %.6f\n",
+                  LASHeader_GetMinX(header), 
+                  LASHeader_GetMinY(header), 
+                  LASHeader_GetMinZ(header));
 
-    fprintf(stderr, "  Max X Y Z                  %.6f %.6f %.6f\n", 
-                    LASHeader_GetMaxX(header), 
-                    LASHeader_GetMaxY(header), 
-                    LASHeader_GetMaxZ(header));
+    fprintf(file, "  Max X Y Z                  %.6f %.6f %.6f\n", 
+                  LASHeader_GetMaxX(header), 
+                  LASHeader_GetMaxY(header), 
+                  LASHeader_GetMaxZ(header));
     
-    fprintf(stderr, " Spatial Reference           %s\n",
-                    pszProj4);
+    fprintf(file, " Spatial Reference           %s\n",
+                  pszProj4);
 
     if (nVLR && !bSkipVLR) {
         
-    fprintf(stderr, "\n---------------------------------------------------------\n");
-    fprintf(stderr, "  VLR Summary\n");
-    fprintf(stderr, "---------------------------------------------------------\n");
+    fprintf(file, "\n---------------------------------------------------------\n");
+    fprintf(file, "  VLR Summary\n");
+    fprintf(file, "---------------------------------------------------------\n");
 
         for (i = 0; i < (int)nVLR; i++) {
             pVLR = LASHeader_GetVLR(header, i);
@@ -459,8 +459,8 @@
             nVLRRecordId = LASVLR_GetRecordId(pVLR);
             
 
-            fprintf(stderr, "   User: '%s' - Description: '%s'\n", pszVLRUser, pszVLRDescription);
-            fprintf(stderr, "   ID: %d Length: %d\n\n", nVLRRecordId, nVLRLength);
+            fprintf(file, "   User: '%s' - Description: '%s'\n", pszVLRUser, pszVLRDescription);
+            fprintf(file, "   ID: %d Length: %d\n\n", nVLRRecordId, nVLRLength);
             
             LASVLR_Destroy(pVLR);
             pVLR = NULL;
@@ -477,7 +477,7 @@
     free(pszProj4);
 }
 
-void repair_header(LASHeaderH header, LASPointSummary* summary) {
+void repair_header(FILE *file, LASHeaderH header, LASPointSummary* summary) {
 
     int repair_bounding_box = FALSE;
     int update_return_counts = FALSE;    
@@ -513,7 +513,7 @@
     }
     
     if (repair_bounding_box) {
-        fprintf(stderr, "  Reparing Bounding Box...\n");
+        fprintf(file, "  Reparing Bounding Box...\n");
         err = LASHeader_SetMin( header, 
                                 LASPoint_GetX(summary->pmin), 
                                 LASPoint_GetY(summary->pmin), 
@@ -547,7 +547,7 @@
     }
     
     if (update_return_counts) {
-        fprintf(stderr, "  Reparing Point Count by Return...\n");
+        fprintf(file, "  Reparing Point Count by Return...\n");
         for (i = 0; i < 5; i++) {
             LASHeader_SetPointRecordsByReturnCount( header,  
                                                     i, 
diff -r 9660e01d86bf apps/lasinfo.c
--- a/apps/lasinfo.c	Fri Sep 19 15:17:56 2008 -0700
+++ b/apps/lasinfo.c	Mon Sep 22 09:53:38 2008 -0700
@@ -25,8 +25,8 @@
 
 
 LASPointSummary* SummarizePoints(LASReaderH reader);
-void print_point_summary(LASPointSummary* summary, LASHeaderH header);
-void print_header(LASHeaderH header, const char* file_name, int bSkipVLR);
+void print_point_summary(FILE *file, LASPointSummary* summary, LASHeaderH header);
+void print_header(FILE *file, LASHeaderH header, const char* file_name, int bSkipVLR);
 
 void usage()
 {
@@ -240,7 +240,7 @@
 
     
     
-    print_header(header, file_name, skip_vlr);
+    print_header(stdout, header, file_name, skip_vlr);
     
     if (change_header) {
         if (system_identifier) {
@@ -298,12 +298,12 @@
         
         if (!summary)
             summary = SummarizePoints(reader);
-        print_point_summary(summary, header);
+        print_point_summary(stdout, summary, header);
         
         if (repair_header) {
-            fprintf(stderr, "\n---------------------------------------------------------\n");
-            fprintf(stderr, "  Repair Summary\n");
-            fprintf(stderr, "---------------------------------------------------------\n");
+            fprintf(stdout, "\n---------------------------------------------------------\n");
+            fprintf(stdout, "  Repair Summary\n");
+            fprintf(stdout, "---------------------------------------------------------\n");
 
             
             if (use_stdin) {
@@ -337,7 +337,7 @@
             }
             
             if (repair_bounding_box) {
-                fprintf(stderr, "  Reparing Bounding Box...\n");
+                fprintf(stdout, "  Reparing Bounding Box...\n");
                 err = LASHeader_SetMin( header, 
                                         LASPoint_GetX(summary->pmin), 
                                         LASPoint_GetY(summary->pmin), 
@@ -371,7 +371,7 @@
             }
             
             if (update_return_counts) {
-                fprintf(stderr, "  Reparing Point Count by Return...\n");
+                fprintf(stdout, "  Reparing Point Count by Return...\n");
                 for (i = 0; i < 5; i++) {
                     LASHeader_SetPointRecordsByReturnCount( header,  
                                                             i, 
diff -r 9660e01d86bf apps/lasmerge.c
--- a/apps/lasmerge.c	Fri Sep 19 15:17:56 2008 -0700
+++ b/apps/lasmerge.c	Mon Sep 22 09:53:38 2008 -0700
@@ -20,8 +20,8 @@
 #include "liblas.h"
 
 LASPointSummary* SummarizePoints(LASReaderH reader);
-void print_point_summary(LASPointSummary* summary, LASHeaderH header);
-void print_header(LASHeaderH header, const char* file_name, int bSkipVLR);
+void print_point_summary(FILE *file, LASPointSummary* summary, LASHeaderH header);
+void print_header(FILE *file, LASHeaderH header, const char* file_name, int bSkipVLR);
 
 void usage()
 {
@@ -494,9 +494,9 @@
             exit(1);
         } 
 
-        print_header(header, file_name_out, skip_vlr);        
+        print_header(stderr, header, file_name_out, skip_vlr);        
         summary = SummarizePoints(reader);
-        print_point_summary(summary, header);
+        print_point_summary(stderr, summary, header);
         
         LASHeader_Destroy(header);
         header = NULL;            
-------------- next part --------------
A non-text attachment was scrubbed...
Name: las2las.c
Type: application/octet-stream
Size: 29355 bytes
Desc: not available
Url : http://lists.osgeo.org/pipermail/liblas-devel/attachments/20080922/1c062283/las2las.obj
-------------- next part --------------
A non-text attachment was scrubbed...
Name: las2txt.c
Type: application/octet-stream
Size: 18587 bytes
Desc: not available
Url : http://lists.osgeo.org/pipermail/liblas-devel/attachments/20080922/1c062283/las2txt.obj
-------------- next part --------------
A non-text attachment was scrubbed...
Name: lascommon.c
Type: application/octet-stream
Size: 21158 bytes
Desc: not available
Url : http://lists.osgeo.org/pipermail/liblas-devel/attachments/20080922/1c062283/lascommon.obj
-------------- next part --------------
A non-text attachment was scrubbed...
Name: lasinfo.c
Type: application/octet-stream
Size: 14084 bytes
Desc: not available
Url : http://lists.osgeo.org/pipermail/liblas-devel/attachments/20080922/1c062283/lasinfo.obj
-------------- next part --------------
A non-text attachment was scrubbed...
Name: lasmerge.c
Type: application/octet-stream
Size: 19697 bytes
Desc: not available
Url : http://lists.osgeo.org/pipermail/liblas-devel/attachments/20080922/1c062283/lasmerge.obj


More information about the Liblas-devel mailing list