Pacific Side

23 March 2010

News Video Map

News Video Map

News Video Map

The most natural way of presenting world news content to me is on a map. Even without one presented to me, a geographical schema is my mind's automatic way of visualizing a list of world news articles or videos. My goal was to take a collection of world news video from providers like the AP, Reuters, and AFP, associate the content with geographic locations, and plot the results on a map.

This started as a one-day project I worked on for one of the Yahoo! Hack Days last year, and I've been playing with it since then when I have time. Hover over video clip thumbnails for a full second to open a preview of the associated video clip. Click on the play button in the preview to view the video.

The mashup combines data services and tools from the following Yahoo! providers:




It also relies on for Flash embedding and this free image resizing proxy called Images.weserv.nl.

On the backend, there's a cron job that executes the PHP layer every hour. The PHP layer takes the Yahoo! News video feed for the World News category from the past seven days and runs all the video titles and descriptions through Yahoo! Placemaker to assign geographic locations to each one in latitudinal and longitudinal coordinates. The PHP layer then creates a JavaScript array of JSON objects from the data. For production use, it then rolls up the JSON data with the required JavaScript libraries and initialization script. The JavaScript layer creates the map and plots each video with a degree of randomization to prevent video clip thumbnails from stacking on top of one another.

The major issue to overcome in development was the amount of time required for data processing. Initially, the mashup fired an AJAX request to the PHP API that returned fresh data per request. It was taking over ten seconds for the page to load each request though, so I added a five minute cache to the API. The unfortunate user who hit a stale cache still had to wait over ten seconds for the page to load. In the end, I decided that since the purpose of the service is to provide a snapshot of videos from the previous week, it's not particularly important that the data be fresh to the minute. I switched to a cron-driven script that updates the JavaScript every hour, making it available in native JSON at page load rather than via a delayed AJAX request for XML. I also made a number of optimizations to the frontend — removing duplicate scripts loaded by the Yahoo! Maps API, rolling up all required JavaScript into one file, deleting data from memory when it's no longer needed, etc. Before putting this into full-scale production I would want to use an enterprise-grade image resizing proxy to scale the video clip thumbnails before they are loaded. As it is, it's faster to load the larger thumbnails directly from the cache server than to pass them through the free image resizing proxy.

Update: Have switched to enterprise-grade image resizing. It's more reliable than the free proxy and makes everything a lot faster. :)

Language

Archives

Categories

Trevor Powell © 2015. All rights reserved.