PostGIS  3.3.9dev-r@@SVN_REVISION@@

◆ is_clockwise()

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

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

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

References free(), malloc(), pixval::x, and pixval::y.

Referenced by create_multipolygon(), create_polygon(), and ST_IsPolygonCW().

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