Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/64.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/vba/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
从mysql中的点构造lineString_Mysql_Spatial Query_Mysql Spatial - Fatal编程技术网

从mysql中的点构造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; +------

给出下表(位置)

我想从位置列中的点构造一个线串来计算距离

如何从位置列构造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;

+-------------+------------+-----------------------------+---------------------+
| 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 |
+------------+------------- +--------------------+---------------------+