[Liblas-commits] r1094 - trunk/apps
liblas-commits at liblas.org
liblas-commits at liblas.org
Thu Mar 12 15:40:39 EDT 2009
Author: hobu
Date: Thu Mar 12 15:40:39 2009
New Revision: 1094
URL: http://liblas.org/changeset/1094
Log:
support setting RGB colors in txt2las #103
Modified:
trunk/apps/txt2las.c
Modified: trunk/apps/txt2las.c
==============================================================================
--- trunk/apps/txt2las.c (original)
+++ trunk/apps/txt2las.c Thu Mar 12 15:40:39 2009
@@ -53,8 +53,11 @@
fprintf(stderr," u - user data (does not currently work)\n");
fprintf(stderr," p - point source ID\n");
fprintf(stderr," e - edge of flight line\n");
- fprintf(stderr," d - direction of scan flag\n\n");
-
+ fprintf(stderr," d - direction of scan flag\n");
+ fprintf(stderr," R - red channel of RGB color\n");
+ fprintf(stderr," G - green channel of RGB color\n");
+ fprintf(stderr," B - blue channel of RGB color\n\n");
+
fprintf(stderr,"\n----------------------------------------------------------\n");
fprintf(stderr," The '-scale 0.02' flag specifies the quantization. The\n");
fprintf(stderr," default value of 0.01 means that the smallest increment\n");
@@ -95,7 +98,8 @@
const char* p = parse_string;
const char* l = line;
-
+ LASColorH color = LASColor_Create();
+
while (p[0])
{
/* // we expect the x coordinate */
@@ -291,12 +295,48 @@
/* // then advance to next white space */
while (l[0] && l[0] != ' ' && l[0] != ',' && l[0] != '\t') l++;
}
+ /* // we expect the red channel of the RGB field */
+ else if (p[0] == 'R')
+ {
+ /* // first skip white spaces */
+ while (l[0] && (l[0] == ' ' || l[0] == ',' || l[0] == '\t')) l++;
+ if (l[0] == 0) return FALSE;
+ if (sscanf(l, "%d", &temp_i) != 1) return FALSE;
+ LASColor_SetRed(color, temp_i);
+ /* // then advance to next white space */
+ while (l[0] && l[0] != ' ' && l[0] != ',' && l[0] != '\t') l++;
+ }
+ /* // we expect the green channel of the RGB field */
+ else if (p[0] == 'G')
+ {
+ /* // first skip white spaces */
+ while (l[0] && (l[0] == ' ' || l[0] == ',' || l[0] == '\t')) l++;
+ if (l[0] == 0) return FALSE;
+ if (sscanf(l, "%d", &temp_i) != 1) return FALSE;
+ LASColor_SetGreen(color, temp_i);
+ /* // then advance to next white space */
+ while (l[0] && l[0] != ' ' && l[0] != ',' && l[0] != '\t') l++;
+ }
+ /* // we expect the blue channel of the RGB field */
+ else if (p[0] == 'B')
+ {
+ /* // first skip white spaces */
+ while (l[0] && (l[0] == ' ' || l[0] == ',' || l[0] == '\t')) l++;
+ if (l[0] == 0) return FALSE;
+ if (sscanf(l, "%d", &temp_i) != 1) return FALSE;
+ LASColor_SetBlue(color, temp_i);
+ /* // then advance to next white space */
+ while (l[0] && l[0] != ' ' && l[0] != ',' && l[0] != '\t') l++;
+ }
+
else
{
fprintf(stderr, "ERROR: next symbol '%s' unknown in parse control string\n", p);
}
p++;
}
+ LASPoint_SetColor(point, color);
+ LASColor_Destroy(color);
return TRUE;
}
More information about the Liblas-commits
mailing list