Introducing osmgraph: a crate for converting OpenStreetMap Data into Graphs

72 points NoahSchiro

Hello rust! This is my first ever crate and so I wanted to share and get some feedback from the community on this little project I've been working on:

Have you ever wanted to code your own path finding algorithm? Have you ever wanted to compute TSP but in real life? Maybe you are making a mini-metro style game and want to use real life maps. I've got the crate for you.

I often find, when I am diving into a project, that I love working with maps, or graph data structures, or some combination of these two. A while back, I tried to compute the optimal path to traverse every road in my town. it was terribly slow and was not super familiar with OSM yet. I've had a few other ideas for projects I would like to do with maps but decided that there was a need for a tool that could efficiently fetch this data for you and automatically hand you a graph! osmgraph is born!

I mentioned this is my first ever crate. I did my best to follow the crate guidelines and have docs and a hopefully nicely maintained repo with some informative examples but I know that there can always be improvements. I would love to hear what you all think could be done to improve this. Feel free to submit issues if you'd like and contributions are always welcome.

The API is free (please don't spam it though) and did I mention this is fast? As a test, I tried querying and parsing out Manhattan. There is around 2.1 million elements in the response json, 442k nodes and 274k edges and my laptop is able to rip through the json, extract the relevant information, and create a graph in a little under 3 seconds. I do have plans in the near future for optimizations as well though.

GitHub: https://github.com/NoahSchiro/osmgraph

Docs: https://docs.rs/osmgraph/latest/osmgraph/

Manhattan (along with an random A\* path in red):

https://preview.redd.it/b1rtjmmfrfjd1.png?width=3000&format=png&auto=webp&s=b8703cb82f6da71b6a7da6b3d655c2338b31e73d