mysqlspatialspatial-querymysql-spatial

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


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!


Solution

  • 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;