MySQL:如何从 GEOMETRY 列中获取 lat/lgn 值?

MySQL: how to get lat/lgn values from GEOMETRY column?

如果一系列纬度和经度值存储在 MySQL 的 GEOMETRY 列中,一旦这些值存储为几何数据类型,是否有办法取回这些值?示例数据:

CREATE TABLE poi_milan_fp
( idno INTEGER,
  name CHARACTER(80),
  ptyp CHARACTER(50),
  area FLOAT,
  gn GEOMETRY);

INSERT INTO poi_milan_fp (idno,name,ptyp,area,gn)
VALUES (11, 'Giardini pubblici', '02 - garden',0, 
PolygonFromText('POLYGON(( 
9.197915773 45.476819539,
9.195513514 45.472823358,
9.196395088 45.471905458,
9.197969097 45.470451939,
9.200557298 45.470952889,
9.201648922 45.472091272,
9.202453092 45.471989421,
9.204439767 45.474246289,
9.198739377 45.476916834,
9.197915773 45.476819539))')
);

http://sqlfiddle.com/#!9/023746/1

According to the manual,可以使用AsText()函数。在 5.6 及更高版本中(我相信)你应该使用 ST_AsText() 函数。旧名称在最新版本中已弃用。

SELECT ST_AsText(gn) FROM poi_milan_fp;