PostGIS 3.7.0dev-r@@SVN_REVISION@@
Loading...
Searching...
No Matches

◆ is_clockwise()

static int is_clockwise ( int  num_points,
double *  x,
double *  y,
double *  z 
)
static

Definition at line 511 of file pgsql2shp-core.c.

512{
513 int i;
514 double x_change,y_change,area;
515 double *x_new, *y_new; /* the points, translated to the origin
516 * for safer accuracy */
517
518 x_new = (double *)malloc(sizeof(double) * num_points);
519 y_new = (double *)malloc(sizeof(double) * num_points);
520 area=0.0;
521 x_change = x[0];
522 y_change = y[0];
523
524 for (i=0; i < num_points ; i++)
525 {
526 x_new[i] = x[i] - x_change;
527 y_new[i] = y[i] - y_change;
528 }
529
530 for (i=0; i < num_points - 1; i++)
531 {
532 /* calculate the area */
533 area += (x[i] * y[i+1]) - (y[i] * x[i+1]);
534 }
535 if (area > 0 )
536 {
537 free(x_new);
538 free(y_new);
539 return 0; /*counter-clockwise */
540 }
541 else
542 {
543 free(x_new);
544 free(y_new);
545 return 1; /*clockwise */
546 }
547}
void * malloc(YYSIZE_T)
void free(void *)

References free(), and malloc().

Referenced by create_multipolygon(), and create_polygon().

Here is the call graph for this function:
Here is the caller graph for this function: