Changeset 66460


Ignore:
Timestamp:
Oct 9, 2015, 5:02:55 PM (9 years ago)
Author:
wenzeslaus
Message:

v.distance: use bbox in 2D and 3D accordingly (see #2734)

Check if we are considering z and use appropriate point in box function. This should
fix #2734 where point inside an area is classified as outsie of that area when point
3D but the area is 2D. The expected behavior is reduction to 2D.

The test works with this commit but its 3D part fails with code prior to this commit.

This commit depens on r66459 which adds Vect_point_in_box_2d() function.

Location:
grass/trunk/vector/v.distance
Files:
2 added
2 edited

Legend:

Unmodified
Added
Removed
  • grass/trunk/vector/v.distance/distance.c

    r61979 r66460  
    290290    all_outside_inner = 1;
    291291
     292    int in_box;
    292293    for (i = 0; i < Points->n_points; i++) {
    293         if (Vect_point_in_box(Points->x[i], Points->y[i],
    294                               Points->z[i], abox)) {
     294        if (with_z)
     295            in_box = Vect_point_in_box(Points->x[i], Points->y[i],
     296                                       Points->z[i], abox);
     297        else
     298            in_box = Vect_point_in_box_2d(Points->x[i], Points->y[i], abox);
     299        if (in_box) {
    295300
    296301            int poly;
     
    324329
    325330                for (j = 0; j < nisles; j++) {
    326                     if (Vect_point_in_box(Points->x[i], Points->y[i], Points->z[i],
    327                                           &ibox[j])) {
     331                    if (with_z)
     332                        in_box = Vect_point_in_box(Points->x[i], Points->y[i],
     333                                                   Points->z[i], &ibox[j]);
     334                    else
     335                        in_box = Vect_point_in_box_2d(Points->x[i],
     336                                                      Points->y[i], &ibox[j]);
     337                    if (in_box) {
    328338
    329339                        poly = Vect_point_in_poly(Points->x[i], Points->y[i], iPoints[j]);
  • grass/trunk/vector/v.distance/main.c

    r66426 r66460  
    1414 * PURPOSE:      Calculates distance from a point to nearest feature in vector layer.
    1515 *               
    16  * COPYRIGHT:    (C) 2002-2012 by the GRASS Development Team
     16 * COPYRIGHT:    (C) 2002-2015 by the GRASS Development Team
    1717 *
    1818 *               This program is free software under the
Note: See TracChangeset for help on using the changeset viewer.