【问题标题】:Is there a way to get POINT coordinate from Lat, Lng using MySQL functions?有没有办法使用 MySQL 函数从 Lat、Lng 获取 POINT 坐标?
【发布时间】:2013-10-28 22:34:31
【问题描述】:

我需要从 Node.js 中的LatLng 获取墨卡托坐标。我可以使用一些模块(例如,node-sphericalmercator)。但这意味着计算是在Node服务器上完成的,而不是在MySQL中:

// Here is pseudo code example
var sphericalmercator = new Sphericalmercator();

res = "SELECT ALL lat, lng FROM table"

var rs = res.map(function(row) {
    return [sphericalmercator.forward([row.lng, row.lat])]
});

// and only then I can do subsequent INSERTs.
INSERT INTO table VALUES POINTFROMTEXT("POINT(rs[0] rs[1])")

但我想直接在 MySQL 中将 LatLng 转换为 POINT,而不是在 Nodejs 服务器上。有一些功能吗?

INSERT INTO table VALUES SomeFuncThatTraslatesToPoint(Lng, Lat)

【问题讨论】:

    标签: javascript mysql node.js google-maps mercator


    【解决方案1】:

    我承认我不是专家,但这是否像你想要做的那样?

    Moving lat/lon text columns into a 'point' type column

    特别是关于GeomFromText(CONCAT('POINT(', lat, ' ', lng, ')'))的部分

    【讨论】:

      猜你喜欢
      • 2021-10-15
      • 2011-09-08
      • 2013-01-27
      • 2018-02-19
      • 2013-06-19
      • 1970-01-01
      • 2016-02-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多