Changeset 68418
- Timestamp:
- May 10, 2016, 11:03:54 AM (8 years ago)
- Location:
- grass/trunk/raster/r.in.lidar
- Files:
-
- 3 edited
-
local_proto.h (modified) (1 diff)
-
main.c (modified) (10 diffs)
-
point_binning.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
grass/trunk/raster/r.in.lidar/local_proto.h
r67210 r68418 91 91 void string_list_free(struct StringList *string_list); 92 92 93 /* forward declarations */94 struct Map_info;95 struct line_pnts;96 struct line_cats;97 98 struct VectorWriter99 {100 struct Map_info *info;101 struct line_pnts *points;102 struct line_cats *cats;103 #ifdef HAVE_LONG_LONG_INT104 unsigned long long count;105 #else106 unsigned long count;107 #endif108 };109 110 93 #endif /* __LOCAL_PROTO_H__ */ -
grass/trunk/raster/r.in.lidar/main.c
r68083 r68418 29 29 #include <grass/gprojects.h> 30 30 #include <grass/glocale.h> 31 #include <grass/vector.h>32 31 #include <liblas/capi/liblas.h> 33 32 … … 80 79 struct Option *trim_opt, *pth_opt, *res_opt; 81 80 struct Option *file_list_opt; 82 struct Option *voutput_opt;83 81 struct Flag *print_flag, *scan_flag, *shell_style, *over_flag, *extents_flag, *intens_flag; 84 82 struct Flag *set_region_flag; 85 83 struct Flag *base_rast_res_flag; 86 struct Flag *notopo_flag;87 84 88 85 /* LAS */ … … 114 111 115 112 output_opt = G_define_standard_option(G_OPT_R_OUTPUT); 116 output_opt->required = NO;113 output_opt->required = YES; 117 114 output_opt->guisection = _("Output"); 118 115 … … 123 120 file_list_opt->required = NO; 124 121 file_list_opt->guisection = _("Input"); 125 126 voutput_opt = G_define_standard_option(G_OPT_V_OUTPUT);127 voutput_opt->key = "vector_output";128 voutput_opt->required = NO;129 voutput_opt->label = _("Grid-decimated point cloud");130 voutput_opt->description = _("Grid-decimated point cloud with"131 " XYZ coordinates which are mean for all points in a raster cell");132 voutput_opt->guisection = _("Output");133 122 134 123 method_opt = G_define_option(); … … 276 265 _("Use base raster actual resolution instead of computational region"); 277 266 278 notopo_flag = G_define_standard_flag(G_FLG_V_TOPO);279 280 G_option_required(output_opt, voutput_opt, NULL);281 282 267 if (G_parser(argc, argv)) 283 268 exit(EXIT_FAILURE); … … 303 288 304 289 /* parse input values */ 305 if (output_opt->answer) 306 outmap = output_opt->answer; 307 else 308 outmap = NULL; 290 outmap = output_opt->answer; 309 291 310 292 if (shell_style->answer && !scan_flag->answer) { … … 416 398 417 399 point_binning_set(&point_binning, method_opt->answer, pth_opt->answer, 418 trim_opt->answer, voutput_opt->answer ? TRUE :FALSE);400 trim_opt->answer, FALSE); 419 401 420 402 base_array = NULL; … … 513 495 514 496 /* open output map */ 515 if (outmap) 516 out_fd = Rast_open_new(outmap, rtype); 517 else 518 out_fd = 0; /* TODO: is this correct? */ 497 out_fd = Rast_open_new(outmap, rtype); 519 498 520 499 /* allocate memory for a single row of output data */ 521 500 raster_row = Rast_allocate_output_buf(rtype); 522 523 struct Map_info voutput;524 struct VectorWriter vector_writer;525 if (voutput_opt->answer) {526 if (Vect_open_new(&voutput, voutput_opt->answer, 1) < 0)527 G_fatal_error(_("Unable to create vector map <%s>"), voutput_opt->answer);528 vector_writer.info = &voutput;529 vector_writer.points = Vect_new_line_struct();530 vector_writer.cats = Vect_new_cats_struct();531 vector_writer.count = 0;532 Vect_hist_command(&voutput);533 }534 501 535 502 G_message(_("Reading data ...")); … … 665 632 /* potentially vector writing can be independent on the binning */ 666 633 write_values(&point_binning, &bin_index_nodes, raster_row, row, 667 cols, rtype, &vector_writer);634 cols, rtype, NULL); 668 635 /* write out line of raster data */ 669 if (outmap) 670 Rast_put_row(out_fd, raster_row, rtype); 636 Rast_put_row(out_fd, raster_row, rtype); 671 637 } 672 638 … … 683 649 684 650 /* close raster file & write history */ 685 if (outmap) 686 Rast_close(out_fd); 687 688 if (outmap) { 689 sprintf(title, "Raw x,y,z data binned into a raster grid by cell %s", 690 method_opt->answer); 691 Rast_put_cell_title(outmap, title); 692 693 Rast_short_history(outmap, "raster", &history); 694 Rast_command_history(&history); 695 Rast_set_history(&history, HIST_DATSRC_1, infile); 696 Rast_write_history(outmap, &history); 697 } 698 699 /* close output vector map */ 700 if (voutput_opt->answer) { 701 if (!notopo_flag->answer) 702 Vect_build(vector_writer.info); 703 Vect_close(vector_writer.info); 704 Vect_destroy_line_struct(vector_writer.points); 705 Vect_destroy_cats_struct(vector_writer.cats); 706 } 651 Rast_close(out_fd); 652 653 sprintf(title, "Raw x,y,z data binned into a raster grid by cell %s", 654 method_opt->answer); 655 Rast_put_cell_title(outmap, title); 656 657 Rast_short_history(outmap, "raster", &history); 658 Rast_command_history(&history); 659 Rast_set_history(&history, HIST_DATSRC_1, infile); 660 Rast_write_history(outmap, &history); 707 661 708 662 /* set computation region to the new raster map */ -
grass/trunk/raster/r.in.lidar/point_binning.h
r67210 r68418 90 90 RASTER_MAP_TYPE rtype, double trim); 91 91 92 /* forward declaration */ 93 struct VectorWriter; 92 /* forward declarations */ 93 struct Map_info; 94 struct line_pnts; 95 struct line_cats; 96 97 struct VectorWriter 98 { 99 struct Map_info *info; 100 struct line_pnts *points; 101 struct line_cats *cats; 102 #ifdef HAVE_LONG_LONG_INT 103 unsigned long long count; 104 #else 105 unsigned long count; 106 #endif 107 }; 94 108 95 109 void write_values(struct PointBinning *point_binning,
Note:
See TracChangeset
for help on using the changeset viewer.
