<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Nov 12, 2015 at 6:07 PM, Martin Landa <span dir="ltr"><<a href="mailto:landa.martin@gmail.com" target="_blank">landa.martin@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<span class=""><br>
2015-11-12 23:51 GMT+01:00 <<a href="mailto:svn_grass@osgeo.org">svn_grass@osgeo.org</a>>:<br>
> Author: wenzeslaus<br>
> Date: 2015-11-12 14:51:02 -0800 (Thu, 12 Nov 2015)<br>
> New Revision: 66823<br>
><br>
> Modified:<br>
> grass/trunk/vector/v.in.lidar/main.c<br>
> Log:<br>
> v.in.lidar: import points only in selected areas [news]<br>
<br>
</span>I like your idea (if I understand well, it's a tag which should help<br>
us to collect release news). I would suggest also to other devs to use<br>
it. Martin<br></blockquote><div><br></div><div>Yes, it is great idea, I think Martin you came up with it couple of months ago:-) </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="HOEnZb"><div class="h5"><br>
> ===================================================================<br>
> --- grass/trunk/vector/v.in.lidar/main.c 2015-11-12 22:28:39 UTC (rev 66822)<br>
> +++ grass/trunk/vector/v.in.lidar/main.c 2015-11-12 22:51:02 UTC (rev 66823)<br>
> @@ -113,11 +113,13 @@<br>
> struct GModule *module;<br>
> struct Option *in_opt, *out_opt, *spat_opt, *filter_opt, *class_opt;<br>
> struct Option *id_layer_opt, *return_layer_opt, *class_layer_opt;<br>
> + struct Option *vector_mask_opt, *vector_mask_field_opt;<br>
> struct Option *skip_opt, *preserve_opt, *offset_opt, *limit_opt;<br>
> struct Option *outloc_opt;<br>
> struct Flag *print_flag, *notab_flag, *region_flag, *notopo_flag;<br>
> struct Flag *nocats_flag;<br>
> struct Flag *over_flag, *extend_flag, *no_import_flag;<br>
> + struct Flag *invert_mask_flag;<br>
> char buf[2000];<br>
> struct Key_Value *loc_proj_info = NULL, *loc_proj_units = NULL;<br>
> struct Key_Value *proj_info, *proj_units;<br>
> @@ -155,12 +157,12 @@<br>
> unsigned long long n_features; /* what libLAS reports as point count */<br>
> unsigned long long points_imported; /* counter how much we have imported */<br>
> unsigned long long feature_count, n_outside,<br>
> - n_filtered, n_class_filtered, not_valid;<br>
> + n_outside_mask, n_filtered, n_class_filtered, not_valid;<br>
> #else<br>
> unsigned long n_features;<br>
> unsigned long points_imported;<br>
> unsigned long feature_count, n_outside,<br>
> - n_filtered, n_class_filtered, not_valid;<br>
> + n_outside_mask, n_filtered, n_class_filtered, not_valid;<br>
> #endif<br>
><br>
> int overwrite;<br>
> @@ -227,6 +229,18 @@<br>
> "If not specified, all points are imported.");<br>
> class_opt->guisection = _("Selection");<br>
><br>
> + vector_mask_opt = G_define_standard_option(G_OPT_V_INPUT);<br>
> + vector_mask_opt->key = "mask";<br>
> + vector_mask_opt->required = NO;<br>
> + vector_mask_opt->label = _("Areas where to import points");<br>
> + vector_mask_opt->description = _("Name of vector map with areas where the points should be imported");<br>
> + vector_mask_opt->guisection = _("Selection");<br>
> +<br>
> + vector_mask_field_opt = G_define_standard_option(G_OPT_V_FIELD);<br>
> + vector_mask_field_opt->key = "mask_layer";<br>
> + vector_mask_field_opt->label = _("Layer number or name for mask option");<br>
> + vector_mask_field_opt->guisection = _("Selection");<br>
> +<br>
> skip_opt = G_define_option();<br>
> skip_opt->key = "skip";<br>
> skip_opt->type = TYPE_INTEGER;<br>
> @@ -283,6 +297,11 @@<br>
> region_flag->guisection = _("Selection");<br>
> region_flag->description = _("Limit import to the current region");<br>
><br>
> + invert_mask_flag = G_define_flag();<br>
> + invert_mask_flag->key = 'i';<br>
> + invert_mask_flag->description = _("Invert mask when selecting points");<br>
> + invert_mask_flag->guisection = _("Selection");<br>
> +<br>
> extend_flag = G_define_flag();<br>
> extend_flag->key = 'e';<br>
> extend_flag->description =<br>
> @@ -752,6 +771,23 @@<br>
> db_begin_transaction(driver);<br>
> }<br>
><br>
> + struct Map_info vector_mask;<br>
> + int naareas;<br>
> + int aarea;<br>
> + struct bound_box *mask_area_boxes;<br>
> + int invert_mask = 0;<br>
> + if (vector_mask_opt->answer) {<br>
> + if (Vect_open_old2(&vector_mask, vector_mask_opt->answer, "", vector_mask_field_opt->answer) < 2)<br>
> + G_fatal_error(_("Failed to open vector <%s>"), vector_mask_opt->answer);<br>
> + naareas = Vect_get_num_areas(&vector_mask);<br>
> + mask_area_boxes = G_malloc(naareas * sizeof(struct bound_box));<br>
> + for (aarea = 1; aarea <= naareas; aarea++) {<br>
> + Vect_get_area_box(&vector_mask, aarea, &mask_area_boxes[aarea - 1]);<br>
> + }<br>
> + if (invert_mask_flag->answer)<br>
> + invert_mask = 1;<br>
> + }<br>
> +<br>
> /* Import feature */<br>
> points_imported = 0;<br>
> cat = 1;<br>
> @@ -760,6 +796,7 @@<br>
> n_outside = 0;<br>
> n_filtered = 0;<br>
> n_class_filtered = 0;<br>
> + n_outside_mask = 0;<br>
><br>
> Points = Vect_new_line_struct();<br>
> Cats = Vect_new_cats_struct();<br>
> @@ -817,6 +854,19 @@<br>
> continue;<br>
> }<br>
> }<br>
> + if (vector_mask_opt->answer) {<br>
> + skipme = TRUE;<br>
> + for (aarea = 1; aarea <= naareas; aarea++) {<br>
> + if (Vect_point_in_area(x, y, &vector_mask, aarea, &mask_area_boxes[aarea - 1])) {<br>
> + skipme = FALSE;<br>
> + break;<br>
> + }<br>
> + }<br>
> + if (invert_mask ^ skipme) {<br>
> + n_outside_mask++;<br>
> + continue;<br>
> + }<br>
> + }<br>
> if (return_filter != LAS_ALL) {<br>
> int return_no = LASPoint_GetReturnNumber(LAS_point);<br>
> int n_returns = LASPoint_GetNumberOfReturns(LAS_point);<br>
> @@ -992,6 +1042,11 @@<br>
> db_close_database_shutdown_driver(driver);<br>
> }<br>
><br>
> + if (vector_mask_opt->answer) {<br>
> + Vect_close(&vector_mask);<br>
> + G_free(mask_area_boxes);<br>
> + }<br>
> +<br>
> LASSRS_Destroy(LAS_srs);<br>
> LASHeader_Destroy(LAS_header);<br>
> LASReader_Destroy(LAS_reader);<br>
> @@ -1004,7 +1059,7 @@<br>
> /* can be easily determined only when iterated over all points */<br>
> if (!limit_n && !cat_max_reached && points_imported != n_features<br>
> - not_valid - n_outside - n_filtered - n_class_filtered<br>
> - - offset_n_counter - n_count_filtered)<br>
> + - n_outside_mask - offset_n_counter - n_count_filtered)<br>
> G_warning(_("The underlying libLAS library is at its limits."<br>
> " Previously reported counts might have been distorted."<br>
> " However, the import itself should be unaffected."));<br>
> @@ -1018,6 +1073,8 @@<br>
> G_message(_("%llu input points were not valid"), not_valid);<br>
> if (n_outside)<br>
> G_message(_("%llu input points were outside of the selected area"), n_outside);<br>
> + if (n_outside_mask)<br>
> + G_message(_("%llu input points were outside of the area specified by mask"), n_outside_mask);<br>
> if (n_filtered)<br>
> G_message(_("%llu input points were filtered out by return number"), n_filtered);<br>
> if (n_class_filtered)<br>
> @@ -1035,6 +1092,8 @@<br>
> G_message(_("%lu input points were not valid"), not_valid);<br>
> if (n_outside)<br>
> G_message(_("%lu input points were outside of the selected area"), n_outside);<br>
> + if (n_outside_mask)<br>
> + G_message(_("%lu input points were outside of the area specified by mask"), n_outside_mask);<br>
> if (n_filtered)<br>
> G_message(_("%lu input points were filtered out by return number"), n_filtered);<br>
> if (n_class_filtered)<br>
><br>
> _______________________________________________<br>
> grass-commit mailing list<br>
> <a href="mailto:grass-commit@lists.osgeo.org">grass-commit@lists.osgeo.org</a><br>
> <a href="http://lists.osgeo.org/mailman/listinfo/grass-commit" rel="noreferrer" target="_blank">http://lists.osgeo.org/mailman/listinfo/grass-commit</a><br>
<br>
<br>
<br>
</div></div><span class="HOEnZb"><font color="#888888">--<br>
Martin Landa<br>
<a href="http://geo.fsv.cvut.cz/gwiki/Landa" rel="noreferrer" target="_blank">http://geo.fsv.cvut.cz/gwiki/Landa</a><br>
<a href="http://gismentors.cz/mentors/landa" rel="noreferrer" target="_blank">http://gismentors.cz/mentors/landa</a><br>
_______________________________________________<br>
grass-dev mailing list<br>
<a href="mailto:grass-dev@lists.osgeo.org">grass-dev@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/mailman/listinfo/grass-dev" rel="noreferrer" target="_blank">http://lists.osgeo.org/mailman/listinfo/grass-dev</a></font></span></blockquote></div><br></div></div>