24 #define HUGE_VAL 9999999999999.0 41 register int i, j, point, start, end, inc;
53 for (i = 0; i < n_lines; i++) {
64 for (i = 0; i < n_lines; i++) {
66 if (direction[i] > 0) {
77 for (j = start; j != end; j += inc) {
78 BPoints->
x[point] = Points->
x[j];
79 BPoints->
y[point] = Points->
y[j];
84 BPoints->
x[point] = Points->
x[j];
85 BPoints->
y[point] = Points->
y[j];
113 for (i = 1; i < Points->
n_points; i++) {
114 tot_area += (x[i] - x[i - 1]) * (y[i] + y[i - 1]);
116 *totalarea = 0.5 * tot_area;
141 unsigned int pnext, pprev, pcur = 0;
142 unsigned int lastpoint = Points->
n_points - 1;
143 double *
x, *
y, orientation;
149 for (pnext = 1; pnext < lastpoint; pnext++) {
150 if (y[pnext] < y[pcur])
152 else if (y[pnext] == y[pcur]) {
153 if (x[pnext] > x[pcur])
155 if (x[pnext] == x[pcur]) {
156 pprev = (pcur == 0 ? lastpoint - 1 : pcur - 1);
157 if (y[pnext - 1] < y[pprev])
170 if (pnext < lastpoint - 1)
174 }
while (pnext != pcur && x[pcur] == x[pnext] && y[pcur] == y[pnext]);
181 pprev = lastpoint - 1;
182 }
while (pprev != pcur && x[pcur] == x[pprev] && y[pcur] == y[pprev]);
186 orientation = (x[pnext] - x[pprev]) * (y[pcur] - y[pprev])
187 - (x[pcur] - x[pprev]) * (y[pnext] - y[pprev]);
195 for (pnext = 1; pnext < lastpoint; pnext++) {
196 if (y[pnext] < y[pcur])
198 else if (y[pnext] == y[pcur]) {
199 if (x[pnext] < x[pcur])
201 if (x[pnext] == x[pcur]) {
202 pprev = (pcur == 0 ? lastpoint - 1 : pcur - 1);
203 if (y[pnext - 1] < y[pprev])
216 if (pnext < lastpoint - 1)
220 }
while (pnext != pcur && x[pcur] == x[pnext] && y[pcur] == y[pnext]);
227 pprev = lastpoint - 1;
228 }
while (pprev != pcur && x[pcur] == x[pprev] && y[pcur] == y[pprev]);
232 orientation = (x[pnext] - x[pprev]) * (y[pcur] - y[pprev])
233 - (x[pcur] - x[pprev]) * (y[pnext] - y[pprev]);
241 for (pnext = 1; pnext < lastpoint; pnext++) {
242 if (y[pnext] > y[pcur])
244 else if (y[pnext] == y[pcur]) {
245 if (x[pnext] > x[pcur])
247 if (x[pnext] == x[pcur]) {
248 pprev = (pcur == 0 ? lastpoint - 1 : pcur - 1);
249 if (y[pnext - 1] > y[pprev])
262 if (pnext < lastpoint - 1)
266 }
while (pnext != pcur && x[pcur] == x[pnext] && y[pcur] == y[pnext]);
273 pprev = lastpoint - 1;
274 }
while (pprev != pcur && x[pcur] == x[pprev] && y[pcur] == y[pprev]);
278 orientation = (x[pnext] - x[pprev]) * (y[pcur] - y[pprev])
279 - (x[pcur] - x[pprev]) * (y[pnext] - y[pprev]);
287 for (pnext = 1; pnext < lastpoint; pnext++) {
288 if (y[pnext] > y[pcur])
290 else if (y[pnext] == y[pcur]) {
291 if (x[pnext] < x[pcur])
293 if (x[pnext] == x[pcur]) {
294 pprev = (pcur == 0 ? lastpoint - 1 : pcur - 1);
295 if (y[pnext - 1] > y[pprev])
308 if (pnext < lastpoint - 1)
312 }
while (pnext != pcur && x[pcur] == x[pnext] && y[pcur] == y[pnext]);
319 pprev = lastpoint - 1;
320 }
while (pprev != pcur && x[pcur] == x[pprev] && y[pcur] == y[pprev]);
324 orientation = (x[pnext] - x[pprev]) * (y[pcur] - y[pprev])
325 - (x[pcur] - x[pprev]) * (y[pnext] - y[pprev]);
int dig_get_poly_points(int n_lines, struct line_pnts **LPoints, int *direction, struct line_pnts *BPoints)
int n_points
Number of points.
double dig_find_poly_orientation(struct line_pnts *Points)
double * x
Array of X coordinates.
Feature geometry info - coordinates.
int dig_alloc_points(struct line_pnts *, int)
allocate room for 'num' X and Y arrays in struct line_pnts
double * y
Array of Y coordinates.
int dig_find_area_poly(struct line_pnts *Points, double *totalarea)