This is an early example of how we might interface with the simulator libary I am building. Nothing about the library is finalized, however, so be aware that much is likely to change.
Most interfaces and such will likely be made private. The Edge
interface may gain more methods but probably won't lose any.
This program exists more for testing and edification than actually usage.
First, download the preliminary traffic simulation:
go get github.com/spencer-p/traffic
This will download my simulation library (as it stands) to your $GOPATH/src/github.com/spencer-p/traffic
.
Then save these two .go
files in another project directory to compile and use them.
If you misuse it it will tell you what you did wrong, but here's the usage:
Usage of ./sim:
-destination string
Location to go to
-directed
Count edges as directed/one way
-input string
GeoJSON to parse
-start string
Location to start at
The input json I ran this against is from the LA City GeoHub: Intersections (APIs -> GeoJSON).
- The intersections are edges and streets are vertices. This is the opposite of how it should be.
- Every edge has equal weight. (shortest path is actually fewest intersections).