23 #define HUGE_VAL 9999999999999.0
39 register int i, j, point, start, end, inc;
51 for (i = 0; i < n_lines; i++) {
62 for (i = 0; i < n_lines; i++) {
64 if (direction[i] > 0) {
75 for (j = start; j != end; j += inc) {
76 BPoints->
x[point] = Points->
x[j];
77 BPoints->
y[point] = Points->
y[j];
82 BPoints->
x[point] = Points->
x[j];
83 BPoints->
y[point] = Points->
y[j];
111 for (i = 1; i < Points->
n_points; i++) {
112 tot_area += (
x[i] -
x[i - 1]) * (
y[i] +
y[i - 1]);
114 *totalarea = 0.5 * tot_area;
139 unsigned int pnext, pprev, pcur = 0;
140 unsigned int lastpoint = Points->
n_points - 1;
141 double *
x, *
y, orientation;
147 for (pnext = 1; pnext < lastpoint; pnext++) {
148 if (
y[pnext] <
y[pcur])
150 else if (
y[pnext] ==
y[pcur]) {
151 if (
x[pnext] >
x[pcur])
155 pprev = (pcur == 0 ? lastpoint - 1 : pcur - 1);
156 if (
y[pnext - 1] <
y[pprev])
169 if (pnext < lastpoint - 1)
173 }
while (pnext != pcur &&
x[pcur] ==
x[pnext] &&
y[pcur] ==
y[pnext]);
180 pprev = lastpoint - 1;
181 }
while (pprev != pcur &&
x[pcur] ==
x[pprev] &&
y[pcur] ==
y[pprev]);
185 orientation = (
x[pnext] -
x[pprev]) * (
y[pcur] -
y[pprev]) -
186 (
x[pcur] -
x[pprev]) * (
y[pnext] -
y[pprev]);
194 for (pnext = 1; pnext < lastpoint; pnext++) {
195 if (
y[pnext] <
y[pcur])
197 else if (
y[pnext] ==
y[pcur]) {
198 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])
249 pprev = (pcur == 0 ? lastpoint - 1 : pcur - 1);
250 if (
y[pnext - 1] >
y[pprev])
263 if (pnext < lastpoint - 1)
267 }
while (pnext != pcur &&
x[pcur] ==
x[pnext] &&
y[pcur] ==
y[pnext]);
274 pprev = lastpoint - 1;
275 }
while (pprev != pcur &&
x[pcur] ==
x[pprev] &&
y[pcur] ==
y[pprev]);
279 orientation = (
x[pnext] -
x[pprev]) * (
y[pcur] -
y[pprev]) -
280 (
x[pcur] -
x[pprev]) * (
y[pnext] -
y[pprev]);
288 for (pnext = 1; pnext < lastpoint; pnext++) {
289 if (
y[pnext] >
y[pcur])
291 else if (
y[pnext] ==
y[pcur]) {
292 if (
x[pnext] <
x[pcur])
296 pprev = (pcur == 0 ? lastpoint - 1 : pcur - 1);
297 if (
y[pnext - 1] >
y[pprev])
310 if (pnext < lastpoint - 1)
314 }
while (pnext != pcur &&
x[pcur] ==
x[pnext] &&
y[pcur] ==
y[pnext]);
321 pprev = lastpoint - 1;
322 }
while (pprev != pcur &&
x[pcur] ==
x[pprev] &&
y[pcur] ==
y[pprev]);
326 orientation = (
x[pnext] -
x[pprev]) * (
y[pcur] -
y[pprev]) -
327 (
x[pcur] -
x[pprev]) * (
y[pnext] -
y[pprev]);
int dig_alloc_points(struct line_pnts *, int)
allocate room for 'num' X and Y arrays in struct line_pnts
int dig_get_poly_points(int n_lines, struct line_pnts **LPoints, int *direction, struct line_pnts *BPoints)
int dig_find_area_poly(struct line_pnts *Points, double *totalarea)
double dig_find_poly_orientation(struct line_pnts *Points)
Feature geometry info - coordinates.
double * y
Array of Y coordinates.
double * x
Array of X coordinates.
int n_points
Number of points.