3

I just called the ST_CENTROID(), MySQL 8 returns:

[22001][3618] Data truncation: st_centroid(POLYGON) has not been implemented for geographic spatial reference systems.

I want get polygons from my db which should be within a circle, I use the function ST_Distance_Sphere() ,it needs two parameters both point so I need to get the polygon`s center point to complete it.

halfer
  • 19,824
  • 17
  • 99
  • 186
康少麒
  • 31
  • 2
  • `ST_CENTROID()` still exists in [MySQL8](https://dev.mysql.com/doc/refman/8.0/en/gis-polygon-property-functions.html#function_st-centroid). – Tangentially Perpendicular Jul 07 '21 at 01:54
  • 1
    Thanks , it seems like that you just said, But how can I get the center point?I just called the ST_CENTROID() ,MYSQL8 return "[22001][3618] Data truncation: st_centroid(POLYGON) has not been implemented for geographic spatial reference systems." – 康少麒 Jul 07 '21 at 02:22
  • I've no idea, but that's a different question. I suggest you reword this to be specific about the problem you're having, since the basis of your original question is clearly wrong, but there is still an issue. – Tangentially Perpendicular Jul 07 '21 at 02:27

1 Answers1

0

I had similar issue.

This is the workaround I found:

The following command didn't work:

st_centroid(ST_GeomFromGeoJSON("...."))

And this worked:

ST_Centroid(ST_GeomFromText(ST_AsText(ST_GeomFromGeoJSON("..."))))
Alex Stanovsky
  • 1,286
  • 1
  • 13
  • 28