postgrespro / pgsphere

PgSphere provides spherical data types, functions, operators, and indexing for PostgreSQL.
https://pgsphere.org
BSD 3-Clause "New" or "Revised" License
16 stars 15 forks source link

Implemeted SQL function center() that calculates the gravity center(centroid) from array of points #33

Closed dura0ok closed 6 months ago

dura0ok commented 11 months ago

@esabol @vitcpp please, review it.

vitcpp commented 11 months ago

I have some concerns related to the cases when cartesian geometric center lies in the center of the sphere. The following situations are possible:

dura0ok commented 11 months ago

Other popular libraries, except javascript, do not even allow you to check which center of mass they give out for two antipodal points, because they write that a minimum of 6 points is needed to create a polygon. And for some reason the Javascript library writes (0,0), which is fundamentally wrong

vitcpp commented 11 months ago

We can't compare the function for calculation the centroid of a set of independent points with the calculation of a polygon figure. The set of independent points does not form a figure. We should compare the equivalent function in other spherical geometry libraries if such function exist. The only unresolved question - what to return when the points are on opposite sides. There are two cases: either we have two result points or there are no points at all (when the calculated center in 3D is near the center of the sphere).

vitcpp commented 6 months ago

There are some conceptual problems with centroid function. I propose to close it as it is not required right now. Later we may reopen it if neeed.

vitcpp commented 6 months ago

Closed as incomplete.