POSIT:Real Time Updating Notes

From Notes

Jump to: navigation, search
   * Last Edited - Tuesday August 3, 2010
   * About - Real Time Updating of Map Display




  • Comet - A model in which an http request is held by the server, allowing it to push data to the browser without a request.
  • AJAX (Asynchronous JavaScript and XML) - A way of retrieving data from the server asynchronously without interfering with the browser's display.
  • PHP (PHP: Hypertext Preprocessor) - A scripting language used for the server of POSIT. Everyone seems to despise it.


One of the features we wanted to add to the map of finds and expeditions was instantaneous updating. Ideally, this would involve the server pushing new expedition points and finds to the client as they were received. Theoretically, this can be accomplished through the use of a comet. Unfortunately, comets can't be implemented efficiently in PHP, so we had to rely on AJAX queries to retrieve updates. Using this method, updates will be retrieved every 20 seconds before being displayed on the map. When there is a large number of expeditions, a noticeable amount of lag occurs during updates, so only expeditions that are checked will be updates. Additionally, real time updating is turned off by default and can be enabled using a checkbox displayed by the map.


On the server side, real time updating is handled by an ajax controller which handles ajax client requests by retrieving coordinates or timestamps from the database in use. Using the timestamps of the last point in an expedition and the last find in a project that are included in most of the ajax requests, the server returns any new points or finds to the client.

On the client side, real time updating begins when the tilesloaded event of the map is complete. After this occurs, ajax requests (separated by 200 ms) are sent out for each expedition to retrieve the time at which the last point was uploaded. An additional request is also sent out to retrieve the time stamp of the last find added to the project. Ten seconds after the tilesloaded event, ajax requests are sent out for each checked expedition. Following this the overlay element for the expedition is deleted and redrawn with any new points that have been added. After these requests are finished, an ajax query is sent out to retrieve any new finds, which are added to the map if they exist. When all of these queries have finished, a second set of queries is sent to retrieve new timestamps for each expedition and the project itself.

Problems/Known issues

  • Lag is the largest issue. The sheer number of requests sent causes noticeable delay whenever an update occurs. This could probably be improved by getting rid of the separate time stamp requests with each update.
  • The delay that occurs between updates is another large issue that also needs to be fixed. Having updates every 20 seconds is a necessary concession to the concerns about lag, but this means that the updating isn't close to occurring in real time. Creating a separate server to handle comets is probably the best solution at this point.
Personal tools
NSF K-12