数据类型在Mysql中存储经度/纬度 [英] Datatype to Store Longitude/Latitude in Mysql
问题描述
'43 .005895',' - 71.013202'
Trying使用:
$ b $ pre $ INSERT INTO表(fanDetLocZip,fanDetLocCity,fanDetLocState,fanDetLocLat,fanDetLocLong,fanDetLocTZ,fanDetLocDST)
VALUES (00210,朴茨茅斯,NH,43.005895,-71.013202,-5,1);
我正在使用数据类型 SPATIAL
, GEOMETRY
。
它给我错误:
无法从发送到GEOMETRY字段的数据中获取几何对象
所有值都有2位数字,小数点后6位小数。我如何存储在MySQL中?
当我使用以下命令时出现错误:
INSERT INTO表(fanDetLocZip,fanDetLocCity,fanDetLocState,fanDetLocLatLong,fanDetLocTZ,fanDetLocDST )
VALUES(00210,'朴次茅斯','NH',点(43.005895,-71.013202),-5,1)
错误图片:
POINT()
来存储 GEOMETRY
类型的列。或 POINT
: POINT(43.005895,-71.013202)
如果Geometry列被命名为 geom
,您可以使用这个:
$ b $ pre $ code>插入表
(...,geom,...)
VALUES
(...,POINT(43.005895,-71.013202),...)
如果要显示存储的数据,可以使用 $ b $ b
SELECT X(geom)AS x,Y(geom)AS
pre>
FROM table
'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
.Its giving me errors like:
Cannot get geometry object from data you send to the GEOMETRY field
All the values have 2 digits, and 6 decimal places after decimal. How do I store this in 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 typeGEOMETRY
orPOINT
:POINT(43.005895, -71.013202)
If the Geometry column is named
geom
, you can use this:INSERT INTO table ( ..., geom, ...) VALUES ( ..., POINT(43.005895, -71.013202), ...)
If you want to show data stored, you can use the
X()
andY()
functions:SELECT X(geom) AS x, Y(geom) AS y FROM table
这篇关于数据类型在Mysql中存储经度/纬度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!