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

时间:2015-12-28 03:16:14

标签: mysql gis mysql-spatial

如果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

1 个答案:

答案 0 :(得分:1)

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

SELECT ST_AsText(gn) FROM poi_milan_fp;