Loading...
Logo
Processing Forum
Hi,

when i saw a recent post about Dijkstra implementation in P5, I thought It'd be nice to share a recent experiment. It's an attempt to make a traffic simulation in a medium-sized city.



I read GIS data into a GLGraphics VBO (GLModel) using OpenJUMP library, populated the road network with cars and then used Dijkstra to find routes for the cars to drive on. There were quite a few challenges in constructing a navigable network, but it runs quite smoothly in Processing, considering there are millions of polygons to render.

Somewhat more detailed description with video here. I also uploaded the entire sketch with data on the site, you can find the link there, or just download it directly. It's not very good programming, I was a little confused about Java then, but it works.

Hope you like it, I had much fun programming.

Best,

Marko

Replies(5)

Thanks for sharing. I would suggest using...
Copy code
  1.       Object in = parser.parse((new FileReader(p.dataPath("builds.json"))));
  2.       Object in = parser.parse((new FileReader(p.dataPath("paths.json"))));
...in Buildings.java and SloRoads.java respectively. This will make your sketch path-independent meaning it will work no matter which computer and which paths it's located on. Currently it only works on your computer and your current path, which one has to change manually to make it work.
You're right, sloppy of me. I just checked if the sketch works before uploading, but not if it's path-independent. Sorry.
I corrected that as you suggested and uploaded a new version at the same address.
Thanks!
solipsy

that is really really awesome!!!  ,thanks for sharing.
However i have a problem running it, i get "the package 'org.jgrapht' does not exit" i really cannot understand why..

i am on debian 64mb, i even downloaded the library again, but no luck...


any ideas? 

(i want to try to make something similar with different data so i have some more questions, but first i d like to run your application  )

(arrgghhh..."follow this topic" & bookmark this topic do not work anymore?)
Hmmm ... that's strange.  It runs on Windows64 bit, that much I know.  I never tried to run it on Debian.

You could probably begin to debug with a simpler program to see if the problem is in the library. I wrote one such sketch for you, it's here: https://dl.dropbox.com/u/58577159/test_jgrapht.rar

It constructs a graph, adds a few vertices and a few edges and then prints out all edges that are touching the first vertex.
If it works, you should see something like:

(vertex1 : vertex2)
(vertex1 : vertex3)

We can take it from there, depending on the result. If you use Eclipse, I can put the Eclipse project somewhere for download, maybe that will work. Another idea would be to try the sketch out with 32-bit Processing 1.5.1, as this is what I use.

Test it out and let me know. Maybe it's best if you email me at vito (dot) solipsy (at) gmail (dot) com, or continue here if you think it's a common error.

Best,

Marko


hi solipsy and sorry for my late reply, it seems that forum notifications do not work any more, i subscribed to this topic and never got an email for you latest post...

thanks for your last sketch to test the library but i actually got your traffic network sketch working and it is really really beautiful!!

the problem was that since you made the whole project in eclipse, you had different folder names than those that processing understands, "Code" has to be "code" in order to see the libraries, actually if i just rename it, it does not work, i had to delete the folder and drag & drop the jars into the pde to create a new  code folder...


actually i found some data (shp files) and i will try to make it myself, but i am really new to these algorithms, (just did them in coursera`s Algorithms II class)and probably will take me some time..

i just try to figure out how to correctly get the streets from the shapefiles (with the mapThing library) which is not as easy as i thought ...these shapefiles are huge pain . from what i understand, for every street i need to have , lets say, something like arraylist<LineSegments>,  to know which is the first and the last segment and the street crossings...