Create geometry (f.e. LineString()) from stored points. MySQL spatial

故事扮演 提交于 2019-12-23 05:52:13

问题


Is there any way to create some Geometry (f.e. LineString(pt1,pt2,...)) from MySQL query (where pt1,pt2,... is a result of another query, in other words pt1,pt2,... stored in MySQL table)?

Example: SELECT LineString(SELECT point FROM points) AS line; Thanks!


回答1:


I had a similar problem and solved it in this way:

SELECT pt1, pt2, pt3, pt4, @Line_string := GEOMFROMTEXT(CONCAT('LINESTRING(',pt1,' ',pt2,', ',pt3,' ',pt4,')')) FROM table;



回答2:


LineString(pt1,pt2)

MySQL and MariaDB both support this now with LineString(pt1,pt2,...)

> SELECT ST_AsText( LineString( Point(0,0), Point(1,1) ) );
+---------------------------------------------------+
| ST_AsText( LineString( Point(0,0), Point(1,1) ) ) |
+---------------------------------------------------+
| LINESTRING(0 0,1 1)                               |
+---------------------------------------------------+


来源:https://stackoverflow.com/questions/25133424/create-geometry-f-e-linestring-from-stored-points-mysql-spatial

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!