PostGIS  3.4.0dev-r@@SVN_REVISION@@

◆ is_clockwise()

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

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

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