23 #define HUGE_VAL 9999999999999.0
38 register int i, j, point, start, end, inc;
50 for (i = 0; i < n_lines; i++) {
61 for (i = 0; i < n_lines; i++) {
63 if (direction[i] > 0) {
74 for (j = start; j != end; j += inc) {
75 BPoints->
x[point] = Points->
x[j];
76 BPoints->
y[point] = Points->
y[j];
81 BPoints->
x[point] = Points->
x[j];
82 BPoints->
y[point] = Points->
y[j];
110 for (i = 1; i < Points->
n_points; i++) {
111 tot_area += (
x[i] -
x[i - 1]) * (
y[i] +
y[i - 1]);
113 *totalarea = 0.5 * tot_area;
138 unsigned int pnext, pprev, pcur = 0;
139 unsigned int lastpoint = Points->
n_points - 1;
140 double *
x, *
y, orientation;
146 for (pnext = 1; pnext < lastpoint; pnext++) {
147 if (
y[pnext] <
y[pcur])
149 else if (
y[pnext] ==
y[pcur]) {
150 if (
x[pnext] >
x[pcur])
154 pprev = (pcur == 0 ? lastpoint - 1 : pcur - 1);
155 if (
y[pnext - 1] <
y[pprev])
168 if (pnext < lastpoint - 1)
172 }
while (pnext != pcur &&
x[pcur] ==
x[pnext] &&
y[pcur] ==
y[pnext]);
179 pprev = lastpoint - 1;
180 }
while (pprev != pcur &&
x[pcur] ==
x[pprev] &&
y[pcur] ==
y[pprev]);
184 orientation = (
x[pnext] -
x[pprev]) * (
y[pcur] -
y[pprev]) -
185 (
x[pcur] -
x[pprev]) * (
y[pnext] -
y[pprev]);
193 for (pnext = 1; pnext < lastpoint; pnext++) {
194 if (
y[pnext] <
y[pcur])
196 else if (
y[pnext] ==
y[pcur]) {
197 if (
x[pnext] <
x[pcur])
201 pprev = (pcur == 0 ? lastpoint - 1 : pcur - 1);
202 if (
y[pnext - 1] <
y[pprev])
215 if (pnext < lastpoint - 1)
219 }
while (pnext != pcur &&
x[pcur] ==
x[pnext] &&
y[pcur] ==
y[pnext]);
226 pprev = lastpoint - 1;
227 }
while (pprev != pcur &&
x[pcur] ==
x[pprev] &&
y[pcur] ==
y[pprev]);
231 orientation = (
x[pnext] -
x[pprev]) * (
y[pcur] -
y[pprev]) -
232 (
x[pcur] -
x[pprev]) * (
y[pnext] -
y[pprev]);
240 for (pnext = 1; pnext < lastpoint; pnext++) {
241 if (
y[pnext] >
y[pcur])
243 else if (
y[pnext] ==
y[pcur]) {
244 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])
295 pprev = (pcur == 0 ? lastpoint - 1 : pcur - 1);
296 if (
y[pnext - 1] >
y[pprev])
309 if (pnext < lastpoint - 1)
313 }
while (pnext != pcur &&
x[pcur] ==
x[pnext] &&
y[pcur] ==
y[pnext]);
320 pprev = lastpoint - 1;
321 }
while (pprev != pcur &&
x[pcur] ==
x[pprev] &&
y[pcur] ==
y[pprev]);
325 orientation = (
x[pnext] -
x[pprev]) * (
y[pcur] -
y[pprev]) -
326 (
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.