【发布时间】:2013-10-28 22:34:31
【问题描述】:
我需要从 Node.js 中的Lat、Lng 获取墨卡托坐标。我可以使用一些模块(例如,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 中将 Lat、Lng 转换为 POINT,而不是在 Nodejs 服务器上。有一些功能吗?
INSERT INTO table VALUES SomeFuncThatTraslatesToPoint(Lng, Lat)
【问题讨论】:
标签: javascript mysql node.js google-maps mercator