Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v.distance: initialize variable; remove unused variables #5043

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions vector/v.distance/distance.c
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ int line2line(struct line_pnts *FPoints, int ftype, struct line_pnts *TPoints,
*falong = Vect_line_length(FPoints);
FPoints->n_points = np;
}
np = fseg;
// np = fseg;
if (fseg == 0)
fseg = 1;
*fangle = sangle(FPoints, fseg);
Expand Down Expand Up @@ -176,7 +176,7 @@ int line2line(struct line_pnts *FPoints, int ftype, struct line_pnts *TPoints,
*talong = Vect_line_length(TPoints);
TPoints->n_points = np;
}
np = tseg;
// np = tseg;
if (tseg == 0)
tseg = 1;
*tangle = sangle(TPoints, tseg);
Expand Down Expand Up @@ -231,7 +231,8 @@ int line2area(struct Map_info *To, struct line_pnts *Points, int type, int area,
int i, j;
double tmp_dist;
int isle, nisles;
int all_inside_outer, all_outside_outer, all_outside_inner;
int all_inside_outer, all_outside_inner;
// int all_outside_outer;
static struct line_pnts *aPoints = NULL;
static struct line_pnts **iPoints = NULL;
static struct bound_box *ibox = NULL;
Expand Down Expand Up @@ -272,7 +273,8 @@ int line2area(struct Map_info *To, struct line_pnts *Points, int type, int area,
}

/* inside area ? */
all_inside_outer = all_outside_outer = 1;
all_inside_outer = 1;
// all_outside_outer = 1;
all_outside_inner = 1;

int in_box;
Expand All @@ -291,7 +293,7 @@ int line2area(struct Map_info *To, struct line_pnts *Points, int type, int area,

if (poly > 0) {
/* inside outer ring */
all_outside_outer = 0;
// all_outside_outer = 0;
}
else {
/* outside outer ring */
Expand Down
52 changes: 24 additions & 28 deletions vector/v.distance/local_proto.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,44 +6,40 @@
#define _LOCAL_PROTO_

/* define codes for characteristics of relation between two nearest features */
#define CAT 1 /* category of nearest feature */
#define FROM_X 2 /* x coordinate of nearest point on 'from' */
/* feature */
#define FROM_Y 3 /* y coordinate of nearest point on 'from' */
/* feature */
#define TO_X 4 /* x coordinate of nearest point on 'to' */
/* feature */
#define TO_Y 5 /* y coordinate of nearest point on 'to' */
/* feature */
#define FROM_ALONG 6 /* distance to nearest point on 'from' along */
/* linear feature */
#define TO_ALONG 7 /* distance to nearest point on 'to' along */
/* linear feature */
#define DIST 8 /* minimum distance to nearest feature */
#define TO_ANGLE 9 /* angle of linear feature in nearest point */
#define TO_ATTR 10 /* attribute of nearest feature */
#define END 11 /* end of list */
enum Code {
CAT = 1, // category of nearest feature
FROM_X = 2, // x coordinate of nearest point on 'from' feature
FROM_Y = 3, // y coordinate of nearest point on 'from' feature
TO_X = 4, // x coordinate of nearest point on 'to' feature
TO_Y = 5, // y coordinate of nearest point on 'to' feature
FROM_ALONG = 6, // distance to nearest point on 'from' along linear feature
TO_ALONG = 7, // distance to nearest point on 'to' along linear feature
DIST = 8, // minimum distance to nearest feature
TO_ANGLE = 9, // angle of linear feature in nearest point
TO_ATTR = 10, // attribute of nearest feature
END = 11 // end of list
};

enum OutputFormat { PLAIN, JSON };

/* Structure to store info about nearest feature for each category */
typedef struct {
int from_cat; /* category (from) */
int count; /* number of features already found */
int to_cat; /* category (to) */
double from_x, from_y, from_z; /* coordinates of nearest 'from' point */
double to_x, to_y, to_z; /* coordinates of nearest 'to' point */
int from_cat; // category (from)
int count; // number of features already found
int to_cat; // category (to)
double from_x, from_y, from_z; // coordinates of nearest 'from' point
double to_x, to_y, to_z; // coordinates of nearest 'to' point
double from_along,
to_along; /* distance along a linear feature to the nearest point */
double from_angle; /* angle of linear feature in nearest point */
double to_angle; /* angle of linear feature in nearest point */
double dist; /* distance to nearest feature */
to_along; // distance along a linear feature to the nearest point
double from_angle; // angle of linear feature in nearest point
double to_angle; // angle of linear feature in nearest point
double dist; // distance to nearest feature
} NEAR;

/* Upload and column store */
typedef struct {
int upload; /* code */
char *column; /* column name */
enum Code upload; // code
char *column; // column name
} UPLOAD;

typedef int dist_func(const struct line_pnts *, double, double, double, int,
Expand Down
6 changes: 6 additions & 0 deletions vector/v.distance/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1454,6 +1454,8 @@ int main(int argc, char *argv[])
break;
case TO_ATTR:
sprintf(buf2, "%s %s", Upload[j].column, to_attr_sqltype);
default:
break;
}
db_append_string(&stmt, buf2);
j++;
Expand Down Expand Up @@ -1641,6 +1643,8 @@ int main(int argc, char *argv[])
sprintf(buf2, " null");
}
break;
default:
break;
}
db_append_string(&stmt, buf2);
j++;
Expand Down Expand Up @@ -1742,6 +1746,8 @@ int main(int argc, char *argv[])
sprintf(buf2, " null");
}
break;
default:
break;
}
db_append_string(&stmt, buf2);
}
Expand Down
6 changes: 5 additions & 1 deletion vector/v.distance/print.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ int print_upload(NEAR *Near, UPLOAD *Upload, int i, dbCatValArray *cvarr,
JSON_Value *relations_value, *relation_value;
JSON_Array *relations;
JSON_Object *relation_object;
char *name;
char *name = NULL;

if (format == JSON) {
relations_value = json_value_init_array();
Expand Down Expand Up @@ -105,6 +105,8 @@ int print_upload(NEAR *Near, UPLOAD *Upload, int i, dbCatValArray *cvarr,
json_object_set_null(relation_object, "value");
}
break;
default:
break;
}
json_object_set_string(relation_object, "name", name);
json_array_append_value(relations, relation_value);
Expand Down Expand Up @@ -167,6 +169,8 @@ int print_upload(NEAR *Near, UPLOAD *Upload, int i, dbCatValArray *cvarr,
fprintf(stdout, "%snull", sep);
}
break;
default:
break;
}
break;
}
Expand Down
Loading