Details
-
Bug
-
Status: Confirmed (View Workflow)
-
Major
-
Resolution: Unresolved
-
10.3.27, 10.5.9, 10.2(EOL), 10.3(EOL), 10.4(EOL), 10.5
-
Ububtu 20.04, debian 9
Description
In some not so rare cases, when trying to get a centroid of a polygon, the point it returns is not even close to the polygon example:
SELECT AsText(ST_Centroid(ST_GeomFromText('POLYGON((141.473127 -31.949235,141.47322 -31.949187,141.473232 -31.949181,141.473238 -31.949186,141.473244 -31.94919,141.473254 -31.949198,141.473269 -31.94921,141.473311 -31.949243,141.47322 -31.949235,141.473231 -31.949199,141.473127 -31.949235))'))) |
Have tested this on MariaDB ver: 10.3.27 (what i'm using) and latest stable (10.5.9)
it shows a point ~600m away from the polygon. trying the exact same on MySQL ver: 5.7.20 & 8.0.22, the point is where you would expect it.
here is some GeoJSON to demonstrate the issue (use on GeoJSON.io):
{
|
"type": "FeatureCollection", |
"features": [ |
{
|
"type": "Feature", |
"properties": {"name": "centroid", "version": "MariaDB 10.3.27"}, |
"geometry": { |
"type": "Point", |
"coordinates": [141.4804016259371, -31.950833470712737] |
}
|
},
|
{
|
"type": "Feature", |
"properties": {"name": "centroid", "version": "MariaDB 10.5.9"}, |
"geometry": { |
"type": "Point", |
"coordinates": [141.4804016259371, -31.950833470712737] |
}
|
},
|
{
|
"type": "Feature", |
"properties": {"name": "centroid", "version": "MySQL 5.7.20"}, |
"geometry": { |
"type": "Point", |
"coordinates": [141.47323905138515, -31.949215928358655] |
}
|
},
|
{
|
"type": "Feature", |
"properties": {"name": "polygon"}, |
"geometry": { |
"type": "Polygon", |
"coordinates": [[[141.473127, -31.949235], [141.47322, -31.949187], [141.473232, -31.949181], [141.473238, -31.949186], [141.473244, -31.94919], [141.473254, -31.949198], [141.473269, -31.94921], [141.473311, -31.949243], [141.47322, -31.949235], [141.473231, -31.949199], [141.473127, -31.949235]]]} |
}
|
]
|
}
|
It seems to be random, alter the polygon a little and it will work. its not just a freak accident as it has been brought up to me 8-10 times is the few months we have been using MariaDB over MySQL
Results:
Server Type | Server Version | Centroid |
---|---|---|
MariaDB | 10.3.27 | POINT(141.4804016259371 -31.950833470712737) |
MariaDB | 10.5.9 | POINT(141.4804016259371 -31.950833470712737) |
MySQL | 5.7.20 | POINT(141.47323905138515 -31.949215928358655) |
MySQL | 8.0.22 | POINT(141.47323905138515 -31.949215928358655) |