46 fprintf(stderr,
"ERROR: file name pointer is zero\n");
50 file = fopen(file_name,
"w");
54 fprintf(stderr,
"ERROR: cannot open file '%s'\n", file_name);
60 return open(
file, header, parse_string, separator);
67 fprintf(stderr,
"ERROR: file pointer is zero\n");
76 this->parse_string = strdup(parse_string);
82 this->parse_string = strdup(
"xyzt");
86 this->parse_string = strdup(
"xyzRGB");
90 this->parse_string = strdup(
"xyztRGB");
94 this->parse_string = strdup(
"xyz");
105 if (strcmp(separator,
"comma") == 0)
109 else if (strcmp(separator,
"tab") == 0)
113 else if (strcmp(separator,
"dot") == 0 || strcmp(separator,
"period") == 0)
117 else if (strcmp(separator,
"colon") == 0)
121 else if (strcmp(separator,
"semicolon") == 0)
125 else if (strcmp(separator,
"hyphen") == 0 || strcmp(separator,
"minus") == 0)
129 else if (strcmp(separator,
"space") == 0)
135 fprintf(stderr,
"ERROR: unknown seperator '%s'\n", separator);
146 len = sprintf(
string,
"%.15f", value) - 1;
147 while (
string[len] ==
'0') len--;
148 if (
string[len] !=
'.') len++;
154 if (precision == 0.1)
155 sprintf(
string,
"%.1f", value);
156 else if (precision == 0.01)
157 sprintf(
string,
"%.2f", value);
158 else if (precision == 0.001)
159 sprintf(
string,
"%.3f", value);
160 else if (precision == 0.0001)
161 sprintf(
string,
"%.4f", value);
162 else if (precision == 0.00001)
163 sprintf(
string,
"%.5f", value);
164 else if (precision == 0.000001)
165 sprintf(
string,
"%.6f", value);
166 else if (precision == 0.0000001)
167 sprintf(
string,
"%.7f", value);
168 else if (precision == 0.00000001)
169 sprintf(
string,
"%.8f", value);
170 else if (precision == 0.000000001)
171 sprintf(
string,
"%.9f", value);
189 fprintf(
file,
"%g", temp_d);
193 fprintf(
file,
"%d", (
I32)value);
203 fprintf(
file,
"%g", temp_d);
207 fprintf(
file,
"%d", (
I32)value);
217 fprintf(
file,
"%g", temp_d);
221 fprintf(
file,
"%d", (
I32)value);
231 fprintf(
file,
"%g", temp_d);
235 fprintf(
file,
"%d", (
I32)value);
245 fprintf(
file,
"%g", temp_d);
249 fprintf(
file,
"%d", (
I32)value);
259 fprintf(
file,
"%g", temp_d);
263 fprintf(
file,
"%d", value);
273 fprintf(
file,
"%g", temp_d);
277 fprintf(
file,
"%g", value);
287 fprintf(
file,
"%g", temp_d);
291 fprintf(
file,
"%g", value);
296 fprintf(stderr,
"WARNING: extra attribute %d not (yet) implemented.\n", index);
350 fprintf(
file,
"%d", point->
rgb[0]);
353 fprintf(
file,
"%d", point->
rgb[1]);
356 fprintf(
file,
"%d", point->
rgb[2]);
376 fprintf(
file,
"%d%c%d%c%d%c%g%c%.15g%c%.15g%c%.15g", point->
wavepacket.
getIndex(),
separator_sign, (
U32)point->
wavepacket.
getOffset(),
separator_sign, point->
wavepacket.
getSize(),
separator_sign, point->
wavepacket.
getLocation(),
separator_sign, point->
wavepacket.
getXt(),
separator_sign, point->
wavepacket.
getYt(),
separator_sign, point->
wavepacket.
getZt());
379 fprintf(
file,
"%d", point->
x);
382 fprintf(
file,
"%d", point->
y);
385 fprintf(
file,
"%d", point->
z);
397 fprintf(
file,
"\012");
477 if (p[0] >=
'0' && p[0] <=
'9')
479 I32 index = (
I32)(p[0] -
'0');
482 fprintf(stderr,
"ERROR: extra attribute '%d' does not exist.\n", index);
489 fprintf(stderr,
"ERROR: unknown symbol '%c' in parse string. valid are\n", p[0]);
490 fprintf(stderr,
" 'x' : the x coordinate\n");
491 fprintf(stderr,
" 'y' : the y coordinate\n");
492 fprintf(stderr,
" 'z' : the x coordinate\n");
493 fprintf(stderr,
" 't' : the gps time\n");
494 fprintf(stderr,
" 'R' : the red channel of the RGB field\n");
495 fprintf(stderr,
" 'G' : the green channel of the RGB field\n");
496 fprintf(stderr,
" 'B' : the blue channel of the RGB field\n");
497 fprintf(stderr,
" 's' : a string or a number that we don't care about\n");
498 fprintf(stderr,
" 'i' : the intensity\n");
499 fprintf(stderr,
" 'a' : the scan angle\n");
500 fprintf(stderr,
" 'n' : the number of returns of that given pulse\n");
501 fprintf(stderr,
" 'r' : the number of the return\n");
502 fprintf(stderr,
" 'c' : the classification\n");
503 fprintf(stderr,
" 'u' : the user data\n");
504 fprintf(stderr,
" 'p' : the point source ID\n");
505 fprintf(stderr,
" 'e' : the edge of flight line flag\n");
506 fprintf(stderr,
" 'd' : the direction of scan flag\n");
507 fprintf(stderr,
" 'M' : the index of the point\n");
508 fprintf(stderr,
" 'w' : the wavepacket descriptor index\n");
509 fprintf(stderr,
" 'W' : all wavepacket attributes\n");
510 fprintf(stderr,
" 'X' : the unscaled and unoffset integer x coordinate\n");
511 fprintf(stderr,
" 'Y' : the unscaled and unoffset integer y coordinate\n");
512 fprintf(stderr,
" 'Z' : the unscaled and unoffset integer z coordinate\n");
static void lidardouble2string(char *string, double value)
I64 close(BOOL update_npoints=true)
BOOL unparse_extra_attribute(const LASpoint *point, I32 index)
BOOL check_parse_string(const char *parse_string)
F64 get_y(const I32 y) const
I32 number_extra_attributes
I32 extra_attribute_array_offsets[10]
F64 get_z(const I32 z) const
I32 get_extra_attribute_array_offset(const char *name) const
F64 get_x(const I32 x) const
void get_extra_attribute(I32 index, U8 *data) const
BOOL update_header(const LASheader *header, BOOL use_inventory=TRUE, BOOL update_extra_bytes=FALSE)
LASattribute * extra_attributes
BOOL open(const char *file_name, const LASheader *header, const char *parse_string=0, const char *separator=0)
U8 number_of_returns_of_given_pulse
BOOL write_point(const LASpoint *point)