[英]Datatype to Store Longitude/Latitude in Mysql
'43.005895','-71.013202'
Trying to use: 试图使用:
INSERT INTO table(fanDetLocZip, fanDetLocCity, fanDetLocState, fanDetLocLat, fanDetLocLong, fanDetLocTZ, fanDetLocDST)
VALUES(00210, 'Portsmouth', 'NH', '43.005895', '-71.013202', -5, 1);
I'm currently using the datatype SPATIAL
, GEOMETRY
. 我目前正在使用数据类型
SPATIAL
, GEOMETRY
。
Its giving me errors like: 它给我的错误如下:
Cannot get geometry object from data you send to the GEOMETRY field 无法从发送到GEOMETRY字段的数据中获取几何对象
All the values have 2 digits, and 6 decimal places after decimal. 所有值都有2位数,小数点后6位小数。 How do I store this in mysql?
我如何将其存储在mysql中?
Error I get when I use: 我使用时遇到错误:
INSERT INTO Table(fanDetLocZip, fanDetLocCity, fanDetLocState, fanDetLocLatLong, fanDetLocTZ, fanDetLocDST)
VALUES(00210, 'Portsmouth', 'NH', point(43.005895,-71.013202), -5,1)
Error Image: 错误图片:
You can use POINT()
to store into a column of type GEOMETRY
or POINT
: 您可以使用
POINT()
存储到GEOMETRY
或POINT
类型的列中:
POINT(43.005895, -71.013202)
If the Geometry column is named geom
, you can use this: 如果Geometry列名为
geom
,则可以使用:
INSERT INTO table
( ..., geom, ...)
VALUES
( ..., POINT(43.005895, -71.013202), ...)
If you want to show data stored, you can use the X()
and Y()
functions: 如果要显示存储的数据,可以使用
X()
和Y()
函数:
SELECT X(geom) AS x, Y(geom) AS y
FROM table
为什么不使用Float类型作为lat / long?
Float (10,6)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.