[GRASS-SVN] r67351 - in grass/trunk/vector/v.in.lidar: . testsuite

svn_grass at osgeo.org svn_grass at osgeo.org
Wed Dec 23 14:35:39 PST 2015


Author: wenzeslaus
Date: 2015-12-23 14:35:39 -0800 (Wed, 23 Dec 2015)
New Revision: 67351

Modified:
   grass/trunk/vector/v.in.lidar/testsuite/mask_test.py
   grass/trunk/vector/v.in.lidar/vector_mask.c
   grass/trunk/vector/v.in.lidar/vector_mask.h
Log:
v.in.lidar: check bbox of the whole mask before checking individual areas

Modified: grass/trunk/vector/v.in.lidar/testsuite/mask_test.py
===================================================================
--- grass/trunk/vector/v.in.lidar/testsuite/mask_test.py	2015-12-23 21:35:31 UTC (rev 67350)
+++ grass/trunk/vector/v.in.lidar/testsuite/mask_test.py	2015-12-23 22:35:39 UTC (rev 67351)
@@ -31,6 +31,9 @@
 21.41013052,11.05432488,19
 """
 
+# the point with cat 4 is outside the bbox of the areas vector map
+# which is what we need for the tests
+
 AREAS = """\
 ORGANIZATION:
 DIGIT DATE:

Modified: grass/trunk/vector/v.in.lidar/vector_mask.c
===================================================================
--- grass/trunk/vector/v.in.lidar/vector_mask.c	2015-12-23 21:35:31 UTC (rev 67350)
+++ grass/trunk/vector/v.in.lidar/vector_mask.c	2015-12-23 22:35:39 UTC (rev 67351)
@@ -18,6 +18,8 @@
     vector_mask->map_info = G_malloc(sizeof(struct Map_info));
     if (Vect_open_old2(vector_mask->map_info, name, "", layer) < 2)
         G_fatal_error(_("Failed to open vector <%s>"), name);
+    vector_mask->map_bbox = G_malloc(sizeof(struct bound_box));
+    Vect_get_map_box(vector_mask->map_info, vector_mask->map_bbox);
     vector_mask->nareas = Vect_get_num_areas(vector_mask->map_info);
     vector_mask->area_bboxes = G_malloc(vector_mask->nareas * sizeof(struct bound_box));
     int i;
@@ -32,6 +34,7 @@
 
 void VectorMask_destroy(struct VectorMask *vector_mask)
 {
+    G_free(vector_mask->map_bbox);
     G_free(vector_mask->area_bboxes);
     Vect_close(vector_mask->map_info);
     G_free(vector_mask->map_info);
@@ -39,6 +42,14 @@
 
 int VectorMask_point_in(struct VectorMask *vector_mask, double x, double y)
 {
+    /* inv in res
+     *   F  T continue
+     *   F  F return F
+     *   T  T continue
+     *   T  F return T
+     */
+    if (!Vect_point_in_box_2d(x, y, vector_mask->map_bbox))
+        return vector_mask->inverted;
     int is_out = TRUE;
     int i;
     for (i = 1; i <= vector_mask->nareas; i++) {

Modified: grass/trunk/vector/v.in.lidar/vector_mask.h
===================================================================
--- grass/trunk/vector/v.in.lidar/vector_mask.h	2015-12-23 21:35:31 UTC (rev 67350)
+++ grass/trunk/vector/v.in.lidar/vector_mask.h	2015-12-23 22:35:39 UTC (rev 67351)
@@ -21,6 +21,7 @@
 
 struct VectorMask {
     struct Map_info *map_info;
+    struct bound_box *map_bbox;
     struct bound_box *area_bboxes;
     int nareas;
     int inverted;



More information about the grass-commit mailing list