PostGIS  2.5.0dev-r@@SVN_REVISION@@
LWPOINT * geography_centroid_from_wpoints ( const uint32_t  srid,
const POINT3DM points,
const uint32_t  size 
)

Convert lat-lon-points to x-y-z-coordinates, calculate a weighted average point and return lat-lon-coordinated.

Definition at line 179 of file geography_centroid.c.

References cart_to_lwpoint(), lonlat_to_cart(), lwfree(), POINT3DM::m, pixval::x, POINT3D::x, pixval::y, POINT3D::y, and POINT3D::z.

Referenced by geography_centroid(), geography_centroid_from_mline(), and geography_centroid_from_mpoly().

180 {
181  double_t x_sum = 0;
182  double_t y_sum = 0;
183  double_t z_sum = 0;
184  double_t weight_sum = 0;
185 
186  double_t weight = 1;
187  POINT3D* point;
188 
189  uint32_t i;
190  for (i = 0; i < size; i++ )
191  {
192  point = lonlat_to_cart(points[i].x, points[i].y);
193  weight = points[i].m;
194 
195  x_sum += point->x * weight;
196  y_sum += point->y * weight;
197  z_sum += point->z * weight;
198 
199  weight_sum += weight;
200 
201  lwfree(point);
202  }
203 
204  return cart_to_lwpoint(x_sum, y_sum, z_sum, weight_sum, srid);
205 }
LWPOINT * cart_to_lwpoint(const double_t x_sum, const double_t y_sum, const double_t z_sum, const double_t weight_sum, const uint32_t srid)
void lwfree(void *mem)
Definition: lwutil.c:244
double y
Definition: liblwgeom.h:339
POINT3D * lonlat_to_cart(const double_t raw_lon, const double_t raw_lat)
double x
Definition: liblwgeom.h:339
double z
Definition: liblwgeom.h:339
unsigned int uint32_t
Definition: uthash.h:78
double m
Definition: liblwgeom.h:345
tuple x
Definition: pixval.py:53
tuple y
Definition: pixval.py:54

Here is the call graph for this function:

Here is the caller graph for this function: