PostGIS  3.0.6dev-r@@SVN_REVISION@@

◆ is_clockwise()

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

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

490 {
491  int i;
492  double x_change,y_change,area;
493  double *x_new, *y_new; /* the points, translated to the origin
494  * for safer accuracy */
495 
496  x_new = (double *)malloc(sizeof(double) * num_points);
497  y_new = (double *)malloc(sizeof(double) * num_points);
498  area=0.0;
499  x_change = x[0];
500  y_change = y[0];
501 
502  for (i=0; i < num_points ; i++)
503  {
504  x_new[i] = x[i] - x_change;
505  y_new[i] = y[i] - y_change;
506  }
507 
508  for (i=0; i < num_points - 1; i++)
509  {
510  /* calculate the area */
511  area += (x[i] * y[i+1]) - (y[i] * x[i+1]);
512  }
513  if (area > 0 )
514  {
515  free(x_new);
516  free(y_new);
517  return 0; /*counter-clockwise */
518  }
519  else
520  {
521  free(x_new);
522  free(y_new);
523  return 1; /*clockwise */
524  }
525 }
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: