gTraffic: Down perhaps not out.

Some of you may have come to this site from my UK road traffic site gTraffic.info. You will have noticed that there is no longer any traffic incidents available. This is because the TPEG feed which was the source of incident data has been cut by the BBC. I am fairly philosophical about this. It wasn’t like the feed was going to be there forever. I got about four years out of it which isn’t bad.

I have just shifted the URL to a different provider so I am not quite ready to kill off the site just yet. Technically I could probably put a script together which generates data from the HA rss feed. I have other stuff to get on with so that may or may not happen.

 

 

GWT: gTraffic Timeline

I occasionally have a look at my GWT traffic mashup to make sure it’s still working. I was looking at it again tonight and was struck by how many good ideas it seems to have. Good ideas that no one else seems to have bothered to pick up on. As an example take a look at the view (as of tonight) for the Berkshire area.

gTraffic

I was clicking around to make sure that the data seemed up to date and kept clicking on long running Roadworks. If you only had that view then it would be a chore to determine what was new and what was long running except that you have the ability to flick over to the time-line. Looking at that I could see right away what the latest events were. The time-line view is not perfect but I am still amazed no one else has copied this idea cos I think this is genuinely useful.

gTraffic timeline

Another one is the zoom-in/zoom-out buttons on the infowindow. My implementation jumps down to the street view and then back up to the last selected zoom level. I know this has been used elsewhere in sites connected to me but I would have thought this would be more widespread as, again, it’s a useful functionality.

gTraffic zoom

Maybe it’s just me but I think there are some good ideas here which are not represented in current traffic web sites.

Flex: flexTraffic v0.0.2

