Changeset 68418


Ignore:
Timestamp:
May 10, 2016, 11:03:54 AM (8 years ago)
Author:
wenzeslaus
Message:

r.in.lidar: revert r67210 for main.c to hide grid-based decimation

The grid-based decimation outputs vector and
should not be part of a raster module.
Keeping code in place for further use
hopefully in a library.

Location:
grass/trunk/raster/r.in.lidar
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • grass/trunk/raster/r.in.lidar/local_proto.h

    r67210 r68418  
    9191void string_list_free(struct StringList *string_list);
    9292
    93 /* forward declarations */
    94 struct Map_info;
    95 struct line_pnts;
    96 struct line_cats;
    97 
    98 struct VectorWriter
    99 {
    100     struct Map_info *info;
    101     struct line_pnts *points;
    102     struct line_cats *cats;
    103 #ifdef HAVE_LONG_LONG_INT
    104     unsigned long long count;
    105 #else
    106     unsigned long count;
    107 #endif
    108 };
    109 
    11093#endif /* __LOCAL_PROTO_H__ */
  • grass/trunk/raster/r.in.lidar/main.c

    r68083 r68418  
    2929#include <grass/gprojects.h>
    3030#include <grass/glocale.h>
    31 #include <grass/vector.h>
    3231#include <liblas/capi/liblas.h>
    3332
     
    8079    struct Option *trim_opt, *pth_opt, *res_opt;
    8180    struct Option *file_list_opt;
    82     struct Option *voutput_opt;
    8381    struct Flag *print_flag, *scan_flag, *shell_style, *over_flag, *extents_flag, *intens_flag;
    8482    struct Flag *set_region_flag;
    8583    struct Flag *base_rast_res_flag;
    86     struct Flag *notopo_flag;
    8784
    8885    /* LAS */
     
    114111
    115112    output_opt = G_define_standard_option(G_OPT_R_OUTPUT);
    116     output_opt->required = NO;
     113    output_opt->required = YES;
    117114    output_opt->guisection = _("Output");
    118115
     
    123120    file_list_opt->required = NO;
    124121    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");
    133122
    134123    method_opt = G_define_option();
     
    276265        _("Use base raster actual resolution instead of computational region");
    277266
    278     notopo_flag = G_define_standard_flag(G_FLG_V_TOPO);
    279 
    280     G_option_required(output_opt, voutput_opt, NULL);
    281 
    282267    if (G_parser(argc, argv))
    283268        exit(EXIT_FAILURE);
     
    303288
    304289    /* parse input values */
    305     if (output_opt->answer)
    306         outmap = output_opt->answer;
    307     else
    308         outmap = NULL;
     290    outmap = output_opt->answer;
    309291
    310292    if (shell_style->answer && !scan_flag->answer) {
     
    416398
    417399    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);
    419401
    420402    base_array = NULL;
     
    513495
    514496    /* 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);
    519498
    520499    /* allocate memory for a single row of output data */
    521500    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     }
    534501
    535502    G_message(_("Reading data ..."));
     
    665632        /* potentially vector writing can be independent on the binning */
    666633        write_values(&point_binning, &bin_index_nodes, raster_row, row,
    667             cols, rtype, &vector_writer);
     634            cols, rtype, NULL);
    668635            /* 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);
    671637        }
    672638
     
    683649
    684650    /* 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);
    707661
    708662    /* set computation region to the new raster map */
  • grass/trunk/raster/r.in.lidar/point_binning.h

    r67210 r68418  
    9090                    RASTER_MAP_TYPE rtype, double trim);
    9191
    92 /* forward declaration */
    93 struct VectorWriter;
     92/* forward declarations */
     93struct Map_info;
     94struct line_pnts;
     95struct line_cats;
     96
     97struct 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};
    94108
    95109void write_values(struct PointBinning *point_binning,
Note: See TracChangeset for help on using the changeset viewer.