[Liblas-commits] r1015 - in trunk: apps include/liblas/capi

liblas-commits at liblas.org liblas-commits at liblas.org
Wed Feb 11 14:18:14 EST 2009


Author: hobu
Date: Wed Feb 11 14:18:13 2009
New Revision: 1015
URL: http://liblas.org/changeset/1015

Log:
report min/max colors as part of a summary

Modified:
   trunk/apps/lascommon.c
   trunk/include/liblas/capi/liblas.h

Modified: trunk/apps/lascommon.c
==============================================================================
--- trunk/apps/lascommon.c	(original)
+++ trunk/apps/lascommon.c	Wed Feb 11 14:18:13 2009
@@ -45,8 +45,16 @@
 LASPointSummary* SummarizePoints(LASReaderH reader) {
     
     LASPointSummary* summary;
-    LASPointH p;
+    LASPointH p = NULL;
+    LASColorH color = NULL;
+    LASColorH min_color = NULL;
+    LASColorH max_color = NULL;
+    
     uint8_t cls = 0;
+    uint16_t red = 0;
+    uint16_t green = 0;
+    uint16_t blue = 0;
+    
     int i = 0;
 
     summary = (LASPointSummary*) malloc(sizeof(LASPointSummary));
@@ -138,7 +146,35 @@
         
         cls = LASPoint_GetClassification(p);
         LASPoint_SetClassification(summary->pmin, MIN(cls, LASPoint_GetClassification(summary->pmin)));
-        LASPoint_SetClassification(summary->pmax, MAX(cls, LASPoint_GetClassification(summary->pmax)));  
+        LASPoint_SetClassification(summary->pmax, MAX(cls, LASPoint_GetClassification(summary->pmax)));
+        
+        color = LASPoint_GetColor(p);
+        min_color = LASPoint_GetColor(summary->pmin);
+        max_color = LASPoint_GetColor(summary->pmax);
+        
+        red = MIN(LASColor_GetRed(LASPoint_GetColor(summary->pmin)), LASColor_GetRed(color));
+        green = MIN(LASColor_GetGreen(LASPoint_GetColor(summary->pmin)), LASColor_GetGreen(color));
+        blue = MIN(LASColor_GetBlue(LASPoint_GetColor(summary->pmin)), LASColor_GetBlue(color));
+
+        LASColor_SetRed(min_color, red);
+        LASColor_SetGreen(min_color, green);
+        LASColor_SetBlue(min_color, blue);
+        
+        LASPoint_SetColor(summary->pmin, min_color);
+        LASColor_Destroy(min_color);
+
+        red = MAX(LASColor_GetRed(LASPoint_GetColor(summary->pmax)), LASColor_GetRed(color));
+        green = MAX(LASColor_GetGreen(LASPoint_GetColor(summary->pmax)), LASColor_GetGreen(color));
+        blue = MAX(LASColor_GetBlue(LASPoint_GetColor(summary->pmax)), LASColor_GetBlue(color));
+
+        LASColor_SetRed(max_color, red);
+        LASColor_SetGreen(max_color, green);
+        LASColor_SetBlue(max_color, blue);
+        
+        LASPoint_SetColor(summary->pmax, max_color);
+        LASColor_Destroy(color);
+        
+        
 
         summary->classification[(cls & 31)]++;            
         if (cls & 32) summary->classification_synthetic++;          
@@ -201,7 +237,11 @@
     fprintf(file, "  Classification:\t%d\n",
                   LASPoint_GetClassification(point)
                   );
-
+    fprintf(file, "  Color:\t%d %d %d\n",
+                  LASColor_GetRed(LASPoint_GetColor(point)),
+                  LASColor_GetGreen(LASPoint_GetColor(point)),
+                  LASColor_GetBlue(LASPoint_GetColor(point))
+                  );
 }
 void print_point_summary(FILE *file, LASPointSummary* summary, LASHeaderH header) {
 
@@ -273,6 +313,17 @@
                   LASPoint_GetClassification(summary->pmin),
                   LASPoint_GetClassification(summary->pmax)
                   );
+    fprintf(file, "  Minimum Color:\t %d %d %d\n",
+                  LASColor_GetRed(LASPoint_GetColor(summary->pmin)),
+                  LASColor_GetGreen(LASPoint_GetColor(summary->pmin)),
+                  LASColor_GetBlue(LASPoint_GetColor(summary->pmin))
+        );
+
+    fprintf(file, "  Maximum Color:\t %d %d %d\n",
+                  LASColor_GetRed(LASPoint_GetColor(summary->pmax)),
+                  LASColor_GetGreen(LASPoint_GetColor(summary->pmax)),
+                  LASColor_GetBlue(LASPoint_GetColor(summary->pmax))
+        );
 
     fprintf(file, "\n  Number of Points by Return\n");
     fprintf(file, "---------------------------------------------------------\n");

Modified: trunk/include/liblas/capi/liblas.h
==============================================================================
--- trunk/include/liblas/capi/liblas.h	(original)
+++ trunk/include/liblas/capi/liblas.h	Wed Feb 11 14:18:13 2009
@@ -95,6 +95,9 @@
     uint16_t numret;
     uint16_t scandir;
     uint16_t fedge;
+    uint16_t red;
+    uint16_t green;
+    uint16_t blue;
     long rgpsum;    
     int number_of_point_records;
     int number_of_points_by_return[8];


More information about the Liblas-commits mailing list