I have finally got round to making some updates to the flexTraffic site.

  • Uses my new iFrame component
  • I have added an experimental ‘graph’ pane. This is a bit of a work in progress. I had originally linked all the roads together with the events hanging off them but the end result looked like a centipede. In fact when the number of events against the road is listed, as it is here, you can see that there is rarely more than one per road. This is an experiment only and a bit of fun learning how to use the Springgraph component.
  • Flex: flexTraffic v0.0.1

    flexTraffic

    The initial version of flexTraffic is here. This application displays BBC traffic and travel information on a Google Map hosted inside a Flex app. The data is fetched from the server side using the Flex mx:HTTPService component and parsed into a format which is then passed through FABridge to the map control.

    In essence this has the same back-end as gTraffic but with a Flex application for the front-end.

    There is lots of clever stuff going on here like two way communication between the html iframe and the Flex app through FABridge. The html component is the same one from here but it has been modified so it will hide itself automatically if it’s parent holder is no longer visible (I will post an example with code for this soon).

    update: flexTraffic

    I am still working on this. So busy with other stuff that I have had very little time to put into this and when I did have time I couldn’t be bothered looking at the code. Anyway there is a version deployed but I am still ironing out stuff. I have dropped the timeline as it just isn’t good enough.

    gTraffic : Status

    I see that the parser is now receiving data properly again. Must have been a glitch in the BBC feed. I see from my web stats that the traffic (no pun intended) has dropped off somewhat.

    gTraffic : Parser problems

    There appears to be a problem with the TPEG data parser for the BBC traffic data. The incidents shown on the map are not up to date.

    Looking into it…

    Flex: Yahoo map won’t make the cut

    I have valiantly tried to use the Yahoo Map Flex component but it’s so slow to plot points that it’s completely useless.

    I was going to show the development version but probably better not to. Here is a screen shot:

    flexTraffic event pane

    – Plotting many markers is slow. This is no use to me. I’m really surprised and disappointed about this as I had thought the Flex map would be quick. Obviously having to put some sort of communication channel down to the AS2 map and then to the map tiles is having an effect.

    – The only events you can catch on the map markers are from POI (Point Of Interest) markers. The catch is that the event returned contains _no_ information about the marker. There is a fix but you have to recompile the .fla file which means you need Flash.

    The Yahoo map looks beautiful but the Flex implementation is not ready for the big time. I hate to slag anything off given the effort that’s been put into the (free) AS3 library but it’s not as if their short of cash to throw at this kind of thing.

    The only solution now is an embedded iframe and FABridge.

    Flex: Asset lookup dictionary

    Here is the latest events panel from my gTraffic rewrite in Flex here ever after to be called (until I change my mind) ‘flexTraffic’

    flexTraffic event panel

    One of the important parts of the original application was a lookup of a traffic event ‘severity’ and ‘category’ to fetch the appropriate icon for the map and the events panel (DataGrid now). This was offloaded into the Python script which generated the an atttribute with a path to the icon in the XML. I could have recreated this in the Flex code but I didn’t want to rewrite the Python script to alter the path and I had the impression that embeddeding the icons into the Flex app was ‘the right thing to do’.

    I reimplemented this lookup in ActionScript as a Dictionary of Dictionaries keyed on the same elements. This was pure graft as I was using the images contained within a Assets class which had the icons as embedded elements i.e. I had to explicity state the strings and the appropriate Class elements (images) to return from the lookup. As example for the roadworks would be:

    
    assetDict[TXT_ROADWORKS] = new Dictionary();
    assetDict[TXT_ROADWORKS]
    [TXT_SEVERITY_VERYSEVERE] = model.assets.roadworkPanelSevere;
    assetDict[TXT_ROADWORKS]
    [TXT_SEVERITY_SEVERE] = model.assets.roadworkPanelSevere;
    assetDict[TXT_ROADWORKS]
    [TXT_SEVERITY_MEDIUM] = model.assets.roadworkPanelMedium;
    assetDict[TXT_ROADWORKS]
    [TXT_SEVERITY_SLIGHT] = model.assets.roadworkPanelSlight;
    assetDict[TXT_ROADWORKS]
    [TXT_SEVERITY_VERYSLIGHT] = model.assets.roadworkPanelSlight;
    assetDict[TXT_ROADWORKS]
    [TXT_SEVERITY_UNKNOWN] = model.assets.roadworkPanelSlight;
    assetDict[TXT_ROADWORKS]
    [TXT_SEVERITY_UNSPECIFIED] = model.assets.roadworkPanelSlight;
    

    Please note, I have compacted the code to fit into this blog. See the code here..

    The PanelSeverityRenderer now has:

    
    public function getSeverityIcon(category:String, severity:String):Class
    {
    var result : Class = TrafficAssetDictionary.
                               getInstance().lookup(category, severity);
    
    return result;	
    }
    
    

    So the severity renderer now calls a singleton which contains the lookup table. The original code was this:

    
    public function lookup(category:String, severity:String):Class
    {
    var item:Class = null;
                
    item= assetDict[category][severity];
    
    if (item==null) 
       item = assetDict[TXT_UNKNOWN][TXT_SEVERITY_SLIGHT];
                
    return item;
    }
    

    So far so good but I noticed that some rows didn’t have an icon. A little debugging later and I discovered that my assumption that the Dictionary lookup would return null if it couldn’t find a match was incorrect (some categories are not included in the lookup, too much work). What was happening instead was that a silent exception was being thrown. This didn’t show up even in debug mode which was a little disconcerting and meant I was scratching my head quite a lot.

    The solution is that you have to put a try..catch around a dictionary lookup to see if it fails:

    
    public function lookup(category:String, severity:String):Class
    {
    var item:Class = null;
                
    try
    {
    item= assetDict[category][severity];
    }
    catch (e:Error)
    {
    item = assetDict[TXT_UNKNOWN][TXT_SEVERITY_SLIGHT];
    }
                
    return item;
    }
    

    It would be nice I think if Flex would adopt the java Hashmap functionality and return a null for a failed lookup.

    Flex: Cairngorm 2.2 Events

    I have been updating my flex version of gTraffic to the recently released version of Cairngorm. One of the changes it that there is a new means of dispatching Cairngorm events. It used to be:

    
    CairngormEventDispatcher.getInstance().
    dispatchEvent(new GetRegionsEvent());
    

    and now it’s

    
    var event:CairngormEvent = new GetRegionsEvent();
    event.dispatch();
    

    I have a problem with this which is that it’s not very explicit especially if you rewrite it as:

    
    var event:GetRegionsEvent = new GetRegionsEvent();
    event.dispatch();
    

    At least the original way you were firmly in Cairngorm-land and knew it. If you rewrite it the second way then looking at it it doesn’t seem totally clear unless you are aware that only CairngormEvent has a dispatch method.

    I guess the Cairngorm guys know what they are doing but experience has taught me to be very wary of putting in a ‘shortcut’ like this. Too much scope to confuse a developer looking at a Flex/Cairngorm application which might have a mix of both Flex bog-standard events and Cairngorm events.

    Next Page →