[英]Is there a way to get POINT coordinate from Lat, Lng using MySQL functions?
I need to get mercator coordinates from Lat
, Lng
in Node.js. 我需要从Node.js中的
Lat
, Lng
获取墨卡托坐标。 I can use some module (for example, node-sphericalmercator ). 我可以使用一些模块(例如node-sphericalmercator )。 But it means that the calculation is done on the Node server, not in MySQL:
但这意味着计算是在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])")
But I'd like to covert Lat
, Lng
into POINT
straightly in MySQL, not on Nodejs server. 但是我想在MySQL中而不是在Nodejs服务器上直接将
Lat
, Lng
转换为POINT
。 Is there some functions for this? 有一些功能吗?
INSERT INTO table VALUES SomeFuncThatTraslatesToPoint(Lng, Lat)
I admit i'm no expert, but is this something like what you're trying to do? 我承认我不是专家,但这是否像您想要的那样?
Moving lat/lon text columns into a 'point' type column 将经/纬文本列移动到“点”类型列
Specifically the section regarding GeomFromText(CONCAT('POINT(', lat, ' ', lng, ')'))
特别是有关
GeomFromText(CONCAT('POINT(', lat, ' ', lng, ')'))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.