21 static double dist_squared(
double,
double,
double,
double);
52 G_debug(3,
"dig_node_add_line(): node = %d line = %d", nodeid, lineid);
54 node = plus->
Node[nodeid];
68 G_debug(3,
" angle = %f", angle);
72 if (angle >= node->
angles[i - 1])
80 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);
108 G_debug(3,
"dig_add_node(): n_nodes = %d, alloc_nodes = %d", plus->
n_nodes,
120 node = plus->
Node[nnum];
129 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 "
214 "connected to the node: "
221 static double dist_squared(
double x1,
double y1,
double x2,
double y2)
227 return (dx * dx + dy * dy);
void void void void G_fatal_error(const char *,...) __attribute__((format(printf
int G_debug(int, const char *,...) __attribute__((format(printf
int dig_alloc_nodes(struct Plus_head *, int)
Reallocate array of pointers to nodes.
int dig_spidx_add_node(struct Plus_head *, int, double, double, double)
Add new node to spatial index.
float dig_calc_begin_angle(const struct line_pnts *, double)
int dig_node_alloc_line(struct P_node *, int)
Allocate space in P_node struct.
float dig_calc_end_angle(const struct line_pnts *, double)
struct P_node * dig_alloc_node(void)
Allocate new node structure.
float dig_node_line_angle(struct Plus_head *plus, int nodeid, int lineid)
Return line angle.
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_add_node(struct Plus_head *plus, double x, double y, double z)
Add new node to plus structure.
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.
Topological feature - node.
plus_t n_lines
Number of attached lines (size of lines, angle)
float * angles
List of angles of connected lines.
plus_t * lines
List of connected lines.
double z
Z coordinate (used only for 3D data)
Basic topology-related info.
plus_t n_nodes
Current number of topological features derived from vector geometries.
plus_t alloc_nodes
Number of allocated nodes.
struct P_node ** Node
Array of nodes.
Feature geometry info - coordinates.