Changeset 66823
- Timestamp:
- Nov 12, 2015, 2:51:02 PM (9 years ago)
- File:
-
- 1 edited
-
grass/trunk/vector/v.in.lidar/main.c (modified) (12 diffs)
Legend:
- Unmodified
- Added
- Removed
-
grass/trunk/vector/v.in.lidar/main.c
r66561 r66823 114 114 struct Option *in_opt, *out_opt, *spat_opt, *filter_opt, *class_opt; 115 115 struct Option *id_layer_opt, *return_layer_opt, *class_layer_opt; 116 struct Option *vector_mask_opt, *vector_mask_field_opt; 116 117 struct Option *skip_opt, *preserve_opt, *offset_opt, *limit_opt; 117 118 struct Option *outloc_opt; … … 119 120 struct Flag *nocats_flag; 120 121 struct Flag *over_flag, *extend_flag, *no_import_flag; 122 struct Flag *invert_mask_flag; 121 123 char buf[2000]; 122 124 struct Key_Value *loc_proj_info = NULL, *loc_proj_units = NULL; … … 156 158 unsigned long long points_imported; /* counter how much we have imported */ 157 159 unsigned long long feature_count, n_outside, 158 n_ filtered, n_class_filtered, not_valid;160 n_outside_mask, n_filtered, n_class_filtered, not_valid; 159 161 #else 160 162 unsigned long n_features; 161 163 unsigned long points_imported; 162 164 unsigned long feature_count, n_outside, 163 n_ filtered, n_class_filtered, not_valid;165 n_outside_mask, n_filtered, n_class_filtered, not_valid; 164 166 #endif 165 167 … … 228 230 class_opt->guisection = _("Selection"); 229 231 232 vector_mask_opt = G_define_standard_option(G_OPT_V_INPUT); 233 vector_mask_opt->key = "mask"; 234 vector_mask_opt->required = NO; 235 vector_mask_opt->label = _("Areas where to import points"); 236 vector_mask_opt->description = _("Name of vector map with areas where the points should be imported"); 237 vector_mask_opt->guisection = _("Selection"); 238 239 vector_mask_field_opt = G_define_standard_option(G_OPT_V_FIELD); 240 vector_mask_field_opt->key = "mask_layer"; 241 vector_mask_field_opt->label = _("Layer number or name for mask option"); 242 vector_mask_field_opt->guisection = _("Selection"); 243 230 244 skip_opt = G_define_option(); 231 245 skip_opt->key = "skip"; … … 283 297 region_flag->guisection = _("Selection"); 284 298 region_flag->description = _("Limit import to the current region"); 299 300 invert_mask_flag = G_define_flag(); 301 invert_mask_flag->key = 'i'; 302 invert_mask_flag->description = _("Invert mask when selecting points"); 303 invert_mask_flag->guisection = _("Selection"); 285 304 286 305 extend_flag = G_define_flag(); … … 753 772 } 754 773 774 struct Map_info vector_mask; 775 int naareas; 776 int aarea; 777 struct bound_box *mask_area_boxes; 778 int invert_mask = 0; 779 if (vector_mask_opt->answer) { 780 if (Vect_open_old2(&vector_mask, vector_mask_opt->answer, "", vector_mask_field_opt->answer) < 2) 781 G_fatal_error(_("Failed to open vector <%s>"), vector_mask_opt->answer); 782 naareas = Vect_get_num_areas(&vector_mask); 783 mask_area_boxes = G_malloc(naareas * sizeof(struct bound_box)); 784 for (aarea = 1; aarea <= naareas; aarea++) { 785 Vect_get_area_box(&vector_mask, aarea, &mask_area_boxes[aarea - 1]); 786 } 787 if (invert_mask_flag->answer) 788 invert_mask = 1; 789 } 790 755 791 /* Import feature */ 756 792 points_imported = 0; … … 761 797 n_filtered = 0; 762 798 n_class_filtered = 0; 799 n_outside_mask = 0; 763 800 764 801 Points = Vect_new_line_struct(); … … 818 855 } 819 856 } 857 if (vector_mask_opt->answer) { 858 skipme = TRUE; 859 for (aarea = 1; aarea <= naareas; aarea++) { 860 if (Vect_point_in_area(x, y, &vector_mask, aarea, &mask_area_boxes[aarea - 1])) { 861 skipme = FALSE; 862 break; 863 } 864 } 865 if (invert_mask ^ skipme) { 866 n_outside_mask++; 867 continue; 868 } 869 } 820 870 if (return_filter != LAS_ALL) { 821 871 int return_no = LASPoint_GetReturnNumber(LAS_point); … … 993 1043 } 994 1044 1045 if (vector_mask_opt->answer) { 1046 Vect_close(&vector_mask); 1047 G_free(mask_area_boxes); 1048 } 1049 995 1050 LASSRS_Destroy(LAS_srs); 996 1051 LASHeader_Destroy(LAS_header); … … 1005 1060 if (!limit_n && !cat_max_reached && points_imported != n_features 1006 1061 - not_valid - n_outside - n_filtered - n_class_filtered 1007 - offset_n_counter - n_count_filtered)1062 - n_outside_mask - offset_n_counter - n_count_filtered) 1008 1063 G_warning(_("The underlying libLAS library is at its limits." 1009 1064 " Previously reported counts might have been distorted." … … 1019 1074 if (n_outside) 1020 1075 G_message(_("%llu input points were outside of the selected area"), n_outside); 1076 if (n_outside_mask) 1077 G_message(_("%llu input points were outside of the area specified by mask"), n_outside_mask); 1021 1078 if (n_filtered) 1022 1079 G_message(_("%llu input points were filtered out by return number"), n_filtered); … … 1036 1093 if (n_outside) 1037 1094 G_message(_("%lu input points were outside of the selected area"), n_outside); 1095 if (n_outside_mask) 1096 G_message(_("%lu input points were outside of the area specified by mask"), n_outside_mask); 1038 1097 if (n_filtered) 1039 1098 G_message(_("%lu input points were filtered out by return number"), n_filtered);
Note:
See TracChangeset
for help on using the changeset viewer.
