Changeset 66343
- Timestamp:
- Sep 26, 2015, 5:14:00 PM (9 years ago)
- File:
-
- 1 edited
-
grass/trunk/vector/v.in.lidar/main.c (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
grass/trunk/vector/v.in.lidar/main.c
r66255 r66343 113 113 struct GModule *module; 114 114 struct Option *in_opt, *out_opt, *spat_opt, *filter_opt, *class_opt; 115 struct Option *id_layer_opt, *return_layer_opt, *class_layer_opt; 115 116 struct Option *skip_opt, *preserve_opt, *offset_opt, *limit_opt; 116 117 struct Option *outloc_opt; 117 118 struct Flag *print_flag, *notab_flag, *region_flag, *notopo_flag; 119 struct Flag *nocats_flag; 118 120 struct Flag *over_flag, *extend_flag, *no_import_flag; 119 121 char buf[2000]; … … 171 173 172 174 out_opt = G_define_standard_option(G_OPT_V_OUTPUT); 173 175 176 id_layer_opt = G_define_standard_option(G_OPT_V_FIELD); 177 id_layer_opt->key = "id_layer"; 178 id_layer_opt->label = _("Layer number to store generated point ID as category"); 179 id_layer_opt->answer = NULL; 180 id_layer_opt->guisection = _("Categories"); 181 182 return_layer_opt = G_define_standard_option(G_OPT_V_FIELD); 183 return_layer_opt->key = "return_layer"; 184 return_layer_opt->label = _("Layer number to store return number as category"); 185 return_layer_opt->answer = NULL; 186 return_layer_opt->guisection = _("Categories"); 187 188 class_layer_opt = G_define_standard_option(G_OPT_V_FIELD); 189 class_layer_opt->key = "class_layer"; 190 class_layer_opt->label = _("Layer number to store class number as category"); 191 class_layer_opt->answer = NULL; 192 class_layer_opt->guisection = _("Categories"); 193 174 194 spat_opt = G_define_option(); 175 195 spat_opt->key = "spatial"; … … 266 286 notab_flag->guisection = _("Speed"); 267 287 288 nocats_flag = G_define_flag(); 289 nocats_flag->key = 'c'; 290 nocats_flag->label = 291 _("Store only the coordinates"); 292 nocats_flag->description = 293 _("Do not add categories to points and do not create attribute table"); 294 nocats_flag->guisection = _("Speed"); 295 268 296 notopo_flag = G_define_standard_flag(G_FLG_V_TOPO); 269 297 notopo_flag->guisection = _("Speed"); … … 284 312 285 313 G_option_exclusive(skip_opt, preserve_opt, NULL); 314 G_option_excludes(nocats_flag, id_layer_opt, return_layer_opt, class_layer_opt, NULL); 286 315 287 316 /* The parser checks if the map already exists in current mapset, this is … … 292 321 if (G_parser(argc, argv)) 293 322 exit(EXIT_FAILURE); 323 324 /* no cats implies no table */ 325 if (nocats_flag->answer) 326 notab_flag->answer = 1; 294 327 295 328 /* Don't crash on cmd line if file not found */ … … 343 376 else 344 377 G_fatal_error(_("Unknown filter option <%s>"), filter_opt->answer); 378 } 379 380 int id_layer = 0; 381 int return_layer = 0; 382 int class_layer = 0; 383 if (id_layer_opt->answer) 384 id_layer = atoi(id_layer_opt->answer); 385 if (return_layer_opt->answer) 386 return_layer = atoi(return_layer_opt->answer); 387 if (class_layer_opt->answer) 388 class_layer = atoi(class_layer_opt->answer); 389 /* If no layer specified by user, force 1 to be used for ids. 390 * If id_layer not specified by the attributes table was, find a layer. 391 * nocats implies notab and we don't add any layers. 392 * Also when layers are set to zero by user, we consider it as if 393 * the nocats flag would be specified. We use !id_layer_opt->answer 394 * to see that user was the one not setting the id_layer which are 395 * are about to turn on. 396 * Later on, layer set to 0 is considered as no layer set. 397 */ 398 if (!nocats_flag->answer && !id_layer_opt->answer && !return_layer && !class_layer) { 399 id_layer = 1; 400 } 401 if (!notab_flag->answer && !id_layer) { 402 /* get the first free layer number */ 403 for (i = 1; i <= MAX(return_layer, class_layer) + 1; i++) { 404 if (i != return_layer && i != class_layer) 405 break; 406 } 407 id_layer = i; 345 408 } 346 409 … … 569 632 char *cat_col_name = GV_KEY_COLUMN; 570 633 571 Fi = Vect_default_field_info(&Map, 1, NULL, GV_1TABLE);572 573 Vect_map_add_dblink(&Map, 1, out_opt->answer, Fi->table,634 Fi = Vect_default_field_info(&Map, id_layer, NULL, GV_1TABLE); 635 636 Vect_map_add_dblink(&Map, id_layer, out_opt->answer, Fi->table, 574 637 cat_col_name, Fi->database, Fi->driver); 575 638 … … 811 874 812 875 Vect_append_point(Points, x, y, z); 813 Vect_cat_set(Cats, 1, cat); 876 if (id_layer) 877 Vect_cat_set(Cats, id_layer, cat); 878 if (return_layer) 879 Vect_cat_set(Cats, return_layer, LASPoint_GetReturnNumber(LAS_point)); 880 if (class_layer) 881 Vect_cat_set(Cats, class_layer, LASPoint_GetClassification(LAS_point)); 814 882 Vect_write_line(&Map, GV_POINT, Points, Cats); 815 883
Note:
See TracChangeset
for help on using the changeset viewer.
