mysql ST_ShortestPath
时间: 2023-07-02 12:10:26 浏览: 111
MySQL ST_ShortestPath is a function that can be used to find the shortest path between two points in a spatial network graph. It takes as input the start and end points of the path and the name of the spatial network graph table. The function returns the shortest path between the two points in the form of a set of linestrings.
To use the ST_ShortestPath function, you first need to create a spatial network graph table in MySQL. This table should have columns for the node IDs, the geometry of the nodes, the edge IDs, and the geometry of the edges. Once you have created this table, you can use the ST_ShortestPath function to find the shortest path between two points.
Here is an example query that uses the ST_ShortestPath function in MySQL:
```
SELECT ST_ShortestPath(
'network_graph', -- name of the spatial network graph table
1, -- start node ID
5 -- end node ID
) as shortest_path;
```
This query will return the shortest path between node 1 and node 5 in the 'network_graph' table. The result will be a set of linestrings that represent the path between the two nodes.
阅读全文