Browse Source

v.in.lidar: check bbox of the whole mask before checking individual areas

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@67351 15284696-431f-4ddb-bdfa-cd5b030d7da7
Vaclav Petras 9 years ago
parent
commit
5f25741bf6

+ 3 - 0
vector/v.in.lidar/testsuite/mask_test.py

@@ -31,6 +31,9 @@ POINTS = """\
 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:

+ 11 - 0
vector/v.in.lidar/vector_mask.c

@@ -18,6 +18,8 @@ void VectorMask_init(struct VectorMask *vector_mask, const char *name, const cha
     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_init(struct VectorMask *vector_mask, const char *name, const cha
 
 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 @@ void VectorMask_destroy(struct VectorMask *vector_mask)
 
 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++) {

+ 1 - 0
vector/v.in.lidar/vector_mask.h

@@ -21,6 +21,7 @@ struct bound_box;
 
 struct VectorMask {
     struct Map_info *map_info;
+    struct bound_box *map_bbox;
     struct bound_box *area_bboxes;
     int nareas;
     int inverted;