[Liblas-commits] hg: 2 new changesets
liblas-commits at liblas.org
liblas-commits at liblas.org
Mon Oct 26 13:30:13 EDT 2009
changeset 5bfa8fedf282 in /home/www/liblas.org/hg
details: http://hg.liblas.org/main/hg?cmd=changeset;node=5bfa8fedf282
summary: smarten up reprojection, use header's SRS if it is there and we haven't set one with -s_srs
changeset f21138c20a3a in /home/www/liblas.org/hg
details: http://hg.liblas.org/main/hg?cmd=changeset;node=f21138c20a3a
summary: add support for #153, a --thin option
diffstat:
apps/las2las.c | 75 +++++++++++++++++++++++++++++++------
1 files changed, 63 insertions(+), 12 deletions(-)
diffs (161 lines):
diff -r e9158c0af165 -r f21138c20a3a apps/las2las.c
--- a/apps/las2las.c Sat Oct 24 22:01:06 2009 -0500
+++ b/apps/las2las.c Mon Oct 26 12:26:56 2009 -0500
@@ -147,7 +147,11 @@
int eliminated_intensity = 0;
int eliminated_class = 0;
int eliminated_first_only = 0;
- int eliminated_last_only = 0;
+ int eliminated_last_only = 0;
+ int thinned = 0;
+
+ int bThin = FALSE;
+ int nThin = 0;
double xyz_scale[3] = {0.0, 0.0, 0.0};
double xyz_offset[3] = {0.0, 0.0, 0.0};
@@ -156,6 +160,7 @@
LASPointSummary* summary = NULL;
+ char* in_wkt = NULL;
int ret = 0;
for (i = 1; i < argc; i++) {
@@ -317,7 +322,8 @@
}
}
else if ( strcmp(argv[i],"--t_srs") == 0 ||
- strcmp(argv[i],"-t_srs") == 0
+ strcmp(argv[i],"-t_srs") == 0 ||
+ strcmp(argv[i],"-t") == 0
)
{
++i;
@@ -381,6 +387,15 @@
do_pad_header = TRUE;
header_pad = atoi(argv[i]);
}
+ else if ( strcmp(argv[i],"--thin") == 0 ||
+ strcmp(argv[i],"-y") == 0
+ )
+ {
+ i++;
+ bThin = TRUE;
+ nThin = atoi(argv[i]);
+ printf("nThin %d\n");
+ }
else if (file_name_in == NULL && file_name_out == NULL)
{
file_name_in = argv[i];
@@ -435,9 +450,15 @@
exit(1);
}
+ i = 0;
while (p)
{
-
+ if (bThin && ((i % nThin) != 0)) {
+ thinned++;
+ i++;
+ p = LASReader_GetNextPoint(reader);
+ continue;
+ }
if (last_only && LASPoint_GetReturnNumber(p) != LASPoint_GetNumberOfReturns(p))
{
eliminated_last_only++;
@@ -572,7 +593,7 @@
}
p = LASReader_GetNextPoint(reader);
-
+ i++;
}
if (eliminated_first_only)
@@ -604,6 +625,11 @@
"eliminated based on intensity: %d\n",
eliminated_intensity);
+ if (bThin)
+ fprintf(stderr,
+ "thinned: %d\n",
+ thinned);
+
LASReader_Destroy(reader);
LASHeader_Destroy(header);
@@ -794,6 +820,12 @@
"Setting new coordinate system to %s", proj4_text);
free(proj4_text);
}
+
+ /* keep around the header's SRS if we don't have on set by the user */
+ if (in_srs == NULL) {
+ in_srs = LASHeader_GetSRS(surviving_header);
+ }
+
LASHeader_SetSRS(surviving_header, out_srs);
}
@@ -815,16 +847,27 @@
exit(1);
}
- if (in_srs != NULL) {
- LASWriter_SetInputSRS(writer, in_srs);
- }
+ if (do_reprojection) {
+ if (in_srs != NULL) {
+ char* in_wkt = LASSRS_GetWKT(in_srs);
+ if (strlen(in_wkt) == 0) {
+ free(in_wkt);
+ LASError_Print("Input SRS is empty, please specify with -s_srs");
+ exit(1);
+ }
+ free(in_wkt);
+ LASWriter_SetInputSRS(writer, in_srs);
+ } else {
+
+ }
- if (out_srs != NULL) {
- if (verbose) {
- fprintf(stderr,
- "Setting LASWriter_SetOutputSRS to %s", LASSRS_GetProj4(out_srs));
+ if (out_srs != NULL) {
+ if (verbose) {
+ fprintf(stderr,
+ "Setting LASWriter_SetOutputSRS to %s", LASSRS_GetProj4(out_srs));
+ }
+ LASWriter_SetOutputSRS(writer, out_srs);
}
- LASWriter_SetOutputSRS(writer, out_srs);
}
/*
@@ -865,8 +908,15 @@
exit(1);
}
+ i = 0;
while (p) {
+ if (bThin && ((i % nThin) != 0)) {
+ i++;
+ p = LASReader_GetNextPoint(reader);
+ continue;
+ }
+
if (skip_invalid && !LASPoint_IsValid(p)) {
p = LASReader_GetNextPoint(reader);
continue;
@@ -919,6 +969,7 @@
LASWriter_WritePoint(writer,p);
p = LASReader_GetNextPoint(reader);
+ i++;
}
LASWriter_Destroy(writer);
More information about the Liblas-commits
mailing list