从mysql中的点构造lineString
给出下表(位置) 我想从位置列中的点构造一个线串来计算距离 如何从位置列构造lineString? 差不多从mysql中的点构造lineString,mysql,spatial-query,mysql-spatial,Mysql,Spatial Query,Mysql Spatial,给出下表(位置) 我想从位置列中的点构造一个线串来计算距离 如何从位置列构造lineString? 差不多 select vehicle_id, lineString(location) from position group by vehicle_id order by gps_time; 这是数据 select position_id,vehicle_id,astext(location),gps_time from position order by gps_time; +------
select vehicle_id, lineString(location) from position group by vehicle_id order by gps_time;
这是数据
select position_id,vehicle_id,astext(location),gps_time from position order by gps_time;
+-------------+------------+-----------------------------+---------------------+
| position_id | vehicle_id | astext(location) | gps_time |
+-------------+------------+-----------------------------+---------------------+
| 3 | 1 | POINT(44.23912 15.307647) | 2014-11-23 06:02:17 |
| 2 | 1 | POINT(44.240063 15.307788) | 2014-11-23 08:54:11 |
| 1 | 1 | POINT(44.23884 15.307585) | 2014-11-23 11:50:10 |
| 4 | 1 | POINT(44.232296 15.304604) | 2014-11-24 07:24:29 |
| 5 | 1 | POINT(44.2332 15.304803) | 2014-11-24 07:24:39 |
| 6 | 1 | POINT(44.2332 15.304803) | 2014-11-24 07:24:49 |
| 7 | 1 | POINT(44.23428 15.3052) | 2014-11-24 07:24:59 |
+-------------+------------+-----------------------------+---------------------+
我想计算特定gps_时间点之间的距离。
即位置点_id=3和位置点_id=2之间的距离,然后使用位置点_id=2和位置点_id=1之间的距离计算结果,依此类推
预期结果如下:
+------------+------------- +--------------------+---------------------+
| vehicle_id | distance(km) | start_time | end_time |
+------------+------------- +--------------------+---------------------+
| 1 | 1.2 |2014-11-23 06:02:17 | 2014-11-24 07:24:59 |
+------------+------------- +--------------------+---------------------+
距离值(1.2)只是我心目中的一个随机值。它应该根据前面的几点进行计算。给出一些预期输出的示例数据。请检查我对您问题的回答@AbhikChakraborty先生
+------------+------------- +--------------------+---------------------+
| vehicle_id | distance(km) | start_time | end_time |
+------------+------------- +--------------------+---------------------+
| 1 | 1.2 |2014-11-23 06:02:17 | 2014-11-24 07:24:59 |
+------------+------------- +--------------------+---------------------+