Split lines into segments and calculate with middle of segment as weighted point.
Definition at line 256 of file geography_centroid.c.
257{
258 double_t tolerance = 0.0;
259 uint32_t size = 0;
260 uint32_t i, k, j = 0;
263
264
265 for (i = 0; i < mline->
ngeoms; i++) {
267 }
268
269 points = palloc(size*
sizeof(
POINT3DM));
270
271 for (i = 0; i < mline->
ngeoms; i++) {
273
274
278 double_t weight;
279
280
287
288
290
293 points[j].
m = weight;
294 j++;
295
298 points[j].
m = weight;
299 j++;
300
303 }
304 }
305
307 pfree(points);
309}
char result[OUT_DOUBLE_BUFFER_SIZE]
LWPOINT * geography_centroid_from_wpoints(const int32_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-co...
void lwgeom_set_geodetic(LWGEOM *geom, int value)
Set the FLAGS geodetic bit on geometry an all sub-geometries and pointlists.
LWGEOM * lwpoint_as_lwgeom(const LWPOINT *obj)
double lwgeom_distance_spheroid(const LWGEOM *lwgeom1, const LWGEOM *lwgeom2, const SPHEROID *spheroid, double tolerance)
Calculate the geodetic distance from lwgeom1 to lwgeom2 on the spheroid.
void lwgeom_free(LWGEOM *geom)
LWPOINT * lwpoint_make2d(int32_t srid, double x, double y)
#define LW_TRUE
Return types for functions with status returns.
static const POINT2D * getPoint2d_cp(const POINTARRAY *pa, uint32_t n)
Returns a POINT2D pointer into the POINTARRAY serialized_ptlist, suitable for reading from.
References geography_centroid_from_wpoints(), LWMLINE::geoms, getPoint2d_cp(), LW_TRUE, lwgeom_distance_spheroid(), lwgeom_free(), lwgeom_set_geodetic(), lwpoint_as_lwgeom(), lwpoint_make2d(), POINT3DM::m, LWMLINE::ngeoms, POINTARRAY::npoints, LWLINE::points, result, s, LWMLINE::srid, POINT2D::x, POINT3DM::x, POINT2D::y, and POINT3DM::y.
Referenced by geography_centroid().