简体   繁体   中英

Generate path from 2 coordinates

This is kind of hard to explain...

I have an image (campus map), for example I have coordinates of A and B relative to the image, I need to generate a path from A to B using the roads in the map, kinda like google directions but not that complex. I created a table of locations and their coordinates in the database like this:

id | coord_x | coord_y | location
1  | 45      | 150     | Library
2  | 61      | 80      | Cafeteria

I'm confused in the road part, I mean I can create a straight line from A to B but I need to use the road as path (like google directions). I don't know how I will save the roads in the database and how I will calculate the path, need help pls...

You will have to set waypoints and connect them in a way it is possible to walk along the connections. If you are allowed to use any datastore you want I would go for a graph database and build upon the following example: https://neo4j.com/blog/finding-the-shortest-path-through-the-park/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM