Friday, November 25, 2011

Open Street Map Transit Time Map

I thought that today I would do a quick post about my Open Street Map project I dabbled with a while back.
The basic concept was to create a travel time map for Brisbane that graphically shows via colour mapping the time taken to get to the city via public transport.  Sounds complicated, well it is.  The more that you look at the problem the harder it becomes.  That aside, the hardest part was finding a cohesive source of timetable information for all the different sources in Brisbane, and that was not going to happen.

Ideally I needed a database of stops, and their location, routes between stops, and timetable data.  All this info is out there, but not any easily accessible format.  The timetable and route information could be scraped of websites, but the GPS data required for the stops would just be a nightmare.  The train stations and ferries aren't that bad, but have you got any idea how many bus stops there are? Neither do I, because there are too many for one person to enter into a database.  I noticed recently the Brisbane City Council had a competition for programmers where they released this data to them.  I think it's meant for an app to find the nearest bus stop and things like that.  Anyhow, that data could be handy.

The other major problem I had is that there is only limited connectivity in the network.  By that I mean most bus stops aren't located in the same position as a train station.  So to make the network complete you need to consider ad hoc walking routes between different stops.  There is no data for this, you need to work these out for yourself.  With a bit of blood sweat and tears they could probably be derived from the OSM data set, but the project was becoming a bit too big for one person.  Don't even mention the behaviour of commuters, I walk about 6 km/h and might catch a train, where my sister walks about 4 km/h and might miss it, and because of the inherent granularity of the timetables, being a minute late to the station may mean you get to your destination 20 minutes later.

I did however manage to get an OpenGL viewer in c++ going for OSM tiles so datasets I was hopefully going to enter could be visualised.  Once that was done I called it a day.  I would still like to finish the project one day, but that's for future Grant, he has better coding skills than me, who just codes out of necessity.  It was starting to become a project that was more suited to a team of people not just one person.

Anyway here is some screen captures I recorded as the project progressed. Captions are from YouTube.

Caption - A quick tour around Brisbane in an OpenGL application.  The program uses a custom rendered set of tiles from the Open Street Map project to provide a 3D navigable map.  It's been developed as a framework for another project I have going.  Few problems, the rendering of the tiles by Mapnik had some issues not rendering certain features, and a limited amount of graphics memory (32MB) which can be seen by the less than ideal quality of the map and occasional bluring of adjacent tiles.  Neither are big problems and are easily solved.  The jittery camera movent is an artifact of the process used for the screen capture.  The tour starts in the CBD, heads toward Sherwood and on to Forest Lake.  The camera then travels towards Brisbane Airport demonstrating some of the camera movements along the way.  Nowhere as good as the other OSM-3D project out there, but I needed something simple that I could build on.  UPDATE - I have since started work on an updated version.  The framework is done just need to fill in the details.  This time I am on a new laptop with 512MB of VRAM, using Windows.  Just to make things a bit nicer I have also added a skybox and some satellite imagery from nearmap.  When rendering the tile set, it was done at twice the resolution so it should be a lot clearer.


Caption - This is the framework for the newer version of the program that was mentioned in the last clip. This was just a quick play around to show the improvement. It renders at about 200 fps but should be higher. This is because I am using a fragment shader to warp the satellite imagery to make it more realistic. I am currently changing this to use pre-warped images that can be rendered like any other texture. The clip shows the sky box and the two different speeds that the camera is able to move at. Was having issues finding a way to do the screen capture, but stumbled across FRAPS. This was done as half resolution.

Caption - Not a lot different here. Just testing a higher resolution output. Added a base test map. The satellite imagery is now pre-warped to save some time. Should be at 720p. Use the pop out feature or make it full screen for full effect, and select 720p as the resolution. Still doesn't do it justice like a video card does ;-) It's a LOT smoother. Have the fps nudging 300 again with multisampling. (I know I can't render at 300 fps, it's just for benchmarking) Now I have to get down and dirty with threads and loading the sub textures.

Caption - This is a small update, went through tidied up some code. The first stage on rendering tiles is to change the background image. As you zoom in, the details on the map become finer and the map dimensions double. The lowest detail map is 1024x1024, but the background image for the highest detail would be 524288x524288 which is unmanageable. So these large maps of higher detail have been shrunk down to 1024x1024. This allows the detail to increase but produces a blurry map, which can be seen when zooming in. But, as these are background maps this doesn't matter, the goal is to provide the right level of detail in the distance, the blurry imagery close to the camera will be rendered over by higher resolution maps. The imagery in the distance that can be seen on the zoom out is the goal. As these images are used a lot in the rendering, they are loaded on opening of the program and transferred to the graphics card and stay resident for the duration of the program. I also added a nifty little cross hair.

Caption - This is the final result for now. The project is basically a small program to view GIS data in 3D. Higher details tiles swap in and out and work to an extent, but could be done better. The data set loaded is the city train network that was downloaded from the OSM data set and simplified. The network is elevated in this clip. A tour from Ipswich to the city is shown. Now that the program is now at a stage I can use to visualise and check my data sets, I can move onto the next stage. Onward and upward.

No comments:

Post a Comment