本文介绍了数据类型在Mysql中存储经度/纬度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

    $ b $   b 

  SELECT X(geom)AS x,Y(geom)AS 
FROM table
pre>

'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 type GEOMETRY or POINT:

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() and Y() functions:

SELECT X(geom) AS x, Y(geom) AS y
FROM table 

这篇关于数据类型在Mysql中存储经度/纬度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-12 08:18