22 static double dist_squared(
double,
double,
double,
double);
53 G_debug(3,
"dig_node_add_line(): node = %d line = %d", nodeid, lineid);
55 node = plus->
Node[nodeid];
69 G_debug(3,
" angle = %f", angle);
73 if (angle >= node->
angles[i - 1])
81 node->
lines[i] = lineid;
86 "dig_node_add_line(): line %d added position %d n_lines: %d angle %f",
87 lineid, i, node->
n_lines, angle);
109 G_debug(3,
"dig_add_node(): n_nodes = %d, alloc_nodes = %d",
121 node = plus->
Node[nnum];
130 G_debug(3,
"new node = %d, n_nodes = %d, alloc_nodes = %d", nnum,
149 register int first_time;
150 register int have_match;
152 double least_dist, dist;
159 for (i = 1; i <= plus->
n_nodes; i++) {
163 node = plus->
Node[i];
164 if ((fabs(node->
x - x) <= thresh) && (fabs(node->
y - y) <= thresh)) {
165 dist = dist_squared(x, y, node->
x, node->
y);
172 if (dist < least_dist) {
203 G_debug(3,
"dig_node_line_angle: node = %d line = %d", nodeid, lineid);
205 node = plus->
Node[nodeid];
208 for (i = 0; i < nlines; i++) {
209 if (node->
lines[i] == lineid)
213 G_fatal_error(
_(
"Attempt to read line angle for the line which is not connected to the node: " 214 "node %d, line %d"), nodeid, lineid);
219 static double dist_squared(
double x1,
double y1,
double x2,
double y2)
225 return (dx * dx + dy * dy);
void void void void G_fatal_error(const char *,...) __attribute__((format(printf
plus_t alloc_nodes
Number of allocated nodes.
float dig_node_line_angle(struct Plus_head *plus, int nodeid, int lineid)
Return line angle.
struct P_node ** Node
Array of nodes.
float dig_calc_end_angle(const struct line_pnts *, double)
plus_t n_lines
Number of attached lines (size of lines, angle)
plus_t * lines
List of connected lines.
int dig_add_node(struct Plus_head *plus, double x, double y, double z)
Add new node to plus structure.
double z
Z coordinate (used only for 3D data)
Feature geometry info - coordinates.
float dig_calc_begin_angle(const struct line_pnts *, double)
Basic topology-related info.
float * angles
List of angles of connected lines.
int dig_node_alloc_line(struct P_node *, int)
Allocate space in P_node struct.
struct P_node * dig_alloc_node()
Allocate new node structure.
Topological feature - node.
int dig_spidx_add_node(struct Plus_head *, int, double, double, double)
Add new node to spatial index.
int dig_which_node(struct Plus_head *plus, double x, double y, double thresh)
Return actual index into node arrays of the first set of matching coordinates.
int dig_node_add_line(struct Plus_head *plus, int nodeid, int lineid, const struct line_pnts *points, int type)
Add line info to node.
int G_debug(int, const char *,...) __attribute__((format(printf
int dig_alloc_nodes(struct Plus_head *, int)
Reallocate array of pointers to nodes.
plus_t n_nodes
Current number of topological features derived from vector geometries.