问题
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